This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR binutils/13257: NM + plugin does not list correctly symbols in thin archives


On Mon, Oct 10, 2011 at 12:52:26PM -0700, H.J. Lu wrote:
> We never pass "plugin" when opening a new bfd on archive members.

The PR shows that nm works as expected for normal archives, doesn't
it?  So the problem is only with thin archives.

>  This patch fixes it.  OK to install?

I think there is a more general bug here with thin archives.  If you
take a look at what happens with normal archives, you'll see the
element bfd inheriting the containing archive xvec and various other
flags (_bfd_new_bfd_contained_in).  We ought to do something similary
with thin archives.

	PR binutils/13257
	* archive.c (_bfd_find_nested_archive, _bfd_get_elt_at_filepos): Open
	thin archive element using container target if not defaulted.

Index: bfd/archive.c
===================================================================
RCS file: /cvs/src/src/bfd/archive.c,v
retrieving revision 1.77
diff -u -p -r1.77 archive.c
--- bfd/archive.c	31 May 2011 14:27:39 -0000	1.77
+++ bfd/archive.c	11 Oct 2011 01:34:59 -0000
@@ -343,6 +343,7 @@ static bfd *
 _bfd_find_nested_archive (bfd *arch_bfd, const char *filename)
 {
   bfd *abfd;
+  const char *target;
 
   for (abfd = arch_bfd->nested_archives;
        abfd != NULL;
@@ -351,7 +352,10 @@ _bfd_find_nested_archive (bfd *arch_bfd,
       if (filename_cmp (filename, abfd->filename) == 0)
         return abfd;
     }
-  abfd = bfd_openr (filename, NULL);
+  target = NULL;
+  if (!arch_bfd->target_defaulted)
+    target = arch_bfd->xvec->name;
+  abfd = bfd_openr (filename, target);
   if (abfd)
     {
       abfd->archive_next = arch_bfd->nested_archives;
@@ -597,6 +601,8 @@ _bfd_get_elt_at_filepos (bfd *archive, f
 
   if (bfd_is_thin_archive (archive))
     {
+      const char *target;
+
       /* This is a proxy entry for an external file.  */
       if (! IS_ABSOLUTE_PATH (filename))
         {
@@ -628,7 +634,10 @@ _bfd_get_elt_at_filepos (bfd *archive, f
         }
       /* It's not an element of a nested archive;
          open the external file as a bfd.  */
-      n_nfd = bfd_openr (filename, NULL);
+      target = NULL;
+      if (!archive->target_defaulted)
+	target = archive->xvec->name;
+      n_nfd = bfd_openr (filename, target);
       if (n_nfd == NULL)
 	bfd_set_error (bfd_error_malformed_archive);
     }

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]