LLEXT: Xtensa: add a Kconfig option to enable -fPIC
Currently when building LLEXT for Xtensa we use the -fPIC compiler option, but this cannot be used when using detached sections in extensions. Add a Kconfig option to switch between the two compilation modes and switch -fPIC off when building relocatable (partially linked) ELF binaries. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
parent
4f0cb90c59
commit
e2d8daae16
|
@ -3,8 +3,6 @@
|
|||
# Flags not supported by llext linker
|
||||
# (regexps are supported and match whole word)
|
||||
set(LLEXT_REMOVE_FLAGS
|
||||
-fno-pic
|
||||
-fno-pie
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
-g.*
|
||||
|
@ -14,7 +12,20 @@ set(LLEXT_REMOVE_FLAGS
|
|||
|
||||
# Flags to be added to llext code compilation
|
||||
set(LLEXT_APPEND_FLAGS
|
||||
-fPIC
|
||||
-nostdlib
|
||||
-nodefaultlibs
|
||||
)
|
||||
|
||||
if(CONFIG_LLEXT_BUILD_PIC)
|
||||
set(LLEXT_REMOVE_FLAGS ${LLEXT_REMOVE_FLAGS}
|
||||
-fno-pic
|
||||
-fno-pie
|
||||
)
|
||||
set(LLEXT_APPEND_FLAGS ${LLEXT_APPEND_FLAGS}
|
||||
-fPIC
|
||||
)
|
||||
else()
|
||||
set(LLEXT_APPEND_FLAGS ${LLEXT_APPEND_FLAGS}
|
||||
-ffreestanding
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -5,8 +5,6 @@ include(${ZEPHYR_BASE}/cmake/compiler/xcc/target.cmake)
|
|||
# Flags not supported by llext linker
|
||||
# (regexps are supported and match whole word)
|
||||
set(LLEXT_REMOVE_FLAGS
|
||||
-fno-pic
|
||||
-fno-pie
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
-g.*
|
||||
|
@ -16,7 +14,20 @@ set(LLEXT_REMOVE_FLAGS
|
|||
|
||||
# Flags to be added to llext code compilation
|
||||
set(LLEXT_APPEND_FLAGS
|
||||
-fPIC
|
||||
-nostdlib
|
||||
-nodefaultlibs
|
||||
)
|
||||
|
||||
if(CONFIG_LLEXT_BUILD_PIC)
|
||||
set(LLEXT_REMOVE_FLAGS ${LLEXT_REMOVE_FLAGS}
|
||||
-fno-pic
|
||||
-fno-pie
|
||||
)
|
||||
set(LLEXT_APPEND_FLAGS ${LLEXT_APPEND_FLAGS}
|
||||
-fPIC
|
||||
)
|
||||
else()
|
||||
set(LLEXT_APPEND_FLAGS ${LLEXT_APPEND_FLAGS}
|
||||
-ffreestanding
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -49,6 +49,16 @@ config LLEXT_HEAP_SIZE
|
|||
help
|
||||
Heap size in kilobytes available to llext for dynamic allocation
|
||||
|
||||
config LLEXT_BUILD_PIC
|
||||
bool "Use -fPIC when building LLEXT"
|
||||
depends on XTENSA
|
||||
default y if LLEXT_TYPE_ELF_SHAREDLIB
|
||||
help
|
||||
By default LLEXT compilation is performed with -fno-pic -fno-pie compiler
|
||||
flags. Some platforms can benefit from using -fPIC instead, in which case
|
||||
most internal linking is performed by the linker at build time. Select "y"
|
||||
to make use of that advantage.
|
||||
|
||||
config LLEXT_SHELL
|
||||
bool "llext shell commands"
|
||||
depends on SHELL
|
||||
|
|
Loading…
Reference in New Issue