Remove path name from test case
[binutils-gdb.git] / gas / dw2gencfi.h
1 /* dw2gencfi.h - Support for generating Dwarf2 CFI information.
2 Copyright (C) 2003-2023 Free Software Foundation, Inc.
3 Contributed by Michal Ludvig <mludvig@suse.cz>
4
5 This file is part of GAS, the GNU Assembler.
6
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
21
22 #ifndef DW2GENCFI_H
23 #define DW2GENCFI_H
24
25 #include "dwarf2.h"
26
27 struct symbol;
28
29 extern const pseudo_typeS cfi_pseudo_table[];
30
31 /* cfi_finish() is called at the end of file. It will complain if
32 the last CFI wasn't properly closed by .cfi_endproc. */
33 extern void cfi_finish (void);
34
35 /* Entry points for backends to add unwind information. */
36 extern void cfi_new_fde (struct symbol *);
37 extern void cfi_end_fde (struct symbol *);
38 extern void cfi_set_return_column (unsigned);
39 extern void cfi_set_sections (void);
40 extern void cfi_add_advance_loc (struct symbol *);
41 extern void cfi_add_label (const char *);
42
43 extern void cfi_add_CFA_offset (unsigned, offsetT);
44 extern void cfi_add_CFA_val_offset (unsigned, offsetT);
45 extern void cfi_add_CFA_def_cfa (unsigned, offsetT);
46 extern void cfi_add_CFA_register (unsigned, unsigned);
47 extern void cfi_add_CFA_def_cfa_register (unsigned);
48 extern void cfi_add_CFA_def_cfa_offset (offsetT);
49 extern void cfi_add_CFA_restore (unsigned);
50 extern void cfi_add_CFA_undefined (unsigned);
51 extern void cfi_add_CFA_same_value (unsigned);
52 extern void cfi_add_CFA_remember_state (void);
53 extern void cfi_add_CFA_restore_state (void);
54
55 /* Structures for md_cfi_end. */
56
57 #if defined (TE_PE) || defined (TE_PEP)
58 #define SUPPORT_FRAME_LINKONCE 1
59 #else
60 #define SUPPORT_FRAME_LINKONCE 0
61 #endif
62
63 #ifdef tc_cfi_reloc_for_encoding
64 #define SUPPORT_COMPACT_EH 1
65 #else
66 #define SUPPORT_COMPACT_EH 0
67 #endif
68
69 #ifndef TARGET_MULTIPLE_EH_FRAME_SECTIONS
70 #define TARGET_MULTIPLE_EH_FRAME_SECTIONS 0
71 #endif
72
73 #define MULTIPLE_FRAME_SECTIONS (SUPPORT_FRAME_LINKONCE || SUPPORT_COMPACT_EH \
74 || TARGET_MULTIPLE_EH_FRAME_SECTIONS)
75
76 struct cfi_insn_data
77 {
78 struct cfi_insn_data *next;
79 #if MULTIPLE_FRAME_SECTIONS
80 segT cur_seg;
81 #endif
82 int insn;
83 union
84 {
85 struct
86 {
87 unsigned reg;
88 offsetT offset;
89 } ri;
90
91 struct
92 {
93 unsigned reg1;
94 unsigned reg2;
95 } rr;
96
97 unsigned r;
98 offsetT i;
99
100 struct
101 {
102 symbolS *lab1;
103 symbolS *lab2;
104 } ll;
105
106 struct cfi_escape_data *esc;
107
108 struct
109 {
110 unsigned reg, encoding;
111 expressionS exp;
112 } ea;
113
114 const char *sym_name;
115 } u;
116 };
117
118 /* An enumeration describing the Compact EH header format. The least
119 significant bit is used to distinguish the entries.
120
121 Inline Compact: Function offset [0]
122 Four chars of unwind data.
123 Out-of-line Compact: Function offset [1]
124 Compact unwind data offset [0]
125 Legacy: Function offset [1]
126 Unwind data offset [1]
127
128 The header type is initialized to EH_COMPACT_UNKNOWN until the
129 format is discovered by encountering a .fde_data entry.
130 Failure to find a .fde_data entry will cause an EH_COMPACT_LEGACY
131 header to be generated. */
132
133 enum {
134 EH_COMPACT_UNKNOWN,
135 EH_COMPACT_LEGACY,
136 EH_COMPACT_INLINE,
137 EH_COMPACT_OUTLINE,
138 EH_COMPACT_OUTLINE_DONE,
139 /* Outline if .cfi_inline_lsda used, otherwise legacy FDE. */
140 EH_COMPACT_HAS_LSDA
141 };
142
143 /* Stack of old CFI data, for save/restore. */
144 struct cfa_save_data
145 {
146 struct cfa_save_data *next;
147 offsetT cfa_offset;
148 };
149
150 /* Current open FDE entry. */
151 struct frch_cfi_data
152 {
153 struct fde_entry *cur_fde_data;
154 symbolS *last_address;
155 offsetT cur_cfa_offset;
156 struct cfa_save_data *cfa_save_stack;
157 };
158
159 struct fde_entry
160 {
161 struct fde_entry *next;
162 #if MULTIPLE_FRAME_SECTIONS
163 segT cur_seg;
164 #endif
165 symbolS *start_address;
166 symbolS *end_address;
167 struct cfi_insn_data *data;
168 struct cfi_insn_data **last;
169 unsigned char per_encoding;
170 unsigned char lsda_encoding;
171 int personality_id;
172 expressionS personality;
173 expressionS lsda;
174 unsigned int return_column;
175 unsigned int signal_frame;
176 #if MULTIPLE_FRAME_SECTIONS
177 int handled;
178 #endif
179 int eh_header_type;
180 /* Compact unwinding opcodes, not including the PR byte or LSDA. */
181 int eh_data_size;
182 bfd_byte *eh_data;
183 /* For out of line tables and FDEs. */
184 symbolS *eh_loc;
185 int sections;
186 #ifdef tc_fde_entry_extras
187 tc_fde_entry_extras
188 #endif
189 };
190
191 /* The list of all FDEs that have been collected. */
192 extern struct fde_entry *all_fde_data;
193
194 /* Fake CFI type; outside the byte range of any real CFI insn. */
195 #define CFI_adjust_cfa_offset 0x100
196 #define CFI_return_column 0x101
197 #define CFI_rel_offset 0x102
198 #define CFI_escape 0x103
199 #define CFI_signal_frame 0x104
200 #define CFI_val_encoded_addr 0x105
201 #define CFI_label 0x106
202
203 /* By default emit .eh_frame only, not .debug_frame. */
204 #define CFI_EMIT_eh_frame (1 << 0)
205 #define CFI_EMIT_debug_frame (1 << 1)
206 #define CFI_EMIT_target (1 << 2)
207 #define CFI_EMIT_eh_frame_compact (1 << 3)
208 #define CFI_EMIT_sframe (1 << 4)
209
210 #endif /* DW2GENCFI_H */