From 477ae4419cb9ae9f20a2201e60ec4073a9922359 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 7 Mar 2016 22:53:06 -0800 Subject: [PATCH] ofmt: get rid of the debuginfo parameter to ofmt->cleanup() Get rid of the completely pointless "debuginfo" parameter to ofmt->cleanup(). Most backends completely ignore it, and the two that care (obj, ieee) can simply test dfmt instead. Also, dfmt is never NULL, so any test for a NULL dfmt is bogus. Signed-off-by: H. Peter Anvin --- nasm.c | 2 +- nasm.h | 2 +- output/outaout.c | 4 +--- output/outas86.c | 4 +--- output/outbin.c | 4 +--- output/outcoff.c | 5 ++--- output/outdbg.c | 3 +-- output/outelf32.c | 18 ++++++------------ output/outelf64.c | 20 +++++++------------- output/outelfx32.c | 20 +++++++------------- output/outieee.c | 10 ++++++---- output/outmacho.c | 4 +--- output/outobj.c | 11 +++++++---- output/outrdf2.c | 4 +--- 14 files changed, 43 insertions(+), 68 deletions(-) diff --git a/nasm.c b/nasm.c index 3c4a1b12..7a699ef6 100644 --- a/nasm.c +++ b/nasm.c @@ -466,7 +466,7 @@ int main(int argc, char **argv) assemble_file(inname, depend_ptr); if (!terminate_after_phase) { - ofmt->cleanup(using_debug_info); + ofmt->cleanup(); cleanup_labels(); fflush(ofile); if (ferror(ofile)) diff --git a/nasm.h b/nasm.h index 16d4ae81..9393e511 100644 --- a/nasm.h +++ b/nasm.h @@ -839,7 +839,7 @@ struct ofmt { * One thing the cleanup routine should always do is to close * the output file pointer. */ - void (*cleanup)(int debuginfo); + void (*cleanup)(void); }; /* diff --git a/output/outaout.c b/output/outaout.c index 66045519..b353600e 100644 --- a/output/outaout.c +++ b/output/outaout.c @@ -211,12 +211,10 @@ static void aoutb_init(void) #endif -static void aout_cleanup(int debuginfo) +static void aout_cleanup(void) { struct Reloc *r; - (void)debuginfo; - aout_pad_sections(); aout_fixup_relocs(&stext); aout_fixup_relocs(&sdata); diff --git a/output/outas86.c b/output/outas86.c index 84e3035c..b69c1d34 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -138,12 +138,10 @@ static void as86_init(void) as86_add_string(as86_module); } -static void as86_cleanup(int debuginfo) +static void as86_cleanup(void) { struct Piece *p; - (void)debuginfo; - as86_write(); saa_free(stext.data); while (stext.head) { diff --git a/output/outbin.c b/output/outbin.c index 915dc45f..ae07de4f 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -220,7 +220,7 @@ static struct Section *create_section(char *name) return last_section; } -static void bin_cleanup(int debuginfo) +static void bin_cleanup(void) { struct Section *g, **gp; struct Section *gs = NULL, **gsp; @@ -232,8 +232,6 @@ static void bin_cleanup(int debuginfo) uint64_t pend; int h; - (void)debuginfo; /* placate optimizers */ - #ifdef DEBUG nasm_error(ERR_DEBUG, "bin_cleanup: Sections were initially referenced in this order:\n"); diff --git a/output/outcoff.c b/output/outcoff.c index 935b6540..56d76674 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -223,13 +223,12 @@ static void coff_gen_init(void) def_seg = seg_alloc(); } -static void coff_cleanup(int debuginfo) +static void coff_cleanup(void) { struct coff_Reloc *r; int i; - if (debuginfo && dfmt->cleanup) - dfmt->cleanup(); + dfmt->cleanup(); coff_write(); for (i = 0; i < coff_nsects; i++) { diff --git a/output/outdbg.c b/output/outdbg.c index 83860abd..c68d1990 100644 --- a/output/outdbg.c +++ b/output/outdbg.c @@ -63,9 +63,8 @@ static void dbg_init(void) fprintf(ofile, "NASM Output format debug dump\n"); } -static void dbg_cleanup(int debuginfo) +static void dbg_cleanup(void) { - (void)debuginfo; dfmt->cleanup(); while (dbgsect) { struct Section *tmp = dbgsect; diff --git a/output/outelf32.c b/output/outelf32.c index 3ab8590d..b1596c90 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -217,13 +217,11 @@ static void elf_init(void) def_seg = seg_alloc(); } -static void elf_cleanup(int debuginfo) +static void elf_cleanup(void) { struct elf_reloc *r; int i; - (void)debuginfo; - elf_write(); for (i = 0; i < nsects; i++) { if (sects[i]->type != SHT_NOBITS) @@ -240,9 +238,7 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (dfmt) { - dfmt->cleanup(); - } + dfmt->cleanup(); } static void add_sectname(char *firsthalf, char *secondhalf) @@ -691,12 +687,10 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (dfmt) { - sinfo.offset = s->len; - sinfo.section = i; - sinfo.name = s->name; - dfmt->debug_output(TY_STABSSYMLIN, &sinfo); - } + sinfo.offset = s->len; + sinfo.section = i; + sinfo.name = s->name; + dfmt->debug_output(TY_STABSSYMLIN, &sinfo); /* end of debugging stuff */ if (s->type == SHT_NOBITS && type != OUT_RESERVE) { diff --git a/output/outelf64.c b/output/outelf64.c index b6c04d6c..878c8e49 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -221,13 +221,11 @@ static void elf_init(void) } -static void elf_cleanup(int debuginfo) +static void elf_cleanup(void) { struct elf_reloc *r; int i; - (void)debuginfo; - elf_write(); for (i = 0; i < nsects; i++) { if (sects[i]->type != SHT_NOBITS) @@ -244,9 +242,7 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (dfmt) { - dfmt->cleanup(); - } + dfmt->cleanup(); } /* add entry to the elf .shstrtab section */ @@ -707,13 +703,11 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (dfmt) { - sinfo.offset = s->len; - sinfo.section = i; - sinfo.segto = segto; - sinfo.name = s->name; - dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); - } + sinfo.offset = s->len; + sinfo.section = i; + sinfo.segto = segto; + sinfo.name = s->name; + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); /* end of debugging stuff */ if (s->type == SHT_NOBITS && type != OUT_RESERVE) { diff --git a/output/outelfx32.c b/output/outelfx32.c index 42ab3aa3..5af5cfb0 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -220,13 +220,11 @@ static void elf_init(void) } -static void elf_cleanup(int debuginfo) +static void elf_cleanup(void) { struct elf_reloc *r; int i; - (void)debuginfo; - elf_write(); for (i = 0; i < nsects; i++) { if (sects[i]->type != SHT_NOBITS) @@ -243,9 +241,7 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (dfmt) { - dfmt->cleanup(); - } + dfmt->cleanup(); } /* add entry to the elf .shstrtab section */ @@ -706,13 +702,11 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (dfmt) { - sinfo.offset = s->len; - sinfo.section = i; - sinfo.segto = segto; - sinfo.name = s->name; - dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); - } + sinfo.offset = s->len; + sinfo.section = i; + sinfo.segto = segto; + sinfo.name = s->name; + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); /* end of debugging stuff */ if (s->type == SHT_NOBITS && type != OUT_RESERVE) { diff --git a/output/outieee.c b/output/outieee.c index f5f6f5a6..eb4bcf41 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -185,13 +185,14 @@ static int32_t ieee_entry_seg, ieee_entry_ofs; static int checksum; extern struct ofmt of_ieee; +static struct dfmt ladsoft_debug_form; static void ieee_data_new(struct ieeeSection *); static void ieee_write_fixup(int32_t, int32_t, struct ieeeSection *, int, uint64_t, int32_t); static void ieee_install_fixup(struct ieeeSection *, struct ieeeFixupp *); static int32_t ieee_segment(char *, int, int *); -static void ieee_write_file(int debuginfo); +static void ieee_write_file(void); static void ieee_write_byte(struct ieeeSection *, int); static void ieee_write_word(struct ieeeSection *, int); static void ieee_write_dword(struct ieeeSection *, int32_t); @@ -232,9 +233,9 @@ static int ieee_set_info(enum geninfo type, char **val) /* * Rundown */ -static void ieee_cleanup(int debuginfo) +static void ieee_cleanup(void) { - ieee_write_file(debuginfo); + ieee_write_file(); dfmt->cleanup(); while (seghead) { struct ieeeSection *segtmp = seghead; @@ -899,7 +900,7 @@ static void ieee_filename(char *inname, char *outname) standard_extension(inname, outname, ".o"); } -static void ieee_write_file(int debuginfo) +static void ieee_write_file(void) { struct tm *thetime; time_t reltime; @@ -911,6 +912,7 @@ static void ieee_write_file(int debuginfo) struct ieeeFixupp *fix; struct Array *arr; int i; + const bool debuginfo = (dfmt == &ladsoft_debug_form); /* * Write the module header diff --git a/output/outmacho.c b/output/outmacho.c index b67561c6..26a62ea6 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -1543,14 +1543,12 @@ static void macho_write (void) for the object file, writing, and then freeing all of the data from the file. */ -static void macho_cleanup(int debuginfo) +static void macho_cleanup(void) { struct section *s; struct reloc *r; struct symbol *sym; - (void)debuginfo; - /* Sort all symbols. */ macho_layout_symbols (&nsyms, &strslen); diff --git a/output/outobj.c b/output/outobj.c index fd6c326a..c82b5c26 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -625,12 +625,13 @@ static struct ExpDef { static int32_t obj_entry_seg, obj_entry_ofs; struct ofmt of_obj; +static struct dfmt borland_debug_form; /* The current segment */ static struct Segment *current_seg; static int32_t obj_segment(char *, int, int *); -static void obj_write_file(int debuginfo); +static void obj_write_file(void); static int obj_directive(enum directives, char *, int); static void obj_init(void) @@ -667,9 +668,10 @@ static int obj_set_info(enum geninfo type, char **val) return 0; } -static void obj_cleanup(int debuginfo) + +static void obj_cleanup(void) { - obj_write_file(debuginfo); + obj_write_file(); dfmt->cleanup(); while (seghead) { struct Segment *segtmp = seghead; @@ -1916,7 +1918,7 @@ static void obj_filename(char *inname, char *outname) standard_extension(inname, outname, ".obj"); } -static void obj_write_file(int debuginfo) +static void obj_write_file(void) { struct Segment *seg, *entry_seg_ptr = 0; struct FileName *fn; @@ -1928,6 +1930,7 @@ static void obj_write_file(int debuginfo) struct ExpDef *export; int lname_idx; ObjRecord *orp; + const bool debuginfo = (dfmt == &borland_debug_form); /* * Write the THEADR module header. diff --git a/output/outrdf2.c b/output/outrdf2.c index e6dcda98..960acb45 100644 --- a/output/outrdf2.c +++ b/output/outrdf2.c @@ -657,14 +657,12 @@ static void rdf2_out(int32_t segto, const void *data, } } -static void rdf2_cleanup(int debuginfo) +static void rdf2_cleanup(void) { int32_t l; struct BSSRec bs; int i; - (void)debuginfo; - /* should write imported & exported symbol declarations to header here */ /* generate the output file... */ -- 2.11.4.GIT