Commit 0bb9276c by Arnaud Charlet

[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
parent ee222ce0
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.
2011-08-01 Robert Dewar <dewar@adacore.com>
* make.adb, sem_ch4.adb: Minor reformatting.
......
......@@ -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
......
......@@ -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) */
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment