Skip to content

Commit 958ef22

Browse files
keith-packardkartben
authored andcommitted
tests/llext: Compute linker script option rather than using -Wl,-T
Use the same logic as the top-level Zephyr CMakeLists.txt does to find the linker script option by using the first one of these which is set: 1. Global TOPT property 2. Compiler's linker_script property 3. -Wl,-T This avoids toolchains which insert a default linker script when none is provided on the command line using the -T option. Signed-off-by: Keith Packard <keithp@keithp.com>
1 parent bcfe94c commit 958ef22

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/subsys/llext/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ if(NOT CONFIG_LLEXT_TYPE_ELF_OBJECT)
6969
)
7070
endif()
7171

72+
get_property(TOPT GLOBAL PROPERTY TOPT)
73+
get_property(COMPILER_TOPT TARGET compiler PROPERTY linker_script)
74+
set_ifndef( TOPT "${COMPILER_TOPT}")
75+
set_ifndef( TOPT -Wl,-T) # Use this if the compiler driver doesn't set a value
76+
7277
if (CONFIG_LLEXT_TYPE_ELF_RELOCATABLE AND NOT CONFIG_ARM AND NOT CONFIG_RISCV)
7378
# Manually fix the pre_located extension's text address at a multiple of 4
7479
get_target_property(pre_located_target pre_located_ext lib_target)
@@ -78,7 +83,7 @@ if (CONFIG_LLEXT_TYPE_ELF_RELOCATABLE AND NOT CONFIG_ARM AND NOT CONFIG_RISCV)
7883
POST_BUILD
7984
COMMAND ${CMAKE_C_COMPILER}
8085
${LLEXT_APPEND_FLAGS}
81-
-Wl,-r -Wl,-Ttext=0xbada110c -nostdlib -nodefaultlibs -nostartfiles
86+
-Wl,-r ${TOPT}text=0xbada110c -nostdlib -nodefaultlibs -nostartfiles
8287
$<TARGET_OBJECTS:${pre_located_target}> -o ${pre_located_file}
8388
)
8489
endif()

0 commit comments

Comments
 (0)