return 1;
}
-/* Close the plugin file descriptor. */
+/* Close the plugin file descriptor FD. If ABFD isn't NULL, it is an
+ archive member. */
void
bfd_plugin_close_file_descriptor (bfd *abfd, int fd)
{
- bfd *iobfd;
-
- iobfd = abfd;
- while (iobfd->my_archive
- && !bfd_is_thin_archive (iobfd->my_archive))
- iobfd = iobfd->my_archive;
- if (iobfd == abfd)
+ if (abfd == NULL)
close (fd);
else
{
- iobfd->archive_plugin_fd_open_count--;
+ while (abfd->my_archive
+ && !bfd_is_thin_archive (abfd->my_archive))
+ abfd = abfd->my_archive;
+
+ abfd->archive_plugin_fd_open_count--;
/* Dup the archive plugin file descriptor for later use, which
will be closed by _bfd_archive_close_and_cleanup. */
- if (iobfd->archive_plugin_fd_open_count == 0)
+ if (abfd->archive_plugin_fd_open_count == 0)
{
- iobfd->archive_plugin_fd = dup (fd);
+ abfd->archive_plugin_fd = dup (fd);
close (fd);
}
}
&& current_plugin->claim_file)
{
current_plugin->claim_file (&file, &claimed);
- bfd_plugin_close_file_descriptor (abfd, file.fd);
+ bfd_plugin_close_file_descriptor ((abfd->my_archive != NULL
+ ? abfd : NULL),
+ file.fd);
}
return claimed;
pointer. */
typedef struct plugin_input_file
{
+ /* The dummy BFD. */
bfd *abfd;
+ /* The original input BFD. Non-NULL if it is an archive member. */
bfd *ibfd;
view_buffer_t view_buffer;
char *name;
file.handle = input;
input->abfd = abfd;
- input->ibfd = ibfd;
+ input->ibfd = ibfd->my_archive != NULL ? ibfd : NULL;
input->view_buffer.addr = NULL;
input->view_buffer.filesize = 0;
input->view_buffer.offset = 0;