[syslinux:elflink] module: Allow .c32 files to execute themselves

syslinux-bot for Matt Fleming matt.fleming at intel.com
Fri Jan 11 01:36:04 PST 2013

Commit-ID:  04cf121216bf2d5c6fc9e01028519f7d655d66cf
Gitweb:     http://www.syslinux.org/commit/04cf121216bf2d5c6fc9e01028519f7d655d66cf
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 10 Jan 2013 13:39:50 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 10 Jan 2013 14:02:19 +0000

module: Allow .c32 files to execute themselves

Historically, .c32 files had to explicitly link against ldlinux.c32 in
order to use its exported symbols. This lead to the undesirable
situation during module dependency resolution where loading,
e.g. menu.c32, would cause ldlinux.c32 to be reloaded, thus
re-executing its main() function and dropping the user at a prompt
instead of executing menu.c32.

commit 1357b7e62706 ("elflink: Don't reload the current EXEC_MODULE
module") was the solution to this problem, since you don't need to
reload a module to link against it's symbols. Unfortunately, while
this commit was intended to stop ldlinux.c32 being reloaded, it also
broke the use case where a .c32 wants to load itself, e.g. when
vesamenu.c32 wants to execute vesamenu.c32 with a different config.

Luckily, modules no longer need to include ldlinux.c32 in their
dependency list, since ldlinux.c32 is *always* loaded and any symbols
can be automatically resolved. Which means that the check in
spawn_load() can be deleted.

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

 com32/lib/sys/module/exec.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c
index 559bafc..ac9ca79 100644
--- a/com32/lib/sys/module/exec.c
+++ b/com32/lib/sys/module/exec.c
@@ -203,20 +203,8 @@ int spawn_load(const char *name, int argc, char **argv)
 	if (!strcmp(cur_module->name, module->name)) {
 		dprintf("We is running this module %s already!", module->name);
-		/*
-		 * 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
-		 * 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
-		 */
-		if (get_module_type(module) == EXEC_MODULE)
-			return 0;
+		module_unload(cur_module);
+		cur_module = NULL;
 	res = module_load(module);

More information about the Syslinux-commits mailing list