This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ranlib.exe crashes with lto-plugin
- From: KONRAD Frederic <frederic dot konrad at adacore dot com>
- To: amodra at gmail dot com
- Cc: binutils at sourceware dot org
- Date: Wed, 12 Sep 2018 18:05:59 +0200
- Subject: ranlib.exe crashes with lto-plugin
Hello Alan,
I found a bug with ranlib + "-flto" compilation flag under
windows since:
commit 27b0767593284f97384b3597ebd211164f8c8b47
Author: Alan Modra <amodra@gmail.com>
Date: Tue Jun 5 21:04:00 2018 +0930
PR23254, ld.bfd mishandles file pointers while scanning
archive
With a dummy test.c file:
void foo(void)
{
}
Compiling test.c: `gcc -flto -c test.c -o test.o
Creating an archive with it: `ar cr test.a test.o`
Running ranlib on it: `ranlib test.a`
Will trigger the following error:
C:\..\ranlib.exe: unable to rename 'test.a'; reason: File
exists
The reason is that the second opened file descriptor in
bfd_plugin_open_input is only closed if claim_file is failing so
smart_rename is failing as it tries to remove the file..
It seems to me that the lto-plugin doesn't use the file
descriptor after claim_file is called.. So I though that a
solution would be to implement release_input_file in bfd/plugin.c
and call it in the lto-plugin.. But it seems overkill to me and I
don't see any clean or simple fix for that.. Do you have any
idea?
Regards,
Fred