This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR binutils/12004: "ar --plugin" doesn't work with more than 9 files
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Wed, 15 Sep 2010 08:32:54 -0700
- Subject: PATCH: PR binutils/12004: "ar --plugin" doesn't work with more than 9 files
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
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)