1 #ifndef INCLUDE__LLVMDisassembler_hxx
2 #define INCLUDE__LLVMDisassembler_hxx
6 #include <log4cxx/logger.h>
8 #include "include_llvm.hxx"
10 #include "disassembler/Disassembler.hxx"
15 Disassembler * createLLVMDisassembler(const std::string& filename, InformationManager* manager);
17 template <typename ObjectType>
18 class LLVMDisassembler
19 : public Disassembler {
21 LLVMDisassembler(const std::string& filename, InformationManager* manager,
22 llvm::object::ObjectFile* file = NULL);
23 virtual ~LLVMDisassembler();
27 uint64_t entryAddress();
29 void printEachInstruction(uint64_t start, uint64_t end,
30 std::function<void (uint8_t*, size_t, const std::string&,
31 const std::string&)> fun);
33 Function * disassembleFunctionAt(uint64_t address, const std::string& name = "");
34 std::vector<Instruction> getInstructions(const BasicBlock* block);
37 // http://llvm.org/docs/doxygen/html/MCObjectDisassembler_8cpp_source.html +197
38 void disassembleFunction(Function* function);
39 void splitBlocks(Function* fun);
41 llvm::object::SectionRef getTextSection();
45 void readDynamicSymbols();
47 log4cxx::LoggerPtr logger;
50 std::shared_ptr<llvm::object::Binary> binary;
52 const llvm::Target * target;
53 llvm::object::ObjectFile * o;
55 std::unique_ptr<const llvm::MCRegisterInfo> MRI;
56 std::unique_ptr<const llvm::MCAsmInfo> AsmInfo;
57 std::unique_ptr<llvm::MCModule> Mod;
58 std::unique_ptr<llvm::MCInstPrinter> IP;
59 std::unique_ptr<llvm::MCDisassembler> DisAsm;
60 std::unique_ptr<const llvm::MCObjectFileInfo> MOFI;
61 std::unique_ptr<llvm::MCContext> Ctx;
62 std::unique_ptr<const llvm::MCInstrAnalysis> MIA;
63 std::unique_ptr<const llvm::MCSubtargetInfo> STI;
64 std::unique_ptr<const llvm::MCInstrInfo> MII;
65 std::unique_ptr<llvm::MCRelocationInfo> RelInfo;
66 std::unique_ptr<llvm::MCSymbolizer> Symzer;
68 std::map<std::string, llvm::object::SectionRef> sections;
69 std::map<std::string, llvm::object::SymbolRef> symbols;
70 InformationManager * manager;
71 uint64_t _entryAddress;