daily update
[deliverable/binutils-gdb.git] / gas / dw2gencfi.c
index 3bfd14f46ac6065111d66141c8a7661e6f76a088..eb2f476b71105a5c6d70a78f17f961af5b8e2b8b 100644 (file)
@@ -1,5 +1,5 @@
 /* dw2gencfi.c - Support for generating Dwarf2 CFI information.
-   Copyright 2003, 2004 Free Software Foundation, Inc.
+   Copyright 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Michal Ludvig <mludvig@suse.cz>
 
    This file is part of GAS, the GNU Assembler.
@@ -16,8 +16,8 @@
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to the Free
-   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 #include "as.h"
 #include "dw2gencfi.h"
 #endif
 
 #ifndef EH_FRAME_ALIGNMENT
-# ifdef BFD_ASSEMBLER
-#  define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2)
-# else
-#  define EH_FRAME_ALIGNMENT 2
-# endif
+# define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2)
 #endif
 
 #ifndef tc_cfi_frame_initial_instructions
@@ -419,7 +415,7 @@ cfi_parse_reg (void)
     }
 #endif
 
-  expression (&exp);
+  expression_and_evaluate (&exp);
   switch (exp.X_op)
     {
     case O_register:
@@ -451,6 +447,7 @@ dot_cfi (int arg)
   if (!cur_fde_data)
     {
       as_bad (_("CFI instruction used without previous .cfi_startproc"));
+      ignore_rest_of_line ();
       return;
     }
 
@@ -505,13 +502,27 @@ dot_cfi (int arg)
       break;
 
     case DW_CFA_restore:
-      reg1 = cfi_parse_reg ();
-      cfi_add_CFA_restore (reg1);
+      for (;;)
+       {
+         reg1 = cfi_parse_reg ();
+         cfi_add_CFA_restore (reg1);
+         SKIP_WHITESPACE ();
+         if (*input_line_pointer != ',')
+           break;
+         ++input_line_pointer;
+       }
       break;
 
     case DW_CFA_undefined:
-      reg1 = cfi_parse_reg ();
-      cfi_add_CFA_undefined (reg1);
+      for (;;)
+       {
+         reg1 = cfi_parse_reg ();
+         cfi_add_CFA_undefined (reg1);
+         SKIP_WHITESPACE ();
+         if (*input_line_pointer != ',')
+           break;
+         ++input_line_pointer;
+       }
       break;
 
     case DW_CFA_same_value:
@@ -552,6 +563,7 @@ dot_cfi_escape (int ignored ATTRIBUTE_UNUSED)
   if (!cur_fde_data)
     {
       as_bad (_("CFI instruction used without previous .cfi_startproc"));
+      ignore_rest_of_line ();
       return;
     }
 
@@ -574,6 +586,9 @@ dot_cfi_escape (int ignored ATTRIBUTE_UNUSED)
   insn = alloc_cfi_insn_data ();
   insn->insn = CFI_escape;
   insn->u.esc = head;
+
+  --input_line_pointer;
+  demand_empty_rest_of_line ();
 }
 
 static void
@@ -584,6 +599,7 @@ dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
   if (cur_fde_data)
     {
       as_bad (_("previous CFI entry not closed (missing .cfi_endproc)"));
+      ignore_rest_of_line ();
       return;
     }
 
@@ -607,6 +623,7 @@ dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
     }
   demand_empty_rest_of_line ();
 
+  cur_cfa_offset = 0;
   if (!simple)
     tc_cfi_frame_initial_instructions ();
 }
@@ -617,10 +634,13 @@ dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED)
   if (! cur_fde_data)
     {
       as_bad (_(".cfi_endproc without corresponding .cfi_startproc"));
+      ignore_rest_of_line ();
       return;
     }
 
   cfi_end_fde (symbol_temp_new_now ());
+
+  demand_empty_rest_of_line ();
 }
 
 \f
@@ -728,7 +748,7 @@ output_cfi_insn (struct cfi_insn_data *insn)
        {
          out_one (DW_CFA_def_cfa_sf);
          out_uleb128 (insn->u.ri.reg);
-         out_uleb128 (offset);
+         out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT);
        }
       else
        {
@@ -750,7 +770,7 @@ output_cfi_insn (struct cfi_insn_data *insn)
       if (offset < 0)
        {
          out_one (DW_CFA_def_cfa_offset_sf);
-         out_sleb128 (offset);
+         out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT);
        }
       else
        {
@@ -862,7 +882,7 @@ output_cie (struct cie_entry *cie)
     for (i = cie->first; i != cie->last; i = i->next)
       output_cfi_insn (i);
 
-  frag_align (2, 0, 0);
+  frag_align (2, DW_CFA_nop, 0);
   symbol_set_value_now (end_address);
 }
 
@@ -912,7 +932,7 @@ output_fde (struct fde_entry *fde, struct cie_entry *cie,
   for (; first; first = first->next)
     output_cfi_insn (first);
 
-  frag_align (align, 0, 0);
+  frag_align (align, DW_CFA_nop, 0);
   symbol_set_value_now (end_address);
 }
 
@@ -1031,10 +1051,8 @@ cfi_finish (void)
 
   /* Open .eh_frame section.  */
   cfi_seg = subseg_new (".eh_frame", 0);
-#ifdef BFD_ASSEMBLER
   bfd_set_section_flags (stdoutput, cfi_seg,
                         SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY);
-#endif
   subseg_set (cfi_seg, 0);
   record_alignment (cfi_seg, EH_FRAME_ALIGNMENT);
 
This page took 0.025021 seconds and 4 git commands to generate.