[PATCH 3/3] ARM lowlevel: Use get_runtime_offset
Sascha Hauer
s.hauer at pengutronix.de
Mon Sep 10 03:56:49 EDT 2012
The current approach to get the offset between link and runtime address
is fragile. It requires a big fat comment to put no code above it and it
requires an extra linker section. Instead use a small assembler function.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/arm/cpu/start-pbl.c | 12 +++---------
arch/arm/cpu/start.c | 12 +++---------
arch/arm/include/asm/barebox-arm.h | 1 -
arch/arm/lib/barebox.lds.S | 2 --
arch/arm/pbl/zbarebox.lds.S | 2 --
5 files changed, 6 insertions(+), 23 deletions(-)
diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index 09a1940..5a6b99b 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -152,23 +152,17 @@ static void barebox_uncompress(void *compressed_start, unsigned int len)
* Board code can jump here by either returning from board_init_lowlevel
* or by calling this function directly.
*/
-void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
+void __naked board_init_lowlevel_return(void)
{
- uint32_t r, addr, offset;
+ uint32_t r, offset;
uint32_t pg_start, pg_end, pg_len;
- /*
- * 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 offset between linked address and runtime address */
- offset = (uint32_t)__ll_return - addr;
+ offset = get_runtime_offset();
pg_start = (uint32_t)&input_data - offset;
pg_end = (uint32_t)&input_data_end - offset;
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index e43ff9c..1c6a7dd 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -59,22 +59,16 @@ void __naked __section(.text_entry) start(void)
* Board code can jump here by either returning from board_init_lowlevel
* or by calling this function directly.
*/
-void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
+void __naked board_init_lowlevel_return(void)
{
- uint32_t r, addr, offset;
-
- /*
- * Get runtime address of this function. Do not
- * put any code above this.
- */
- __asm__ __volatile__("1: adr %0, 1b":"=r"(addr));
+ uint32_t r, offset;
/* Setup the stack */
r = STACK_BASE + STACK_SIZE - 16;
__asm__ __volatile__("mov sp, %0" : : "r"(r));
/* Get offset between linked address and runtime address */
- offset = (uint32_t)__ll_return - addr;
+ offset = get_runtime_offset();
/* relocate to link address if necessary */
if (offset)
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 3639365..a71f420 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -37,7 +37,6 @@ int board_init(void);
int dram_init (void);
extern char __exceptions_start[], __exceptions_stop[];
-extern char __ll_return[];
void board_init_lowlevel(void);
void board_init_lowlevel_return(void);
diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index a69013f..40af705 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -40,8 +40,6 @@ SECTIONS
_stext = .;
_text = .;
*(.text_entry*)
- __ll_return = .;
- *(.text_ll_return*)
__bare_init_start = .;
*(.text_bare_init*)
__bare_init_end = .;
diff --git a/arch/arm/pbl/zbarebox.lds.S b/arch/arm/pbl/zbarebox.lds.S
index 2dca278..37af4e9 100644
--- a/arch/arm/pbl/zbarebox.lds.S
+++ b/arch/arm/pbl/zbarebox.lds.S
@@ -39,8 +39,6 @@ SECTIONS
_stext = .;
_text = .;
*(.text_head_entry*)
- __ll_return = .;
- *(.text_ll_return*)
__bare_init_start = .;
*(.text_bare_init*)
__bare_init_end = .;
--
1.7.10.4
More information about the barebox
mailing list