Commit baa3b6a5 authored by Luca Burelli's avatar Luca Burelli Committed by Alberto Escolar
Browse files

llext: disable LL_EXTENSION_SYMBOL when not building an llext



The LL_EXTENSION_SYMBOL macro is used to export a symbol to the base
image. When CONFIG_LLEXT is not defined, or the file is being compiled
outside of an llext, the macro is not useful and would leave orphan
sections in the final image instead.

This patch adds the LL_EXTENSION_BUILD definition to the llext build
process, and uses it to stub out the symbol-defining macro when not
building an llext.

Signed-off-by: default avatarLuca Burelli <l.burelli@arduino.cc>
parent 12405a64
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5394,6 +5394,7 @@ function(add_llext_target target_name)

  target_compile_definitions(${llext_lib_target} PRIVATE
    $<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_DEFINITIONS>
    LL_EXTENSION_BUILD
  )
  target_compile_options(${llext_lib_target} PRIVATE
    ${zephyr_filtered_flags}
+4 −0
Original line number Diff line number Diff line
@@ -114,12 +114,16 @@ struct llext_symtable {
 *
 * @param x Extension symbol to export to the base image
 */
#if defined(CONFIG_LLEXT) && defined(LL_EXTENSION_BUILD)
#define LL_EXTENSION_SYMBOL(x)							\
	static const struct llext_const_symbol					\
			Z_GENERIC_SECTION(".exported_sym") __used		\
			x ## _sym = {						\
		.name = STRINGIFY(x), .addr = (const void *)&x,			\
	}
#else
#define LL_EXTENSION_SYMBOL(x)
#endif

/**
 * @}