[U-Boot] [PATCH 2/4] ARM: don't relocate if we are already too high
Alessandro Rubini
rubini at gnudd.com
Mon Apr 18 11:20:53 CEST 2011
Signed-off-by: Alessandro Rubini <rubini at 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
More information about the U-Boot
mailing list