[syslinux] [PATCH 18/20] elflink: Don't require every module to have init/exit functions
Matt Fleming
matt at console-pimps.org
Sat Apr 16 07:17:46 PDT 2011
From: Matt Fleming <matt.fleming at linux.intel.com>
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 at linux.intel.com>
---
com32/lib/sys/module/elf_module.c | 31 ++++++++++++-------------------
1 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index afb5b64..8db4220 100644
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -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)
--
1.7.4.2
More information about the Syslinux
mailing list