From 155562cb3bdaf92b9352852b2526082a0b5cfb7e Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 29 Jul 2014 16:12:27 +0200 Subject: [PATCH] [multiple changes] 2014-07-29 Ed Schonberg * gnat_rm.texi: No doc needed for Ada2012 aspect Implicit_dereference. 2014-07-29 Robert Dewar * sem_attr.adb (Attribute_12): New array (Analyze_Attribute): Check impl-defined Ada 2012 attributes. (Check_Ada_2012_Attribute): Removed. 2014-07-29 Doug Rupp * init.c (vxworks6): Call sigtramp for RTP (as well as DKM) for ARM, PPC, and e500. * sigtramp-vxworks.c: New file. * sigtramp-armvxw.c, sigtramp-ppcvxw.c: removed files. From-SVN: r213199 --- gcc/ada/ChangeLog | 18 ++ gcc/ada/gnat_rm.texi | 8 - gcc/ada/init.c | 2 +- gcc/ada/sem_attr.adb | 158 +++++----- gcc/ada/sigtramp-ppcvxw.c | 293 ------------------ .../{sigtramp-armvxw.c => sigtramp-vxworks.c} | 164 +++++++++- 6 files changed, 244 insertions(+), 399 deletions(-) delete mode 100644 gcc/ada/sigtramp-ppcvxw.c rename gcc/ada/{sigtramp-armvxw.c => sigtramp-vxworks.c} (69%) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 71009dc976f..251cc2dd96b 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,21 @@ +2014-07-29 Ed Schonberg + + * gnat_rm.texi: No doc needed for Ada2012 aspect + Implicit_dereference. + +2014-07-29 Robert Dewar + + * sem_attr.adb (Attribute_12): New array + (Analyze_Attribute): Check impl-defined Ada 2012 attributes. + (Check_Ada_2012_Attribute): Removed. + +2014-07-29 Doug Rupp + + * init.c (vxworks6): Call sigtramp for RTP (as well as DKM) for ARM, + PPC, and e500. + * sigtramp-vxworks.c: New file. + * sigtramp-armvxw.c, sigtramp-ppcvxw.c: removed files. + 2014-07-29 Ed Schonberg * lib-xref.adb (Output_Refs, Check_Type_Reference): For a diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index c53ed275c9d..d631fd755c3 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -364,7 +364,6 @@ Implementation Defined Attributes * Attribute Has_Access_Values:: * Attribute Has_Discriminants:: * Attribute Img:: -* Attribute Implicit_Dereference:: * Attribute Integer_Value:: * Attribute Invalid_Value:: * Attribute Iterable:: @@ -8574,7 +8573,6 @@ consideration, you should minimize the use of these attributes. * Attribute Has_Access_Values:: * Attribute Has_Discriminants:: * Attribute Img:: -* Attribute Implicit_Dereference:: * Attribute Integer_Value:: * Attribute Invalid_Value:: * Attribute Iterable:: @@ -9066,12 +9064,6 @@ that returns the appropriate string when called. This means that @code{X'Img} can be renamed as a function-returning-string, or used in an instantiation as a function parameter. -@node Attribute Implicit_Dereference -@unnumberedsec Attribute Implicit_Dereference -@findex Implicit_Dereference -@noindent -PLEASE ADD DOCUMENTATION HERE??? - @node Attribute Integer_Value @unnumberedsec Attribute Integer_Value @findex Integer_Value diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 5f764f6937d..de9b34b0ffb 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -1911,7 +1911,7 @@ __gnat_error_handler (int sig, siginfo_t *si, void *sc) sigdelset (&mask, sig); sigprocmask (SIG_SETMASK, &mask, NULL); -#if defined (__ARMEL__) || (defined (__PPC__) && defined (_WRS_KERNEL)) +#if defined (__ARMEL__) || defined (__PPC__) /* On PowerPC, kernel mode, we process signals through a Call Frame Info trampoline, voiding the need for myriads of fallback_frame_state variants in the ZCX runtime. We have no simple way to distinguish ZCX diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index f35170f0844..bc75fed35a8 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -86,65 +86,75 @@ package body Sem_Attr is -- used so that we can abandon the processing so we don't run into -- trouble with cascaded errors. - -- The following array is the list of attributes defined in the Ada 83 RM - -- that are not included in Ada 95, but still get recognized in GNAT. + -- The following array is the list of attributes defined in the Ada 83 RM: Attribute_83 : constant Attribute_Class_Array := Attribute_Class_Array'( - Attribute_Address | - Attribute_Aft | - Attribute_Alignment | - Attribute_Base | - Attribute_Callable | - Attribute_Constrained | - Attribute_Count | - Attribute_Delta | - Attribute_Digits | - Attribute_Emax | - Attribute_Epsilon | - Attribute_First | - Attribute_First_Bit | - Attribute_Fore | - Attribute_Image | - Attribute_Large | - Attribute_Last | - Attribute_Last_Bit | - Attribute_Leading_Part | - Attribute_Length | - Attribute_Machine_Emax | - Attribute_Machine_Emin | - Attribute_Machine_Mantissa | - Attribute_Machine_Overflows | - Attribute_Machine_Radix | - Attribute_Machine_Rounds | - Attribute_Mantissa | - Attribute_Pos | - Attribute_Position | - Attribute_Pred | - Attribute_Range | - Attribute_Safe_Emax | - Attribute_Safe_Large | - Attribute_Safe_Small | - Attribute_Size | - Attribute_Small | - Attribute_Storage_Size | - Attribute_Succ | - Attribute_Terminated | - Attribute_Val | - Attribute_Value | - Attribute_Width => True, - others => False); + Attribute_Address | + Attribute_Aft | + Attribute_Alignment | + Attribute_Base | + Attribute_Callable | + Attribute_Constrained | + Attribute_Count | + Attribute_Delta | + Attribute_Digits | + Attribute_Emax | + Attribute_Epsilon | + Attribute_First | + Attribute_First_Bit | + Attribute_Fore | + Attribute_Image | + Attribute_Large | + Attribute_Last | + Attribute_Last_Bit | + Attribute_Leading_Part | + Attribute_Length | + Attribute_Machine_Emax | + Attribute_Machine_Emin | + Attribute_Machine_Mantissa | + Attribute_Machine_Overflows | + Attribute_Machine_Radix | + Attribute_Machine_Rounds | + Attribute_Mantissa | + Attribute_Pos | + Attribute_Position | + Attribute_Pred | + Attribute_Range | + Attribute_Safe_Emax | + Attribute_Safe_Large | + Attribute_Safe_Small | + Attribute_Size | + Attribute_Small | + Attribute_Storage_Size | + Attribute_Succ | + Attribute_Terminated | + Attribute_Val | + Attribute_Value | + Attribute_Width => True, + others => False); -- The following array is the list of attributes defined in the Ada 2005 -- RM which are not defined in Ada 95. These are recognized in Ada 95 mode, -- but in Ada 95 they are considered to be implementation defined. Attribute_05 : constant Attribute_Class_Array := Attribute_Class_Array'( - Attribute_Machine_Rounding | - Attribute_Mod | - Attribute_Priority | - Attribute_Stream_Size | - Attribute_Wide_Wide_Width => True, - others => False); + Attribute_Machine_Rounding | + Attribute_Mod | + Attribute_Priority | + Attribute_Stream_Size | + Attribute_Wide_Wide_Width => True, + others => False); + + -- The following array is the list of attributes defined in the Ada 2012 + -- RM which are not defined in Ada 2005. These are recognized in Ada 95 + -- and Ada 2005 modes, but are considered to be implementation defined. + + Attribute_12 : constant Attribute_Class_Array := Attribute_Class_Array'( + Attribute_First_Valid | + Attribute_Has_Same_Storage | + Attribute_Last_Valid | + Attribute_Max_Alignment_For_Allocation => True, + others => False); -- The following array contains all attributes that imply a modification -- of their prefixes or result in an access value. Such prefixes can be @@ -152,13 +162,13 @@ package body Sem_Attr is Attribute_Name_Implies_Lvalue_Prefix : constant Attribute_Class_Array := Attribute_Class_Array'( - Attribute_Access | - Attribute_Address | - Attribute_Input | - Attribute_Read | - Attribute_Unchecked_Access | - Attribute_Unrestricted_Access => True, - others => False); + Attribute_Access | + Attribute_Address | + Attribute_Input | + Attribute_Read | + Attribute_Unchecked_Access | + Attribute_Unrestricted_Access => True, + others => False); ----------------------- -- Local_Subprograms -- @@ -180,8 +190,7 @@ package body Sem_Attr is function Is_Anonymous_Tagged_Base (Anon : Entity_Id; - Typ : Entity_Id) - return Boolean; + Typ : Entity_Id) return Boolean; -- For derived tagged types that constrain parent discriminants we build -- an anonymous unconstrained base type. We need to recognize the relation -- between the two when analyzing an access attribute for a constrained @@ -235,11 +244,6 @@ package body Sem_Attr is -- for internally generated uses of the attributes. This legality rule -- only applies to scalar types. - procedure Check_Ada_2012_Attribute; - -- Check that we are in Ada 2012 mode for an Ada 2012 attribute, and - -- issue appropriate messages if not (and return to caller even in - -- the error case). - procedure Check_Array_Or_Scalar_Type; -- Common procedure used by First, Last, Range attribute to check -- that the prefix is a constrained array or scalar type, or a name @@ -1083,16 +1087,6 @@ package body Sem_Attr is end if; end Bad_Attribute_For_Predicate; - ------------------------------ - -- Check_Ada_2012_Attribute -- - ------------------------------ - - procedure Check_Ada_2012_Attribute is - begin - Error_Msg_Name_1 := Aname; - Error_Msg_Ada_2012_Feature ("attribute %", Sloc (N)); - end Check_Ada_2012_Attribute; - -------------------------------- -- Check_Array_Or_Scalar_Type -- -------------------------------- @@ -1487,7 +1481,6 @@ package body Sem_Attr is procedure Check_First_Last_Valid is begin - Check_Ada_2012_Attribute; Check_Discrete_Type; -- Freeze the subtype now, so that the following test for predicates @@ -2382,9 +2375,13 @@ package body Sem_Attr is end if; -- Deal with Ada 2005 attributes that are implementation attributes - -- because they appear in a version of Ada before Ada 2005. + -- because they appear in a version of Ada before Ada 2005, and + -- similarly for Ada 2012 attributes appearing in an earlier version. - if Attribute_05 (Attr_Id) and then Ada_Version < Ada_2005 then + if (Attribute_05 (Attr_Id) and then Ada_Version < Ada_2005) + or else + (Attribute_12 (Attr_Id) and then Ada_Version < Ada_2012) + then Check_Restriction (No_Implementation_Attributes, N); end if; @@ -3646,7 +3643,6 @@ package body Sem_Attr is ---------------------- when Attribute_Has_Same_Storage => - Check_Ada_2012_Attribute; Check_E1; -- The arguments must be objects of any type @@ -6335,7 +6331,6 @@ package body Sem_Attr is begin Check_E1; - Check_Ada_2012_Attribute; if not Is_Object_Reference (P) then Error_Attr_P ("prefix of attribute % must denote an object"); @@ -9766,8 +9761,7 @@ package body Sem_Attr is function Is_Anonymous_Tagged_Base (Anon : Entity_Id; - Typ : Entity_Id) - return Boolean + Typ : Entity_Id) return Boolean is begin return diff --git a/gcc/ada/sigtramp-ppcvxw.c b/gcc/ada/sigtramp-ppcvxw.c deleted file mode 100644 index ff2f0a8792b..00000000000 --- a/gcc/ada/sigtramp-ppcvxw.c +++ /dev/null @@ -1,293 +0,0 @@ -/**************************************************************************** - * * - * GNAT COMPILER COMPONENTS * - * * - * S I G T R A M P * - * * - * Asm Implementation File * - * * - * Copyright (C) 2011-2014, Free Software Foundation, Inc. * - * * - * GNAT is free software; you can redistribute it and/or modify it under * - * terms of the GNU General Public License as published by the Free Soft- * - * ware Foundation; either version 3, or (at your option) any later ver- * - * sion. GNAT is distributed in the hope that it will be useful, but WITH- * - * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * - * or FITNESS FOR A PARTICULAR PURPOSE. * - * * - * As a special exception under Section 7 of GPL version 3, you are granted * - * additional permissions described in the GCC Runtime Library Exception, * - * version 3.1, as published by the Free Software Foundation. * - * * - * You should have received a copy of the GNU General Public License and * - * a copy of the GCC Runtime Library Exception along with this program; * - * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see * - * . * - * * - * GNAT was originally developed by the GNAT team at New York University. * - * Extensive contributions were provided by Ada Core Technologies Inc. * - * * - ****************************************************************************/ - -/********************************************************** - * PowerPC-VxWorks version of the __gnat_sigtramp service * - **********************************************************/ - -#include "sigtramp.h" -/* See sigtramp.h for a general explanation of functionality. */ - -#include -#include -#include - -/* ---------------------- - -- General comments -- - ---------------------- - - Stubs are generated from toplevel asms and .cfi directives, much simpler - to use and check for correctness than manual encodings of CFI byte - sequences. The general idea is to establish CFA as sigcontext->sc_pregs - and state where to find the registers as offsets from there. - - As of today, we support a stub providing CFI info for common - registers (GPRs, LR, ...). We might need variants with support for floating - point or altivec registers as well at some point. - - Checking which variant should apply and getting at sc_pregs is simpler - to express in C (we can't use offsetof in toplevel asms and hardcoding - constants is not workable with the flurry of VxWorks variants), so this - is the choice for our toplevel interface. - - Note that the registers we "restore" here are those to which we have - direct access through the system sigcontext structure, which includes - only a partial set of the non-volatiles ABI-wise. */ - -/* ----------------------------------------- - -- Protypes for our internal asm stubs -- - ----------------------------------------- - - SC_PREGS is always expected to be SIGCONTEXT->sc_pregs. Eventhough our - symbols will remain local, the prototype claims "extern" and not - "static" to prevent compiler complaints about a symbol used but never - defined. */ - -/* sigtramp stub providing CFI info for common registers. */ - -extern void __gnat_sigtramp_common -(int signo, void *siginfo, void *sigcontext, - __sigtramphandler_t * handler, void * sc_pregs); - - -/* ------------------------------------- - -- Common interface implementation -- - ------------------------------------- - - We enforce optimization to minimize the overhead of the extra layer. */ - -void __gnat_sigtramp (int signo, void *si, void *sc, - __sigtramphandler_t * handler) - __attribute__((optimize(2))); - -void __gnat_sigtramp (int signo, void *si, void *sc, - __sigtramphandler_t * handler) -{ - struct sigcontext * sctx = (struct sigcontext *) sc; - - __gnat_sigtramp_common (signo, si, sctx, handler, sctx->sc_pregs); -} - - -/* --------------------------- - -- And now the asm stubs -- - --------------------------- - - They all have a common structure with blocks of asm sequences queued one - after the others. Typically: - - SYMBOL_START - - CFI_DIRECTIVES - CFI_DEF_CFA, - CFI_COMMON_REGISTERS, - ... - - STUB_BODY - asm code to establish frame, setup the cfa reg value, - call the real signal handler, ... - - SYMBOL_END -*/ - -/*-------------------------------- - -- Misc constants and helpers -- - -------------------------------- */ - -/* REGNO constants, dwarf column numbers for registers of interest. */ - -#define REGNO_LR 65 -#define REGNO_CTR 66 -#define REGNO_CR 70 -#define REGNO_XER 76 -#define REGNO_GR(N) (N) - -#define REGNO_PC 67 /* ARG_POINTER_REGNUM */ - -/* asm string construction helpers. */ - -#define STR(TEXT) #TEXT -/* stringify expanded TEXT, surrounding it with double quotes. */ - -#define S(E) STR(E) -/* stringify E, which will resolve as text but may contain macros - still to be expanded. */ - -/* asm (TEXT) outputs TEXT. These facilitate the output of - multine contents: */ -#define TAB(S) "\t" S -#define CR(S) S "\n" - -#undef TCR -#define TCR(S) TAB(CR(S)) - -/*------------------------------ - -- Stub construction blocks -- - ------------------------------ */ - -/* CFA setup block - --------------- - Only non-volatile registers are suitable for a CFA base. These are the - only ones we can expect to be able retrieve from the unwinding context - while walking up the chain, saved by at least the bottom-most exception - propagation services. We use r15 here and set it to the value we need - in stub body that follows. Note that r14 is inappropriate here, even - though it is non-volatile according to the ABI, because GCC uses it as - an extra SCRATCH on SPE targets. */ - -#define CFA_REG 15 - -#define CFI_DEF_CFA \ -CR(".cfi_def_cfa " S(CFA_REG) ", 0") - -/* Register location blocks - ------------------------ - Rules to find registers of interest from the CFA. This should comprise - all the non-volatile registers relevant to the interrupted context. - - Note that we include r1 in this set, unlike the libgcc unwinding - fallbacks. This is useful for fallbacks to allow the use of r1 in CFI - expressions and the absence of rule for r1 gets compensated by using the - target CFA instead. We don't need the expression facility here and - setup a fake CFA to allow very simple offset expressions, so having a - rule for r1 is the proper thing to do. We for sure have observed - crashes in some cases without it. */ - -#define COMMON_CFI(REG) \ - ".cfi_offset " S(REGNO_##REG) "," S(REG_SET_##REG) - -#define CFI_COMMON_REGS \ -CR("# CFI for common registers\n") \ -TCR(COMMON_CFI(GR(0))) \ -TCR(COMMON_CFI(GR(1))) \ -TCR(COMMON_CFI(GR(2))) \ -TCR(COMMON_CFI(GR(3))) \ -TCR(COMMON_CFI(GR(4))) \ -TCR(COMMON_CFI(GR(5))) \ -TCR(COMMON_CFI(GR(6))) \ -TCR(COMMON_CFI(GR(7))) \ -TCR(COMMON_CFI(GR(8))) \ -TCR(COMMON_CFI(GR(9))) \ -TCR(COMMON_CFI(GR(10))) \ -TCR(COMMON_CFI(GR(11))) \ -TCR(COMMON_CFI(GR(12))) \ -TCR(COMMON_CFI(GR(13))) \ -TCR(COMMON_CFI(GR(14))) \ -TCR(COMMON_CFI(GR(15))) \ -TCR(COMMON_CFI(GR(16))) \ -TCR(COMMON_CFI(GR(17))) \ -TCR(COMMON_CFI(GR(18))) \ -TCR(COMMON_CFI(GR(19))) \ -TCR(COMMON_CFI(GR(20))) \ -TCR(COMMON_CFI(GR(21))) \ -TCR(COMMON_CFI(GR(22))) \ -TCR(COMMON_CFI(GR(23))) \ -TCR(COMMON_CFI(GR(24))) \ -TCR(COMMON_CFI(GR(25))) \ -TCR(COMMON_CFI(GR(26))) \ -TCR(COMMON_CFI(GR(27))) \ -TCR(COMMON_CFI(GR(28))) \ -TCR(COMMON_CFI(GR(29))) \ -TCR(COMMON_CFI(GR(30))) \ -TCR(COMMON_CFI(GR(31))) \ -TCR(COMMON_CFI(LR)) \ -TCR(COMMON_CFI(CR)) \ -TCR(COMMON_CFI(CTR)) \ -TCR(COMMON_CFI(XER)) \ -TCR(COMMON_CFI(PC)) \ -TCR(".cfi_return_column " S(REGNO_PC)) - -/* Trampoline body block - --------------------- */ - -#define SIGTRAMP_BODY \ -CR("") \ -TCR("# Allocate frame and save the non-volatile") \ -TCR("# registers we're going to modify") \ -TCR("stwu %r1,-16(%r1)") \ -TCR("mflr %r0") \ -TCR("stw %r0,20(%r1)") \ -TCR("stw %r" S(CFA_REG) ",8(%r1)") \ -TCR("") \ -TCR("# Setup CFA_REG = sc_pregs, that we'll retrieve as our CFA value") \ -TCR("mr %r" S(CFA_REG) ", %r7") \ -TCR("") \ -TCR("# Call the real handler. The signo, siginfo and sigcontext") \ -TCR("# arguments are the same as those we received in r3, r4 and r5") \ -TCR("mtctr %r6") \ -TCR("bctrl") \ -TCR("") \ -TCR("# Restore our callee-saved items, release our frame and return") \ -TCR("lwz %r" S(CFA_REG) ",8(%r1)") \ -TCR("lwz %r0,20(%r1)") \ -TCR("mtlr %r0") \ -TCR("") \ -TCR("addi %r1,%r1,16") \ -TCR("blr") - -/* Symbol definition block - ----------------------- */ - -#define SIGTRAMP_START(SYM) \ -CR("# " S(SYM) " cfi trampoline") \ -TCR(".type " S(SYM) ", @function") \ -CR("") \ -CR(S(SYM) ":") \ -TCR(".cfi_startproc") \ -TCR(".cfi_signal_frame") - -/* Symbol termination block - ------------------------ */ - -#define SIGTRAMP_END(SYM) \ -CR(".cfi_endproc") \ -TCR(".size " S(SYM) ", .-" S(SYM)) - -/*---------------------------- - -- And now, the real code -- - ---------------------------- */ - -/* Text section start. The compiler isn't aware of that switch. */ - -asm (".text\n" - TCR(".align 2")); - -/* sigtramp stub for common registers. */ - -#define TRAMP_COMMON __gnat_sigtramp_common - -asm (SIGTRAMP_START(TRAMP_COMMON)); -asm (CFI_DEF_CFA); -asm (CFI_COMMON_REGS); -asm (SIGTRAMP_BODY); -asm (SIGTRAMP_END(TRAMP_COMMON)); - - diff --git a/gcc/ada/sigtramp-armvxw.c b/gcc/ada/sigtramp-vxworks.c similarity index 69% rename from gcc/ada/sigtramp-armvxw.c rename to gcc/ada/sigtramp-vxworks.c index 0cef508908e..bd65b641981 100644 --- a/gcc/ada/sigtramp-armvxw.c +++ b/gcc/ada/sigtramp-vxworks.c @@ -6,7 +6,7 @@ * * * Asm Implementation File * * * - * Copyright (C) 2014, Free Software Foundation, Inc. * + * Copyright (C) 2011-2014, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -29,9 +29,9 @@ * * ****************************************************************************/ -/****************************************************** - * ARM-VxWorks version of the __gnat_sigtramp service * - ******************************************************/ +/************************************************** + * VxWorks version of the __gnat_sigtramp service * + **************************************************/ #include "sigtramp.h" /* See sigtramp.h for a general explanation of functionality. */ @@ -42,7 +42,20 @@ #include #else #include -#include +#include + +typedef struct mcontext + { + REG_SET regs; + } mcontext_t; + +typedef struct ucontext + { + mcontext_t uc_mcontext; /* register set */ + struct ucontext * uc_link; /* not used */ + sigset_t uc_sigmask; /* set of signals blocked */ + stack_t uc_stack; /* stack of context signaled */ + } ucontext_t; #endif /* ---------------------- @@ -135,12 +148,6 @@ void __gnat_sigtramp (int signo, void *si, void *sc, -- Misc constants and helpers -- -------------------------------- */ -/* REGNO constants, dwarf column numbers for registers of interest. */ - -#define REGNO_G_REG_OFFSET(N) (N) - -#define REGNO_PC_OFFSET 15 /* PC_REGNUM */ - /* asm string construction helpers. */ #define STR(TEXT) #TEXT @@ -158,6 +165,33 @@ void __gnat_sigtramp (int signo, void *si, void *sc, #undef TCR #define TCR(S) TAB(CR(S)) +/* REGNO constants, dwarf column numbers for registers of interest. */ + +#if defined (__PPC__) + +#define REGNO_LR 65 +#define REGNO_CTR 66 +#define REGNO_CR 70 +#define REGNO_XER 76 +#define REGNO_GR(N) (N) + +#define REGNO_PC 67 /* ARG_POINTER_REGNUM */ + +#define FUNCTION "@function" + +#elif defined (__ARMEL__) + +#define REGNO_G_REG_OFFSET(N) (N) + +#define REGNO_PC_OFFSET 15 /* PC_REGNUM */ + +#define FUNCTION "%function" + +#else +Not implemented; +#endif /* REGNO constants */ + + /*------------------------------ -- Stub construction blocks -- ------------------------------ */ @@ -167,22 +201,119 @@ void __gnat_sigtramp (int signo, void *si, void *sc, Only non-volatile registers are suitable for a CFA base. These are the only ones we can expect to be able retrieve from the unwinding context while walking up the chain, saved by at least the bottom-most exception - propagation services. We use r8 here and set it to the value we need - in stub body that follows. Any of r4-r8 should work. */ + propagation services. We set a non-volatile register to the value we + need in the stub body that follows. */ + +#if defined (__PPC__) + +/* Use r15 for PPC. Note that r14 is inappropriate here, even though it + is non-volatile according to the ABI, because GCC uses it as an extra + SCRATCH on SPE targets. */ + +#define CFA_REG 15 + +#elif defined (__ARMEL__) + +/* Use r8 for ARM. Any of r4-r8 should work. */ #define CFA_REG 8 +#else +Not_implemented; +#endif /* CFA setup block */ + #define CFI_DEF_CFA \ CR(".cfi_def_cfa " S(CFA_REG) ", 0") /* Register location blocks ------------------------ Rules to find registers of interest from the CFA. This should comprise - all the non-volatile registers relevant to the interrupted context. */ + all the non-volatile registers relevant to the interrupted context. + + Note that we include r1 in this set, unlike the libgcc unwinding + fallbacks. This is useful for fallbacks to allow the use of r1 in CFI + expressions and the absence of rule for r1 gets compensated by using the + target CFA instead. We don't need the expression facility here and + setup a fake CFA to allow very simple offset expressions, so having a + rule for r1 is the proper thing to do. We for sure have observed + crashes in some cases without it. */ #define COMMON_CFI(REG) \ ".cfi_offset " S(REGNO_##REG) "," S(REG_SET_##REG) +#if defined (__PPC__) + +#define CFI_COMMON_REGS \ +CR("# CFI for common registers\n") \ +TCR(COMMON_CFI(GR(0))) \ +TCR(COMMON_CFI(GR(1))) \ +TCR(COMMON_CFI(GR(2))) \ +TCR(COMMON_CFI(GR(3))) \ +TCR(COMMON_CFI(GR(4))) \ +TCR(COMMON_CFI(GR(5))) \ +TCR(COMMON_CFI(GR(6))) \ +TCR(COMMON_CFI(GR(7))) \ +TCR(COMMON_CFI(GR(8))) \ +TCR(COMMON_CFI(GR(9))) \ +TCR(COMMON_CFI(GR(10))) \ +TCR(COMMON_CFI(GR(11))) \ +TCR(COMMON_CFI(GR(12))) \ +TCR(COMMON_CFI(GR(13))) \ +TCR(COMMON_CFI(GR(14))) \ +TCR(COMMON_CFI(GR(15))) \ +TCR(COMMON_CFI(GR(16))) \ +TCR(COMMON_CFI(GR(17))) \ +TCR(COMMON_CFI(GR(18))) \ +TCR(COMMON_CFI(GR(19))) \ +TCR(COMMON_CFI(GR(20))) \ +TCR(COMMON_CFI(GR(21))) \ +TCR(COMMON_CFI(GR(22))) \ +TCR(COMMON_CFI(GR(23))) \ +TCR(COMMON_CFI(GR(24))) \ +TCR(COMMON_CFI(GR(25))) \ +TCR(COMMON_CFI(GR(26))) \ +TCR(COMMON_CFI(GR(27))) \ +TCR(COMMON_CFI(GR(28))) \ +TCR(COMMON_CFI(GR(29))) \ +TCR(COMMON_CFI(GR(30))) \ +TCR(COMMON_CFI(GR(31))) \ +TCR(COMMON_CFI(LR)) \ +TCR(COMMON_CFI(CR)) \ +TCR(COMMON_CFI(CTR)) \ +TCR(COMMON_CFI(XER)) \ +TCR(COMMON_CFI(PC)) \ +TCR(".cfi_return_column " S(REGNO_PC)) + +/* Trampoline body block + --------------------- */ + +#define SIGTRAMP_BODY \ +CR("") \ +TCR("# Allocate frame and save the non-volatile") \ +TCR("# registers we're going to modify") \ +TCR("stwu %r1,-16(%r1)") \ +TCR("mflr %r0") \ +TCR("stw %r0,20(%r1)") \ +TCR("stw %r" S(CFA_REG) ",8(%r1)") \ +TCR("") \ +TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \ +TCR("mr %r" S(CFA_REG) ", %r7") \ +TCR("") \ +TCR("# Call the real handler. The signo, siginfo and sigcontext") \ +TCR("# arguments are the same as those we received in r3, r4 and r5") \ +TCR("mtctr %r6") \ +TCR("bctrl") \ +TCR("") \ +TCR("# Restore our callee-saved items, release our frame and return") \ +TCR("lwz %r" S(CFA_REG) ",8(%r1)") \ +TCR("lwz %r0,20(%r1)") \ +TCR("mtlr %r0") \ +TCR("") \ +TCR("addi %r1,%r1,16") \ +TCR("blr") + +#elif defined (__ARMEL__) + #define CFI_COMMON_REGS \ CR("# CFI for common registers\n") \ TCR(COMMON_CFI(G_REG_OFFSET(0))) \ @@ -222,13 +353,16 @@ TCR("blx r3") \ TCR("# Restore our callee-saved items, release our frame and return") \ TCR("ldmfd sp, {r"S(CFA_REG)", fp, sp, pc}") +#else +Not_implemented; +#endif /* CFI_COMMON_REGS and SIGTRAMP_BODY */ /* Symbol definition block ----------------------- */ #define SIGTRAMP_START(SYM) \ CR("# " S(SYM) " cfi trampoline") \ -TCR(".type " S(SYM) ", %function") \ +TCR(".type " S(SYM) ", "FUNCTION) \ CR("") \ CR(S(SYM) ":") \ TCR(".cfi_startproc") \ -- 2.30.2