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 <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2016-03-07 22:53:06 -08:00
parent 3ab8c5f9c6
commit 477ae4419c
14 changed files with 43 additions and 68 deletions

2
nasm.c
View file

@ -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))

2
nasm.h
View file

@ -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);
};
/*

View file

@ -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);

View file

@ -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) {

View file

@ -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");

View file

@ -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++) {

View file

@ -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;

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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

View file

@ -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);

View file

@ -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.

View file

@ -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... */