FreeCalypso > hg > freecalypso-reveng
diff ticoff/thumbdis.c @ 117:f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 03 Apr 2014 07:16:20 +0000 |
parents | 2f23301d2f86 |
children | ca82528ec84d |
line wrap: on
line diff
--- a/ticoff/thumbdis.c Thu Apr 03 07:00:08 2014 +0000 +++ b/ticoff/thumbdis.c Thu Apr 03 07:16:20 2014 +0000 @@ -405,3 +405,27 @@ printf("%04x %04x\tbl\t0x%x\n", ins1, ins2, dest); return(1); } + +void +thumb_bl_reloc(sec, rel) + struct internal_scnhdr *sec; + struct internal_reloc *rel; +{ + unsigned ins1, ins2; + unsigned dest; + + ins1 = get_u16(filemap + sec->data_offset + rel->location); + ins2 = get_u16(filemap + sec->data_offset + rel->location + 2); + printf("%04x %04x R\t", ins1, ins2); + if ((ins1 & 0xF800) != 0xF000 || (ins2 & 0xF800) != 0xF800) { + printf("<invalid Thumb_BL reloc: opcode not BL>\n"); + return; + } + dest = ((ins1 & 0x7FF) << 12) | ((ins2 & 0x7FF) << 1); + if (dest & 0x00400000) + dest |= 0xFF800000; + dest += rel->location + 4; + fputs("bl\t", stdout); + disasm_reloc_target(sec, rel, dest); + putchar('\n'); +}