From: Christoph Egger Date: Tue, 27 May 2014 14:17:13 +0000 (+0200) Subject: Properly create and export BasicBlock linking X-Git-Tag: v0.1~191 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=1d66010fc38eab99ec29d25606e3d44a3297e6e6;p=frida%2Ffrida.git Properly create and export BasicBlock linking --- diff --git a/src/disassembler/Disassembler.hxx b/src/disassembler/Disassembler.hxx index 285c673..7ad4dc0 100644 --- a/src/disassembler/Disassembler.hxx +++ b/src/disassembler/Disassembler.hxx @@ -17,6 +17,7 @@ public: uint64_t entryAddress(); virtual void forEachFunction(std::function callback) = 0; + virtual BasicBlock * getBasicBlock(uint64_t address) = 0; protected: virtual bool isFunctionCall(uint64_t address) = 0; diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index c6146f8..a8c2867 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -214,6 +214,7 @@ void LLVMDisassembler::disassemble() { if (blocks.find(jmptarget) == blocks.end()) { LLVMBasicBlock * block = new LLVMBasicBlock(jmptarget); blocks.insert(std::make_pair(block->getStartAddress(), block)); + current_block->setNextBlock(0, block->getStartAddress()); remaining_blocks.push(block); } if (MIA->isConditionalBranch(inst)) { @@ -221,6 +222,7 @@ void LLVMDisassembler::disassemble() { if (blocks.find(jmptarget) == blocks.end()) { LLVMBasicBlock * block = new LLVMBasicBlock(jmptarget); blocks.insert(std::make_pair(block->getStartAddress(), block)); + current_block->setNextBlock(1, block->getStartAddress()); remaining_blocks.push(new LLVMBasicBlock(jmptarget)); } } diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index 682b1df..848b20e 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -24,6 +24,9 @@ public: uint64_t entryAddress(); void forEachFunction(std::function callback); + BasicBlock * getBasicBlock(uint64_t address) { + return blocks[address]; + } protected: bool isFunctionCall(uint64_t address) {return false;}