# HG changeset patch # User Michael Spacefalcon # Date 1396729315 0 # Node ID 03f8a618689eb6f5c032298d457385ca350a77a3 # Parent a314d6aa9bf121ef6b65441f091165fc4ea645f3 tiobjd disasm: initial hook-in of the hints mechanism diff -r a314d6aa9bf1 -r 03f8a618689e ticoff/disasm.c --- 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);