diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-07-17 16:23:05 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-07-17 16:23:05 +0000 |
commit | fbfed869106cc9c9cad7538db5e65bcd24f4d92e (patch) | |
tree | 3d69a5eb0a000e681cb45c9e7858e769243450fb /compiler-rt/lib/builtins/enable_execute_stack.c | |
parent | 8e2fb681e3273d5524ae68c6b907e0d675f67138 (diff) | |
download | llvm-fbfed869106cc9c9cad7538db5e65bcd24f4d92e.zip llvm-fbfed869106cc9c9cad7538db5e65bcd24f4d92e.tar.gz llvm-fbfed869106cc9c9cad7538db5e65bcd24f4d92e.tar.bz2 |
compiler-rt: add support for mingw-w64 in builtins
The is so that we can avoid using libgcc and use compiler-rt with
mingw-w64.
Related driver patch
http://reviews.llvm.org/D11077
I have tested this with mingw-w64 and everything seems to be in order.
I also sent this patch to the mingw-w64 mailing list for them to look at.
Patch by Martell Malone.
Differential Revision: http://reviews.llvm.org/D11085
llvm-svn: 242539
Diffstat (limited to 'compiler-rt/lib/builtins/enable_execute_stack.c')
-rw-r--r-- | compiler-rt/lib/builtins/enable_execute_stack.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler-rt/lib/builtins/enable_execute_stack.c b/compiler-rt/lib/builtins/enable_execute_stack.c index 63d836b..23e4940 100644 --- a/compiler-rt/lib/builtins/enable_execute_stack.c +++ b/compiler-rt/lib/builtins/enable_execute_stack.c @@ -10,7 +10,9 @@ #include "int_lib.h" +#ifndef _WIN32 #include <sys/mman.h> +#endif /* #include "config.h" * FIXME: CMake - include when cmake system is ready. @@ -18,9 +20,14 @@ */ #define HAVE_SYSCONF 1 +#ifdef _WIN32 +#include <windef.h> +#include <winbase.h> +#else #ifndef __APPLE__ #include <unistd.h> #endif /* __APPLE__ */ +#endif /* _WIN32 */ #if __LP64__ #define TRAMPOLINE_SIZE 48 @@ -40,6 +47,12 @@ COMPILER_RT_ABI void __enable_execute_stack(void* addr) { +#if _WIN32 + MEMORY_BASIC_INFORMATION mbi; + if (!VirtualQuery (addr, &mbi, sizeof(mbi))) + return; /* We should probably assert here because there is no return value */ + VirtualProtect (mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect); +#else #if __APPLE__ /* On Darwin, pagesize is always 4096 bytes */ const uintptr_t pageSize = 4096; @@ -55,4 +68,5 @@ __enable_execute_stack(void* addr) unsigned char* endPage = (unsigned char*)((p+TRAMPOLINE_SIZE+pageSize) & pageAlignMask); size_t length = endPage - startPage; (void) mprotect((void *)startPage, length, PROT_READ | PROT_WRITE | PROT_EXEC); +#endif } |