X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fdisassembler%2Fllvm%2FLLVMDisassembler.hxx;h=d00381b7ed962862c8be6e26008cdf94d06f9da8;hp=87dbefa2c9ed355349dcf892aac5a3a936614dae;hb=0daf9a157f3d41690cf4a0287db1adecc4ad0b71;hpb=c55f9e2b5f5ff83817ab5187eb0122600a4c5cea diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index 87dbefa..d00381b 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -8,61 +8,71 @@ #include "include_llvm.hxx" #include "disassembler/Disassembler.hxx" -#include "disassembler/BasicBlock.hxx" -#include "disassembler/Function.hxx" -#include "disassembler/llvm/LLVMBasicBlock.hxx" +class Function; +class BasicBlock; +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 * 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: + typedef llvm::object::ELFFile ELFO; + + // http://llvm.org/docs/doxygen/html/MCObjectDisassembler_8cpp_source.html +197 + void disassembleFunction(Function* function); + void splitBlocks(Function* fun); void disassemble(); void readSymbols(); void readSections(); - - 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; + void readDynamicSymbols(); + + log4cxx::LoggerPtr logger; + + 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