diff --git a/asm/nasm.c b/asm/nasm.c index 383f38876..f35826804 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -1903,8 +1903,10 @@ void close_output(bool error) fflush(ofile); } else { fclose(ofile); - if (error && !keep_all) + if (error && !keep_all) { nasm_remove(get_filename(FN_OUTFILE)); + nasm_remove(get_filename(FN_MAPFILE)); + } } ofile = NULL; } diff --git a/include/files.h b/include/files.h index 314dea184..4d4d13005 100644 --- a/include/files.h +++ b/include/files.h @@ -19,6 +19,7 @@ enum filenames { FN_ERRFILE, /* Error message file */ FN_LISTFILE, /* Listing file */ FN_DEPENDFILE, /* Dependency file */ + FN_MAPFILE, /* Map file (outbin) */ FN_NFILES }; diff --git a/output/outbin.c b/output/outbin.c index 7f7d8f7b3..75bf147ea 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -1295,6 +1295,8 @@ bin_directive(enum directive directive, char *args) else if (!nasm_stricmp(p, "stderr")) rf = stderr; else { /* Must be a filename. */ + copy_filename(FN_MAPFILE, p); + check_overwrite_files(); rf = nasm_open_write(p, NF_TEXT); if (!rf) { nasm_nonfatal("unable to open map file `%s'", p);