# HG changeset patch # User Michael Spacefalcon # Date 1398752819 0 # Node ID 1e1815a6d701c539fdedbccc262b732665e3cddc # Parent 70631c246df05c5bbf6fdd43787517460225bc24 tiobjd: beginning of disasm -g diff -r 70631c246df0 -r 1e1815a6d701 leo-obj/tool/disasm.c --- a/leo-obj/tool/disasm.c Tue Apr 29 05:18:09 2014 +0000 +++ b/leo-obj/tool/disasm.c Tue Apr 29 06:26:59 2014 +0000 @@ -15,6 +15,7 @@ extern char *storage_class_to_string(); int auto_xlat_section_relocs = 1; +int disasm_richsym; static void find_better_symbol(sec, symp, addp) @@ -83,7 +84,7 @@ struct internal_syment *sym; int *statep, *linebrkp; { - char *sym_comment; + char *sym_comment, *cpref; if (sym->class == C_FCN && !strcmp(sym->name, ".ef")) { printf("; End function\n"); @@ -100,9 +101,11 @@ switch (sym->class) { case C_EXT: sym_comment = "Global"; + cpref = "; "; break; case C_STAT: sym_comment = "static"; + cpref = "; static "; break; case C_LABEL: sym_comment = "label"; @@ -115,6 +118,11 @@ sym_comment = "unexpected class!"; } printf("%s:\t; %s\n", sym->name, sym_comment); + if (!disasm_richsym || sym->class != C_EXT && sym->class != C_STAT) + return; + if (!sym->aux || sym->name[0] != '_' && sym->name[0] != '$') + return; + richsym_print_in_c(cpref, sym, 0); } void @@ -347,7 +355,7 @@ { unsigned m; struct internal_syment *sym; - char classbuf[8]; + char classbuf[8], *cpref; putchar('\n'); for (m = 0; m < sec->nsymbols; m++) { @@ -355,6 +363,19 @@ printf("%08X %-7s %s\n", sym->value, storage_class_to_string(sym->class, classbuf), sym->name); + if (!disasm_richsym || !sym->aux || sym->name[0] != '_') + continue; + switch (sym->class) { + case C_EXT: + cpref = "; "; + break; + case C_STAT: + cpref = "; static "; + break; + default: + continue; + } + richsym_print_in_c(cpref, sym, 0); } printf("%08X \n", sec->size); } @@ -389,8 +410,11 @@ unsigned secnum; int c; - while ((c = getopt(argc, argv, "h:s")) != EOF) + while ((c = getopt(argc, argv, "gh:s")) != EOF) switch (c) { + case 'g': + disasm_richsym++; + continue; case 'h': hintsfile = optarg; continue; @@ -411,6 +435,8 @@ read_hints_file(hintsfile); extern_profile_report("Module"); sort_symbols_of_all_sec(); + if (disasm_richsym) + richsym_initial_preen(); for (secnum = 0; secnum < nsections; secnum++) { sec = sections + secnum; printf("=== %s ===\n", sec->name);