FreeCalypso > hg > freecalypso-reveng
diff ticoff/thumbdis.c @ 113:d97fbe98600b
tiobjd: recognizing relocs in ldr literals
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 03 Apr 2014 06:20:06 +0000 |
parents | 0f94d17899b3 |
children | 2f23301d2f86 |
line wrap: on
line diff
--- a/ticoff/thumbdis.c Thu Apr 03 05:54:59 2014 +0000 +++ b/ticoff/thumbdis.c Thu Apr 03 06:20:06 2014 +0000 @@ -11,6 +11,7 @@ #include "globals.h" extern unsigned get_u16(), get_u32(); +extern struct internal_reloc *find_reloc(); extern char *regnames[16], *condition_decode[16], *shift_types[4]; @@ -114,16 +115,23 @@ struct internal_scnhdr *sec; unsigned off, word; { - unsigned loff, litoff; + unsigned loff, litoff, datum; + struct internal_reloc *rel; loff = (word & 0xFF) << 2; off &= ~3; off += 4; litoff = off + loff; - if (litoff+4 <= sec->size) - printf("ldr\t%s, =0x%x\t; via 0x%x\n", regnames[(word>>8)&7], - get_u32(filemap + sec->data_offset + litoff), litoff); - else + if (litoff+4 <= sec->size) { + rel = find_reloc(sec, litoff); + datum = get_u32(filemap + sec->data_offset + litoff); + printf("ldr\t%s, =", regnames[(word>>8)&7]); + if (rel) + disasm_reloc_target(sec, rel, datum); + else + printf("0x%x", datum); + printf("\t; via 0x%x\n", litoff); + } else printf("ldr\t%s, [pc, #%u]\t(0x%x)\n", regnames[(word>>8)&7], loff, litoff); }