From 5adeeb75ea803fbfa8a7db12d8fb64dc6f3cf60a Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Thu, 26 Aug 2021 23:09:13 +0500 Subject: [PATCH] Enable Control flow guard and Qspectre protection for windows binaries found by BinSkim --- src/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86bac60c..2e70c6ee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,6 +60,18 @@ include_directories(.) if(WIN32) add_definitions(-DWIN32 -D_WINDOWS -DOS_WIN32 -D_CRT_SECURE_NO_WARNINGS) + + # + # https://msrc-blog.microsoft.com/2020/08/17/control-flow-guard-for-clang-llvm-and-rust/ + # + + message("Setting CONTROL FLOW GUARD") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf") + set(CMAKE_EXE_LINKER_FLAGS "/guard:cf /DYNAMICBASE") + + message("Setting QSPECTRE") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qspectre") + endif() if(UNIX)