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 24, 2024
1 parent 06872ef commit e2f2f23
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 @@ -505,7 +505,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 @@ -521,7 +522,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 e2f2f23

Please sign in to comment.