From 1d66010fc38eab99ec29d25606e3d44a3297e6e6 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Tue, 27 May 2014 16:17:13 +0200 Subject: [PATCH] Properly create and export BasicBlock linking --- src/disassembler/Disassembler.hxx | 1 + src/disassembler/llvm/LLVMDisassembler.cxx | 2 ++ src/disassembler/llvm/LLVMDisassembler.hxx | 3 +++ 3 files changed, 6 insertions(+) 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;} -- 2.39.5