@@ -423,8 +423,29 @@ void board_init_f (ulong bootflag)
gd->relocaddr = addr;
gd->start_addr_sp = addr_sp;
gd->reloc_off = addr - _TEXT_BASE;
+
+ /*
+ * Destination is higher than current address, but may overlap
+ * our address range. If so, pass the source address as destination
+ * address so the asm will not relocate and only clear bss
+ */
+ if ((addr_sp - 256) < _bss_start_ofs+_TEXT_BASE) {
+ debug("Won't fit above us: disabling relocation\n");
+ if (gd->reloc_off < 0) {
+ printf("Can't relocate to lower ram, currently\n");
+ hang();
+ }
+ addr -= gd->reloc_off;
+ addr_sp -= gd->reloc_off;
+ gd->start_addr_sp = addr_sp;
+ id -= gd->reloc_off;
+ gd->reloc_off = 0;
+ }
+
+
debug ("relocation Offset is: %08lx\n", gd->reloc_off);
- memcpy (id, (void *)gd, sizeof (gd_t));
+ if (id != (void *)gd)
+ memcpy (id, (void *)gd, sizeof (gd_t));
relocate_code (addr_sp, id, addr);
Signed-off-by: Alessandro Rubini <rubini@gnudd.com> --- arch/arm/lib/board.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-)