loader: add control-flow enforcement to unknown asm file
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index 52e6b29..6739b3a 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -19,6 +19,8 @@
# Check for the existance of the secure_getenv or __secure_getenv commands
include(CheckFunctionExists)
+include(CheckIncludeFile)
+
check_function_exists(secure_getenv HAVE_SECURE_GETENV)
check_function_exists(__secure_getenv HAVE___SECURE_GETENV)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader_cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/loader_cmake_config.h)
@@ -149,6 +151,10 @@
enable_language(ASM)
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}")
+ check_include_file("cet.h" HAVE_CET_H)
+ if(HAVE_CET_H)
+ add_definitions(-DHAVE_CET_H)
+ endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/asm_test.S
".intel_syntax noprefix\n.text\n.global sample\nsample:\nmov ecx, [eax + 16]\n")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
diff --git a/loader/unknown_ext_chain_gas.S b/loader/unknown_ext_chain_gas.S
index 3a422b4..f847e14 100644
--- a/loader/unknown_ext_chain_gas.S
+++ b/loader/unknown_ext_chain_gas.S
@@ -23,7 +23,11 @@
# VkPhysicalDevice or a dispatchable object it can unwrap the object, possibly overwriting the wrapped physical device, and then
# jump to the next function in the call chain
+#ifdef HAVE_CET_H
+#include <cet.h>
+#else
#define _CET_ENDBR
+#endif
.intel_syntax noprefix
.include "gen_defines.asm"