Skip to content

Commit 5f6d4be

Browse files
cgutmancharles-lunarg
authored andcommitted
cmake: Enable EH metadata on 64-bit MSVC builds
Exception handling continuation metadata further hardens control flow by ensuring NtContinue() or RtlRestoreContext() cannot be exploited to redirect exception handling to a target that is not a valid exception handler.
1 parent f5cf218 commit 5f6d4be

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC" OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" A
232232
target_link_options(loader_common_options INTERFACE "LINKER:/cetcompat")
233233
endif()
234234

235+
# Enable EH Continuation Metadata for 64-bit architectures
236+
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
237+
target_compile_options(loader_common_options INTERFACE $<$<COMPILE_LANGUAGE::CXX,C>:/guard:ehcont>)
238+
target_link_options(loader_common_options INTERFACE "LINKER:/guard:ehcont")
239+
endif()
240+
235241
# Prevent <windows.h> from polluting the code. guards against things like MIN and MAX
236242
target_compile_definitions(loader_common_options INTERFACE WIN32_LEAN_AND_MEAN)
237243

0 commit comments

Comments
 (0)