unlink outfile first

file mode problem if the outfile already exists
master
Changming Xu 2011-03-03 21:09:18 +08:00
parent c93eca4fe4
commit c27e76aa2a
1 changed files with 1 additions and 0 deletions

View File

@ -2086,6 +2086,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
mode = 0666;
else
mode = 0777;
unlink(filename);
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
if (fd < 0) {
error_noabort("could not write '%s'", filename);