linker: decouple KERNEL_WHOLE_ARCHIVE from LLEXT

Dynamic code execution applications not using LLEXT for "extension"
loading are subject to the same linker optimization symbol resolution
issue described in commit 321e395 (in summary, libkernel.a syscalls
not used directly by the application result in weak symbol resolution
of their z_mrsh_ wrapper).

To support usecases where an application is using alternative methods
to load and execute code calling syscalls (likely from userspace) or
is using a mechanism where the linker may not be aware, the configuration
option has been decoupled from CONFIG_LLEXT (who is now a selector) to
KERNEL_WHOLE_ARCHIVE.

Signed-off-by: Daniel Apperloo <daniel.apperloo@intel.com>
This commit is contained in:
Daniel Apperloo 2024-05-03 01:55:49 +00:00 committed by Carles Cufí
commit 9fc26804fb
3 changed files with 8 additions and 1 deletions

View file

@ -906,7 +906,7 @@ foreach(zephyr_lib ${ZEPHYR_LIBS_PROPERTY})
add_dependencies(${zephyr_lib} zephyr_generated_headers)
endforeach()
if(CONFIG_LLEXT)
if(CONFIG_KERNEL_WHOLE_ARCHIVE)
set(WHOLE_ARCHIVE_LIBS ${ZEPHYR_LIBS_PROPERTY} kernel)
else()
set(WHOLE_ARCHIVE_LIBS ${ZEPHYR_LIBS_PROPERTY})

View file

@ -1020,6 +1020,12 @@ config THREAD_LOCAL_STORAGE
help
This option enables thread local storage (TLS) support in kernel.
config KERNEL_WHOLE_ARCHIVE
bool
help
This option forces every object file in the libkernel.a archive
to be included, rather than searching the archive for required object files.
endmenu
rsource "Kconfig.device"

View file

@ -4,6 +4,7 @@
menuconfig LLEXT
bool "Linkable loadable extensions"
select CACHE_MANAGEMENT if DCACHE
select KERNEL_WHOLE_ARCHIVE
help
Enable the linkable loadable extension subsystem