RFC: PR 31761: Stop the linker from overwriting source files
Simon Richter
Simon.Richter@hogyros.de
Thu Jun 20 06:14:29 GMT 2024
Hi,
On 6/20/24 09:16, Alan Modra wrote:
> I think your instincts about this PR as shown by your initial comments
> in the PR were correct. I don't think ld should restrict the file
> name given on its command line in any way, except for sanity checking
> against other command line arguments. Trying to make things foolproof
> always fails.
FWIW I have accidentally overwritten source files, but always in the
context of "gcc -o <tab> <space> <tab>" when I meant to edit the output
name first. The "ld -o foo.c foo.o" case is a lot more difficult to
reach, except through the gcc frontend.
What makes sense is checking that input and output files are different
(which ld does), and maybe the gcc frontend could get a check like that
as well.
Simon
More information about the Binutils
mailing list