elflink: Don't require every module to have init/exit functions
authorMatt Fleming <matt.fleming@linux.intel.com>
Fri, 15 Apr 2011 20:10:55 +0000 (21:10 +0100)
committerMatt Fleming <matt.fleming@linux.intel.com>
Tue, 26 Apr 2011 09:06:25 +0000 (10:06 +0100)
Don't complain or refuse to load a module if it doesn't contain an
init or exit function, as many of the init/exit functions are in fact
empty.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
com32/lib/sys/module/elf_module.c

index afb5b64..8db4220 100644 (file)
@@ -390,27 +390,20 @@ static int extract_operations(struct elf_module *module) {
        Elf32_Sym *exit_sym = module_find_symbol(MODULE_ELF_EXIT_PTR, module);
        Elf32_Sym *main_sym = module_find_symbol("main", module);
 
-       if (init_sym == NULL) {
-               DBG_PRINT("Cannot find initialization routine pointer.\n");
-               printf("Cannot find initialization routine pointer.\n");
-               return -1;
-       }
-       if (exit_sym == NULL) {
-               DBG_PRINT("Cannot find exit routine pointer.\n");
-               printf("Cannot find exit routine pointer.\n");
-               return -1;
-       }
-
-       module->init_func = (module_init_t*)module_get_absolute(
-                                                               init_sym->st_value, module);
-       if (*(module->init_func) == NULL) {
-               module->init_func = NULL;
+       if (init_sym) {
+               module->init_func = (module_init_t*)module_get_absolute(
+                       init_sym->st_value, module);
+               if (*(module->init_func) == NULL) {
+                       module->init_func = NULL;
+               }
        }
 
-       module->exit_func = (module_exit_t*)module_get_absolute(
-                                                               exit_sym->st_value, module);
-       if (*(module->exit_func) == NULL) {
-               module->exit_func = NULL;
+       if (exit_sym) {
+               module->exit_func = (module_exit_t*)module_get_absolute(
+                       exit_sym->st_value, module);
+               if (*(module->exit_func) == NULL) {
+                       module->exit_func = NULL;
+               }
        }
 
        if (main_sym)