This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR binutils/12004: "ar --plugin" doesn't work with more than 9 files
- From: Rafael Espindola <espindola at google dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 15 Sep 2010 12:10:09 -0400
- Subject: Re: PATCH: PR binutils/12004: "ar --plugin" doesn't work with more than 9 files
- References: <20100915153254.GA30572@intel.com>
I think this is OK, but don't think I am qualified to actually approve
it. I probably never noticed this because ar is normally passed .o
files and the LLVM plugin uses the filename instead of fd when
handling them.
Thanks,
Rafael
On 15 September 2010 11:32, H.J. Lu <hongjiu.lu@intel.com> wrote:
> 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)
>
--
Rafael Ãvila de EspÃndola