Hi, Dear LLVM Dev Group,
I am doing an LLVM project aimed to disassemble an ARM ELF binary executable to the MCInst format, inserting some instructions or doing some modification, and re-assemble the MCInst to an ELF binary.
As I used the llvm-mc, it seems to only have the option “llvm-mc -disassemble”, which reads strings and output strings. Is there any command or function that can take a binary, and translates it to the MCInst format, finally translating back to a binary?
Thanks a million for your help.
Best,
Hi Yue,
You may want to have a look to llvm-objdump tool.
You will find some good hints on how to use/build the MCDisassembler to decode the MCInst from a stream of bytes.
More specifically, MCDisassembler::getInstruction does the decode part.
-Quentin
How about:
http://blog.llvm.org/2010/01/x86-disassembler.html
This is what llvm-objdump does:
It has some steps:
-
Define the target
-
Initialize the tables.
-
Decode binary to MCInst
-
Print MCInst in ATT or Intel format.
You would need to modify it to use the ARM target.
You just need to skip step (4)