module: Allow .c32 files to execute themselves
authorMatt Fleming <matt.fleming@intel.com>
Thu, 10 Jan 2013 13:39:50 +0000 (13:39 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Thu, 10 Jan 2013 14:02:19 +0000 (14:02 +0000)
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@intel.com>
com32/lib/sys/module/exec.c

index 559bafc..ac9ca79 100644 (file)
@@ -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
-                * EXEC_MODULE.
-                */
-               if (get_module_type(module) == EXEC_MODULE)
-                       return 0;
+               module_unload(cur_module);
+               cur_module = NULL;
        }
 
        res = module_load(module);