linker: Include libkernel.a in the whole-archive when llext is enabled
Differently from other libraries, which are included whole in the final Zephyr ELF, libkernel.a itself isn't. Assuming this is intended to enable optimisations (if it isn't, this patch will break things) - linker can remove parts of the kernel that are not used by the application. However, when considering Linkable Loadable Extensions (llext), this optimisations can be counterproductive: for instance, syscalls that are not used by the application won't be available for extensions. It won't matter if someone "EXPORT_SYMBOL" for them, or even try to keep them using LINKER_KEEP, they'll be gone. To avoid that, this patches includes, when CONFIG_LLEXT=y, libkernel.a inside the linker "whole-archive" block. This ends up making it consider libkernel.a as a library whose all symbols should be kept. Note this doesn't mean that all symbols will be there - things compiled out via Kconfig will naturally still be out. Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
This commit is contained in:
parent
a924c87dc2
commit
321e395a8f
6 changed files with 16 additions and 9 deletions
|
@ -876,6 +876,13 @@ foreach(zephyr_lib ${ZEPHYR_LIBS_PROPERTY})
|
|||
add_dependencies(${zephyr_lib} zephyr_generated_headers)
|
||||
endforeach()
|
||||
|
||||
if(CONFIG_LLEXT)
|
||||
set(WHOLE_ARCHIVE_LIBS ${ZEPHYR_LIBS_PROPERTY} kernel)
|
||||
else()
|
||||
set(WHOLE_ARCHIVE_LIBS ${ZEPHYR_LIBS_PROPERTY})
|
||||
set(NO_WHOLE_ARCHIVE_LIBS kernel)
|
||||
endif()
|
||||
|
||||
get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT)
|
||||
|
||||
if (CONFIG_CODE_DATA_RELOCATION)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue