Skip to content

Commit

Permalink
GCC: ARM_CM0: Fix L6286E error on Keil MDK
Browse files Browse the repository at this point in the history
Change the .b instruction to .bx with higher range to solve error
reported by MDK descibed bellow.

Fix:
Error: L6286E: Relocation #REL:0 in portasm.o(.text.SVC_Handler) with respect to vPortSVCHandler_C. Value(0x1a04) out of range(-0x800 - 0x7fe) for (R_ARM_THM_JUMP11)

Compiler: Keil MDK ARMClang 6.22.0

https://developer.arm.com/documentation/ka002847/latest/
https://developer.arm.com/documentation/dui0496/m/Linker-Errors-and-Warnings/List-of-the-armlink-error-and-warning-messages

Signed-off-by: Tomas Galbicka <[email protected]>
  • Loading branch information
TomasGalbickaNXP committed Aug 28, 2024
1 parent 23cfd11 commit 6abb4df
Showing 1 changed file with 67 additions and 60 deletions.
127 changes: 67 additions & 60 deletions portable/GCC/ARM_CM0/portasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,49 +443,52 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
{
__asm volatile
(
" .syntax unified \n"
" .extern vPortSVCHandler_C \n"
" .extern vSystemCallEnter \n"
" .extern vSystemCallExit \n"
" .extern pxCurrentTCB \n"
" \n"
" movs r0, #4 \n"
" mov r1, lr \n"
" tst r0, r1 \n"
" beq stack_on_msp \n"
" \n"
" stack_on_psp: \n"
" mrs r0, psp \n"
" b route_svc \n"
" \n"
" stack_on_msp: \n"
" mrs r0, msp \n"
" b route_svc \n"
" \n"
" route_svc: \n"
" ldr r3, [r0, #24] \n"
" subs r3, #2 \n"
" ldrb r2, [r3, #0] \n"
" ldr r3, =%0 \n"
" cmp r2, r3 \n"
" blt system_call_enter \n"
" ldr r3, =%1 \n"
" cmp r2, r3 \n"
" beq system_call_exit \n"
" b vPortSVCHandler_C \n"
" \n"
" system_call_enter: \n"
" push {lr} \n"
" bl vSystemCallEnter \n"
" pop {pc} \n"
" \n"
" system_call_exit: \n"
" push {lr} \n"
" bl vSystemCallExit \n"
" pop {pc} \n"
" \n"
" .align 4 \n"
" \n"
" .syntax unified \n"
" .extern vPortSVCHandler_C \n"
" .extern vSystemCallEnter \n"
" .extern vSystemCallExit \n"
" .extern pxCurrentTCB \n"
" \n"
" movs r0, #4 \n"
" mov r1, lr \n"
" tst r0, r1 \n"
" beq stack_on_msp \n"
" \n"
" stack_on_psp: \n"
" mrs r0, psp \n"
" b route_svc \n"
" \n"
" stack_on_msp: \n"
" mrs r0, msp \n"
" b route_svc \n"
" \n"
" route_svc: \n"
" ldr r3, [r0, #24] \n"
" subs r3, #2 \n"
" ldrb r2, [r3, #0] \n"
" ldr r3, =%0 \n"
" cmp r2, r3 \n"
" blt system_call_enter \n"
" ldr r3, =%1 \n"
" cmp r2, r3 \n"
" beq system_call_exit \n"
" ldr r3, vPortSVCHandler_C_Address \n"
" bx r3 \n"
" \n"
" system_call_enter: \n"
" push {lr} \n"
" bl vSystemCallEnter \n"
" pop {pc} \n"
" \n"
" system_call_exit: \n"
" push {lr} \n"
" bl vSystemCallExit \n"
" pop {pc} \n"
" \n"
" .ltorg \n"
" .align 4 \n"
" vPortSVCHandler_C_Address: .word vPortSVCHandler_C \n"
" \n"
: /* No outputs. */
: "i" ( NUM_SYSTEM_CALLS ), "i" ( portSVC_SYSTEM_CALL_EXIT )
: "r0", "r1", "r2", "r3", "memory"
Expand All @@ -498,23 +501,27 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
{
__asm volatile
(
" .syntax unified \n"
" .extern vPortSVCHandler_C \n"
" \n"
" movs r0, #4 \n"
" mov r1, lr \n"
" tst r0, r1 \n"
" beq stacking_used_msp \n"
" \n"
" stacking_used_psp: \n"
" mrs r0, psp \n"
" b vPortSVCHandler_C \n"
" \n"
" stacking_used_msp: \n"
" mrs r0, msp \n"
" b vPortSVCHandler_C \n"
" \n"
" .align 4 \n"
" .syntax unified \n"
" .extern vPortSVCHandler_C \n"
" \n"
" movs r0, #4 \n"
" mov r1, lr \n"
" tst r0, r1 \n"
" beq stacking_used_msp \n"
" \n"
" stacking_used_psp: \n"
" mrs r0, psp \n"
" ldr r3, vPortSVCHandler_C_Address \n"
" bx r3 \n"
" \n"
" stacking_used_msp: \n"
" mrs r0, msp \n"
" ldr r3, vPortSVCHandler_C_Address \n"
" bx r3 \n"
" \n"
" .ltorg \n"
" .align 4 \n"
" vPortSVCHandler_C_Address: .word vPortSVCHandler_C \n"
);
}

Expand Down

0 comments on commit 6abb4df

Please sign in to comment.