1 /* dw2gencfi.c - Support for generating Dwarf2 CFI information.
2 Copyright 2003, 2004, 2005, 2006 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"
27 /* We re-use DWARF2_LINE_MIN_INSN_LENGTH for the code alignment field
28 of the CIE. Default to 1 if not otherwise specified. */
29 #ifndef DWARF2_LINE_MIN_INSN_LENGTH
30 # define DWARF2_LINE_MIN_INSN_LENGTH 1
33 /* If TARGET_USE_CFIPOP is defined, it is required that the target
34 provide the following definitions. Otherwise provide them to
35 allow compilation to continue. */
36 #ifndef TARGET_USE_CFIPOP
37 # ifndef DWARF2_DEFAULT_RETURN_COLUMN
38 # define DWARF2_DEFAULT_RETURN_COLUMN 0
40 # ifndef DWARF2_CIE_DATA_ALIGNMENT
41 # define DWARF2_CIE_DATA_ALIGNMENT 1
45 #ifndef EH_FRAME_ALIGNMENT
46 # define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2)
49 #ifndef tc_cfi_frame_initial_instructions
50 # define tc_cfi_frame_initial_instructions() ((void)0)
56 struct cfi_insn_data *next;
77 struct cfi_escape_data {
78 struct cfi_escape_data *next;
86 struct fde_entry *next;
87 symbolS *start_address;
89 struct cfi_insn_data *data;
90 struct cfi_insn_data **last;
91 unsigned int return_column;
92 unsigned int signal_frame;
97 struct cie_entry *next;
98 symbolS *start_address;
99 unsigned int return_column;
100 unsigned int signal_frame;
101 struct cfi_insn_data *first, *last;
105 /* List of FDE entries. */
106 static struct fde_entry *all_fde_data;
107 static struct fde_entry **last_fde_data = &all_fde_data;
109 /* List of CIEs so that they could be reused. */
110 static struct cie_entry *cie_root;
112 /* Stack of old CFI data, for save/restore. */
115 struct cfa_save_data *next;
119 /* Current open FDE entry. */
122 struct fde_entry *cur_fde_data;
123 symbolS *last_address;
124 offsetT cur_cfa_offset;
125 struct cfa_save_data *cfa_save_stack;
128 /* Construct a new FDE structure and add it to the end of the fde list. */
130 static struct fde_entry *
131 alloc_fde_entry (void)
133 struct fde_entry *fde = xcalloc (1, sizeof (struct fde_entry));
135 frchain_now->frch_cfi_data = xcalloc (1, sizeof (struct frch_cfi_data));
136 frchain_now->frch_cfi_data->cur_fde_data = fde;
137 *last_fde_data = fde;
138 last_fde_data = &fde->next;
140 fde->last = &fde->data;
141 fde->return_column = DWARF2_DEFAULT_RETURN_COLUMN;
146 /* The following functions are available for a backend to construct its
147 own unwind information, usually from legacy unwind directives. */
149 /* Construct a new INSN structure and add it to the end of the insn list
150 for the currently active FDE. */
152 static struct cfi_insn_data *
153 alloc_cfi_insn_data (void)
155 struct cfi_insn_data *insn = xcalloc (1, sizeof (struct cfi_insn_data));
156 struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data;
158 *cur_fde_data->last = insn;
159 cur_fde_data->last = &insn->next;
164 /* Construct a new FDE structure that begins at LABEL. */
167 cfi_new_fde (symbolS *label)
169 struct fde_entry *fde = alloc_fde_entry ();
170 fde->start_address = label;
171 frchain_now->frch_cfi_data->last_address = label;
174 /* End the currently open FDE. */
177 cfi_end_fde (symbolS *label)
179 frchain_now->frch_cfi_data->cur_fde_data->end_address = label;
180 free (frchain_now->frch_cfi_data);
181 frchain_now->frch_cfi_data = NULL;
184 /* Set the return column for the current FDE. */
187 cfi_set_return_column (unsigned regno)
189 frchain_now->frch_cfi_data->cur_fde_data->return_column = regno;
192 /* Universal functions to store new instructions. */
195 cfi_add_CFA_insn(int insn)
197 struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data ();
199 insn_ptr->insn = insn;
203 cfi_add_CFA_insn_reg (int insn, unsigned regno)
205 struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data ();
207 insn_ptr->insn = insn;
208 insn_ptr->u.r = regno;
212 cfi_add_CFA_insn_offset (int insn, offsetT offset)
214 struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data ();
216 insn_ptr->insn = insn;
217 insn_ptr->u.i = offset;
221 cfi_add_CFA_insn_reg_reg (int insn, unsigned reg1, unsigned reg2)
223 struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data ();
225 insn_ptr->insn = insn;
226 insn_ptr->u.rr.reg1 = reg1;
227 insn_ptr->u.rr.reg2 = reg2;
231 cfi_add_CFA_insn_reg_offset (int insn, unsigned regno, offsetT offset)
233 struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data ();
235 insn_ptr->insn = insn;
236 insn_ptr->u.ri.reg = regno;
237 insn_ptr->u.ri.offset = offset;
240 /* Add a CFI insn to advance the PC from the last address to LABEL. */
243 cfi_add_advance_loc (symbolS *label)
245 struct cfi_insn_data *insn = alloc_cfi_insn_data ();
247 insn->insn = DW_CFA_advance_loc;
248 insn->u.ll.lab1 = frchain_now->frch_cfi_data->last_address;
249 insn->u.ll.lab2 = label;
251 frchain_now->frch_cfi_data->last_address = label;
254 /* Add a DW_CFA_offset record to the CFI data. */
257 cfi_add_CFA_offset (unsigned regno, offsetT offset)
259 unsigned int abs_data_align;
261 assert (DWARF2_CIE_DATA_ALIGNMENT != 0);
262 cfi_add_CFA_insn_reg_offset (DW_CFA_offset, regno, offset);
264 abs_data_align = (DWARF2_CIE_DATA_ALIGNMENT < 0
265 ? -DWARF2_CIE_DATA_ALIGNMENT : DWARF2_CIE_DATA_ALIGNMENT);
266 if (offset % abs_data_align)
267 as_bad (_("register save offset not a multiple of %u"), abs_data_align);
270 /* Add a DW_CFA_def_cfa record to the CFI data. */
273 cfi_add_CFA_def_cfa (unsigned regno, offsetT offset)
275 cfi_add_CFA_insn_reg_offset (DW_CFA_def_cfa, regno, offset);
276 frchain_now->frch_cfi_data->cur_cfa_offset = offset;
279 /* Add a DW_CFA_register record to the CFI data. */
282 cfi_add_CFA_register (unsigned reg1, unsigned reg2)
284 cfi_add_CFA_insn_reg_reg (DW_CFA_register, reg1, reg2);
287 /* Add a DW_CFA_def_cfa_register record to the CFI data. */
290 cfi_add_CFA_def_cfa_register (unsigned regno)
292 cfi_add_CFA_insn_reg (DW_CFA_def_cfa_register, regno);
295 /* Add a DW_CFA_def_cfa_offset record to the CFI data. */
298 cfi_add_CFA_def_cfa_offset (offsetT offset)
300 cfi_add_CFA_insn_offset (DW_CFA_def_cfa_offset, offset);
301 frchain_now->frch_cfi_data->cur_cfa_offset = offset;
305 cfi_add_CFA_restore (unsigned regno)
307 cfi_add_CFA_insn_reg (DW_CFA_restore, regno);
311 cfi_add_CFA_undefined (unsigned regno)
313 cfi_add_CFA_insn_reg (DW_CFA_undefined, regno);
317 cfi_add_CFA_same_value (unsigned regno)
319 cfi_add_CFA_insn_reg (DW_CFA_same_value, regno);
323 cfi_add_CFA_remember_state (void)
325 struct cfa_save_data *p;
327 cfi_add_CFA_insn (DW_CFA_remember_state);
329 p = xmalloc (sizeof (*p));
330 p->cfa_offset = frchain_now->frch_cfi_data->cur_cfa_offset;
331 p->next = frchain_now->frch_cfi_data->cfa_save_stack;
332 frchain_now->frch_cfi_data->cfa_save_stack = p;
336 cfi_add_CFA_restore_state (void)
338 struct cfa_save_data *p;
340 cfi_add_CFA_insn (DW_CFA_restore_state);
342 p = frchain_now->frch_cfi_data->cfa_save_stack;
345 frchain_now->frch_cfi_data->cur_cfa_offset = p->cfa_offset;
346 frchain_now->frch_cfi_data->cfa_save_stack = p->next;
350 as_bad (_("CFI state restore without previous remember"));
354 /* Parse CFI assembler directives. */
356 static void dot_cfi (int);
357 static void dot_cfi_escape (int);
358 static void dot_cfi_startproc (int);
359 static void dot_cfi_endproc (int);
361 /* Fake CFI type; outside the byte range of any real CFI insn. */
362 #define CFI_adjust_cfa_offset 0x100
363 #define CFI_return_column 0x101
364 #define CFI_rel_offset 0x102
365 #define CFI_escape 0x103
366 #define CFI_signal_frame 0x104
368 const pseudo_typeS cfi_pseudo_table[] =
370 { "cfi_startproc", dot_cfi_startproc, 0 },
371 { "cfi_endproc", dot_cfi_endproc, 0 },
372 { "cfi_def_cfa", dot_cfi, DW_CFA_def_cfa },
373 { "cfi_def_cfa_register", dot_cfi, DW_CFA_def_cfa_register },
374 { "cfi_def_cfa_offset", dot_cfi, DW_CFA_def_cfa_offset },
375 { "cfi_adjust_cfa_offset", dot_cfi, CFI_adjust_cfa_offset },
376 { "cfi_offset", dot_cfi, DW_CFA_offset },
377 { "cfi_rel_offset", dot_cfi, CFI_rel_offset },
378 { "cfi_register", dot_cfi, DW_CFA_register },
379 { "cfi_return_column", dot_cfi, CFI_return_column },
380 { "cfi_restore", dot_cfi, DW_CFA_restore },
381 { "cfi_undefined", dot_cfi, DW_CFA_undefined },
382 { "cfi_same_value", dot_cfi, DW_CFA_same_value },
383 { "cfi_remember_state", dot_cfi, DW_CFA_remember_state },
384 { "cfi_restore_state", dot_cfi, DW_CFA_restore_state },
385 { "cfi_window_save", dot_cfi, DW_CFA_GNU_window_save },
386 { "cfi_escape", dot_cfi_escape, 0 },
387 { "cfi_signal_frame", dot_cfi, CFI_signal_frame },
392 cfi_parse_separator (void)
395 if (*input_line_pointer == ',')
396 input_line_pointer++;
398 as_bad (_("missing separator"));
407 #ifdef tc_regname_to_dw2regnum
409 if (is_name_beginner (*input_line_pointer)
410 || (*input_line_pointer == '%'
411 && is_name_beginner (*++input_line_pointer)))
415 name = input_line_pointer;
416 c = get_symbol_end ();
418 if ((regno = tc_regname_to_dw2regnum (name)) < 0)
420 as_bad (_("bad register expression"));
424 *input_line_pointer = c;
429 expression_and_evaluate (&exp);
434 regno = exp.X_add_number;
438 as_bad (_("bad register expression"));
447 cfi_parse_const (void)
449 return get_absolute_expression ();
458 if (frchain_now->frch_cfi_data == NULL)
460 as_bad (_("CFI instruction used without previous .cfi_startproc"));
461 ignore_rest_of_line ();
465 /* If the last address was not at the current PC, advance to current. */
466 if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now
467 || S_GET_VALUE (frchain_now->frch_cfi_data->last_address)
469 cfi_add_advance_loc (symbol_temp_new_now ());
474 reg1 = cfi_parse_reg ();
475 cfi_parse_separator ();
476 offset = cfi_parse_const ();
477 cfi_add_CFA_offset (reg1, offset);
481 reg1 = cfi_parse_reg ();
482 cfi_parse_separator ();
483 offset = cfi_parse_const ();
484 cfi_add_CFA_offset (reg1,
485 offset - frchain_now->frch_cfi_data->cur_cfa_offset);
489 reg1 = cfi_parse_reg ();
490 cfi_parse_separator ();
491 offset = cfi_parse_const ();
492 cfi_add_CFA_def_cfa (reg1, offset);
495 case DW_CFA_register:
496 reg1 = cfi_parse_reg ();
497 cfi_parse_separator ();
498 reg2 = cfi_parse_reg ();
499 cfi_add_CFA_register (reg1, reg2);
502 case DW_CFA_def_cfa_register:
503 reg1 = cfi_parse_reg ();
504 cfi_add_CFA_def_cfa_register (reg1);
507 case DW_CFA_def_cfa_offset:
508 offset = cfi_parse_const ();
509 cfi_add_CFA_def_cfa_offset (offset);
512 case CFI_adjust_cfa_offset:
513 offset = cfi_parse_const ();
514 cfi_add_CFA_def_cfa_offset (frchain_now->frch_cfi_data->cur_cfa_offset
521 reg1 = cfi_parse_reg ();
522 cfi_add_CFA_restore (reg1);
524 if (*input_line_pointer != ',')
526 ++input_line_pointer;
530 case DW_CFA_undefined:
533 reg1 = cfi_parse_reg ();
534 cfi_add_CFA_undefined (reg1);
536 if (*input_line_pointer != ',')
538 ++input_line_pointer;
542 case DW_CFA_same_value:
543 reg1 = cfi_parse_reg ();
544 cfi_add_CFA_same_value (reg1);
547 case CFI_return_column:
548 reg1 = cfi_parse_reg ();
549 cfi_set_return_column (reg1);
552 case DW_CFA_remember_state:
553 cfi_add_CFA_remember_state ();
556 case DW_CFA_restore_state:
557 cfi_add_CFA_restore_state ();
560 case DW_CFA_GNU_window_save:
561 cfi_add_CFA_insn (DW_CFA_GNU_window_save);
564 case CFI_signal_frame:
565 frchain_now->frch_cfi_data->cur_fde_data->signal_frame = 1;
572 demand_empty_rest_of_line ();
576 dot_cfi_escape (int ignored ATTRIBUTE_UNUSED)
578 struct cfi_escape_data *head, **tail, *e;
579 struct cfi_insn_data *insn;
581 if (frchain_now->frch_cfi_data == NULL)
583 as_bad (_("CFI instruction used without previous .cfi_startproc"));
584 ignore_rest_of_line ();
588 /* If the last address was not at the current PC, advance to current. */
589 if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now
590 || S_GET_VALUE (frchain_now->frch_cfi_data->last_address)
592 cfi_add_advance_loc (symbol_temp_new_now ());
597 e = xmalloc (sizeof (*e));
598 do_parse_cons_expression (&e->exp, 1);
602 while (*input_line_pointer++ == ',');
605 insn = alloc_cfi_insn_data ();
606 insn->insn = CFI_escape;
609 --input_line_pointer;
610 demand_empty_rest_of_line ();
614 dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
618 if (frchain_now->frch_cfi_data != NULL)
620 as_bad (_("previous CFI entry not closed (missing .cfi_endproc)"));
621 ignore_rest_of_line ();
625 cfi_new_fde (symbol_temp_new_now ());
628 if (is_name_beginner (*input_line_pointer))
632 name = input_line_pointer;
633 c = get_symbol_end ();
635 if (strcmp (name, "simple") == 0)
638 *input_line_pointer = c;
641 input_line_pointer = name;
643 demand_empty_rest_of_line ();
645 frchain_now->frch_cfi_data->cur_cfa_offset = 0;
647 tc_cfi_frame_initial_instructions ();
651 dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED)
653 if (frchain_now->frch_cfi_data == NULL)
655 as_bad (_(".cfi_endproc without corresponding .cfi_startproc"));
656 ignore_rest_of_line ();
660 cfi_end_fde (symbol_temp_new_now ());
662 demand_empty_rest_of_line ();
666 /* Emit a single byte into the current segment. */
671 FRAG_APPEND_1_CHAR (byte);
674 /* Emit a two-byte word into the current segment. */
679 md_number_to_chars (frag_more (2), data, 2);
682 /* Emit a four byte word into the current segment. */
687 md_number_to_chars (frag_more (4), data, 4);
690 /* Emit an unsigned "little-endian base 128" number. */
693 out_uleb128 (addressT value)
695 output_leb128 (frag_more (sizeof_leb128 (value, 0)), value, 0);
698 /* Emit an unsigned "little-endian base 128" number. */
701 out_sleb128 (offsetT value)
703 output_leb128 (frag_more (sizeof_leb128 (value, 1)), value, 1);
707 output_cfi_insn (struct cfi_insn_data *insn)
714 case DW_CFA_advance_loc:
716 symbolS *from = insn->u.ll.lab1;
717 symbolS *to = insn->u.ll.lab2;
719 if (symbol_get_frag (to) == symbol_get_frag (from))
721 addressT delta = S_GET_VALUE (to) - S_GET_VALUE (from);
722 addressT scaled = delta / DWARF2_LINE_MIN_INSN_LENGTH;
725 out_one (DW_CFA_advance_loc + scaled);
726 else if (delta <= 0xFF)
728 out_one (DW_CFA_advance_loc1);
731 else if (delta <= 0xFFFF)
733 out_one (DW_CFA_advance_loc2);
738 out_one (DW_CFA_advance_loc4);
746 exp.X_op = O_subtract;
747 exp.X_add_symbol = to;
748 exp.X_op_symbol = from;
749 exp.X_add_number = 0;
751 /* The code in ehopt.c expects that one byte of the encoding
752 is already allocated to the frag. This comes from the way
753 that it scans the .eh_frame section looking first for the
754 .byte DW_CFA_advance_loc4. */
757 frag_var (rs_cfa, 4, 0, DWARF2_LINE_MIN_INSN_LENGTH << 3,
758 make_expr_symbol (&exp), frag_now_fix () - 1,
765 offset = insn->u.ri.offset;
768 out_one (DW_CFA_def_cfa_sf);
769 out_uleb128 (insn->u.ri.reg);
770 out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT);
774 out_one (DW_CFA_def_cfa);
775 out_uleb128 (insn->u.ri.reg);
776 out_uleb128 (offset);
780 case DW_CFA_def_cfa_register:
781 case DW_CFA_undefined:
782 case DW_CFA_same_value:
783 out_one (insn->insn);
784 out_uleb128 (insn->u.r);
787 case DW_CFA_def_cfa_offset:
791 out_one (DW_CFA_def_cfa_offset_sf);
792 out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT);
796 out_one (DW_CFA_def_cfa_offset);
797 out_uleb128 (offset);
805 out_one (DW_CFA_restore + regno);
809 out_one (DW_CFA_restore_extended);
815 regno = insn->u.ri.reg;
816 offset = insn->u.ri.offset / DWARF2_CIE_DATA_ALIGNMENT;
819 out_one (DW_CFA_offset_extended_sf);
821 out_sleb128 (offset);
823 else if (regno <= 0x3F)
825 out_one (DW_CFA_offset + regno);
826 out_uleb128 (offset);
830 out_one (DW_CFA_offset_extended);
832 out_uleb128 (offset);
836 case DW_CFA_register:
837 out_one (DW_CFA_register);
838 out_uleb128 (insn->u.rr.reg1);
839 out_uleb128 (insn->u.rr.reg2);
842 case DW_CFA_remember_state:
843 case DW_CFA_restore_state:
844 out_one (insn->insn);
847 case DW_CFA_GNU_window_save:
848 out_one (DW_CFA_GNU_window_save);
853 struct cfi_escape_data *e;
854 for (e = insn->u.esc; e ; e = e->next)
855 emit_expr (&e->exp, 1);
865 output_cie (struct cie_entry *cie)
867 symbolS *after_size_address, *end_address;
869 struct cfi_insn_data *i;
871 cie->start_address = symbol_temp_new_now ();
872 after_size_address = symbol_temp_make ();
873 end_address = symbol_temp_make ();
875 exp.X_op = O_subtract;
876 exp.X_add_symbol = end_address;
877 exp.X_op_symbol = after_size_address;
878 exp.X_add_number = 0;
880 emit_expr (&exp, 4); /* Length. */
881 symbol_set_value_now (after_size_address);
882 out_four (0); /* CIE id. */
883 out_one (DW_CIE_VERSION); /* Version. */
884 out_one ('z'); /* Augmentation. */
886 if (cie->signal_frame)
889 out_uleb128 (DWARF2_LINE_MIN_INSN_LENGTH); /* Code alignment. */
890 out_sleb128 (DWARF2_CIE_DATA_ALIGNMENT); /* Data alignment. */
891 if (DW_CIE_VERSION == 1) /* Return column. */
892 out_one (cie->return_column);
894 out_uleb128 (cie->return_column);
895 out_uleb128 (1); /* Augmentation size. */
896 #if defined DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
897 out_one (DW_EH_PE_pcrel | DW_EH_PE_sdata4);
899 out_one (DW_EH_PE_sdata4);
903 for (i = cie->first; i != cie->last; i = i->next)
906 frag_align (2, DW_CFA_nop, 0);
907 symbol_set_value_now (end_address);
911 output_fde (struct fde_entry *fde, struct cie_entry *cie,
912 struct cfi_insn_data *first, int align)
914 symbolS *after_size_address, *end_address;
917 after_size_address = symbol_temp_make ();
918 end_address = symbol_temp_make ();
920 exp.X_op = O_subtract;
921 exp.X_add_symbol = end_address;
922 exp.X_op_symbol = after_size_address;
923 exp.X_add_number = 0;
924 emit_expr (&exp, 4); /* Length. */
925 symbol_set_value_now (after_size_address);
927 exp.X_add_symbol = after_size_address;
928 exp.X_op_symbol = cie->start_address;
929 emit_expr (&exp, 4); /* CIE offset. */
932 exp.X_add_symbol = fde->start_address;
933 exp.X_op_symbol = symbol_temp_new_now ();
934 emit_expr (&exp, 4); /* Code offset. */
937 exp.X_add_symbol = fde->start_address;
938 exp.X_op_symbol = NULL;
939 #ifdef tc_cfi_emit_pcrel_expr
940 tc_cfi_emit_pcrel_expr (&exp, 4); /* Code offset. */
942 emit_expr (&exp, 4); /* Code offset. */
944 exp.X_op = O_subtract;
947 exp.X_add_symbol = fde->end_address;
948 exp.X_op_symbol = fde->start_address; /* Code length. */
951 out_uleb128 (0); /* Augmentation size. */
953 for (; first; first = first->next)
954 output_cfi_insn (first);
956 frag_align (align, DW_CFA_nop, 0);
957 symbol_set_value_now (end_address);
960 static struct cie_entry *
961 select_cie_for_fde (struct fde_entry *fde, struct cfi_insn_data **pfirst)
963 struct cfi_insn_data *i, *j;
964 struct cie_entry *cie;
966 for (cie = cie_root; cie; cie = cie->next)
968 if (cie->return_column != fde->return_column
969 || cie->signal_frame != fde->signal_frame)
971 for (i = cie->first, j = fde->data;
972 i != cie->last && j != NULL;
973 i = i->next, j = j->next)
975 if (i->insn != j->insn)
979 case DW_CFA_advance_loc:
980 case DW_CFA_remember_state:
981 /* We reached the first advance/remember in the FDE,
982 but did not reach the end of the CIE list. */
987 if (i->u.ri.reg != j->u.ri.reg)
989 if (i->u.ri.offset != j->u.ri.offset)
993 case DW_CFA_register:
994 if (i->u.rr.reg1 != j->u.rr.reg1)
996 if (i->u.rr.reg2 != j->u.rr.reg2)
1000 case DW_CFA_def_cfa_register:
1001 case DW_CFA_restore:
1002 case DW_CFA_undefined:
1003 case DW_CFA_same_value:
1004 if (i->u.r != j->u.r)
1008 case DW_CFA_def_cfa_offset:
1009 if (i->u.i != j->u.i)
1014 /* Don't bother matching these for now. */
1022 /* Success if we reached the end of the CIE list, and we've either
1023 run out of FDE entries or we've encountered an advance,
1024 remember, or escape. */
1027 || j->insn == DW_CFA_advance_loc
1028 || j->insn == DW_CFA_remember_state
1029 || j->insn == CFI_escape))
1038 cie = xmalloc (sizeof (struct cie_entry));
1039 cie->next = cie_root;
1041 cie->return_column = fde->return_column;
1042 cie->signal_frame = fde->signal_frame;
1043 cie->first = fde->data;
1045 for (i = cie->first; i ; i = i->next)
1046 if (i->insn == DW_CFA_advance_loc
1047 || i->insn == DW_CFA_remember_state
1048 || i->insn == CFI_escape)
1063 struct fde_entry *fde;
1064 int save_flag_traditional_format;
1066 if (all_fde_data == 0)
1069 /* Open .eh_frame section. */
1070 cfi_seg = subseg_new (".eh_frame", 0);
1071 bfd_set_section_flags (stdoutput, cfi_seg,
1072 SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY);
1073 subseg_set (cfi_seg, 0);
1074 record_alignment (cfi_seg, EH_FRAME_ALIGNMENT);
1076 /* Make sure check_eh_frame doesn't do anything with our output. */
1077 save_flag_traditional_format = flag_traditional_format;
1078 flag_traditional_format = 1;
1080 for (fde = all_fde_data; fde ; fde = fde->next)
1082 struct cfi_insn_data *first;
1083 struct cie_entry *cie;
1085 if (fde->end_address == NULL)
1087 as_bad (_("open CFI at the end of file; missing .cfi_endproc directive"));
1088 fde->end_address = fde->start_address;
1091 cie = select_cie_for_fde (fde, &first);
1092 output_fde (fde, cie, first, fde->next == NULL ? EH_FRAME_ALIGNMENT : 2);
1095 flag_traditional_format = save_flag_traditional_format;