Rev 5222 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5222 | Rev 6324 | ||
---|---|---|---|
1 | /* dw2gencfi.c - Support for generating Dwarf2 CFI information. |
1 | /* dw2gencfi.c - Support for generating Dwarf2 CFI information. |
2 | Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
- | |
3 | Free Software Foundation, Inc. |
2 | Copyright (C) 2003-2015 Free Software Foundation, Inc. |
4 | Contributed by Michal Ludvig |
3 | Contributed by Michal Ludvig |
5 | 4 | ||
6 | This file is part of GAS, the GNU Assembler. |
5 | This file is part of GAS, the GNU Assembler. |
7 | 6 | ||
8 | GAS is free software; you can redistribute it and/or modify |
7 | GAS is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
8 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 3, or (at your option) |
9 | the Free Software Foundation; either version 3, or (at your option) |
11 | any later version. |
10 | any later version. |
12 | 11 | ||
13 | GAS is distributed in the hope that it will be useful, |
12 | GAS is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
15 | GNU General Public License for more details. |
17 | 16 | ||
18 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
19 | along with GAS; see the file COPYING. If not, write to the Free |
18 | along with GAS; see the file COPYING. If not, write to the Free |
20 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
19 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
21 | 02110-1301, USA. */ |
20 | 02110-1301, USA. */ |
22 | 21 | ||
23 | #include "as.h" |
22 | #include "as.h" |
24 | #include "dw2gencfi.h" |
23 | #include "dw2gencfi.h" |
25 | #include "subsegs.h" |
24 | #include "subsegs.h" |
26 | #include "dwarf2dbg.h" |
25 | #include "dwarf2dbg.h" |
27 | 26 | ||
28 | #ifdef TARGET_USE_CFIPOP |
27 | #ifdef TARGET_USE_CFIPOP |
29 | 28 | ||
30 | /* By default, use difference expressions if DIFF_EXPR_OK is defined. */ |
29 | /* By default, use difference expressions if DIFF_EXPR_OK is defined. */ |
31 | #ifndef CFI_DIFF_EXPR_OK |
30 | #ifndef CFI_DIFF_EXPR_OK |
32 | # ifdef DIFF_EXPR_OK |
31 | # ifdef DIFF_EXPR_OK |
33 | # define CFI_DIFF_EXPR_OK 1 |
32 | # define CFI_DIFF_EXPR_OK 1 |
34 | # else |
33 | # else |
35 | # define CFI_DIFF_EXPR_OK 0 |
34 | # define CFI_DIFF_EXPR_OK 0 |
36 | # endif |
35 | # endif |
37 | #endif |
36 | #endif |
38 | 37 | ||
39 | #ifndef CFI_DIFF_LSDA_OK |
38 | #ifndef CFI_DIFF_LSDA_OK |
40 | #define CFI_DIFF_LSDA_OK CFI_DIFF_EXPR_OK |
39 | #define CFI_DIFF_LSDA_OK CFI_DIFF_EXPR_OK |
41 | #endif |
40 | #endif |
42 | 41 | ||
43 | #if CFI_DIFF_EXPR_OK == 1 && CFI_DIFF_LSDA_OK == 0 |
42 | #if CFI_DIFF_EXPR_OK == 1 && CFI_DIFF_LSDA_OK == 0 |
44 | # error "CFI_DIFF_EXPR_OK should imply CFI_DIFF_LSDA_OK" |
43 | # error "CFI_DIFF_EXPR_OK should imply CFI_DIFF_LSDA_OK" |
45 | #endif |
44 | #endif |
46 | 45 | ||
47 | /* We re-use DWARF2_LINE_MIN_INSN_LENGTH for the code alignment field |
46 | /* We re-use DWARF2_LINE_MIN_INSN_LENGTH for the code alignment field |
48 | of the CIE. Default to 1 if not otherwise specified. */ |
47 | of the CIE. Default to 1 if not otherwise specified. */ |
49 | #ifndef DWARF2_LINE_MIN_INSN_LENGTH |
48 | #ifndef DWARF2_LINE_MIN_INSN_LENGTH |
50 | #define DWARF2_LINE_MIN_INSN_LENGTH 1 |
49 | #define DWARF2_LINE_MIN_INSN_LENGTH 1 |
51 | #endif |
50 | #endif |
52 | 51 | ||
53 | /* By default, use 32-bit relocations from .eh_frame into .text. */ |
52 | /* By default, use 32-bit relocations from .eh_frame into .text. */ |
54 | #ifndef DWARF2_FDE_RELOC_SIZE |
53 | #ifndef DWARF2_FDE_RELOC_SIZE |
55 | #define DWARF2_FDE_RELOC_SIZE 4 |
54 | #define DWARF2_FDE_RELOC_SIZE 4 |
56 | #endif |
55 | #endif |
57 | 56 | ||
58 | /* By default, use a read-only .eh_frame section. */ |
57 | /* By default, use a read-only .eh_frame section. */ |
59 | #ifndef DWARF2_EH_FRAME_READ_ONLY |
58 | #ifndef DWARF2_EH_FRAME_READ_ONLY |
60 | #define DWARF2_EH_FRAME_READ_ONLY SEC_READONLY |
59 | #define DWARF2_EH_FRAME_READ_ONLY SEC_READONLY |
61 | #endif |
60 | #endif |
62 | 61 | ||
63 | #ifndef EH_FRAME_ALIGNMENT |
62 | #ifndef EH_FRAME_ALIGNMENT |
64 | #define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2) |
63 | #define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2) |
65 | #endif |
64 | #endif |
66 | 65 | ||
67 | #ifndef tc_cfi_frame_initial_instructions |
66 | #ifndef tc_cfi_frame_initial_instructions |
68 | #define tc_cfi_frame_initial_instructions() ((void)0) |
67 | #define tc_cfi_frame_initial_instructions() ((void)0) |
69 | #endif |
68 | #endif |
70 | 69 | ||
71 | #ifndef tc_cfi_startproc |
70 | #ifndef tc_cfi_startproc |
72 | # define tc_cfi_startproc() ((void)0) |
71 | # define tc_cfi_startproc() ((void)0) |
73 | #endif |
72 | #endif |
74 | 73 | ||
75 | #ifndef tc_cfi_endproc |
74 | #ifndef tc_cfi_endproc |
76 | # define tc_cfi_endproc(fde) ((void) (fde)) |
75 | # define tc_cfi_endproc(fde) ((void) (fde)) |
77 | #endif |
76 | #endif |
- | 77 | ||
- | 78 | #define EH_FRAME_LINKONCE (SUPPORT_FRAME_LINKONCE || compact_eh) |
|
78 | 79 | ||
79 | #ifndef DWARF2_FORMAT |
80 | #ifndef DWARF2_FORMAT |
80 | #define DWARF2_FORMAT(SEC) dwarf2_format_32bit |
81 | #define DWARF2_FORMAT(SEC) dwarf2_format_32bit |
81 | #endif |
82 | #endif |
82 | 83 | ||
83 | #ifndef DWARF2_ADDR_SIZE |
84 | #ifndef DWARF2_ADDR_SIZE |
84 | #define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8) |
85 | #define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8) |
85 | #endif |
86 | #endif |
86 | 87 | ||
87 | #if SUPPORT_FRAME_LINKONCE |
88 | #if MULTIPLE_FRAME_SECTIONS |
88 | #define CUR_SEG(structp) structp->cur_seg |
89 | #define CUR_SEG(structp) structp->cur_seg |
89 | #define SET_CUR_SEG(structp, seg) structp->cur_seg = seg |
90 | #define SET_CUR_SEG(structp, seg) structp->cur_seg = seg |
90 | #define HANDLED(structp) structp->handled |
91 | #define HANDLED(structp) structp->handled |
91 | #define SET_HANDLED(structp, val) structp->handled = val |
92 | #define SET_HANDLED(structp, val) structp->handled = val |
92 | #else |
93 | #else |
93 | #define CUR_SEG(structp) NULL |
94 | #define CUR_SEG(structp) NULL |
94 | #define SET_CUR_SEG(structp, seg) (void) (0 && seg) |
95 | #define SET_CUR_SEG(structp, seg) (void) (0 && seg) |
95 | #define HANDLED(structp) 0 |
96 | #define HANDLED(structp) 0 |
96 | #define SET_HANDLED(structp, val) (void) (0 && val) |
97 | #define SET_HANDLED(structp, val) (void) (0 && val) |
97 | #endif |
98 | #endif |
- | 99 | ||
- | 100 | #ifndef tc_cfi_reloc_for_encoding |
|
- | 101 | #define tc_cfi_reloc_for_encoding(e) BFD_RELOC_NONE |
|
- | 102 | #endif |
|
98 | 103 | ||
99 | /* Private segment collection list. */ |
104 | /* Private segment collection list. */ |
100 | struct dwcfi_seg_list |
105 | struct dwcfi_seg_list |
101 | { |
106 | { |
102 | segT seg; |
107 | segT seg; |
103 | int subseg; |
108 | int subseg; |
104 | char * seg_name; |
109 | char * seg_name; |
105 | }; |
110 | }; |
- | 111 | ||
- | 112 | #ifdef SUPPORT_COMPACT_EH |
|
- | 113 | static bfd_boolean compact_eh; |
|
106 | 114 | #else |
|
- | 115 | #define compact_eh 0 |
|
107 | #define FRAME_NAME ".eh_frame" |
116 | #endif |
108 | 117 | ||
109 | static struct hash_control *dwcfi_hash; |
118 | static struct hash_control *dwcfi_hash; |
- | 119 | ||
- | 120 | /* Emit a single byte into the current segment. */ |
|
- | 121 | ||
- | 122 | static inline void |
|
- | 123 | out_one (int byte) |
|
- | 124 | { |
|
- | 125 | FRAG_APPEND_1_CHAR (byte); |
|
- | 126 | } |
|
- | 127 | ||
- | 128 | /* Emit a two-byte word into the current segment. */ |
|
- | 129 | ||
- | 130 | static inline void |
|
- | 131 | out_two (int data) |
|
- | 132 | { |
|
- | 133 | md_number_to_chars (frag_more (2), data, 2); |
|
- | 134 | } |
|
- | 135 | ||
- | 136 | /* Emit a four byte word into the current segment. */ |
|
- | 137 | ||
- | 138 | static inline void |
|
- | 139 | out_four (int data) |
|
- | 140 | { |
|
- | 141 | md_number_to_chars (frag_more (4), data, 4); |
|
- | 142 | } |
|
- | 143 | ||
- | 144 | /* Emit an unsigned "little-endian base 128" number. */ |
|
- | 145 | ||
- | 146 | static void |
|
- | 147 | out_uleb128 (addressT value) |
|
- | 148 | { |
|
- | 149 | output_leb128 (frag_more (sizeof_leb128 (value, 0)), value, 0); |
|
- | 150 | } |
|
- | 151 | ||
- | 152 | /* Emit an unsigned "little-endian base 128" number. */ |
|
- | 153 | ||
- | 154 | static void |
|
- | 155 | out_sleb128 (offsetT value) |
|
- | 156 | { |
|
- | 157 | output_leb128 (frag_more (sizeof_leb128 (value, 1)), value, 1); |
|
- | 158 | } |
|
- | 159 | ||
- | 160 | static offsetT |
|
- | 161 | encoding_size (unsigned char encoding) |
|
- | 162 | { |
|
- | 163 | if (encoding == DW_EH_PE_omit) |
|
- | 164 | return 0; |
|
- | 165 | switch (encoding & 0x7) |
|
- | 166 | { |
|
- | 167 | case 0: |
|
- | 168 | return bfd_get_arch_size (stdoutput) == 64 ? 8 : 4; |
|
- | 169 | case DW_EH_PE_udata2: |
|
- | 170 | return 2; |
|
- | 171 | case DW_EH_PE_udata4: |
|
- | 172 | return 4; |
|
- | 173 | case DW_EH_PE_udata8: |
|
- | 174 | return 8; |
|
- | 175 | default: |
|
- | 176 | abort (); |
|
- | 177 | } |
|
- | 178 | } |
|
- | 179 | ||
- | 180 | /* Emit expression EXP in ENCODING. If EMIT_ENCODING is true, first |
|
- | 181 | emit a byte containing ENCODING. */ |
|
- | 182 | ||
- | 183 | static void |
|
- | 184 | emit_expr_encoded (expressionS *exp, int encoding, bfd_boolean emit_encoding) |
|
- | 185 | { |
|
- | 186 | offsetT size = encoding_size (encoding); |
|
- | 187 | bfd_reloc_code_real_type code; |
|
- | 188 | ||
- | 189 | if (encoding == DW_EH_PE_omit) |
|
- | 190 | return; |
|
- | 191 | ||
- | 192 | if (emit_encoding) |
|
- | 193 | out_one (encoding); |
|
- | 194 | ||
- | 195 | code = tc_cfi_reloc_for_encoding (encoding); |
|
- | 196 | if (code != BFD_RELOC_NONE) |
|
- | 197 | { |
|
- | 198 | reloc_howto_type *howto = bfd_reloc_type_lookup (stdoutput, code); |
|
- | 199 | char *p = frag_more (size); |
|
- | 200 | md_number_to_chars (p, 0, size); |
|
- | 201 | fix_new (frag_now, p - frag_now->fr_literal, size, exp->X_add_symbol, |
|
- | 202 | exp->X_add_number, howto->pc_relative, code); |
|
- | 203 | } |
|
- | 204 | else if ((encoding & 0x70) == DW_EH_PE_pcrel) |
|
- | 205 | { |
|
- | 206 | #if CFI_DIFF_EXPR_OK |
|
- | 207 | expressionS tmp = *exp; |
|
- | 208 | tmp.X_op = O_subtract; |
|
- | 209 | tmp.X_op_symbol = symbol_temp_new_now (); |
|
- | 210 | emit_expr (&tmp, size); |
|
- | 211 | #elif defined (tc_cfi_emit_pcrel_expr) |
|
- | 212 | tc_cfi_emit_pcrel_expr (exp, size); |
|
- | 213 | #else |
|
- | 214 | abort (); |
|
- | 215 | #endif |
|
- | 216 | } |
|
- | 217 | else |
|
- | 218 | emit_expr (exp, size); |
|
- | 219 | } |
|
110 | 220 | ||
111 | /* Build based on segment the derived .debug_... |
221 | /* Build based on segment the derived .debug_... |
112 | segment name containing origin segment's postfix name part. */ |
222 | segment name containing origin segment's postfix name part. */ |
113 | 223 | ||
114 | static char * |
224 | static char * |
115 | get_debugseg_name (segT seg, const char *base_name) |
225 | get_debugseg_name (segT seg, const char *base_name) |
116 | { |
226 | { |
117 | const char *name; |
227 | const char *name; |
118 | 228 | ||
119 | if (!seg) |
229 | if (!seg) |
120 | name = ""; |
230 | name = ""; |
121 | else |
231 | else |
122 | { |
232 | { |
123 | const char * dollar; |
233 | const char * dollar; |
124 | const char * dot; |
234 | const char * dot; |
125 | 235 | ||
126 | name = bfd_get_section_name (stdoutput, seg); |
236 | name = bfd_get_section_name (stdoutput, seg); |
127 | 237 | ||
128 | dollar = strchr (name, '$'); |
238 | dollar = strchr (name, '$'); |
129 | dot = strchr (name + 1, '.'); |
239 | dot = strchr (name + 1, '.'); |
130 | 240 | ||
131 | if (!dollar && !dot) |
241 | if (!dollar && !dot) |
- | 242 | { |
|
- | 243 | if (!strcmp (base_name, ".eh_frame_entry") |
|
- | 244 | && strcmp (name, ".text") != 0) |
|
- | 245 | return concat (base_name, ".", name, NULL); |
|
- | 246 | ||
132 | name = ""; |
247 | name = ""; |
- | 248 | } |
|
133 | else if (!dollar) |
249 | else if (!dollar) |
134 | name = dot; |
250 | name = dot; |
135 | else if (!dot) |
251 | else if (!dot) |
136 | name = dollar; |
252 | name = dollar; |
137 | else if (dot < dollar) |
253 | else if (dot < dollar) |
138 | name = dot; |
254 | name = dot; |
139 | else |
255 | else |
140 | name = dollar; |
256 | name = dollar; |
141 | } |
257 | } |
142 | 258 | ||
143 | return concat (base_name, name, NULL); |
259 | return concat (base_name, name, NULL); |
144 | } |
260 | } |
145 | 261 | ||
146 | /* Allocate a dwcfi_seg_list structure. */ |
262 | /* Allocate a dwcfi_seg_list structure. */ |
147 | 263 | ||
148 | static struct dwcfi_seg_list * |
264 | static struct dwcfi_seg_list * |
149 | alloc_debugseg_item (segT seg, int subseg, char *name) |
265 | alloc_debugseg_item (segT seg, int subseg, char *name) |
150 | { |
266 | { |
151 | struct dwcfi_seg_list *r; |
267 | struct dwcfi_seg_list *r; |
152 | 268 | ||
153 | r = (struct dwcfi_seg_list *) |
269 | r = (struct dwcfi_seg_list *) |
154 | xmalloc (sizeof (struct dwcfi_seg_list) + strlen (name)); |
270 | xmalloc (sizeof (struct dwcfi_seg_list) + strlen (name)); |
155 | r->seg = seg; |
271 | r->seg = seg; |
156 | r->subseg = subseg; |
272 | r->subseg = subseg; |
157 | r->seg_name = name; |
273 | r->seg_name = name; |
158 | return r; |
274 | return r; |
159 | } |
275 | } |
160 | 276 | ||
161 | static segT |
277 | static segT |
162 | is_now_linkonce_segment (void) |
278 | is_now_linkonce_segment (void) |
163 | { |
279 | { |
- | 280 | if (compact_eh) |
|
- | 281 | return now_seg; |
|
- | 282 | ||
164 | if ((bfd_get_section_flags (stdoutput, now_seg) |
283 | if ((bfd_get_section_flags (stdoutput, now_seg) |
165 | & (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD |
284 | & (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD |
166 | | SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE |
285 | | SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE |
167 | | SEC_LINK_DUPLICATES_SAME_CONTENTS)) != 0) |
286 | | SEC_LINK_DUPLICATES_SAME_CONTENTS)) != 0) |
168 | return now_seg; |
287 | return now_seg; |
169 | return NULL; |
288 | return NULL; |
170 | } |
289 | } |
171 | 290 | ||
172 | /* Generate debug... segment with same linkonce properties |
291 | /* Generate debug... segment with same linkonce properties |
173 | of based segment. */ |
292 | of based segment. */ |
174 | 293 | ||
175 | static segT |
294 | static segT |
176 | make_debug_seg (segT cseg, char *name, int sflags) |
295 | make_debug_seg (segT cseg, char *name, int sflags) |
177 | { |
296 | { |
178 | segT save_seg = now_seg; |
297 | segT save_seg = now_seg; |
179 | int save_subseg = now_subseg; |
298 | int save_subseg = now_subseg; |
180 | segT r; |
299 | segT r; |
181 | flagword flags; |
300 | flagword flags; |
182 | 301 | ||
183 | r = subseg_new (name, 0); |
302 | r = subseg_new (name, 0); |
184 | 303 | ||
185 | /* Check if code segment is marked as linked once. */ |
304 | /* Check if code segment is marked as linked once. */ |
186 | if (!cseg) |
305 | if (!cseg) |
187 | flags = 0; |
306 | flags = 0; |
188 | else |
307 | else |
189 | flags = bfd_get_section_flags (stdoutput, cseg) |
308 | flags = bfd_get_section_flags (stdoutput, cseg) |
190 | & (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD |
309 | & (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD |
191 | | SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE |
310 | | SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE |
192 | | SEC_LINK_DUPLICATES_SAME_CONTENTS); |
311 | | SEC_LINK_DUPLICATES_SAME_CONTENTS); |
193 | 312 | ||
194 | /* Add standard section flags. */ |
313 | /* Add standard section flags. */ |
195 | flags |= sflags; |
314 | flags |= sflags; |
196 | 315 | ||
197 | /* Apply possibly linked once flags to new generated segment, too. */ |
316 | /* Apply possibly linked once flags to new generated segment, too. */ |
198 | if (!bfd_set_section_flags (stdoutput, r, flags)) |
317 | if (!bfd_set_section_flags (stdoutput, r, flags)) |
199 | as_bad (_("bfd_set_section_flags: %s"), |
318 | as_bad (_("bfd_set_section_flags: %s"), |
200 | bfd_errmsg (bfd_get_error ())); |
319 | bfd_errmsg (bfd_get_error ())); |
201 | 320 | ||
202 | /* Restore to previous segment. */ |
321 | /* Restore to previous segment. */ |
203 | if (save_seg != NULL) |
322 | if (save_seg != NULL) |
204 | subseg_set (save_seg, save_subseg); |
323 | subseg_set (save_seg, save_subseg); |
205 | return r; |
324 | return r; |
206 | } |
325 | } |
207 | 326 | ||
208 | static void |
327 | static void |
209 | dwcfi_hash_insert (const char *name, struct dwcfi_seg_list *item) |
328 | dwcfi_hash_insert (const char *name, struct dwcfi_seg_list *item) |
210 | { |
329 | { |
211 | const char *error_string; |
330 | const char *error_string; |
212 | 331 | ||
213 | if ((error_string = hash_jam (dwcfi_hash, name, (char *) item))) |
332 | if ((error_string = hash_jam (dwcfi_hash, name, (char *) item))) |
214 | as_fatal (_("Inserting \"%s\" into structure table failed: %s"), |
333 | as_fatal (_("Inserting \"%s\" into structure table failed: %s"), |
215 | name, error_string); |
334 | name, error_string); |
216 | } |
335 | } |
217 | 336 | ||
218 | static struct dwcfi_seg_list * |
337 | static struct dwcfi_seg_list * |
219 | dwcfi_hash_find (char *name) |
338 | dwcfi_hash_find (char *name) |
220 | { |
339 | { |
221 | return (struct dwcfi_seg_list *) hash_find (dwcfi_hash, name); |
340 | return (struct dwcfi_seg_list *) hash_find (dwcfi_hash, name); |
222 | } |
341 | } |
223 | 342 | ||
224 | static struct dwcfi_seg_list * |
343 | static struct dwcfi_seg_list * |
225 | dwcfi_hash_find_or_make (segT cseg, const char *base_name, int flags) |
344 | dwcfi_hash_find_or_make (segT cseg, const char *base_name, int flags) |
226 | { |
345 | { |
227 | struct dwcfi_seg_list *item; |
346 | struct dwcfi_seg_list *item; |
228 | char *name; |
347 | char *name; |
229 | 348 | ||
230 | /* Initialize dwcfi_hash once. */ |
349 | /* Initialize dwcfi_hash once. */ |
231 | if (!dwcfi_hash) |
350 | if (!dwcfi_hash) |
232 | dwcfi_hash = hash_new (); |
351 | dwcfi_hash = hash_new (); |
233 | 352 | ||
234 | name = get_debugseg_name (cseg, base_name); |
353 | name = get_debugseg_name (cseg, base_name); |
235 | 354 | ||
236 | item = dwcfi_hash_find (name); |
355 | item = dwcfi_hash_find (name); |
237 | if (!item) |
356 | if (!item) |
238 | { |
357 | { |
239 | item = alloc_debugseg_item (make_debug_seg (cseg, name, flags), 0, name); |
358 | item = alloc_debugseg_item (make_debug_seg (cseg, name, flags), 0, name); |
240 | 359 | ||
241 | dwcfi_hash_insert (item->seg_name, item); |
360 | dwcfi_hash_insert (item->seg_name, item); |
242 | } |
361 | } |
243 | else |
362 | else |
244 | free (name); |
363 | free (name); |
245 | 364 | ||
246 | return item; |
365 | return item; |
247 | } |
366 | } |
248 | 367 | ||
249 | /* ??? Share this with dwarf2cfg.c. */ |
368 | /* ??? Share this with dwarf2cfg.c. */ |
250 | #ifndef TC_DWARF2_EMIT_OFFSET |
369 | #ifndef TC_DWARF2_EMIT_OFFSET |
251 | #define TC_DWARF2_EMIT_OFFSET generic_dwarf2_emit_offset |
370 | #define TC_DWARF2_EMIT_OFFSET generic_dwarf2_emit_offset |
252 | 371 | ||
253 | /* Create an offset to .dwarf2_*. */ |
372 | /* Create an offset to .dwarf2_*. */ |
254 | 373 | ||
255 | static void |
374 | static void |
256 | generic_dwarf2_emit_offset (symbolS *symbol, unsigned int size) |
375 | generic_dwarf2_emit_offset (symbolS *symbol, unsigned int size) |
257 | { |
376 | { |
258 | expressionS exp; |
377 | expressionS exp; |
259 | 378 | ||
260 | exp.X_op = O_symbol; |
379 | exp.X_op = O_symbol; |
261 | exp.X_add_symbol = symbol; |
380 | exp.X_add_symbol = symbol; |
262 | exp.X_add_number = 0; |
381 | exp.X_add_number = 0; |
263 | emit_expr (&exp, size); |
382 | emit_expr (&exp, size); |
264 | } |
383 | } |
265 | #endif |
384 | #endif |
266 | 385 | ||
267 | struct cfi_escape_data |
386 | struct cfi_escape_data |
268 | { |
387 | { |
269 | struct cfi_escape_data *next; |
388 | struct cfi_escape_data *next; |
270 | expressionS exp; |
389 | expressionS exp; |
271 | }; |
390 | }; |
272 | 391 | ||
273 | struct cie_entry |
392 | struct cie_entry |
274 | { |
393 | { |
275 | struct cie_entry *next; |
394 | struct cie_entry *next; |
276 | #if SUPPORT_FRAME_LINKONCE |
395 | #if MULTIPLE_FRAME_SECTIONS |
277 | segT cur_seg; |
396 | segT cur_seg; |
278 | #endif |
397 | #endif |
279 | symbolS *start_address; |
398 | symbolS *start_address; |
280 | unsigned int return_column; |
399 | unsigned int return_column; |
281 | unsigned int signal_frame; |
400 | unsigned int signal_frame; |
- | 401 | unsigned char fde_encoding; |
|
282 | unsigned char per_encoding; |
402 | unsigned char per_encoding; |
283 | unsigned char lsda_encoding; |
403 | unsigned char lsda_encoding; |
284 | expressionS personality; |
404 | expressionS personality; |
285 | struct cfi_insn_data *first, *last; |
405 | struct cfi_insn_data *first, *last; |
286 | }; |
406 | }; |
287 | 407 | ||
288 | /* List of FDE entries. */ |
408 | /* List of FDE entries. */ |
289 | 409 | ||
290 | struct fde_entry *all_fde_data; |
410 | struct fde_entry *all_fde_data; |
291 | static struct fde_entry **last_fde_data = &all_fde_data; |
411 | static struct fde_entry **last_fde_data = &all_fde_data; |
292 | 412 | ||
293 | /* List of CIEs so that they could be reused. */ |
413 | /* List of CIEs so that they could be reused. */ |
294 | static struct cie_entry *cie_root; |
414 | static struct cie_entry *cie_root; |
295 | 415 | ||
296 | /* Stack of old CFI data, for save/restore. */ |
416 | /* Stack of old CFI data, for save/restore. */ |
297 | struct cfa_save_data |
417 | struct cfa_save_data |
298 | { |
418 | { |
299 | struct cfa_save_data *next; |
419 | struct cfa_save_data *next; |
300 | offsetT cfa_offset; |
420 | offsetT cfa_offset; |
301 | }; |
421 | }; |
302 | 422 | ||
303 | /* Current open FDE entry. */ |
423 | /* Current open FDE entry. */ |
304 | struct frch_cfi_data |
424 | struct frch_cfi_data |
305 | { |
425 | { |
306 | struct fde_entry *cur_fde_data; |
426 | struct fde_entry *cur_fde_data; |
307 | symbolS *last_address; |
427 | symbolS *last_address; |
308 | offsetT cur_cfa_offset; |
428 | offsetT cur_cfa_offset; |
309 | struct cfa_save_data *cfa_save_stack; |
429 | struct cfa_save_data *cfa_save_stack; |
310 | }; |
430 | }; |
311 | 431 | ||
312 | /* Construct a new FDE structure and add it to the end of the fde list. */ |
432 | /* Construct a new FDE structure and add it to the end of the fde list. */ |
313 | 433 | ||
314 | static struct fde_entry * |
434 | static struct fde_entry * |
315 | alloc_fde_entry (void) |
435 | alloc_fde_entry (void) |
316 | { |
436 | { |
317 | struct fde_entry *fde = (struct fde_entry *) |
437 | struct fde_entry *fde = (struct fde_entry *) |
318 | xcalloc (1, sizeof (struct fde_entry)); |
438 | xcalloc (1, sizeof (struct fde_entry)); |
319 | 439 | ||
320 | frchain_now->frch_cfi_data = (struct frch_cfi_data *) |
440 | frchain_now->frch_cfi_data = (struct frch_cfi_data *) |
321 | xcalloc (1, sizeof (struct frch_cfi_data)); |
441 | xcalloc (1, sizeof (struct frch_cfi_data)); |
322 | frchain_now->frch_cfi_data->cur_fde_data = fde; |
442 | frchain_now->frch_cfi_data->cur_fde_data = fde; |
323 | *last_fde_data = fde; |
443 | *last_fde_data = fde; |
324 | last_fde_data = &fde->next; |
444 | last_fde_data = &fde->next; |
325 | SET_CUR_SEG (fde, is_now_linkonce_segment ()); |
445 | SET_CUR_SEG (fde, is_now_linkonce_segment ()); |
326 | SET_HANDLED (fde, 0); |
446 | SET_HANDLED (fde, 0); |
327 | fde->last = &fde->data; |
447 | fde->last = &fde->data; |
328 | fde->return_column = DWARF2_DEFAULT_RETURN_COLUMN; |
448 | fde->return_column = DWARF2_DEFAULT_RETURN_COLUMN; |
329 | fde->per_encoding = DW_EH_PE_omit; |
449 | fde->per_encoding = DW_EH_PE_omit; |
330 | fde->lsda_encoding = DW_EH_PE_omit; |
450 | fde->lsda_encoding = DW_EH_PE_omit; |
- | 451 | fde->eh_header_type = EH_COMPACT_UNKNOWN; |
|
331 | 452 | ||
332 | return fde; |
453 | return fde; |
333 | } |
454 | } |
334 | 455 | ||
335 | /* The following functions are available for a backend to construct its |
456 | /* The following functions are available for a backend to construct its |
336 | own unwind information, usually from legacy unwind directives. */ |
457 | own unwind information, usually from legacy unwind directives. */ |
337 | 458 | ||
338 | /* Construct a new INSN structure and add it to the end of the insn list |
459 | /* Construct a new INSN structure and add it to the end of the insn list |
339 | for the currently active FDE. */ |
460 | for the currently active FDE. */ |
- | 461 | ||
- | 462 | static bfd_boolean cfi_sections_set = FALSE; |
|
- | 463 | static int cfi_sections = CFI_EMIT_eh_frame; |
|
- | 464 | int all_cfi_sections = 0; |
|
- | 465 | static struct fde_entry *last_fde; |
|
340 | 466 | ||
341 | static struct cfi_insn_data * |
467 | static struct cfi_insn_data * |
342 | alloc_cfi_insn_data (void) |
468 | alloc_cfi_insn_data (void) |
343 | { |
469 | { |
344 | struct cfi_insn_data *insn = (struct cfi_insn_data *) |
470 | struct cfi_insn_data *insn = (struct cfi_insn_data *) |
345 | xcalloc (1, sizeof (struct cfi_insn_data)); |
471 | xcalloc (1, sizeof (struct cfi_insn_data)); |
346 | struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data; |
472 | struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data; |
347 | 473 | ||
348 | *cur_fde_data->last = insn; |
474 | *cur_fde_data->last = insn; |
349 | cur_fde_data->last = &insn->next; |
475 | cur_fde_data->last = &insn->next; |
350 | SET_CUR_SEG (insn, is_now_linkonce_segment ()); |
476 | SET_CUR_SEG (insn, is_now_linkonce_segment ()); |
351 | return insn; |
477 | return insn; |
352 | } |
478 | } |
353 | 479 | ||
354 | /* Construct a new FDE structure that begins at LABEL. */ |
480 | /* Construct a new FDE structure that begins at LABEL. */ |
355 | 481 | ||
356 | void |
482 | void |
357 | cfi_new_fde (symbolS *label) |
483 | cfi_new_fde (symbolS *label) |
358 | { |
484 | { |
359 | struct fde_entry *fde = alloc_fde_entry (); |
485 | struct fde_entry *fde = alloc_fde_entry (); |
360 | fde->start_address = label; |
486 | fde->start_address = label; |
361 | frchain_now->frch_cfi_data->last_address = label; |
487 | frchain_now->frch_cfi_data->last_address = label; |
362 | } |
488 | } |
363 | 489 | ||
364 | /* End the currently open FDE. */ |
490 | /* End the currently open FDE. */ |
365 | 491 | ||
366 | void |
492 | void |
367 | cfi_end_fde (symbolS *label) |
493 | cfi_end_fde (symbolS *label) |
368 | { |
494 | { |
369 | frchain_now->frch_cfi_data->cur_fde_data->end_address = label; |
495 | frchain_now->frch_cfi_data->cur_fde_data->end_address = label; |
370 | free (frchain_now->frch_cfi_data); |
496 | free (frchain_now->frch_cfi_data); |
371 | frchain_now->frch_cfi_data = NULL; |
497 | frchain_now->frch_cfi_data = NULL; |
372 | } |
498 | } |
373 | 499 | ||
374 | /* Set the return column for the current FDE. */ |
500 | /* Set the return column for the current FDE. */ |
375 | 501 | ||
376 | void |
502 | void |
377 | cfi_set_return_column (unsigned regno) |
503 | cfi_set_return_column (unsigned regno) |
378 | { |
504 | { |
379 | frchain_now->frch_cfi_data->cur_fde_data->return_column = regno; |
505 | frchain_now->frch_cfi_data->cur_fde_data->return_column = regno; |
380 | } |
506 | } |
- | 507 | ||
- | 508 | void |
|
- | 509 | cfi_set_sections (void) |
|
- | 510 | { |
|
- | 511 | frchain_now->frch_cfi_data->cur_fde_data->sections = all_cfi_sections; |
|
- | 512 | } |
|
381 | 513 | ||
382 | /* Universal functions to store new instructions. */ |
514 | /* Universal functions to store new instructions. */ |
383 | 515 | ||
384 | static void |
516 | static void |
385 | cfi_add_CFA_insn (int insn) |
517 | cfi_add_CFA_insn (int insn) |
386 | { |
518 | { |
387 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
519 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
388 | 520 | ||
389 | insn_ptr->insn = insn; |
521 | insn_ptr->insn = insn; |
390 | } |
522 | } |
391 | 523 | ||
392 | static void |
524 | static void |
393 | cfi_add_CFA_insn_reg (int insn, unsigned regno) |
525 | cfi_add_CFA_insn_reg (int insn, unsigned regno) |
394 | { |
526 | { |
395 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
527 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
396 | 528 | ||
397 | insn_ptr->insn = insn; |
529 | insn_ptr->insn = insn; |
398 | insn_ptr->u.r = regno; |
530 | insn_ptr->u.r = regno; |
399 | } |
531 | } |
400 | 532 | ||
401 | static void |
533 | static void |
402 | cfi_add_CFA_insn_offset (int insn, offsetT offset) |
534 | cfi_add_CFA_insn_offset (int insn, offsetT offset) |
403 | { |
535 | { |
404 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
536 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
405 | 537 | ||
406 | insn_ptr->insn = insn; |
538 | insn_ptr->insn = insn; |
407 | insn_ptr->u.i = offset; |
539 | insn_ptr->u.i = offset; |
408 | } |
540 | } |
409 | 541 | ||
410 | static void |
542 | static void |
411 | cfi_add_CFA_insn_reg_reg (int insn, unsigned reg1, unsigned reg2) |
543 | cfi_add_CFA_insn_reg_reg (int insn, unsigned reg1, unsigned reg2) |
412 | { |
544 | { |
413 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
545 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
414 | 546 | ||
415 | insn_ptr->insn = insn; |
547 | insn_ptr->insn = insn; |
416 | insn_ptr->u.rr.reg1 = reg1; |
548 | insn_ptr->u.rr.reg1 = reg1; |
417 | insn_ptr->u.rr.reg2 = reg2; |
549 | insn_ptr->u.rr.reg2 = reg2; |
418 | } |
550 | } |
419 | 551 | ||
420 | static void |
552 | static void |
421 | cfi_add_CFA_insn_reg_offset (int insn, unsigned regno, offsetT offset) |
553 | cfi_add_CFA_insn_reg_offset (int insn, unsigned regno, offsetT offset) |
422 | { |
554 | { |
423 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
555 | struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); |
424 | 556 | ||
425 | insn_ptr->insn = insn; |
557 | insn_ptr->insn = insn; |
426 | insn_ptr->u.ri.reg = regno; |
558 | insn_ptr->u.ri.reg = regno; |
427 | insn_ptr->u.ri.offset = offset; |
559 | insn_ptr->u.ri.offset = offset; |
428 | } |
560 | } |
429 | 561 | ||
430 | /* Add a CFI insn to advance the PC from the last address to LABEL. */ |
562 | /* Add a CFI insn to advance the PC from the last address to LABEL. */ |
431 | 563 | ||
432 | void |
564 | void |
433 | cfi_add_advance_loc (symbolS *label) |
565 | cfi_add_advance_loc (symbolS *label) |
434 | { |
566 | { |
435 | struct cfi_insn_data *insn = alloc_cfi_insn_data (); |
567 | struct cfi_insn_data *insn = alloc_cfi_insn_data (); |
436 | 568 | ||
437 | insn->insn = DW_CFA_advance_loc; |
569 | insn->insn = DW_CFA_advance_loc; |
438 | insn->u.ll.lab1 = frchain_now->frch_cfi_data->last_address; |
570 | insn->u.ll.lab1 = frchain_now->frch_cfi_data->last_address; |
439 | insn->u.ll.lab2 = label; |
571 | insn->u.ll.lab2 = label; |
440 | 572 | ||
441 | frchain_now->frch_cfi_data->last_address = label; |
573 | frchain_now->frch_cfi_data->last_address = label; |
442 | } |
574 | } |
- | 575 | ||
- | 576 | /* Add a CFI insn to label the current position in the CFI segment. */ |
|
- | 577 | ||
- | 578 | void |
|
- | 579 | cfi_add_label (const char *name) |
|
- | 580 | { |
|
- | 581 | unsigned int len = strlen (name) + 1; |
|
- | 582 | struct cfi_insn_data *insn = alloc_cfi_insn_data (); |
|
- | 583 | ||
- | 584 | insn->insn = CFI_label; |
|
- | 585 | obstack_grow (¬es, name, len); |
|
- | 586 | insn->u.sym_name = (char *) obstack_finish (¬es); |
|
- | 587 | } |
|
443 | 588 | ||
444 | /* Add a DW_CFA_offset record to the CFI data. */ |
589 | /* Add a DW_CFA_offset record to the CFI data. */ |
445 | 590 | ||
446 | void |
591 | void |
447 | cfi_add_CFA_offset (unsigned regno, offsetT offset) |
592 | cfi_add_CFA_offset (unsigned regno, offsetT offset) |
448 | { |
593 | { |
449 | unsigned int abs_data_align; |
594 | unsigned int abs_data_align; |
450 | 595 | ||
451 | gas_assert (DWARF2_CIE_DATA_ALIGNMENT != 0); |
596 | gas_assert (DWARF2_CIE_DATA_ALIGNMENT != 0); |
452 | cfi_add_CFA_insn_reg_offset (DW_CFA_offset, regno, offset); |
597 | cfi_add_CFA_insn_reg_offset (DW_CFA_offset, regno, offset); |
453 | 598 | ||
454 | abs_data_align = (DWARF2_CIE_DATA_ALIGNMENT < 0 |
599 | abs_data_align = (DWARF2_CIE_DATA_ALIGNMENT < 0 |
455 | ? -DWARF2_CIE_DATA_ALIGNMENT : DWARF2_CIE_DATA_ALIGNMENT); |
600 | ? -DWARF2_CIE_DATA_ALIGNMENT : DWARF2_CIE_DATA_ALIGNMENT); |
456 | if (offset % abs_data_align) |
601 | if (offset % abs_data_align) |
457 | as_bad (_("register save offset not a multiple of %u"), abs_data_align); |
602 | as_bad (_("register save offset not a multiple of %u"), abs_data_align); |
458 | } |
603 | } |
459 | 604 | ||
460 | /* Add a DW_CFA_def_cfa record to the CFI data. */ |
605 | /* Add a DW_CFA_def_cfa record to the CFI data. */ |
461 | 606 | ||
462 | void |
607 | void |
463 | cfi_add_CFA_def_cfa (unsigned regno, offsetT offset) |
608 | cfi_add_CFA_def_cfa (unsigned regno, offsetT offset) |
464 | { |
609 | { |
465 | cfi_add_CFA_insn_reg_offset (DW_CFA_def_cfa, regno, offset); |
610 | cfi_add_CFA_insn_reg_offset (DW_CFA_def_cfa, regno, offset); |
466 | frchain_now->frch_cfi_data->cur_cfa_offset = offset; |
611 | frchain_now->frch_cfi_data->cur_cfa_offset = offset; |
467 | } |
612 | } |
468 | 613 | ||
469 | /* Add a DW_CFA_register record to the CFI data. */ |
614 | /* Add a DW_CFA_register record to the CFI data. */ |
470 | 615 | ||
471 | void |
616 | void |
472 | cfi_add_CFA_register (unsigned reg1, unsigned reg2) |
617 | cfi_add_CFA_register (unsigned reg1, unsigned reg2) |
473 | { |
618 | { |
474 | cfi_add_CFA_insn_reg_reg (DW_CFA_register, reg1, reg2); |
619 | cfi_add_CFA_insn_reg_reg (DW_CFA_register, reg1, reg2); |
475 | } |
620 | } |
476 | 621 | ||
477 | /* Add a DW_CFA_def_cfa_register record to the CFI data. */ |
622 | /* Add a DW_CFA_def_cfa_register record to the CFI data. */ |
478 | 623 | ||
479 | void |
624 | void |
480 | cfi_add_CFA_def_cfa_register (unsigned regno) |
625 | cfi_add_CFA_def_cfa_register (unsigned regno) |
481 | { |
626 | { |
482 | cfi_add_CFA_insn_reg (DW_CFA_def_cfa_register, regno); |
627 | cfi_add_CFA_insn_reg (DW_CFA_def_cfa_register, regno); |
483 | } |
628 | } |
484 | 629 | ||
485 | /* Add a DW_CFA_def_cfa_offset record to the CFI data. */ |
630 | /* Add a DW_CFA_def_cfa_offset record to the CFI data. */ |
486 | 631 | ||
487 | void |
632 | void |
488 | cfi_add_CFA_def_cfa_offset (offsetT offset) |
633 | cfi_add_CFA_def_cfa_offset (offsetT offset) |
489 | { |
634 | { |
490 | cfi_add_CFA_insn_offset (DW_CFA_def_cfa_offset, offset); |
635 | cfi_add_CFA_insn_offset (DW_CFA_def_cfa_offset, offset); |
491 | frchain_now->frch_cfi_data->cur_cfa_offset = offset; |
636 | frchain_now->frch_cfi_data->cur_cfa_offset = offset; |
492 | } |
637 | } |
493 | 638 | ||
494 | void |
639 | void |
495 | cfi_add_CFA_restore (unsigned regno) |
640 | cfi_add_CFA_restore (unsigned regno) |
496 | { |
641 | { |
497 | cfi_add_CFA_insn_reg (DW_CFA_restore, regno); |
642 | cfi_add_CFA_insn_reg (DW_CFA_restore, regno); |
498 | } |
643 | } |
499 | 644 | ||
500 | void |
645 | void |
501 | cfi_add_CFA_undefined (unsigned regno) |
646 | cfi_add_CFA_undefined (unsigned regno) |
502 | { |
647 | { |
503 | cfi_add_CFA_insn_reg (DW_CFA_undefined, regno); |
648 | cfi_add_CFA_insn_reg (DW_CFA_undefined, regno); |
504 | } |
649 | } |
505 | 650 | ||
506 | void |
651 | void |
507 | cfi_add_CFA_same_value (unsigned regno) |
652 | cfi_add_CFA_same_value (unsigned regno) |
508 | { |
653 | { |
509 | cfi_add_CFA_insn_reg (DW_CFA_same_value, regno); |
654 | cfi_add_CFA_insn_reg (DW_CFA_same_value, regno); |
510 | } |
655 | } |
511 | 656 | ||
512 | void |
657 | void |
513 | cfi_add_CFA_remember_state (void) |
658 | cfi_add_CFA_remember_state (void) |
514 | { |
659 | { |
515 | struct cfa_save_data *p; |
660 | struct cfa_save_data *p; |
516 | 661 | ||
517 | cfi_add_CFA_insn (DW_CFA_remember_state); |
662 | cfi_add_CFA_insn (DW_CFA_remember_state); |
518 | 663 | ||
519 | p = (struct cfa_save_data *) xmalloc (sizeof (*p)); |
664 | p = (struct cfa_save_data *) xmalloc (sizeof (*p)); |
520 | p->cfa_offset = frchain_now->frch_cfi_data->cur_cfa_offset; |
665 | p->cfa_offset = frchain_now->frch_cfi_data->cur_cfa_offset; |
521 | p->next = frchain_now->frch_cfi_data->cfa_save_stack; |
666 | p->next = frchain_now->frch_cfi_data->cfa_save_stack; |
522 | frchain_now->frch_cfi_data->cfa_save_stack = p; |
667 | frchain_now->frch_cfi_data->cfa_save_stack = p; |
523 | } |
668 | } |
524 | 669 | ||
525 | void |
670 | void |
526 | cfi_add_CFA_restore_state (void) |
671 | cfi_add_CFA_restore_state (void) |
527 | { |
672 | { |
528 | struct cfa_save_data *p; |
673 | struct cfa_save_data *p; |
529 | 674 | ||
530 | cfi_add_CFA_insn (DW_CFA_restore_state); |
675 | cfi_add_CFA_insn (DW_CFA_restore_state); |
531 | 676 | ||
532 | p = frchain_now->frch_cfi_data->cfa_save_stack; |
677 | p = frchain_now->frch_cfi_data->cfa_save_stack; |
533 | if (p) |
678 | if (p) |
534 | { |
679 | { |
535 | frchain_now->frch_cfi_data->cur_cfa_offset = p->cfa_offset; |
680 | frchain_now->frch_cfi_data->cur_cfa_offset = p->cfa_offset; |
536 | frchain_now->frch_cfi_data->cfa_save_stack = p->next; |
681 | frchain_now->frch_cfi_data->cfa_save_stack = p->next; |
537 | free (p); |
682 | free (p); |
538 | } |
683 | } |
539 | else |
684 | else |
540 | as_bad (_("CFI state restore without previous remember")); |
685 | as_bad (_("CFI state restore without previous remember")); |
541 | } |
686 | } |
542 | 687 | ||
543 | 688 | ||
544 | /* Parse CFI assembler directives. */ |
689 | /* Parse CFI assembler directives. */ |
545 | 690 | ||
546 | static void dot_cfi (int); |
691 | static void dot_cfi (int); |
547 | static void dot_cfi_escape (int); |
692 | static void dot_cfi_escape (int); |
548 | static void dot_cfi_sections (int); |
693 | static void dot_cfi_sections (int); |
549 | static void dot_cfi_startproc (int); |
694 | static void dot_cfi_startproc (int); |
550 | static void dot_cfi_endproc (int); |
695 | static void dot_cfi_endproc (int); |
- | 696 | static void dot_cfi_fde_data (int); |
|
551 | static void dot_cfi_personality (int); |
697 | static void dot_cfi_personality (int); |
- | 698 | static void dot_cfi_personality_id (int); |
|
552 | static void dot_cfi_lsda (int); |
699 | static void dot_cfi_lsda (int); |
553 | static void dot_cfi_val_encoded_addr (int); |
700 | static void dot_cfi_val_encoded_addr (int); |
- | 701 | static void dot_cfi_inline_lsda (int); |
|
- | 702 | static void dot_cfi_label (int); |
|
554 | 703 | ||
555 | const pseudo_typeS cfi_pseudo_table[] = |
704 | const pseudo_typeS cfi_pseudo_table[] = |
556 | { |
705 | { |
557 | { "cfi_sections", dot_cfi_sections, 0 }, |
706 | { "cfi_sections", dot_cfi_sections, 0 }, |
558 | { "cfi_startproc", dot_cfi_startproc, 0 }, |
707 | { "cfi_startproc", dot_cfi_startproc, 0 }, |
559 | { "cfi_endproc", dot_cfi_endproc, 0 }, |
708 | { "cfi_endproc", dot_cfi_endproc, 0 }, |
- | 709 | { "cfi_fde_data", dot_cfi_fde_data, 0 }, |
|
560 | { "cfi_def_cfa", dot_cfi, DW_CFA_def_cfa }, |
710 | { "cfi_def_cfa", dot_cfi, DW_CFA_def_cfa }, |
561 | { "cfi_def_cfa_register", dot_cfi, DW_CFA_def_cfa_register }, |
711 | { "cfi_def_cfa_register", dot_cfi, DW_CFA_def_cfa_register }, |
562 | { "cfi_def_cfa_offset", dot_cfi, DW_CFA_def_cfa_offset }, |
712 | { "cfi_def_cfa_offset", dot_cfi, DW_CFA_def_cfa_offset }, |
563 | { "cfi_adjust_cfa_offset", dot_cfi, CFI_adjust_cfa_offset }, |
713 | { "cfi_adjust_cfa_offset", dot_cfi, CFI_adjust_cfa_offset }, |
564 | { "cfi_offset", dot_cfi, DW_CFA_offset }, |
714 | { "cfi_offset", dot_cfi, DW_CFA_offset }, |
565 | { "cfi_rel_offset", dot_cfi, CFI_rel_offset }, |
715 | { "cfi_rel_offset", dot_cfi, CFI_rel_offset }, |
566 | { "cfi_register", dot_cfi, DW_CFA_register }, |
716 | { "cfi_register", dot_cfi, DW_CFA_register }, |
567 | { "cfi_return_column", dot_cfi, CFI_return_column }, |
717 | { "cfi_return_column", dot_cfi, CFI_return_column }, |
568 | { "cfi_restore", dot_cfi, DW_CFA_restore }, |
718 | { "cfi_restore", dot_cfi, DW_CFA_restore }, |
569 | { "cfi_undefined", dot_cfi, DW_CFA_undefined }, |
719 | { "cfi_undefined", dot_cfi, DW_CFA_undefined }, |
570 | { "cfi_same_value", dot_cfi, DW_CFA_same_value }, |
720 | { "cfi_same_value", dot_cfi, DW_CFA_same_value }, |
571 | { "cfi_remember_state", dot_cfi, DW_CFA_remember_state }, |
721 | { "cfi_remember_state", dot_cfi, DW_CFA_remember_state }, |
572 | { "cfi_restore_state", dot_cfi, DW_CFA_restore_state }, |
722 | { "cfi_restore_state", dot_cfi, DW_CFA_restore_state }, |
573 | { "cfi_window_save", dot_cfi, DW_CFA_GNU_window_save }, |
723 | { "cfi_window_save", dot_cfi, DW_CFA_GNU_window_save }, |
574 | { "cfi_escape", dot_cfi_escape, 0 }, |
724 | { "cfi_escape", dot_cfi_escape, 0 }, |
575 | { "cfi_signal_frame", dot_cfi, CFI_signal_frame }, |
725 | { "cfi_signal_frame", dot_cfi, CFI_signal_frame }, |
576 | { "cfi_personality", dot_cfi_personality, 0 }, |
726 | { "cfi_personality", dot_cfi_personality, 0 }, |
- | 727 | { "cfi_personality_id", dot_cfi_personality_id, 0 }, |
|
577 | { "cfi_lsda", dot_cfi_lsda, 0 }, |
728 | { "cfi_lsda", dot_cfi_lsda, 0 }, |
578 | { "cfi_val_encoded_addr", dot_cfi_val_encoded_addr, 0 }, |
729 | { "cfi_val_encoded_addr", dot_cfi_val_encoded_addr, 0 }, |
- | 730 | { "cfi_inline_lsda", dot_cfi_inline_lsda, 0 }, |
|
- | 731 | { "cfi_label", dot_cfi_label, 0 }, |
|
579 | { NULL, NULL, 0 } |
732 | { NULL, NULL, 0 } |
580 | }; |
733 | }; |
581 | 734 | ||
582 | static void |
735 | static void |
583 | cfi_parse_separator (void) |
736 | cfi_parse_separator (void) |
584 | { |
737 | { |
585 | SKIP_WHITESPACE (); |
738 | SKIP_WHITESPACE (); |
586 | if (*input_line_pointer == ',') |
739 | if (*input_line_pointer == ',') |
587 | input_line_pointer++; |
740 | input_line_pointer++; |
588 | else |
741 | else |
589 | as_bad (_("missing separator")); |
742 | as_bad (_("missing separator")); |
590 | } |
743 | } |
591 | 744 | ||
592 | #ifndef tc_parse_to_dw2regnum |
745 | #ifndef tc_parse_to_dw2regnum |
593 | static void |
746 | static void |
594 | tc_parse_to_dw2regnum (expressionS *exp) |
747 | tc_parse_to_dw2regnum (expressionS *exp) |
595 | { |
748 | { |
596 | # ifdef tc_regname_to_dw2regnum |
749 | # ifdef tc_regname_to_dw2regnum |
597 | SKIP_WHITESPACE (); |
750 | SKIP_WHITESPACE (); |
598 | if (is_name_beginner (*input_line_pointer) |
751 | if (is_name_beginner (*input_line_pointer) |
599 | || (*input_line_pointer == '%' |
752 | || (*input_line_pointer == '%' |
600 | && is_name_beginner (*++input_line_pointer))) |
753 | && is_name_beginner (*++input_line_pointer))) |
601 | { |
754 | { |
602 | char *name, c; |
755 | char *name, c; |
603 | - | ||
604 | name = input_line_pointer; |
756 | |
605 | c = get_symbol_end (); |
757 | c = get_symbol_name (& name); |
606 | 758 | ||
607 | exp->X_op = O_constant; |
759 | exp->X_op = O_constant; |
608 | exp->X_add_number = tc_regname_to_dw2regnum (name); |
760 | exp->X_add_number = tc_regname_to_dw2regnum (name); |
609 | 761 | ||
610 | *input_line_pointer = c; |
762 | restore_line_pointer (c); |
611 | } |
763 | } |
612 | else |
764 | else |
613 | # endif |
765 | # endif |
614 | expression_and_evaluate (exp); |
766 | expression_and_evaluate (exp); |
615 | } |
767 | } |
616 | #endif |
768 | #endif |
617 | 769 | ||
618 | static unsigned |
770 | static unsigned |
619 | cfi_parse_reg (void) |
771 | cfi_parse_reg (void) |
620 | { |
772 | { |
621 | int regno; |
773 | int regno; |
622 | expressionS exp; |
774 | expressionS exp; |
623 | 775 | ||
624 | tc_parse_to_dw2regnum (&exp); |
776 | tc_parse_to_dw2regnum (&exp); |
625 | switch (exp.X_op) |
777 | switch (exp.X_op) |
626 | { |
778 | { |
627 | case O_register: |
779 | case O_register: |
628 | case O_constant: |
780 | case O_constant: |
629 | regno = exp.X_add_number; |
781 | regno = exp.X_add_number; |
630 | break; |
782 | break; |
631 | 783 | ||
632 | default: |
784 | default: |
633 | regno = -1; |
785 | regno = -1; |
634 | break; |
786 | break; |
635 | } |
787 | } |
636 | 788 | ||
637 | if (regno < 0) |
789 | if (regno < 0) |
638 | { |
790 | { |
639 | as_bad (_("bad register expression")); |
791 | as_bad (_("bad register expression")); |
640 | regno = 0; |
792 | regno = 0; |
641 | } |
793 | } |
642 | 794 | ||
643 | return regno; |
795 | return regno; |
644 | } |
796 | } |
645 | 797 | ||
646 | static offsetT |
798 | static offsetT |
647 | cfi_parse_const (void) |
799 | cfi_parse_const (void) |
648 | { |
800 | { |
649 | return get_absolute_expression (); |
801 | return get_absolute_expression (); |
650 | } |
802 | } |
651 | 803 | ||
652 | static void |
804 | static void |
653 | dot_cfi (int arg) |
805 | dot_cfi (int arg) |
654 | { |
806 | { |
655 | offsetT offset; |
807 | offsetT offset; |
656 | unsigned reg1, reg2; |
808 | unsigned reg1, reg2; |
657 | 809 | ||
658 | if (frchain_now->frch_cfi_data == NULL) |
810 | if (frchain_now->frch_cfi_data == NULL) |
659 | { |
811 | { |
660 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
812 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
661 | ignore_rest_of_line (); |
813 | ignore_rest_of_line (); |
662 | return; |
814 | return; |
663 | } |
815 | } |
664 | 816 | ||
665 | /* If the last address was not at the current PC, advance to current. */ |
817 | /* If the last address was not at the current PC, advance to current. */ |
666 | if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now |
818 | if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now |
667 | || S_GET_VALUE (frchain_now->frch_cfi_data->last_address) |
819 | || S_GET_VALUE (frchain_now->frch_cfi_data->last_address) |
668 | != frag_now_fix ()) |
820 | != frag_now_fix ()) |
669 | cfi_add_advance_loc (symbol_temp_new_now ()); |
821 | cfi_add_advance_loc (symbol_temp_new_now ()); |
670 | 822 | ||
671 | switch (arg) |
823 | switch (arg) |
672 | { |
824 | { |
673 | case DW_CFA_offset: |
825 | case DW_CFA_offset: |
674 | reg1 = cfi_parse_reg (); |
826 | reg1 = cfi_parse_reg (); |
675 | cfi_parse_separator (); |
827 | cfi_parse_separator (); |
676 | offset = cfi_parse_const (); |
828 | offset = cfi_parse_const (); |
677 | cfi_add_CFA_offset (reg1, offset); |
829 | cfi_add_CFA_offset (reg1, offset); |
678 | break; |
830 | break; |
679 | 831 | ||
680 | case CFI_rel_offset: |
832 | case CFI_rel_offset: |
681 | reg1 = cfi_parse_reg (); |
833 | reg1 = cfi_parse_reg (); |
682 | cfi_parse_separator (); |
834 | cfi_parse_separator (); |
683 | offset = cfi_parse_const (); |
835 | offset = cfi_parse_const (); |
684 | cfi_add_CFA_offset (reg1, |
836 | cfi_add_CFA_offset (reg1, |
685 | offset - frchain_now->frch_cfi_data->cur_cfa_offset); |
837 | offset - frchain_now->frch_cfi_data->cur_cfa_offset); |
686 | break; |
838 | break; |
687 | 839 | ||
688 | case DW_CFA_def_cfa: |
840 | case DW_CFA_def_cfa: |
689 | reg1 = cfi_parse_reg (); |
841 | reg1 = cfi_parse_reg (); |
690 | cfi_parse_separator (); |
842 | cfi_parse_separator (); |
691 | offset = cfi_parse_const (); |
843 | offset = cfi_parse_const (); |
692 | cfi_add_CFA_def_cfa (reg1, offset); |
844 | cfi_add_CFA_def_cfa (reg1, offset); |
693 | break; |
845 | break; |
694 | 846 | ||
695 | case DW_CFA_register: |
847 | case DW_CFA_register: |
696 | reg1 = cfi_parse_reg (); |
848 | reg1 = cfi_parse_reg (); |
697 | cfi_parse_separator (); |
849 | cfi_parse_separator (); |
698 | reg2 = cfi_parse_reg (); |
850 | reg2 = cfi_parse_reg (); |
699 | cfi_add_CFA_register (reg1, reg2); |
851 | cfi_add_CFA_register (reg1, reg2); |
700 | break; |
852 | break; |
701 | 853 | ||
702 | case DW_CFA_def_cfa_register: |
854 | case DW_CFA_def_cfa_register: |
703 | reg1 = cfi_parse_reg (); |
855 | reg1 = cfi_parse_reg (); |
704 | cfi_add_CFA_def_cfa_register (reg1); |
856 | cfi_add_CFA_def_cfa_register (reg1); |
705 | break; |
857 | break; |
706 | 858 | ||
707 | case DW_CFA_def_cfa_offset: |
859 | case DW_CFA_def_cfa_offset: |
708 | offset = cfi_parse_const (); |
860 | offset = cfi_parse_const (); |
709 | cfi_add_CFA_def_cfa_offset (offset); |
861 | cfi_add_CFA_def_cfa_offset (offset); |
710 | break; |
862 | break; |
711 | 863 | ||
712 | case CFI_adjust_cfa_offset: |
864 | case CFI_adjust_cfa_offset: |
713 | offset = cfi_parse_const (); |
865 | offset = cfi_parse_const (); |
714 | cfi_add_CFA_def_cfa_offset (frchain_now->frch_cfi_data->cur_cfa_offset |
866 | cfi_add_CFA_def_cfa_offset (frchain_now->frch_cfi_data->cur_cfa_offset |
715 | + offset); |
867 | + offset); |
716 | break; |
868 | break; |
717 | 869 | ||
718 | case DW_CFA_restore: |
870 | case DW_CFA_restore: |
719 | for (;;) |
871 | for (;;) |
720 | { |
872 | { |
721 | reg1 = cfi_parse_reg (); |
873 | reg1 = cfi_parse_reg (); |
722 | cfi_add_CFA_restore (reg1); |
874 | cfi_add_CFA_restore (reg1); |
723 | SKIP_WHITESPACE (); |
875 | SKIP_WHITESPACE (); |
724 | if (*input_line_pointer != ',') |
876 | if (*input_line_pointer != ',') |
725 | break; |
877 | break; |
726 | ++input_line_pointer; |
878 | ++input_line_pointer; |
727 | } |
879 | } |
728 | break; |
880 | break; |
729 | 881 | ||
730 | case DW_CFA_undefined: |
882 | case DW_CFA_undefined: |
731 | for (;;) |
883 | for (;;) |
732 | { |
884 | { |
733 | reg1 = cfi_parse_reg (); |
885 | reg1 = cfi_parse_reg (); |
734 | cfi_add_CFA_undefined (reg1); |
886 | cfi_add_CFA_undefined (reg1); |
735 | SKIP_WHITESPACE (); |
887 | SKIP_WHITESPACE (); |
736 | if (*input_line_pointer != ',') |
888 | if (*input_line_pointer != ',') |
737 | break; |
889 | break; |
738 | ++input_line_pointer; |
890 | ++input_line_pointer; |
739 | } |
891 | } |
740 | break; |
892 | break; |
741 | 893 | ||
742 | case DW_CFA_same_value: |
894 | case DW_CFA_same_value: |
743 | reg1 = cfi_parse_reg (); |
895 | reg1 = cfi_parse_reg (); |
744 | cfi_add_CFA_same_value (reg1); |
896 | cfi_add_CFA_same_value (reg1); |
745 | break; |
897 | break; |
746 | 898 | ||
747 | case CFI_return_column: |
899 | case CFI_return_column: |
748 | reg1 = cfi_parse_reg (); |
900 | reg1 = cfi_parse_reg (); |
749 | cfi_set_return_column (reg1); |
901 | cfi_set_return_column (reg1); |
750 | break; |
902 | break; |
751 | 903 | ||
752 | case DW_CFA_remember_state: |
904 | case DW_CFA_remember_state: |
753 | cfi_add_CFA_remember_state (); |
905 | cfi_add_CFA_remember_state (); |
754 | break; |
906 | break; |
755 | 907 | ||
756 | case DW_CFA_restore_state: |
908 | case DW_CFA_restore_state: |
757 | cfi_add_CFA_restore_state (); |
909 | cfi_add_CFA_restore_state (); |
758 | break; |
910 | break; |
759 | 911 | ||
760 | case DW_CFA_GNU_window_save: |
912 | case DW_CFA_GNU_window_save: |
761 | cfi_add_CFA_insn (DW_CFA_GNU_window_save); |
913 | cfi_add_CFA_insn (DW_CFA_GNU_window_save); |
762 | break; |
914 | break; |
763 | 915 | ||
764 | case CFI_signal_frame: |
916 | case CFI_signal_frame: |
765 | frchain_now->frch_cfi_data->cur_fde_data->signal_frame = 1; |
917 | frchain_now->frch_cfi_data->cur_fde_data->signal_frame = 1; |
766 | break; |
918 | break; |
767 | 919 | ||
768 | default: |
920 | default: |
769 | abort (); |
921 | abort (); |
770 | } |
922 | } |
771 | 923 | ||
772 | demand_empty_rest_of_line (); |
924 | demand_empty_rest_of_line (); |
773 | } |
925 | } |
774 | 926 | ||
775 | static void |
927 | static void |
776 | dot_cfi_escape (int ignored ATTRIBUTE_UNUSED) |
928 | dot_cfi_escape (int ignored ATTRIBUTE_UNUSED) |
777 | { |
929 | { |
778 | struct cfi_escape_data *head, **tail, *e; |
930 | struct cfi_escape_data *head, **tail, *e; |
779 | struct cfi_insn_data *insn; |
931 | struct cfi_insn_data *insn; |
780 | 932 | ||
781 | if (frchain_now->frch_cfi_data == NULL) |
933 | if (frchain_now->frch_cfi_data == NULL) |
782 | { |
934 | { |
783 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
935 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
784 | ignore_rest_of_line (); |
936 | ignore_rest_of_line (); |
785 | return; |
937 | return; |
786 | } |
938 | } |
787 | 939 | ||
788 | /* If the last address was not at the current PC, advance to current. */ |
940 | /* If the last address was not at the current PC, advance to current. */ |
789 | if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now |
941 | if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now |
790 | || S_GET_VALUE (frchain_now->frch_cfi_data->last_address) |
942 | || S_GET_VALUE (frchain_now->frch_cfi_data->last_address) |
791 | != frag_now_fix ()) |
943 | != frag_now_fix ()) |
792 | cfi_add_advance_loc (symbol_temp_new_now ()); |
944 | cfi_add_advance_loc (symbol_temp_new_now ()); |
793 | 945 | ||
794 | tail = &head; |
946 | tail = &head; |
795 | do |
947 | do |
796 | { |
948 | { |
797 | e = (struct cfi_escape_data *) xmalloc (sizeof (*e)); |
949 | e = (struct cfi_escape_data *) xmalloc (sizeof (*e)); |
798 | do_parse_cons_expression (&e->exp, 1); |
950 | do_parse_cons_expression (&e->exp, 1); |
799 | *tail = e; |
951 | *tail = e; |
800 | tail = &e->next; |
952 | tail = &e->next; |
801 | } |
953 | } |
802 | while (*input_line_pointer++ == ','); |
954 | while (*input_line_pointer++ == ','); |
803 | *tail = NULL; |
955 | *tail = NULL; |
804 | 956 | ||
805 | insn = alloc_cfi_insn_data (); |
957 | insn = alloc_cfi_insn_data (); |
806 | insn->insn = CFI_escape; |
958 | insn->insn = CFI_escape; |
807 | insn->u.esc = head; |
959 | insn->u.esc = head; |
808 | 960 | ||
809 | --input_line_pointer; |
961 | --input_line_pointer; |
810 | demand_empty_rest_of_line (); |
962 | demand_empty_rest_of_line (); |
811 | } |
963 | } |
812 | 964 | ||
813 | static void |
965 | static void |
814 | dot_cfi_personality (int ignored ATTRIBUTE_UNUSED) |
966 | dot_cfi_personality (int ignored ATTRIBUTE_UNUSED) |
815 | { |
967 | { |
816 | struct fde_entry *fde; |
968 | struct fde_entry *fde; |
817 | offsetT encoding; |
969 | offsetT encoding; |
818 | 970 | ||
819 | if (frchain_now->frch_cfi_data == NULL) |
971 | if (frchain_now->frch_cfi_data == NULL) |
820 | { |
972 | { |
821 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
973 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
822 | ignore_rest_of_line (); |
974 | ignore_rest_of_line (); |
823 | return; |
975 | return; |
824 | } |
976 | } |
825 | 977 | ||
826 | fde = frchain_now->frch_cfi_data->cur_fde_data; |
978 | fde = frchain_now->frch_cfi_data->cur_fde_data; |
827 | encoding = cfi_parse_const (); |
979 | encoding = cfi_parse_const (); |
828 | if (encoding == DW_EH_PE_omit) |
980 | if (encoding == DW_EH_PE_omit) |
829 | { |
981 | { |
830 | demand_empty_rest_of_line (); |
982 | demand_empty_rest_of_line (); |
831 | fde->per_encoding = encoding; |
983 | fde->per_encoding = encoding; |
832 | return; |
984 | return; |
833 | } |
985 | } |
834 | 986 | ||
835 | if ((encoding & 0xff) != encoding |
987 | if ((encoding & 0xff) != encoding |
836 | || ((encoding & 0x70) != 0 |
988 | || ((((encoding & 0x70) != 0 |
837 | #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr |
989 | #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr |
838 | && (encoding & 0x70) != DW_EH_PE_pcrel |
990 | && (encoding & 0x70) != DW_EH_PE_pcrel |
839 | #endif |
991 | #endif |
840 | ) |
992 | ) |
841 | /* leb128 can be handled, but does something actually need it? */ |
993 | /* leb128 can be handled, but does something actually need it? */ |
842 | || (encoding & 7) == DW_EH_PE_uleb128 |
994 | || (encoding & 7) == DW_EH_PE_uleb128 |
843 | || (encoding & 7) > DW_EH_PE_udata8) |
995 | || (encoding & 7) > DW_EH_PE_udata8) |
- | 996 | && tc_cfi_reloc_for_encoding (encoding) == BFD_RELOC_NONE)) |
|
844 | { |
997 | { |
845 | as_bad (_("invalid or unsupported encoding in .cfi_personality")); |
998 | as_bad (_("invalid or unsupported encoding in .cfi_personality")); |
846 | ignore_rest_of_line (); |
999 | ignore_rest_of_line (); |
847 | return; |
1000 | return; |
848 | } |
1001 | } |
849 | 1002 | ||
850 | if (*input_line_pointer++ != ',') |
1003 | if (*input_line_pointer++ != ',') |
851 | { |
1004 | { |
852 | as_bad (_(".cfi_personality requires encoding and symbol arguments")); |
1005 | as_bad (_(".cfi_personality requires encoding and symbol arguments")); |
853 | ignore_rest_of_line (); |
1006 | ignore_rest_of_line (); |
854 | return; |
1007 | return; |
855 | } |
1008 | } |
856 | 1009 | ||
857 | expression_and_evaluate (&fde->personality); |
1010 | expression_and_evaluate (&fde->personality); |
858 | switch (fde->personality.X_op) |
1011 | switch (fde->personality.X_op) |
859 | { |
1012 | { |
860 | case O_symbol: |
1013 | case O_symbol: |
861 | break; |
1014 | break; |
862 | case O_constant: |
1015 | case O_constant: |
863 | if ((encoding & 0x70) == DW_EH_PE_pcrel) |
1016 | if ((encoding & 0x70) == DW_EH_PE_pcrel) |
864 | encoding = DW_EH_PE_omit; |
1017 | encoding = DW_EH_PE_omit; |
865 | break; |
1018 | break; |
866 | default: |
1019 | default: |
867 | encoding = DW_EH_PE_omit; |
1020 | encoding = DW_EH_PE_omit; |
868 | break; |
1021 | break; |
869 | } |
1022 | } |
870 | 1023 | ||
871 | fde->per_encoding = encoding; |
1024 | fde->per_encoding = encoding; |
872 | 1025 | ||
873 | if (encoding == DW_EH_PE_omit) |
1026 | if (encoding == DW_EH_PE_omit) |
874 | { |
1027 | { |
875 | as_bad (_("wrong second argument to .cfi_personality")); |
1028 | as_bad (_("wrong second argument to .cfi_personality")); |
876 | ignore_rest_of_line (); |
1029 | ignore_rest_of_line (); |
877 | return; |
1030 | return; |
878 | } |
1031 | } |
879 | 1032 | ||
880 | demand_empty_rest_of_line (); |
1033 | demand_empty_rest_of_line (); |
881 | } |
1034 | } |
882 | 1035 | ||
883 | static void |
1036 | static void |
884 | dot_cfi_lsda (int ignored ATTRIBUTE_UNUSED) |
1037 | dot_cfi_lsda (int ignored ATTRIBUTE_UNUSED) |
885 | { |
1038 | { |
886 | struct fde_entry *fde; |
1039 | struct fde_entry *fde; |
887 | offsetT encoding; |
1040 | offsetT encoding; |
888 | 1041 | ||
889 | if (frchain_now->frch_cfi_data == NULL) |
1042 | if (frchain_now->frch_cfi_data == NULL) |
890 | { |
1043 | { |
891 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
1044 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
892 | ignore_rest_of_line (); |
1045 | ignore_rest_of_line (); |
893 | return; |
1046 | return; |
894 | } |
1047 | } |
895 | 1048 | ||
896 | fde = frchain_now->frch_cfi_data->cur_fde_data; |
1049 | fde = frchain_now->frch_cfi_data->cur_fde_data; |
897 | encoding = cfi_parse_const (); |
1050 | encoding = cfi_parse_const (); |
898 | if (encoding == DW_EH_PE_omit) |
1051 | if (encoding == DW_EH_PE_omit) |
899 | { |
1052 | { |
900 | demand_empty_rest_of_line (); |
1053 | demand_empty_rest_of_line (); |
901 | fde->lsda_encoding = encoding; |
1054 | fde->lsda_encoding = encoding; |
902 | return; |
1055 | return; |
903 | } |
1056 | } |
904 | 1057 | ||
905 | if ((encoding & 0xff) != encoding |
1058 | if ((encoding & 0xff) != encoding |
906 | || ((encoding & 0x70) != 0 |
1059 | || ((((encoding & 0x70) != 0 |
907 | #if CFI_DIFF_LSDA_OK || defined tc_cfi_emit_pcrel_expr |
1060 | #if CFI_DIFF_LSDA_OK || defined tc_cfi_emit_pcrel_expr |
908 | && (encoding & 0x70) != DW_EH_PE_pcrel |
1061 | && (encoding & 0x70) != DW_EH_PE_pcrel |
909 | #endif |
1062 | #endif |
910 | ) |
1063 | ) |
911 | /* leb128 can be handled, but does something actually need it? */ |
1064 | /* leb128 can be handled, but does something actually need it? */ |
912 | || (encoding & 7) == DW_EH_PE_uleb128 |
1065 | || (encoding & 7) == DW_EH_PE_uleb128 |
913 | || (encoding & 7) > DW_EH_PE_udata8) |
1066 | || (encoding & 7) > DW_EH_PE_udata8) |
- | 1067 | && tc_cfi_reloc_for_encoding (encoding) == BFD_RELOC_NONE)) |
|
914 | { |
1068 | { |
915 | as_bad (_("invalid or unsupported encoding in .cfi_lsda")); |
1069 | as_bad (_("invalid or unsupported encoding in .cfi_lsda")); |
916 | ignore_rest_of_line (); |
1070 | ignore_rest_of_line (); |
917 | return; |
1071 | return; |
918 | } |
1072 | } |
919 | 1073 | ||
920 | if (*input_line_pointer++ != ',') |
1074 | if (*input_line_pointer++ != ',') |
921 | { |
1075 | { |
922 | as_bad (_(".cfi_lsda requires encoding and symbol arguments")); |
1076 | as_bad (_(".cfi_lsda requires encoding and symbol arguments")); |
923 | ignore_rest_of_line (); |
1077 | ignore_rest_of_line (); |
924 | return; |
1078 | return; |
925 | } |
1079 | } |
926 | 1080 | ||
927 | fde->lsda_encoding = encoding; |
1081 | fde->lsda_encoding = encoding; |
928 | 1082 | ||
929 | expression_and_evaluate (&fde->lsda); |
1083 | expression_and_evaluate (&fde->lsda); |
930 | switch (fde->lsda.X_op) |
1084 | switch (fde->lsda.X_op) |
931 | { |
1085 | { |
932 | case O_symbol: |
1086 | case O_symbol: |
933 | break; |
1087 | break; |
934 | case O_constant: |
1088 | case O_constant: |
935 | if ((encoding & 0x70) == DW_EH_PE_pcrel) |
1089 | if ((encoding & 0x70) == DW_EH_PE_pcrel) |
936 | encoding = DW_EH_PE_omit; |
1090 | encoding = DW_EH_PE_omit; |
937 | break; |
1091 | break; |
938 | default: |
1092 | default: |
939 | encoding = DW_EH_PE_omit; |
1093 | encoding = DW_EH_PE_omit; |
940 | break; |
1094 | break; |
941 | } |
1095 | } |
942 | 1096 | ||
943 | fde->lsda_encoding = encoding; |
1097 | fde->lsda_encoding = encoding; |
944 | 1098 | ||
945 | if (encoding == DW_EH_PE_omit) |
1099 | if (encoding == DW_EH_PE_omit) |
946 | { |
1100 | { |
947 | as_bad (_("wrong second argument to .cfi_lsda")); |
1101 | as_bad (_("wrong second argument to .cfi_lsda")); |
948 | ignore_rest_of_line (); |
1102 | ignore_rest_of_line (); |
949 | return; |
1103 | return; |
950 | } |
1104 | } |
951 | 1105 | ||
952 | demand_empty_rest_of_line (); |
1106 | demand_empty_rest_of_line (); |
953 | } |
1107 | } |
954 | 1108 | ||
955 | static void |
1109 | static void |
956 | dot_cfi_val_encoded_addr (int ignored ATTRIBUTE_UNUSED) |
1110 | dot_cfi_val_encoded_addr (int ignored ATTRIBUTE_UNUSED) |
957 | { |
1111 | { |
958 | struct cfi_insn_data *insn_ptr; |
1112 | struct cfi_insn_data *insn_ptr; |
959 | offsetT encoding; |
1113 | offsetT encoding; |
960 | 1114 | ||
961 | if (frchain_now->frch_cfi_data == NULL) |
1115 | if (frchain_now->frch_cfi_data == NULL) |
962 | { |
1116 | { |
963 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
1117 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
964 | ignore_rest_of_line (); |
1118 | ignore_rest_of_line (); |
965 | return; |
1119 | return; |
966 | } |
1120 | } |
967 | 1121 | ||
968 | /* If the last address was not at the current PC, advance to current. */ |
1122 | /* If the last address was not at the current PC, advance to current. */ |
969 | if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now |
1123 | if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now |
970 | || S_GET_VALUE (frchain_now->frch_cfi_data->last_address) |
1124 | || S_GET_VALUE (frchain_now->frch_cfi_data->last_address) |
971 | != frag_now_fix ()) |
1125 | != frag_now_fix ()) |
972 | cfi_add_advance_loc (symbol_temp_new_now ()); |
1126 | cfi_add_advance_loc (symbol_temp_new_now ()); |
973 | 1127 | ||
974 | insn_ptr = alloc_cfi_insn_data (); |
1128 | insn_ptr = alloc_cfi_insn_data (); |
975 | insn_ptr->insn = CFI_val_encoded_addr; |
1129 | insn_ptr->insn = CFI_val_encoded_addr; |
976 | 1130 | ||
977 | insn_ptr->u.ea.reg = cfi_parse_reg (); |
1131 | insn_ptr->u.ea.reg = cfi_parse_reg (); |
978 | 1132 | ||
979 | cfi_parse_separator (); |
1133 | cfi_parse_separator (); |
980 | encoding = cfi_parse_const (); |
1134 | encoding = cfi_parse_const (); |
981 | if ((encoding & 0xff) != encoding |
1135 | if ((encoding & 0xff) != encoding |
982 | || ((encoding & 0x70) != 0 |
1136 | || ((encoding & 0x70) != 0 |
983 | #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr |
1137 | #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr |
984 | && (encoding & 0x70) != DW_EH_PE_pcrel |
1138 | && (encoding & 0x70) != DW_EH_PE_pcrel |
985 | #endif |
1139 | #endif |
986 | ) |
1140 | ) |
987 | /* leb128 can be handled, but does something actually need it? */ |
1141 | /* leb128 can be handled, but does something actually need it? */ |
988 | || (encoding & 7) == DW_EH_PE_uleb128 |
1142 | || (encoding & 7) == DW_EH_PE_uleb128 |
989 | || (encoding & 7) > DW_EH_PE_udata8) |
1143 | || (encoding & 7) > DW_EH_PE_udata8) |
990 | { |
1144 | { |
991 | as_bad (_("invalid or unsupported encoding in .cfi_lsda")); |
1145 | as_bad (_("invalid or unsupported encoding in .cfi_lsda")); |
992 | encoding = DW_EH_PE_omit; |
1146 | encoding = DW_EH_PE_omit; |
993 | } |
1147 | } |
994 | 1148 | ||
995 | cfi_parse_separator (); |
1149 | cfi_parse_separator (); |
996 | expression_and_evaluate (&insn_ptr->u.ea.exp); |
1150 | expression_and_evaluate (&insn_ptr->u.ea.exp); |
997 | switch (insn_ptr->u.ea.exp.X_op) |
1151 | switch (insn_ptr->u.ea.exp.X_op) |
998 | { |
1152 | { |
999 | case O_symbol: |
1153 | case O_symbol: |
1000 | break; |
1154 | break; |
1001 | case O_constant: |
1155 | case O_constant: |
1002 | if ((encoding & 0x70) != DW_EH_PE_pcrel) |
1156 | if ((encoding & 0x70) != DW_EH_PE_pcrel) |
1003 | break; |
1157 | break; |
1004 | default: |
1158 | default: |
1005 | encoding = DW_EH_PE_omit; |
1159 | encoding = DW_EH_PE_omit; |
1006 | break; |
1160 | break; |
1007 | } |
1161 | } |
1008 | 1162 | ||
1009 | insn_ptr->u.ea.encoding = encoding; |
1163 | insn_ptr->u.ea.encoding = encoding; |
1010 | if (encoding == DW_EH_PE_omit) |
1164 | if (encoding == DW_EH_PE_omit) |
1011 | { |
1165 | { |
1012 | as_bad (_("wrong third argument to .cfi_val_encoded_addr")); |
1166 | as_bad (_("wrong third argument to .cfi_val_encoded_addr")); |
1013 | ignore_rest_of_line (); |
1167 | ignore_rest_of_line (); |
1014 | return; |
1168 | return; |
1015 | } |
1169 | } |
1016 | 1170 | ||
1017 | demand_empty_rest_of_line (); |
1171 | demand_empty_rest_of_line (); |
1018 | } |
1172 | } |
- | 1173 | ||
1019 | 1174 | static void |
|
- | 1175 | dot_cfi_label (int ignored ATTRIBUTE_UNUSED) |
|
1020 | /* By default emit .eh_frame only, not .debug_frame. */ |
1176 | { |
- | 1177 | char *name = read_symbol_name (); |
|
- | 1178 | ||
- | 1179 | if (name == NULL) |
|
- | 1180 | return; |
|
- | 1181 | ||
- | 1182 | /* If the last address was not at the current PC, advance to current. */ |
|
- | 1183 | if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now |
|
- | 1184 | || S_GET_VALUE (frchain_now->frch_cfi_data->last_address) |
|
1021 | #define CFI_EMIT_eh_frame (1 << 0) |
1185 | != frag_now_fix ()) |
- | 1186 | cfi_add_advance_loc (symbol_temp_new_now ()); |
|
1022 | #define CFI_EMIT_debug_frame (1 << 1) |
1187 | |
- | 1188 | cfi_add_label (name); |
|
1023 | #define CFI_EMIT_target (1 << 2) |
1189 | |
- | 1190 | demand_empty_rest_of_line (); |
|
1024 | static int cfi_sections = CFI_EMIT_eh_frame; |
1191 | } |
1025 | 1192 | ||
1026 | static void |
1193 | static void |
1027 | dot_cfi_sections (int ignored ATTRIBUTE_UNUSED) |
1194 | dot_cfi_sections (int ignored ATTRIBUTE_UNUSED) |
1028 | { |
1195 | { |
1029 | int sections = 0; |
1196 | int sections = 0; |
1030 | 1197 | ||
1031 | SKIP_WHITESPACE (); |
1198 | SKIP_WHITESPACE (); |
1032 | if (is_name_beginner (*input_line_pointer)) |
1199 | if (is_name_beginner (*input_line_pointer) || *input_line_pointer == '"') |
1033 | while (1) |
1200 | while (1) |
1034 | { |
1201 | { |
- | 1202 | char * saved_ilp; |
|
1035 | char *name, c; |
1203 | char *name, c; |
1036 | 1204 | ||
1037 | name = input_line_pointer; |
1205 | saved_ilp = input_line_pointer; |
1038 | c = get_symbol_end (); |
1206 | c = get_symbol_name (& name); |
1039 | 1207 | ||
1040 | if (strncmp (name, ".eh_frame", sizeof ".eh_frame") == 0 |
1208 | if (strncmp (name, ".eh_frame", sizeof ".eh_frame") == 0 |
1041 | && name[9] != '_') |
1209 | && name[9] != '_') |
1042 | sections |= CFI_EMIT_eh_frame; |
1210 | sections |= CFI_EMIT_eh_frame; |
1043 | else if (strncmp (name, ".debug_frame", sizeof ".debug_frame") == 0) |
1211 | else if (strncmp (name, ".debug_frame", sizeof ".debug_frame") == 0) |
1044 | sections |= CFI_EMIT_debug_frame; |
1212 | sections |= CFI_EMIT_debug_frame; |
- | 1213 | #if SUPPORT_COMPACT_EH |
|
- | 1214 | else if (strncmp (name, ".eh_frame_entry", sizeof ".eh_frame_entry") == 0) |
|
- | 1215 | { |
|
- | 1216 | compact_eh = TRUE; |
|
- | 1217 | sections |= CFI_EMIT_eh_frame_compact; |
|
- | 1218 | } |
|
- | 1219 | #endif |
|
1045 | #ifdef tc_cfi_section_name |
1220 | #ifdef tc_cfi_section_name |
1046 | else if (strcmp (name, tc_cfi_section_name) == 0) |
1221 | else if (strcmp (name, tc_cfi_section_name) == 0) |
1047 | sections |= CFI_EMIT_target; |
1222 | sections |= CFI_EMIT_target; |
1048 | #endif |
1223 | #endif |
1049 | else |
1224 | else |
1050 | { |
1225 | { |
1051 | *input_line_pointer = c; |
1226 | *input_line_pointer = c; |
1052 | input_line_pointer = name; |
1227 | input_line_pointer = saved_ilp; |
1053 | break; |
1228 | break; |
1054 | } |
1229 | } |
1055 | 1230 | ||
1056 | *input_line_pointer = c; |
1231 | *input_line_pointer = c; |
1057 | SKIP_WHITESPACE (); |
1232 | SKIP_WHITESPACE_AFTER_NAME (); |
1058 | if (*input_line_pointer == ',') |
1233 | if (*input_line_pointer == ',') |
1059 | { |
1234 | { |
1060 | name = input_line_pointer++; |
1235 | name = input_line_pointer++; |
1061 | SKIP_WHITESPACE (); |
1236 | SKIP_WHITESPACE (); |
1062 | if (!is_name_beginner (*input_line_pointer)) |
1237 | if (!is_name_beginner (*input_line_pointer) && *input_line_pointer != '"') |
1063 | { |
1238 | { |
1064 | input_line_pointer = name; |
1239 | input_line_pointer = name; |
1065 | break; |
1240 | break; |
1066 | } |
1241 | } |
1067 | } |
1242 | } |
1068 | else if (is_name_beginner (*input_line_pointer)) |
1243 | else if (is_name_beginner (*input_line_pointer) || *input_line_pointer == '"') |
1069 | break; |
1244 | break; |
1070 | } |
1245 | } |
1071 | 1246 | ||
1072 | demand_empty_rest_of_line (); |
1247 | demand_empty_rest_of_line (); |
- | 1248 | if (cfi_sections_set && cfi_sections != sections) |
|
- | 1249 | as_bad (_("inconsistent uses of .cfi_sections")); |
|
- | 1250 | cfi_sections_set = TRUE; |
|
1073 | cfi_sections = sections; |
1251 | cfi_sections = sections; |
1074 | } |
1252 | } |
1075 | 1253 | ||
1076 | static void |
1254 | static void |
1077 | dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED) |
1255 | dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED) |
1078 | { |
1256 | { |
1079 | int simple = 0; |
1257 | int simple = 0; |
1080 | 1258 | ||
1081 | if (frchain_now->frch_cfi_data != NULL) |
1259 | if (frchain_now->frch_cfi_data != NULL) |
1082 | { |
1260 | { |
1083 | as_bad (_("previous CFI entry not closed (missing .cfi_endproc)")); |
1261 | as_bad (_("previous CFI entry not closed (missing .cfi_endproc)")); |
1084 | ignore_rest_of_line (); |
1262 | ignore_rest_of_line (); |
1085 | return; |
1263 | return; |
1086 | } |
1264 | } |
1087 | 1265 | ||
1088 | cfi_new_fde (symbol_temp_new_now ()); |
1266 | cfi_new_fde (symbol_temp_new_now ()); |
1089 | 1267 | ||
1090 | SKIP_WHITESPACE (); |
1268 | SKIP_WHITESPACE (); |
1091 | if (is_name_beginner (*input_line_pointer)) |
1269 | if (is_name_beginner (*input_line_pointer) || *input_line_pointer == '"') |
1092 | { |
1270 | { |
- | 1271 | char * saved_ilp = input_line_pointer; |
|
1093 | char *name, c; |
1272 | char *name, c; |
1094 | - | ||
1095 | name = input_line_pointer; |
1273 | |
1096 | c = get_symbol_end (); |
1274 | c = get_symbol_name (& name); |
1097 | 1275 | ||
1098 | if (strcmp (name, "simple") == 0) |
1276 | if (strcmp (name, "simple") == 0) |
1099 | { |
1277 | { |
1100 | simple = 1; |
1278 | simple = 1; |
1101 | *input_line_pointer = c; |
1279 | restore_line_pointer (c); |
1102 | } |
1280 | } |
1103 | else |
1281 | else |
1104 | input_line_pointer = name; |
1282 | input_line_pointer = saved_ilp; |
1105 | } |
1283 | } |
1106 | demand_empty_rest_of_line (); |
1284 | demand_empty_rest_of_line (); |
- | 1285 | ||
- | 1286 | all_cfi_sections |= cfi_sections; |
|
1107 | 1287 | cfi_set_sections (); |
|
1108 | frchain_now->frch_cfi_data->cur_cfa_offset = 0; |
1288 | frchain_now->frch_cfi_data->cur_cfa_offset = 0; |
1109 | if (!simple) |
1289 | if (!simple) |
1110 | tc_cfi_frame_initial_instructions (); |
1290 | tc_cfi_frame_initial_instructions (); |
1111 | 1291 | ||
1112 | if ((cfi_sections & CFI_EMIT_target) != 0) |
1292 | if ((cfi_sections & CFI_EMIT_target) != 0) |
1113 | tc_cfi_startproc (); |
1293 | tc_cfi_startproc (); |
1114 | } |
1294 | } |
1115 | 1295 | ||
1116 | static void |
1296 | static void |
1117 | dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED) |
1297 | dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED) |
1118 | { |
1298 | { |
1119 | struct fde_entry *fde; |
- | |
1120 | - | ||
1121 | if (frchain_now->frch_cfi_data == NULL) |
1299 | if (frchain_now->frch_cfi_data == NULL) |
1122 | { |
1300 | { |
1123 | as_bad (_(".cfi_endproc without corresponding .cfi_startproc")); |
1301 | as_bad (_(".cfi_endproc without corresponding .cfi_startproc")); |
1124 | ignore_rest_of_line (); |
1302 | ignore_rest_of_line (); |
1125 | return; |
1303 | return; |
1126 | } |
1304 | } |
1127 | 1305 | ||
1128 | fde = frchain_now->frch_cfi_data->cur_fde_data; |
1306 | last_fde = frchain_now->frch_cfi_data->cur_fde_data; |
1129 | 1307 | ||
1130 | cfi_end_fde (symbol_temp_new_now ()); |
1308 | cfi_end_fde (symbol_temp_new_now ()); |
1131 | 1309 | ||
1132 | demand_empty_rest_of_line (); |
1310 | demand_empty_rest_of_line (); |
1133 | 1311 | ||
1134 | if ((cfi_sections & CFI_EMIT_target) != 0) |
1312 | if ((cfi_sections & CFI_EMIT_target) != 0) |
1135 | tc_cfi_endproc (fde); |
1313 | tc_cfi_endproc (last_fde); |
1136 | } |
1314 | } |
- | 1315 | ||
- | 1316 | static segT |
|
- | 1317 | get_cfi_seg (segT cseg, const char *base, flagword flags, int align) |
|
- | 1318 | { |
|
- | 1319 | /* Exclude .debug_frame sections for Compact EH. */ |
|
- | 1320 | if (SUPPORT_FRAME_LINKONCE || ((flags & SEC_DEBUGGING) == 0 && compact_eh)) |
|
- | 1321 | { |
|
1137 | 1322 | struct dwcfi_seg_list *l; |
|
1138 | 1323 | ||
1139 | /* Emit a single byte into the current segment. */ |
1324 | l = dwcfi_hash_find_or_make (cseg, base, flags); |
1140 | 1325 | ||
- | 1326 | cseg = l->seg; |
|
- | 1327 | subseg_set (cseg, l->subseg); |
|
1141 | static inline void |
1328 | } |
1142 | out_one (int byte) |
1329 | else |
- | 1330 | { |
|
- | 1331 | cseg = subseg_new (base, 0); |
|
- | 1332 | bfd_set_section_flags (stdoutput, cseg, flags); |
|
- | 1333 | } |
|
1143 | { |
1334 | record_alignment (cseg, align); |
- | 1335 | return cseg; |
|
- | 1336 | } |
|
1144 | FRAG_APPEND_1_CHAR (byte); |
1337 | |
- | 1338 | #if SUPPORT_COMPACT_EH |
|
- | 1339 | static void |
|
1145 | } |
- | |
1146 | 1340 | dot_cfi_personality_id (int ignored ATTRIBUTE_UNUSED) |
|
1147 | /* Emit a two-byte word into the current segment. */ |
1341 | { |
- | 1342 | struct fde_entry *fde; |
|
1148 | 1343 | ||
- | 1344 | if (frchain_now->frch_cfi_data == NULL) |
|
1149 | static inline void |
1345 | { |
- | 1346 | as_bad (_("CFI instruction used without previous .cfi_startproc")); |
|
1150 | out_two (int data) |
1347 | ignore_rest_of_line (); |
- | 1348 | return; |
|
1151 | { |
- | |
1152 | md_number_to_chars (frag_more (2), data, 2); |
1349 | } |
1153 | } |
1350 | |
1154 | 1351 | fde = frchain_now->frch_cfi_data->cur_fde_data; |
|
- | 1352 | fde->personality_id = cfi_parse_const (); |
|
- | 1353 | demand_empty_rest_of_line (); |
|
1155 | /* Emit a four byte word into the current segment. */ |
1354 | |
- | 1355 | if (fde->personality_id == 0 || fde->personality_id > 3) |
|
- | 1356 | { |
|
- | 1357 | as_bad (_("wrong argument to .cfi_personality_id")); |
|
- | 1358 | return; |
|
- | 1359 | } |
|
- | 1360 | } |
|
- | 1361 | ||
- | 1362 | static void |
|
- | 1363 | dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED) |
|
- | 1364 | { |
|
- | 1365 | if (frchain_now->frch_cfi_data == NULL) |
|
- | 1366 | { |
|
- | 1367 | as_bad (_(".cfi_fde_data without corresponding .cfi_startproc")); |
|
- | 1368 | ignore_rest_of_line (); |
|
- | 1369 | return; |
|
- | 1370 | } |
|
- | 1371 | ||
- | 1372 | last_fde = frchain_now->frch_cfi_data->cur_fde_data; |
|
- | 1373 | ||
- | 1374 | if ((cfi_sections & CFI_EMIT_target) != 0 |
|
- | 1375 | || (cfi_sections & CFI_EMIT_eh_frame_compact) != 0) |
|
- | 1376 | { |
|
- | 1377 | struct cfi_escape_data *head, **tail, *e; |
|
- | 1378 | int num_ops = 0; |
|
- | 1379 | ||
- | 1380 | tail = &head; |
|
- | 1381 | if (!is_it_end_of_statement ()) |
|
- | 1382 | { |
|
- | 1383 | num_ops = 0; |
|
- | 1384 | do |
|
- | 1385 | { |
|
- | 1386 | e = (struct cfi_escape_data *) xmalloc (sizeof (*e)); |
|
- | 1387 | do_parse_cons_expression (&e->exp, 1); |
|
- | 1388 | *tail = e; |
|
- | 1389 | tail = &e->next; |
|
- | 1390 | num_ops++; |
|
- | 1391 | } |
|
- | 1392 | while (*input_line_pointer++ == ','); |
|
- | 1393 | --input_line_pointer; |
|
- | 1394 | } |
|
- | 1395 | *tail = NULL; |
|
- | 1396 | ||
- | 1397 | if (last_fde->lsda_encoding != DW_EH_PE_omit) |
|
- | 1398 | last_fde->eh_header_type = EH_COMPACT_HAS_LSDA; |
|
- | 1399 | else if (num_ops <= 3 && last_fde->per_encoding == DW_EH_PE_omit) |
|
- | 1400 | last_fde->eh_header_type = EH_COMPACT_INLINE; |
|
- | 1401 | else |
|
- | 1402 | last_fde->eh_header_type = EH_COMPACT_OUTLINE; |
|
- | 1403 | ||
- | 1404 | if (last_fde->eh_header_type == EH_COMPACT_INLINE) |
|
- | 1405 | num_ops = 3; |
|
- | 1406 | ||
- | 1407 | last_fde->eh_data_size = num_ops; |
|
- | 1408 | last_fde->eh_data = (bfd_byte *) xmalloc (num_ops); |
|
- | 1409 | num_ops = 0; |
|
- | 1410 | while (head) |
|
- | 1411 | { |
|
- | 1412 | e = head; |
|
- | 1413 | head = e->next; |
|
- | 1414 | last_fde->eh_data[num_ops++] = e->exp.X_add_number; |
|
- | 1415 | free (e); |
|
- | 1416 | } |
|
- | 1417 | if (last_fde->eh_header_type == EH_COMPACT_INLINE) |
|
1156 | 1418 | while (num_ops < 3) |
|
- | 1419 | last_fde->eh_data[num_ops++] = tc_compact_eh_opcode_stop; |
|
- | 1420 | } |
|
1157 | static inline void |
1421 | |
1158 | out_four (int data) |
1422 | demand_empty_rest_of_line (); |
1159 | { |
1423 | } |
- | 1424 | ||
- | 1425 | /* Function to emit the compact unwinding opcodes stored in the |
|
- | 1426 | fde's eh_data field. The end of the opcode data will be |
|
- | 1427 | padded to the value in align. */ |
|
- | 1428 | ||
- | 1429 | static void |
|
- | 1430 | output_compact_unwind_data (struct fde_entry *fde, int align) |
|
- | 1431 | { |
|
- | 1432 | int data_size = fde->eh_data_size + 2; |
|
- | 1433 | int align_padding; |
|
- | 1434 | int amask; |
|
- | 1435 | char *p; |
|
- | 1436 | ||
- | 1437 | fde->eh_loc = symbol_temp_new_now (); |
|
- | 1438 | ||
- | 1439 | p = frag_more (1); |
|
- | 1440 | if (fde->personality_id != 0) |
|
- | 1441 | *p = fde->personality_id; |
|
- | 1442 | else if (fde->per_encoding != DW_EH_PE_omit) |
|
- | 1443 | { |
|
- | 1444 | *p = 0; |
|
- | 1445 | emit_expr_encoded (&fde->personality, fde->per_encoding, FALSE); |
|
1160 | md_number_to_chars (frag_more (4), data, 4); |
1446 | data_size += encoding_size (fde->per_encoding); |
- | 1447 | } |
|
- | 1448 | else |
|
- | 1449 | *p = 1; |
|
- | 1450 | ||
- | 1451 | amask = (1 << align) - 1; |
|
- | 1452 | align_padding = ((data_size + amask) & ~amask) - data_size; |
|
- | 1453 | ||
- | 1454 | p = frag_more (fde->eh_data_size + 1 + align_padding); |
|
1161 | } |
1455 | memcpy (p, fde->eh_data, fde->eh_data_size); |
1162 | 1456 | p += fde->eh_data_size; |
|
- | 1457 | ||
- | 1458 | while (align_padding-- > 0) |
|
- | 1459 | *(p++) = tc_compact_eh_opcode_pad; |
|
- | 1460 | ||
- | 1461 | *(p++) = tc_compact_eh_opcode_stop; |
|
- | 1462 | fde->eh_header_type = EH_COMPACT_OUTLINE_DONE; |
|
- | 1463 | } |
|
- | 1464 | ||
- | 1465 | /* Handle the .cfi_inline_lsda directive. */ |
|
- | 1466 | static void |
|
- | 1467 | dot_cfi_inline_lsda (int ignored ATTRIBUTE_UNUSED) |
|
- | 1468 | { |
|
- | 1469 | segT ccseg; |
|
- | 1470 | int align; |
|
- | 1471 | long max_alignment = 28; |
|
- | 1472 | ||
- | 1473 | if (!last_fde) |
|
- | 1474 | { |
|
- | 1475 | as_bad (_("unexpected .cfi_inline_lsda")); |
|
- | 1476 | ignore_rest_of_line (); |
|
- | 1477 | return; |
|
- | 1478 | } |
|
- | 1479 | ||
- | 1480 | if ((last_fde->sections & CFI_EMIT_eh_frame_compact) == 0) |
|
- | 1481 | { |
|
- | 1482 | as_bad (_(".cfi_inline_lsda not valid for this frame")); |
|
- | 1483 | ignore_rest_of_line (); |
|
- | 1484 | return; |
|
- | 1485 | } |
|
- | 1486 | ||
- | 1487 | if (last_fde->eh_header_type != EH_COMPACT_UNKNOWN |
|
- | 1488 | && last_fde->eh_header_type != EH_COMPACT_HAS_LSDA) |
|
- | 1489 | { |
|
- | 1490 | as_bad (_(".cfi_inline_lsda seen for frame without .cfi_lsda")); |
|
- | 1491 | ignore_rest_of_line (); |
|
- | 1492 | return; |
|
- | 1493 | } |
|
- | 1494 | ||
- | 1495 | #ifdef md_flush_pending_output |
|
- | 1496 | md_flush_pending_output (); |
|
- | 1497 | #endif |
|
- | 1498 | ||
- | 1499 | align = get_absolute_expression (); |
|
- | 1500 | if (align > max_alignment) |
|
- | 1501 | { |
|
- | 1502 | align = max_alignment; |
|
- | 1503 | as_bad (_("Alignment too large: %d. assumed."), align); |
|
- | 1504 | } |
|
- | 1505 | else if (align < 0) |
|
- | 1506 | { |
|
- | 1507 | as_warn (_("Alignment negative: 0 assumed.")); |
|
- | 1508 | align = 0; |
|
- | 1509 | } |
|
- | 1510 | ||
- | 1511 | demand_empty_rest_of_line (); |
|
- | 1512 | ccseg = CUR_SEG (last_fde); |
|
- | 1513 | ||
- | 1514 | /* Open .gnu_extab section. */ |
|
- | 1515 | get_cfi_seg (ccseg, ".gnu_extab", |
|
- | 1516 | (SEC_ALLOC | SEC_LOAD | SEC_DATA |
|
- | 1517 | | DWARF2_EH_FRAME_READ_ONLY), |
|
- | 1518 | 1); |
|
- | 1519 | ||
- | 1520 | frag_align (align, 0, 0); |
|
- | 1521 | record_alignment (now_seg, align); |
|
- | 1522 | if (last_fde->eh_header_type == EH_COMPACT_HAS_LSDA) |
|
- | 1523 | output_compact_unwind_data (last_fde, align); |
|
- | 1524 | ||
- | 1525 | last_fde = NULL; |
|
- | 1526 | ||
1163 | /* Emit an unsigned "little-endian base 128" number. */ |
1527 | return; |
1164 | 1528 | } |
|
1165 | static void |
1529 | #else /* !SUPPORT_COMPACT_EH */ |
1166 | out_uleb128 (addressT value) |
1530 | static void |
- | 1531 | dot_cfi_inline_lsda (int ignored ATTRIBUTE_UNUSED) |
|
- | 1532 | { |
|
- | 1533 | as_bad (_(".cfi_inline_lsda is not supported for this target")); |
|
- | 1534 | ignore_rest_of_line (); |
|
- | 1535 | } |
|
- | 1536 | ||
- | 1537 | static void |
|
- | 1538 | dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED) |
|
1167 | { |
1539 | { |
- | 1540 | as_bad (_(".cfi_fde_data is not supported for this target")); |
|
1168 | output_leb128 (frag_more (sizeof_leb128 (value, 0)), value, 0); |
1541 | ignore_rest_of_line (); |
1169 | } |
1542 | } |
1170 | 1543 | ||
1171 | /* Emit an unsigned "little-endian base 128" number. */ |
1544 | static void |
1172 | 1545 | dot_cfi_personality_id (int ignored ATTRIBUTE_UNUSED) |
|
1173 | static void |
1546 | { |
1174 | out_sleb128 (offsetT value) |
1547 | as_bad (_(".cfi_personality_id is not supported for this target")); |
1175 | { |
1548 | ignore_rest_of_line (); |
1176 | output_leb128 (frag_more (sizeof_leb128 (value, 1)), value, 1); |
1549 | } |
1177 | } |
1550 | #endif |
1178 | 1551 | ||
1179 | static void |
1552 | static void |
1180 | output_cfi_insn (struct cfi_insn_data *insn) |
1553 | output_cfi_insn (struct cfi_insn_data *insn) |
1181 | { |
1554 | { |
1182 | offsetT offset; |
1555 | offsetT offset; |
1183 | unsigned int regno; |
1556 | unsigned int regno; |
1184 | 1557 | ||
1185 | switch (insn->insn) |
1558 | switch (insn->insn) |
1186 | { |
1559 | { |
1187 | case DW_CFA_advance_loc: |
1560 | case DW_CFA_advance_loc: |
1188 | { |
1561 | { |
1189 | symbolS *from = insn->u.ll.lab1; |
1562 | symbolS *from = insn->u.ll.lab1; |
1190 | symbolS *to = insn->u.ll.lab2; |
1563 | symbolS *to = insn->u.ll.lab2; |
1191 | 1564 | ||
1192 | if (symbol_get_frag (to) == symbol_get_frag (from)) |
1565 | if (symbol_get_frag (to) == symbol_get_frag (from)) |
1193 | { |
1566 | { |
1194 | addressT delta = S_GET_VALUE (to) - S_GET_VALUE (from); |
1567 | addressT delta = S_GET_VALUE (to) - S_GET_VALUE (from); |
1195 | addressT scaled = delta / DWARF2_LINE_MIN_INSN_LENGTH; |
1568 | addressT scaled = delta / DWARF2_LINE_MIN_INSN_LENGTH; |
1196 | 1569 | ||
1197 | if (scaled <= 0x3F) |
1570 | if (scaled <= 0x3F) |
1198 | out_one (DW_CFA_advance_loc + scaled); |
1571 | out_one (DW_CFA_advance_loc + scaled); |
1199 | else if (scaled <= 0xFF) |
1572 | else if (scaled <= 0xFF) |
1200 | { |
1573 | { |
1201 | out_one (DW_CFA_advance_loc1); |
1574 | out_one (DW_CFA_advance_loc1); |
1202 | out_one (scaled); |
1575 | out_one (scaled); |
1203 | } |
1576 | } |
1204 | else if (scaled <= 0xFFFF) |
1577 | else if (scaled <= 0xFFFF) |
1205 | { |
1578 | { |
1206 | out_one (DW_CFA_advance_loc2); |
1579 | out_one (DW_CFA_advance_loc2); |
1207 | out_two (scaled); |
1580 | out_two (scaled); |
1208 | } |
1581 | } |
1209 | else |
1582 | else |
1210 | { |
1583 | { |
1211 | out_one (DW_CFA_advance_loc4); |
1584 | out_one (DW_CFA_advance_loc4); |
1212 | out_four (scaled); |
1585 | out_four (scaled); |
1213 | } |
1586 | } |
1214 | } |
1587 | } |
1215 | else |
1588 | else |
1216 | { |
1589 | { |
1217 | expressionS exp; |
1590 | expressionS exp; |
1218 | 1591 | ||
1219 | exp.X_op = O_subtract; |
1592 | exp.X_op = O_subtract; |
1220 | exp.X_add_symbol = to; |
1593 | exp.X_add_symbol = to; |
1221 | exp.X_op_symbol = from; |
1594 | exp.X_op_symbol = from; |
1222 | exp.X_add_number = 0; |
1595 | exp.X_add_number = 0; |
1223 | 1596 | ||
1224 | /* The code in ehopt.c expects that one byte of the encoding |
1597 | /* The code in ehopt.c expects that one byte of the encoding |
1225 | is already allocated to the frag. This comes from the way |
1598 | is already allocated to the frag. This comes from the way |
1226 | that it scans the .eh_frame section looking first for the |
1599 | that it scans the .eh_frame section looking first for the |
1227 | .byte DW_CFA_advance_loc4. */ |
1600 | .byte DW_CFA_advance_loc4. */ |
1228 | *frag_more (1) = DW_CFA_advance_loc4; |
1601 | *frag_more (1) = DW_CFA_advance_loc4; |
1229 | 1602 | ||
1230 | frag_var (rs_cfa, 4, 0, DWARF2_LINE_MIN_INSN_LENGTH << 3, |
1603 | frag_var (rs_cfa, 4, 0, DWARF2_LINE_MIN_INSN_LENGTH << 3, |
1231 | make_expr_symbol (&exp), frag_now_fix () - 1, |
1604 | make_expr_symbol (&exp), frag_now_fix () - 1, |
1232 | (char *) frag_now); |
1605 | (char *) frag_now); |
1233 | } |
1606 | } |
1234 | } |
1607 | } |
1235 | break; |
1608 | break; |
1236 | 1609 | ||
1237 | case DW_CFA_def_cfa: |
1610 | case DW_CFA_def_cfa: |
1238 | offset = insn->u.ri.offset; |
1611 | offset = insn->u.ri.offset; |
1239 | if (offset < 0) |
1612 | if (offset < 0) |
1240 | { |
1613 | { |
1241 | out_one (DW_CFA_def_cfa_sf); |
1614 | out_one (DW_CFA_def_cfa_sf); |
1242 | out_uleb128 (insn->u.ri.reg); |
1615 | out_uleb128 (insn->u.ri.reg); |
1243 | out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT); |
1616 | out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT); |
1244 | } |
1617 | } |
1245 | else |
1618 | else |
1246 | { |
1619 | { |
1247 | out_one (DW_CFA_def_cfa); |
1620 | out_one (DW_CFA_def_cfa); |
1248 | out_uleb128 (insn->u.ri.reg); |
1621 | out_uleb128 (insn->u.ri.reg); |
1249 | out_uleb128 (offset); |
1622 | out_uleb128 (offset); |
1250 | } |
1623 | } |
1251 | break; |
1624 | break; |
1252 | 1625 | ||
1253 | case DW_CFA_def_cfa_register: |
1626 | case DW_CFA_def_cfa_register: |
1254 | case DW_CFA_undefined: |
1627 | case DW_CFA_undefined: |
1255 | case DW_CFA_same_value: |
1628 | case DW_CFA_same_value: |
1256 | out_one (insn->insn); |
1629 | out_one (insn->insn); |
1257 | out_uleb128 (insn->u.r); |
1630 | out_uleb128 (insn->u.r); |
1258 | break; |
1631 | break; |
1259 | 1632 | ||
1260 | case DW_CFA_def_cfa_offset: |
1633 | case DW_CFA_def_cfa_offset: |
1261 | offset = insn->u.i; |
1634 | offset = insn->u.i; |
1262 | if (offset < 0) |
1635 | if (offset < 0) |
1263 | { |
1636 | { |
1264 | out_one (DW_CFA_def_cfa_offset_sf); |
1637 | out_one (DW_CFA_def_cfa_offset_sf); |
1265 | out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT); |
1638 | out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT); |
1266 | } |
1639 | } |
1267 | else |
1640 | else |
1268 | { |
1641 | { |
1269 | out_one (DW_CFA_def_cfa_offset); |
1642 | out_one (DW_CFA_def_cfa_offset); |
1270 | out_uleb128 (offset); |
1643 | out_uleb128 (offset); |
1271 | } |
1644 | } |
1272 | break; |
1645 | break; |
1273 | 1646 | ||
1274 | case DW_CFA_restore: |
1647 | case DW_CFA_restore: |
1275 | regno = insn->u.r; |
1648 | regno = insn->u.r; |
1276 | if (regno <= 0x3F) |
1649 | if (regno <= 0x3F) |
1277 | { |
1650 | { |
1278 | out_one (DW_CFA_restore + regno); |
1651 | out_one (DW_CFA_restore + regno); |
1279 | } |
1652 | } |
1280 | else |
1653 | else |
1281 | { |
1654 | { |
1282 | out_one (DW_CFA_restore_extended); |
1655 | out_one (DW_CFA_restore_extended); |
1283 | out_uleb128 (regno); |
1656 | out_uleb128 (regno); |
1284 | } |
1657 | } |
1285 | break; |
1658 | break; |
1286 | 1659 | ||
1287 | case DW_CFA_offset: |
1660 | case DW_CFA_offset: |
1288 | regno = insn->u.ri.reg; |
1661 | regno = insn->u.ri.reg; |
1289 | offset = insn->u.ri.offset / DWARF2_CIE_DATA_ALIGNMENT; |
1662 | offset = insn->u.ri.offset / DWARF2_CIE_DATA_ALIGNMENT; |
1290 | if (offset < 0) |
1663 | if (offset < 0) |
1291 | { |
1664 | { |
1292 | out_one (DW_CFA_offset_extended_sf); |
1665 | out_one (DW_CFA_offset_extended_sf); |
1293 | out_uleb128 (regno); |
1666 | out_uleb128 (regno); |
1294 | out_sleb128 (offset); |
1667 | out_sleb128 (offset); |
1295 | } |
1668 | } |
1296 | else if (regno <= 0x3F) |
1669 | else if (regno <= 0x3F) |
1297 | { |
1670 | { |
1298 | out_one (DW_CFA_offset + regno); |
1671 | out_one (DW_CFA_offset + regno); |
1299 | out_uleb128 (offset); |
1672 | out_uleb128 (offset); |
1300 | } |
1673 | } |
1301 | else |
1674 | else |
1302 | { |
1675 | { |
1303 | out_one (DW_CFA_offset_extended); |
1676 | out_one (DW_CFA_offset_extended); |
1304 | out_uleb128 (regno); |
1677 | out_uleb128 (regno); |
1305 | out_uleb128 (offset); |
1678 | out_uleb128 (offset); |
1306 | } |
1679 | } |
1307 | break; |
1680 | break; |
1308 | 1681 | ||
1309 | case DW_CFA_register: |
1682 | case DW_CFA_register: |
1310 | out_one (DW_CFA_register); |
1683 | out_one (DW_CFA_register); |
1311 | out_uleb128 (insn->u.rr.reg1); |
1684 | out_uleb128 (insn->u.rr.reg1); |
1312 | out_uleb128 (insn->u.rr.reg2); |
1685 | out_uleb128 (insn->u.rr.reg2); |
1313 | break; |
1686 | break; |
1314 | 1687 | ||
1315 | case DW_CFA_remember_state: |
1688 | case DW_CFA_remember_state: |
1316 | case DW_CFA_restore_state: |
1689 | case DW_CFA_restore_state: |
1317 | out_one (insn->insn); |
1690 | out_one (insn->insn); |
1318 | break; |
1691 | break; |
1319 | 1692 | ||
1320 | case DW_CFA_GNU_window_save: |
1693 | case DW_CFA_GNU_window_save: |
1321 | out_one (DW_CFA_GNU_window_save); |
1694 | out_one (DW_CFA_GNU_window_save); |
1322 | break; |
1695 | break; |
1323 | 1696 | ||
1324 | case CFI_escape: |
1697 | case CFI_escape: |
1325 | { |
1698 | { |
1326 | struct cfi_escape_data *e; |
1699 | struct cfi_escape_data *e; |
1327 | for (e = insn->u.esc; e ; e = e->next) |
1700 | for (e = insn->u.esc; e ; e = e->next) |
1328 | emit_expr (&e->exp, 1); |
1701 | emit_expr (&e->exp, 1); |
1329 | break; |
1702 | break; |
1330 | } |
1703 | } |
1331 | 1704 | ||
1332 | case CFI_val_encoded_addr: |
1705 | case CFI_val_encoded_addr: |
1333 | { |
1706 | { |
1334 | unsigned encoding = insn->u.ea.encoding; |
1707 | unsigned encoding = insn->u.ea.encoding; |
1335 | offsetT encoding_size; |
1708 | offsetT enc_size; |
1336 | 1709 | ||
1337 | if (encoding == DW_EH_PE_omit) |
1710 | if (encoding == DW_EH_PE_omit) |
1338 | break; |
1711 | break; |
1339 | out_one (DW_CFA_val_expression); |
1712 | out_one (DW_CFA_val_expression); |
1340 | out_uleb128 (insn->u.ea.reg); |
1713 | out_uleb128 (insn->u.ea.reg); |
1341 | 1714 | ||
1342 | switch (encoding & 0x7) |
1715 | switch (encoding & 0x7) |
1343 | { |
1716 | { |
1344 | case DW_EH_PE_absptr: |
1717 | case DW_EH_PE_absptr: |
1345 | encoding_size = DWARF2_ADDR_SIZE (stdoutput); |
1718 | enc_size = DWARF2_ADDR_SIZE (stdoutput); |
1346 | break; |
1719 | break; |
1347 | case DW_EH_PE_udata2: |
1720 | case DW_EH_PE_udata2: |
1348 | encoding_size = 2; |
1721 | enc_size = 2; |
1349 | break; |
1722 | break; |
1350 | case DW_EH_PE_udata4: |
1723 | case DW_EH_PE_udata4: |
1351 | encoding_size = 4; |
1724 | enc_size = 4; |
1352 | break; |
1725 | break; |
1353 | case DW_EH_PE_udata8: |
1726 | case DW_EH_PE_udata8: |
1354 | encoding_size = 8; |
1727 | enc_size = 8; |
1355 | break; |
1728 | break; |
1356 | default: |
1729 | default: |
1357 | abort (); |
1730 | abort (); |
1358 | } |
1731 | } |
1359 | 1732 | ||
1360 | /* If the user has requested absolute encoding, |
1733 | /* If the user has requested absolute encoding, |
1361 | then use the smaller DW_OP_addr encoding. */ |
1734 | then use the smaller DW_OP_addr encoding. */ |
1362 | if (insn->u.ea.encoding == DW_EH_PE_absptr) |
1735 | if (insn->u.ea.encoding == DW_EH_PE_absptr) |
1363 | { |
1736 | { |
1364 | out_uleb128 (1 + encoding_size); |
1737 | out_uleb128 (1 + enc_size); |
1365 | out_one (DW_OP_addr); |
1738 | out_one (DW_OP_addr); |
1366 | } |
1739 | } |
1367 | else |
1740 | else |
1368 | { |
1741 | { |
1369 | out_uleb128 (1 + 1 + encoding_size); |
1742 | out_uleb128 (1 + 1 + enc_size); |
1370 | out_one (DW_OP_GNU_encoded_addr); |
1743 | out_one (DW_OP_GNU_encoded_addr); |
1371 | out_one (encoding); |
1744 | out_one (encoding); |
1372 | 1745 | ||
1373 | if ((encoding & 0x70) == DW_EH_PE_pcrel) |
1746 | if ((encoding & 0x70) == DW_EH_PE_pcrel) |
1374 | { |
1747 | { |
1375 | #if CFI_DIFF_EXPR_OK |
1748 | #if CFI_DIFF_EXPR_OK |
1376 | insn->u.ea.exp.X_op = O_subtract; |
1749 | insn->u.ea.exp.X_op = O_subtract; |
1377 | insn->u.ea.exp.X_op_symbol = symbol_temp_new_now (); |
1750 | insn->u.ea.exp.X_op_symbol = symbol_temp_new_now (); |
1378 | #elif defined (tc_cfi_emit_pcrel_expr) |
1751 | #elif defined (tc_cfi_emit_pcrel_expr) |
1379 | tc_cfi_emit_pcrel_expr (&insn->u.ea.exp, encoding_size); |
1752 | tc_cfi_emit_pcrel_expr (&insn->u.ea.exp, enc_size); |
1380 | break; |
1753 | break; |
1381 | #else |
1754 | #else |
1382 | abort (); |
1755 | abort (); |
1383 | #endif |
1756 | #endif |
1384 | } |
1757 | } |
1385 | } |
1758 | } |
1386 | emit_expr (&insn->u.ea.exp, encoding_size); |
1759 | emit_expr (&insn->u.ea.exp, enc_size); |
1387 | } |
1760 | } |
1388 | break; |
1761 | break; |
1389 | 1762 | ||
1390 | default: |
1763 | case CFI_label: |
1391 | abort (); |
1764 | colon (insn->u.sym_name); |
1392 | } |
- | |
1393 | } |
- | |
1394 | - | ||
1395 | static offsetT |
- | |
1396 | encoding_size (unsigned char encoding) |
- | |
1397 | { |
- | |
1398 | if (encoding == DW_EH_PE_omit) |
- | |
1399 | return 0; |
- | |
1400 | switch (encoding & 0x7) |
- | |
1401 | { |
- | |
1402 | case 0: |
- | |
1403 | return bfd_get_arch_size (stdoutput) == 64 ? 8 : 4; |
- | |
1404 | case DW_EH_PE_udata2: |
- | |
1405 | return 2; |
- | |
1406 | case DW_EH_PE_udata4: |
- | |
1407 | return 4; |
- | |
1408 | case DW_EH_PE_udata8: |
1765 | break; |
1409 | return 8; |
1766 | |
1410 | default: |
1767 | default: |
1411 | abort (); |
1768 | abort (); |
1412 | } |
1769 | } |
1413 | } |
1770 | } |
1414 | 1771 | ||
1415 | static void |
1772 | static void |
1416 | output_cie (struct cie_entry *cie, bfd_boolean eh_frame, int align) |
1773 | output_cie (struct cie_entry *cie, bfd_boolean eh_frame, int align) |
1417 | { |
1774 | { |
1418 | symbolS *after_size_address, *end_address; |
1775 | symbolS *after_size_address, *end_address; |
1419 | expressionS exp; |
1776 | expressionS exp; |
1420 | struct cfi_insn_data *i; |
1777 | struct cfi_insn_data *i; |
1421 | offsetT augmentation_size; |
1778 | offsetT augmentation_size; |
1422 | int enc; |
1779 | int enc; |
1423 | enum dwarf2_format fmt = DWARF2_FORMAT (now_seg); |
1780 | enum dwarf2_format fmt = DWARF2_FORMAT (now_seg); |
1424 | 1781 | ||
1425 | cie->start_address = symbol_temp_new_now (); |
1782 | cie->start_address = symbol_temp_new_now (); |
1426 | after_size_address = symbol_temp_make (); |
1783 | after_size_address = symbol_temp_make (); |
1427 | end_address = symbol_temp_make (); |
1784 | end_address = symbol_temp_make (); |
1428 | 1785 | ||
1429 | exp.X_op = O_subtract; |
1786 | exp.X_op = O_subtract; |
1430 | exp.X_add_symbol = end_address; |
1787 | exp.X_add_symbol = end_address; |
1431 | exp.X_op_symbol = after_size_address; |
1788 | exp.X_op_symbol = after_size_address; |
1432 | exp.X_add_number = 0; |
1789 | exp.X_add_number = 0; |
1433 | 1790 | ||
1434 | if (eh_frame || fmt == dwarf2_format_32bit) |
1791 | if (eh_frame || fmt == dwarf2_format_32bit) |
1435 | emit_expr (&exp, 4); /* Length. */ |
1792 | emit_expr (&exp, 4); /* Length. */ |
1436 | else |
1793 | else |
1437 | { |
1794 | { |
1438 | if (fmt == dwarf2_format_64bit) |
1795 | if (fmt == dwarf2_format_64bit) |
1439 | out_four (-1); |
1796 | out_four (-1); |
1440 | emit_expr (&exp, 8); /* Length. */ |
1797 | emit_expr (&exp, 8); /* Length. */ |
1441 | } |
1798 | } |
1442 | symbol_set_value_now (after_size_address); |
1799 | symbol_set_value_now (after_size_address); |
1443 | if (eh_frame) |
1800 | if (eh_frame) |
1444 | out_four (0); /* CIE id. */ |
1801 | out_four (0); /* CIE id. */ |
1445 | else |
1802 | else |
1446 | { |
1803 | { |
1447 | out_four (-1); /* CIE id. */ |
1804 | out_four (-1); /* CIE id. */ |
1448 | if (fmt != dwarf2_format_32bit) |
1805 | if (fmt != dwarf2_format_32bit) |
1449 | out_four (-1); |
1806 | out_four (-1); |
1450 | } |
1807 | } |
1451 | out_one (DW_CIE_VERSION); /* Version. */ |
1808 | out_one (DW_CIE_VERSION); /* Version. */ |
1452 | if (eh_frame) |
1809 | if (eh_frame) |
1453 | { |
1810 | { |
1454 | out_one ('z'); /* Augmentation. */ |
1811 | out_one ('z'); /* Augmentation. */ |
1455 | if (cie->per_encoding != DW_EH_PE_omit) |
1812 | if (cie->per_encoding != DW_EH_PE_omit) |
1456 | out_one ('P'); |
1813 | out_one ('P'); |
1457 | if (cie->lsda_encoding != DW_EH_PE_omit) |
1814 | if (cie->lsda_encoding != DW_EH_PE_omit) |
1458 | out_one ('L'); |
1815 | out_one ('L'); |
1459 | out_one ('R'); |
1816 | out_one ('R'); |
1460 | } |
1817 | } |
1461 | if (cie->signal_frame) |
1818 | if (cie->signal_frame) |
1462 | out_one ('S'); |
1819 | out_one ('S'); |
1463 | out_one (0); |
1820 | out_one (0); |
1464 | out_uleb128 (DWARF2_LINE_MIN_INSN_LENGTH); /* Code alignment. */ |
1821 | out_uleb128 (DWARF2_LINE_MIN_INSN_LENGTH); /* Code alignment. */ |
1465 | out_sleb128 (DWARF2_CIE_DATA_ALIGNMENT); /* Data alignment. */ |
1822 | out_sleb128 (DWARF2_CIE_DATA_ALIGNMENT); /* Data alignment. */ |
1466 | if (DW_CIE_VERSION == 1) /* Return column. */ |
1823 | if (DW_CIE_VERSION == 1) /* Return column. */ |
1467 | out_one (cie->return_column); |
1824 | out_one (cie->return_column); |
1468 | else |
1825 | else |
1469 | out_uleb128 (cie->return_column); |
1826 | out_uleb128 (cie->return_column); |
1470 | if (eh_frame) |
1827 | if (eh_frame) |
1471 | { |
1828 | { |
1472 | augmentation_size = 1 + (cie->lsda_encoding != DW_EH_PE_omit); |
1829 | augmentation_size = 1 + (cie->lsda_encoding != DW_EH_PE_omit); |
1473 | if (cie->per_encoding != DW_EH_PE_omit) |
1830 | if (cie->per_encoding != DW_EH_PE_omit) |
1474 | augmentation_size += 1 + encoding_size (cie->per_encoding); |
1831 | augmentation_size += 1 + encoding_size (cie->per_encoding); |
1475 | out_uleb128 (augmentation_size); /* Augmentation size. */ |
1832 | out_uleb128 (augmentation_size); /* Augmentation size. */ |
1476 | - | ||
1477 | if (cie->per_encoding != DW_EH_PE_omit) |
- | |
1478 | { |
1833 | |
1479 | offsetT size = encoding_size (cie->per_encoding); |
- | |
1480 | out_one (cie->per_encoding); |
- | |
1481 | exp = cie->personality; |
- | |
1482 | if ((cie->per_encoding & 0x70) == DW_EH_PE_pcrel) |
- | |
1483 | { |
- | |
1484 | #if CFI_DIFF_EXPR_OK |
- | |
1485 | exp.X_op = O_subtract; |
- | |
1486 | exp.X_op_symbol = symbol_temp_new_now (); |
- | |
1487 | emit_expr (&exp, size); |
- | |
1488 | #elif defined (tc_cfi_emit_pcrel_expr) |
- | |
1489 | tc_cfi_emit_pcrel_expr (&exp, size); |
- | |
1490 | #else |
- | |
1491 | abort (); |
- | |
1492 | #endif |
- | |
1493 | } |
- | |
1494 | else |
- | |
1495 | emit_expr (&exp, size); |
- | |
1496 | } |
1834 | emit_expr_encoded (&cie->personality, cie->per_encoding, TRUE); |
1497 | 1835 | ||
1498 | if (cie->lsda_encoding != DW_EH_PE_omit) |
1836 | if (cie->lsda_encoding != DW_EH_PE_omit) |
1499 | out_one (cie->lsda_encoding); |
1837 | out_one (cie->lsda_encoding); |
1500 | } |
1838 | } |
1501 | 1839 | ||
1502 | switch (DWARF2_FDE_RELOC_SIZE) |
1840 | switch (DWARF2_FDE_RELOC_SIZE) |
1503 | { |
1841 | { |
1504 | case 2: |
1842 | case 2: |
1505 | enc = DW_EH_PE_sdata2; |
1843 | enc = DW_EH_PE_sdata2; |
1506 | break; |
1844 | break; |
1507 | case 4: |
1845 | case 4: |
1508 | enc = DW_EH_PE_sdata4; |
1846 | enc = DW_EH_PE_sdata4; |
1509 | break; |
1847 | break; |
1510 | case 8: |
1848 | case 8: |
1511 | enc = DW_EH_PE_sdata8; |
1849 | enc = DW_EH_PE_sdata8; |
1512 | break; |
1850 | break; |
1513 | default: |
1851 | default: |
1514 | abort (); |
1852 | abort (); |
1515 | } |
1853 | } |
1516 | #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr |
1854 | #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr |
1517 | enc |= DW_EH_PE_pcrel; |
1855 | enc |= DW_EH_PE_pcrel; |
1518 | #endif |
1856 | #endif |
- | 1857 | #ifdef DWARF2_FDE_RELOC_ENCODING |
|
- | 1858 | /* Allow target to override encoding. */ |
|
- | 1859 | enc = DWARF2_FDE_RELOC_ENCODING (enc); |
|
- | 1860 | #endif |
|
- | 1861 | cie->fde_encoding = enc; |
|
1519 | if (eh_frame) |
1862 | if (eh_frame) |
1520 | out_one (enc); |
1863 | out_one (enc); |
1521 | 1864 | ||
1522 | if (cie->first) |
1865 | if (cie->first) |
1523 | { |
1866 | { |
1524 | for (i = cie->first; i != cie->last; i = i->next) |
1867 | for (i = cie->first; i != cie->last; i = i->next) |
1525 | { |
1868 | { |
1526 | if (CUR_SEG (i) != CUR_SEG (cie)) |
1869 | if (CUR_SEG (i) != CUR_SEG (cie)) |
1527 | continue; |
1870 | continue; |
1528 | output_cfi_insn (i); |
1871 | output_cfi_insn (i); |
1529 | } |
1872 | } |
1530 | } |
1873 | } |
1531 | 1874 | ||
1532 | frag_align (align, DW_CFA_nop, 0); |
1875 | frag_align (align, DW_CFA_nop, 0); |
1533 | symbol_set_value_now (end_address); |
1876 | symbol_set_value_now (end_address); |
1534 | } |
1877 | } |
1535 | 1878 | ||
1536 | static void |
1879 | static void |
1537 | output_fde (struct fde_entry *fde, struct cie_entry *cie, |
1880 | output_fde (struct fde_entry *fde, struct cie_entry *cie, |
1538 | bfd_boolean eh_frame, struct cfi_insn_data *first, |
1881 | bfd_boolean eh_frame, struct cfi_insn_data *first, |
1539 | int align) |
1882 | int align) |
1540 | { |
1883 | { |
1541 | symbolS *after_size_address, *end_address; |
1884 | symbolS *after_size_address, *end_address; |
1542 | expressionS exp; |
1885 | expressionS exp; |
1543 | offsetT augmentation_size; |
1886 | offsetT augmentation_size; |
1544 | enum dwarf2_format fmt = DWARF2_FORMAT (now_seg); |
1887 | enum dwarf2_format fmt = DWARF2_FORMAT (now_seg); |
1545 | int offset_size; |
1888 | int offset_size; |
1546 | int addr_size; |
1889 | int addr_size; |
1547 | 1890 | ||
1548 | after_size_address = symbol_temp_make (); |
1891 | after_size_address = symbol_temp_make (); |
1549 | end_address = symbol_temp_make (); |
1892 | end_address = symbol_temp_make (); |
1550 | 1893 | ||
1551 | exp.X_op = O_subtract; |
1894 | exp.X_op = O_subtract; |
1552 | exp.X_add_symbol = end_address; |
1895 | exp.X_add_symbol = end_address; |
1553 | exp.X_op_symbol = after_size_address; |
1896 | exp.X_op_symbol = after_size_address; |
1554 | exp.X_add_number = 0; |
1897 | exp.X_add_number = 0; |
1555 | if (eh_frame || fmt == dwarf2_format_32bit) |
1898 | if (eh_frame || fmt == dwarf2_format_32bit) |
1556 | offset_size = 4; |
1899 | offset_size = 4; |
1557 | else |
1900 | else |
1558 | { |
1901 | { |
1559 | if (fmt == dwarf2_format_64bit) |
1902 | if (fmt == dwarf2_format_64bit) |
1560 | out_four (-1); |
1903 | out_four (-1); |
1561 | offset_size = 8; |
1904 | offset_size = 8; |
1562 | } |
1905 | } |
1563 | emit_expr (&exp, offset_size); /* Length. */ |
1906 | emit_expr (&exp, offset_size); /* Length. */ |
1564 | symbol_set_value_now (after_size_address); |
1907 | symbol_set_value_now (after_size_address); |
1565 | 1908 | ||
1566 | if (eh_frame) |
1909 | if (eh_frame) |
1567 | { |
1910 | { |
1568 | exp.X_op = O_subtract; |
1911 | exp.X_op = O_subtract; |
1569 | exp.X_add_symbol = after_size_address; |
1912 | exp.X_add_symbol = after_size_address; |
1570 | exp.X_op_symbol = cie->start_address; |
1913 | exp.X_op_symbol = cie->start_address; |
1571 | exp.X_add_number = 0; |
1914 | exp.X_add_number = 0; |
1572 | emit_expr (&exp, offset_size); /* CIE offset. */ |
1915 | emit_expr (&exp, offset_size); /* CIE offset. */ |
1573 | } |
1916 | } |
1574 | else |
1917 | else |
1575 | { |
1918 | { |
1576 | TC_DWARF2_EMIT_OFFSET (cie->start_address, offset_size); |
1919 | TC_DWARF2_EMIT_OFFSET (cie->start_address, offset_size); |
1577 | } |
1920 | } |
- | 1921 | ||
1578 | 1922 | exp.X_op = O_symbol; |
|
1579 | if (eh_frame) |
1923 | if (eh_frame) |
- | 1924 | { |
|
- | 1925 | bfd_reloc_code_real_type code |
|
- | 1926 | = tc_cfi_reloc_for_encoding (cie->fde_encoding); |
|
- | 1927 | if (code != BFD_RELOC_NONE) |
|
- | 1928 | { |
|
- | 1929 | reloc_howto_type *howto = bfd_reloc_type_lookup (stdoutput, code); |
|
- | 1930 | char *p = frag_more (4); |
|
- | 1931 | md_number_to_chars (p, 0, 4); |
|
- | 1932 | fix_new (frag_now, p - frag_now->fr_literal, 4, fde->start_address, |
|
- | 1933 | 0, howto->pc_relative, code); |
|
- | 1934 | } |
|
- | 1935 | else |
|
1580 | { |
1936 | { |
1581 | exp.X_op = O_subtract; |
1937 | exp.X_op = O_subtract; |
1582 | exp.X_add_number = 0; |
1938 | exp.X_add_number = 0; |
1583 | #if CFI_DIFF_EXPR_OK |
1939 | #if CFI_DIFF_EXPR_OK |
1584 | exp.X_add_symbol = fde->start_address; |
1940 | exp.X_add_symbol = fde->start_address; |
1585 | exp.X_op_symbol = symbol_temp_new_now (); |
1941 | exp.X_op_symbol = symbol_temp_new_now (); |
1586 | emit_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ |
1942 | emit_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ |
1587 | #else |
1943 | #else |
1588 | exp.X_op = O_symbol; |
1944 | exp.X_op = O_symbol; |
1589 | exp.X_add_symbol = fde->start_address; |
1945 | exp.X_add_symbol = fde->start_address; |
- | 1946 | ||
1590 | #ifdef tc_cfi_emit_pcrel_expr |
1947 | #if defined(tc_cfi_emit_pcrel_expr) |
1591 | tc_cfi_emit_pcrel_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ |
1948 | tc_cfi_emit_pcrel_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ |
1592 | #else |
1949 | #else |
1593 | emit_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ |
1950 | emit_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ |
1594 | #endif |
1951 | #endif |
1595 | #endif |
1952 | #endif |
- | 1953 | } |
|
1596 | addr_size = DWARF2_FDE_RELOC_SIZE; |
1954 | addr_size = DWARF2_FDE_RELOC_SIZE; |
1597 | } |
1955 | } |
1598 | else |
1956 | else |
1599 | { |
1957 | { |
1600 | exp.X_op = O_symbol; |
- | |
1601 | exp.X_add_symbol = fde->start_address; |
- | |
1602 | exp.X_add_number = 0; |
1958 | exp.X_add_number = 0; |
- | 1959 | exp.X_add_symbol = fde->start_address; |
|
1603 | addr_size = DWARF2_ADDR_SIZE (stdoutput); |
1960 | addr_size = DWARF2_ADDR_SIZE (stdoutput); |
1604 | emit_expr (&exp, addr_size); |
1961 | emit_expr (&exp, addr_size); |
1605 | } |
1962 | } |
1606 | 1963 | ||
1607 | exp.X_op = O_subtract; |
1964 | exp.X_op = O_subtract; |
1608 | exp.X_add_symbol = fde->end_address; |
1965 | exp.X_add_symbol = fde->end_address; |
1609 | exp.X_op_symbol = fde->start_address; /* Code length. */ |
1966 | exp.X_op_symbol = fde->start_address; /* Code length. */ |
1610 | exp.X_add_number = 0; |
1967 | exp.X_add_number = 0; |
1611 | emit_expr (&exp, addr_size); |
1968 | emit_expr (&exp, addr_size); |
1612 | 1969 | ||
1613 | augmentation_size = encoding_size (fde->lsda_encoding); |
1970 | augmentation_size = encoding_size (fde->lsda_encoding); |
1614 | if (eh_frame) |
1971 | if (eh_frame) |
1615 | out_uleb128 (augmentation_size); /* Augmentation size. */ |
1972 | out_uleb128 (augmentation_size); /* Augmentation size. */ |
1616 | - | ||
1617 | if (fde->lsda_encoding != DW_EH_PE_omit) |
- | |
1618 | { |
- | |
1619 | exp = fde->lsda; |
- | |
1620 | if ((fde->lsda_encoding & 0x70) == DW_EH_PE_pcrel) |
- | |
1621 | { |
- | |
1622 | #if CFI_DIFF_LSDA_OK |
- | |
1623 | exp.X_op = O_subtract; |
- | |
1624 | exp.X_op_symbol = symbol_temp_new_now (); |
1973 | |
1625 | emit_expr (&exp, augmentation_size); |
- | |
1626 | #elif defined (tc_cfi_emit_pcrel_expr) |
- | |
1627 | tc_cfi_emit_pcrel_expr (&exp, augmentation_size); |
- | |
1628 | #else |
- | |
1629 | abort (); |
- | |
1630 | #endif |
- | |
1631 | } |
- | |
1632 | else |
- | |
1633 | emit_expr (&exp, augmentation_size); |
- | |
1634 | } |
1974 | emit_expr_encoded (&fde->lsda, cie->lsda_encoding, FALSE); |
1635 | 1975 | ||
1636 | for (; first; first = first->next) |
1976 | for (; first; first = first->next) |
1637 | if (CUR_SEG (first) == CUR_SEG (fde)) |
1977 | if (CUR_SEG (first) == CUR_SEG (fde)) |
1638 | output_cfi_insn (first); |
1978 | output_cfi_insn (first); |
1639 | 1979 | ||
1640 | frag_align (align, DW_CFA_nop, 0); |
1980 | frag_align (align, DW_CFA_nop, 0); |
1641 | symbol_set_value_now (end_address); |
1981 | symbol_set_value_now (end_address); |
1642 | } |
1982 | } |
1643 | 1983 | ||
1644 | static struct cie_entry * |
1984 | static struct cie_entry * |
1645 | select_cie_for_fde (struct fde_entry *fde, bfd_boolean eh_frame, |
1985 | select_cie_for_fde (struct fde_entry *fde, bfd_boolean eh_frame, |
1646 | struct cfi_insn_data **pfirst, int align) |
1986 | struct cfi_insn_data **pfirst, int align) |
1647 | { |
1987 | { |
1648 | struct cfi_insn_data *i, *j; |
1988 | struct cfi_insn_data *i, *j; |
1649 | struct cie_entry *cie; |
1989 | struct cie_entry *cie; |
1650 | 1990 | ||
1651 | for (cie = cie_root; cie; cie = cie->next) |
1991 | for (cie = cie_root; cie; cie = cie->next) |
1652 | { |
1992 | { |
1653 | if (CUR_SEG (cie) != CUR_SEG (fde)) |
1993 | if (CUR_SEG (cie) != CUR_SEG (fde)) |
1654 | continue; |
1994 | continue; |
1655 | if (cie->return_column != fde->return_column |
1995 | if (cie->return_column != fde->return_column |
1656 | || cie->signal_frame != fde->signal_frame |
1996 | || cie->signal_frame != fde->signal_frame |
1657 | || cie->per_encoding != fde->per_encoding |
1997 | || cie->per_encoding != fde->per_encoding |
1658 | || cie->lsda_encoding != fde->lsda_encoding) |
1998 | || cie->lsda_encoding != fde->lsda_encoding) |
1659 | continue; |
1999 | continue; |
1660 | if (cie->per_encoding != DW_EH_PE_omit) |
2000 | if (cie->per_encoding != DW_EH_PE_omit) |
1661 | { |
2001 | { |
1662 | if (cie->personality.X_op != fde->personality.X_op |
2002 | if (cie->personality.X_op != fde->personality.X_op |
1663 | || cie->personality.X_add_number |
2003 | || cie->personality.X_add_number |
1664 | != fde->personality.X_add_number) |
2004 | != fde->personality.X_add_number) |
1665 | continue; |
2005 | continue; |
1666 | switch (cie->personality.X_op) |
2006 | switch (cie->personality.X_op) |
1667 | { |
2007 | { |
1668 | case O_constant: |
2008 | case O_constant: |
1669 | if (cie->personality.X_unsigned != fde->personality.X_unsigned) |
2009 | if (cie->personality.X_unsigned != fde->personality.X_unsigned) |
1670 | continue; |
2010 | continue; |
1671 | break; |
2011 | break; |
1672 | case O_symbol: |
2012 | case O_symbol: |
1673 | if (cie->personality.X_add_symbol |
2013 | if (cie->personality.X_add_symbol |
1674 | != fde->personality.X_add_symbol) |
2014 | != fde->personality.X_add_symbol) |
1675 | continue; |
2015 | continue; |
1676 | break; |
2016 | break; |
1677 | default: |
2017 | default: |
1678 | abort (); |
2018 | abort (); |
1679 | } |
2019 | } |
1680 | } |
2020 | } |
1681 | for (i = cie->first, j = fde->data; |
2021 | for (i = cie->first, j = fde->data; |
1682 | i != cie->last && j != NULL; |
2022 | i != cie->last && j != NULL; |
1683 | i = i->next, j = j->next) |
2023 | i = i->next, j = j->next) |
1684 | { |
2024 | { |
1685 | if (i->insn != j->insn) |
2025 | if (i->insn != j->insn) |
1686 | goto fail; |
2026 | goto fail; |
1687 | switch (i->insn) |
2027 | switch (i->insn) |
1688 | { |
2028 | { |
1689 | case DW_CFA_advance_loc: |
2029 | case DW_CFA_advance_loc: |
1690 | case DW_CFA_remember_state: |
2030 | case DW_CFA_remember_state: |
1691 | /* We reached the first advance/remember in the FDE, |
2031 | /* We reached the first advance/remember in the FDE, |
1692 | but did not reach the end of the CIE list. */ |
2032 | but did not reach the end of the CIE list. */ |
1693 | goto fail; |
2033 | goto fail; |
1694 | 2034 | ||
1695 | case DW_CFA_offset: |
2035 | case DW_CFA_offset: |
1696 | case DW_CFA_def_cfa: |
2036 | case DW_CFA_def_cfa: |
1697 | if (i->u.ri.reg != j->u.ri.reg) |
2037 | if (i->u.ri.reg != j->u.ri.reg) |
1698 | goto fail; |
2038 | goto fail; |
1699 | if (i->u.ri.offset != j->u.ri.offset) |
2039 | if (i->u.ri.offset != j->u.ri.offset) |
1700 | goto fail; |
2040 | goto fail; |
1701 | break; |
2041 | break; |
1702 | 2042 | ||
1703 | case DW_CFA_register: |
2043 | case DW_CFA_register: |
1704 | if (i->u.rr.reg1 != j->u.rr.reg1) |
2044 | if (i->u.rr.reg1 != j->u.rr.reg1) |
1705 | goto fail; |
2045 | goto fail; |
1706 | if (i->u.rr.reg2 != j->u.rr.reg2) |
2046 | if (i->u.rr.reg2 != j->u.rr.reg2) |
1707 | goto fail; |
2047 | goto fail; |
1708 | break; |
2048 | break; |
1709 | 2049 | ||
1710 | case DW_CFA_def_cfa_register: |
2050 | case DW_CFA_def_cfa_register: |
1711 | case DW_CFA_restore: |
2051 | case DW_CFA_restore: |
1712 | case DW_CFA_undefined: |
2052 | case DW_CFA_undefined: |
1713 | case DW_CFA_same_value: |
2053 | case DW_CFA_same_value: |
1714 | if (i->u.r != j->u.r) |
2054 | if (i->u.r != j->u.r) |
1715 | goto fail; |
2055 | goto fail; |
1716 | break; |
2056 | break; |
1717 | 2057 | ||
1718 | case DW_CFA_def_cfa_offset: |
2058 | case DW_CFA_def_cfa_offset: |
1719 | if (i->u.i != j->u.i) |
2059 | if (i->u.i != j->u.i) |
1720 | goto fail; |
2060 | goto fail; |
1721 | break; |
2061 | break; |
1722 | 2062 | ||
1723 | case CFI_escape: |
2063 | case CFI_escape: |
1724 | case CFI_val_encoded_addr: |
2064 | case CFI_val_encoded_addr: |
- | 2065 | case CFI_label: |
|
1725 | /* Don't bother matching these for now. */ |
2066 | /* Don't bother matching these for now. */ |
1726 | goto fail; |
2067 | goto fail; |
1727 | 2068 | ||
1728 | default: |
2069 | default: |
1729 | abort (); |
2070 | abort (); |
1730 | } |
2071 | } |
1731 | } |
2072 | } |
1732 | 2073 | ||
1733 | /* Success if we reached the end of the CIE list, and we've either |
2074 | /* Success if we reached the end of the CIE list, and we've either |
1734 | run out of FDE entries or we've encountered an advance, |
2075 | run out of FDE entries or we've encountered an advance, |
1735 | remember, or escape. */ |
2076 | remember, or escape. */ |
1736 | if (i == cie->last |
2077 | if (i == cie->last |
1737 | && (!j |
2078 | && (!j |
1738 | || j->insn == DW_CFA_advance_loc |
2079 | || j->insn == DW_CFA_advance_loc |
1739 | || j->insn == DW_CFA_remember_state |
2080 | || j->insn == DW_CFA_remember_state |
1740 | || j->insn == CFI_escape |
2081 | || j->insn == CFI_escape |
1741 | || j->insn == CFI_val_encoded_addr)) |
2082 | || j->insn == CFI_val_encoded_addr |
- | 2083 | || j->insn == CFI_label)) |
|
1742 | { |
2084 | { |
1743 | *pfirst = j; |
2085 | *pfirst = j; |
1744 | return cie; |
2086 | return cie; |
1745 | } |
2087 | } |
1746 | 2088 | ||
1747 | fail:; |
2089 | fail:; |
1748 | } |
2090 | } |
1749 | 2091 | ||
1750 | cie = (struct cie_entry *) xmalloc (sizeof (struct cie_entry)); |
2092 | cie = (struct cie_entry *) xmalloc (sizeof (struct cie_entry)); |
1751 | cie->next = cie_root; |
2093 | cie->next = cie_root; |
1752 | cie_root = cie; |
2094 | cie_root = cie; |
1753 | SET_CUR_SEG (cie, CUR_SEG (fde)); |
2095 | SET_CUR_SEG (cie, CUR_SEG (fde)); |
1754 | cie->return_column = fde->return_column; |
2096 | cie->return_column = fde->return_column; |
1755 | cie->signal_frame = fde->signal_frame; |
2097 | cie->signal_frame = fde->signal_frame; |
1756 | cie->per_encoding = fde->per_encoding; |
2098 | cie->per_encoding = fde->per_encoding; |
1757 | cie->lsda_encoding = fde->lsda_encoding; |
2099 | cie->lsda_encoding = fde->lsda_encoding; |
1758 | cie->personality = fde->personality; |
2100 | cie->personality = fde->personality; |
1759 | cie->first = fde->data; |
2101 | cie->first = fde->data; |
1760 | 2102 | ||
1761 | for (i = cie->first; i ; i = i->next) |
2103 | for (i = cie->first; i ; i = i->next) |
1762 | if (i->insn == DW_CFA_advance_loc |
2104 | if (i->insn == DW_CFA_advance_loc |
1763 | || i->insn == DW_CFA_remember_state |
2105 | || i->insn == DW_CFA_remember_state |
1764 | || i->insn == CFI_escape |
2106 | || i->insn == CFI_escape |
1765 | || i->insn == CFI_val_encoded_addr) |
2107 | || i->insn == CFI_val_encoded_addr |
- | 2108 | || i->insn == CFI_label) |
|
1766 | break; |
2109 | break; |
1767 | 2110 | ||
1768 | cie->last = i; |
2111 | cie->last = i; |
1769 | *pfirst = i; |
2112 | *pfirst = i; |
1770 | 2113 | ||
1771 | output_cie (cie, eh_frame, align); |
2114 | output_cie (cie, eh_frame, align); |
1772 | 2115 | ||
1773 | return cie; |
2116 | return cie; |
1774 | } |
2117 | } |
1775 | 2118 | ||
1776 | #ifdef md_reg_eh_frame_to_debug_frame |
2119 | #ifdef md_reg_eh_frame_to_debug_frame |
1777 | static void |
2120 | static void |
1778 | cfi_change_reg_numbers (struct cfi_insn_data *insn, segT ccseg) |
2121 | cfi_change_reg_numbers (struct cfi_insn_data *insn, segT ccseg) |
1779 | { |
2122 | { |
1780 | for (; insn; insn = insn->next) |
2123 | for (; insn; insn = insn->next) |
1781 | { |
2124 | { |
1782 | if (CUR_SEG (insn) != ccseg) |
2125 | if (CUR_SEG (insn) != ccseg) |
1783 | continue; |
2126 | continue; |
1784 | switch (insn->insn) |
2127 | switch (insn->insn) |
1785 | { |
2128 | { |
1786 | case DW_CFA_advance_loc: |
2129 | case DW_CFA_advance_loc: |
1787 | case DW_CFA_def_cfa_offset: |
2130 | case DW_CFA_def_cfa_offset: |
1788 | case DW_CFA_remember_state: |
2131 | case DW_CFA_remember_state: |
1789 | case DW_CFA_restore_state: |
2132 | case DW_CFA_restore_state: |
1790 | case DW_CFA_GNU_window_save: |
2133 | case DW_CFA_GNU_window_save: |
1791 | case CFI_escape: |
2134 | case CFI_escape: |
- | 2135 | case CFI_label: |
|
1792 | break; |
2136 | break; |
1793 | 2137 | ||
1794 | case DW_CFA_def_cfa: |
2138 | case DW_CFA_def_cfa: |
1795 | case DW_CFA_offset: |
2139 | case DW_CFA_offset: |
1796 | insn->u.ri.reg = md_reg_eh_frame_to_debug_frame (insn->u.ri.reg); |
2140 | insn->u.ri.reg = md_reg_eh_frame_to_debug_frame (insn->u.ri.reg); |
1797 | break; |
2141 | break; |
1798 | 2142 | ||
1799 | case DW_CFA_def_cfa_register: |
2143 | case DW_CFA_def_cfa_register: |
1800 | case DW_CFA_undefined: |
2144 | case DW_CFA_undefined: |
1801 | case DW_CFA_same_value: |
2145 | case DW_CFA_same_value: |
1802 | case DW_CFA_restore: |
2146 | case DW_CFA_restore: |
1803 | insn->u.r = md_reg_eh_frame_to_debug_frame (insn->u.r); |
2147 | insn->u.r = md_reg_eh_frame_to_debug_frame (insn->u.r); |
1804 | break; |
2148 | break; |
1805 | 2149 | ||
1806 | case DW_CFA_register: |
2150 | case DW_CFA_register: |
1807 | insn->u.rr.reg1 = md_reg_eh_frame_to_debug_frame (insn->u.rr.reg1); |
2151 | insn->u.rr.reg1 = md_reg_eh_frame_to_debug_frame (insn->u.rr.reg1); |
1808 | insn->u.rr.reg2 = md_reg_eh_frame_to_debug_frame (insn->u.rr.reg2); |
2152 | insn->u.rr.reg2 = md_reg_eh_frame_to_debug_frame (insn->u.rr.reg2); |
1809 | break; |
2153 | break; |
1810 | 2154 | ||
1811 | case CFI_val_encoded_addr: |
2155 | case CFI_val_encoded_addr: |
1812 | insn->u.ea.reg = md_reg_eh_frame_to_debug_frame (insn->u.ea.reg); |
2156 | insn->u.ea.reg = md_reg_eh_frame_to_debug_frame (insn->u.ea.reg); |
1813 | break; |
2157 | break; |
1814 | 2158 | ||
1815 | default: |
2159 | default: |
1816 | abort (); |
2160 | abort (); |
1817 | } |
2161 | } |
1818 | } |
2162 | } |
1819 | } |
2163 | } |
1820 | #else |
2164 | #else |
1821 | #define cfi_change_reg_numbers(insn, cseg) do { } while (0) |
2165 | #define cfi_change_reg_numbers(insn, cseg) do { } while (0) |
1822 | #endif |
2166 | #endif |
- | 2167 | ||
1823 | 2168 | #if SUPPORT_COMPACT_EH |
|
1824 | static segT |
2169 | static void |
1825 | get_cfi_seg (segT cseg, const char *base, flagword flags, int align) |
2170 | cfi_emit_eh_header (symbolS *sym, bfd_vma addend) |
- | 2171 | { |
|
- | 2172 | expressionS exp; |
|
1826 | { |
2173 | |
- | 2174 | exp.X_add_number = addend; |
|
- | 2175 | exp.X_add_symbol = sym; |
|
- | 2176 | emit_expr_encoded (&exp, DW_EH_PE_sdata4 | DW_EH_PE_pcrel, FALSE); |
|
- | 2177 | } |
|
- | 2178 | ||
- | 2179 | static void |
|
1827 | if (SUPPORT_FRAME_LINKONCE) |
2180 | output_eh_header (struct fde_entry *fde) |
- | 2181 | { |
|
1828 | { |
2182 | char *p; |
1829 | struct dwcfi_seg_list *l; |
2183 | bfd_vma addend; |
- | 2184 | ||
- | 2185 | if (fde->eh_header_type == EH_COMPACT_INLINE) |
|
- | 2186 | addend = 0; |
|
- | 2187 | else |
|
- | 2188 | addend = 1; |
|
- | 2189 | ||
- | 2190 | cfi_emit_eh_header (fde->start_address, addend); |
|
- | 2191 | ||
- | 2192 | if (fde->eh_header_type == EH_COMPACT_INLINE) |
|
1830 | 2193 | { |
|
1831 | l = dwcfi_hash_find_or_make (cseg, base, flags); |
2194 | p = frag_more (4); |
1832 | 2195 | /* Inline entries always use PR1. */ |
|
1833 | cseg = l->seg; |
2196 | *(p++) = 1; |
1834 | subseg_set (cseg, l->subseg); |
2197 | memcpy(p, fde->eh_data, 3); |
1835 | } |
2198 | } |
1836 | else |
2199 | else |
1837 | { |
2200 | { |
- | 2201 | if (fde->eh_header_type == EH_COMPACT_LEGACY) |
|
- | 2202 | addend = 1; |
|
1838 | cseg = subseg_new (base, 0); |
2203 | else if (fde->eh_header_type == EH_COMPACT_OUTLINE |
- | 2204 | || fde->eh_header_type == EH_COMPACT_OUTLINE_DONE) |
|
- | 2205 | addend = 0; |
|
- | 2206 | else |
|
- | 2207 | abort (); |
|
1839 | bfd_set_section_flags (stdoutput, cseg, flags); |
2208 | cfi_emit_eh_header (fde->eh_loc, addend); |
1840 | } |
2209 | } |
1841 | record_alignment (cseg, align); |
- | |
1842 | return cseg; |
- | |
1843 | } |
2210 | } |
- | 2211 | #endif |
|
1844 | 2212 | ||
1845 | void |
2213 | void |
1846 | cfi_finish (void) |
2214 | cfi_finish (void) |
1847 | { |
2215 | { |
1848 | struct cie_entry *cie, *cie_next; |
2216 | struct cie_entry *cie, *cie_next; |
1849 | segT cfi_seg, ccseg; |
2217 | segT cfi_seg, ccseg; |
1850 | struct fde_entry *fde; |
2218 | struct fde_entry *fde; |
1851 | struct cfi_insn_data *first; |
2219 | struct cfi_insn_data *first; |
1852 | int save_flag_traditional_format, seek_next_seg; |
2220 | int save_flag_traditional_format, seek_next_seg; |
1853 | 2221 | ||
1854 | if (all_fde_data == 0) |
2222 | if (all_fde_data == 0) |
1855 | return; |
2223 | return; |
1856 | 2224 | ||
- | 2225 | if ((all_cfi_sections & CFI_EMIT_eh_frame) != 0 |
|
1857 | if ((cfi_sections & CFI_EMIT_eh_frame) != 0) |
2226 | || (all_cfi_sections & CFI_EMIT_eh_frame_compact) != 0) |
1858 | { |
2227 | { |
1859 | /* Make sure check_eh_frame doesn't do anything with our output. */ |
2228 | /* Make sure check_eh_frame doesn't do anything with our output. */ |
1860 | save_flag_traditional_format = flag_traditional_format; |
2229 | save_flag_traditional_format = flag_traditional_format; |
1861 | flag_traditional_format = 1; |
2230 | flag_traditional_format = 1; |
1862 | 2231 | ||
1863 | if (!SUPPORT_FRAME_LINKONCE) |
2232 | if (!EH_FRAME_LINKONCE) |
1864 | { |
2233 | { |
1865 | /* Open .eh_frame section. */ |
2234 | /* Open .eh_frame section. */ |
1866 | cfi_seg = get_cfi_seg (NULL, ".eh_frame", |
2235 | cfi_seg = get_cfi_seg (NULL, ".eh_frame", |
1867 | (SEC_ALLOC | SEC_LOAD | SEC_DATA |
2236 | (SEC_ALLOC | SEC_LOAD | SEC_DATA |
1868 | | DWARF2_EH_FRAME_READ_ONLY), |
2237 | | DWARF2_EH_FRAME_READ_ONLY), |
1869 | EH_FRAME_ALIGNMENT); |
2238 | EH_FRAME_ALIGNMENT); |
1870 | #ifdef md_fix_up_eh_frame |
2239 | #ifdef md_fix_up_eh_frame |
1871 | md_fix_up_eh_frame (cfi_seg); |
2240 | md_fix_up_eh_frame (cfi_seg); |
1872 | #else |
2241 | #else |
1873 | (void) cfi_seg; |
2242 | (void) cfi_seg; |
1874 | #endif |
2243 | #endif |
1875 | } |
2244 | } |
1876 | 2245 | ||
1877 | do |
2246 | do |
1878 | { |
2247 | { |
1879 | ccseg = NULL; |
2248 | ccseg = NULL; |
1880 | seek_next_seg = 0; |
2249 | seek_next_seg = 0; |
1881 | 2250 | ||
1882 | for (cie = cie_root; cie; cie = cie_next) |
2251 | for (cie = cie_root; cie; cie = cie_next) |
1883 | { |
2252 | { |
1884 | cie_next = cie->next; |
2253 | cie_next = cie->next; |
1885 | free ((void *) cie); |
2254 | free ((void *) cie); |
1886 | } |
2255 | } |
1887 | cie_root = NULL; |
2256 | cie_root = NULL; |
1888 | 2257 | ||
1889 | for (fde = all_fde_data; fde ; fde = fde->next) |
2258 | for (fde = all_fde_data; fde ; fde = fde->next) |
1890 | { |
2259 | { |
- | 2260 | if ((fde->sections & CFI_EMIT_eh_frame) == 0 |
|
- | 2261 | && (fde->sections & CFI_EMIT_eh_frame_compact) == 0) |
|
- | 2262 | continue; |
|
- | 2263 | ||
- | 2264 | #if SUPPORT_COMPACT_EH |
|
- | 2265 | /* Emit a LEGACY format header if we have processed all |
|
- | 2266 | of the .cfi directives without encountering either inline or |
|
- | 2267 | out-of-line compact unwinding opcodes. */ |
|
- | 2268 | if (fde->eh_header_type == EH_COMPACT_HAS_LSDA |
|
- | 2269 | || fde->eh_header_type == EH_COMPACT_UNKNOWN) |
|
- | 2270 | fde->eh_header_type = EH_COMPACT_LEGACY; |
|
- | 2271 | ||
- | 2272 | if (fde->eh_header_type != EH_COMPACT_LEGACY) |
|
- | 2273 | continue; |
|
- | 2274 | #endif |
|
1891 | if (SUPPORT_FRAME_LINKONCE) |
2275 | if (EH_FRAME_LINKONCE) |
1892 | { |
2276 | { |
1893 | if (HANDLED (fde)) |
2277 | if (HANDLED (fde)) |
1894 | continue; |
2278 | continue; |
1895 | if (seek_next_seg && CUR_SEG (fde) != ccseg) |
2279 | if (seek_next_seg && CUR_SEG (fde) != ccseg) |
1896 | { |
2280 | { |
1897 | seek_next_seg = 2; |
2281 | seek_next_seg = 2; |
1898 | continue; |
2282 | continue; |
1899 | } |
2283 | } |
1900 | if (!seek_next_seg) |
2284 | if (!seek_next_seg) |
1901 | { |
2285 | { |
1902 | ccseg = CUR_SEG (fde); |
2286 | ccseg = CUR_SEG (fde); |
1903 | /* Open .eh_frame section. */ |
2287 | /* Open .eh_frame section. */ |
1904 | cfi_seg = get_cfi_seg (ccseg, ".eh_frame", |
2288 | cfi_seg = get_cfi_seg (ccseg, ".eh_frame", |
1905 | (SEC_ALLOC | SEC_LOAD | SEC_DATA |
2289 | (SEC_ALLOC | SEC_LOAD | SEC_DATA |
1906 | | DWARF2_EH_FRAME_READ_ONLY), |
2290 | | DWARF2_EH_FRAME_READ_ONLY), |
1907 | EH_FRAME_ALIGNMENT); |
2291 | EH_FRAME_ALIGNMENT); |
1908 | #ifdef md_fix_up_eh_frame |
2292 | #ifdef md_fix_up_eh_frame |
1909 | md_fix_up_eh_frame (cfi_seg); |
2293 | md_fix_up_eh_frame (cfi_seg); |
1910 | #else |
2294 | #else |
1911 | (void) cfi_seg; |
2295 | (void) cfi_seg; |
1912 | #endif |
2296 | #endif |
1913 | seek_next_seg = 1; |
2297 | seek_next_seg = 1; |
1914 | } |
2298 | } |
1915 | SET_HANDLED (fde, 1); |
2299 | SET_HANDLED (fde, 1); |
1916 | } |
2300 | } |
1917 | 2301 | ||
1918 | if (fde->end_address == NULL) |
2302 | if (fde->end_address == NULL) |
1919 | { |
2303 | { |
1920 | as_bad (_("open CFI at the end of file; missing .cfi_endproc directive")); |
2304 | as_bad (_("open CFI at the end of file; missing .cfi_endproc directive")); |
1921 | fde->end_address = fde->start_address; |
2305 | fde->end_address = fde->start_address; |
1922 | } |
2306 | } |
1923 | 2307 | ||
1924 | cie = select_cie_for_fde (fde, TRUE, &first, 2); |
2308 | cie = select_cie_for_fde (fde, TRUE, &first, 2); |
- | 2309 | fde->eh_loc = symbol_temp_new_now (); |
|
1925 | output_fde (fde, cie, TRUE, first, |
2310 | output_fde (fde, cie, TRUE, first, |
1926 | fde->next == NULL ? EH_FRAME_ALIGNMENT : 2); |
2311 | fde->next == NULL ? EH_FRAME_ALIGNMENT : 2); |
1927 | } |
2312 | } |
1928 | } |
2313 | } |
1929 | while (SUPPORT_FRAME_LINKONCE && seek_next_seg == 2); |
2314 | while (EH_FRAME_LINKONCE && seek_next_seg == 2); |
- | 2315 | ||
- | 2316 | if (EH_FRAME_LINKONCE) |
|
- | 2317 | for (fde = all_fde_data; fde ; fde = fde->next) |
|
- | 2318 | SET_HANDLED (fde, 0); |
|
- | 2319 | ||
- | 2320 | #if SUPPORT_COMPACT_EH |
|
- | 2321 | if (compact_eh) |
|
- | 2322 | { |
|
- | 2323 | /* Create remaining out of line table entries. */ |
|
- | 2324 | do |
|
- | 2325 | { |
|
- | 2326 | ccseg = NULL; |
|
- | 2327 | seek_next_seg = 0; |
|
- | 2328 | ||
- | 2329 | for (fde = all_fde_data; fde ; fde = fde->next) |
|
- | 2330 | { |
|
- | 2331 | if ((fde->sections & CFI_EMIT_eh_frame) == 0 |
|
- | 2332 | && (fde->sections & CFI_EMIT_eh_frame_compact) == 0) |
|
- | 2333 | continue; |
|
- | 2334 | ||
- | 2335 | if (fde->eh_header_type != EH_COMPACT_OUTLINE) |
|
- | 2336 | continue; |
|
- | 2337 | if (HANDLED (fde)) |
|
- | 2338 | continue; |
|
- | 2339 | if (seek_next_seg && CUR_SEG (fde) != ccseg) |
|
- | 2340 | { |
|
- | 2341 | seek_next_seg = 2; |
|
- | 2342 | continue; |
|
- | 2343 | } |
|
- | 2344 | if (!seek_next_seg) |
|
- | 2345 | { |
|
- | 2346 | ccseg = CUR_SEG (fde); |
|
- | 2347 | /* Open .gnu_extab section. */ |
|
- | 2348 | get_cfi_seg (ccseg, ".gnu_extab", |
|
- | 2349 | (SEC_ALLOC | SEC_LOAD | SEC_DATA |
|
- | 2350 | | DWARF2_EH_FRAME_READ_ONLY), |
|
- | 2351 | 1); |
|
- | 2352 | seek_next_seg = 1; |
|
- | 2353 | } |
|
- | 2354 | SET_HANDLED (fde, 1); |
|
- | 2355 | ||
- | 2356 | frag_align (1, 0, 0); |
|
- | 2357 | record_alignment (now_seg, 1); |
|
- | 2358 | output_compact_unwind_data (fde, 1); |
|
- | 2359 | } |
|
- | 2360 | } |
|
- | 2361 | while (EH_FRAME_LINKONCE && seek_next_seg == 2); |
|
- | 2362 | ||
- | 2363 | for (fde = all_fde_data; fde ; fde = fde->next) |
|
- | 2364 | SET_HANDLED (fde, 0); |
|
- | 2365 | ||
- | 2366 | /* Create index table fragments. */ |
|
- | 2367 | do |
|
- | 2368 | { |
|
- | 2369 | ccseg = NULL; |
|
- | 2370 | seek_next_seg = 0; |
|
- | 2371 | ||
- | 2372 | for (fde = all_fde_data; fde ; fde = fde->next) |
|
- | 2373 | { |
|
- | 2374 | if ((fde->sections & CFI_EMIT_eh_frame) == 0 |
|
- | 2375 | && (fde->sections & CFI_EMIT_eh_frame_compact) == 0) |
|
- | 2376 | continue; |
|
- | 2377 | ||
- | 2378 | if (HANDLED (fde)) |
|
- | 2379 | continue; |
|
- | 2380 | if (seek_next_seg && CUR_SEG (fde) != ccseg) |
|
- | 2381 | { |
|
- | 2382 | seek_next_seg = 2; |
|
- | 2383 | continue; |
|
- | 2384 | } |
|
- | 2385 | if (!seek_next_seg) |
|
- | 2386 | { |
|
- | 2387 | ccseg = CUR_SEG (fde); |
|
- | 2388 | /* Open .eh_frame_entry section. */ |
|
- | 2389 | cfi_seg = get_cfi_seg (ccseg, ".eh_frame_entry", |
|
- | 2390 | (SEC_ALLOC | SEC_LOAD | SEC_DATA |
|
- | 2391 | | DWARF2_EH_FRAME_READ_ONLY), |
|
- | 2392 | 2); |
|
- | 2393 | seek_next_seg = 1; |
|
- | 2394 | } |
|
- | 2395 | SET_HANDLED (fde, 1); |
|
- | 2396 | ||
- | 2397 | output_eh_header (fde); |
|
- | 2398 | } |
|
- | 2399 | } |
|
- | 2400 | while (seek_next_seg == 2); |
|
1930 | - | ||
1931 | if (SUPPORT_FRAME_LINKONCE) |
2401 | |
1932 | for (fde = all_fde_data; fde ; fde = fde->next) |
2402 | for (fde = all_fde_data; fde ; fde = fde->next) |
- | 2403 | SET_HANDLED (fde, 0); |
|
- | 2404 | } |
|
1933 | SET_HANDLED (fde, 0); |
2405 | #endif /* SUPPORT_COMPACT_EH */ |
1934 | 2406 | ||
1935 | flag_traditional_format = save_flag_traditional_format; |
2407 | flag_traditional_format = save_flag_traditional_format; |
1936 | } |
2408 | } |
1937 | 2409 | ||
1938 | if ((cfi_sections & CFI_EMIT_debug_frame) != 0) |
2410 | if ((all_cfi_sections & CFI_EMIT_debug_frame) != 0) |
1939 | { |
2411 | { |
1940 | int alignment = ffs (DWARF2_ADDR_SIZE (stdoutput)) - 1; |
2412 | int alignment = ffs (DWARF2_ADDR_SIZE (stdoutput)) - 1; |
1941 | 2413 | ||
1942 | if (!SUPPORT_FRAME_LINKONCE) |
2414 | if (!SUPPORT_FRAME_LINKONCE) |
1943 | get_cfi_seg (NULL, ".debug_frame", |
2415 | get_cfi_seg (NULL, ".debug_frame", |
1944 | SEC_READONLY | SEC_DEBUGGING, |
2416 | SEC_READONLY | SEC_DEBUGGING, |
1945 | alignment); |
2417 | alignment); |
1946 | 2418 | ||
1947 | do |
2419 | do |
1948 | { |
2420 | { |
1949 | ccseg = NULL; |
2421 | ccseg = NULL; |
1950 | seek_next_seg = 0; |
2422 | seek_next_seg = 0; |
1951 | 2423 | ||
1952 | for (cie = cie_root; cie; cie = cie_next) |
2424 | for (cie = cie_root; cie; cie = cie_next) |
1953 | { |
2425 | { |
1954 | cie_next = cie->next; |
2426 | cie_next = cie->next; |
1955 | free ((void *) cie); |
2427 | free ((void *) cie); |
1956 | } |
2428 | } |
1957 | cie_root = NULL; |
2429 | cie_root = NULL; |
1958 | 2430 | ||
1959 | for (fde = all_fde_data; fde ; fde = fde->next) |
2431 | for (fde = all_fde_data; fde ; fde = fde->next) |
1960 | { |
2432 | { |
- | 2433 | if ((fde->sections & CFI_EMIT_debug_frame) == 0) |
|
- | 2434 | continue; |
|
- | 2435 | ||
1961 | if (SUPPORT_FRAME_LINKONCE) |
2436 | if (SUPPORT_FRAME_LINKONCE) |
1962 | { |
2437 | { |
1963 | if (HANDLED (fde)) |
2438 | if (HANDLED (fde)) |
1964 | continue; |
2439 | continue; |
1965 | if (seek_next_seg && CUR_SEG (fde) != ccseg) |
2440 | if (seek_next_seg && CUR_SEG (fde) != ccseg) |
1966 | { |
2441 | { |
1967 | seek_next_seg = 2; |
2442 | seek_next_seg = 2; |
1968 | continue; |
2443 | continue; |
1969 | } |
2444 | } |
1970 | if (!seek_next_seg) |
2445 | if (!seek_next_seg) |
1971 | { |
2446 | { |
1972 | ccseg = CUR_SEG (fde); |
2447 | ccseg = CUR_SEG (fde); |
1973 | /* Open .debug_frame section. */ |
2448 | /* Open .debug_frame section. */ |
1974 | get_cfi_seg (ccseg, ".debug_frame", |
2449 | get_cfi_seg (ccseg, ".debug_frame", |
1975 | SEC_READONLY | SEC_DEBUGGING, |
2450 | SEC_READONLY | SEC_DEBUGGING, |
1976 | alignment); |
2451 | alignment); |
1977 | seek_next_seg = 1; |
2452 | seek_next_seg = 1; |
1978 | } |
2453 | } |
1979 | SET_HANDLED (fde, 1); |
2454 | SET_HANDLED (fde, 1); |
1980 | } |
2455 | } |
1981 | if (fde->end_address == NULL) |
2456 | if (fde->end_address == NULL) |
1982 | { |
2457 | { |
1983 | as_bad (_("open CFI at the end of file; missing .cfi_endproc directive")); |
2458 | as_bad (_("open CFI at the end of file; missing .cfi_endproc directive")); |
1984 | fde->end_address = fde->start_address; |
2459 | fde->end_address = fde->start_address; |
1985 | } |
2460 | } |
1986 | 2461 | ||
1987 | fde->per_encoding = DW_EH_PE_omit; |
2462 | fde->per_encoding = DW_EH_PE_omit; |
1988 | fde->lsda_encoding = DW_EH_PE_omit; |
2463 | fde->lsda_encoding = DW_EH_PE_omit; |
1989 | cfi_change_reg_numbers (fde->data, ccseg); |
2464 | cfi_change_reg_numbers (fde->data, ccseg); |
1990 | cie = select_cie_for_fde (fde, FALSE, &first, alignment); |
2465 | cie = select_cie_for_fde (fde, FALSE, &first, alignment); |
1991 | output_fde (fde, cie, FALSE, first, alignment); |
2466 | output_fde (fde, cie, FALSE, first, alignment); |
1992 | } |
2467 | } |
1993 | } |
2468 | } |
1994 | while (SUPPORT_FRAME_LINKONCE && seek_next_seg == 2); |
2469 | while (SUPPORT_FRAME_LINKONCE && seek_next_seg == 2); |
1995 | 2470 | ||
1996 | if (SUPPORT_FRAME_LINKONCE) |
2471 | if (SUPPORT_FRAME_LINKONCE) |
1997 | for (fde = all_fde_data; fde ; fde = fde->next) |
2472 | for (fde = all_fde_data; fde ; fde = fde->next) |
1998 | SET_HANDLED (fde, 0); |
2473 | SET_HANDLED (fde, 0); |
1999 | } |
2474 | } |
2000 | } |
2475 | } |
2001 | 2476 | ||
2002 | #else /* TARGET_USE_CFIPOP */ |
2477 | #else /* TARGET_USE_CFIPOP */ |
2003 | 2478 | ||
2004 | /* Emit an intelligible error message for missing support. */ |
2479 | /* Emit an intelligible error message for missing support. */ |
2005 | 2480 | ||
2006 | static void |
2481 | static void |
2007 | dot_cfi_dummy (int ignored ATTRIBUTE_UNUSED) |
2482 | dot_cfi_dummy (int ignored ATTRIBUTE_UNUSED) |
2008 | { |
2483 | { |
2009 | as_bad (_("CFI is not supported for this target")); |
2484 | as_bad (_("CFI is not supported for this target")); |
2010 | ignore_rest_of_line (); |
2485 | ignore_rest_of_line (); |
2011 | } |
2486 | } |
2012 | 2487 | ||
2013 | const pseudo_typeS cfi_pseudo_table[] = |
2488 | const pseudo_typeS cfi_pseudo_table[] = |
2014 | { |
2489 | { |
2015 | { "cfi_sections", dot_cfi_dummy, 0 }, |
2490 | { "cfi_sections", dot_cfi_dummy, 0 }, |
2016 | { "cfi_startproc", dot_cfi_dummy, 0 }, |
2491 | { "cfi_startproc", dot_cfi_dummy, 0 }, |
2017 | { "cfi_endproc", dot_cfi_dummy, 0 }, |
2492 | { "cfi_endproc", dot_cfi_dummy, 0 }, |
- | 2493 | { "cfi_fde_data", dot_cfi_dummy, 0 }, |
|
2018 | { "cfi_def_cfa", dot_cfi_dummy, 0 }, |
2494 | { "cfi_def_cfa", dot_cfi_dummy, 0 }, |
2019 | { "cfi_def_cfa_register", dot_cfi_dummy, 0 }, |
2495 | { "cfi_def_cfa_register", dot_cfi_dummy, 0 }, |
2020 | { "cfi_def_cfa_offset", dot_cfi_dummy, 0 }, |
2496 | { "cfi_def_cfa_offset", dot_cfi_dummy, 0 }, |
2021 | { "cfi_adjust_cfa_offset", dot_cfi_dummy, 0 }, |
2497 | { "cfi_adjust_cfa_offset", dot_cfi_dummy, 0 }, |
2022 | { "cfi_offset", dot_cfi_dummy, 0 }, |
2498 | { "cfi_offset", dot_cfi_dummy, 0 }, |
2023 | { "cfi_rel_offset", dot_cfi_dummy, 0 }, |
2499 | { "cfi_rel_offset", dot_cfi_dummy, 0 }, |
2024 | { "cfi_register", dot_cfi_dummy, 0 }, |
2500 | { "cfi_register", dot_cfi_dummy, 0 }, |
2025 | { "cfi_return_column", dot_cfi_dummy, 0 }, |
2501 | { "cfi_return_column", dot_cfi_dummy, 0 }, |
2026 | { "cfi_restore", dot_cfi_dummy, 0 }, |
2502 | { "cfi_restore", dot_cfi_dummy, 0 }, |
2027 | { "cfi_undefined", dot_cfi_dummy, 0 }, |
2503 | { "cfi_undefined", dot_cfi_dummy, 0 }, |
2028 | { "cfi_same_value", dot_cfi_dummy, 0 }, |
2504 | { "cfi_same_value", dot_cfi_dummy, 0 }, |
2029 | { "cfi_remember_state", dot_cfi_dummy, 0 }, |
2505 | { "cfi_remember_state", dot_cfi_dummy, 0 }, |
2030 | { "cfi_restore_state", dot_cfi_dummy, 0 }, |
2506 | { "cfi_restore_state", dot_cfi_dummy, 0 }, |
2031 | { "cfi_window_save", dot_cfi_dummy, 0 }, |
2507 | { "cfi_window_save", dot_cfi_dummy, 0 }, |
2032 | { "cfi_escape", dot_cfi_dummy, 0 }, |
2508 | { "cfi_escape", dot_cfi_dummy, 0 }, |
2033 | { "cfi_signal_frame", dot_cfi_dummy, 0 }, |
2509 | { "cfi_signal_frame", dot_cfi_dummy, 0 }, |
2034 | { "cfi_personality", dot_cfi_dummy, 0 }, |
2510 | { "cfi_personality", dot_cfi_dummy, 0 }, |
- | 2511 | { "cfi_personality_id", dot_cfi_dummy, 0 }, |
|
2035 | { "cfi_lsda", dot_cfi_dummy, 0 }, |
2512 | { "cfi_lsda", dot_cfi_dummy, 0 }, |
2036 | { "cfi_val_encoded_addr", dot_cfi_dummy, 0 }, |
2513 | { "cfi_val_encoded_addr", dot_cfi_dummy, 0 }, |
- | 2514 | { "cfi_label", dot_cfi_dummy, 0 }, |
|
- | 2515 | { "cfi_inline_lsda", dot_cfi_dummy, 0 }, |
|
2037 | { NULL, NULL, 0 } |
2516 | { NULL, NULL, 0 } |
2038 | }; |
2517 | }; |
2039 | 2518 | ||
2040 | void |
2519 | void |
2041 | cfi_finish (void) |
2520 | cfi_finish (void) |
2042 | { |
2521 | { |
2043 | } |
2522 | } |
2044 | #endif /* TARGET_USE_CFIPOP */=>>=>>>><>=>=>=>><>><>><>>>> |
2523 | #endif /* TARGET_USE_CFIPOP */=>>=>>>><>=>=>=>>><>>=>>>> |