summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/rmodule.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c
index 81e9ef10ed..4276ed33e8 100644
--- a/src/lib/rmodule.c
+++ b/src/lib/rmodule.c
@@ -241,13 +241,17 @@ int rmodule_load(void *base, struct rmodule *module)
* In order to load the module at a given address, the following steps
* take place:
* 1. Copy payload to base address.
- * 2. Clear the bss segment.
- * 3. Adjust relocations within the module to new base address.
+ * 2. Adjust relocations within the module to new base address.
+ * 3. Clear the bss segment last since the relocations live where
+ * the bss is. If an rmodule is being loaded from its load
+ * address the relocations need to be processed before the bss.
*/
module->location = base;
rmodule_copy_payload(module);
+ if (rmodule_relocate(module))
+ return -1;
rmodule_clear_bss(module);
- return rmodule_relocate(module);
+ return 0;
}
void *rmodule_find_region_below(void *addr, size_t rmodule_size,