Handle NULL iostream in bfd_plugin_object_p.

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

	PR binutils/12004
	* plugin.c (bfd_plugin_object_p): Handle NULL iostream.
This commit is contained in:
H.J. Lu
2010-09-15 17:12:59 +00:00
parent 492d5973f0
commit 028ed2b2b6
2 changed files with 20 additions and 10 deletions

@ -1,3 +1,8 @@
2010-09-15 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/12004
* plugin.c (bfd_plugin_object_p): Handle NULL iostream.
2010-09-14 Kai Tietz <kai.tietz@onevision.com> 2010-09-14 Kai Tietz <kai.tietz@onevision.com>
* pe-x86_64.c (COFF_SECTION_ALIGNMENT_ENTRIES): Make * pe-x86_64.c (COFF_SECTION_ALIGNMENT_ENTRIES): Make

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