summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Dgien <dgienda125@gmail.com>2020-06-29 20:38:33 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2020-07-01 07:21:25 +0200
commitc788931fb16f136c2e09e59022dabb242d4d3ba3 (patch)
tree05075d4ffeaea81a280e58af3e09e1a575201521
parente84ccc449afc2371fbe058fa9b58bc2d23056b27 (diff)
downloadbarebox-c788931fb16f136c2e09e59022dabb242d4d3ba3.tar.gz
barebox-c788931fb16f136c2e09e59022dabb242d4d3ba3.tar.xz
module: Fix adding module to list after layout
During load_module(), the 'this_module' section is relocated, but the pointer to the module struct isn't updated to account account for the move. Do so before adding the module to the module_list. As a side effect of properly pointing to the relocated module struct, we no longer need to manually search for and fixup the init_module symbol, so remove that code. Signed-off-by: David Dgien <dgienda125@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/module.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/common/module.c b/common/module.c
index 829c120007..5ace544e07 100644
--- a/common/module.c
+++ b/common/module.c
@@ -297,13 +297,8 @@ struct module * load_module(void *mod_image, unsigned long len)
}
}
- for (i = 0; i < numsyms; i++) {
- if (!strcmp(strtab + sym[i].st_name, MODULE_SYMBOL_PREFIX "init_module")) {
- printf("found init_module() at 0x%08x\n", sym[i].st_value);
- module->init = (void *)sym[i].st_value;
- }
- }
-
+ /* Module has been moved */
+ module = (void *)sechdrs[modindex].sh_addr;
list_add_tail(&module->list, &module_list);
return module;
@@ -311,8 +306,6 @@ struct module * load_module(void *mod_image, unsigned long len)
cleanup:
if (ptr)
free(ptr);
- if (module)
- free(module);
return NULL;
}