diff --git a/cmake/compiler/gcc/target_arc.cmake b/cmake/compiler/gcc/target_arc.cmake index d306fe1550f..60a516272bb 100644 --- a/cmake/compiler/gcc/target_arc.cmake +++ b/cmake/compiler/gcc/target_arc.cmake @@ -15,7 +15,6 @@ set(LLEXT_REMOVE_FLAGS -fno-pie -ffunction-sections -fdata-sections - -g.* -Os ) diff --git a/cmake/compiler/gcc/target_arm.cmake b/cmake/compiler/gcc/target_arm.cmake index 72b6cc03601..7d46a4e9572 100644 --- a/cmake/compiler/gcc/target_arm.cmake +++ b/cmake/compiler/gcc/target_arm.cmake @@ -54,7 +54,6 @@ set(LLEXT_REMOVE_FLAGS -fno-pie -ffunction-sections -fdata-sections - -g.* -Os ) @@ -67,8 +66,9 @@ set(LLEXT_APPEND_FLAGS list(APPEND LLEXT_EDK_REMOVE_FLAGS --sysroot=.* -fmacro-prefix-map=.* - ) + -g.* +) list(APPEND LLEXT_EDK_APPEND_FLAGS -nodefaultlibs - ) +) diff --git a/cmake/compiler/gcc/target_arm64.cmake b/cmake/compiler/gcc/target_arm64.cmake index 2674cac50cc..2bc16e61bc1 100644 --- a/cmake/compiler/gcc/target_arm64.cmake +++ b/cmake/compiler/gcc/target_arm64.cmake @@ -22,13 +22,13 @@ set(LLEXT_REMOVE_FLAGS -fno-pie -ffunction-sections -fdata-sections - -g.* -Os ) list(APPEND LLEXT_EDK_REMOVE_FLAGS --sysroot=.* -fmacro-prefix-map=.* + -g.* ) list(APPEND LLEXT_EDK_APPEND_FLAGS diff --git a/cmake/compiler/gcc/target_xtensa.cmake b/cmake/compiler/gcc/target_xtensa.cmake index 0b398023f67..abe0c7be703 100644 --- a/cmake/compiler/gcc/target_xtensa.cmake +++ b/cmake/compiler/gcc/target_xtensa.cmake @@ -5,7 +5,6 @@ set(LLEXT_REMOVE_FLAGS -ffunction-sections -fdata-sections - -g.* -Os -mcpu=.* ) diff --git a/cmake/compiler/xt-clang/target.cmake b/cmake/compiler/xt-clang/target.cmake index 978bc7c7860..73cf348a1fd 100644 --- a/cmake/compiler/xt-clang/target.cmake +++ b/cmake/compiler/xt-clang/target.cmake @@ -7,7 +7,6 @@ include(${ZEPHYR_BASE}/cmake/compiler/xcc/target.cmake) set(LLEXT_REMOVE_FLAGS -ffunction-sections -fdata-sections - -g.* -Os -mcpu=.* ) diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index c63412cd16e..4613a48449f 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -5700,7 +5700,7 @@ function(add_llext_target target_name) # to be used to support POST_BUILD commands on targets that do not use a # dynamic library. set(llext_proc_target ${target_name}_llext_proc) - set(llext_pkg_input ${PROJECT_BINARY_DIR}/${target_name}.llext.pkg_input) + set(llext_pkg_input ${PROJECT_BINARY_DIR}/${target_name}_debug.elf) add_custom_target(${llext_proc_target} DEPENDS ${llext_pkg_input}) set_property(TARGET ${llext_proc_target} PROPERTY has_post_build_cmds 0) @@ -5733,49 +5733,19 @@ function(add_llext_target target_name) set(slid_inject_cmd ${CMAKE_COMMAND} -E true) endif() - # Type-specific packaging of the built binary file into an .llext file - if(CONFIG_LLEXT_TYPE_ELF_OBJECT) - - # No packaging required, simply copy the object file - add_custom_command( - OUTPUT ${llext_pkg_output} - COMMAND ${CMAKE_COMMAND} -E copy ${llext_pkg_input} ${llext_pkg_output} - COMMAND ${slid_inject_cmd} - DEPENDS ${llext_proc_target} ${llext_pkg_input} - ) - - elseif(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE) - - # Need to remove just some sections from the relocatable object - # (using strip in this case would remove _all_ symbols) - add_custom_command( - OUTPUT ${llext_pkg_output} - COMMAND $ - $ - $.xt.* - $${llext_pkg_input} - $${llext_pkg_output} - $ - COMMAND ${slid_inject_cmd} - DEPENDS ${llext_proc_target} ${llext_pkg_input} - ) - - elseif(CONFIG_LLEXT_TYPE_ELF_SHAREDLIB) - - # Need to strip the shared library of some sections - add_custom_command( - OUTPUT ${llext_pkg_output} - COMMAND $ - $ - $.xt.* - $${llext_pkg_input} - $${llext_pkg_output} - $ - COMMAND ${slid_inject_cmd} - DEPENDS ${llext_proc_target} ${llext_pkg_input} - ) - - endif() + # Remove sections that are unused by the llext loader + add_custom_command( + OUTPUT ${llext_pkg_output} + COMMAND $ + $ + $ + $.xt.* + $${llext_pkg_input} + $${llext_pkg_output} + $ + COMMAND ${slid_inject_cmd} + DEPENDS ${llext_proc_target} ${llext_pkg_input} + ) # Add user-visible target and dependency, and fill in properties get_filename_component(output_name ${llext_pkg_output} NAME)