From: Christoph Egger Date: Tue, 10 Mar 2015 11:34:36 +0000 (+0100) Subject: Finish current function before starting next one X-Git-Tag: v0.1~59 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=f9ae4391568cfcbf4e6de0475bddcdd68e9b31d2;p=frida%2Ffrida.git Finish current function before starting next one When BasicBlocks appear in multiple functions, we ran into the situation where a unfinished basicblock is included in a different function and causing bad loops as it's end address wasn't set yet --- diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 875a474..1f1cdff 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -206,6 +206,7 @@ Function* LLVMDisassembler::disassembleFunctionAt(uint64_t address, const template void LLVMDisassembler::disassembleFunction(Function* function) { + std::vector called_functions; std::stack remaining_blocks; /* TODO: * Do all blocks get added properly? We should take care to remove @@ -249,7 +250,7 @@ void LLVMDisassembler::disassembleFunction(Function* function) { if (!MIA->isIndirectBranch(inst)) { if (MIA->isCall(inst)) { if (NULL == manager->getFunction(jmptarget)) - disassembleFunctionAt(jmptarget); + called_functions.push_back(jmptarget); } else { current_block->setNextBlock(0, jmptarget); if (new_blocks.find(jmptarget) == new_blocks.end()) { @@ -298,6 +299,8 @@ void LLVMDisassembler::disassembleFunction(Function* function) { splitBlocks(function); LOG4CXX_DEBUG(logger, "Finished function " << function->getName()); manager->finishFunction(function); + for (uint64_t address : called_functions) + disassembleFunctionAt(address); } template