From 6fe95394431a776210848049e0f1e8dcbf63003e Mon Sep 17 00:00:00 2001 From: charlet Date: Mon, 1 Aug 2011 14:30:34 +0000 Subject: [PATCH] 2011-08-01 Eric Botcazou * gnat_rm.texi: Document limitation of Pragma No_Strict_Aliasing. 2011-08-01 Tristan Gingold * seh_init.c: Fix SEH handler installation on win64. 2011-08-01 Ed Schonberg * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177037 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 14 ++++++++++ gcc/ada/gnat_rm.texi | 2 ++ gcc/ada/seh_init.c | 73 +++++++++++++++------------------------------------- gcc/ada/sem_ch3.adb | 16 ++++++++++++ 4 files changed, 53 insertions(+), 52 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index b1ea032..88e6a37 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,17 @@ +2011-08-01 Eric Botcazou + + * gnat_rm.texi: Document limitation of Pragma No_Strict_Aliasing. + +2011-08-01 Tristan Gingold + + * seh_init.c: Fix SEH handler installation on win64. + +2011-08-01 Ed Schonberg + + * 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. + 2011-08-01 Robert Dewar * make.adb, sem_ch4.adb: Minor reformatting. diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 0eb8482..acccd37 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -3489,6 +3489,8 @@ description of the strict aliasing optimization, and the situations in which it must be suppressed, see @ref{Optimization and Strict Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}. +This pragma currently has no effects on access to unconstrained array types. + @node Pragma Normalize_Scalars @unnumberedsec Pragma Normalize_Scalars @findex Normalize_Scalars diff --git a/gcc/ada/seh_init.c b/gcc/ada/seh_init.c index 2ce99f3..610df54 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) */ diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index c686e90..c44b4e7 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -1172,6 +1172,22 @@ package body Sem_Ch3 is begin F := First (Formals); + + -- In ASIS mode, the access_to_subprogram may be analyzed twice, + -- when it is part of an unconstrained type and subtype expansion + -- is disabled. To avoid back-end problems with shared profiles, + -- use previous subprogram type as the designated type. + + if ASIS_Mode + and then Present (Scope (Defining_Identifier (F))) + then + Set_Etype (T_Name, T_Name); + Init_Size_Align (T_Name); + Set_Directly_Designated_Type (T_Name, + Scope (Defining_Identifier (F))); + return; + end if; + while Present (F) loop if No (Parent (Defining_Identifier (F))) then Set_Parent (Defining_Identifier (F), F); -- 2.7.4