aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/sys/module/elf_module.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/lib/sys/module/elf_module.c')
-rw-r--r--com32/lib/sys/module/elf_module.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index 3e373847..7d892aa9 100644
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -513,11 +513,15 @@ int module_load(struct elf_module *module) {
/*
* nr_needed can be modified by recursive calls to
* module_load() so keep a local copy on the stack.
+ *
+ * Note that we have to load the dependencies in
+ * reverse order.
*/
- n = nr_needed;
- for (i = 0; i < n; i++) {
+ n = nr_needed - 1;
+ for (i = n; i >= 0; i--) {
size_t len, j;
char *dep, *p;
+ char *argv[2] = { NULL, NULL };
dep = module->str_table + needed[i];
@@ -526,16 +530,14 @@ int module_load(struct elf_module *module) {
if (!len)
continue;
- p = dep + len - 1;
- while (j > 0 && *p && *p != '/') {
- p--;
- j--;
- }
+ if (strchr(dep, '/')) {
+ p = strrchr(dep, '/');
+ p++;
+ } else
+ p = dep;
- if (*p++ == '/') {
- char *argv[2] = { p, NULL };
- spawn_load(p, 1, argv);
- }
+ argv[0] = p;
+ spawn_load(p, 1, argv);
}
}