diff options
author | Alan Modra <amodra@gmail.com> | 2023-01-27 15:32:06 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-01-27 15:47:09 +1030 |
commit | 1f5e6267aacce29ad21b0c2d072b6029ba6c14ac (patch) | |
tree | d2afcf864bd435dbb8284d4dfee7dfa78a5db2d5 /ld/ldmain.c | |
parent | 8219cab3f883cb9981e533407d3ce93d9da7d5f2 (diff) | |
download | binutils-1f5e6267aacce29ad21b0c2d072b6029ba6c14ac.zip binutils-1f5e6267aacce29ad21b0c2d072b6029ba6c14ac.tar.gz binutils-1f5e6267aacce29ad21b0c2d072b6029ba6c14ac.tar.bz2 |
Call bfd_close_all_done in ld_cleanup
This is similar to "Call bfd_close_all_done in output_file_close",
but with some code tidying in the pe/pep write_build_id functions.
write_build_id is passed the output bfd as its parameter, so there is
no need to go looking for the output bfd via link_info (and doing so
will no longer work since I clear link_info.output_bfd before calling
bfd_close).
* emultempl/pe.em (write_build_id): Rename t to td. Formatting.
Don't access pe_data(link_info.output_bfd), use td instead.
(setup_build_id): Rename t to td. Formatting.
* emultempl/pep.em: As for pe.em.
* ldmain.c (ld_cleanup): Call bfd_close_all_done on linker bfds.
(main): Clear link_info.output_bfd when closing.
Diffstat (limited to 'ld/ldmain.c')
-rw-r--r-- | ld/ldmain.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c index 9290a18..8c2fc9b 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -212,7 +212,14 @@ write_dependency_file (void) static void ld_cleanup (void) { - bfd_cache_close_all (); + bfd *ibfd, *inext; + if (link_info.output_bfd) + bfd_close_all_done (link_info.output_bfd); + for (ibfd = link_info.input_bfds; ibfd; ibfd = inext) + { + inext = ibfd->link.next; + bfd_close_all_done (ibfd); + } #if BFD_SUPPORTS_PLUGINS plugin_call_cleanup (); #endif @@ -559,7 +566,9 @@ main (int argc, char **argv) } else { - if (!bfd_close (link_info.output_bfd)) + bfd *obfd = link_info.output_bfd; + link_info.output_bfd = NULL; + if (!bfd_close (obfd)) einfo (_("%F%P: %s: final close failed: %E\n"), output_filename); /* If the --force-exe-suffix is enabled, and we're making an @@ -621,7 +630,7 @@ main (int argc, char **argv) fflush (stderr); } - /* Prevent ld_cleanup from doing anything, after a successful link. */ + /* Prevent ld_cleanup from deleting the output file. */ output_filename = NULL; xexit (0); |