1

I am writing/(using binutils) a piece code to do an manual dis-assembly of thumb2(16bit and 32 bit) instructions. I am facing a problem to differentiate between genuine ARM instructions and DATA portions.

The biggest problem is instructions are not word aligned. So when i try to read 32 bit instruction, many times it actually overlapping with the next instructions.

Any help please.

Thanks, VJ

old_timer
  • 69,149
  • 8
  • 89
  • 168
user1468106
  • 33
  • 1
  • 3

2 Answers2

0

arm instructions are always word aligned. thumb are always aligned. thumb2 is variable word length. and you cant disassemble a variable word length the same way a fixed word length. to disassemble variable word length instruction sets you cannot simply walk through memory on aligned addresses and disassemble. In some form you must walk the data in execution order to find the start address for each instruction, then from that list you disassemble.

old_timer
  • 69,149
  • 8
  • 89
  • 168
0

If you are able to also read the symbol table, GCC will leave symbols $a $t $d indicating at which address you should switch how you interpret bytes: Arm, Thumb and Data, respectively.

For example, this is how objdump knows to display the contents of literal pools, but not try to map them back to instructions, despite existing between adjacent functions in the a .text section..

Thomson
  • 20,586
  • 28
  • 90
  • 134
David Mirabito
  • 455
  • 5
  • 13