Fix -save-temp leaking files in /tmp
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 17 Feb 2020 16:40:07 +0000 (17:40 +0100)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Wed, 19 Feb 2020 11:48:54 +0000 (12:48 +0100)
commit73d531205083eaf19934b516b37b1cf4940895c7
tree5e5393a083a3d6873314120c69276168052f5673
parent51faf07cef9293af544bfacc7d0b320ab90d7d60
Fix -save-temp leaking files in /tmp

And avoid signal handler calling signal unsafe functions,
and/or calling unlink with uninitialized memory pointer.

2020-02-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* collect2.c (c_file, o_file): Make const again.
(ldout,lderrout, dump_ld_file): Remove.
(tool_cleanup): Avoid calling not signal-safe functions.
(maybe_run_lto_and_relink): Avoid possible signal handler
access to unintialzed memory (lto_o_files).
(main): Avoid leaking temp files in $TMPDIR.
Initialize c_file/o_file with concat, which avoids exposing
uninitialized memory to signal handler, which calls unlink(!).
Avoid calling maybe_unlink when the main function returns,
since the atexit handler is already doing this.
* collect2.h (dump_ld_file, ldout, lderrout): Remove.
gcc/ChangeLog
gcc/collect2.c
gcc/collect2.h