build: Fix native_posix build on GNU GCC
Update -fno-pie to only be added when relevant. This fixes native_posix builds on Debian hosts. * Debian and other Linux distributions have ld with --warn-textrel as default. * The option generates a warning when linking on x86. * The warning make scripts/twister fail because we treat all warnings as error. * The warning is issued when no PIE objects are linked against PIE library. * PIE (Position Independent Executable) or not can be seen with the following command. * When you want to generate non PIE, link with `-no-pie.` Non PIE $ readelf -l build/zephyr/zephyr.elf | grep 'Elf file type is' Elf file type is EXEC (Executable file) PIE $ readelf -l /lib/x86_64-linux-gnu/libc.so.6 | \ grep 'Elf file type is' Elf file type is DYN (Shared object file) Issue #35244 Signed-off-by: Yuval Peress <peress@google.com>
This commit is contained in:
parent
ef0d955758
commit
a81f8af701
2 changed files with 1 additions and 1 deletions
|
@ -8,7 +8,6 @@ macro(toolchain_ld_baremetal)
|
||||||
zephyr_ld_options(
|
zephyr_ld_options(
|
||||||
-nostdlib
|
-nostdlib
|
||||||
-static
|
-static
|
||||||
-no-pie
|
|
||||||
${LINKERFLAGPREFIX},-X
|
${LINKERFLAGPREFIX},-X
|
||||||
${LINKERFLAGPREFIX},-N
|
${LINKERFLAGPREFIX},-N
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,6 +11,7 @@ macro(toolchain_ld_base)
|
||||||
# TOOLCHAIN_LD_FLAGS comes from compiler/gcc/target.cmake
|
# TOOLCHAIN_LD_FLAGS comes from compiler/gcc/target.cmake
|
||||||
# LINKERFLAGPREFIX comes from linker/ld/target.cmake
|
# LINKERFLAGPREFIX comes from linker/ld/target.cmake
|
||||||
zephyr_ld_options(
|
zephyr_ld_options(
|
||||||
|
-no-pie
|
||||||
${TOOLCHAIN_LD_FLAGS}
|
${TOOLCHAIN_LD_FLAGS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue