I have been trying to use LLVM as a disassembler, thus providing a
small part of my decompiler that I am working on.
It currently decompiles from X86_64 binary.o -> LLVM IR.
It works with a small set of test programs so far, so cannot currently
handle large binary programs yet.
The problem is with the LLVM "getInstruction()" method.
It used to have a PC (program counter) parameter that worked. You
could use the PC as an offset within the buffer to start disassembling
In LLVM 4.0 and above the only value of the PC parameter that works is zero.
Please can someone look into fixing this?
P.S. Example code below:
TripleName = "x86_64-pc-linux-gnu";
// Get the target.
// Set up disassembler.
DisAsm = TheTarget->createMCDisassembler(*STI, *Ctx);
// S = DisAsm->getInstruction(*Inst, Size, Bytes_A, PC,
// /*REMOVE*/ nulls(), nulls());
// Latest LLVM messes up with the PC set to anything other than zero
S = DisAsm->getInstruction(*Inst, Size, Bytes_A, 0,
/*REMOVE*/ nulls(), nulls());