Skip to contentSkip to conversation

ARM: check relocation

PATCH New Alexander Holler 1 participant 1 message Oct 30, 2010 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: check relocation

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.

---
 arch/arm/lib/board.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/lib/board.c +7 -0
index 1fd5f83..2f3c7fe 100644
@@ -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
Signature · 1 line
1.7.2.3