xref: /netbsd-src/external/gpl3/gcc.old/dist/libgcc/config/i386/enable-execute-stack-mingw32.c (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg /* Implement __enable_execute_stack for Windows32.
2*8feb0f0bSmrg    Copyright (C) 2011-2020 Free Software Foundation, Inc.
31debfc3dSmrg 
41debfc3dSmrg    This file is part of GCC.
51debfc3dSmrg 
61debfc3dSmrg    GCC is free software; you can redistribute it and/or modify it under
71debfc3dSmrg    the terms of the GNU General Public License as published by the Free
81debfc3dSmrg    Software Foundation; either version 3, or (at your option) any later
91debfc3dSmrg    version.
101debfc3dSmrg 
111debfc3dSmrg    GCC is distributed in the hope that it will be useful, but WITHOUT ANY
121debfc3dSmrg    WARRANTY; without even the implied warranty of MERCHANTABILITY or
131debfc3dSmrg    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
141debfc3dSmrg    for more details.
151debfc3dSmrg 
161debfc3dSmrg    Under Section 7 of GPL version 3, you are granted additional
171debfc3dSmrg    permissions described in the GCC Runtime Library Exception, version
181debfc3dSmrg    3.1, as published by the Free Software Foundation.
191debfc3dSmrg 
201debfc3dSmrg    You should have received a copy of the GNU General Public License and
211debfc3dSmrg    a copy of the GCC Runtime Library Exception along with this program;
221debfc3dSmrg    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
231debfc3dSmrg    <http://www.gnu.org/licenses/>.  */
241debfc3dSmrg 
251debfc3dSmrg #include <windows.h>
261debfc3dSmrg 
271debfc3dSmrg extern void __enable_execute_stack (void *);
281debfc3dSmrg 
291debfc3dSmrg void
__enable_execute_stack(void * addr)301debfc3dSmrg __enable_execute_stack (void *addr)
311debfc3dSmrg {
321debfc3dSmrg   MEMORY_BASIC_INFORMATION b;
331debfc3dSmrg 
341debfc3dSmrg   if (!VirtualQuery (addr, &b, sizeof(b)))
351debfc3dSmrg     abort ();
361debfc3dSmrg   VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE,
371debfc3dSmrg 		  &b.Protect);
381debfc3dSmrg }
39