diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 4c989e808ae..c0eeb18acbf 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -5309,17 +5309,15 @@ function(add_llext_target target_name) ) # Compile the source file using current Zephyr settings but a different - # set of flags. - # This is currently arch-specific since the ARM loader for .llext files - # expects object file format, while the Xtensa one uses shared libraries. + # set of flags to obtain the desired llext object type. set(llext_lib_target ${target_name}_llext_lib) - if(CONFIG_ARM) + if(CONFIG_LLEXT_TYPE_ELF_OBJECT) # Create an object library to compile the source file add_library(${llext_lib_target} OBJECT ${source_file}) set(llext_lib_output $) - elseif(CONFIG_XTENSA) + elseif(CONFIG_LLEXT_TYPE_ELF_SHAREDLIB) # Create a shared library add_library(${llext_lib_target} SHARED ${source_file}) @@ -5371,8 +5369,8 @@ function(add_llext_target target_name) COMMAND_EXPAND_LISTS ) - # Arch-specific packaging of the built binary file into an .llext file - if(CONFIG_ARM) + # 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( @@ -5381,7 +5379,7 @@ function(add_llext_target target_name) DEPENDS ${llext_proc_target} ${llext_pkg_input} ) - elseif(CONFIG_XTENSA) + elseif(CONFIG_LLEXT_TYPE_ELF_SHAREDLIB) # Need to strip the shared library of some sections add_custom_command( @@ -5395,8 +5393,6 @@ function(add_llext_target target_name) DEPENDS ${llext_proc_target} ${llext_pkg_input} ) - else() - message(FATAL_ERROR "add_llext_target: unsupported architecture") endif() # Add user-visible target and dependency, and fill in properties diff --git a/subsys/llext/Kconfig b/subsys/llext/Kconfig index 59a4129a1ad..4bc5e5b6136 100644 --- a/subsys/llext/Kconfig +++ b/subsys/llext/Kconfig @@ -9,6 +9,29 @@ menuconfig LLEXT if LLEXT +choice LLEXT_BINARY_TYPE + prompt "Binary object type for llext" + default LLEXT_TYPE_ELF_OBJECT if ARM + default LLEXT_TYPE_ELF_SHAREDLIB if XTENSA + help + Object type for llext + +config LLEXT_TYPE_ELF_OBJECT + bool "Single object ELF file" + help + Build and expect object files as binary object type for the + llext subsystem. A single compiler invocation is used to + generate the object file. + +config LLEXT_TYPE_ELF_SHAREDLIB + bool "Shared library ELF file" + help + Build and expect shared libraries as binary object type for + the llext subsystem. The usual linking process is used to + generate the shared library from multiple object files. + +endchoice + config LLEXT_HEAP_SIZE int "llext heap memory size in kilobytes" default 8