FreeCalypso > hg > freecalypso-reveng
changeset 128:03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 05 Apr 2014 20:21:55 +0000 |
parents | a314d6aa9bf1 |
children | 597143ba1c37 |
files | ticoff/disasm.c |
diffstat | 1 files changed, 35 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/ticoff/disasm.c Sat Apr 05 20:00:46 2014 +0000 +++ b/ticoff/disasm.c Sat Apr 05 20:21:55 2014 +0000 @@ -14,6 +14,8 @@ extern unsigned get_u16(), get_u32(); extern char *storage_class_to_string(); +static int auto_xlat_section_relocs = 1; + static void find_better_symbol(sec, symp, addp) struct internal_scnhdr *sec; @@ -50,7 +52,8 @@ if (sym) addend -= sym->value; - if (!sym || sym->section && !strcmp(sym->name, sym->section->name)) + if (auto_xlat_section_relocs && + (!sym || sym->section && !strcmp(sym->name, sym->section->name))) find_better_symbol(sym ? sym->section : sec, &sym, &addend); if (sym) fputs(sym->name, stdout); @@ -352,39 +355,59 @@ } void -disasm_sectype_by_name(sec) +disasm_sec_by_type(sec) struct internal_scnhdr *sec; { - if (!strncmp(sec->name, ".text", 5)) + switch (sec->disasm_mode) { + case DISASM_MODE_CODE: disasm_text_section(sec); - else if (!strcmp(sec->name, ".const")) - disasm_data_section(sec); - else if (!strcmp(sec->name, ".cinit")) + return; + case DISASM_MODE_DATA: disasm_data_section(sec); - else if (!strcmp(sec->name, ".data")) - disasm_data_section(sec); - else if (!strcmp(sec->name, ".bss")) + return; + case DISASM_MODE_BSS: disasm_bss(sec); - else + return; + default: printf("Unrecognized section type, skipped\n"); + } } -cmd_disasm() +cmd_disasm(argc, argv) + char **argv; { + extern char *optarg; + char *hintsfile = 0; struct internal_scnhdr *sec; unsigned secnum; + int c; + + while ((c = getopt(argc, argv, "h:s")) != EOF) + switch (c) { + case 'h': + hintsfile = optarg; + continue; + case 's': + auto_xlat_section_relocs = 0; + continue; + default: + /* error msg already printed */ + exit(1); + } printf("%s:\n", objfilename); dump_filehdr_info(); putchar('\n'); get_int_section_table(); get_int_symbol_table(); + if (hintsfile) + read_hints_file(hintsfile); extern_profile_report("Module"); sort_symbols_of_all_sec(); for (secnum = 0; secnum < nsections; secnum++) { sec = sections + secnum; printf("=== %s ===\n", sec->name); - disasm_sectype_by_name(sec); + disasm_sec_by_type(sec); putchar('\n'); } exit(0);