mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-19 02:17:50 +08:00
44 lines
1.5 KiB
Diff
44 lines
1.5 KiB
Diff
|
From 53291b332b1bc061a3409d3b60c38f313609b98e Mon Sep 17 00:00:00 2001
|
||
|
From: Matthew Waters <matthew@centricular.com>
|
||
|
Date: Fri, 16 Mar 2018 15:10:04 +1100
|
||
|
Subject: [PATCH] x86/win64: disable runtime stack frame checks with msvc
|
||
|
around built assembly
|
||
|
|
||
|
MSVC can add truntime code that checks if a stack frame is mismanaged
|
||
|
however our custom assembly delibrately accesses and modifies the parent
|
||
|
stack frame. Fortunately we can disable that specific check for the
|
||
|
function call so do that.
|
||
|
---
|
||
|
src/x86/ffiw64.c | 11 +++++++++++
|
||
|
1 file changed, 11 insertions(+)
|
||
|
|
||
|
diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c
|
||
|
index f7875252..88bb3a34 100644
|
||
|
--- a/src/x86/ffiw64.c
|
||
|
+++ b/src/x86/ffiw64.c
|
||
|
@@ -106,6 +106,14 @@ EFI64(ffi_prep_cif_machdep)(ffi_cif *cif)
|
||
|
return FFI_OK;
|
||
|
}
|
||
|
|
||
|
+/* we perform some black magic here to use some of the parent's
|
||
|
+ * stack frame in ff_call_win64() that breaks with the msvc compiler
|
||
|
+ * with the /RTCs or /GZ flags. Disable the 'Stack frame run time
|
||
|
+ * error checking' for this function so we don't hit weird exceptions
|
||
|
+ * in debug builds */
|
||
|
+#if defined(_MSC_VER)
|
||
|
+#pragma runtime_checks("s", off)
|
||
|
+#endif
|
||
|
static void
|
||
|
ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
||
|
void **avalue, void *closure)
|
||
|
@@ -170,6 +178,9 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
||
|
|
||
|
ffi_call_win64 (stack, frame, closure);
|
||
|
}
|
||
|
+#if defined(_MSC_VER)
|
||
|
+#pragma runtime_checks("s", restore)
|
||
|
+#endif
|
||
|
|
||
|
void
|
||
|
EFI64(ffi_call)(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|