From 70a18e571e0c18bd2c162b451090b18b34af178d Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Fri, 8 Nov 2024 16:24:49 +0100 Subject: [PATCH] linker: llext: avoid modifying current address in linker script snippet The linker script snippet that places the llext_no_syscall_impl section has the unfortunate side effect of overwriting the current linker address. This can lead to unexpected behavior of the caller script. Saving the current address before defining the section and restoring it afterwards avoids this issue. Fixes #81136. Signed-off-by: Luca Burelli --- include/zephyr/linker/llext-sections.ld | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/zephyr/linker/llext-sections.ld b/include/zephyr/linker/llext-sections.ld index 3dcfc3e8f0cd8..f6344a531298b 100644 --- a/include/zephyr/linker/llext-sections.ld +++ b/include/zephyr/linker/llext-sections.ld @@ -1,12 +1,16 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* - * Map the no_syscall_impl symbol in llext_export_syscalls.c to + * Save the current address to avoid changing it in this file. + */ + HIDDEN(__llext_current_addr = .); + + /* + * Map the 'no_syscall_impl' symbol in 'syscall_export_llext.c' to * absolute address 0 so other weak symbols are exported as NULL. * This section is used for mapping that symbol only and is not * to be included in the final binary. */ - SECTION_PROLOGUE(llext_no_syscall_impl, 0 (COPY), ) { *(llext_no_syscall_impl) @@ -29,3 +33,5 @@ KEEP(*(llext_exports_strtab)) } #endif + + . = __llext_current_addr;