diff mbox

[U-Boot] board_f: fix calculation of reloc_off

Message ID 1496909905-27310-1-git-send-email-LW@KARO-electronics.de
State Accepted
Commit 53207bfd704250354c56aa74c7e96151fddee1f1
Delegated to: Tom Rini
Headers show

Commit Message

Lothar Waßmann June 8, 2017, 8:18 a.m. UTC
relocate_code() calculates the relocation offset wrt. the symbol
__image_copy_start which happens to have the same value as
CONFIG_TEXT_BASE on most systems.
When creating an i.MX boot image with an integrated IVT it is
convenient to have CONFIG_TEXT_BASE point to the start of the IVT
that is prepended to the actual code. Thus CONFIG_TEXT_BASE will
differ from __image_copy_start, while the calculation
'gd->relocaddr - __image_copy_start' still gives the right relocation
offset.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 common/board_f.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Tom Rini June 12, 2017, 10:44 p.m. UTC | #1
On Thu, Jun 08, 2017 at 10:18:25AM +0200, Lothar Waßmann wrote:

> relocate_code() calculates the relocation offset wrt. the symbol
> __image_copy_start which happens to have the same value as
> CONFIG_TEXT_BASE on most systems.
> When creating an i.MX boot image with an integrated IVT it is
> convenient to have CONFIG_TEXT_BASE point to the start of the IVT
> that is prepended to the actual code. Thus CONFIG_TEXT_BASE will
> differ from __image_copy_start, while the calculation
> 'gd->relocaddr - __image_copy_start' still gives the right relocation
> offset.
> 
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>

Reviewed-by: Tom Rini <trini@konsulko.com>
diff mbox

Patch

diff --git a/common/board_f.c b/common/board_f.c
index d9431ee..e71a38e 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -610,13 +610,16 @@  static int setup_reloc(void)
 	}
 
 #ifdef CONFIG_SYS_TEXT_BASE
-	gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
-#ifdef CONFIG_M68K
+#ifdef ARM
+	gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start;
+#elif defined(CONFIG_M68K)
 	/*
 	 * On all ColdFire arch cpu, monitor code starts always
 	 * just after the default vector table location, so at 0x400
 	 */
 	gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400);
+#else
+	gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
 #endif
 #endif
 	memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));