Compare commits
4
Commits
995ddf329f
...
d8c9491eb3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8c9491eb3 | ||
|
|
b4144298bb | ||
|
|
b894ae7a80 | ||
|
|
eb9925ffec |
+18
-5
@@ -51,12 +51,16 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
add_compile_options("-Wno-maybe-uninitialized")
|
||||
endif()
|
||||
|
||||
set(full_relro_flags "-pie;LINKER:-z,relro,-z,now,-z,noexecstack")
|
||||
set(relro_flags "LINKER:-z,relro,-z,now,-z,noexecstack")
|
||||
set(full_relro_flags "-pie;${relro_flags}")
|
||||
cmake_push_check_state()
|
||||
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${full_relro_flags})
|
||||
check_cxx_source_compiles("int main(){}" HAS_FULL_RELRO FAIL_REGEX "warning:")
|
||||
if(HAS_FULL_RELRO)
|
||||
add_link_options(${full_relro_flags})
|
||||
# -pie only applies to executables; passing it when linking a shared library
|
||||
# makes the driver pull in Scrt1.o, which requires main.
|
||||
add_link_options("$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-pie>"
|
||||
${relro_flags})
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
|
||||
@@ -202,9 +206,18 @@ endif()
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
find_program(HARDENING_CHECK hardening-check)
|
||||
if(HARDENING_CHECK)
|
||||
add_test(NAME hardening_check
|
||||
COMMAND ${HARDENING_CHECK} $<TARGET_FILE:${PROJECT_NAME}>
|
||||
--nofortify --nostackprotector)
|
||||
# Control flow integrity (CET) is x86-only and branch protection (PAC/BTI)
|
||||
# is arm64-only, so ignore whichever doesn't apply.
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR
|
||||
STREQUAL arm64)
|
||||
set(hardening_check_arch_flags --nocfprotection)
|
||||
else()
|
||||
set(hardening_check_arch_flags --nobranchprotection)
|
||||
endif()
|
||||
add_test(
|
||||
NAME hardening_check
|
||||
COMMAND ${HARDENING_CHECK} $<TARGET_FILE:${PROJECT_NAME}> --nofortify
|
||||
--nostackprotector ${hardening_check_arch_flags})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
Binary file not shown.
+9119
-7134
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user