+2014-07-29 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat_rm.texi: No doc needed for Ada2012 aspect
+ Implicit_dereference.
+
+2014-07-29 Robert Dewar <dewar@adacore.com>
+
+ * 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 <rupp@adacore.com>
+
+ * 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 <schonberg@adacore.com>
* lib-xref.adb (Output_Refs, Check_Type_Reference): For a
* Attribute Has_Access_Values::
* Attribute Has_Discriminants::
* Attribute Img::
-* Attribute Implicit_Dereference::
* Attribute Integer_Value::
* Attribute Invalid_Value::
* Attribute Iterable::
* Attribute Has_Access_Values::
* Attribute Has_Discriminants::
* Attribute Img::
-* Attribute Implicit_Dereference::
* Attribute Integer_Value::
* Attribute Invalid_Value::
* Attribute Iterable::
@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
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
-- 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
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 --
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
-- 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
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 --
--------------------------------
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
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;
----------------------
when Attribute_Has_Same_Storage =>
- Check_Ada_2012_Attribute;
Check_E1;
-- The arguments must be objects of any type
begin
Check_E1;
- Check_Ada_2012_Attribute;
if not Is_Object_Reference (P) then
Error_Attr_P ("prefix of attribute % must denote an object");
function Is_Anonymous_Tagged_Base
(Anon : Entity_Id;
- Typ : Entity_Id)
- return Boolean
+ Typ : Entity_Id) return Boolean
is
begin
return
+++ /dev/null
-/****************************************************************************
- * *
- * GNAT COMPILER COMPONENTS *
- * *
- * S I G T R A M P *
- * *
- * Asm Implementation File *
- * *
- * Copyright (C) 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. *
- * *
- * In particular, you can freely distribute your programs built with the *
- * GNAT Pro compiler, including any required library run-time units, using *
- * any licensing terms of your choosing. See the AdaCore Software License *
- * for full details. *
- * *
- * GNAT was originally developed by the GNAT team at New York University. *
- * Extensive contributions were provided by Ada Core Technologies Inc. *
- * *
- ****************************************************************************/
-
-/******************************************************
- * ARM-VxWorks version of the __gnat_sigtramp service *
- ******************************************************/
-
-#include "sigtramp.h"
-/* See sigtramp.h for a general explanation of functionality. */
-
-#include <vxWorks.h>
-#include <arch/../regs.h>
-#ifndef __RTP__
-#include <sigLib.h>
-#else
-#include <signal.h>
-#include <base/b_ucontext_t.h>
-#endif
-
-/* ----------------------
- -- 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
- (for DKM) and mcontext (for RTP) 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 / mcontext
- 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. */
-
-/* -------------------------------------------
- -- Prototypes for our internal asm stubs --
- -------------------------------------------
-
- 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)
-{
-#ifdef __RTP__
- mcontext_t *mcontext = &((ucontext_t *) sc)->uc_mcontext;
-
- /* Pass MCONTEXT in the fifth position so that the assembly code can find
- it at the same stack location or in the same register as SC_PREGS. */
- __gnat_sigtramp_common (signo, si, mcontext, handler, mcontext);
-#else
- struct sigcontext * sctx = (struct sigcontext *) sc;
-
- __gnat_sigtramp_common (signo, si, sctx, handler, sctx->sc_pregs);
-#endif
-}
-
-
-/* ---------------------------
- -- 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_G_REG_OFFSET(N) (N)
-
-#define REGNO_PC_OFFSET 15 /* PC_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 <tab>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 r8 here and set it to the value we need
- in stub body that follows. Any of r4-r8 should work. */
-
-#define CFA_REG 8
-
-#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. */
-
-#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(G_REG_OFFSET(0))) \
-TCR(COMMON_CFI(G_REG_OFFSET(1))) \
-TCR(COMMON_CFI(G_REG_OFFSET(2))) \
-TCR(COMMON_CFI(G_REG_OFFSET(3))) \
-TCR(COMMON_CFI(G_REG_OFFSET(4))) \
-TCR(COMMON_CFI(G_REG_OFFSET(5))) \
-TCR(COMMON_CFI(G_REG_OFFSET(6))) \
-TCR(COMMON_CFI(G_REG_OFFSET(7))) \
-TCR(COMMON_CFI(G_REG_OFFSET(8))) \
-TCR(COMMON_CFI(G_REG_OFFSET(9))) \
-TCR(COMMON_CFI(G_REG_OFFSET(10))) \
-TCR(COMMON_CFI(G_REG_OFFSET(11))) \
-TCR(COMMON_CFI(G_REG_OFFSET(12))) \
-TCR(COMMON_CFI(G_REG_OFFSET(13))) \
-TCR(COMMON_CFI(G_REG_OFFSET(14))) \
-TCR(COMMON_CFI(PC_OFFSET)) \
-TCR(".cfi_return_column " S(REGNO_PC_OFFSET))
-
-/* Trampoline body block
- --------------------- */
-
-#define SIGTRAMP_BODY \
-CR("") \
-TCR("# Allocate frame and save the non-volatile") \
-TCR("# registers we're going to modify") \
-TCR("mov ip, sp") \
-TCR("stmfd sp!, {r"S(CFA_REG)", fp, ip, lr, pc}") \
-TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \
-TCR("ldr r"S(CFA_REG)", [ip]") \
-TCR("") \
-TCR("# Call the real handler. The signo, siginfo and sigcontext") \
-TCR("# arguments are the same as those we received in r0, r1 and r2") \
-TCR("sub fp, ip, #4") \
-TCR("blx r3") \
-TCR("# Restore our callee-saved items, release our frame and return") \
-TCR("ldmfd sp, {r"S(CFA_REG)", fp, sp, pc}")
-
-
-/* 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));
-
-
+++ /dev/null
-/****************************************************************************
- * *
- * 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 *
- * <http://www.gnu.org/licenses/>. *
- * *
- * 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 <vxWorks.h>
-#include <arch/../regs.h>
-#include <sigLib.h>
-
-/* ----------------------
- -- 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 <tab>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));
-
-
--- /dev/null
+/****************************************************************************
+ * *
+ * 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. *
+ * *
+ * In particular, you can freely distribute your programs built with the *
+ * GNAT Pro compiler, including any required library run-time units, using *
+ * any licensing terms of your choosing. See the AdaCore Software License *
+ * for full details. *
+ * *
+ * GNAT was originally developed by the GNAT team at New York University. *
+ * Extensive contributions were provided by Ada Core Technologies Inc. *
+ * *
+ ****************************************************************************/
+
+/**************************************************
+ * VxWorks version of the __gnat_sigtramp service *
+ **************************************************/
+
+#include "sigtramp.h"
+/* See sigtramp.h for a general explanation of functionality. */
+
+#include <vxWorks.h>
+#include <arch/../regs.h>
+#ifndef __RTP__
+#include <sigLib.h>
+#else
+#include <signal.h>
+#include <regs.h>
+
+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
+
+/* ----------------------
+ -- 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
+ (for DKM) and mcontext (for RTP) 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 / mcontext
+ 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. */
+
+/* -------------------------------------------
+ -- Prototypes for our internal asm stubs --
+ -------------------------------------------
+
+ 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)
+{
+#ifdef __RTP__
+ mcontext_t *mcontext = &((ucontext_t *) sc)->uc_mcontext;
+
+ /* Pass MCONTEXT in the fifth position so that the assembly code can find
+ it at the same stack location or in the same register as SC_PREGS. */
+ __gnat_sigtramp_common (signo, si, mcontext, handler, mcontext);
+#else
+ struct sigcontext * sctx = (struct sigcontext *) sc;
+
+ __gnat_sigtramp_common (signo, si, sctx, handler, sctx->sc_pregs);
+#endif
+}
+
+
+/* ---------------------------
+ -- 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 --
+ -------------------------------- */
+
+/* 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 <tab>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))
+
+/* 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 --
+ ------------------------------ */
+
+/* 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 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.
+
+ 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))) \
+TCR(COMMON_CFI(G_REG_OFFSET(1))) \
+TCR(COMMON_CFI(G_REG_OFFSET(2))) \
+TCR(COMMON_CFI(G_REG_OFFSET(3))) \
+TCR(COMMON_CFI(G_REG_OFFSET(4))) \
+TCR(COMMON_CFI(G_REG_OFFSET(5))) \
+TCR(COMMON_CFI(G_REG_OFFSET(6))) \
+TCR(COMMON_CFI(G_REG_OFFSET(7))) \
+TCR(COMMON_CFI(G_REG_OFFSET(8))) \
+TCR(COMMON_CFI(G_REG_OFFSET(9))) \
+TCR(COMMON_CFI(G_REG_OFFSET(10))) \
+TCR(COMMON_CFI(G_REG_OFFSET(11))) \
+TCR(COMMON_CFI(G_REG_OFFSET(12))) \
+TCR(COMMON_CFI(G_REG_OFFSET(13))) \
+TCR(COMMON_CFI(G_REG_OFFSET(14))) \
+TCR(COMMON_CFI(PC_OFFSET)) \
+TCR(".cfi_return_column " S(REGNO_PC_OFFSET))
+
+/* Trampoline body block
+ --------------------- */
+
+#define SIGTRAMP_BODY \
+CR("") \
+TCR("# Allocate frame and save the non-volatile") \
+TCR("# registers we're going to modify") \
+TCR("mov ip, sp") \
+TCR("stmfd sp!, {r"S(CFA_REG)", fp, ip, lr, pc}") \
+TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \
+TCR("ldr r"S(CFA_REG)", [ip]") \
+TCR("") \
+TCR("# Call the real handler. The signo, siginfo and sigcontext") \
+TCR("# arguments are the same as those we received in r0, r1 and r2") \
+TCR("sub fp, ip, #4") \
+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) \
+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));
+
+