]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/config/arm/unwind-arm.h
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / arm / unwind-arm.h
CommitLineData
2a75c0b6 1/* Header file for the ARM EABI unwinder
a945c346 2 Copyright (C) 2003-2024 Free Software Foundation, Inc.
2a75c0b6
PB
3 Contributed by Paul Brook
4
5 This file is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
748086b7 7 Free Software Foundation; either version 3, or (at your option) any
2a75c0b6
PB
8 later version.
9
2a75c0b6
PB
10 This file is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
748086b7
JJ
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
2a75c0b6 23
619519c8
KH
24/* Language-independent unwinder header public defines. This contains both
25 ABI defined objects, and GNU support routines. */
2a75c0b6
PB
26
27#ifndef UNWIND_ARM_H
28#define UNWIND_ARM_H
29
1e874273
PB
30#include "unwind-arm-common.h"
31
32#define UNWIND_STACK_REG 13
33/* Use IP as a scratch register within the personality routine. */
34#define UNWIND_POINTER_REG 12
2a75c0b6 35
5d727a4b
CL
36#define FDPIC_REGNUM 9
37
38#define STR(x) #x
39#define XSTR(x) STR(x)
40
2a75c0b6
PB
41#ifdef __cplusplus
42extern "C" {
43#endif
5d727a4b
CL
44_Unwind_Ptr __attribute__((weak)) __gnu_Unwind_Find_got (_Unwind_Ptr);
45
811a475e 46static inline _Unwind_Ptr _Unwind_gnu_Find_got (_Unwind_Ptr ptr)
5d727a4b
CL
47{
48 _Unwind_Ptr res;
49
50 if (__gnu_Unwind_Find_got)
811a475e 51 res = __gnu_Unwind_Find_got (ptr);
5d727a4b 52 else
811a475e
JJ
53 __asm volatile ("mov %[result], r" XSTR(FDPIC_REGNUM)
54 : [result] "=r" (res));
5d727a4b
CL
55
56 return res;
57}
58
2a75c0b6
PB
59 /* Decode an R_ARM_TARGET2 relocation. */
60 static inline _Unwind_Word
acb72498
MK
61 _Unwind_decode_typeinfo_ptr (_Unwind_Word base __attribute__ ((unused)),
62 _Unwind_Word ptr)
2a75c0b6
PB
63 {
64 _Unwind_Word tmp;
65
66 tmp = *(_Unwind_Word *) ptr;
67 /* Zero values are always NULL. */
68 if (!tmp)
69 return 0;
70
5d727a4b
CL
71#if __FDPIC__
72 /* For FDPIC, we store the offset of the GOT entry. */
73 /* So, first get GOT from dynamic linker and then use indirect access. */
811a475e 74 tmp += _Unwind_gnu_Find_got (ptr);
5d727a4b
CL
75 tmp = *(_Unwind_Word *) tmp;
76#elif (defined(linux) && !defined(__uClinux__)) || defined(__NetBSD__) \
7ab8766a 77 || defined(__FreeBSD__) || defined(__fuchsia__)
2a75c0b6 78 /* Pc-relative indirect. */
1e874273 79#define _GLIBCXX_OVERRIDE_TTYPE_ENCODING (DW_EH_PE_pcrel | DW_EH_PE_indirect)
2a75c0b6
PB
80 tmp += ptr;
81 tmp = *(_Unwind_Word *) tmp;
433d52fd 82#elif defined(__symbian__) || defined(__uClinux__)
1e874273 83#define _GLIBCXX_OVERRIDE_TTYPE_ENCODING (DW_EH_PE_absptr)
619519c8 84 /* Absolute pointer. Nothing more to do. */
2a75c0b6 85#else
1e874273 86#define _GLIBCXX_OVERRIDE_TTYPE_ENCODING (DW_EH_PE_pcrel)
2a75c0b6
PB
87 /* Pc-relative pointer. */
88 tmp += ptr;
89#endif
90 return tmp;
91 }
92
1e874273 93 static inline _Unwind_Reason_Code
acb72498 94 __gnu_unwind_24bit (_Unwind_Context * context __attribute__ ((unused)),
7c9bc875 95 _uw data __attribute__ ((unused)),
acb72498 96 int compact __attribute__ ((unused)))
2a75c0b6 97 {
1e874273 98 return _URC_FAILURE;
2a75c0b6 99 }
78eca309 100#ifndef __FreeBSD__
2a75c0b6
PB
101 /* Return the address of the instruction, not the actual IP value. */
102#define _Unwind_GetIP(context) \
103 (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
104
2a75c0b6
PB
105#define _Unwind_SetIP(context, val) \
106 _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
78eca309
AT
107#else
108 #undef _Unwind_GetIPInfo
109 _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
110 _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
111 void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
112#endif
2a75c0b6 113
2a75c0b6
PB
114#ifdef __cplusplus
115} /* extern "C" */
116#endif
117
118#endif /* defined UNWIND_ARM_H */