Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distinguish thumb instruction from arm instruction in an elf file?

As the title shows, I want to disassemble the ELF file, but I suffered a problem that I could not know which instruction is arm instruction and which is thumb instruction. Because the arm instruction is 32-bit, and the thumb instruction is 16-bit, the disassembling way is different. So how could I detect the thumb instruction from the hex instructions?

like image 797
user2301210 Avatar asked Oct 29 '25 15:10

user2301210


1 Answers

In an ELF file, there is actually a straightforward method - just look at the function addresses in the symbol table. Much like target addresses for interworking branches, the bottom bit of the symbol address indicates the relevant instruction set - clear for ARM functions, and set for Thumb functions (see section 4.5.3 of the ARM ELF ABI).

like image 101
Notlikethat Avatar answered Nov 01 '25 13:11

Notlikethat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!