diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-01 16:30:34 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-01 16:30:34 +0200 |
commit | 0bb9276c88e58a10a6711a49b974bb5e71eb37e7 (patch) | |
tree | 4dd72eda6c0336868945cbdd3efd64412ecd91c9 /gcc/ada/seh_init.c | |
parent | ee222ce05cf5321a72c7f70e75a5e839c3e0bdaf (diff) | |
download | gcc-0bb9276c88e58a10a6711a49b974bb5e71eb37e7.tar.gz |
[multiple changes]
2011-08-01 Eric Botcazou <ebotcazou@adacore.com>
* gnat_rm.texi: Document limitation of Pragma No_Strict_Aliasing.
2011-08-01 Tristan Gingold <gingold@adacore.com>
* seh_init.c: Fix SEH handler installation on win64.
2011-08-01 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Access_Subprogram_Declaration): in Asis mode, prevent
double analysis of an anonymous access to subprogram, because it can
lead to improper sharing of profiles and a back-end crash.
From-SVN: r177037
Diffstat (limited to 'gcc/ada/seh_init.c')
-rw-r--r-- | gcc/ada/seh_init.c | 73 |
1 files changed, 21 insertions, 52 deletions
diff --git a/gcc/ada/seh_init.c b/gcc/ada/seh_init.c index 2ce99f3a0c2..610df54d6ab 100644 --- a/gcc/ada/seh_init.c +++ b/gcc/ada/seh_init.c @@ -212,20 +212,6 @@ __gnat_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord, unwinding is handled by the runtime using either the GNAT SJLJ mechanism or the ZCX GCC mechanism. - The current implementation is using the RtlAddFunctionTable. Here is for - information purposes the equivalent using a static .pdata section: - - .section .rdata,"dr" - .align 4 - Lunwind_info: - .byte 9,0,0,0 - .rva ___gnat_SEH_error_handler - .section .pdata,"dr" - .align 4 - .long 0 - .rva etext - .rva Lunwind_info - Solutions based on SetUnhandledExceptionFilter have been discarded as this function is mostly disabled on last Windows versions. Using AddVectoredExceptionHandler should also be discarded as it overrides @@ -233,47 +219,30 @@ __gnat_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord, the loaded DLL (for example it results in unexpected behaviors in the Win32 subsystem. */ -typedef struct _UNWIND_INFO { - BYTE VersionAndFlags; - BYTE PrologSize; - BYTE CountOfUnwindCodes; - BYTE FrameRegisterAndOffset; - ULONG AddressOfExceptionHandler; -} UNWIND_INFO,*PUNWIND_INFO; - -static RUNTIME_FUNCTION Table[1]; -static UNWIND_INFO unwind_info[1]; - -#define UNW_VERSION 0x01 -#define UNW_FLAG_EHANDLER 0x08 +asm +( + " .section .rdata, \"dr\"\n" + " .align 4\n" + "unwind_info:\n" + " .byte 9\n" /* UNW_FLAG_EHANDLER | UNW_VERSION */ + " .byte 0\n" /* Prologue size. */ + " .byte 0\n" /* Count of unwind code. */ + " .byte 0\n" /* Frame register and offset. */ + " .rva __gnat_SEH_error_handler\n" + "\n" + " .section .pdata, \"dr\"\n" + " .align 4\n" + " .long 0\n" /* ImageBase */ + " .rva etext\n" + " .rva unwind_info\n" + "\n" + " .text\n" +); void __gnat_install_SEH_handler (void *eh ATTRIBUTE_UNUSED) { - /* Get the end of the text section. */ - extern char etext[] asm("etext"); - /* Get the base of the module. */ - extern char __ImageBase[]; - - /* Current version is always 1 and we are registering an - exception handler. */ - unwind_info[0].VersionAndFlags = UNW_FLAG_EHANDLER | UNW_VERSION; - - /* We don't use the unwinding info so fill the structure with 0 values. */ - unwind_info[0].PrologSize = 0; - unwind_info[0].CountOfUnwindCodes = 0; - unwind_info[0].FrameRegisterAndOffset = 0; - - /* Add the exception handler. */ - unwind_info[0].AddressOfExceptionHandler = - (DWORD)((char *)__gnat_SEH_error_handler - __ImageBase); - - /* Set its scope to the entire program. */ - Table[0].BeginAddress = 0; - Table[0].EndAddress = (DWORD)(etext - __ImageBase); - Table[0].UnwindData = (DWORD)((char *)unwind_info - __ImageBase); - - /* Register the unwind information. */ - RtlAddFunctionTable (Table, 1, (DWORD64)__ImageBase); + /* Nothing to do, the handler is statically installed by the asm statement + just above. */ } #else /* defined (_WIN64) */ |