[PATCH] arm start.c: Make runtime function address calculation tolerant for more compilers
Sascha Hauer
s.hauer at pengutronix.de
Wed May 19 07:23:43 EDT 2010
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/arm/cpu/start.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 67d54a6..eea7dcf 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -81,21 +81,24 @@ void __naked __bare_init reset(void)
*/
void __naked __bare_init board_init_lowlevel_return(void)
{
- uint32_t r;
+ uint32_t r, addr;
+
+ /*
+ * Get runtime address of this function. Do not
+ * put any code above this.
+ */
+ __asm__ __volatile__("1: adr %0, 1b":"=r"(addr));
/* Setup the stack */
r = STACK_BASE + STACK_SIZE - 16;
__asm__ __volatile__("mov sp, %0" : : "r"(r));
- /* Get runtime address of this function */
- __asm__ __volatile__("adr %0, 0":"=r"(r));
-
/* Get start of binary image */
- r -= (uint32_t)&board_init_lowlevel_return - TEXT_BASE;
+ addr -= (uint32_t)&board_init_lowlevel_return - TEXT_BASE;
/* relocate to link address if necessary */
- if (r != TEXT_BASE)
- memcpy((void *)TEXT_BASE, (void *)r,
+ if (addr != TEXT_BASE)
+ memcpy((void *)TEXT_BASE, (void *)addr,
(unsigned int)&__bss_start - TEXT_BASE);
/* clear bss */
--
1.7.0
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list