From 0b03b302ae4b9a2785e5011f5fa4c2c198a8eb4b Mon Sep 17 00:00:00 2001 From: Kai Tietz Date: Tue, 8 Apr 2008 09:38:15 +0000 Subject: [PATCH] Enable trampoline code for nx-protected stack Windows. * 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 | 7 +++++++ gcc/config/i386/mingw32.h | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index af448939d3e..05949d1777c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2008-04-08 Kai Tietz + + * 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 * config/cris/cris.c (cris_address_cost): For a PLUS, swap tem1 diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index 890a09674dd..200569ed090 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -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 +#endif + #if !TARGET_64BIT #define MD_UNWIND_SUPPORT "config/i386/w32-unwind.h" #endif -- 2.30.2