This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Running GCC as root
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:
$ 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.
Maciej