+ if (mri_common_symbol != NULL)
+ {
+ as_bad (_("attempt to allocate data in common section"));
+ mri_common_symbol = NULL;
+ }
+}
+
+/* Allocate a frag on the specified obstack.
+ Call this routine from everywhere else, so that all the weird alignment
+ hackery can be done in just one place. */
+
+fragS *
+frag_alloc (struct obstack *ob)
+{
+ fragS *ptr;
+ int oalign;
+
+ (void) obstack_alloc (ob, 0);
+ oalign = obstack_alignment_mask (ob);
+ obstack_alignment_mask (ob) = 0;
+ ptr = (fragS *) obstack_alloc (ob, SIZEOF_STRUCT_FRAG);
+ obstack_alignment_mask (ob) = oalign;
+ memset (ptr, 0, SIZEOF_STRUCT_FRAG);
+ totalfrags++;
+ return ptr;
+}
+\f
+/* Try to augment current frag by nchars chars.
+ If there is no room, close off the current frag with a ".fill 0"
+ and begin a new frag. Then loop until the new frag has at least
+ nchars chars available. Does not set up any fields in frag_now. */
+
+void
+frag_grow (size_t nchars)
+{
+ if (obstack_room (&frchain_now->frch_obstack) < nchars)
+ {
+ size_t oldc;
+ size_t newc;
+
+ /* Try to allocate a bit more than needed right now. But don't do
+ this if we would waste too much memory. Especially necessary
+ for extremely big (like 2GB initialized) frags. */
+ if (nchars < 0x10000)
+ newc = 2 * nchars;
+ else
+ newc = nchars + 0x10000;
+ newc += SIZEOF_STRUCT_FRAG;
+
+ /* Check for possible overflow. */
+ if (newc < nchars)
+ as_fatal (ngettext ("can't extend frag %lu char",
+ "can't extend frag %lu chars",
+ (unsigned long) nchars),
+ (unsigned long) nchars);
+
+ /* Force to allocate at least NEWC bytes, but not less than the
+ default. */
+ oldc = obstack_chunk_size (&frchain_now->frch_obstack);
+ if (newc > oldc)
+ obstack_chunk_size (&frchain_now->frch_obstack) = newc;
+
+ while (obstack_room (&frchain_now->frch_obstack) < nchars)
+ {
+ /* Not enough room in this frag. Close it and start a new one.
+ This must be done in a loop because the created frag may not
+ be big enough if the current obstack chunk is used. */
+ frag_wane (frag_now);
+ frag_new (0);
+ }
+
+ /* Restore the old chunk size. */
+ obstack_chunk_size (&frchain_now->frch_obstack) = oldc;