]> git.wh0rd.org Git - elf2flt.git/commitdiff
Rather than putting the `rm` at the end of the script before the normal
authorDavid McCullough <davidm@snapgear.com>
Tue, 2 Jun 2009 00:09:46 +0000 (00:09 +0000)
committerDavid McCullough <davidm@snapgear.com>
Tue, 2 Jun 2009 00:09:46 +0000 (00:09 +0000)
exit point, create a trap to automatically delete the script when exiting.
This way the linker script gets cleaned up whenever there is an error as
well.  Otherwise every link invocation that ends in a failure could leave
behind crap.  On my system, i found almost 2 million of these suckers in
my /tmp dir.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
ld-elf2flt.in

index 32eb7e0cab7fbb62655827f7edb5ec757cc49fb1..91e1ccbea2d084d92faf7582b687c6d1c037fcce 100644 (file)
@@ -107,6 +107,7 @@ then
                [ "$VERBOSE" = "y" ] && set -x
                ARG1="$ARG1 $FINAL_ONLY"
                NEWLDSCRIPT=`mktemp /tmp/flt-XXXXXX`
+               trap 'rm -f "$NEWLDSCRIPT"' EXIT
                SEDOP=" -e s/^R_RODAT// -e /^W_RODAT/d"
                OBJCOPYOP=""
                if [ "$MOVDAT" ]
@@ -225,7 +226,6 @@ then
                 fi
                fi
                [ "$RFILE" = "$OFILE.gdb" ] || rm -f "$RFILE"  # not needed for any reason
-               rm -f "$NEWLDSCRIPT"
                exit 0
        fi