Mercurial > hg > index.cgi
diff lwasm/main.c @ 487:7fbf3171ca15
Add symbol table dump in assembly format
Add --symbol-dump[=FILE] which will dump the global symbol table in assembly
source format to stdout or to the FILE named by FILE.
author | William Astle <lost@l-w.ca> |
---|---|
date | Fri, 03 May 2019 19:44:02 -0600 |
parents | 469a130e7029 |
children | e10618b48e68 |
line wrap: on
line diff
--- a/lwasm/main.c Wed Apr 24 19:54:51 2019 -0600 +++ b/lwasm/main.c Fri May 03 19:44:02 2019 -0600 @@ -49,6 +49,7 @@ { "list-nofiles", 0x104, 0, 0, "Omit file names in list output"}, { "symbols", 's', 0, lw_cmdline_opt_optional, "Generate symbol list in listing, no effect without --list"}, { "symbols-nolocals", 0x103, 0, lw_cmdline_opt_optional, "Same as --symbols but with local labels ignored"}, + { "symbol-dump", 0x106, "FILE", lw_cmdline_opt_optional, "Dump global symbol table in assembly format" }, { "tabs", 't', "WIDTH", 0, "Set tab spacing in listing (0=don't expand tabs)" }, { "map", 'm', "FILE", lw_cmdline_opt_optional, "Generate map [to FILE]"}, { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, @@ -111,6 +112,16 @@ as -> flags |= FLAG_NOOUT; break; + case 0x106: + if (as -> symbol_dump_file) + lw_free(as -> symbol_dump_file); + if (!arg) + as -> symbol_dump_file = lw_strdup("-"); + else + as -> symbol_dump_file = lw_strdup(arg); + as -> flags |= FLAG_SYMDUMP; + break; + case 'd': #ifdef LWASM_NODEBUG fprintf(stderr, "This binary has been built without debugging message support\n"); @@ -274,6 +285,7 @@ void do_pass6(asmstate_t *as); void do_pass7(asmstate_t *as); void do_output(asmstate_t *as); +void do_symdump(asmstate_t *as); void do_list(asmstate_t *as); void do_map(asmstate_t *as); lw_expr_t lwasm_evaluate_special(int t, void *ptr, void *priv); @@ -390,6 +402,7 @@ debug_message(&asmstate, 50, "Invoking unicorns"); lwasm_do_unicorns(&asmstate); } + do_symdump(&asmstate); do_list(&asmstate); do_map(&asmstate);