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, -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130918/819e5526/attachment.html>
Quentin Colombet
2013-Sep-18 23:16 UTC
[LLVMdev] Translation between MCInst and Binary Executable
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 On Sep 18, 2013, at 2:07 PM, Yue Chen <ycyc54321 at gmail.com> wrote:> > 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, > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130918/88bcaa2f/attachment.html>
James Courtier-Dutton
2013-Sep-18 23:48 UTC
[LLVMdev] Translation between MCInst and Binary Executable
How about: http://blog.llvm.org/2010/01/x86-disassembler.html This is what llvm-objdump does: It has some steps: 1) Define the target 2) Initialize the tables. 3) Decode binary to MCInst 4) 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) On 18 September 2013 22:07, Yue Chen <ycyc54321 at gmail.com> wrote:> > 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, > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130919/9af43622/attachment.html>