]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgcc/config/alpha/linux-unwind.h
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / alpha / linux-unwind.h
1 /* DWARF2 EH unwinding support for Alpha Linux.
2 Copyright (C) 2004-2018 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify
7 it 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.
10
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
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.
19
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
24
25 #ifndef inhibit_libc
26 /* Do code reading to identify a signal frame, and set the frame
27 state data appropriately. See unwind-dw2.c for the structs. */
28
29 #include <signal.h>
30 #include <sys/ucontext.h>
31
32 #define MD_FALLBACK_FRAME_STATE_FOR alpha_fallback_frame_state
33
34 static _Unwind_Reason_Code
35 alpha_fallback_frame_state (struct _Unwind_Context *context,
36 _Unwind_FrameState *fs)
37 {
38 unsigned int *pc = context->ra;
39 struct sigcontext *sc;
40 long new_cfa;
41 int i;
42
43 if (pc[0] != 0x47fe0410 /* mov $30,$16 */
44 || pc[2] != 0x00000083) /* callsys */
45 return _URC_END_OF_STACK;
46 if (context->cfa == 0)
47 return _URC_END_OF_STACK;
48 if (pc[1] == 0x201f0067) /* lda $0,NR_sigreturn */
49 sc = context->cfa;
50 else if (pc[1] == 0x201f015f) /* lda $0,NR_rt_sigreturn */
51 {
52 struct rt_sigframe {
53 siginfo_t info;
54 ucontext_t uc;
55 } *rt_ = context->cfa;
56 sc = &rt_->uc.uc_mcontext;
57 }
58 else
59 return _URC_END_OF_STACK;
60
61 new_cfa = sc->sc_regs[30];
62 fs->regs.cfa_how = CFA_REG_OFFSET;
63 fs->regs.cfa_reg = 30;
64 fs->regs.cfa_offset = new_cfa - (long) context->cfa;
65 for (i = 0; i < 30; ++i)
66 {
67 fs->regs.reg[i].how = REG_SAVED_OFFSET;
68 fs->regs.reg[i].loc.offset
69 = (long) &sc->sc_regs[i] - new_cfa;
70 }
71 for (i = 0; i < 31; ++i)
72 {
73 fs->regs.reg[i+32].how = REG_SAVED_OFFSET;
74 fs->regs.reg[i+32].loc.offset
75 = (long) &sc->sc_fpregs[i] - new_cfa;
76 }
77 fs->regs.reg[64].how = REG_SAVED_OFFSET;
78 fs->regs.reg[64].loc.offset = (long)&sc->sc_pc - new_cfa;
79 fs->retaddr_column = 64;
80 fs->signal_frame = 1;
81
82 return _URC_NO_REASON;
83 }
84
85 #define MD_FROB_UPDATE_CONTEXT alpha_frob_update_context
86
87 /* Fix up for signal handlers that don't have S flag set. */
88
89 static void
90 alpha_frob_update_context (struct _Unwind_Context *context,
91 _Unwind_FrameState *fs ATTRIBUTE_UNUSED)
92 {
93 unsigned int *pc = context->ra;
94
95 if (pc[0] == 0x47fe0410 /* mov $30,$16 */
96 && pc[2] == 0x00000083 /* callsys */
97 && (pc[1] == 0x201f0067 /* lda $0,NR_sigreturn */
98 || pc[1] == 0x201f015f)) /* lda $0,NR_rt_sigreturn */
99 _Unwind_SetSignalFrame (context, 1);
100 }
101 #endif