Skip to content

Commit

Permalink
cmake: Add partial linking abstraction
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
aescolar authored and carlescufi committed Jun 23, 2023
1 parent b4b2eaa commit e9af821
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmake/linker/ld/linker_flags.cmake
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cmake/linker/linker_flags_template.cmake
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions cmake/linker/lld/linker_flags.cmake
Expand Up @@ -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")

0 comments on commit e9af821

Please sign in to comment.