Throw away dodgy coff line number info earlier
[deliverable/binutils-gdb.git] / gas / dw2gencfi.c
index 705157bff1fcda02d35c75f0caccd3f5372bbc4a..0f54fec598a5040a384301c9942654d9c3eb719e 100644 (file)
@@ -1,6 +1,5 @@
 /* dw2gencfi.c - Support for generating Dwarf2 CFI information.
-   Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2003-2014 Free Software Foundation, Inc.
    Contributed by Michal Ludvig <mludvig@suse.cz>
 
    This file is part of GAS, the GNU Assembler.
 #define tc_cfi_frame_initial_instructions() ((void)0)
 #endif
 
+#ifndef tc_cfi_startproc
+# define tc_cfi_startproc() ((void)0)
+#endif
+
+#ifndef tc_cfi_endproc
+# define tc_cfi_endproc(fde) ((void) (fde))
+#endif
+
 #ifndef DWARF2_FORMAT
 #define DWARF2_FORMAT(SEC) dwarf2_format_32bit
 #endif
 #define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8)
 #endif
 
-#if defined (TE_PE) || defined (TE_PEP)
-#define SUPPORT_FRAME_LINKONCE 1
-#else
-#define SUPPORT_FRAME_LINKONCE 0
-#endif
-
 #if SUPPORT_FRAME_LINKONCE
 #define CUR_SEG(structp) structp->cur_seg
-#define SET_CUR_SEG(structp, seg) structp->cur_seg = seg 
+#define SET_CUR_SEG(structp, seg) structp->cur_seg = seg
 #define HANDLED(structp) structp->handled
 #define SET_HANDLED(structp, val) structp->handled = val
 #else
@@ -186,8 +187,8 @@ make_debug_seg (segT cseg, char *name, int sflags)
   else
     flags = bfd_get_section_flags (stdoutput, cseg)
       & (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
-         | SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE
-         | SEC_LINK_DUPLICATES_SAME_CONTENTS);
+        | SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE
+        | SEC_LINK_DUPLICATES_SAME_CONTENTS);
 
   /* Add standard section flags.  */
   flags |= sflags;
@@ -268,67 +269,6 @@ struct cfi_escape_data
   expressionS exp;
 };
 
-struct cfi_insn_data
-{
-  struct cfi_insn_data *next;
-#if SUPPORT_FRAME_LINKONCE
-  segT cur_seg;
-#endif
-  int insn;
-  union
-  {
-    struct
-    {
-      unsigned reg;
-      offsetT offset;
-    } ri;
-
-    struct
-    {
-      unsigned reg1;
-      unsigned reg2;
-    } rr;
-
-    unsigned r;
-    offsetT i;
-
-    struct
-    {
-      symbolS *lab1;
-      symbolS *lab2;
-    } ll;
-
-    struct cfi_escape_data *esc;
-
-    struct
-    {
-      unsigned reg, encoding;
-      expressionS exp;
-    } ea;
-  } u;
-};
-
-struct fde_entry
-{
-  struct fde_entry *next;
-#if SUPPORT_FRAME_LINKONCE
-  segT cur_seg;
-#endif
-  symbolS *start_address;
-  symbolS *end_address;
-  struct cfi_insn_data *data;
-  struct cfi_insn_data **last;
-  unsigned char per_encoding;
-  unsigned char lsda_encoding;
-  expressionS personality;
-  expressionS lsda;
-  unsigned int return_column;
-  unsigned int signal_frame;
-#if SUPPORT_FRAME_LINKONCE
-  int handled;
-#endif
-};
-
 struct cie_entry
 {
   struct cie_entry *next;
@@ -346,7 +286,7 @@ struct cie_entry
 
 /* List of FDE entries.  */
 
-static struct fde_entry *all_fde_data;
+struct fde_entry *all_fde_data;
 static struct fde_entry **last_fde_data = &all_fde_data;
 
 /* List of CIEs so that they could be reused.  */
@@ -611,14 +551,6 @@ static void dot_cfi_personality (int);
 static void dot_cfi_lsda (int);
 static void dot_cfi_val_encoded_addr (int);
 
-/* Fake CFI type; outside the byte range of any real CFI insn.  */
-#define CFI_adjust_cfa_offset  0x100
-#define CFI_return_column      0x101
-#define CFI_rel_offset         0x102
-#define CFI_escape             0x103
-#define CFI_signal_frame       0x104
-#define CFI_val_encoded_addr   0x105
-
 const pseudo_typeS cfi_pseudo_table[] =
   {
     { "cfi_sections", dot_cfi_sections, 0 },
@@ -1067,7 +999,7 @@ dot_cfi_val_encoded_addr (int ignored ATTRIBUTE_UNUSED)
       break;
     case O_constant:
       if ((encoding & 0x70) != DW_EH_PE_pcrel)
-        break;
+       break;
     default:
       encoding = DW_EH_PE_omit;
       break;
@@ -1087,6 +1019,7 @@ dot_cfi_val_encoded_addr (int ignored ATTRIBUTE_UNUSED)
 /* By default emit .eh_frame only, not .debug_frame.  */
 #define CFI_EMIT_eh_frame      (1 << 0)
 #define CFI_EMIT_debug_frame   (1 << 1)
+#define CFI_EMIT_target                (1 << 2)
 static int cfi_sections = CFI_EMIT_eh_frame;
 
 static void
@@ -1108,6 +1041,10 @@ dot_cfi_sections (int ignored ATTRIBUTE_UNUSED)
          sections |= CFI_EMIT_eh_frame;
        else if (strncmp (name, ".debug_frame", sizeof ".debug_frame") == 0)
          sections |= CFI_EMIT_debug_frame;
+#ifdef tc_cfi_section_name
+       else if (strcmp (name, tc_cfi_section_name) == 0)
+         sections |= CFI_EMIT_target;
+#endif
        else
          {
            *input_line_pointer = c;
@@ -1170,11 +1107,16 @@ dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
   frchain_now->frch_cfi_data->cur_cfa_offset = 0;
   if (!simple)
     tc_cfi_frame_initial_instructions ();
+
+  if ((cfi_sections & CFI_EMIT_target) != 0)
+    tc_cfi_startproc ();
 }
 
 static void
 dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED)
 {
+  struct fde_entry *fde;
+
   if (frchain_now->frch_cfi_data == NULL)
     {
       as_bad (_(".cfi_endproc without corresponding .cfi_startproc"));
@@ -1182,9 +1124,14 @@ dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED)
       return;
     }
 
+  fde = frchain_now->frch_cfi_data->cur_fde_data;
+
   cfi_end_fde (symbol_temp_new_now ());
 
   demand_empty_rest_of_line ();
+
+  if ((cfi_sections & CFI_EMIT_target) != 0)
+    tc_cfi_endproc (fde);
 }
 
 \f
@@ -1383,15 +1330,15 @@ output_cfi_insn (struct cfi_insn_data *insn)
 
     case CFI_val_encoded_addr:
       {
-        unsigned encoding = insn->u.ea.encoding;
-        offsetT encoding_size;
+       unsigned encoding = insn->u.ea.encoding;
+       offsetT encoding_size;
 
        if (encoding == DW_EH_PE_omit)
          break;
        out_one (DW_CFA_val_expression);
        out_uleb128 (insn->u.ea.reg);
 
-        switch (encoding & 0x7)
+       switch (encoding & 0x7)
          {
          case DW_EH_PE_absptr:
            encoding_size = DWARF2_ADDR_SIZE (stdoutput);
@@ -1574,7 +1521,7 @@ output_cie (struct cie_entry *cie, bfd_boolean eh_frame, int align)
   if (cie->first)
     {
       for (i = cie->first; i != cie->last; i = i->next)
-        {
+       {
          if (CUR_SEG (i) != CUR_SEG (cie))
            continue;
          output_cfi_insn (i);
@@ -1832,7 +1779,7 @@ cfi_change_reg_numbers (struct cfi_insn_data *insn, segT ccseg)
   for (; insn; insn = insn->next)
     {
       if (CUR_SEG (insn) != ccseg)
-        continue;
+       continue;
       switch (insn->insn)
        {
        case DW_CFA_advance_loc:
@@ -1927,7 +1874,7 @@ cfi_finish (void)
        }
 
       do
-        {
+       {
          ccseg = NULL;
          seek_next_seg = 0;
 
@@ -1997,7 +1944,7 @@ cfi_finish (void)
                     alignment);
 
       do
-        {
+       {
          ccseg = NULL;
          seek_next_seg = 0;
 
This page took 0.026356 seconds and 4 git commands to generate.