# HG changeset patch # User Michael Spacefalcon # Date 1396504499 0 # Node ID 61a58677dc68a1593d816fc8215a7d7065feba7a # Parent 0f94d17899b3a94f5ea036127b2f5d905081dbee tiobjd disasm: beginning of reloc handling diff -r 0f94d17899b3 -r 61a58677dc68 ticoff/disasm.c --- a/ticoff/disasm.c Thu Apr 03 05:14:15 2014 +0000 +++ b/ticoff/disasm.c Thu Apr 03 05:54:59 2014 +0000 @@ -14,6 +14,36 @@ extern unsigned get_u16(), get_u32(); void +disasm_reloc_target(sec, rel, addend) + struct internal_scnhdr *sec; + struct internal_reloc *rel; + unsigned addend; +{ + struct internal_syment *sym = rel->sym; + + addend -= sym->value; + if (addend >= 10) + printf("%s+0x%x", sym->name, addend); + else if (addend) + printf("%s+%u", sym->name, addend); + else + fputs(sym->name, stdout); +} + +void +disasm_word32_reloc(sec, rel) + struct internal_scnhdr *sec; + struct internal_reloc *rel; +{ + unsigned word; + + word = get_u32(filemap + sec->data_offset + rel->location); + printf("%08x R\t.word\t", word); + disasm_reloc_target(sec, rel, word); + putchar('\n'); +} + +void disasm_text_section(sec) struct internal_scnhdr *sec; { @@ -76,6 +106,15 @@ } else rel = 0; printf("%8x:\t", pos); + if (rel && rel->type == RTYPE_LONG) { + if (pos & 3) { + printf("MISALIGNED pos for word32 reloc, aborting\n"); + return; + } + disasm_word32_reloc(sec, rel); + incr = 4; + goto next; + } switch (state) { case 0: /* ARM */ if (pos & 3) { @@ -103,7 +142,7 @@ printf("UNKNOWN T state, aborting\n"); return; } - linebrk = 0; +next: linebrk = 0; if (incr > headroom) { printf("error: increment %u > headroom %u, aborting\n", incr, headroom);