cmake: Add partial linking abstraction

Add a property to abstract the partial linking/rellocatable
linking for gcc ld and llvm's lld.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-06-15 12:35:13 +02:00 committed by Carles Cufí
parent b4b2eaae35
commit e9af821e22
3 changed files with 8 additions and 0 deletions

View file

@ -10,6 +10,8 @@ else()
set_property(TARGET linker PROPERTY no_position_independent)
endif()
set_property(TARGET linker PROPERTY partial_linking "-r")
# Some linker flags might not be purely ld specific, but a combination of
# linker and compiler, such as:
# --coverage for clang

View file

@ -16,3 +16,7 @@ set_property(TARGET linker PROPERTY warnings_as_errors)
# Linker flag for disabling position independent binaries,
# such as, "-no-pie" for LD, and "--no-pie" for LLD.
set_property(TARGET linker PROPERTY no_position_independent)
# Linker flag for doing partial linking
# such as, "-r" or "--relocatable" for LD and LLD.
set_property(TARGET linker PROPERTY partial_linking)

View file

@ -5,3 +5,5 @@
include(${ZEPHYR_BASE}/cmake/linker/ld/${COMPILER}/linker_flags.cmake OPTIONAL)
set_property(TARGET linker PROPERTY no_position_independent "${LINKERFLAGPREFIX},--no-pie")
set_property(TARGET linker PROPERTY partial_linking "-r")