Make GFORTRAN_9 symbol node depend on GFORTRAN_8.
[official-gcc.git] / libgcc / config / arc / linux-unwind.h
blobe9591fd466c6eb14d3af3072cc83ceef30b92e9f
1 /* DWARF2 EH unwinding support for ARC Linux.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License
21 and a copy of the GCC Runtime Library Exception along with this
22 program; see the files COPYING3 and COPYING.RUNTIME respectively.
23 If not, see <http://www.gnu.org/licenses/>. */
25 /* This order is defined by a structure in the kernel, in file
26 arch/arc/kernel/signal.c. */
28 #define REGISTER_IN_STACK(REG_NAME, ID) \
29 REG_NAME,
30 enum registers_stack_order {
31 REGISTER_STACK_ORDER_START = -1,
32 #include "config/arc/linux-unwind-reg.def"
33 REGISTER_STACK_ORDER_SIZE,
36 struct register_position {
37 int reg_id;
38 int offset_in_stack;
40 #undef REGISTER_IN_STACK
42 #define REGISTER_SIZE_IN_WORDS 4
43 #define REGISTER_IN_STACK(REG_NAME, ID) (int) ID,
44 int
45 register_id_for_index[REGISTER_STACK_ORDER_SIZE] = {
46 #include "config/arc/linux-unwind-reg.def"
48 #undef REGISTER_IN_STACK
50 #ifndef inhibit_libc
51 /* Do code reading to identify a signal frame, and set the frame
52 state data appropriately. See unwind-dw2.c for the structs. */
54 #include <signal.h>
55 #include <asm/unistd.h>
58 00010edc <__default_rt_sa_restorer>:
59 10edc: 208a 12c2 mov r8,139
60 10ee0: 781e trap_s 0
61 10ee2: 7ee0 j_s [blink]
64 #if __BIG_ENDIAN__
65 #define MOV_R8_139 0x8a20c212
66 #define TRAP_S_J_S_BLINK 0x1e78e07e
67 #define SWI 0x6f223f00
68 #elif __LITTLE_ENDIAN__
69 #define MOV_R8_139 0x12c2208a
70 #define TRAP_S_J_S_BLINK 0x7ee0781e
71 #define SWI 0x003f226f
72 #endif
74 #define MD_FALLBACK_FRAME_STATE_FOR arc_fallback_frame_state
76 static __attribute__((noinline)) _Unwind_Reason_Code
77 arc_fallback_frame_state (struct _Unwind_Context *context,
78 _Unwind_FrameState *fs)
80 struct rt_sigframe {
81 siginfo_t info;
82 ucontext_t uc;
83 unsigned int sigret_magic;
86 struct rt_sigframe *rt_;
87 u_int32_t *pc = (u_int32_t *) context->ra;
88 struct sigcontext *sc;
89 _Unwind_Ptr new_cfa;
90 int i;
92 #ifdef __ARC700__
93 if (pc[1] != SWI)
94 return _URC_END_OF_STACK;
95 #else
96 if (pc[1] != TRAP_S_J_S_BLINK)
97 return _URC_END_OF_STACK;
98 #endif
100 if (pc[0] == MOV_R8_139)
102 rt_ = context->cfa;
103 sc = &rt_->uc.uc_mcontext;
105 else
106 return _URC_END_OF_STACK;
108 new_cfa = (_Unwind_Ptr) sc;
109 fs->regs.cfa_how = CFA_REG_OFFSET;
110 fs->regs.cfa_reg = __LIBGCC_STACK_POINTER_REGNUM__;
111 fs->regs.cfa_offset = new_cfa - (_Unwind_Ptr) context->cfa;
113 unsigned long *regs = &sc->regs.scratch.bta;
114 for (i = 0; i < REGISTER_STACK_ORDER_SIZE; i++)
116 if (register_id_for_index[i] == -1)
117 continue;
118 fs->regs.reg[register_id_for_index[i]].how = REG_SAVED_OFFSET;
119 fs->regs.reg[register_id_for_index[i]].loc.offset
120 = ((_Unwind_Ptr) &(regs[i])) - new_cfa;
123 fs->regs.reg[31].how = REG_SAVED_VAL_OFFSET;
124 fs->regs.reg[31].loc.offset = ((_Unwind_Ptr) (regs[ret])) - new_cfa;
126 fs->retaddr_column = 31;
128 return _URC_NO_REASON;
130 #endif
132 #define MD_FROB_UPDATE_CONTEXT arc_frob_update_context
133 /* Save fp register for unwinding to work. */
135 static void
136 arc_frob_update_context (struct _Unwind_Context *context,
137 _Unwind_FrameState *fs)
139 _Unwind_Word fp_val;
140 asm ("mov %0,fp" : "=r" (fp_val));
142 switch (fs->regs.reg[27].how)
144 case REG_UNSAVED:
145 case REG_UNDEFINED:
146 if (context->reg[27] == NULL)
147 _Unwind_SetGRValue (context, 27, fp_val);
148 break;
150 default:
151 break;