Skip to content

Commit

Permalink
fixup! cmake: Add HARDENING option
Browse files Browse the repository at this point in the history
Do not pass `-mbranch-protection=bti` during link stage.
  • Loading branch information
hebasto committed May 26, 2024
1 parent b18aefe commit 4c4a12c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ if(ENABLE_HARDENING)
try_append_linker_flag("/NXCOMPAT" TARGET hardening_interface)
else()
target_compile_options(hardening_interface INTERFACE
$<$<NOT:$<CONFIG:Debug>>:-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3>
$<$<NOT:$<CONFIG:Debug>>:-U_FORTIFY_SOURCE>
$<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=3>
)

try_append_cxx_flags("-Wstack-protector" TARGET hardening_interface SKIP_LINK)
Expand All @@ -518,7 +519,7 @@ if(ENABLE_HARDENING)
endif()

if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
try_append_cxx_flags("-mbranch-protection=bti" TARGET hardening_interface)
try_append_cxx_flags("-mbranch-protection=bti" TARGET hardening_interface SKIP_LINK)
endif()

try_append_linker_flag("-Wl,--enable-reloc-section" TARGET hardening_interface)
Expand Down

0 comments on commit 4c4a12c

Please sign in to comment.