bfd/
[deliverable/binutils-gdb.git] / gas / ehopt.c
index c25fd51e5db1f32e2ef386e816cd00e6b43515e2..048bc57b5a09f5fbcee50e93ab90e086a9571993 100644 (file)
@@ -1,23 +1,23 @@
 /* ehopt.c--optimize gcc exception frame information.
-   Copyright 1998, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1998, 2000, 2001, 2003, 2005, 2007 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
-This file is part of GAS, the GNU Assembler.
+   This file is part of GAS, the GNU Assembler.
 
-GAS is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+   GAS is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
 
-GAS is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   GAS is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-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.  */
+   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, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 #include "as.h"
 #include "subsegs.h"
@@ -94,13 +94,12 @@ struct cie_info
   int z_augmentation;
 };
 
-static int get_cie_info PARAMS ((struct cie_info *));
+static int get_cie_info (struct cie_info *);
 
 /* Extract information from the CIE.  */
 
 static int
-get_cie_info (info)
-     struct cie_info *info;
+get_cie_info (struct cie_info *info)
 {
   fragS *f;
   fixS *fix;
@@ -112,16 +111,8 @@ get_cie_info (info)
 
   /* We should find the CIE at the start of the section.  */
 
-#if defined (BFD_ASSEMBLER) || defined (MANY_SEGMENTS)
   f = seg_info (now_seg)->frchainP->frch_root;
-#else
-  f = frchain_now->frch_root;
-#endif
-#ifdef BFD_ASSEMBLER
   fix = seg_info (now_seg)->frchainP->fix_root;
-#else
-  fix = *seg_fix_rootP;
-#endif
 
   /* Look through the frags of the section to find the code alignment.  */
 
@@ -248,9 +239,7 @@ get_cie_info (info)
    change *EXP and *PNBYTES.  */
 
 int
-check_eh_frame (exp, pnbytes)
-     expressionS *exp;
-     unsigned int *pnbytes;
+check_eh_frame (expressionS *exp, unsigned int *pnbytes)
 {
   struct frame_data
   {
@@ -286,6 +275,11 @@ check_eh_frame (exp, pnbytes)
   if (flag_traditional_format)
     return 0;
 
+#ifdef md_allow_eh_opt
+  if (! md_allow_eh_opt)
+    return 0;
+#endif
+
   /* Select the proper section data.  */
   if (strcmp (segment_name (now_seg), ".eh_frame") == 0)
     d = &eh_frame_data;
@@ -363,6 +357,8 @@ check_eh_frame (exp, pnbytes)
        }
       else
        d->state = state_error;
+      if (d->state == state_skipping_aug && d->aug_size == 0)
+       d->state = state_wait_loc4;
       break;
 
     case state_skipping_aug:
@@ -370,7 +366,7 @@ check_eh_frame (exp, pnbytes)
        d->state = state_error;
       else
        {
-          int left = (d->aug_size -= *pnbytes);
+         int left = (d->aug_size -= *pnbytes);
          if (left == 0)
            d->state = state_wait_loc4;
          else if (left < 0)
@@ -455,14 +451,13 @@ check_eh_frame (exp, pnbytes)
    relaxation loop.  We set fr_subtype{0:2} to the expected length.  */
 
 int
-eh_frame_estimate_size_before_relax (frag)
-     fragS *frag;
+eh_frame_estimate_size_before_relax (fragS *frag)
 {
   offsetT diff;
   int ca = frag->fr_subtype >> 3;
   int ret;
 
-  diff = resolve_symbol_value (frag->fr_symbol, 0);
+  diff = resolve_symbol_value (frag->fr_symbol);
 
   if (ca > 0 && diff % ca == 0 && diff / ca < 0x40)
     ret = 0;
@@ -483,8 +478,7 @@ eh_frame_estimate_size_before_relax (frag)
    the frag.  This returns the change in frag length.  */
 
 int
-eh_frame_relax_frag (frag)
-     fragS *frag;
+eh_frame_relax_frag (fragS *frag)
 {
   int oldsize, newsize;
 
@@ -498,8 +492,7 @@ eh_frame_relax_frag (frag)
    fr_subtype{0:2} will be the desired length of the frag.  */
 
 void
-eh_frame_convert_frag (frag)
-     fragS *frag;
+eh_frame_convert_frag (fragS *frag)
 {
   offsetT diff;
   fragS *loc4_frag;
@@ -508,7 +501,7 @@ eh_frame_convert_frag (frag)
   loc4_frag = (fragS *) frag->fr_opcode;
   loc4_fix = (int) frag->fr_offset;
 
-  diff = resolve_symbol_value (frag->fr_symbol, finalize_syms);
+  diff = resolve_symbol_value (frag->fr_symbol);
 
   switch (frag->fr_subtype & 7)
     {
This page took 0.025028 seconds and 4 git commands to generate.