summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--com32/lib/sys/module/elf_module.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index c92fe266..8a8ed20e 100644
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -492,6 +492,7 @@ int module_load(struct elf_module *module) {
Elf32_Sym *main_sym;
Elf32_Ehdr elf_hdr;
module_ctor_t *ctor;
+ struct elf_module *head = NULL;
// Do not allow duplicate modules
if (module_find(module->name) != NULL) {
@@ -525,6 +526,8 @@ int module_load(struct elf_module *module) {
CHECKED(res, prepare_dynlinking(module), error);
//printf("check... 4\n");
+ head = list_entry(&modules_head, typeof(*head), list);
+
/* Find modules we need to load as dependencies */
if (module->str_table) {
int i;
@@ -550,7 +553,11 @@ int module_load(struct elf_module *module) {
p = dep;
argv[0] = p;
- spawn_load(p, 1, argv);
+ res = spawn_load(p, 1, argv);
+ if (res < 0) {
+ printf("Failed to load %s\n", p);
+ goto error;
+ }
}
}
@@ -595,6 +602,9 @@ int module_load(struct elf_module *module) {
return 0;
error:
+ if (head)
+ unload_modules_since(head->name);
+
// Remove the module from the module list (if applicable)
list_del_init(&module->list);