OSDN Git Service

Enable trampoline code for nx-protected stack Windows.
authorktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 Apr 2008 09:38:15 +0000 (09:38 +0000)
committerktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 Apr 2008 09:38:15 +0000 (09:38 +0000)
* config/i386/mingw32.h (ENABLE_EXECUTE_STACK): New.
(MINGW_ENABLE_EXECUTE_STACK): New.
(IN_LIBGCC2): For libgcc include windows.h file for
function declarations.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134089 138bc75d-0d04-0410-961f-82ee72b054a4

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

index af44893..05949d1 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 890a096..200569e 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