summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-12-12 08:55:31 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-12-14 11:27:13 +0100
commit0230365df6601cd561c9e3e368c96222076ec9f5 (patch)
treea12ac05b8dd938297f417f4e6a0e0b1e594898fb
parent804770590556be5c922c9fb7e779e72805911e57 (diff)
downloadbarebox-0230365df6601cd561c9e3e368c96222076ec9f5.tar.gz
barebox-0230365df6601cd561c9e3e368c96222076ec9f5.tar.xz
ARM: fix setup_c when runtime offset is != 0
The runtime offset has to be added to the memcpy source address and substracted from the return address. This should have been changed in a43e2bbc46 which changed from returning the negative runtime offset into changing the positive runtime offset. Instead a43e2bbc46 only changed a zero substraction ("subs r4, r0, #0") into a zero addition ("adds r4, r0, #0") which was used as a equal to zero test and changed nothing. This part is reverted here. Fixes wrong copy / return locations when setup_c is called with different runtime and link addresses. fixes: a43e2bbc46 ("ARM: return positive offset in get_runtime_offset()") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/cpu/setupc.S8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/arm/cpu/setupc.S b/arch/arm/cpu/setupc.S
index 717500cfff..a5f311b8ec 100644
--- a/arch/arm/cpu/setupc.S
+++ b/arch/arm/cpu/setupc.S
@@ -15,13 +15,13 @@ ENTRY(setup_c)
push {r4, r5}
mov r5, lr
bl get_runtime_offset
- adds r4, r0, #0
+ subs r4, r0, #0
beq 1f /* skip memcpy if already at correct address */
ldr r0,=_text
ldr r2,=__bss_start
sub r2, r2, r0
- sub r1, r0, r4
- bl memcpy /* memcpy(_text, _text - offset, __bss_start - _text) */
+ add r1, r0, r4
+ bl memcpy /* memcpy(_text, _text + offset, __bss_start - _text) */
1: ldr r0, =__bss_start
mov r1, #0
ldr r2, =__bss_stop
@@ -32,7 +32,7 @@ ENTRY(setup_c)
#endif
mov r0, #0
mcr p15, 0, r0, c7, c5, 0 /* flush icache */
- add lr, r5, r4 /* adjust return address to new location */
+ sub lr, r5, r4 /* adjust return address to new location */
pop {r4, r5}
mov pc, lr
ENDPROC(setup_c)