2012-01-10 Tristan Gingold <gingold@adacore.com>
authorTristan Gingold <gingold@adacore.com>
Tue, 10 Jan 2012 11:51:09 +0000 (11:51 +0000)
committerTristan Gingold <gingold@adacore.com>
Tue, 10 Jan 2012 11:51:09 +0000 (11:51 +0000)
* bfdio.c (bfd_tell): Handle nested archives.
(bfd_seek): Ditto.
* cache.c (bfd_cache_lookup_worker): Ditto.
* archive.c (_bfd_get_elt_at_filepos): Remove code dealing with
nested archives.
(bfd_generic_openr_next_archived_file): Likewise.

bfd/ChangeLog
bfd/archive.c
bfd/bfdio.c
bfd/cache.c

index d820ad24c3ea34caea506741b9dd2e6ef4f11440..5b623188991c9672f5e6cd68c2829eacd8cbf1b9 100644 (file)
@@ -1,3 +1,12 @@
+2012-01-10  Tristan Gingold  <gingold@adacore.com>
+
+       * bfdio.c (bfd_tell): Handle nested archives.
+       (bfd_seek): Ditto.
+       * cache.c (bfd_cache_lookup_worker): Ditto.
+       * archive.c (_bfd_get_elt_at_filepos): Remove code dealing with
+       nested archives.
+       (bfd_generic_openr_next_archived_file): Likewise.
+
 2012-01-09  Iain Sandoe  <idsandoe@googlemail.com>
 
        * mach-o.c (bfd_mach_o_bfd_copy_private_symbol_data): Implement.
index 3e333c7e8949870614233df0ab310760caff1c2f..ac2be3e00d9aa69515a2bd3c90ff837b2ab3c6aa 100644 (file)
@@ -581,12 +581,6 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
   bfd *n_nfd;
   char *filename;
 
-  if (archive->my_archive)
-    {
-      filepos += archive->origin;
-      archive = archive->my_archive;
-    }
-
   n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
   if (n_nfd)
     return n_nfd;
@@ -732,8 +726,6 @@ bfd_generic_openr_next_archived_file (bfd *archive, bfd *last_file)
       filestart = last_file->proxy_origin;
       if (! bfd_is_thin_archive (archive))
         filestart += size;
-      if (archive->my_archive)
-       filestart -= archive->origin;
       /* Pad to an even boundary...
         Note that last_file->origin can be odd in the case of
         BSD-4.4-style element with a long odd size.  */
index f8c9f3e4c418ad67762124902ffa73e3227bb05a..c142c179cb475b7b6273d4fe7ba73fc4d1721cc0 100644 (file)
@@ -233,10 +233,14 @@ bfd_tell (bfd *abfd)
 
   if (abfd->iovec)
     {
+      bfd *parent_bfd = abfd;
       ptr = abfd->iovec->btell (abfd);
 
-      if (abfd->my_archive)
-       ptr -= abfd->origin;
+      while (parent_bfd->my_archive != NULL)
+       {
+         ptr -= parent_bfd->origin;
+         parent_bfd = parent_bfd->my_archive;
+       }
     }
   else
     ptr = 0;
@@ -308,8 +312,16 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
     }
 
   file_position = position;
-  if (direction == SEEK_SET && abfd->my_archive != NULL)
-    file_position += abfd->origin;
+  if (direction == SEEK_SET)
+    {
+      bfd *parent_bfd = abfd;
+
+      while (parent_bfd->my_archive != NULL)
+        {
+          file_position += parent_bfd->origin;
+          parent_bfd = parent_bfd->my_archive;
+        }
+    }
 
   if (abfd->iovec)
     result = abfd->iovec->bseek (abfd, file_position, direction);
index 5ddbbe470a04e66c49a1d5dc0c8547823bc6d255..3842f517d1fe8c1942f157d195520ab49d8aab7e 100644 (file)
@@ -198,7 +198,7 @@ bfd_cache_lookup_worker (bfd *abfd, enum cache_flag flag)
   if ((abfd->flags & BFD_IN_MEMORY) != 0)
     abort ();
 
-  if (abfd->my_archive)
+  while (abfd->my_archive)
     abfd = abfd->my_archive;
 
   if (abfd->iostream != NULL)