[U-Boot] [PATCH 1/1] armv7: start.S: Fix relocation address caculation

Jason Liu r64343 at freescale.com
Wed Dec 15 14:57:59 CET 2010


There will have issue if the _start not equal TEXT_BASE
when enable relocation. The reason is as the followings,

The _dynsym_start_ofs and _rel_dyn_start_ofs is the
offset from _start, so, need use _start address instead
of _TEXT_BASE to caculate the rel dyn start and sym table
address. This patch also correct the board_init_r function
address caculation in relocation area. The addr of board_init_r
after relocation is: _board_init_r_offs + relocation start address.

This patch also make code cleanup by removing some useless code

Signed-off-by: Jason Liu <r64343 at freescale.com>
---
 arch/arm/cpu/armv7/start.S |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index 684f2d2..08902b0 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -171,7 +171,6 @@ stack_setup:
 	beq	clear_bss		/* skip relocation */
 #endif
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r2, _TEXT_BASE
 	ldr	r3, _bss_start_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
@@ -185,7 +184,7 @@ copy_loop:
 	/*
 	 * fix .rel.dyn relocations
 	 */
-	ldr	r0, _TEXT_BASE		/* r0 <- Text base */
+	adr     r0, _start
 	sub	r9, r6, r0		/* r9 <- relocation offset */
 	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */
 	add	r10, r10, r0		/* r10 <- sym table in FLASH */
@@ -224,7 +223,6 @@ fixnext:
 clear_bss:
 	ldr	r0, _bss_start_ofs
 	ldr	r1, _bss_end_ofs
-	ldr	r3, _TEXT_BASE		/* Text base */
 	mov	r4, r6			/* reloc addr */
 	add	r0, r0, r4
 	add	r1, r1, r4
@@ -242,9 +240,7 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
  */
 jump_2_ram:
 	ldr	r0, _board_init_r_ofs
-	adr	r1, _start
-	add	lr, r0, r1
-	add	lr, lr, r9
+	add	lr, r0, r4
 	/* setup parameters for board_init_r */
 	mov	r0, r5		/* gd_t */
 	mov	r1, r6		/* dest_addr */
-- 
1.7.0.4




More information about the U-Boot mailing list