This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch ld]: Close BFDs before linker-plugin's atexit routine is called


2011/2/14 Alan Modra <amodra@gmail.com>:
> On Wed, Feb 09, 2011 at 07:51:58PM +0100, Kai Tietz wrote:
>> 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.

Hi Alan,

> The fact that you need to patch three places to fix one problem
> says to me that this isn't the best fix..
Well, here I am not that sure about. I thought about fixing it just
within the atexit-handler of plugin, but well, next one trying to
opearate on files in a similar way, will have the same issues again. I
think it is simply bad style to exit a program without even try to
cleanup  opened file descriptors and used memory. This could even help
to use tools like valgrind on ld ...

> ?Does a single
> bfd_cache_close_all at the start of plugin_call_cleanup fix your
> problem?
Yes, it does.

Regards,
Kai


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]