FreeCalypso > hg > freecalypso-reveng
diff leo-obj/tool/disasm.c @ 147:1e1815a6d701
tiobjd: beginning of disasm -g
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 29 Apr 2014 06:26:59 +0000 |
parents | acdf75463e30 |
children | 13cc7e19ecec |
line wrap: on
line diff
--- 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 <end of section>\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);