From 87cd2baa79a6bbfaaad9d0c69bbf1fdb7462c20a Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Tue, 19 May 2015 17:57:43 +0200 Subject: [PATCH] Don't create empty blocks for unconditional jumps out of the text segment These are most likely optimized tail-calls and should be handles as such. Ref T34 --- src/disassembler/llvm/LLVMDisassembler.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 049f1fc..5dc7f3a 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -322,6 +322,15 @@ void LLVMDisassembler::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); -- 2.39.5