After bfd_close nothing should access bfd memory. Now that bfd_close
always tidies up even after an error, attempting to tidy the cached
bfd list by calling bfd_cache_close is wrong and not needed.
PR 30060
* ar.c (remove_output): Don't call bfd_cache_close.
(output_bfd): Delete.
* arsup.c (ar_end): Call bfd_close_all_done, not bfd_cache_close.
static const char *output_filename = NULL;
static FILE *output_file = NULL;
-static bfd *output_bfd = NULL;
static void
remove_output (void)
{
if (output_filename != NULL)
{
- if (output_bfd != NULL)
- bfd_cache_close (output_bfd);
if (output_file != NULL)
fclose (output_file);
unlink_if_ordinary (output_filename);
bfd_fatal (old_name);
}
- output_bfd = obfd;
-
bfd_set_format (obfd, bfd_archive);
/* Request writing the archive symbol table unless we've
if (!bfd_close (obfd))
bfd_fatal (old_name);
- output_bfd = NULL;
output_filename = NULL;
/* We don't care if this fails; we might be creating the archive. */
{
if (obfd)
{
- bfd_cache_close (obfd);
- unlink (bfd_get_filename (obfd));
+ const char *filename = bfd_get_filename (obfd);
+ bfd_close_all_done (obfd);
+ unlink (filename);
}
}