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]

PATCH: PR binutils/12004: "ar --plugin" doesn't work with more than 9 files


cache.c has

#define BFD_CACHE_MAX_OPEN 10
...

bfd_boolean
bfd_cache_init (bfd *abfd)
{
  BFD_ASSERT (abfd->iostream != NULL);
  if (open_files >= BFD_CACHE_MAX_OPEN)
    {   
      if (! close_one ()) 
        return FALSE;
    }   
  abfd->iovec = &cache_iovec;
  insert (abfd);
  ++open_files;
  return TRUE;
}

When you use AR with more than 9 files, one of them will be closed. But
plugin isn't prepared to deal with it.  This patch calls bfd_open_file
if iostream is NULL.  OK to install?

Thanks.


H.J.
---
2010-09-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/12004
	* plugin.c (bfd_plugin_object_p): Handle NULL iostream.

diff --git a/bfd/plugin.c b/bfd/plugin.c
index 4c24a7f..a46bf90 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -233,26 +233,31 @@ bfd_plugin_object_p (bfd *abfd)
   int claimed = 0;
   int t = load_plugin ();
   struct ld_plugin_input_file file;
+  bfd *iobfd;
+
   if (!t)
     return NULL;
 
   file.name = abfd->filename;
 
-  if (abfd->iostream)
+  if (abfd->my_archive)
     {
-      file.fd = fileno ((FILE *) abfd->iostream);
-      file.offset = 0;
-      file.filesize = 0; /*FIXME*/
+      iobfd = abfd->my_archive;
+      file.offset = abfd->origin;
+      file.filesize = arelt_size (abfd);
     }
   else
     {
-      bfd *archive = abfd->my_archive;
-      BFD_ASSERT (archive);
-      file.fd = fileno ((FILE *) archive->iostream);
-      file.offset = abfd->origin;
-      file.filesize = arelt_size (abfd);
-
+      iobfd = abfd;
+      file.offset = 0;
+      file.filesize = 0; /*FIXME*/
     }
+
+  if (!iobfd->iostream && !bfd_open_file (iobfd))
+    return NULL;
+
+  file.fd = fileno ((FILE *) iobfd->iostream);
+
   file.handle = abfd;
   claim_file (&file, &claimed);
   if (!claimed)


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