]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgcc/config/aarch64/aarch64-unwind.h
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / aarch64 / aarch64-unwind.h
1 /* Copyright (C) 2017-2021 Free Software Foundation, Inc.
2 Contributed by ARM Ltd.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 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 #if !defined (AARCH64_UNWIND_H) && !defined (__ILP32__)
26 #define AARCH64_UNWIND_H
27
28 #define DWARF_REGNUM_AARCH64_RA_STATE 34
29
30 #define MD_DEMANGLE_RETURN_ADDR(context, fs, addr) \
31 aarch64_demangle_return_addr (context, fs, addr)
32 #define MD_FROB_UPDATE_CONTEXT(context, fs) \
33 aarch64_frob_update_context (context, fs)
34
35 static inline int
36 aarch64_cie_signed_with_b_key (struct _Unwind_Context *context)
37 {
38 const struct dwarf_fde *fde = _Unwind_Find_FDE (context->bases.func,
39 &context->bases);
40 if (fde != NULL)
41 {
42 const struct dwarf_cie *cie = get_cie (fde);
43 if (cie != NULL)
44 {
45 char *aug_str = cie->augmentation;
46 return strchr (aug_str, 'B') == NULL ? 0 : 1;
47 }
48 }
49 return 0;
50 }
51
52 /* Do AArch64 private extraction on ADDR_WORD based on context info CONTEXT and
53 unwind frame info FS. If ADDR_WORD is signed, we do address authentication
54 on it using CFA of current frame. */
55
56 static inline void *
57 aarch64_demangle_return_addr (struct _Unwind_Context *context,
58 _Unwind_FrameState *fs ATTRIBUTE_UNUSED,
59 _Unwind_Word addr_word)
60 {
61 void *addr = (void *)addr_word;
62 if (context->flags & RA_SIGNED_BIT)
63 {
64 _Unwind_Word salt = (_Unwind_Word) context->cfa;
65 if (aarch64_cie_signed_with_b_key (context) != 0)
66 return __builtin_aarch64_autib1716 (addr, salt);
67 return __builtin_aarch64_autia1716 (addr, salt);
68 }
69 else
70 return addr;
71 }
72
73 /* Do AArch64 private initialization on CONTEXT based on frame info FS. Mark
74 CONTEXT as return address signed if bit 0 of DWARF_REGNUM_AARCH64_RA_STATE is
75 set. */
76
77 static inline void
78 aarch64_frob_update_context (struct _Unwind_Context *context,
79 _Unwind_FrameState *fs)
80 {
81 if (fs->regs.reg[DWARF_REGNUM_AARCH64_RA_STATE].loc.offset & 0x1)
82 /* The flag is used for re-authenticating EH handler's address. */
83 context->flags |= RA_SIGNED_BIT;
84 else
85 context->flags &= ~RA_SIGNED_BIT;
86
87 return;
88 }
89
90 #endif /* defined AARCH64_UNWIND_H && defined __ILP32__ */