This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c188d555f6cebf373d6d62f239dffe75d08ae8fd Author: Marco Casaroli <[email protected]> AuthorDate: Wed Oct 21 12:33:33 2026 +0200 arch/arm: Keep the stub table of dispatch_syscall() in an LTO link. On armv7-a, armv7-r and armv8-r, dispatch_syscall() reads g_stublookup only in its inline assembly. LTO does not see that reference, so with CONFIG_LTO_FULL the link of a protected or kernel build does not take syscall_stublookup.o from libstubs.a, or makes the table local: arm_syscall.c:144:(.text.dispatch_syscall+0x24): undefined reference to `g_stublookup' The assembly now gets the table as an "i" operand. The compiler then sees the reference: the link takes the table, and the assembly uses the name that LTO gives to it. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- arch/arm/src/armv7-a/arm_syscall.c | 4 +++- arch/arm/src/armv7-r/arm_syscall.c | 4 +++- arch/arm/src/armv8-r/arm_syscall.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/armv7-a/arm_syscall.c b/arch/arm/src/armv7-a/arm_syscall.c index 09b7f133fd0..bd3a430555a 100644 --- a/arch/arm/src/armv7-a/arm_syscall.c +++ b/arch/arm/src/armv7-a/arm_syscall.c @@ -132,7 +132,7 @@ static void dispatch_syscall(void) " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */ " str lr, [sp, #12]\n" /* Save lr in the stack frame */ - " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */ + " ldr ip, =%c0\n" /* R12=The base of the stub lookup table */ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */ " blx ip\n" /* Call the stub (modifies lr) */ " ldr lr, [sp, #12]\n" /* Restore lr */ @@ -140,6 +140,8 @@ static void dispatch_syscall(void) " mov r2, r0\n" /* R2=Save return value in R2 */ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */ + : + : "i"(g_stublookup) ); } #endif diff --git a/arch/arm/src/armv7-r/arm_syscall.c b/arch/arm/src/armv7-r/arm_syscall.c index cf2563b6ee1..e70ca09ae79 100644 --- a/arch/arm/src/armv7-r/arm_syscall.c +++ b/arch/arm/src/armv7-r/arm_syscall.c @@ -129,7 +129,7 @@ static void dispatch_syscall(void) " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */ " str lr, [sp, #12]\n" /* Save lr in the stack frame */ - " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */ + " ldr ip, =%c0\n" /* R12=The base of the stub lookup table */ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */ " blx ip\n" /* Call the stub (modifies lr) */ " ldr lr, [sp, #12]\n" /* Restore lr */ @@ -137,6 +137,8 @@ static void dispatch_syscall(void) " mov r2, r0\n" /* R2=Save return value in R2 */ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */ + : + : "i"(g_stublookup) ); } #endif diff --git a/arch/arm/src/armv8-r/arm_syscall.c b/arch/arm/src/armv8-r/arm_syscall.c index 98536a217e3..f7f5f32a2ae 100644 --- a/arch/arm/src/armv8-r/arm_syscall.c +++ b/arch/arm/src/armv8-r/arm_syscall.c @@ -129,7 +129,7 @@ static void dispatch_syscall(void) " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */ " str lr, [sp, #12]\n" /* Save lr in the stack frame */ - " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */ + " ldr ip, =%c0\n" /* R12=The base of the stub lookup table */ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */ " blx ip\n" /* Call the stub (modifies lr) */ " ldr lr, [sp, #12]\n" /* Restore lr */ @@ -137,6 +137,8 @@ static void dispatch_syscall(void) " mov r2, r0\n" /* R2=Save return value in R2 */ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */ + : + : "i"(g_stublookup) ); } #endif
