From: Peter Johnson Date: Tue, 18 Mar 2003 06:25:30 +0000 (-0000) Subject: Add all_syms parameter to objfmt->output() for debugging purposes. X-Git-Tag: v0.2.2~3^2~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=395ebb7a0f6c58b80e1ba71d6ca2afa0290d468d;p=yasm Add all_syms parameter to objfmt->output() for debugging purposes. svn path=/trunk/yasm/; revision=879 --- diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 815d01cf..498fd494 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -434,7 +434,8 @@ main(int argc, char *argv[]) } /* Write the object file */ - cur_objfmt->output(obj?obj:stderr, sections); + cur_objfmt->output(obj?obj:stderr, sections, + strcmp(cur_dbgfmt->keyword, "null")); /* Close object file */ if (obj) diff --git a/libyasm/objfmt.h b/libyasm/objfmt.h index 45522c56..7cc73a53 100644 --- a/libyasm/objfmt.h +++ b/libyasm/objfmt.h @@ -68,7 +68,7 @@ struct yasm_objfmt { * This function may call symrec functions as necessary (including * symrec_traverse) to retrieve symbolic information. */ - void (*output) (FILE *f, yasm_sectionhead *sections); + void (*output) (FILE *f, yasm_sectionhead *sections, int all_syms); /* Cleans up anything allocated by initialize. * May be NULL if not needed by the object format. diff --git a/modules/objfmts/bin/bin-objfmt.c b/modules/objfmts/bin/bin-objfmt.c index adb9e307..4007a363 100644 --- a/modules/objfmts/bin/bin-objfmt.c +++ b/modules/objfmts/bin/bin-objfmt.c @@ -216,7 +216,8 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d) } static void -bin_objfmt_output(FILE *f, yasm_sectionhead *sections) +bin_objfmt_output(FILE *f, yasm_sectionhead *sections, + /*@unused@*/ int all_syms) { /*@observer@*/ /*@null@*/ yasm_section *text, *data, *bss, *prevsect; /*@null@*/ yasm_expr *startexpr; diff --git a/modules/objfmts/coff/coff-objfmt.c b/modules/objfmts/coff/coff-objfmt.c index d6da3406..edd025f4 100644 --- a/modules/objfmts/coff/coff-objfmt.c +++ b/modules/objfmts/coff/coff-objfmt.c @@ -182,6 +182,15 @@ coff_objfmt_symtab_append(yasm_symrec *sym, coff_symrec_sclass sclass, return entry; } +static int +coff_objfmt_append_local_sym(yasm_symrec *sym, /*@unused@*/ /*@null@*/ void *d) +{ + if (!yasm_symrec_get_of_data(sym)) + coff_objfmt_symtab_append(sym, COFF_SCL_STAT, NULL, 0, + COFF_SYMTAB_AUX_NONE); + return 1; +} + static void coff_objfmt_initialize(const char *in_filename, /*@unused@*/ const char *obj_filename, @@ -494,7 +503,7 @@ coff_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d) } static void -coff_objfmt_output(FILE *f, yasm_sectionhead *sections) +coff_objfmt_output(FILE *f, yasm_sectionhead *sections, int all_syms) { coff_objfmt_output_info info; unsigned char *localbuf; @@ -530,6 +539,10 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections) return; /* Symbol table */ + if (all_syms) { + /* Need to put all local syms into COFF symbol table */ + yasm_symrec_traverse(NULL, coff_objfmt_append_local_sym); + } pos = ftell(f); if (pos == -1) { yasm__error(0, N_("could not get file position on output file")); @@ -667,7 +680,9 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections) YASM_WRITE_32_L(localbuf, symtab_pos); /* file ptr to symtab */ YASM_WRITE_32_L(localbuf, symtab_count); /* number of symtabs */ YASM_WRITE_16_L(localbuf, 0); /* size of optional header (none) */ - YASM_WRITE_16_L(localbuf, COFF_F_AR32WR|COFF_F_LNNO|COFF_F_LSYMS); /* flags */ + /* flags */ + YASM_WRITE_16_L(localbuf, COFF_F_AR32WR|COFF_F_LNNO + |(all_syms?0:COFF_F_LSYMS)); fwrite(info.buf, 20, 1, f); yasm_sections_traverse(sections, &info, coff_objfmt_output_secthead); diff --git a/modules/objfmts/dbg/dbg-objfmt.c b/modules/objfmts/dbg/dbg-objfmt.c index 2cc1c13a..06a587ee 100644 --- a/modules/objfmts/dbg/dbg-objfmt.c +++ b/modules/objfmts/dbg/dbg-objfmt.c @@ -58,11 +58,12 @@ dbg_objfmt_initialize(const char *in_filename, const char *obj_filename, } static void -dbg_objfmt_output(/*@unused@*/ FILE *f, yasm_sectionhead *sections) +dbg_objfmt_output(/*@unused@*/ FILE *f, yasm_sectionhead *sections, + int all_syms) { fprintf(dbg_objfmt_file, "output(f, sections->\n"); yasm_sections_print(dbg_objfmt_file, 1, sections); - fprintf(dbg_objfmt_file, ")\n"); + fprintf(dbg_objfmt_file, "%d)\n", all_syms); fprintf(dbg_objfmt_file, " Symbol Table:\n"); yasm_symrec_print_all(dbg_objfmt_file, 1); }