[coreboot] Patch set updated for coreboot: 15f7993 rmodule: correct ordering of bss clearing

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Tue Mar 19 20:27:40 CET 2013


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2822

-gerrit

commit 15f7993590b90e61ee85ce4bf1d9a3e8b5b5787f
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Fri Mar 1 17:00:39 2013 -0600

    rmodule: correct ordering of bss clearing
    
    This patch fixes an issue for rmodules which are copied into memory
    at the final load/link location. If the bss section is cleared for
    that rmodule the relocation could not take place properly since the
    relocation information was wiped by act of clearing the bss. The
    reason is that the relocation information resides at the same
    address as the bss section. Correct this issue by performing the
    relocation before clearing the bss.
    
    Change-Id: I01a124a8201321a9eaf6144c743fa818c0f004b4
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 src/lib/rmodule.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c
index 60c89f0..d36f9f3 100644
--- a/src/lib/rmodule.c
+++ b/src/lib/rmodule.c
@@ -241,14 +241,18 @@ static int __rmodule_load(void *base, struct rmodule *module, int clear_bss)
 	 * 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;
 	if (clear_bss)
 		rmodule_clear_bss(module);
-	return rmodule_relocate(module);
+	return 0;
 }
 
 int rmodule_load(void *base, struct rmodule *module)



More information about the coreboot mailing list