Enable trampoline code for nx-protected stack Windows.
authorKai Tietz <kai.tietz@onevision.com>
Tue, 8 Apr 2008 09:38:15 +0000 (09:38 +0000)
committerKai Tietz <ktietz@gcc.gnu.org>
Tue, 8 Apr 2008 09:38:15 +0000 (11:38 +0200)
* config/i386/mingw32.h (ENABLE_EXECUTE_STACK): New.
(MINGW_ENABLE_EXECUTE_STACK): New.
(IN_LIBGCC2): For libgcc include windows.h file for
function declarations.

From-SVN: r134089

gcc/ChangeLog
gcc/config/i386/mingw32.h

index af448939d3edd8096534a7db43a8d3fb20fb6fc7..05949d1777c7a1772523f9e0e2a9c4d7774c2198 100644 (file)
@@ -1,3 +1,10 @@
+2008-04-08  Kai Tietz  <kai.tietz@onevision.com>
+
+       * config/i386/mingw32.h (ENABLE_EXECUTE_STACK): New.
+       (MINGW_ENABLE_EXECUTE_STACK): New.
+       (IN_LIBGCC2): For libgcc include windows.h file for
+       function declarations.
+
 2008-04-08  Hans-Peter Nilsson  <hp@axis.com>
 
        * config/cris/cris.c (cris_address_cost): For a PLUS, swap tem1
index 890a09674dd82fa419448a204146f56487e4fad6..200569ed09065d4d049ee7603641e35fdaa0818b 100644 (file)
@@ -164,6 +164,27 @@ do {                                                        \
 #undef TARGET_USE_JCR_SECTION
 #define TARGET_USE_JCR_SECTION 1
 
+#undef MINGW_ENABLE_EXECUTE_STACK
+#define MINGW_ENABLE_EXECUTE_STACK     \
+extern void __enable_execute_stack (void *);    \
+void         \
+__enable_execute_stack (void *addr)                                    \
+{                                                                      \
+  MEMORY_BASIC_INFORMATION b;                                          \
+  if (!VirtualQuery (addr, &b, sizeof(b)))                             \
+    abort ();                                                          \
+  VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, \
+                 &b.Protect);                                          \
+}
+
+#undef ENABLE_EXECUTE_STACK
+#define ENABLE_EXECUTE_STACK MINGW_ENABLE_EXECUTE_STACK
+
+
+#ifdef IN_LIBGCC2
+#include <windows.h>
+#endif
+
 #if !TARGET_64BIT
 #define MD_UNWIND_SUPPORT "config/i386/w32-unwind.h"
 #endif