X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fdisassembler%2Fllvm%2FLLVMDisassembler.hxx;h=6c8767aa1a2bc7b55cb116408446504c109ef513;hp=87dbefa2c9ed355349dcf892aac5a3a936614dae;hb=879c174dd56331b6c7b3254edd115e46a0b5e78c;hpb=c55f9e2b5f5ff83817ab5187eb0122600a4c5cea diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index 87dbefa..6c8767a 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -11,58 +11,74 @@ #include "disassembler/BasicBlock.hxx" #include "disassembler/Function.hxx" #include "disassembler/llvm/LLVMBasicBlock.hxx" +#include "disassembler/llvm/LLVMFunction.hxx" +Disassembler * createLLVMDisassembler(const std::string& filename, InformationManager* manager); + +template class LLVMDisassembler - : public Disassembler { + : public Disassembler { public: - LLVMDisassembler(const std::string& filename); - virtual ~LLVMDisassembler() {}; + LLVMDisassembler(const std::string& filename, InformationManager* manager, + llvm::object::ELFObjectFile* file = NULL); + virtual ~LLVMDisassembler(); - void getSymbols(); - uint64_t entryAddress(); + void start(); + void getSymbols() {} + uint64_t entryAddress() {return _entryAddress;} void forEachFunction(std::function callback); + void printEachInstruction(uint64_t start, uint64_t end, + std::function fun); + + BasicBlock * getBasicBlock(uint64_t address) { + return blocks[address]; + } - BasicBlock * generateControlFlowGraph(const std::string& name); - BasicBlock * generateControlFlowGraph(uint64_t address); + Function * disassembleFunctionAt(uint64_t address, const std::string& name = ""); protected: - bool isFunctionCall(uint64_t address) {return false;} - bool isJump(uint64_t address) {return false;} + bool isFunctionCall(uint64_t address) {return false;} + bool isJump(uint64_t address) {return false;} private: + // http://llvm.org/docs/doxygen/html/MCObjectDisassembler_8cpp_source.html +197 + void disassembleFunction(LLVMFunction* function); + void splitBlocks(LLVMFunction* fun); void disassemble(); void readSymbols(); void readSections(); - log4cxx::LoggerPtr logger; + log4cxx::LoggerPtr logger; std::map blocks; std::map functions; - llvm::Triple triple; - std::shared_ptr binary; - - - const llvm::Target * target; - llvm::object::ObjectFile * o; - - std::unique_ptr MRI; - std::unique_ptr AsmInfo; - std::unique_ptr Mod; - std::unique_ptr IP; - std::unique_ptr DisAsm; - std::unique_ptr MOFI; - std::unique_ptr Ctx; - std::unique_ptr MIA; - std::unique_ptr STI; - std::unique_ptr MII; - llvm::OwningPtr RelInfo; - llvm::OwningPtr Symzer; - - std::map sections; - std::map symbols; + llvm::Triple triple; + std::shared_ptr binary; + + const llvm::Target * target; + llvm::object::ELFObjectFile * o; + + std::unique_ptr MRI; + std::unique_ptr AsmInfo; + std::unique_ptr Mod; + std::unique_ptr IP; + std::unique_ptr DisAsm; + std::unique_ptr MOFI; + std::unique_ptr Ctx; + std::unique_ptr MIA; + std::unique_ptr STI; + std::unique_ptr MII; + std::unique_ptr RelInfo; + std::unique_ptr Symzer; + + std::map sections; + std::map symbols; + InformationManager * manager; + uint64_t _entryAddress; }; #endif