]> git.siccegge.de Git - frida/frida.git/commitdiff
Finish current function before starting next one
authorChristoph Egger <Christoph.Egger@fau.de>
Tue, 10 Mar 2015 11:34:36 +0000 (12:34 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Tue, 10 Mar 2015 11:34:36 +0000 (12:34 +0100)
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

src/disassembler/llvm/LLVMDisassembler.cxx

index 875a474b239c1d69607b55f60c4b1d564fa5d048..1f1cdff1d17670d6b87b900523ef33b7f85bbc6a 100644 (file)
@@ -206,6 +206,7 @@ Function* LLVMDisassembler<ELFT>::disassembleFunctionAt(uint64_t address, const
 
 template <typename ELFT>
 void LLVMDisassembler<ELFT>::disassembleFunction(Function* function) {
+       std::vector<uint64_t> called_functions;
        std::stack<BasicBlock*> remaining_blocks;
        /* TODO:
         * Do all blocks get added properly? We should take care to remove
@@ -249,7 +250,7 @@ void LLVMDisassembler<ELFT>::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<ELFT>::disassembleFunction(Function* function) {
        splitBlocks(function);
        LOG4CXX_DEBUG(logger, "Finished function " << function->getName());
        manager->finishFunction(function);
+       for (uint64_t address : called_functions)
+               disassembleFunctionAt(address);
 }
 
 template <typename ELFT>