[U-Boot] [PATCH] ARM: check relocation

Alexander Holler holler at ahsoftware.de
Sat Oct 30 21:48:13 CEST 2010


Relocation fails here using gcc 4.3.4 or gcc 4.5.1.
So it seems to be a good idea to check this on startup
and print a warning if it failed.

If relocation proved to be correct for ARM, this commit could just be reverted
or put inside #ifdef DEBUG.

Signed-off-by: Alexander Holler <holler at ahsoftware.de>
---
 arch/arm/lib/board.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 1fd5f83..2f3c7fe 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -469,6 +469,13 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 	debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
 
+	/* Check if relocation was ok, dest_addr is the relocated _TEXT_BASE */
+	if ( ! ( _bss_start_ofs + dest_addr <= (ulong)&monitor_flash_len && (ulong)&monitor_flash_len < _bss_end_ofs + dest_addr) ) {
+		printf("(relocated) BSS is from %08lx to %08lx\n", _bss_start_ofs + dest_addr, _bss_end_ofs + dest_addr);
+		printf("&monitor_flash_len: %p\n", &monitor_flash_len);
+		puts("WARNING: relocation failed (&monitor_flash_len is outside reloctated BSS)!\n");
+	}
+
 #ifdef CONFIG_LOGBUFFER
 	logbuff_init_ptrs ();
 #endif
-- 
1.7.2.3



More information about the U-Boot mailing list