diff mbox

[U-Boot] ARM: check relocation

Message ID 1288468093-5748-1-git-send-email-holler@ahsoftware.de
State Superseded
Headers show

Commit Message

Alexander Holler Oct. 30, 2010, 7:48 p.m. UTC
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@ahsoftware.de>
---
 arch/arm/lib/board.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
diff mbox

Patch

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