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