# HG changeset patch # User Michael Spacefalcon # Date 1396509380 0 # Node ID f9fde7f36ae341122cacd54fd85117d502854ad3 # Parent 5f4141ee175bfea1a8113f0078183e2d3e50c64a tiobjd: Thumb_BL reloc handling diff -r 5f4141ee175b -r f9fde7f36ae3 ticoff/disasm.c --- a/ticoff/disasm.c Thu Apr 03 07:00:08 2014 +0000 +++ b/ticoff/disasm.c Thu Apr 03 07:16:20 2014 +0000 @@ -136,8 +136,14 @@ printf("MISALIGNED pos in CODE16 state, aborting\n"); return; } - /* reloc handling to be added */ - if (headroom >= 4 && thumb_check_bl(sec, pos)) + if (rel) { + if (rel->type != RTYPE_THUMB_BL) { + printf("Wrong reloc type in CODE16 state, aborting\n"); + return; + } + thumb_bl_reloc(sec, rel); + incr = 4; + } else if (headroom >= 4 && thumb_check_bl(sec, pos)) incr = 4; else { thumb_disasm_line(sec, pos); diff -r 5f4141ee175b -r f9fde7f36ae3 ticoff/thumbdis.c --- 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("\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'); +}