[Scummvm-cvs-logs] SF.net SVN: scummvm:[52730] scummvm/branches/gsoc2010-plugins

dhewg at users.sourceforge.net dhewg at users.sourceforge.net
Wed Sep 15 09:44:08 CEST 2010


Revision: 52730
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52730&view=rev
Author:   dhewg
Date:     2010-09-15 07:44:08 +0000 (Wed, 15 Sep 2010)

Log Message:
-----------
PLUGINS: Additional plugin check for the ELF loader.

The ELF loader does not have access to the symbols of the main
executable, it just relocates symbols to it via fixed offsets. We need
to make sure that loaded plugins are from the same link process to
prevent crashes. An embedded build date is used for that.

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/Makefile.common
    scummvm/branches/gsoc2010-plugins/backends/module.mk
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.h
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf/plugin.syms
    scummvm/branches/gsoc2010-plugins/base/plugins.h
    scummvm/branches/gsoc2010-plugins/configure

Added Paths:
-----------
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.h

Modified: scummvm/branches/gsoc2010-plugins/Makefile.common
===================================================================
--- scummvm/branches/gsoc2010-plugins/Makefile.common	2010-09-15 07:43:34 UTC (rev 52729)
+++ scummvm/branches/gsoc2010-plugins/Makefile.common	2010-09-15 07:44:08 UTC (rev 52730)
@@ -54,6 +54,10 @@
 # the build date in gScummVMBuildDate is correct.
 base/version.o: $(filter-out base/libbase.a,$(OBJS))
 
+ifdef USE_ELF_LOADER
+backends/plugins/elf/version.o: $(filter-out base/libbase.a,$(filter-out backends/libbackends.a,$(OBJS)))
+endif
+
 # Replace regular output with quiet messages
 ifneq ($(findstring $(MAKEFLAGS),s),s)
 ifneq ($(VERBOSE_BUILD),1)

Modified: scummvm/branches/gsoc2010-plugins/backends/module.mk
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/module.mk	2010-09-15 07:43:34 UTC (rev 52729)
+++ scummvm/branches/gsoc2010-plugins/backends/module.mk	2010-09-15 07:44:08 UTC (rev 52730)
@@ -28,6 +28,7 @@
 	plugins/elf/ppc-loader.o \
 	plugins/elf/arm-loader.o \
 	plugins/elf/elf-provider.o \
+	plugins/elf/version.o \
 	plugins/dc/dc-provider.o \
 	plugins/posix/posix-provider.o \
 	plugins/sdl/sdl-provider.o \

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.cpp	2010-09-15 07:43:34 UTC (rev 52729)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.cpp	2010-09-15 07:44:08 UTC (rev 52730)
@@ -112,6 +112,19 @@
 		return false;
 	}
 
+	CharFunc buildDateFunc = (CharFunc)findSymbol("PLUGIN_getBuildDate");
+	if (!buildDateFunc) {
+		unloadPlugin();
+		warning("elfloader: plugin '%s' is missing symbols", _filename.c_str());
+		return false;
+	}
+
+	if (strncmp(gScummVMPluginBuildDate, buildDateFunc(), strlen(gScummVMPluginBuildDate))) {
+		unloadPlugin();
+		warning("elfloader: plugin '%s' has a different build date", _filename.c_str());
+		return false;
+	}
+
 	bool ret = DynamicPlugin::loadPlugin();
 
 #ifdef ELF_LOADER_CXA_ATEXIT

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.h	2010-09-15 07:43:34 UTC (rev 52729)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.h	2010-09-15 07:44:08 UTC (rev 52730)
@@ -45,6 +45,8 @@
  */
 class ELFPlugin : public DynamicPlugin {
 protected:
+	typedef const char *(*CharFunc)();
+
 	DLObject *_dlHandle;
 	Common::String _filename;
 	void *_dso_handle;

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/plugin.syms
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/plugin.syms	2010-09-15 07:43:34 UTC (rev 52729)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/plugin.syms	2010-09-15 07:44:08 UTC (rev 52730)
@@ -1,3 +1,4 @@
+PLUGIN_getBuildDate
 PLUGIN_getVersion
 PLUGIN_getType
 PLUGIN_getTypeVersion

Added: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.cpp	2010-09-15 07:44:08 UTC (rev 52730)
@@ -0,0 +1,32 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "backends/plugins/elf/version.h"
+
+#ifdef USE_ELF_LOADER
+const char *gScummVMPluginBuildDate __attribute__((visibility("hidden"))) =
+	__DATE__ " " __TIME__ ;
+#endif
+


Property changes on: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Added: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.h	                        (rev 0)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.h	2010-09-15 07:44:08 UTC (rev 52730)
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef BACKENDS_PLUGINS_ELF_VERSION_H
+#define BACKENDS_PLUGINS_ELF_VERSION_H
+
+#include "common/scummsys.h"
+
+#ifdef USE_ELF_LOADER
+extern const char *gScummVMPluginBuildDate;
+#endif
+
+#endif
+


Property changes on: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/version.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2010-plugins/base/plugins.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/plugins.h	2010-09-15 07:43:34 UTC (rev 52729)
+++ scummvm/branches/gsoc2010-plugins/base/plugins.h	2010-09-15 07:44:08 UTC (rev 52730)
@@ -30,6 +30,7 @@
 #include "common/error.h"
 #include "common/singleton.h"
 #include "common/util.h"
+#include "backends/plugins/elf/version.h"
 
 namespace Common {
 	class FSList;
@@ -98,6 +99,13 @@
 #define PLUGIN_DYNAMIC_DSO_HANDLE
 #endif
 
+#ifdef USE_ELF_LOADER
+#define PLUGIN_DYNAMIC_BUILD_DATE \
+	PLUGIN_EXPORT const char *PLUGIN_getBuildDate() { return gScummVMPluginBuildDate; }
+#else
+#define PLUGIN_DYNAMIC_BUILD_DATE
+#endif
+
 /**
  * REGISTER_PLUGIN_STATIC is a convenience macro which is used to declare
  * the plugin interface for static plugins. Code (such as game engines)
@@ -128,6 +136,7 @@
 #define REGISTER_PLUGIN_DYNAMIC(ID,TYPE,PLUGINCLASS) \
 	extern "C" { \
 		PLUGIN_DYNAMIC_DSO_HANDLE \
+		PLUGIN_DYNAMIC_BUILD_DATE \
 		PLUGIN_EXPORT int32 PLUGIN_getVersion() { return PLUGIN_VERSION; } \
 		PLUGIN_EXPORT int32 PLUGIN_getType() { return TYPE; } \
 		PLUGIN_EXPORT int32 PLUGIN_getTypeVersion() { return TYPE##_VERSION; } \

Modified: scummvm/branches/gsoc2010-plugins/configure
===================================================================
--- scummvm/branches/gsoc2010-plugins/configure	2010-09-15 07:43:34 UTC (rev 52729)
+++ scummvm/branches/gsoc2010-plugins/configure	2010-09-15 07:44:08 UTC (rev 52730)
@@ -2112,7 +2112,7 @@
 PLUGIN_PREFIX		:=
 PLUGIN_SUFFIX		:= .plg
 PLUGIN_EXTRA_DEPS	= $(EXECUTABLE)
-PLUGIN_LDFLAGS		= -nostartfiles -Wl,-q,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms
+PLUGIN_LDFLAGS		= -nostartfiles backends/plugins/elf/version.o -Wl,-q,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms
 PRE_OBJS_FLAGS		:= -Wl,--whole-archive
 POST_OBJS_FLAGS		:= -Wl,--no-whole-archive
 '"$_mak_plugins"


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list