]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/opncls.c
Add support for thin archives.
[thirdparty/binutils-gdb.git] / bfd / opncls.c
index 47fef7036a22093a301d3ecc2a5ee0c13548653c..2ceb77eb21aa8417c0ea992eed77906728d3d0bf 100644 (file)
@@ -647,6 +647,8 @@ bfd_boolean
 bfd_close (bfd *abfd)
 {
   bfd_boolean ret;
+  bfd *nbfd;
+  bfd *next;
 
   if (bfd_write_p (abfd))
     {
@@ -654,6 +656,13 @@ bfd_close (bfd *abfd)
        return FALSE;
     }
 
+  /* Close nested archives (if this bfd is a thin archive).  */
+  for (nbfd = abfd->nested_archives; nbfd; nbfd = next)
+    {
+      next = nbfd->archive_next;
+      bfd_close (nbfd);
+    }
+
   if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
     return FALSE;