# HG changeset patch # User Michael Spacefalcon # Date 1396833729 0 # Node ID daeaa5950d10f13a9aa2391f0d98f4729eece5c9 # Parent af0f8bfa3b3ae30df50246e14152f4184c9bc470 tiobjd: Thumb bl w/o reloc: find symbol if there is one diff -r af0f8bfa3b3a -r daeaa5950d10 leo-obj/tool/disasm.c --- a/leo-obj/tool/disasm.c Mon Apr 07 00:59:34 2014 +0000 +++ b/leo-obj/tool/disasm.c Mon Apr 07 01:22:09 2014 +0000 @@ -14,7 +14,7 @@ extern unsigned get_u16(), get_u32(); extern char *storage_class_to_string(); -static int auto_xlat_section_relocs = 1; +int auto_xlat_section_relocs = 1; static void find_better_symbol(sec, symp, addp) diff -r af0f8bfa3b3a -r daeaa5950d10 leo-obj/tool/thumbdis.c --- a/leo-obj/tool/thumbdis.c Mon Apr 07 00:59:34 2014 +0000 +++ b/leo-obj/tool/thumbdis.c Mon Apr 07 01:22:09 2014 +0000 @@ -8,6 +8,7 @@ #include #include #include "intstruct.h" +#include "coffconst.h" #include "globals.h" extern unsigned get_u16(), get_u32(); @@ -15,6 +16,8 @@ extern char *regnames[16], *condition_decode[16], *shift_types[4]; +extern int auto_xlat_section_relocs; + static void format_1_2(word) unsigned word; @@ -389,12 +392,35 @@ } } +static char * +bl_norel_find_symbol(sec, dest) + struct internal_scnhdr *sec; + unsigned dest; +{ + struct internal_syment *sym; + unsigned n; + + for (n = 0; n < sec->nsymbols; n++) { + sym = sec->sorted_symbols[n]; + if (sym->value > dest) + break; + if (sym->value < dest) + continue; + if (sym->class != C_EXT && sym->class != C_STAT) + continue; + if (sym->name[0] == '$') + return(sym->name); + } + return(0); +} + thumb_check_bl(sec, off) struct internal_scnhdr *sec; unsigned off; { unsigned ins1, ins2; unsigned dest; + char *destsym; ins1 = get_u16(filemap + sec->data_offset + off); if ((ins1 & 0xF800) != 0xF000) @@ -407,7 +433,11 @@ if (dest & 0x00400000) dest |= 0xFF800000; dest += off + 4; - printf("%04x %04x\tbl\t0x%x\n", ins1, ins2, dest); + printf("%04x %04x\tbl\t", ins1, ins2); + destsym = bl_norel_find_symbol(sec, dest); + if (destsym) + printf("%s\t; ", destsym); + printf("0x%x\n", dest); return(1); }