]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* write.c (write_object_file): Make use of bfd_section_list_remove.
authorAlan Modra <amodra@gmail.com>
Sat, 5 Jan 2002 13:13:18 +0000 (13:13 +0000)
committerAlan Modra <amodra@gmail.com>
Sat, 5 Jan 2002 13:13:18 +0000 (13:13 +0000)
* config/obj-ecoff.c (ecoff_frob_file): Likewise.
* config/tc-mmix.c (mmix_frob_file): Likewise.

gas/ChangeLog
gas/config/obj-ecoff.c
gas/config/tc-mmix.c
gas/write.c

index ea3a95489978009159742fcc833ffb37f2c20062..c1c52f34ad365a314a93e5077f1d9a7e3e7a2790 100644 (file)
@@ -1,3 +1,9 @@
+2002-01-05  Alan Modra  <amodra@bigpond.net.au>
+
+       * write.c (write_object_file): Make use of bfd_section_list_remove.
+       * config/obj-ecoff.c (ecoff_frob_file): Likewise.
+       * config/tc-mmix.c (mmix_frob_file): Likewise.
+
 2002-01-04  Jason Thorpe  <thorpej@wasabisystems.com>
 
        * configure.in (i386-*-netbsdelf*): Collapse target into...
index d1eabceefb9f845d4ee4f552c00b00f8a24964da..4d055cb62eb814ee97dfa01a28f080ab2f45dfe4 100644 (file)
@@ -106,7 +106,7 @@ ecoff_frob_file ()
   const struct ecoff_debug_swap * const debug_swap
     = &ecoff_backend (stdoutput)->debug_swap;
   bfd_vma addr;
-  asection *sec;
+  asection **sec;
   HDRR *hdr;
   char *buf;
   char *set;
@@ -143,53 +143,39 @@ ecoff_frob_file ()
   };
 #define n_names ((int) (sizeof (names) / sizeof (names[0])))
 
+  /* Sections that match names, order to be straightened out later.  */
+  asection *secs[n_names];
+  int i;
+
   addr = 0;
-  {
-    /* Sections that match names, order to be straightened out later.  */
-    asection *secs[n_names];
-    /* Linked list of sections with non-matching names.  Random ordering.  */
-    asection *other_sections = 0;
-    /* Pointer to next section, since we're destroying the original
-       ordering.  */
-    asection *next;
-
-    int i;
-
-    for (i = 0; i < n_names; i++)
-      secs[i] = 0;
-    for (sec = stdoutput->sections; sec != (asection *) NULL; sec = next)
-      {
-       next = sec->next;
-       for (i = 0; i < n_names; i++)
-         if (!strcmp (sec->name, names[i]))
-           {
-             secs[i] = sec;
-             break;
-           }
-       if (i == n_names)
+  for (i = 0; i < n_names; i++)
+    secs[i] = 0;
+
+  for (sec = &stdoutput->sections; *sec != (asection *) NULL; )
+    {
+      for (i = 0; i < n_names; i++)
+       if (!strcmp ((*sec)->name, names[i]))
          {
-           bfd_set_section_vma (stdoutput, sec, addr);
-           addr += bfd_section_size (stdoutput, sec);
-           sec->next = other_sections;
-           other_sections = sec;
+           secs[i] = *sec;
+           bfd_section_list_remove (stdoutput, sec);
+           break;
          }
-      }
-    for (i = 0; i < n_names; i++)
-      if (secs[i])
+      if (i == n_names)
        {
-         sec = secs[i];
-         bfd_set_section_vma (stdoutput, sec, addr);
-         addr += bfd_section_size (stdoutput, sec);
+         bfd_set_section_vma (stdoutput, *sec, addr);
+         addr += bfd_section_size (stdoutput, *sec);
+         sec = &(*sec)->next;
        }
-    for (i = n_names - 1; i >= 0; i--)
-      if (secs[i])
-       {
-         sec = secs[i];
-         sec->next = other_sections;
-         other_sections = sec;
-       }
-    stdoutput->sections = other_sections;
-  }
+    }
+  for (i = 0; i < n_names; i++)
+    if (secs[i])
+      {
+       bfd_set_section_vma (stdoutput, secs[i], addr);
+       addr += bfd_section_size (stdoutput, secs[i]);
+      }
+  for (i = n_names - 1; i >= 0; i--)
+    if (secs[i])
+      bfd_section_list_insert (stdoutput, &stdoutput->sections, secs[i]);
 
   /* Build the ECOFF debugging information.  */
   assert (ecoff_data (stdoutput) != 0);
index 46d5decf9e120e64788153e8561f90f5a586fc95..fcd7f1e3b0623cc160910bb8ff8276b71915686d 100644 (file)
@@ -3629,14 +3629,12 @@ mmix_frob_file ()
       if (bfd_get_section_flags (stdoutput, real_reg_section) & SEC_HAS_CONTENTS)
        as_fatal (_("register section has contents\n"));
 
-      /* FIXME: This does not seem like the proper way to kill a section,
-        but it's the way it's done elsewhere, like elf64-alpha.c.  */
       /* Really remove the section.  */
       for (secpp = &stdoutput->sections;
           *secpp != real_reg_section;
           secpp = &(*secpp)->next)
        ;
-      *secpp = (*secpp)->next;
+      bfd_section_list_remove (stdoutput, secpp);
       --stdoutput->section_count;
     }
 
index 55db85a7ec91e30f1f861021f3f65c86512d965a..9b20f909194db2d1aa1fc35189a12bf1cac0074c 100644 (file)
@@ -1507,22 +1507,18 @@ write_object_file ()
 #ifdef BFD_ASSEMBLER
   /* Remove the sections created by gas for its own purposes.  */
   {
-    asection **seclist, *sec;
+    asection **seclist;
     int i;
 
     seclist = &stdoutput->sections;
-    while (seclist && *seclist)
+    while (*seclist)
       {
-       sec = *seclist;
-       while (sec == reg_section || sec == expr_section)
+       if (*seclist == reg_section || *seclist == expr_section)
          {
-           sec = sec->next;
-           *seclist = sec;
+           bfd_section_list_remove (stdoutput, seclist);
            stdoutput->section_count--;
-           if (!sec)
-             break;
          }
-       if (*seclist)
+       else
          seclist = &(*seclist)->next;
       }
     i = 0;