This is the mail archive of the
mailing list for the GCC project.
Re: Running GCC as root
"Maciej W. Rozycki" <firstname.lastname@example.org> writes:
> On Mon, 14 Feb 2005, Ian Lance Taylor wrote:
> > For the record, this happens because BFD only unlinks the file first
> > if the size is non-zero. BFD considers unlinking the file to avoid
> > errors which arise when overwriting a running binary (e.g., on SunOS
> > this was permitted by the OS, but could sometimes cause signal
> > handlers to fail in the running binary; strange but true). BFD does
> > not unlink an empty file because gcc will create the .o file first in
> > make_temp_file, and unlinking the file would cause the same race
> > condition which gcc is trying to avoid. Of course the issue about a
> > running binary normally only arises with ld, but gas uses the same
> > routine the open the output file.
> Actually gas unlinks files itself:
Well, true, but those are the error cases. You are certainly right
that you could unlink /dev/null by assembling an erroneous input file
with -o /dev/null.
> $ grep unlink gas/*.c
> gas/as.c: unlink (out_file_name);
> gas/messages.c: unlink (out_file_name);
> The second call is the "funny" one I've mentioned -- if you have a look
> there, you'll know what I mean.
I think both calls are correct, actually, although perhaps they
shouldn't unlink devices.