2000-08-11 Kazu Hirata <kazu@hxi.com>
[deliverable/binutils-gdb.git] / gas / frags.c
index 882cb12284f77ba3a6db1c1d4b8ea7e25064ce3a..5c31b7e89318d527d9154691b739c7a442aff131 100644 (file)
@@ -1,5 +1,5 @@
 /* frags.c - manage frags -
 /* frags.c - manage frags -
-   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 1998
+   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -74,11 +74,13 @@ frag_grow (nchars)
       frag_new (0);
       oldc = frchain_now->frch_obstack.chunk_size;
       frchain_now->frch_obstack.chunk_size = 2 * nchars + SIZEOF_STRUCT_FRAG;
       frag_new (0);
       oldc = frchain_now->frch_obstack.chunk_size;
       frchain_now->frch_obstack.chunk_size = 2 * nchars + SIZEOF_STRUCT_FRAG;
-      while ((n = obstack_room (&frchain_now->frch_obstack)) < nchars)
-       {
-         frag_wane (frag_now);
-         frag_new (0);
-       }
+      if (frchain_now->frch_obstack.chunk_size > 0)
+       while ((n = obstack_room (&frchain_now->frch_obstack)) < nchars
+              && (unsigned long) frchain_now->frch_obstack.chunk_size > nchars)
+         {
+           frag_wane (frag_now);
+           frag_new (0);
+         }
       frchain_now->frch_obstack.chunk_size = oldc;
     }
   if (obstack_room (&frchain_now->frch_obstack) < nchars)
       frchain_now->frch_obstack.chunk_size = oldc;
     }
   if (obstack_room (&frchain_now->frch_obstack) < nchars)
@@ -93,11 +95,14 @@ frag_grow (nchars)
  * [frchain_now remains the same but frag_now is updated.]
  * Because this calculates the correct value of fr_fix by
  * looking at the obstack 'frags', it needs to know how many
  * [frchain_now remains the same but frag_now is updated.]
  * Because this calculates the correct value of fr_fix by
  * looking at the obstack 'frags', it needs to know how many
- * characters at the end of the old frag belong to (the maximal)
- * fr_var: the rest must belong to fr_fix.
- * It doesn't actually set up the old frag's fr_var: you may have
- * set fr_var == 1, but allocated 10 chars to the end of the frag:
- * in this case you pass old_frags_var_max_size == 10.
+ * characters at the end of the old frag belong to the maximal
+ * variable part;  The rest must belong to fr_fix.
+ * It doesn't actually set up the old frag's fr_var.  You may have
+ * set fr_var == 1, but allocated 10 chars to the end of the frag;
+ * In this case you pass old_frags_var_max_size == 10.
+ * In fact, you may use fr_var for something totally unrelated to the
+ * size of the variable part of the frag;  None of the generic frag
+ * handling code makes use of fr_var.
  *
  * Make a new frag, initialising some components. Link new frag at end
  * of frchain_now.
  *
  * Make a new frag, initialising some components. Link new frag at end
  * of frchain_now.
@@ -298,9 +303,10 @@ frag_align (alignment, fill_character, max)
   if (now_seg == absolute_section)
     {
       addressT new_off;
   if (now_seg == absolute_section)
     {
       addressT new_off;
+      addressT mask;
 
 
-      new_off = ((abs_section_offset + alignment - 1)
-                &~ ((1 << alignment) - 1));
+      mask = (~ (addressT) 0) << alignment;
+      new_off = (abs_section_offset + ~ mask) & mask;
       if (max == 0 || new_off - abs_section_offset <= (addressT) max)
        abs_section_offset = new_off;
     }
       if (max == 0 || new_off - abs_section_offset <= (addressT) max)
        abs_section_offset = new_off;
     }
This page took 0.025266 seconds and 4 git commands to generate.