[rtems commit] bsps/arm: Avoid short range branch in start.S
Sebastian Huber
sebh at rtems.org
Wed Nov 21 06:48:38 UTC 2018
Module: rtems
Branch: master
Commit: e0caabe08d9ca0f551c1b7dd8ce8de2dd39e250f
Changeset: http://git.rtems.org/rtems/commit/?id=e0caabe08d9ca0f551c1b7dd8ce8de2dd39e250f
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Nov 20 13:09:53 2018 +0100
bsps/arm: Avoid short range branch in start.S
---
bsps/arm/shared/start/start.S | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/bsps/arm/shared/start/start.S b/bsps/arm/shared/start/start.S
index 9a94688..4893564 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.
More information about the vc
mailing list