James Courtier-Dutton via llvm-dev
2018-Apr-03 12:43 UTC
[llvm-dev] Problems using LLVM as a disassembler.
Hi, 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 from. In LLVM 4.0 and above the only value of the PC parameter that works is zero. Please can someone look into fixing this? Kind Regards James P.S. Example code below: TripleName = "x86_64-pc-linux-gnu"; // Get the target. std::string Error; DecodeAsmX86_64::TheTarget llvm::TargetRegistry::lookupTarget(TripleName, Error); if (!TheTarget) return 1; ... // Set up disassembler. DisAsm = TheTarget->createMCDisassembler(*STI, *Ctx); if (!DisAsm) return 1; ... // 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());
Maybe Matching Threads
- [LLVMdev] Looking for ideas on how to make llvm-objdump handle both arm and thumb disassembly from the same object file
- Using an MCStreamer Directly to produce an object file?
- [LLVMdev] Disassembly arbitrary machine-code byte arrays
- Using an MCStreamer Directly to produce an object file?
- [LLVMdev] Disassembly arbitrary machine-code byte arrays