public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address
@ 2014-05-14 22:05 Darwin Rambo
  2014-05-14 22:41 ` Jeroen Hofstee
  2014-05-15  4:26 ` Wolfgang Denk
  0 siblings, 2 replies; 31+ messages in thread
From: Darwin Rambo @ 2014-05-14 22:05 UTC (permalink / raw)
  To: u-boot

If an earlier loader stage requires an image header and a specific
offset, then u-boot's base address (CONFIG_SYS_TEXT_BASE) may be
advanced beyond an aligned address. In this case the relocation
will not be done correctly for some sections such as vectors and rodata
string tables, which will show an incorrect offset after the symbols
are fixed up. Advance the relocation address by the image offset so that
the gd->reloc_off used will result in relocating these sections to their
correct addresses.

This change is done under CONFIG_ARM64 conditional compilation
because it has only been tested there and may not be appropriate
for other architectures.

Signed-off-by: Darwin Rambo <drambo@broadcom.com>
Reviewed-by: Steve Rae <srae@broadcom.com>
---

 arch/arm/lib/board.c |   13 +++++++++++++
 common/board_f.c     |   10 ++++++++++
 2 files changed, 23 insertions(+)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 9b473b5..df520cc 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -449,6 +449,19 @@ void board_init_f(ulong bootflag)
 	dram_init_banksize();
 	display_dram_config();	/* and display it */
 
+#ifdef CONFIG_ARM64
+	/*
+	 * Fix relocation if u-boot is not on an aligned address.
+	 */
+	{
+		int offset = CONFIG_SYS_TEXT_BASE % 4096;
+		if (offset) {
+			addr += offset;
+			debug("Relocation Addr bumped to 0x%08lx\n", addr);
+		}
+	}
+#endif
+
 	gd->relocaddr = addr;
 	gd->start_addr_sp = addr_sp;
 	gd->reloc_off = addr - (ulong)&_start;
diff --git a/common/board_f.c b/common/board_f.c
index 4ea4cb2..1035d6f 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -728,6 +728,16 @@ static int reloc_fdt(void)
 
 static int setup_reloc(void)
 {
+#ifdef CONFIG_ARM64
+	/*
+	 * Fix relocation if u-boot is not on an aligned address.
+	 */
+	int offset = CONFIG_SYS_TEXT_BASE % 4096;
+	if (offset) {
+		gd->relocaddr += offset;
+		debug("Relocation Addr bumped to 0x%08lx\n", gd->relocaddr);
+	}
+#endif
 	gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
 	memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2014-06-25 12:52 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-14 22:05 [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address Darwin Rambo
2014-05-14 22:41 ` Jeroen Hofstee
2014-05-15 14:21   ` Darwin Rambo
2014-05-15 15:21     ` Wolfgang Denk
2014-05-15 16:07       ` Darwin Rambo
2014-05-15 19:19         ` Wolfgang Denk
2014-05-26  9:50           ` Albert ARIBAUD
2014-05-26 16:11             ` Darwin Rambo
2014-06-02  7:26               ` Albert ARIBAUD
2014-06-03  0:37                 ` Darwin Rambo
2014-06-09 10:23                   ` Albert ARIBAUD
2014-06-09 20:45                     ` Steve Rae
2014-06-09 20:56                       ` Jeroen Hofstee
2014-06-10  5:16                       ` Albert ARIBAUD
2014-06-10 17:56                         ` Steve Rae
2014-06-10 18:13                           ` Wolfgang Denk
2014-06-10 19:38                             ` Steve Rae
2014-06-10 20:35                               ` Wolfgang Denk
2014-06-10 23:15                                 ` Steve Rae
2014-06-11  4:49                                   ` Wolfgang Denk
2014-06-11  6:45                                     ` Albert ARIBAUD
2014-06-11 18:56                                       ` Steve Rae
2014-06-11 21:16                                         ` Wolfgang Denk
2014-06-25 12:52                                           ` Albert ARIBAUD
2014-06-10 21:20                               ` Albert ARIBAUD
2014-06-11  0:14                                 ` Steve Rae
2014-06-11  5:02                                   ` Wolfgang Denk
2014-06-11  4:38                                 ` Wolfgang Denk
2014-05-15  4:26 ` Wolfgang Denk
2014-05-15 14:16   ` Darwin Rambo
2014-05-15 15:16     ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox