[syslinux:elflink] elflink: Don't reload the current EXEC_MODULE module

syslinux-bot for Matt Fleming matt.fleming at linux.intel.com
Mon Mar 14 15:33:53 PDT 2011


Commit-ID:  1357b7e627064e7c498ae6107b141c3d2aed3a46
Gitweb:     http://syslinux.zytor.com/commit/1357b7e627064e7c498ae6107b141c3d2aed3a46
Author:     Matt Fleming <matt.fleming at linux.intel.com>
AuthorDate: Mon, 7 Mar 2011 23:02:35 +0000
Committer:  Matt Fleming <matt.fleming at linux.intel.com>
CommitDate: Wed, 9 Mar 2011 14:32:36 +0000

elflink: Don't reload the current EXEC_MODULE module

As the ldlinux.c32 ELF module is an executable (EXEC_MODULE) and not a
library (LIB_MODULE), we need to make sure we don't reload it when
another executable wants to resolve a symbol exported by ldlinux.

Whenever an EXEC_MODULE module is loaded its MODULE_MAIN function is
executed. In the case of ldlinux, the MODULE_MAIN function drops the
user at a command line. So, what currently happens is that if we load
an executable module, say menu.c32, which needs symbols exported by
ldlinux and ldlinux is already loaded and running, we'll reload
ldlinux when resolving undefined symbols from menu.c32 and end up
dropping the user at a command prompt and _not_ resolve the symbols
and return control to menu.c32's MODULE_MAIN function. ldlinux.c32
effectively steals control of the proces.

Signed-off-by: Matt Fleming <matt.fleming at linux.intel.com>


---
 com32/lib/sys/module/exec.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c
index 0e7aa3f..03d11cb 100644
--- a/com32/lib/sys/module/exec.c
+++ b/com32/lib/sys/module/exec.c
@@ -237,11 +237,23 @@ int spawn_load(const char *name,const char **argv)
 	if (module == NULL)
 		return -1;
 
-	/* ugly hack to reload the same module */
 	if (!strcmp(cur_module->name, module->name)) {
 		mp("We is running this module %s already!", module->name);
-		module_unload(cur_module);
-		cur_module = NULL;
+
+		/*
+		 * If we're already running the module and it's of
+		 * type EXEC_MODULE, then just return. We don't reload
+		 * the module because that might cause us to re-run
+		 * the init functions, which will cause us to run the
+		 * MODULE_MAIN function, which will take control of
+		 * this process.
+		 *
+		 * This can happen if some other EXEC_MODULE is
+		 * resolving a symbol that is exported by the current
+		 * EXEC_MODULE.
+		 */
+		if (get_module_type(module) == EXEC_MODULE)
+			return 0;
 	}
 
 	res = module_load(module);



More information about the Syslinux-commits mailing list