1 /* dw2gencfi.c - Support for generating Dwarf2 CFI information.
2 Copyright (C) 2003-2023 Free Software Foundation, Inc.
3 Contributed by Michal Ludvig <mludvig@suse.cz>
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23 #include "dw2gencfi.h"
25 #include "dwarf2dbg.h"
26 #include "gen-sframe.h"
28 #ifdef TARGET_USE_CFIPOP
30 /* By default, use difference expressions if DIFF_EXPR_OK is defined. */
31 #ifndef CFI_DIFF_EXPR_OK
33 # define CFI_DIFF_EXPR_OK 1
35 # define CFI_DIFF_EXPR_OK 0
39 #ifndef CFI_DIFF_LSDA_OK
40 #define CFI_DIFF_LSDA_OK CFI_DIFF_EXPR_OK
43 #if CFI_DIFF_EXPR_OK == 1 && CFI_DIFF_LSDA_OK == 0
44 # error "CFI_DIFF_EXPR_OK should imply CFI_DIFF_LSDA_OK"
47 /* We re-use DWARF2_LINE_MIN_INSN_LENGTH for the code alignment field
48 of the CIE. Default to 1 if not otherwise specified. */
49 #ifndef DWARF2_LINE_MIN_INSN_LENGTH
50 #define DWARF2_LINE_MIN_INSN_LENGTH 1
53 /* By default, use 32-bit relocations from .eh_frame into .text. */
54 #ifndef DWARF2_FDE_RELOC_SIZE
55 #define DWARF2_FDE_RELOC_SIZE 4
58 /* By default, use a read-only .eh_frame section. */
59 #ifndef DWARF2_EH_FRAME_READ_ONLY
60 #define DWARF2_EH_FRAME_READ_ONLY SEC_READONLY
63 #ifndef EH_FRAME_ALIGNMENT
64 #define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2)
67 #ifndef tc_cfi_frame_initial_instructions
68 #define tc_cfi_frame_initial_instructions() ((void)0)
71 #ifndef tc_cfi_startproc
72 # define tc_cfi_startproc() ((void)0)
75 #ifndef tc_cfi_endproc
76 # define tc_cfi_endproc(fde) ((void) (fde))
79 #define EH_FRAME_LINKONCE (SUPPORT_FRAME_LINKONCE || compact_eh \
80 || TARGET_MULTIPLE_EH_FRAME_SECTIONS)
83 #define DWARF2_FORMAT(SEC) dwarf2_format_32bit
86 #ifndef DWARF2_ADDR_SIZE
87 #define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8)
90 #if MULTIPLE_FRAME_SECTIONS
91 #define CUR_SEG(structp) structp->cur_seg
92 #define SET_CUR_SEG(structp, seg) structp->cur_seg = seg
93 #define HANDLED(structp) structp->handled
94 #define SET_HANDLED(structp, val) structp->handled = val
96 #define CUR_SEG(structp) NULL
97 #define SET_CUR_SEG(structp, seg) (void) (0 && seg)
98 #define HANDLED(structp) 0
99 #define SET_HANDLED(structp, val) (void) (0 && val)
102 #ifndef tc_cfi_reloc_for_encoding
103 #define tc_cfi_reloc_for_encoding(e) BFD_RELOC_NONE
106 /* Targets which support SFrame format will define this and return true. */
107 #ifndef support_sframe_p
108 # define support_sframe_p() false
111 /* Private segment collection list. */
112 struct dwcfi_seg_list
119 #ifdef SUPPORT_COMPACT_EH
120 static bool compact_eh
;
125 static htab_t dwcfi_hash
;
127 /* Emit a single byte into the current segment. */
132 FRAG_APPEND_1_CHAR (byte
);
135 /* Emit a two-byte word into the current segment. */
140 md_number_to_chars (frag_more (2), data
, 2);
143 /* Emit a four byte word into the current segment. */
148 md_number_to_chars (frag_more (4), data
, 4);
151 /* Emit an unsigned "little-endian base 128" number. */
154 out_uleb128 (addressT value
)
156 output_leb128 (frag_more (sizeof_leb128 (value
, 0)), value
, 0);
159 /* Emit an unsigned "little-endian base 128" number. */
162 out_sleb128 (offsetT value
)
164 output_leb128 (frag_more (sizeof_leb128 (value
, 1)), value
, 1);
168 encoding_size (unsigned char encoding
)
170 if (encoding
== DW_EH_PE_omit
)
172 switch (encoding
& 0x7)
175 return bfd_get_arch_size (stdoutput
) == 64 ? 8 : 4;
176 case DW_EH_PE_udata2
:
178 case DW_EH_PE_udata4
:
180 case DW_EH_PE_udata8
:
187 /* Emit expression EXP in ENCODING. If EMIT_ENCODING is true, first
188 emit a byte containing ENCODING. */
191 emit_expr_encoded (expressionS
*exp
, int encoding
, bool emit_encoding
)
193 unsigned int size
= encoding_size (encoding
);
194 bfd_reloc_code_real_type code
;
196 if (encoding
== DW_EH_PE_omit
)
202 code
= tc_cfi_reloc_for_encoding (encoding
);
203 if (code
!= BFD_RELOC_NONE
)
205 reloc_howto_type
*howto
= bfd_reloc_type_lookup (stdoutput
, code
);
206 char *p
= frag_more (size
);
207 gas_assert (size
== (unsigned) howto
->bitsize
/ 8);
208 md_number_to_chars (p
, 0, size
);
209 fix_new (frag_now
, p
- frag_now
->fr_literal
, size
, exp
->X_add_symbol
,
210 exp
->X_add_number
, howto
->pc_relative
, code
);
212 else if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
215 expressionS tmp
= *exp
;
216 tmp
.X_op
= O_subtract
;
217 tmp
.X_op_symbol
= symbol_temp_new_now ();
218 emit_expr (&tmp
, size
);
219 #elif defined (tc_cfi_emit_pcrel_expr)
220 tc_cfi_emit_pcrel_expr (exp
, size
);
226 emit_expr (exp
, size
);
229 /* Build based on segment the derived .debug_...
230 segment name containing origin segment's postfix name part. */
233 get_debugseg_name (segT seg
, const char *base_name
)
240 || (name
= bfd_section_name (seg
)) == NULL
242 return notes_strdup (base_name
);
244 dollar
= strchr (name
, '$');
245 dot
= strchr (name
+ 1, '.');
249 if (!strcmp (base_name
, ".eh_frame_entry")
250 && strcmp (name
, ".text") != 0)
251 return notes_concat (base_name
, ".", name
, NULL
);
259 else if (dot
< dollar
)
264 return notes_concat (base_name
, name
, NULL
);
267 /* Allocate a dwcfi_seg_list structure. */
269 static struct dwcfi_seg_list
*
270 alloc_debugseg_item (segT seg
, int subseg
, char *name
)
272 struct dwcfi_seg_list
*r
;
274 r
= notes_alloc (sizeof (*r
) + strlen (name
));
282 is_now_linkonce_segment (void)
287 if (TARGET_MULTIPLE_EH_FRAME_SECTIONS
)
290 if ((bfd_section_flags (now_seg
)
291 & (SEC_LINK_ONCE
| SEC_LINK_DUPLICATES_DISCARD
292 | SEC_LINK_DUPLICATES_ONE_ONLY
| SEC_LINK_DUPLICATES_SAME_SIZE
293 | SEC_LINK_DUPLICATES_SAME_CONTENTS
)) != 0)
298 /* Generate debug... segment with same linkonce properties
302 make_debug_seg (segT cseg
, char *name
, int sflags
)
304 segT save_seg
= now_seg
;
305 int save_subseg
= now_subseg
;
309 r
= subseg_new (name
, 0);
311 /* Check if code segment is marked as linked once. */
315 flags
= (bfd_section_flags (cseg
)
316 & (SEC_LINK_ONCE
| SEC_LINK_DUPLICATES_DISCARD
317 | SEC_LINK_DUPLICATES_ONE_ONLY
| SEC_LINK_DUPLICATES_SAME_SIZE
318 | SEC_LINK_DUPLICATES_SAME_CONTENTS
));
320 /* Add standard section flags. */
323 /* Apply possibly linked once flags to new generated segment, too. */
324 if (!bfd_set_section_flags (r
, flags
))
325 as_bad (_("bfd_set_section_flags: %s"),
326 bfd_errmsg (bfd_get_error ()));
328 /* Restore to previous segment. */
329 if (save_seg
!= NULL
)
330 subseg_set (save_seg
, save_subseg
);
334 static struct dwcfi_seg_list
*
335 dwcfi_hash_find (char *name
)
337 return (struct dwcfi_seg_list
*) str_hash_find (dwcfi_hash
, name
);
340 static struct dwcfi_seg_list
*
341 dwcfi_hash_find_or_make (segT cseg
, const char *base_name
, int flags
)
343 struct dwcfi_seg_list
*item
;
346 /* Initialize dwcfi_hash once. */
348 dwcfi_hash
= str_htab_create ();
350 name
= get_debugseg_name (cseg
, base_name
);
352 item
= dwcfi_hash_find (name
);
355 item
= alloc_debugseg_item (make_debug_seg (cseg
, name
, flags
), 0, name
);
357 str_hash_insert (dwcfi_hash
, item
->seg_name
, item
, 0);
365 /* ??? Share this with dwarf2cfg.c. */
366 #ifndef TC_DWARF2_EMIT_OFFSET
367 #define TC_DWARF2_EMIT_OFFSET generic_dwarf2_emit_offset
369 /* Create an offset to .dwarf2_*. */
372 generic_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
377 exp
.X_add_symbol
= symbol
;
378 exp
.X_add_number
= 0;
379 emit_expr (&exp
, size
);
383 struct cfi_escape_data
385 struct cfi_escape_data
*next
;
391 struct cie_entry
*next
;
392 #if MULTIPLE_FRAME_SECTIONS
395 symbolS
*start_address
;
396 unsigned int return_column
;
397 unsigned int signal_frame
;
398 unsigned char fde_encoding
;
399 unsigned char per_encoding
;
400 unsigned char lsda_encoding
;
401 expressionS personality
;
402 #ifdef tc_cie_entry_extras
405 struct cfi_insn_data
*first
, *last
;
408 /* List of FDE entries. */
410 struct fde_entry
*all_fde_data
;
411 static struct fde_entry
**last_fde_data
= &all_fde_data
;
413 /* List of CIEs so that they could be reused. */
414 static struct cie_entry
*cie_root
;
416 /* Construct a new FDE structure and add it to the end of the fde list. */
418 static struct fde_entry
*
419 alloc_fde_entry (void)
421 struct fde_entry
*fde
= XCNEW (struct fde_entry
);
423 frchain_now
->frch_cfi_data
= XCNEW (struct frch_cfi_data
);
424 frchain_now
->frch_cfi_data
->cur_fde_data
= fde
;
425 *last_fde_data
= fde
;
426 last_fde_data
= &fde
->next
;
427 SET_CUR_SEG (fde
, is_now_linkonce_segment ());
428 SET_HANDLED (fde
, 0);
429 fde
->last
= &fde
->data
;
430 fde
->return_column
= DWARF2_DEFAULT_RETURN_COLUMN
;
431 fde
->per_encoding
= DW_EH_PE_omit
;
432 fde
->lsda_encoding
= DW_EH_PE_omit
;
433 fde
->eh_header_type
= EH_COMPACT_UNKNOWN
;
434 #ifdef tc_fde_entry_init_extra
435 tc_fde_entry_init_extra (fde
)
441 /* The following functions are available for a backend to construct its
442 own unwind information, usually from legacy unwind directives. */
444 /* Construct a new INSN structure and add it to the end of the insn list
445 for the currently active FDE. */
447 static bool cfi_sections_set
= false;
448 static int cfi_sections
= CFI_EMIT_eh_frame
;
449 int all_cfi_sections
= 0;
450 static struct fde_entry
*last_fde
;
452 static struct cfi_insn_data
*
453 alloc_cfi_insn_data (void)
455 struct cfi_insn_data
*insn
= XCNEW (struct cfi_insn_data
);
456 struct fde_entry
*cur_fde_data
= frchain_now
->frch_cfi_data
->cur_fde_data
;
458 *cur_fde_data
->last
= insn
;
459 cur_fde_data
->last
= &insn
->next
;
460 SET_CUR_SEG (insn
, is_now_linkonce_segment ());
464 /* Construct a new FDE structure that begins at LABEL. */
467 cfi_new_fde (symbolS
*label
)
469 struct fde_entry
*fde
= alloc_fde_entry ();
470 fde
->start_address
= label
;
471 frchain_now
->frch_cfi_data
->last_address
= label
;
474 /* End the currently open FDE. */
477 cfi_end_fde (symbolS
*label
)
479 frchain_now
->frch_cfi_data
->cur_fde_data
->end_address
= label
;
480 free (frchain_now
->frch_cfi_data
);
481 frchain_now
->frch_cfi_data
= NULL
;
484 /* Set the return column for the current FDE. */
487 cfi_set_return_column (unsigned regno
)
489 frchain_now
->frch_cfi_data
->cur_fde_data
->return_column
= regno
;
493 cfi_set_sections (void)
495 frchain_now
->frch_cfi_data
->cur_fde_data
->sections
= all_cfi_sections
;
496 cfi_sections_set
= true;
499 /* Universal functions to store new instructions. */
502 cfi_add_CFA_insn (int insn
)
504 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
506 insn_ptr
->insn
= insn
;
510 cfi_add_CFA_insn_reg (int insn
, unsigned regno
)
512 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
514 insn_ptr
->insn
= insn
;
515 insn_ptr
->u
.r
= regno
;
519 cfi_add_CFA_insn_offset (int insn
, offsetT offset
)
521 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
523 insn_ptr
->insn
= insn
;
524 insn_ptr
->u
.i
= offset
;
528 cfi_add_CFA_insn_reg_reg (int insn
, unsigned reg1
, unsigned reg2
)
530 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
532 insn_ptr
->insn
= insn
;
533 insn_ptr
->u
.rr
.reg1
= reg1
;
534 insn_ptr
->u
.rr
.reg2
= reg2
;
538 cfi_add_CFA_insn_reg_offset (int insn
, unsigned regno
, offsetT offset
)
540 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
542 insn_ptr
->insn
= insn
;
543 insn_ptr
->u
.ri
.reg
= regno
;
544 insn_ptr
->u
.ri
.offset
= offset
;
547 /* Add a CFI insn to advance the PC from the last address to LABEL. */
550 cfi_add_advance_loc (symbolS
*label
)
552 struct cfi_insn_data
*insn
= alloc_cfi_insn_data ();
554 insn
->insn
= DW_CFA_advance_loc
;
555 insn
->u
.ll
.lab1
= frchain_now
->frch_cfi_data
->last_address
;
556 insn
->u
.ll
.lab2
= label
;
558 frchain_now
->frch_cfi_data
->last_address
= label
;
561 /* Add a CFI insn to label the current position in the CFI segment. */
564 cfi_add_label (const char *name
)
566 unsigned int len
= strlen (name
) + 1;
567 struct cfi_insn_data
*insn
= alloc_cfi_insn_data ();
569 insn
->insn
= CFI_label
;
570 obstack_grow (¬es
, name
, len
);
571 insn
->u
.sym_name
= (char *) obstack_finish (¬es
);
574 /* Add a DW_CFA_offset record to the CFI data. */
577 cfi_add_CFA_offset (unsigned regno
, offsetT offset
)
579 unsigned int abs_data_align
;
581 gas_assert (DWARF2_CIE_DATA_ALIGNMENT
!= 0);
582 cfi_add_CFA_insn_reg_offset (DW_CFA_offset
, regno
, offset
);
584 abs_data_align
= (DWARF2_CIE_DATA_ALIGNMENT
< 0
585 ? -DWARF2_CIE_DATA_ALIGNMENT
: DWARF2_CIE_DATA_ALIGNMENT
);
586 if (offset
% abs_data_align
)
587 as_bad (_("register save offset not a multiple of %u"), abs_data_align
);
590 /* Add a DW_CFA_val_offset record to the CFI data. */
593 cfi_add_CFA_val_offset (unsigned regno
, offsetT offset
)
595 unsigned int abs_data_align
;
597 gas_assert (DWARF2_CIE_DATA_ALIGNMENT
!= 0);
598 cfi_add_CFA_insn_reg_offset (DW_CFA_val_offset
, regno
, offset
);
600 abs_data_align
= (DWARF2_CIE_DATA_ALIGNMENT
< 0
601 ? -DWARF2_CIE_DATA_ALIGNMENT
: DWARF2_CIE_DATA_ALIGNMENT
);
602 if (offset
% abs_data_align
)
603 as_bad (_("register save offset not a multiple of %u"), abs_data_align
);
606 /* Add a DW_CFA_def_cfa record to the CFI data. */
609 cfi_add_CFA_def_cfa (unsigned regno
, offsetT offset
)
611 cfi_add_CFA_insn_reg_offset (DW_CFA_def_cfa
, regno
, offset
);
612 frchain_now
->frch_cfi_data
->cur_cfa_offset
= offset
;
615 /* Add a DW_CFA_register record to the CFI data. */
618 cfi_add_CFA_register (unsigned reg1
, unsigned reg2
)
620 cfi_add_CFA_insn_reg_reg (DW_CFA_register
, reg1
, reg2
);
623 /* Add a DW_CFA_def_cfa_register record to the CFI data. */
626 cfi_add_CFA_def_cfa_register (unsigned regno
)
628 cfi_add_CFA_insn_reg (DW_CFA_def_cfa_register
, regno
);
631 /* Add a DW_CFA_def_cfa_offset record to the CFI data. */
634 cfi_add_CFA_def_cfa_offset (offsetT offset
)
636 cfi_add_CFA_insn_offset (DW_CFA_def_cfa_offset
, offset
);
637 frchain_now
->frch_cfi_data
->cur_cfa_offset
= offset
;
641 cfi_add_CFA_restore (unsigned regno
)
643 cfi_add_CFA_insn_reg (DW_CFA_restore
, regno
);
647 cfi_add_CFA_undefined (unsigned regno
)
649 cfi_add_CFA_insn_reg (DW_CFA_undefined
, regno
);
653 cfi_add_CFA_same_value (unsigned regno
)
655 cfi_add_CFA_insn_reg (DW_CFA_same_value
, regno
);
659 cfi_add_CFA_remember_state (void)
661 struct cfa_save_data
*p
;
663 cfi_add_CFA_insn (DW_CFA_remember_state
);
665 p
= XNEW (struct cfa_save_data
);
666 p
->cfa_offset
= frchain_now
->frch_cfi_data
->cur_cfa_offset
;
667 p
->next
= frchain_now
->frch_cfi_data
->cfa_save_stack
;
668 frchain_now
->frch_cfi_data
->cfa_save_stack
= p
;
672 cfi_add_CFA_restore_state (void)
674 struct cfa_save_data
*p
;
676 cfi_add_CFA_insn (DW_CFA_restore_state
);
678 p
= frchain_now
->frch_cfi_data
->cfa_save_stack
;
681 frchain_now
->frch_cfi_data
->cur_cfa_offset
= p
->cfa_offset
;
682 frchain_now
->frch_cfi_data
->cfa_save_stack
= p
->next
;
686 as_bad (_("CFI state restore without previous remember"));
690 /* Parse CFI assembler directives. */
692 static void dot_cfi (int);
693 static void dot_cfi_escape (int);
694 static void dot_cfi_sections (int);
695 static void dot_cfi_startproc (int);
696 static void dot_cfi_endproc (int);
697 static void dot_cfi_fde_data (int);
698 static void dot_cfi_personality (int);
699 static void dot_cfi_personality_id (int);
700 static void dot_cfi_lsda (int);
701 static void dot_cfi_val_encoded_addr (int);
702 static void dot_cfi_inline_lsda (int);
703 static void dot_cfi_label (int);
705 const pseudo_typeS cfi_pseudo_table
[] =
707 { "cfi_sections", dot_cfi_sections
, 0 },
708 { "cfi_startproc", dot_cfi_startproc
, 0 },
709 { "cfi_endproc", dot_cfi_endproc
, 0 },
710 { "cfi_fde_data", dot_cfi_fde_data
, 0 },
711 { "cfi_def_cfa", dot_cfi
, DW_CFA_def_cfa
},
712 { "cfi_def_cfa_register", dot_cfi
, DW_CFA_def_cfa_register
},
713 { "cfi_def_cfa_offset", dot_cfi
, DW_CFA_def_cfa_offset
},
714 { "cfi_adjust_cfa_offset", dot_cfi
, CFI_adjust_cfa_offset
},
715 { "cfi_offset", dot_cfi
, DW_CFA_offset
},
716 { "cfi_rel_offset", dot_cfi
, CFI_rel_offset
},
717 { "cfi_register", dot_cfi
, DW_CFA_register
},
718 { "cfi_return_column", dot_cfi
, CFI_return_column
},
719 { "cfi_restore", dot_cfi
, DW_CFA_restore
},
720 { "cfi_undefined", dot_cfi
, DW_CFA_undefined
},
721 { "cfi_same_value", dot_cfi
, DW_CFA_same_value
},
722 { "cfi_remember_state", dot_cfi
, DW_CFA_remember_state
},
723 { "cfi_restore_state", dot_cfi
, DW_CFA_restore_state
},
724 { "cfi_window_save", dot_cfi
, DW_CFA_GNU_window_save
},
725 { "cfi_negate_ra_state", dot_cfi
, DW_CFA_AARCH64_negate_ra_state
},
726 { "cfi_escape", dot_cfi_escape
, 0 },
727 { "cfi_signal_frame", dot_cfi
, CFI_signal_frame
},
728 { "cfi_personality", dot_cfi_personality
, 0 },
729 { "cfi_personality_id", dot_cfi_personality_id
, 0 },
730 { "cfi_lsda", dot_cfi_lsda
, 0 },
731 { "cfi_val_encoded_addr", dot_cfi_val_encoded_addr
, 0 },
732 { "cfi_inline_lsda", dot_cfi_inline_lsda
, 0 },
733 { "cfi_label", dot_cfi_label
, 0 },
734 { "cfi_val_offset", dot_cfi
, DW_CFA_val_offset
},
739 cfi_parse_separator (void)
742 if (*input_line_pointer
== ',')
743 input_line_pointer
++;
745 as_bad (_("missing separator"));
748 #ifndef tc_parse_to_dw2regnum
750 tc_parse_to_dw2regnum (expressionS
*exp
)
752 # ifdef tc_regname_to_dw2regnum
754 if (is_name_beginner (*input_line_pointer
)
755 || (*input_line_pointer
== '%'
756 && is_name_beginner (*++input_line_pointer
)))
760 c
= get_symbol_name (& name
);
762 exp
->X_op
= O_constant
;
763 exp
->X_add_number
= tc_regname_to_dw2regnum (name
);
765 restore_line_pointer (c
);
769 expression_and_evaluate (exp
);
779 tc_parse_to_dw2regnum (&exp
);
784 regno
= exp
.X_add_number
;
794 as_bad (_("bad register expression"));
802 cfi_parse_const (void)
804 return get_absolute_expression ();
813 if (frchain_now
->frch_cfi_data
== NULL
)
815 as_bad (_("CFI instruction used without previous .cfi_startproc"));
816 ignore_rest_of_line ();
820 /* If the last address was not at the current PC, advance to current. */
821 if (symbol_get_frag (frchain_now
->frch_cfi_data
->last_address
) != frag_now
822 || (S_GET_VALUE (frchain_now
->frch_cfi_data
->last_address
)
824 cfi_add_advance_loc (symbol_temp_new_now ());
829 reg1
= cfi_parse_reg ();
830 cfi_parse_separator ();
831 offset
= cfi_parse_const ();
832 cfi_add_CFA_offset (reg1
, offset
);
835 case DW_CFA_val_offset
:
836 reg1
= cfi_parse_reg ();
837 cfi_parse_separator ();
838 offset
= cfi_parse_const ();
839 cfi_add_CFA_val_offset (reg1
, offset
);
843 reg1
= cfi_parse_reg ();
844 cfi_parse_separator ();
845 offset
= cfi_parse_const ();
846 cfi_add_CFA_offset (reg1
,
847 offset
- frchain_now
->frch_cfi_data
->cur_cfa_offset
);
851 reg1
= cfi_parse_reg ();
852 cfi_parse_separator ();
853 offset
= cfi_parse_const ();
854 cfi_add_CFA_def_cfa (reg1
, offset
);
857 case DW_CFA_register
:
858 reg1
= cfi_parse_reg ();
859 cfi_parse_separator ();
860 reg2
= cfi_parse_reg ();
861 cfi_add_CFA_register (reg1
, reg2
);
864 case DW_CFA_def_cfa_register
:
865 reg1
= cfi_parse_reg ();
866 cfi_add_CFA_def_cfa_register (reg1
);
869 case DW_CFA_def_cfa_offset
:
870 offset
= cfi_parse_const ();
871 cfi_add_CFA_def_cfa_offset (offset
);
874 case CFI_adjust_cfa_offset
:
875 offset
= cfi_parse_const ();
876 cfi_add_CFA_def_cfa_offset (frchain_now
->frch_cfi_data
->cur_cfa_offset
883 reg1
= cfi_parse_reg ();
884 cfi_add_CFA_restore (reg1
);
886 if (*input_line_pointer
!= ',')
888 ++input_line_pointer
;
892 case DW_CFA_undefined
:
895 reg1
= cfi_parse_reg ();
896 cfi_add_CFA_undefined (reg1
);
898 if (*input_line_pointer
!= ',')
900 ++input_line_pointer
;
904 case DW_CFA_same_value
:
905 reg1
= cfi_parse_reg ();
906 cfi_add_CFA_same_value (reg1
);
909 case CFI_return_column
:
910 reg1
= cfi_parse_reg ();
911 cfi_set_return_column (reg1
);
914 case DW_CFA_remember_state
:
915 cfi_add_CFA_remember_state ();
918 case DW_CFA_restore_state
:
919 cfi_add_CFA_restore_state ();
922 case DW_CFA_GNU_window_save
:
923 cfi_add_CFA_insn (DW_CFA_GNU_window_save
);
926 case CFI_signal_frame
:
927 frchain_now
->frch_cfi_data
->cur_fde_data
->signal_frame
= 1;
934 demand_empty_rest_of_line ();
938 dot_cfi_escape (int ignored ATTRIBUTE_UNUSED
)
940 struct cfi_escape_data
*head
, **tail
, *e
;
941 struct cfi_insn_data
*insn
;
943 if (frchain_now
->frch_cfi_data
== NULL
)
945 as_bad (_("CFI instruction used without previous .cfi_startproc"));
946 ignore_rest_of_line ();
950 /* If the last address was not at the current PC, advance to current. */
951 if (symbol_get_frag (frchain_now
->frch_cfi_data
->last_address
) != frag_now
952 || (S_GET_VALUE (frchain_now
->frch_cfi_data
->last_address
)
954 cfi_add_advance_loc (symbol_temp_new_now ());
959 e
= XNEW (struct cfi_escape_data
);
960 do_parse_cons_expression (&e
->exp
, 1);
964 while (*input_line_pointer
++ == ',');
967 insn
= alloc_cfi_insn_data ();
968 insn
->insn
= CFI_escape
;
971 --input_line_pointer
;
972 demand_empty_rest_of_line ();
976 dot_cfi_personality (int ignored ATTRIBUTE_UNUSED
)
978 struct fde_entry
*fde
;
981 if (frchain_now
->frch_cfi_data
== NULL
)
983 as_bad (_("CFI instruction used without previous .cfi_startproc"));
984 ignore_rest_of_line ();
988 fde
= frchain_now
->frch_cfi_data
->cur_fde_data
;
989 encoding
= cfi_parse_const ();
990 if (encoding
== DW_EH_PE_omit
)
992 demand_empty_rest_of_line ();
993 fde
->per_encoding
= encoding
;
997 if ((encoding
& 0xff) != encoding
998 || ((((encoding
& 0x70) != 0
999 #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
1000 && (encoding
& 0x70) != DW_EH_PE_pcrel
1003 /* leb128 can be handled, but does something actually need it? */
1004 || (encoding
& 7) == DW_EH_PE_uleb128
1005 || (encoding
& 7) > DW_EH_PE_udata8
)
1006 && tc_cfi_reloc_for_encoding (encoding
) == BFD_RELOC_NONE
))
1008 as_bad (_("invalid or unsupported encoding in .cfi_personality"));
1009 ignore_rest_of_line ();
1013 if (*input_line_pointer
++ != ',')
1015 as_bad (_(".cfi_personality requires encoding and symbol arguments"));
1016 ignore_rest_of_line ();
1020 expression_and_evaluate (&fde
->personality
);
1021 switch (fde
->personality
.X_op
)
1026 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
1027 encoding
= DW_EH_PE_omit
;
1030 encoding
= DW_EH_PE_omit
;
1034 fde
->per_encoding
= encoding
;
1036 if (encoding
== DW_EH_PE_omit
)
1038 as_bad (_("wrong second argument to .cfi_personality"));
1039 ignore_rest_of_line ();
1043 demand_empty_rest_of_line ();
1047 dot_cfi_lsda (int ignored ATTRIBUTE_UNUSED
)
1049 struct fde_entry
*fde
;
1052 if (frchain_now
->frch_cfi_data
== NULL
)
1054 as_bad (_("CFI instruction used without previous .cfi_startproc"));
1055 ignore_rest_of_line ();
1059 fde
= frchain_now
->frch_cfi_data
->cur_fde_data
;
1060 encoding
= cfi_parse_const ();
1061 if (encoding
== DW_EH_PE_omit
)
1063 demand_empty_rest_of_line ();
1064 fde
->lsda_encoding
= encoding
;
1068 if ((encoding
& 0xff) != encoding
1069 || ((((encoding
& 0x70) != 0
1070 #if CFI_DIFF_LSDA_OK || defined tc_cfi_emit_pcrel_expr
1071 && (encoding
& 0x70) != DW_EH_PE_pcrel
1074 /* leb128 can be handled, but does something actually need it? */
1075 || (encoding
& 7) == DW_EH_PE_uleb128
1076 || (encoding
& 7) > DW_EH_PE_udata8
)
1077 && tc_cfi_reloc_for_encoding (encoding
) == BFD_RELOC_NONE
))
1079 as_bad (_("invalid or unsupported encoding in .cfi_lsda"));
1080 ignore_rest_of_line ();
1084 if (*input_line_pointer
++ != ',')
1086 as_bad (_(".cfi_lsda requires encoding and symbol arguments"));
1087 ignore_rest_of_line ();
1091 fde
->lsda_encoding
= encoding
;
1093 expression_and_evaluate (&fde
->lsda
);
1094 switch (fde
->lsda
.X_op
)
1099 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
1100 encoding
= DW_EH_PE_omit
;
1103 encoding
= DW_EH_PE_omit
;
1107 fde
->lsda_encoding
= encoding
;
1109 if (encoding
== DW_EH_PE_omit
)
1111 as_bad (_("wrong second argument to .cfi_lsda"));
1112 ignore_rest_of_line ();
1116 demand_empty_rest_of_line ();
1120 dot_cfi_val_encoded_addr (int ignored ATTRIBUTE_UNUSED
)
1122 struct cfi_insn_data
*insn_ptr
;
1125 if (frchain_now
->frch_cfi_data
== NULL
)
1127 as_bad (_("CFI instruction used without previous .cfi_startproc"));
1128 ignore_rest_of_line ();
1132 /* If the last address was not at the current PC, advance to current. */
1133 if (symbol_get_frag (frchain_now
->frch_cfi_data
->last_address
) != frag_now
1134 || (S_GET_VALUE (frchain_now
->frch_cfi_data
->last_address
)
1135 != frag_now_fix ()))
1136 cfi_add_advance_loc (symbol_temp_new_now ());
1138 insn_ptr
= alloc_cfi_insn_data ();
1139 insn_ptr
->insn
= CFI_val_encoded_addr
;
1141 insn_ptr
->u
.ea
.reg
= cfi_parse_reg ();
1143 cfi_parse_separator ();
1144 encoding
= cfi_parse_const ();
1145 if ((encoding
& 0xff) != encoding
1146 || ((encoding
& 0x70) != 0
1147 #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
1148 && (encoding
& 0x70) != DW_EH_PE_pcrel
1151 /* leb128 can be handled, but does something actually need it? */
1152 || (encoding
& 7) == DW_EH_PE_uleb128
1153 || (encoding
& 7) > DW_EH_PE_udata8
)
1155 as_bad (_("invalid or unsupported encoding in .cfi_lsda"));
1156 encoding
= DW_EH_PE_omit
;
1159 cfi_parse_separator ();
1160 expression_and_evaluate (&insn_ptr
->u
.ea
.exp
);
1161 switch (insn_ptr
->u
.ea
.exp
.X_op
)
1166 if ((encoding
& 0x70) != DW_EH_PE_pcrel
)
1170 encoding
= DW_EH_PE_omit
;
1174 insn_ptr
->u
.ea
.encoding
= encoding
;
1175 if (encoding
== DW_EH_PE_omit
)
1177 as_bad (_("wrong third argument to .cfi_val_encoded_addr"));
1178 ignore_rest_of_line ();
1182 demand_empty_rest_of_line ();
1186 dot_cfi_label (int ignored ATTRIBUTE_UNUSED
)
1190 if (frchain_now
->frch_cfi_data
== NULL
)
1192 as_bad (_("CFI instruction used without previous .cfi_startproc"));
1193 ignore_rest_of_line ();
1197 name
= read_symbol_name ();
1201 /* If the last address was not at the current PC, advance to current. */
1202 if (symbol_get_frag (frchain_now
->frch_cfi_data
->last_address
) != frag_now
1203 || (S_GET_VALUE (frchain_now
->frch_cfi_data
->last_address
)
1204 != frag_now_fix ()))
1205 cfi_add_advance_loc (symbol_temp_new_now ());
1207 cfi_add_label (name
);
1210 demand_empty_rest_of_line ();
1214 dot_cfi_sections (int ignored ATTRIBUTE_UNUSED
)
1219 if (is_name_beginner (*input_line_pointer
) || *input_line_pointer
== '"')
1225 saved_ilp
= input_line_pointer
;
1226 c
= get_symbol_name (& name
);
1228 if (startswith (name
, ".eh_frame")
1230 sections
|= CFI_EMIT_eh_frame
;
1231 else if (startswith (name
, ".debug_frame"))
1232 sections
|= CFI_EMIT_debug_frame
;
1233 #if SUPPORT_COMPACT_EH
1234 else if (startswith (name
, ".eh_frame_entry"))
1237 sections
|= CFI_EMIT_eh_frame_compact
;
1240 #ifdef tc_cfi_section_name
1241 else if (strcmp (name
, tc_cfi_section_name
) == 0)
1242 sections
|= CFI_EMIT_target
;
1244 else if (startswith (name
, ".sframe"))
1245 sections
|= CFI_EMIT_sframe
;
1248 *input_line_pointer
= c
;
1249 input_line_pointer
= saved_ilp
;
1253 *input_line_pointer
= c
;
1254 SKIP_WHITESPACE_AFTER_NAME ();
1255 if (*input_line_pointer
== ',')
1257 name
= input_line_pointer
++;
1259 if (!is_name_beginner (*input_line_pointer
)
1260 && *input_line_pointer
!= '"')
1262 input_line_pointer
= name
;
1266 else if (is_name_beginner (*input_line_pointer
)
1267 || *input_line_pointer
== '"')
1271 demand_empty_rest_of_line ();
1272 if (cfi_sections_set
1273 && (sections
& (CFI_EMIT_eh_frame
| CFI_EMIT_eh_frame_compact
))
1274 && ((cfi_sections
& (CFI_EMIT_eh_frame
| CFI_EMIT_eh_frame_compact
))
1275 != (sections
& (CFI_EMIT_eh_frame
| CFI_EMIT_eh_frame_compact
))))
1276 as_bad (_("inconsistent uses of .cfi_sections"));
1277 cfi_sections
= sections
;
1281 dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED
)
1285 if (frchain_now
->frch_cfi_data
!= NULL
)
1287 as_bad (_("previous CFI entry not closed (missing .cfi_endproc)"));
1288 ignore_rest_of_line ();
1292 cfi_new_fde (symbol_temp_new_now ());
1295 if (is_name_beginner (*input_line_pointer
) || *input_line_pointer
== '"')
1297 char * saved_ilp
= input_line_pointer
;
1300 c
= get_symbol_name (& name
);
1302 if (strcmp (name
, "simple") == 0)
1305 restore_line_pointer (c
);
1308 input_line_pointer
= saved_ilp
;
1310 demand_empty_rest_of_line ();
1312 cfi_sections_set
= true;
1313 all_cfi_sections
|= cfi_sections
;
1314 cfi_set_sections ();
1315 frchain_now
->frch_cfi_data
->cur_cfa_offset
= 0;
1317 tc_cfi_frame_initial_instructions ();
1319 if ((cfi_sections
& CFI_EMIT_target
) != 0)
1320 tc_cfi_startproc ();
1324 dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED
)
1326 if (frchain_now
->frch_cfi_data
== NULL
)
1328 as_bad (_(".cfi_endproc without corresponding .cfi_startproc"));
1329 ignore_rest_of_line ();
1333 last_fde
= frchain_now
->frch_cfi_data
->cur_fde_data
;
1335 cfi_end_fde (symbol_temp_new_now ());
1337 demand_empty_rest_of_line ();
1339 cfi_sections_set
= true;
1340 if ((cfi_sections
& CFI_EMIT_target
) != 0)
1341 tc_cfi_endproc (last_fde
);
1345 get_cfi_seg (segT cseg
, const char *base
, flagword flags
, int align
)
1347 /* Exclude .debug_frame sections for Compact EH. */
1348 if (SUPPORT_FRAME_LINKONCE
|| ((flags
& SEC_DEBUGGING
) == 0 && compact_eh
)
1349 || ((flags
& SEC_DEBUGGING
) == 0 && TARGET_MULTIPLE_EH_FRAME_SECTIONS
))
1352 struct dwcfi_seg_list
*l
;
1354 l
= dwcfi_hash_find_or_make (cseg
, base
, flags
);
1357 subseg_set (cseg
, l
->subseg
);
1359 if (TARGET_MULTIPLE_EH_FRAME_SECTIONS
1360 && (flags
& DWARF2_EH_FRAME_READ_ONLY
))
1362 const frchainS
*ifrch
= seg_info (iseg
)->frchainP
;
1363 const frchainS
*frch
= seg_info (cseg
)->frchainP
;
1366 exp
.X_op
= O_symbol
;
1367 exp
.X_add_symbol
= (symbolS
*) local_symbol_make (cseg
->name
, cseg
, frch
->frch_root
, 0);
1368 exp
.X_add_number
= 0;
1369 subseg_set (iseg
, ifrch
->frch_subseg
);
1370 fix_new_exp (ifrch
->frch_root
, 0, 0, &exp
, 0, BFD_RELOC_NONE
);
1372 /* Restore the original segment info. */
1373 subseg_set (cseg
, l
->subseg
);
1378 cseg
= subseg_new (base
, 0);
1379 bfd_set_section_flags (cseg
, flags
);
1381 record_alignment (cseg
, align
);
1385 #if SUPPORT_COMPACT_EH
1387 dot_cfi_personality_id (int ignored ATTRIBUTE_UNUSED
)
1389 struct fde_entry
*fde
;
1391 if (frchain_now
->frch_cfi_data
== NULL
)
1393 as_bad (_("CFI instruction used without previous .cfi_startproc"));
1394 ignore_rest_of_line ();
1398 fde
= frchain_now
->frch_cfi_data
->cur_fde_data
;
1399 fde
->personality_id
= cfi_parse_const ();
1400 demand_empty_rest_of_line ();
1402 if (fde
->personality_id
== 0 || fde
->personality_id
> 3)
1404 as_bad (_("wrong argument to .cfi_personality_id"));
1410 dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED
)
1412 if (frchain_now
->frch_cfi_data
== NULL
)
1414 as_bad (_(".cfi_fde_data without corresponding .cfi_startproc"));
1415 ignore_rest_of_line ();
1419 last_fde
= frchain_now
->frch_cfi_data
->cur_fde_data
;
1421 cfi_sections_set
= true;
1422 if ((cfi_sections
& CFI_EMIT_target
) != 0
1423 || (cfi_sections
& CFI_EMIT_eh_frame_compact
) != 0)
1425 struct cfi_escape_data
*head
, **tail
, *e
;
1429 if (!is_it_end_of_statement ())
1434 e
= XNEW (struct cfi_escape_data
);
1435 do_parse_cons_expression (&e
->exp
, 1);
1440 while (*input_line_pointer
++ == ',');
1441 --input_line_pointer
;
1445 if (last_fde
->lsda_encoding
!= DW_EH_PE_omit
)
1446 last_fde
->eh_header_type
= EH_COMPACT_HAS_LSDA
;
1447 else if (num_ops
<= 3 && last_fde
->per_encoding
== DW_EH_PE_omit
)
1448 last_fde
->eh_header_type
= EH_COMPACT_INLINE
;
1450 last_fde
->eh_header_type
= EH_COMPACT_OUTLINE
;
1452 if (last_fde
->eh_header_type
== EH_COMPACT_INLINE
)
1455 last_fde
->eh_data_size
= num_ops
;
1456 last_fde
->eh_data
= XNEWVEC (bfd_byte
, num_ops
);
1462 last_fde
->eh_data
[num_ops
++] = e
->exp
.X_add_number
;
1465 if (last_fde
->eh_header_type
== EH_COMPACT_INLINE
)
1467 last_fde
->eh_data
[num_ops
++] = tc_compact_eh_opcode_stop
;
1470 demand_empty_rest_of_line ();
1473 /* Function to emit the compact unwinding opcodes stored in the
1474 fde's eh_data field. The end of the opcode data will be
1475 padded to the value in align. */
1478 output_compact_unwind_data (struct fde_entry
*fde
, int align
)
1480 int data_size
= fde
->eh_data_size
+ 2;
1485 fde
->eh_loc
= symbol_temp_new_now ();
1488 if (fde
->personality_id
!= 0)
1489 *p
= fde
->personality_id
;
1490 else if (fde
->per_encoding
!= DW_EH_PE_omit
)
1493 emit_expr_encoded (&fde
->personality
, fde
->per_encoding
, false);
1494 data_size
+= encoding_size (fde
->per_encoding
);
1499 amask
= (1 << align
) - 1;
1500 align_padding
= ((data_size
+ amask
) & ~amask
) - data_size
;
1502 p
= frag_more (fde
->eh_data_size
+ 1 + align_padding
);
1503 memcpy (p
, fde
->eh_data
, fde
->eh_data_size
);
1504 p
+= fde
->eh_data_size
;
1506 while (align_padding
-- > 0)
1507 *(p
++) = tc_compact_eh_opcode_pad
;
1509 *(p
++) = tc_compact_eh_opcode_stop
;
1510 fde
->eh_header_type
= EH_COMPACT_OUTLINE_DONE
;
1513 /* Handle the .cfi_inline_lsda directive. */
1515 dot_cfi_inline_lsda (int ignored ATTRIBUTE_UNUSED
)
1519 long max_alignment
= 28;
1523 as_bad (_("unexpected .cfi_inline_lsda"));
1524 ignore_rest_of_line ();
1528 if ((last_fde
->sections
& CFI_EMIT_eh_frame_compact
) == 0)
1530 as_bad (_(".cfi_inline_lsda not valid for this frame"));
1531 ignore_rest_of_line ();
1535 if (last_fde
->eh_header_type
!= EH_COMPACT_UNKNOWN
1536 && last_fde
->eh_header_type
!= EH_COMPACT_HAS_LSDA
)
1538 as_bad (_(".cfi_inline_lsda seen for frame without .cfi_lsda"));
1539 ignore_rest_of_line ();
1543 #ifdef md_flush_pending_output
1544 md_flush_pending_output ();
1547 align
= get_absolute_expression ();
1548 if (align
> max_alignment
)
1550 align
= max_alignment
;
1551 as_bad (_("Alignment too large: %d. assumed."), align
);
1555 as_warn (_("Alignment negative: 0 assumed."));
1559 demand_empty_rest_of_line ();
1560 ccseg
= CUR_SEG (last_fde
);
1562 /* Open .gnu_extab section. */
1563 get_cfi_seg (ccseg
, ".gnu_extab",
1564 (SEC_ALLOC
| SEC_LOAD
| SEC_DATA
1565 | DWARF2_EH_FRAME_READ_ONLY
),
1568 frag_align (align
, 0, 0);
1569 record_alignment (now_seg
, align
);
1570 if (last_fde
->eh_header_type
== EH_COMPACT_HAS_LSDA
)
1571 output_compact_unwind_data (last_fde
, align
);
1577 #else /* !SUPPORT_COMPACT_EH */
1579 dot_cfi_inline_lsda (int ignored ATTRIBUTE_UNUSED
)
1581 as_bad (_(".cfi_inline_lsda is not supported for this target"));
1582 ignore_rest_of_line ();
1586 dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED
)
1588 as_bad (_(".cfi_fde_data is not supported for this target"));
1589 ignore_rest_of_line ();
1593 dot_cfi_personality_id (int ignored ATTRIBUTE_UNUSED
)
1595 as_bad (_(".cfi_personality_id is not supported for this target"));
1596 ignore_rest_of_line ();
1601 output_cfi_insn (struct cfi_insn_data
*insn
)
1608 case DW_CFA_advance_loc
:
1610 symbolS
*from
= insn
->u
.ll
.lab1
;
1611 symbolS
*to
= insn
->u
.ll
.lab2
;
1613 if (symbol_get_frag (to
) == symbol_get_frag (from
))
1615 addressT delta
= S_GET_VALUE (to
) - S_GET_VALUE (from
);
1616 addressT scaled
= delta
/ DWARF2_LINE_MIN_INSN_LENGTH
;
1620 else if (scaled
<= 0x3F)
1621 out_one (DW_CFA_advance_loc
+ scaled
);
1622 else if (scaled
<= 0xFF)
1624 out_one (DW_CFA_advance_loc1
);
1627 else if (scaled
<= 0xFFFF)
1629 out_one (DW_CFA_advance_loc2
);
1634 out_one (DW_CFA_advance_loc4
);
1642 exp
.X_op
= O_subtract
;
1643 exp
.X_add_symbol
= to
;
1644 exp
.X_op_symbol
= from
;
1645 exp
.X_add_number
= 0;
1647 /* The code in ehopt.c expects that one byte of the encoding
1648 is already allocated to the frag. This comes from the way
1649 that it scans the .eh_frame section looking first for the
1650 .byte DW_CFA_advance_loc4. Call frag_grow with the sum of
1651 room needed by frag_more and frag_var to preallocate space
1652 ensuring that the DW_CFA_advance_loc4 is in the fixed part
1653 of the rs_cfa frag, so that the relax machinery can remove
1654 the advance_loc should it advance by zero. */
1656 *frag_more (1) = DW_CFA_advance_loc4
;
1658 frag_var (rs_cfa
, 4, 0, DWARF2_LINE_MIN_INSN_LENGTH
<< 3,
1659 make_expr_symbol (&exp
), frag_now_fix () - 1,
1665 case DW_CFA_def_cfa
:
1666 offset
= insn
->u
.ri
.offset
;
1669 out_one (DW_CFA_def_cfa_sf
);
1670 out_uleb128 (insn
->u
.ri
.reg
);
1671 out_sleb128 (offset
/ DWARF2_CIE_DATA_ALIGNMENT
);
1675 out_one (DW_CFA_def_cfa
);
1676 out_uleb128 (insn
->u
.ri
.reg
);
1677 out_uleb128 (offset
);
1681 case DW_CFA_def_cfa_register
:
1682 case DW_CFA_undefined
:
1683 case DW_CFA_same_value
:
1684 out_one (insn
->insn
);
1685 out_uleb128 (insn
->u
.r
);
1688 case DW_CFA_def_cfa_offset
:
1692 out_one (DW_CFA_def_cfa_offset_sf
);
1693 out_sleb128 (offset
/ DWARF2_CIE_DATA_ALIGNMENT
);
1697 out_one (DW_CFA_def_cfa_offset
);
1698 out_uleb128 (offset
);
1702 case DW_CFA_restore
:
1706 out_one (DW_CFA_restore
+ regno
);
1710 out_one (DW_CFA_restore_extended
);
1711 out_uleb128 (regno
);
1716 regno
= insn
->u
.ri
.reg
;
1717 offset
= insn
->u
.ri
.offset
/ DWARF2_CIE_DATA_ALIGNMENT
;
1720 out_one (DW_CFA_offset_extended_sf
);
1721 out_uleb128 (regno
);
1722 out_sleb128 (offset
);
1724 else if (regno
<= 0x3F)
1726 out_one (DW_CFA_offset
+ regno
);
1727 out_uleb128 (offset
);
1731 out_one (DW_CFA_offset_extended
);
1732 out_uleb128 (regno
);
1733 out_uleb128 (offset
);
1737 case DW_CFA_val_offset
:
1738 regno
= insn
->u
.ri
.reg
;
1739 offset
= insn
->u
.ri
.offset
/ DWARF2_CIE_DATA_ALIGNMENT
;
1742 out_one (DW_CFA_val_offset_sf
);
1743 out_uleb128 (regno
);
1744 out_sleb128 (offset
);
1748 out_one (DW_CFA_val_offset
);
1749 out_uleb128 (regno
);
1750 out_uleb128 (offset
);
1754 case DW_CFA_register
:
1755 out_one (DW_CFA_register
);
1756 out_uleb128 (insn
->u
.rr
.reg1
);
1757 out_uleb128 (insn
->u
.rr
.reg2
);
1760 case DW_CFA_remember_state
:
1761 case DW_CFA_restore_state
:
1762 out_one (insn
->insn
);
1765 case DW_CFA_GNU_window_save
:
1766 out_one (DW_CFA_GNU_window_save
);
1771 struct cfi_escape_data
*e
;
1772 for (e
= insn
->u
.esc
; e
; e
= e
->next
)
1773 emit_expr (&e
->exp
, 1);
1777 case CFI_val_encoded_addr
:
1779 unsigned encoding
= insn
->u
.ea
.encoding
;
1782 if (encoding
== DW_EH_PE_omit
)
1784 out_one (DW_CFA_val_expression
);
1785 out_uleb128 (insn
->u
.ea
.reg
);
1787 switch (encoding
& 0x7)
1789 case DW_EH_PE_absptr
:
1790 enc_size
= DWARF2_ADDR_SIZE (stdoutput
);
1792 case DW_EH_PE_udata2
:
1795 case DW_EH_PE_udata4
:
1798 case DW_EH_PE_udata8
:
1805 /* If the user has requested absolute encoding,
1806 then use the smaller DW_OP_addr encoding. */
1807 if (insn
->u
.ea
.encoding
== DW_EH_PE_absptr
)
1809 out_uleb128 (1 + enc_size
);
1810 out_one (DW_OP_addr
);
1814 out_uleb128 (1 + 1 + enc_size
);
1815 out_one (DW_OP_GNU_encoded_addr
);
1818 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
1820 #if CFI_DIFF_EXPR_OK
1821 insn
->u
.ea
.exp
.X_op
= O_subtract
;
1822 insn
->u
.ea
.exp
.X_op_symbol
= symbol_temp_new_now ();
1823 #elif defined (tc_cfi_emit_pcrel_expr)
1824 tc_cfi_emit_pcrel_expr (&insn
->u
.ea
.exp
, enc_size
);
1831 emit_expr (&insn
->u
.ea
.exp
, enc_size
);
1836 colon (insn
->u
.sym_name
);
1845 output_cie (struct cie_entry
*cie
, bool eh_frame
, int align
)
1847 symbolS
*after_size_address
, *end_address
;
1849 struct cfi_insn_data
*i
;
1850 offsetT augmentation_size
;
1852 enum dwarf2_format fmt
= DWARF2_FORMAT (now_seg
);
1854 cie
->start_address
= symbol_temp_new_now ();
1855 after_size_address
= symbol_temp_make ();
1856 end_address
= symbol_temp_make ();
1858 exp
.X_op
= O_subtract
;
1859 exp
.X_add_symbol
= end_address
;
1860 exp
.X_op_symbol
= after_size_address
;
1861 exp
.X_add_number
= 0;
1863 if (eh_frame
|| fmt
== dwarf2_format_32bit
)
1864 emit_expr (&exp
, 4); /* Length. */
1867 if (fmt
== dwarf2_format_64bit
)
1869 emit_expr (&exp
, 8); /* Length. */
1871 symbol_set_value_now (after_size_address
);
1873 out_four (0); /* CIE id. */
1876 out_four (-1); /* CIE id. */
1877 if (fmt
!= dwarf2_format_32bit
)
1880 out_one (flag_dwarf_cie_version
); /* Version. */
1883 out_one ('z'); /* Augmentation. */
1884 if (cie
->per_encoding
!= DW_EH_PE_omit
)
1886 if (cie
->lsda_encoding
!= DW_EH_PE_omit
)
1889 #ifdef tc_output_cie_extra
1890 tc_output_cie_extra (cie
);
1893 if (cie
->signal_frame
)
1896 if (flag_dwarf_cie_version
>= 4)
1898 /* For now we are assuming a flat address space with 4 or 8 byte
1900 int address_size
= dwarf2_format_32bit
? 4 : 8;
1901 out_one (address_size
); /* Address size. */
1902 out_one (0); /* Segment size. */
1904 out_uleb128 (DWARF2_LINE_MIN_INSN_LENGTH
); /* Code alignment. */
1905 out_sleb128 (DWARF2_CIE_DATA_ALIGNMENT
); /* Data alignment. */
1906 if (flag_dwarf_cie_version
== 1) /* Return column. */
1908 if ((cie
->return_column
& 0xff) != cie
->return_column
)
1909 as_bad (_("return column number %d overflows in CIE version 1"),
1910 cie
->return_column
);
1911 out_one (cie
->return_column
);
1914 out_uleb128 (cie
->return_column
);
1917 augmentation_size
= 1 + (cie
->lsda_encoding
!= DW_EH_PE_omit
);
1918 if (cie
->per_encoding
!= DW_EH_PE_omit
)
1919 augmentation_size
+= 1 + encoding_size (cie
->per_encoding
);
1920 out_uleb128 (augmentation_size
); /* Augmentation size. */
1922 emit_expr_encoded (&cie
->personality
, cie
->per_encoding
, true);
1924 if (cie
->lsda_encoding
!= DW_EH_PE_omit
)
1925 out_one (cie
->lsda_encoding
);
1928 switch (DWARF2_FDE_RELOC_SIZE
)
1931 enc
= DW_EH_PE_sdata2
;
1934 enc
= DW_EH_PE_sdata4
;
1937 enc
= DW_EH_PE_sdata8
;
1942 #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
1943 enc
|= DW_EH_PE_pcrel
;
1945 #ifdef DWARF2_FDE_RELOC_ENCODING
1946 /* Allow target to override encoding. */
1947 enc
= DWARF2_FDE_RELOC_ENCODING (enc
);
1949 cie
->fde_encoding
= enc
;
1955 for (i
= cie
->first
; i
!= cie
->last
; i
= i
->next
)
1957 if (CUR_SEG (i
) != CUR_SEG (cie
))
1959 output_cfi_insn (i
);
1963 frag_align (align
, DW_CFA_nop
, 0);
1964 symbol_set_value_now (end_address
);
1968 output_fde (struct fde_entry
*fde
, struct cie_entry
*cie
,
1969 bool eh_frame
, struct cfi_insn_data
*first
,
1972 symbolS
*after_size_address
, *end_address
;
1974 offsetT augmentation_size
;
1975 enum dwarf2_format fmt
= DWARF2_FORMAT (now_seg
);
1976 unsigned int offset_size
;
1977 unsigned int addr_size
;
1979 after_size_address
= symbol_temp_make ();
1980 end_address
= symbol_temp_make ();
1982 exp
.X_op
= O_subtract
;
1983 exp
.X_add_symbol
= end_address
;
1984 exp
.X_op_symbol
= after_size_address
;
1985 exp
.X_add_number
= 0;
1986 if (eh_frame
|| fmt
== dwarf2_format_32bit
)
1990 if (fmt
== dwarf2_format_64bit
)
1994 emit_expr (&exp
, offset_size
); /* Length. */
1995 symbol_set_value_now (after_size_address
);
1999 exp
.X_op
= O_subtract
;
2000 exp
.X_add_symbol
= after_size_address
;
2001 exp
.X_op_symbol
= cie
->start_address
;
2002 exp
.X_add_number
= 0;
2003 emit_expr (&exp
, offset_size
); /* CIE offset. */
2007 TC_DWARF2_EMIT_OFFSET (cie
->start_address
, offset_size
);
2010 exp
.X_op
= O_symbol
;
2013 bfd_reloc_code_real_type code
2014 = tc_cfi_reloc_for_encoding (cie
->fde_encoding
);
2015 addr_size
= DWARF2_FDE_RELOC_SIZE
;
2016 if (code
!= BFD_RELOC_NONE
)
2018 reloc_howto_type
*howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2019 char *p
= frag_more (addr_size
);
2020 gas_assert (addr_size
== (unsigned) howto
->bitsize
/ 8);
2021 md_number_to_chars (p
, 0, addr_size
);
2022 fix_new (frag_now
, p
- frag_now
->fr_literal
, addr_size
,
2023 fde
->start_address
, 0, howto
->pc_relative
, code
);
2027 exp
.X_op
= O_subtract
;
2028 exp
.X_add_number
= 0;
2029 #if CFI_DIFF_EXPR_OK
2030 exp
.X_add_symbol
= fde
->start_address
;
2031 exp
.X_op_symbol
= symbol_temp_new_now ();
2032 emit_expr (&exp
, addr_size
); /* Code offset. */
2034 exp
.X_op
= O_symbol
;
2035 exp
.X_add_symbol
= fde
->start_address
;
2037 #if defined(tc_cfi_emit_pcrel_expr)
2038 tc_cfi_emit_pcrel_expr (&exp
, addr_size
); /* Code offset. */
2040 emit_expr (&exp
, addr_size
); /* Code offset. */
2047 exp
.X_add_number
= 0;
2048 exp
.X_add_symbol
= fde
->start_address
;
2049 addr_size
= DWARF2_ADDR_SIZE (stdoutput
);
2050 emit_expr (&exp
, addr_size
);
2053 exp
.X_op
= O_subtract
;
2054 exp
.X_add_symbol
= fde
->end_address
;
2055 exp
.X_op_symbol
= fde
->start_address
; /* Code length. */
2056 exp
.X_add_number
= 0;
2057 emit_expr (&exp
, addr_size
);
2059 augmentation_size
= encoding_size (fde
->lsda_encoding
);
2061 out_uleb128 (augmentation_size
); /* Augmentation size. */
2063 emit_expr_encoded (&fde
->lsda
, cie
->lsda_encoding
, false);
2065 for (; first
; first
= first
->next
)
2066 if (CUR_SEG (first
) == CUR_SEG (fde
))
2067 output_cfi_insn (first
);
2069 frag_align (align
, DW_CFA_nop
, 0);
2070 symbol_set_value_now (end_address
);
2073 /* Allow these insns to be put in the initial sequence of a CIE.
2074 If J is non-NULL, then compare I and J insns for a match. */
2077 initial_cie_insn (const struct cfi_insn_data
*i
, const struct cfi_insn_data
*j
)
2079 if (j
&& i
->insn
!= j
->insn
)
2084 case DW_CFA_def_cfa
:
2085 case DW_CFA_val_offset
:
2088 if (i
->u
.ri
.reg
!= j
->u
.ri
.reg
)
2090 if (i
->u
.ri
.offset
!= j
->u
.ri
.offset
)
2095 case DW_CFA_register
:
2098 if (i
->u
.rr
.reg1
!= j
->u
.rr
.reg1
)
2100 if (i
->u
.rr
.reg2
!= j
->u
.rr
.reg2
)
2105 case DW_CFA_def_cfa_register
:
2106 case DW_CFA_restore
:
2107 case DW_CFA_undefined
:
2108 case DW_CFA_same_value
:
2111 if (i
->u
.r
!= j
->u
.r
)
2116 case DW_CFA_def_cfa_offset
:
2119 if (i
->u
.i
!= j
->u
.i
)
2130 static struct cie_entry
*
2131 select_cie_for_fde (struct fde_entry
*fde
, bool eh_frame
,
2132 struct cfi_insn_data
**pfirst
, int align
)
2134 struct cfi_insn_data
*i
, *j
;
2135 struct cie_entry
*cie
;
2137 for (cie
= cie_root
; cie
; cie
= cie
->next
)
2139 if (CUR_SEG (cie
) != CUR_SEG (fde
))
2141 #ifdef tc_cie_fde_equivalent_extra
2142 if (!tc_cie_fde_equivalent_extra (cie
, fde
))
2145 if (cie
->return_column
!= fde
->return_column
2146 || cie
->signal_frame
!= fde
->signal_frame
2147 || cie
->per_encoding
!= fde
->per_encoding
2148 || cie
->lsda_encoding
!= fde
->lsda_encoding
)
2150 if (cie
->per_encoding
!= DW_EH_PE_omit
)
2152 if (cie
->personality
.X_op
!= fde
->personality
.X_op
2153 || (cie
->personality
.X_add_number
2154 != fde
->personality
.X_add_number
))
2156 switch (cie
->personality
.X_op
)
2159 if (cie
->personality
.X_unsigned
!= fde
->personality
.X_unsigned
)
2163 if (cie
->personality
.X_add_symbol
2164 != fde
->personality
.X_add_symbol
)
2171 for (i
= cie
->first
, j
= fde
->data
;
2172 i
!= cie
->last
&& j
!= NULL
;
2173 i
= i
->next
, j
= j
->next
)
2175 if (!initial_cie_insn (i
, j
))
2186 cie
= XNEW (struct cie_entry
);
2187 cie
->next
= cie_root
;
2189 SET_CUR_SEG (cie
, CUR_SEG (fde
));
2190 cie
->return_column
= fde
->return_column
;
2191 cie
->signal_frame
= fde
->signal_frame
;
2192 cie
->per_encoding
= fde
->per_encoding
;
2193 cie
->lsda_encoding
= fde
->lsda_encoding
;
2194 cie
->personality
= fde
->personality
;
2195 cie
->first
= fde
->data
;
2196 #ifdef tc_cie_entry_init_extra
2197 tc_cie_entry_init_extra (cie
, fde
)
2200 for (i
= cie
->first
; i
; i
= i
->next
)
2201 if (!initial_cie_insn (i
, NULL
))
2207 output_cie (cie
, eh_frame
, align
);
2212 #ifdef md_reg_eh_frame_to_debug_frame
2214 cfi_change_reg_numbers (struct cfi_insn_data
*insn
, segT ccseg
)
2216 for (; insn
; insn
= insn
->next
)
2218 if (CUR_SEG (insn
) != ccseg
)
2222 case DW_CFA_advance_loc
:
2223 case DW_CFA_def_cfa_offset
:
2224 case DW_CFA_remember_state
:
2225 case DW_CFA_restore_state
:
2226 case DW_CFA_GNU_window_save
:
2231 case DW_CFA_def_cfa
:
2233 insn
->u
.ri
.reg
= md_reg_eh_frame_to_debug_frame (insn
->u
.ri
.reg
);
2236 case DW_CFA_def_cfa_register
:
2237 case DW_CFA_undefined
:
2238 case DW_CFA_same_value
:
2239 case DW_CFA_restore
:
2240 insn
->u
.r
= md_reg_eh_frame_to_debug_frame (insn
->u
.r
);
2243 case DW_CFA_register
:
2244 insn
->u
.rr
.reg1
= md_reg_eh_frame_to_debug_frame (insn
->u
.rr
.reg1
);
2245 insn
->u
.rr
.reg2
= md_reg_eh_frame_to_debug_frame (insn
->u
.rr
.reg2
);
2248 case CFI_val_encoded_addr
:
2249 insn
->u
.ea
.reg
= md_reg_eh_frame_to_debug_frame (insn
->u
.ea
.reg
);
2258 #define cfi_change_reg_numbers(insn, cseg) do { } while (0)
2261 #if SUPPORT_COMPACT_EH
2263 cfi_emit_eh_header (symbolS
*sym
, bfd_vma addend
)
2267 exp
.X_add_number
= addend
;
2268 exp
.X_add_symbol
= sym
;
2269 emit_expr_encoded (&exp
, DW_EH_PE_sdata4
| DW_EH_PE_pcrel
, false);
2273 output_eh_header (struct fde_entry
*fde
)
2278 if (fde
->eh_header_type
== EH_COMPACT_INLINE
)
2283 cfi_emit_eh_header (fde
->start_address
, addend
);
2285 if (fde
->eh_header_type
== EH_COMPACT_INLINE
)
2288 /* Inline entries always use PR1. */
2290 memcpy(p
, fde
->eh_data
, 3);
2294 if (fde
->eh_header_type
== EH_COMPACT_LEGACY
)
2296 else if (fde
->eh_header_type
== EH_COMPACT_OUTLINE
2297 || fde
->eh_header_type
== EH_COMPACT_OUTLINE_DONE
)
2301 cfi_emit_eh_header (fde
->eh_loc
, addend
);
2309 struct cie_entry
*cie
, *cie_next
;
2310 segT cfi_seg
, ccseg
;
2311 struct fde_entry
*fde
;
2312 struct cfi_insn_data
*first
;
2313 int save_flag_traditional_format
, seek_next_seg
;
2315 if (all_fde_data
== 0)
2318 cfi_sections_set
= true;
2319 if ((all_cfi_sections
& CFI_EMIT_eh_frame
) != 0
2320 || (all_cfi_sections
& CFI_EMIT_eh_frame_compact
) != 0)
2322 /* Make sure check_eh_frame doesn't do anything with our output. */
2323 save_flag_traditional_format
= flag_traditional_format
;
2324 flag_traditional_format
= 1;
2326 if (!EH_FRAME_LINKONCE
)
2328 /* Open .eh_frame section. */
2329 cfi_seg
= get_cfi_seg (NULL
, ".eh_frame",
2330 (SEC_ALLOC
| SEC_LOAD
| SEC_DATA
2331 | DWARF2_EH_FRAME_READ_ONLY
),
2332 EH_FRAME_ALIGNMENT
);
2333 #ifdef md_fix_up_eh_frame
2334 md_fix_up_eh_frame (cfi_seg
);
2345 for (cie
= cie_root
; cie
; cie
= cie_next
)
2347 cie_next
= cie
->next
;
2348 free ((void *) cie
);
2352 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
2354 if ((fde
->sections
& CFI_EMIT_eh_frame
) == 0
2355 && (fde
->sections
& CFI_EMIT_eh_frame_compact
) == 0)
2358 #if SUPPORT_COMPACT_EH
2359 /* Emit a LEGACY format header if we have processed all
2360 of the .cfi directives without encountering either inline or
2361 out-of-line compact unwinding opcodes. */
2362 if (fde
->eh_header_type
== EH_COMPACT_HAS_LSDA
2363 || fde
->eh_header_type
== EH_COMPACT_UNKNOWN
)
2364 fde
->eh_header_type
= EH_COMPACT_LEGACY
;
2366 if (fde
->eh_header_type
!= EH_COMPACT_LEGACY
)
2369 if (EH_FRAME_LINKONCE
)
2373 if (seek_next_seg
&& CUR_SEG (fde
) != ccseg
)
2380 ccseg
= CUR_SEG (fde
);
2381 /* Open .eh_frame section. */
2382 cfi_seg
= get_cfi_seg (ccseg
, ".eh_frame",
2383 (SEC_ALLOC
| SEC_LOAD
| SEC_DATA
2384 | DWARF2_EH_FRAME_READ_ONLY
),
2385 EH_FRAME_ALIGNMENT
);
2386 #ifdef md_fix_up_eh_frame
2387 md_fix_up_eh_frame (cfi_seg
);
2393 SET_HANDLED (fde
, 1);
2396 if (fde
->end_address
== NULL
)
2398 as_bad (_("open CFI at the end of file; "
2399 "missing .cfi_endproc directive"));
2400 fde
->end_address
= fde
->start_address
;
2403 cie
= select_cie_for_fde (fde
, true, &first
, 2);
2404 fde
->eh_loc
= symbol_temp_new_now ();
2405 output_fde (fde
, cie
, true, first
,
2406 fde
->next
== NULL
? EH_FRAME_ALIGNMENT
: 2);
2409 while (EH_FRAME_LINKONCE
&& seek_next_seg
== 2);
2411 if (EH_FRAME_LINKONCE
)
2412 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
2413 SET_HANDLED (fde
, 0);
2415 #if SUPPORT_COMPACT_EH
2418 /* Create remaining out of line table entries. */
2424 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
2426 if ((fde
->sections
& CFI_EMIT_eh_frame
) == 0
2427 && (fde
->sections
& CFI_EMIT_eh_frame_compact
) == 0)
2430 if (fde
->eh_header_type
!= EH_COMPACT_OUTLINE
)
2434 if (seek_next_seg
&& CUR_SEG (fde
) != ccseg
)
2441 ccseg
= CUR_SEG (fde
);
2442 /* Open .gnu_extab section. */
2443 get_cfi_seg (ccseg
, ".gnu_extab",
2444 (SEC_ALLOC
| SEC_LOAD
| SEC_DATA
2445 | DWARF2_EH_FRAME_READ_ONLY
),
2449 SET_HANDLED (fde
, 1);
2451 frag_align (1, 0, 0);
2452 record_alignment (now_seg
, 1);
2453 output_compact_unwind_data (fde
, 1);
2456 while (EH_FRAME_LINKONCE
&& seek_next_seg
== 2);
2458 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
2459 SET_HANDLED (fde
, 0);
2461 /* Create index table fragments. */
2467 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
2469 if ((fde
->sections
& CFI_EMIT_eh_frame
) == 0
2470 && (fde
->sections
& CFI_EMIT_eh_frame_compact
) == 0)
2475 if (seek_next_seg
&& CUR_SEG (fde
) != ccseg
)
2482 ccseg
= CUR_SEG (fde
);
2483 /* Open .eh_frame_entry section. */
2484 cfi_seg
= get_cfi_seg (ccseg
, ".eh_frame_entry",
2485 (SEC_ALLOC
| SEC_LOAD
| SEC_DATA
2486 | DWARF2_EH_FRAME_READ_ONLY
),
2490 SET_HANDLED (fde
, 1);
2492 output_eh_header (fde
);
2495 while (seek_next_seg
== 2);
2497 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
2498 SET_HANDLED (fde
, 0);
2500 #endif /* SUPPORT_COMPACT_EH */
2502 flag_traditional_format
= save_flag_traditional_format
;
2505 cfi_sections_set
= true;
2506 /* Generate SFrame section if the user specifies:
2507 - the command line option to gas, or
2508 - .sframe in the .cfi_sections directive. */
2509 if (flag_gen_sframe
|| (all_cfi_sections
& CFI_EMIT_sframe
) != 0)
2511 if (support_sframe_p ())
2514 int alignment
= ffs (DWARF2_ADDR_SIZE (stdoutput
)) - 1;
2516 if (!SUPPORT_FRAME_LINKONCE
)
2517 sframe_seg
= get_cfi_seg (NULL
, ".sframe",
2518 (SEC_ALLOC
| SEC_LOAD
| SEC_DATA
2519 | DWARF2_EH_FRAME_READ_ONLY
),
2521 output_sframe (sframe_seg
);
2524 as_bad (_(".sframe not supported for target"));
2527 cfi_sections_set
= true;
2528 if ((all_cfi_sections
& CFI_EMIT_debug_frame
) != 0)
2530 int alignment
= ffs (DWARF2_ADDR_SIZE (stdoutput
)) - 1;
2532 if (!SUPPORT_FRAME_LINKONCE
)
2533 get_cfi_seg (NULL
, ".debug_frame",
2534 SEC_READONLY
| SEC_DEBUGGING
,
2542 for (cie
= cie_root
; cie
; cie
= cie_next
)
2544 cie_next
= cie
->next
;
2545 free ((void *) cie
);
2549 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
2551 if ((fde
->sections
& CFI_EMIT_debug_frame
) == 0)
2554 if (SUPPORT_FRAME_LINKONCE
)
2558 if (seek_next_seg
&& CUR_SEG (fde
) != ccseg
)
2565 ccseg
= CUR_SEG (fde
);
2566 /* Open .debug_frame section. */
2567 get_cfi_seg (ccseg
, ".debug_frame",
2568 SEC_READONLY
| SEC_DEBUGGING
,
2572 SET_HANDLED (fde
, 1);
2574 if (fde
->end_address
== NULL
)
2576 as_bad (_("open CFI at the end of file; "
2577 "missing .cfi_endproc directive"));
2578 fde
->end_address
= fde
->start_address
;
2581 fde
->per_encoding
= DW_EH_PE_omit
;
2582 fde
->lsda_encoding
= DW_EH_PE_omit
;
2583 cfi_change_reg_numbers (fde
->data
, ccseg
);
2584 cie
= select_cie_for_fde (fde
, false, &first
, alignment
);
2585 output_fde (fde
, cie
, false, first
, alignment
);
2588 while (SUPPORT_FRAME_LINKONCE
&& seek_next_seg
== 2);
2590 if (SUPPORT_FRAME_LINKONCE
)
2591 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
2592 SET_HANDLED (fde
, 0);
2595 htab_delete (dwcfi_hash
);
2598 #else /* TARGET_USE_CFIPOP */
2600 /* Emit an intelligible error message for missing support. */
2603 dot_cfi_dummy (int ignored ATTRIBUTE_UNUSED
)
2605 as_bad (_("CFI is not supported for this target"));
2606 ignore_rest_of_line ();
2609 const pseudo_typeS cfi_pseudo_table
[] =
2611 { "cfi_sections", dot_cfi_dummy
, 0 },
2612 { "cfi_startproc", dot_cfi_dummy
, 0 },
2613 { "cfi_endproc", dot_cfi_dummy
, 0 },
2614 { "cfi_fde_data", dot_cfi_dummy
, 0 },
2615 { "cfi_def_cfa", dot_cfi_dummy
, 0 },
2616 { "cfi_def_cfa_register", dot_cfi_dummy
, 0 },
2617 { "cfi_def_cfa_offset", dot_cfi_dummy
, 0 },
2618 { "cfi_adjust_cfa_offset", dot_cfi_dummy
, 0 },
2619 { "cfi_offset", dot_cfi_dummy
, 0 },
2620 { "cfi_rel_offset", dot_cfi_dummy
, 0 },
2621 { "cfi_register", dot_cfi_dummy
, 0 },
2622 { "cfi_return_column", dot_cfi_dummy
, 0 },
2623 { "cfi_restore", dot_cfi_dummy
, 0 },
2624 { "cfi_undefined", dot_cfi_dummy
, 0 },
2625 { "cfi_same_value", dot_cfi_dummy
, 0 },
2626 { "cfi_remember_state", dot_cfi_dummy
, 0 },
2627 { "cfi_restore_state", dot_cfi_dummy
, 0 },
2628 { "cfi_window_save", dot_cfi_dummy
, 0 },
2629 { "cfi_escape", dot_cfi_dummy
, 0 },
2630 { "cfi_signal_frame", dot_cfi_dummy
, 0 },
2631 { "cfi_personality", dot_cfi_dummy
, 0 },
2632 { "cfi_personality_id", dot_cfi_dummy
, 0 },
2633 { "cfi_lsda", dot_cfi_dummy
, 0 },
2634 { "cfi_val_encoded_addr", dot_cfi_dummy
, 0 },
2635 { "cfi_label", dot_cfi_dummy
, 0 },
2636 { "cfi_inline_lsda", dot_cfi_dummy
, 0 },
2637 { "cfi_val_offset", dot_cfi_dummy
, 0 },
2645 #endif /* TARGET_USE_CFIPOP */