summaryrefslogtreecommitdiffstats
path: root/bsps/arm/shared/start/start.S
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-11-20 13:09:53 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-11-21 07:48:23 +0100
commite0caabe08d9ca0f551c1b7dd8ce8de2dd39e250f (patch)
tree2ed42ebc983b4ee90cfa517e8c3366443b310f38 /bsps/arm/shared/start/start.S
parentbsps/arm: Use local labels in start.S (diff)
downloadrtems-e0caabe08d9ca0f551c1b7dd8ce8de2dd39e250f.tar.bz2
bsps/arm: Avoid short range branch in start.S
Diffstat (limited to 'bsps/arm/shared/start/start.S')
-rw-r--r--bsps/arm/shared/start/start.S27
1 files changed, 13 insertions, 14 deletions
diff --git a/bsps/arm/shared/start/start.S b/bsps/arm/shared/start/start.S
index 9a946887ce..4893564cc4 100644
--- a/bsps/arm/shared/start/start.S
+++ b/bsps/arm/shared/start/start.S
@@ -276,34 +276,33 @@ _start:
#endif /* ARM_MULTILIB_VFP */
/*
- * Branch to start hook 0.
+ * Invoke the start hook 0.
*
* The previous code and parts of the start hook 0 may run with an
- * address offset. This implies that only branches relative to the
- * program counter are allowed. After the start hook 0 it is assumed
+ * address offset. After the return from start hook 0 it is assumed
* that the code can run at its intended position. Thus the link
- * register will be loaded with the absolute address. In THUMB mode
- * the start hook 0 must be within a 2kByte range due to the branch
- * instruction limitation.
+ * register will be loaded with the absolute address and the branch
+ * link instruction cannot be used. In THUMB mode the branch
+ * instruction as a very limited address range of 2KiB. Use a bx to
+ * the start hook 0 address instead corrected by the address offset.
*/
ldr lr, =.Lstart_hook_0_done
-#ifdef __thumb__
- orr lr, #1
-#endif
-
- SWITCH_FROM_ARM_TO_THUMB r0
+ mov r0, pc
+ ldr r1, =.Lget_absolute_pc
+.Lget_absolute_pc:
+ sub r1, r0
+ ldr r7, =bsp_start_hook_0
+ add r7, r1
mov r0, r4 /* original CPSR value */
mov r1, r5 /* machine type number or ~0 for DT boot */
mov r2, r6 /* physical address of ATAGs or DTB */
- b bsp_start_hook_0
+ bx r7
.Lstart_hook_0_done:
- SWITCH_FROM_THUMB_TO_ARM
-
/*
* Initialize the exception vectors. This includes the exceptions
* vectors and the pointers to the default exception handlers.