Signed-off-by: Alessandro Rubini <rub...@gnudd.com> --- arch/arm/lib/board.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index dc46e21..dab70b5 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -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); -- 1.5.6.5 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot