diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2016-02-17 20:55:08 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2016-02-17 20:55:08 -0800 |
commit | a7bc15dd0aa963ab56a98ee04bc08ce6d9e3baea (patch) | |
tree | 484ed4545faa30d9c83e51eb2bef4b6c2d387d9d | |
parent | 4a8d10c1a004ace853dd3019814329065dda5050 (diff) | |
download | nasm-a7bc15dd0aa963ab56a98ee04bc08ce6d9e3baea.tar.gz |
Remove ofmt->current_dfmt indirection
Move ofmt->current_dfmt into a separate global variable. This
should allow us to make ofmt readonly and removes some additional
gratuitious differences between backends.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | assemble.c | 2 | ||||
-rw-r--r-- | labels.c | 10 | ||||
-rw-r--r-- | nasm.c | 10 | ||||
-rw-r--r-- | nasm.h | 8 | ||||
-rw-r--r-- | output/outcoff.c | 8 | ||||
-rw-r--r-- | output/outdbg.c | 2 | ||||
-rw-r--r-- | output/outelf32.c | 22 | ||||
-rw-r--r-- | output/outelf64.c | 22 | ||||
-rw-r--r-- | output/outelfx32.c | 22 | ||||
-rw-r--r-- | output/outform.c | 2 | ||||
-rw-r--r-- | output/outieee.c | 2 | ||||
-rw-r--r-- | output/outobj.c | 2 |
12 files changed, 55 insertions, 57 deletions
@@ -370,7 +370,7 @@ static void out(int64_t offset, int32_t segto, const void *data, */ if (src_get(&lineno, &lnfname)) - ofmt->current_dfmt->linenum(lnfname, lineno, segto); + dfmt->linenum(lnfname, lineno, segto); if (asize && asize > amax) { if (type != OUT_ADDRESS || (int)size < 0) { @@ -262,14 +262,14 @@ void redefine_label(char *label, int32_t segment, int64_t offset, char *special, ofmt->symdef(xsymbol, segment, offset, exi, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(xsymbol, segment, offset, exi, + dfmt->debug_deflabel(xsymbol, segment, offset, exi, special ? special : lptr->defn.special); /** nasm_free(xsymbol); ! outobj.c stores the pointer; ouch!!! **/ } else { if ((lptr->defn.is_global & (GLOBAL_BIT | EXTERN_BIT)) != EXTERN_BIT) { ofmt->symdef(lptr->defn.label, segment, offset, exi, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(label, segment, offset, exi, + dfmt->debug_deflabel(label, segment, offset, exi, special ? special : lptr->defn.special); } } @@ -327,14 +327,14 @@ void define_label(char *label, int32_t segment, int64_t offset, char *special, ofmt->symdef(xsymbol, segment, offset, exi, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(xsymbol, segment, offset, exi, + dfmt->debug_deflabel(xsymbol, segment, offset, exi, special ? special : lptr->defn.special); /** nasm_free(xsymbol); ! outobj.c stores the pointer; ouch!!! **/ } else { if ((lptr->defn.is_global & (GLOBAL_BIT | EXTERN_BIT)) != EXTERN_BIT) { ofmt->symdef(lptr->defn.label, segment, offset, exi, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(label, segment, offset, exi, + dfmt->debug_deflabel(label, segment, offset, exi, special ? special : lptr->defn.special); } } @@ -371,7 +371,7 @@ void define_common(char *label, int32_t segment, int32_t size, char *special) ofmt->symdef(lptr->defn.label, segment, size, 2, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(lptr->defn.label, segment, size, 2, + dfmt->debug_deflabel(lptr->defn.label, segment, size, 2, special ? special : lptr->defn.special); } @@ -358,7 +358,9 @@ int main(int argc, char **argv) /* If debugging info is disabled, suppress any debug calls */ if (!using_debug_info) - ofmt->current_dfmt = &null_debug_form; + dfmt = &null_debug_form; + else if (!dfmt) + dfmt = ofmt->default_dfmt; if (ofmt->stdmac) preproc->extra_stdmac(ofmt->stdmac); @@ -459,7 +461,6 @@ int main(int argc, char **argv) init_labels(); ofmt->init(); - dfmt = ofmt->current_dfmt; dfmt->init(); assemble_file(inname, depend_ptr); @@ -665,6 +666,7 @@ static bool process_arg(char *p, char *q) "unrecognised output format `%s' - " "use -hf for a list", param); } + dfmt = NULL; break; case 'O': /* Optimization level */ @@ -742,8 +744,8 @@ static bool process_arg(char *p, char *q) break; case 'F': /* specify debug format */ - ofmt->current_dfmt = dfmt_find(ofmt, param); - if (!ofmt->current_dfmt) { + dfmt = dfmt_find(ofmt, param); + if (!dfmt) { nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, "unrecognized debug format `%s' for" " output format `%s'", @@ -751,13 +751,9 @@ struct ofmt { struct dfmt **debug_formats; /* - * and a pointer to the element that is being used - * note: this is set to the default at compile time and changed if the - * -F option is selected. If developing a set of new debug formats for - * an output format, be sure to set this to whatever default you want - * + * the default debugging format if -F is not specified */ - const struct dfmt *current_dfmt; + const struct dfmt *default_dfmt; /* * This, if non-NULL, is a NULL-terminated list of `char *'s diff --git a/output/outcoff.c b/output/outcoff.c index a712f953..bd971d1c 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -228,8 +228,8 @@ static void coff_cleanup(int debuginfo) struct coff_Reloc *r; int i; - if (debuginfo && ofmt->current_dfmt->cleanup) - ofmt->current_dfmt->cleanup(); + if (debuginfo && dfmt->cleanup) + dfmt->cleanup(); coff_write(); for (i = 0; i < coff_nsects; i++) { @@ -603,7 +603,7 @@ static void coff_out(int32_t segto, const void *data, memset(mydata, 0, sizeof(mydata)); - if (ofmt->current_dfmt && ofmt->current_dfmt->debug_output) { + if (dfmt && dfmt->debug_output) { struct coff_DebugInfo dinfo; dinfo.segto = segto; dinfo.seg = segment; @@ -614,7 +614,7 @@ static void coff_out(int32_t segto, const void *data, else dinfo.size = realsize(type, size); - ofmt->current_dfmt->debug_output(type, &dinfo); + dfmt->debug_output(type, &dinfo); } if (type == OUT_RESERVE) { diff --git a/output/outdbg.c b/output/outdbg.c index 034a6152..83860abd 100644 --- a/output/outdbg.c +++ b/output/outdbg.c @@ -66,7 +66,7 @@ static void dbg_init(void) static void dbg_cleanup(int debuginfo) { (void)debuginfo; - of_dbg.current_dfmt->cleanup(); + dfmt->cleanup(); while (dbgsect) { struct Section *tmp = dbgsect; dbgsect = dbgsect->next; diff --git a/output/outelf32.c b/output/outelf32.c index 7852e71b..5a9f847c 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -241,8 +241,8 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (of_elf32.current_dfmt) { - of_elf32.current_dfmt->cleanup(); + if (dfmt) { + dfmt->cleanup(); } } @@ -692,11 +692,11 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (of_elf32.current_dfmt) { + if (dfmt) { sinfo.offset = s->len; sinfo.section = i; sinfo.name = s->name; - of_elf32.current_dfmt->debug_output(TY_STABSSYMLIN, &sinfo); + dfmt->debug_output(TY_STABSSYMLIN, &sinfo); } /* end of debugging stuff */ @@ -895,9 +895,9 @@ static void elf_write(void) * relocation sections for the user sections. */ nsections = sec_numspecial + 1; - if (of_elf32.current_dfmt == &df_stabs) + if (dfmt == &df_stabs) nsections += 3; - else if (of_elf32.current_dfmt == &df_dwarf) + else if (dfmt == &df_dwarf) nsections += 10; add_sectname("", ".shstrtab"); @@ -911,12 +911,12 @@ static void elf_write(void) } } - if (of_elf32.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* in case the debug information is wanted, just add these three sections... */ add_sectname("", ".stab"); add_sectname("", ".stabstr"); add_sectname(".rel", ".stab"); - } else if (of_elf32.current_dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* the dwarf debug standard specifies the following ten sections, not all of which are currently implemented, although all of them are defined. */ @@ -1013,7 +1013,7 @@ static void elf_write(void) p += strlen(p) + 1; } - if (of_elf32.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* for debugging information, create the last three sections which are the .stab , .stabstr and .rel.stab sections respectively */ @@ -1034,7 +1034,7 @@ static void elf_write(void) stabrellen, sec_symtab, sec_stab, 4, 8); p += strlen(p) + 1; } - } else if (of_elf32.current_dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* for dwarf debugging information, create the ten dwarf sections */ /* this function call creates the dwarf sections in memory */ @@ -1161,7 +1161,7 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * which are relocation targets. */ //*** fix for 32 bit - if (of_elf32.current_dfmt == &df_dwarf) { + if (dfmt == &df_dwarf) { dwarf_infosym = *local; p = entry; WRITELONG(p, 0); /* no symbol name */ diff --git a/output/outelf64.c b/output/outelf64.c index d23c53ab..ec001560 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -246,8 +246,8 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (of_elf64.current_dfmt) { - of_elf64.current_dfmt->cleanup(); + if (dfmt) { + dfmt->cleanup(); } } @@ -709,12 +709,12 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (of_elf64.current_dfmt) { + if (dfmt) { sinfo.offset = s->len; sinfo.section = i; sinfo.segto = segto; sinfo.name = s->name; - of_elf64.current_dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); } /* end of debugging stuff */ @@ -977,9 +977,9 @@ static void elf_write(void) * relocation sections for the user sections. */ nsections = sec_numspecial + 1; - if (of_elf64.current_dfmt == &df_stabs) + if (dfmt == &df_stabs) nsections += 3; - else if (of_elf64.current_dfmt == &df_dwarf) + else if (dfmt == &df_dwarf) nsections += 10; add_sectname("", ".shstrtab"); @@ -993,14 +993,14 @@ static void elf_write(void) } } - if (of_elf64.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* in case the debug information is wanted, just add these three sections... */ add_sectname("", ".stab"); add_sectname("", ".stabstr"); add_sectname(".rel", ".stab"); } - else if (of_elf64.current_dfmt == &df_dwarf) { + else if (dfmt == &df_dwarf) { /* the dwarf debug standard specifies the following ten sections, not all of which are currently implemented, although all of them are defined. */ @@ -1098,7 +1098,7 @@ static void elf_write(void) p += strlen(p) + 1; } - if (of_elf64.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* for debugging information, create the last three sections which are the .stab , .stabstr and .rel.stab sections respectively */ @@ -1119,7 +1119,7 @@ static void elf_write(void) stabrellen, symtabsection, sec_stab, 4, 16); p += strlen(p) + 1; } - } else if (of_elf64.current_dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* for dwarf debugging information, create the ten dwarf sections */ /* this function call creates the dwarf sections in memory */ @@ -1245,7 +1245,7 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * dwarf needs symbols for debug sections * which are relocation targets. */ - if (of_elf64.current_dfmt == &df_dwarf) { + if (dfmt == &df_dwarf) { dwarf_infosym = *local; p = entry; WRITELONG(p, 0); /* no symbol name */ diff --git a/output/outelfx32.c b/output/outelfx32.c index 8e1b0c69..fcd97d35 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -245,8 +245,8 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (of_elfx32.current_dfmt) { - of_elfx32.current_dfmt->cleanup(); + if (dfmt) { + dfmt->cleanup(); } } @@ -708,12 +708,12 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (of_elfx32.current_dfmt) { + if (dfmt) { sinfo.offset = s->len; sinfo.section = i; sinfo.segto = segto; sinfo.name = s->name; - of_elfx32.current_dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); } /* end of debugging stuff */ @@ -939,9 +939,9 @@ static void elf_write(void) * relocation sections for the user sections. */ nsections = sec_numspecial + 1; - if (of_elfx32.current_dfmt == &df_stabs) + if (dfmt == &df_stabs) nsections += 3; - else if (of_elfx32.current_dfmt == &df_dwarf) + else if (dfmt == &df_dwarf) nsections += 10; add_sectname("", ".shstrtab"); @@ -955,14 +955,14 @@ static void elf_write(void) } } - if (of_elfx32.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* in case the debug information is wanted, just add these three sections... */ add_sectname("", ".stab"); add_sectname("", ".stabstr"); add_sectname(".rel", ".stab"); } - else if (of_elfx32.current_dfmt == &df_dwarf) { + else if (dfmt == &df_dwarf) { /* the dwarf debug standard specifies the following ten sections, not all of which are currently implemented, although all of them are defined. */ @@ -1059,7 +1059,7 @@ static void elf_write(void) p += strlen(p) + 1; } - if (of_elfx32.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* for debugging information, create the last three sections which are the .stab , .stabstr and .rel.stab sections respectively */ @@ -1080,7 +1080,7 @@ static void elf_write(void) stabrellen, sec_symtab, sec_stab, 4, 8); p += strlen(p) + 1; } - } else if (of_elfx32.current_dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* for dwarf debugging information, create the ten dwarf sections */ /* this function call creates the dwarf sections in memory */ @@ -1206,7 +1206,7 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * dwarf needs symbols for debug sections * which are relocation targets. */ - if (of_elfx32.current_dfmt == &df_dwarf) { + if (dfmt == &df_dwarf) { dwarf_infosym = *local; p = entry; WRITELONG(p, 0); /* no symbol name */ diff --git a/output/outform.c b/output/outform.c index 0c8ae53b..3d70e2a9 100644 --- a/output/outform.c +++ b/output/outform.c @@ -111,7 +111,7 @@ void dfmt_list(struct ofmt *ofmt, FILE *fp) for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) { fprintf(fp, " %c %-10s%s\n", - df == ofmt->current_dfmt ? '*' : ' ', + df == dfmt ? '*' : ' ', df->shortname, df->fullname); } } diff --git a/output/outieee.c b/output/outieee.c index 42f0fb66..2fcbddb1 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -235,7 +235,7 @@ static int ieee_set_info(enum geninfo type, char **val) static void ieee_cleanup(int debuginfo) { ieee_write_file(debuginfo); - of_ieee.current_dfmt->cleanup(); + dfmt->cleanup(); while (seghead) { struct ieeeSection *segtmp = seghead; seghead = seghead->next; diff --git a/output/outobj.c b/output/outobj.c index beb95dab..9a9ff1cb 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -670,7 +670,7 @@ static int obj_set_info(enum geninfo type, char **val) static void obj_cleanup(int debuginfo) { obj_write_file(debuginfo); - of_obj.current_dfmt->cleanup(); + dfmt->cleanup(); while (seghead) { struct Segment *segtmp = seghead; seghead = seghead->next; |