[patch ld]: Close BFDs before linker-plugin's atexit routine is called
Kai Tietz
ktietz70@googlemail.com
Wed Feb 9 18:52:00 GMT 2011
Hello,
This is patch addresses the unlink call when lto linker-plugin is
used. As windows
native doesn't support to unlink still opened files, it fails to do so
as file-descriptors
of bfds aren't closed before atexit routine of plugin gets called.
2011-02-09 Kai Tietz
* ldmain.c (remove_output): Set output_bfd
of link_info to nil and close all cached bfds.
(main): Close output_bfd of link_info and set
it to nil. Additionally close all cached bfds.
Tested on x86_64-pc-linux-gnu and x86_64-w64-mingw32. Ok for apply?
Regards,
Kai
-------------- next part --------------
Index: src/ld/ldmain.c
===================================================================
--- src.orig/ld/ldmain.c 2011-01-18 19:49:25.000000000 +0100
+++ src/ld/ldmain.c 2011-02-09 18:49:38.148905600 +0100
@@ -180,6 +180,8 @@ remove_output (void)
{
if (link_info.output_bfd)
bfd_cache_close (link_info.output_bfd);
+ link_info.output_bfd = NULL;
+ bfd_cache_close_all ();
if (delete_output_file_on_failure)
unlink_if_ordinary (output_filename);
}
@@ -489,6 +491,10 @@ main (int argc, char **argv)
output_filename);
/* The file will be removed by remove_output. */
+ if (link_info.output_bfd)
+ bfd_cache_close (link_info.output_bfd);
+ link_info.output_bfd = NULL;
+ bfd_cache_close_all ();
xexit (1);
}
else
@@ -564,6 +570,10 @@ main (int argc, char **argv)
/* Prevent remove_output from doing anything, after a successful link. */
output_filename = NULL;
+ if (link_info.output_bfd)
+ bfd_cache_close (link_info.output_bfd);
+ link_info.output_bfd = NULL;
+ bfd_cache_close_all ();
xexit (0);
return 0;
}
More information about the Binutils
mailing list