Orphan output section with multiple input sections
[deliverable/binutils-gdb.git] / bfd / section.c
index 834a9ab0b4c1f7f0786dda4e431c7674b0e3a35c..247d98ad1417b2b8cf41974d4edffc968c3fa7fe 100644 (file)
@@ -903,16 +903,18 @@ FUNCTION
        bfd_get_next_section_by_name
 
 SYNOPSIS
-       asection *bfd_get_next_section_by_name (asection *sec);
+       asection *bfd_get_next_section_by_name (bfd *ibfd, asection *sec);
 
 DESCRIPTION
        Given @var{sec} is a section returned by @code{bfd_get_section_by_name},
        return the next most recently created section attached to the same
-       BFD with the same name.  Return NULL if no such section exists.
+       BFD with the same name, or if no such section exists in the same BFD and
+       IBFD is non-NULL, the next section with the same name in any input
+       BFD following IBFD.  Return NULL on finding no section.
 */
 
 asection *
-bfd_get_next_section_by_name (asection *sec)
+bfd_get_next_section_by_name (bfd *ibfd, asection *sec)
 {
   struct section_hash_entry *sh;
   const char *name;
@@ -930,6 +932,16 @@ bfd_get_next_section_by_name (asection *sec)
        && strcmp (sh->root.string, name) == 0)
       return &sh->section;
 
+  if (ibfd != NULL)
+    {
+      while ((ibfd = ibfd->link.next) != NULL)
+       {
+         asection *s = bfd_get_section_by_name (ibfd, name);
+         if (s != NULL)
+           return s;
+       }
+    }
+
   return NULL;
 }
 
@@ -951,7 +963,7 @@ bfd_get_linker_section (bfd *abfd, const char *name)
   asection *sec = bfd_get_section_by_name (abfd, name);
 
   while (sec != NULL && (sec->flags & SEC_LINKER_CREATED) == 0)
-    sec = bfd_get_next_section_by_name (sec);
+    sec = bfd_get_next_section_by_name (NULL, sec);
   return sec;
 }
 
This page took 0.024867 seconds and 4 git commands to generate.