* function.c (dump_stack_clash_frame_info): New function.
[official-gcc.git] / libgcc / config / aarch64 / aarch64-unwind.h
blob94e0d3426fd521f06221ab8bf6c5213d8ce28e6f
1 /* Copyright (C) 2017 Free Software Foundation, Inc.
2 Contributed by ARM Ltd.
4 This file is part of GCC.
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.
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.
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 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/>. */
25 #if !defined (AARCH64_UNWIND_H) && !defined (__ILP32__)
26 #define AARCH64_UNWIND_H
28 #define DWARF_REGNUM_AARCH64_RA_STATE 34
30 #define MD_POST_EXTRACT_ROOT_ADDR(addr) __builtin_aarch64_xpaclri (addr)
31 #define MD_POST_EXTRACT_FRAME_ADDR(context, fs, addr) \
32 aarch64_post_extract_frame_addr (context, fs, addr)
33 #define MD_POST_FROB_EH_HANDLER_ADDR(current, target, addr) \
34 aarch64_post_frob_eh_handler_addr (current, target, addr)
35 #define MD_FROB_UPDATE_CONTEXT(context, fs) \
36 aarch64_frob_update_context (context, fs)
38 /* Do AArch64 private extraction on ADDR based on context info CONTEXT and
39 unwind frame info FS. If ADDR is signed, we do address authentication on it
40 using CFA of current frame. */
42 static inline void *
43 aarch64_post_extract_frame_addr (struct _Unwind_Context *context,
44 _Unwind_FrameState *fs, void *addr)
46 if (fs->regs.reg[DWARF_REGNUM_AARCH64_RA_STATE].loc.offset & 0x1)
48 _Unwind_Word salt = (_Unwind_Word) context->cfa;
49 return __builtin_aarch64_autia1716 (addr, salt);
51 else
52 return addr;
55 /* Do AArch64 private frob on exception handler's address HANDLER_ADDR before
56 installing it into current context CURRENT. TARGET is currently not used.
57 We need to sign exception handler's address if CURRENT itself is signed. */
59 static inline void *
60 aarch64_post_frob_eh_handler_addr (struct _Unwind_Context *current,
61 struct _Unwind_Context *target
62 ATTRIBUTE_UNUSED,
63 void *handler_addr)
65 if (current->flags & RA_A_SIGNED_BIT)
66 return __builtin_aarch64_pacia1716 (handler_addr,
67 (_Unwind_Word) current->cfa);
68 else
69 return handler_addr;
72 /* Do AArch64 private initialization on CONTEXT based on frame info FS. Mark
73 CONTEXT as return address signed if bit 0 of DWARF_REGNUM_AARCH64_RA_STATE is
74 set. */
76 static inline void
77 aarch64_frob_update_context (struct _Unwind_Context *context,
78 _Unwind_FrameState *fs)
80 if (fs->regs.reg[DWARF_REGNUM_AARCH64_RA_STATE].loc.offset & 0x1)
81 /* The flag is used for re-authenticating EH handler's address. */
82 context->flags |= RA_A_SIGNED_BIT;
84 return;
87 #endif /* defined AARCH64_UNWIND_H && defined __ILP32__ */