[PATCH] relocation: Use C-functions to do relocate the GOT & fixups.

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Tue Sep 22 23:24:46 CEST 2009


---
 cpu/mpc83xx/start.S |   29 ++++++++---------------------
 lib_ppc/board.c     |   31 +++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/cpu/mpc83xx/start.S b/cpu/mpc83xx/start.S
index 26e3106..868b070 100644
--- a/cpu/mpc83xx/start.S
+++ b/cpu/mpc83xx/start.S
@@ -950,35 +950,22 @@ in_ram:
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
 	 */
-	li	r0,__got2_entries at sectoff@l
 	la	r3,GOT(_GOT2_TABLE_)
-	lwz	r11,GOT(_GOT2_TABLE_)
-	mtctr	r0
-	sub	r11,r3,r11
-	addi	r3,r3,-4
-1:	lwzu	r0,4(r3)
-	add	r0,r0,r11
-	stw	r0,0(r3)
-	bdnz	1b
+	li	r4,__got2_entries at sectoff@l
+	lwz	r5,GOT(_GOT2_TABLE_)
+	sub	r5,r3,r5
+	mr	r30,r5
+	bl	__eabi_convert

 #ifndef CONFIG_NAND_SPL
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
-	cmpwi	r0,0
-	mtctr	r0
-	addi	r3,r3,-4
-	beq	4f
-3:	lwzu	r4,4(r3)
-	lwzux	r0,r4,r11
-	add	r0,r0,r11
-	stw	r10,0(r3)
-	stw	r0,0(r4)
-	bdnz	3b
-4:
+	li	r4,__fixup_entries at sectoff@l
+	mr	r5,r30
+	bl	__eabi_uconvert
 #endif

 clear_bss:
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 9e944fa..0afc7c3 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -148,6 +148,37 @@ static	ulong	mem_malloc_brk	 = 0;
  ************************************************************************
  */

+/* Relocate the .got2 pointers.  */
+void __eabi_convert(unsigned long *low, unsigned long len,
+		    unsigned long addend)
+{
+	unsigned long val;
+
+	for(--low; len; --len) {
+		val = *++low;
+		if (!val)
+			continue;
+		*low = val + addend;
+	}
+}
+/* Fixup any user initialized pointers (the compiler drops pointers to */
+/* each of the relocs that it does in the .fixup section).  */
+void __eabi_uconvert(unsigned long *low, unsigned long len,
+		     unsigned long addend)
+{
+	unsigned long val, *v2p, val2;
+
+	for(--low; len; --len) {
+		val = *++low;
+		val += addend;
+		*low = val;
+		v2p = (unsigned long *)val;
+		val2 = *v2p;
+		val2 += addend;
+		*v2p = val2;
+	}
+}
+
 /*
  * The Malloc area is immediately below the monitor copy in DRAM
  */
--
1.6.4.4




More information about the U-Boot mailing list