]> git.siccegge.de Git - frida/frida.git/commitdiff
Don't create empty blocks for unconditional jumps out of the text segment
authorChristoph Egger <siccegge@stud.informatik.uni-erlangen.de>
Tue, 19 May 2015 15:57:43 +0000 (17:57 +0200)
committerChristoph Egger <christoph@anonymous.siccegge.de>
Tue, 19 May 2015 17:04:58 +0000 (19:04 +0200)
These are most likely optimized tail-calls and should be handles as
such.

Ref T34

src/disassembler/llvm/LLVMDisassembler.cxx

index 049f1fc90477b82d1a30427bbd7352a9d7a98cf3..5dc7f3a0489d265dc70383c35255ac3dde2eae6b 100644 (file)
@@ -322,6 +322,15 @@ void LLVMDisassembler<ELFT>::disassembleFunction(Function* function) {
                                                        if (NULL == manager->getFunction(jmptarget))
                                                                called_functions.push_back(jmptarget);
                                                } else {
+                                                       if(jmptarget < base_address || jmptarget > base_address + size) {
+                                                               if (MIA->isConditionalBranch(inst)) {
+                                                                       LOG4CXX_WARN(logger, "Conditional jump out of the text segment. This should never happen!");
+                                                               } else {
+                                                                       LOG4CXX_INFO(logger, "Unconditional jump to PLT. Assuming Tail-Call to some library");
+                                                                       current_address += inst_size;
+                                                                       continue;
+                                                               }
+                                                       }
                                                        current_block->setNextBlock(0, jmptarget);
                                                        if (new_blocks.find(jmptarget) == new_blocks.end()) {
                                                                BasicBlock * block = manager->newBasicBlock(jmptarget);