changeset 182:833d392fec82

Arranged for lwasm and lwlink to remove the output file in case they fail
author lost
date Fri, 06 Mar 2009 01:35:40 +0000
parents 14878196ed5b
children 302b8db5fd89
files ChangeLog lwasm/main.c lwlink/main.c
diffstat 3 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 05 02:23:47 2009 +0000
+++ b/ChangeLog	Fri Mar 06 01:35:40 2009 +0000
@@ -15,6 +15,8 @@
 [*] added library search path (-L) and library specification (-l) to LWLINK
 [*] added ability to specify section base addresses on the command line to
     LWLINK (they get prepended to the built in link script)
+[b] arranged for output files for lwasm/lwlink to be removed if the assembly
+    or linking fails
 
 Version 2.2
 
--- a/lwasm/main.c	Thu Mar 05 02:23:47 2009 +0000
+++ b/lwasm/main.c	Fri Mar 06 01:35:40 2009 +0000
@@ -30,6 +30,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "lwasm.h"
 
@@ -176,6 +177,9 @@
 		exit(1);
 	}	
 
+	// lose the output file if it already exists...
+	unlink(asmstate.outfile);
+
 	/* pass 1 - collect the symbols and assign addresses where possible */
 	/* pass 1 also resolves included files, etc. */
 	/* that means files are read exactly once unless included multiple times */
--- a/lwlink/main.c	Thu Mar 05 02:23:47 2009 +0000
+++ b/lwlink/main.c	Fri Mar 06 01:35:40 2009 +0000
@@ -30,6 +30,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "lwlink.h"
 
@@ -154,6 +155,8 @@
 		exit(1);
 	}
 
+	unlink(outfile);
+
 	// handle the linker script
 	setup_script();