OSDN Git Service

Add code to cope with nested archives.
authorNick Clifton <nickc@redhat.com>
Wed, 19 May 2004 14:46:59 +0000 (14:46 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 19 May 2004 14:46:59 +0000 (14:46 +0000)
bfd/ChangeLog
bfd/archive.c

index 479cfcc..2904cd0 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-19  Mikulas Patocka  <mikulas@artax.karlin.mff.cuni.cz>
+
+       * archive.c (_bfd_get_elt_at_filepos): Cope with a nested archives.
+       (bfd_generic_openr_next_archived_file): Likewise.
+
 2004-05-17  Bob Wilson  <bob.wilson@acm.org>
 
        * elf32-xtensa.c (xtensa_get_property_section_name): Determine linkonce
index a8d53c6..ec8a086 100644 (file)
@@ -1,24 +1,24 @@
 /* BFD back-end for archive files (libraries).
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003
+   2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Written by Cygnus Support.  Mostly Gumby Henkel-Wallace's fault.
 
-This file is part of BFD, the Binary File Descriptor library.
+   This file is part of BFD, the Binary File Descriptor library.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /*
 @setfilename archive-info
@@ -467,6 +467,12 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
   struct areltdata *new_areldata;
   bfd *n_nfd;
 
+  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;
@@ -549,10 +555,12 @@ bfd_generic_openr_next_archived_file (bfd *archive, bfd *last_file)
   else
     {
       unsigned int size = arelt_size (last_file);
+      filestart = last_file->origin + 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.  */
-      filestart = last_file->origin + size;
       filestart += filestart % 2;
     }