1 /* dw2gencfi.c - Support for generating Dwarf2 CFI information.
2 Copyright 2003, 2004, 2005 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 2, 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"
26 /* We re-use DWARF2_LINE_MIN_INSN_LENGTH for the code alignment field
27 of the CIE. Default to 1 if not otherwise specified. */
28 #ifndef DWARF2_LINE_MIN_INSN_LENGTH
29 # define DWARF2_LINE_MIN_INSN_LENGTH 1
32 /* If TARGET_USE_CFIPOP is defined, it is required that the target
33 provide the following definitions. Otherwise provide them to
34 allow compilation to continue. */
35 #ifndef TARGET_USE_CFIPOP
36 # ifndef DWARF2_DEFAULT_RETURN_COLUMN
37 # define DWARF2_DEFAULT_RETURN_COLUMN 0
39 # ifndef DWARF2_CIE_DATA_ALIGNMENT
40 # define DWARF2_CIE_DATA_ALIGNMENT 1
44 #ifndef EH_FRAME_ALIGNMENT
45 # define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2)
48 #ifndef tc_cfi_frame_initial_instructions
49 # define tc_cfi_frame_initial_instructions() ((void)0)
55 struct cfi_insn_data
*next
;
76 struct cfi_escape_data
{
77 struct cfi_escape_data
*next
;
85 struct fde_entry
*next
;
86 symbolS
*start_address
;
88 struct cfi_insn_data
*data
;
89 struct cfi_insn_data
**last
;
90 unsigned int return_column
;
95 struct cie_entry
*next
;
96 symbolS
*start_address
;
97 unsigned int return_column
;
98 struct cfi_insn_data
*first
, *last
;
102 /* Current open FDE entry. */
103 static struct fde_entry
*cur_fde_data
;
104 static symbolS
*last_address
;
105 static offsetT cur_cfa_offset
;
107 /* List of FDE entries. */
108 static struct fde_entry
*all_fde_data
;
109 static struct fde_entry
**last_fde_data
= &all_fde_data
;
111 /* List of CIEs so that they could be reused. */
112 static struct cie_entry
*cie_root
;
114 /* Stack of old CFI data, for save/restore. */
117 struct cfa_save_data
*next
;
121 static struct cfa_save_data
*cfa_save_stack
;
123 /* Construct a new FDE structure and add it to the end of the fde list. */
125 static struct fde_entry
*
126 alloc_fde_entry (void)
128 struct fde_entry
*fde
= xcalloc (1, sizeof (struct fde_entry
));
131 *last_fde_data
= fde
;
132 last_fde_data
= &fde
->next
;
134 fde
->last
= &fde
->data
;
135 fde
->return_column
= DWARF2_DEFAULT_RETURN_COLUMN
;
140 /* The following functions are available for a backend to construct its
141 own unwind information, usually from legacy unwind directives. */
143 /* Construct a new INSN structure and add it to the end of the insn list
144 for the currently active FDE. */
146 static struct cfi_insn_data
*
147 alloc_cfi_insn_data (void)
149 struct cfi_insn_data
*insn
= xcalloc (1, sizeof (struct cfi_insn_data
));
151 *cur_fde_data
->last
= insn
;
152 cur_fde_data
->last
= &insn
->next
;
157 /* Construct a new FDE structure that begins at LABEL. */
160 cfi_new_fde (symbolS
*label
)
162 struct fde_entry
*fde
= alloc_fde_entry ();
163 fde
->start_address
= label
;
164 last_address
= label
;
167 /* End the currently open FDE. */
170 cfi_end_fde (symbolS
*label
)
172 cur_fde_data
->end_address
= label
;
176 /* Set the return column for the current FDE. */
179 cfi_set_return_column (unsigned regno
)
181 cur_fde_data
->return_column
= regno
;
184 /* Universal functions to store new instructions. */
187 cfi_add_CFA_insn(int insn
)
189 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
191 insn_ptr
->insn
= insn
;
195 cfi_add_CFA_insn_reg (int insn
, unsigned regno
)
197 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
199 insn_ptr
->insn
= insn
;
200 insn_ptr
->u
.r
= regno
;
204 cfi_add_CFA_insn_offset (int insn
, offsetT offset
)
206 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
208 insn_ptr
->insn
= insn
;
209 insn_ptr
->u
.i
= offset
;
213 cfi_add_CFA_insn_reg_reg (int insn
, unsigned reg1
, unsigned reg2
)
215 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
217 insn_ptr
->insn
= insn
;
218 insn_ptr
->u
.rr
.reg1
= reg1
;
219 insn_ptr
->u
.rr
.reg2
= reg2
;
223 cfi_add_CFA_insn_reg_offset (int insn
, unsigned regno
, offsetT offset
)
225 struct cfi_insn_data
*insn_ptr
= alloc_cfi_insn_data ();
227 insn_ptr
->insn
= insn
;
228 insn_ptr
->u
.ri
.reg
= regno
;
229 insn_ptr
->u
.ri
.offset
= offset
;
232 /* Add a CFI insn to advance the PC from the last address to LABEL. */
235 cfi_add_advance_loc (symbolS
*label
)
237 struct cfi_insn_data
*insn
= alloc_cfi_insn_data ();
239 insn
->insn
= DW_CFA_advance_loc
;
240 insn
->u
.ll
.lab1
= last_address
;
241 insn
->u
.ll
.lab2
= label
;
243 last_address
= label
;
246 /* Add a DW_CFA_offset record to the CFI data. */
249 cfi_add_CFA_offset (unsigned regno
, offsetT offset
)
251 unsigned int abs_data_align
;
253 cfi_add_CFA_insn_reg_offset (DW_CFA_offset
, regno
, offset
);
255 abs_data_align
= (DWARF2_CIE_DATA_ALIGNMENT
< 0
256 ? -DWARF2_CIE_DATA_ALIGNMENT
: DWARF2_CIE_DATA_ALIGNMENT
);
257 if (offset
% abs_data_align
)
258 as_bad (_("register save offset not a multiple of %u"), abs_data_align
);
261 /* Add a DW_CFA_def_cfa record to the CFI data. */
264 cfi_add_CFA_def_cfa (unsigned regno
, offsetT offset
)
266 cfi_add_CFA_insn_reg_offset (DW_CFA_def_cfa
, regno
, offset
);
267 cur_cfa_offset
= offset
;
270 /* Add a DW_CFA_register record to the CFI data. */
273 cfi_add_CFA_register (unsigned reg1
, unsigned reg2
)
275 cfi_add_CFA_insn_reg_reg (DW_CFA_register
, reg1
, reg2
);
278 /* Add a DW_CFA_def_cfa_register record to the CFI data. */
281 cfi_add_CFA_def_cfa_register (unsigned regno
)
283 cfi_add_CFA_insn_reg (DW_CFA_def_cfa_register
, regno
);
286 /* Add a DW_CFA_def_cfa_offset record to the CFI data. */
289 cfi_add_CFA_def_cfa_offset (offsetT offset
)
291 cfi_add_CFA_insn_offset (DW_CFA_def_cfa_offset
, offset
);
292 cur_cfa_offset
= offset
;
296 cfi_add_CFA_restore (unsigned regno
)
298 cfi_add_CFA_insn_reg (DW_CFA_restore
, regno
);
302 cfi_add_CFA_undefined (unsigned regno
)
304 cfi_add_CFA_insn_reg (DW_CFA_undefined
, regno
);
308 cfi_add_CFA_same_value (unsigned regno
)
310 cfi_add_CFA_insn_reg (DW_CFA_same_value
, regno
);
314 cfi_add_CFA_remember_state (void)
316 struct cfa_save_data
*p
;
318 cfi_add_CFA_insn (DW_CFA_remember_state
);
320 p
= xmalloc (sizeof (*p
));
321 p
->cfa_offset
= cur_cfa_offset
;
322 p
->next
= cfa_save_stack
;
327 cfi_add_CFA_restore_state (void)
329 struct cfa_save_data
*p
;
331 cfi_add_CFA_insn (DW_CFA_restore_state
);
336 cur_cfa_offset
= p
->cfa_offset
;
337 cfa_save_stack
= p
->next
;
341 as_bad (_("CFI state restore without previous remember"));
345 /* Parse CFI assembler directives. */
347 static void dot_cfi (int);
348 static void dot_cfi_escape (int);
349 static void dot_cfi_startproc (int);
350 static void dot_cfi_endproc (int);
352 /* Fake CFI type; outside the byte range of any real CFI insn. */
353 #define CFI_adjust_cfa_offset 0x100
354 #define CFI_return_column 0x101
355 #define CFI_rel_offset 0x102
356 #define CFI_escape 0x103
358 const pseudo_typeS cfi_pseudo_table
[] =
360 { "cfi_startproc", dot_cfi_startproc
, 0 },
361 { "cfi_endproc", dot_cfi_endproc
, 0 },
362 { "cfi_def_cfa", dot_cfi
, DW_CFA_def_cfa
},
363 { "cfi_def_cfa_register", dot_cfi
, DW_CFA_def_cfa_register
},
364 { "cfi_def_cfa_offset", dot_cfi
, DW_CFA_def_cfa_offset
},
365 { "cfi_adjust_cfa_offset", dot_cfi
, CFI_adjust_cfa_offset
},
366 { "cfi_offset", dot_cfi
, DW_CFA_offset
},
367 { "cfi_rel_offset", dot_cfi
, CFI_rel_offset
},
368 { "cfi_register", dot_cfi
, DW_CFA_register
},
369 { "cfi_return_column", dot_cfi
, CFI_return_column
},
370 { "cfi_restore", dot_cfi
, DW_CFA_restore
},
371 { "cfi_undefined", dot_cfi
, DW_CFA_undefined
},
372 { "cfi_same_value", dot_cfi
, DW_CFA_same_value
},
373 { "cfi_remember_state", dot_cfi
, DW_CFA_remember_state
},
374 { "cfi_restore_state", dot_cfi
, DW_CFA_restore_state
},
375 { "cfi_window_save", dot_cfi
, DW_CFA_GNU_window_save
},
376 { "cfi_escape", dot_cfi_escape
, 0 },
381 cfi_parse_separator (void)
384 if (*input_line_pointer
== ',')
385 input_line_pointer
++;
387 as_bad (_("missing separator"));
396 #ifdef tc_regname_to_dw2regnum
398 if (is_name_beginner (*input_line_pointer
)
399 || (*input_line_pointer
== '%'
400 && is_name_beginner (*++input_line_pointer
)))
404 name
= input_line_pointer
;
405 c
= get_symbol_end ();
407 if ((regno
= tc_regname_to_dw2regnum (name
)) < 0)
409 as_bad (_("bad register expression"));
413 *input_line_pointer
= c
;
418 expression_and_evaluate (&exp
);
423 regno
= exp
.X_add_number
;
427 as_bad (_("bad register expression"));
436 cfi_parse_const (void)
438 return get_absolute_expression ();
449 as_bad (_("CFI instruction used without previous .cfi_startproc"));
450 ignore_rest_of_line ();
454 /* If the last address was not at the current PC, advance to current. */
455 if (symbol_get_frag (last_address
) != frag_now
456 || S_GET_VALUE (last_address
) != frag_now_fix ())
457 cfi_add_advance_loc (symbol_temp_new_now ());
462 reg1
= cfi_parse_reg ();
463 cfi_parse_separator ();
464 offset
= cfi_parse_const ();
465 cfi_add_CFA_offset (reg1
, offset
);
469 reg1
= cfi_parse_reg ();
470 cfi_parse_separator ();
471 offset
= cfi_parse_const ();
472 cfi_add_CFA_offset (reg1
, offset
- cur_cfa_offset
);
476 reg1
= cfi_parse_reg ();
477 cfi_parse_separator ();
478 offset
= cfi_parse_const ();
479 cfi_add_CFA_def_cfa (reg1
, offset
);
482 case DW_CFA_register
:
483 reg1
= cfi_parse_reg ();
484 cfi_parse_separator ();
485 reg2
= cfi_parse_reg ();
486 cfi_add_CFA_register (reg1
, reg2
);
489 case DW_CFA_def_cfa_register
:
490 reg1
= cfi_parse_reg ();
491 cfi_add_CFA_def_cfa_register (reg1
);
494 case DW_CFA_def_cfa_offset
:
495 offset
= cfi_parse_const ();
496 cfi_add_CFA_def_cfa_offset (offset
);
499 case CFI_adjust_cfa_offset
:
500 offset
= cfi_parse_const ();
501 cfi_add_CFA_def_cfa_offset (cur_cfa_offset
+ offset
);
507 reg1
= cfi_parse_reg ();
508 cfi_add_CFA_restore (reg1
);
510 if (*input_line_pointer
!= ',')
512 ++input_line_pointer
;
516 case DW_CFA_undefined
:
519 reg1
= cfi_parse_reg ();
520 cfi_add_CFA_undefined (reg1
);
522 if (*input_line_pointer
!= ',')
524 ++input_line_pointer
;
528 case DW_CFA_same_value
:
529 reg1
= cfi_parse_reg ();
530 cfi_add_CFA_same_value (reg1
);
533 case CFI_return_column
:
534 reg1
= cfi_parse_reg ();
535 cfi_set_return_column (reg1
);
538 case DW_CFA_remember_state
:
539 cfi_add_CFA_remember_state ();
542 case DW_CFA_restore_state
:
543 cfi_add_CFA_restore_state ();
546 case DW_CFA_GNU_window_save
:
547 cfi_add_CFA_insn (DW_CFA_GNU_window_save
);
554 demand_empty_rest_of_line ();
558 dot_cfi_escape (int ignored ATTRIBUTE_UNUSED
)
560 struct cfi_escape_data
*head
, **tail
, *e
;
561 struct cfi_insn_data
*insn
;
565 as_bad (_("CFI instruction used without previous .cfi_startproc"));
566 ignore_rest_of_line ();
570 /* If the last address was not at the current PC, advance to current. */
571 if (symbol_get_frag (last_address
) != frag_now
572 || S_GET_VALUE (last_address
) != frag_now_fix ())
573 cfi_add_advance_loc (symbol_temp_new_now ());
578 e
= xmalloc (sizeof (*e
));
579 do_parse_cons_expression (&e
->exp
, 1);
583 while (*input_line_pointer
++ == ',');
586 insn
= alloc_cfi_insn_data ();
587 insn
->insn
= CFI_escape
;
590 --input_line_pointer
;
591 demand_empty_rest_of_line ();
595 dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED
)
601 as_bad (_("previous CFI entry not closed (missing .cfi_endproc)"));
602 ignore_rest_of_line ();
606 cfi_new_fde (symbol_temp_new_now ());
609 if (is_name_beginner (*input_line_pointer
))
613 name
= input_line_pointer
;
614 c
= get_symbol_end ();
616 if (strcmp (name
, "simple") == 0)
619 *input_line_pointer
= c
;
622 input_line_pointer
= name
;
624 demand_empty_rest_of_line ();
628 tc_cfi_frame_initial_instructions ();
632 dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED
)
636 as_bad (_(".cfi_endproc without corresponding .cfi_startproc"));
637 ignore_rest_of_line ();
641 cfi_end_fde (symbol_temp_new_now ());
643 demand_empty_rest_of_line ();
647 /* Emit a single byte into the current segment. */
652 FRAG_APPEND_1_CHAR (byte
);
655 /* Emit a two-byte word into the current segment. */
660 md_number_to_chars (frag_more (2), data
, 2);
663 /* Emit a four byte word into the current segment. */
668 md_number_to_chars (frag_more (4), data
, 4);
671 /* Emit an unsigned "little-endian base 128" number. */
674 out_uleb128 (addressT value
)
676 output_leb128 (frag_more (sizeof_leb128 (value
, 0)), value
, 0);
679 /* Emit an unsigned "little-endian base 128" number. */
682 out_sleb128 (offsetT value
)
684 output_leb128 (frag_more (sizeof_leb128 (value
, 1)), value
, 1);
688 output_cfi_insn (struct cfi_insn_data
*insn
)
695 case DW_CFA_advance_loc
:
697 symbolS
*from
= insn
->u
.ll
.lab1
;
698 symbolS
*to
= insn
->u
.ll
.lab2
;
700 if (symbol_get_frag (to
) == symbol_get_frag (from
))
702 addressT delta
= S_GET_VALUE (to
) - S_GET_VALUE (from
);
703 addressT scaled
= delta
/ DWARF2_LINE_MIN_INSN_LENGTH
;
706 out_one (DW_CFA_advance_loc
+ scaled
);
707 else if (delta
<= 0xFF)
709 out_one (DW_CFA_advance_loc1
);
712 else if (delta
<= 0xFFFF)
714 out_one (DW_CFA_advance_loc2
);
719 out_one (DW_CFA_advance_loc4
);
727 exp
.X_op
= O_subtract
;
728 exp
.X_add_symbol
= to
;
729 exp
.X_op_symbol
= from
;
730 exp
.X_add_number
= 0;
732 /* The code in ehopt.c expects that one byte of the encoding
733 is already allocated to the frag. This comes from the way
734 that it scans the .eh_frame section looking first for the
735 .byte DW_CFA_advance_loc4. */
738 frag_var (rs_cfa
, 4, 0, DWARF2_LINE_MIN_INSN_LENGTH
<< 3,
739 make_expr_symbol (&exp
), frag_now_fix () - 1,
746 offset
= insn
->u
.ri
.offset
;
749 out_one (DW_CFA_def_cfa_sf
);
750 out_uleb128 (insn
->u
.ri
.reg
);
751 out_sleb128 (offset
/ DWARF2_CIE_DATA_ALIGNMENT
);
755 out_one (DW_CFA_def_cfa
);
756 out_uleb128 (insn
->u
.ri
.reg
);
757 out_uleb128 (offset
);
761 case DW_CFA_def_cfa_register
:
762 case DW_CFA_undefined
:
763 case DW_CFA_same_value
:
764 out_one (insn
->insn
);
765 out_uleb128 (insn
->u
.r
);
768 case DW_CFA_def_cfa_offset
:
772 out_one (DW_CFA_def_cfa_offset_sf
);
773 out_sleb128 (offset
/ DWARF2_CIE_DATA_ALIGNMENT
);
777 out_one (DW_CFA_def_cfa_offset
);
778 out_uleb128 (offset
);
786 out_one (DW_CFA_restore
+ regno
);
790 out_one (DW_CFA_restore_extended
);
796 regno
= insn
->u
.ri
.reg
;
797 offset
= insn
->u
.ri
.offset
/ DWARF2_CIE_DATA_ALIGNMENT
;
800 out_one (DW_CFA_offset_extended_sf
);
802 out_sleb128 (offset
);
804 else if (regno
<= 0x3F)
806 out_one (DW_CFA_offset
+ regno
);
807 out_uleb128 (offset
);
811 out_one (DW_CFA_offset_extended
);
813 out_uleb128 (offset
);
817 case DW_CFA_register
:
818 out_one (DW_CFA_register
);
819 out_uleb128 (insn
->u
.rr
.reg1
);
820 out_uleb128 (insn
->u
.rr
.reg2
);
823 case DW_CFA_remember_state
:
824 case DW_CFA_restore_state
:
825 out_one (insn
->insn
);
828 case DW_CFA_GNU_window_save
:
829 out_one (DW_CFA_GNU_window_save
);
834 struct cfi_escape_data
*e
;
835 for (e
= insn
->u
.esc
; e
; e
= e
->next
)
836 emit_expr (&e
->exp
, 1);
846 output_cie (struct cie_entry
*cie
)
848 symbolS
*after_size_address
, *end_address
;
850 struct cfi_insn_data
*i
;
852 cie
->start_address
= symbol_temp_new_now ();
853 after_size_address
= symbol_temp_make ();
854 end_address
= symbol_temp_make ();
856 exp
.X_op
= O_subtract
;
857 exp
.X_add_symbol
= end_address
;
858 exp
.X_op_symbol
= after_size_address
;
859 exp
.X_add_number
= 0;
861 emit_expr (&exp
, 4); /* Length. */
862 symbol_set_value_now (after_size_address
);
863 out_four (0); /* CIE id. */
864 out_one (DW_CIE_VERSION
); /* Version. */
865 out_one ('z'); /* Augmentation. */
868 out_uleb128 (DWARF2_LINE_MIN_INSN_LENGTH
); /* Code alignment. */
869 out_sleb128 (DWARF2_CIE_DATA_ALIGNMENT
); /* Data alignment. */
870 if (DW_CIE_VERSION
== 1) /* Return column. */
871 out_one (cie
->return_column
);
873 out_uleb128 (cie
->return_column
);
874 out_uleb128 (1); /* Augmentation size. */
875 #if defined DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
876 out_one (DW_EH_PE_pcrel
| DW_EH_PE_sdata4
);
878 out_one (DW_EH_PE_sdata4
);
882 for (i
= cie
->first
; i
!= cie
->last
; i
= i
->next
)
885 frag_align (2, DW_CFA_nop
, 0);
886 symbol_set_value_now (end_address
);
890 output_fde (struct fde_entry
*fde
, struct cie_entry
*cie
,
891 struct cfi_insn_data
*first
, int align
)
893 symbolS
*after_size_address
, *end_address
;
896 after_size_address
= symbol_temp_make ();
897 end_address
= symbol_temp_make ();
899 exp
.X_op
= O_subtract
;
900 exp
.X_add_symbol
= end_address
;
901 exp
.X_op_symbol
= after_size_address
;
902 exp
.X_add_number
= 0;
903 emit_expr (&exp
, 4); /* Length. */
904 symbol_set_value_now (after_size_address
);
906 exp
.X_add_symbol
= after_size_address
;
907 exp
.X_op_symbol
= cie
->start_address
;
908 emit_expr (&exp
, 4); /* CIE offset. */
911 exp
.X_add_symbol
= fde
->start_address
;
912 exp
.X_op_symbol
= symbol_temp_new_now ();
913 emit_expr (&exp
, 4); /* Code offset. */
916 exp
.X_add_symbol
= fde
->start_address
;
917 exp
.X_op_symbol
= NULL
;
918 #ifdef tc_cfi_emit_pcrel_expr
919 tc_cfi_emit_pcrel_expr (&exp
, 4); /* Code offset. */
921 emit_expr (&exp
, 4); /* Code offset. */
923 exp
.X_op
= O_subtract
;
926 exp
.X_add_symbol
= fde
->end_address
;
927 exp
.X_op_symbol
= fde
->start_address
; /* Code length. */
930 out_uleb128 (0); /* Augmentation size. */
932 for (; first
; first
= first
->next
)
933 output_cfi_insn (first
);
935 frag_align (align
, DW_CFA_nop
, 0);
936 symbol_set_value_now (end_address
);
939 static struct cie_entry
*
940 select_cie_for_fde (struct fde_entry
*fde
, struct cfi_insn_data
**pfirst
)
942 struct cfi_insn_data
*i
, *j
;
943 struct cie_entry
*cie
;
945 for (cie
= cie_root
; cie
; cie
= cie
->next
)
947 if (cie
->return_column
!= fde
->return_column
)
949 for (i
= cie
->first
, j
= fde
->data
;
950 i
!= cie
->last
&& j
!= NULL
;
951 i
= i
->next
, j
= j
->next
)
953 if (i
->insn
!= j
->insn
)
957 case DW_CFA_advance_loc
:
958 case DW_CFA_remember_state
:
959 /* We reached the first advance/remember in the FDE,
960 but did not reach the end of the CIE list. */
965 if (i
->u
.ri
.reg
!= j
->u
.ri
.reg
)
967 if (i
->u
.ri
.offset
!= j
->u
.ri
.offset
)
971 case DW_CFA_register
:
972 if (i
->u
.rr
.reg1
!= j
->u
.rr
.reg1
)
974 if (i
->u
.rr
.reg2
!= j
->u
.rr
.reg2
)
978 case DW_CFA_def_cfa_register
:
980 case DW_CFA_undefined
:
981 case DW_CFA_same_value
:
982 if (i
->u
.r
!= j
->u
.r
)
986 case DW_CFA_def_cfa_offset
:
987 if (i
->u
.i
!= j
->u
.i
)
992 /* Don't bother matching these for now. */
1000 /* Success if we reached the end of the CIE list, and we've either
1001 run out of FDE entries or we've encountered an advance,
1002 remember, or escape. */
1005 || j
->insn
== DW_CFA_advance_loc
1006 || j
->insn
== DW_CFA_remember_state
1007 || j
->insn
== CFI_escape
))
1016 cie
= xmalloc (sizeof (struct cie_entry
));
1017 cie
->next
= cie_root
;
1019 cie
->return_column
= fde
->return_column
;
1020 cie
->first
= fde
->data
;
1022 for (i
= cie
->first
; i
; i
= i
->next
)
1023 if (i
->insn
== DW_CFA_advance_loc
1024 || i
->insn
== DW_CFA_remember_state
1025 || i
->insn
== CFI_escape
)
1040 struct fde_entry
*fde
;
1041 int save_flag_traditional_format
;
1045 as_bad (_("open CFI at the end of file; missing .cfi_endproc directive"));
1046 cur_fde_data
->end_address
= cur_fde_data
->start_address
;
1049 if (all_fde_data
== 0)
1052 /* Open .eh_frame section. */
1053 cfi_seg
= subseg_new (".eh_frame", 0);
1054 bfd_set_section_flags (stdoutput
, cfi_seg
,
1055 SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
);
1056 subseg_set (cfi_seg
, 0);
1057 record_alignment (cfi_seg
, EH_FRAME_ALIGNMENT
);
1059 /* Make sure check_eh_frame doesn't do anything with our output. */
1060 save_flag_traditional_format
= flag_traditional_format
;
1061 flag_traditional_format
= 1;
1063 for (fde
= all_fde_data
; fde
; fde
= fde
->next
)
1065 struct cfi_insn_data
*first
;
1066 struct cie_entry
*cie
;
1068 cie
= select_cie_for_fde (fde
, &first
);
1069 output_fde (fde
, cie
, first
, fde
->next
== NULL
? EH_FRAME_ALIGNMENT
: 2);
1072 flag_traditional_format
= save_flag_traditional_format
;