Skip to content

Commit f5cf218

Browse files
cgutmancharles-lunarg
authored andcommitted
cmake: Enable CET on MSVC x86/x64 builds
Intel CET uses a shadow stack to protect against ROP attacks by terminating the process if a shadow stack violation is detected in a module that has marked itself as CET-compatible with the /CETCOMPAT linker flag (and the process itself has CET enabled).
1 parent 8b9687f commit f5cf218

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC" OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" A
227227
# Enable control flow guard
228228
target_link_options(loader_common_options INTERFACE "LINKER:/guard:cf")
229229

230+
# Enable CET for 32-bit and 64-bit x86 architectures
231+
if (CMAKE_GENERATOR_PLATFORM MATCHES "Win32|x64")
232+
target_link_options(loader_common_options INTERFACE "LINKER:/cetcompat")
233+
endif()
234+
230235
# Prevent <windows.h> from polluting the code. guards against things like MIN and MAX
231236
target_compile_definitions(loader_common_options INTERFACE WIN32_LEAN_AND_MEAN)
232237

0 commit comments

Comments
 (0)