From db08681ab30cdc2a322663b836d215cacedea71a Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Tue, 3 Mar 2015 14:10:31 +0100 Subject: [PATCH] Fix Loading of symbolless files The last commit unconditionally enabled disassembling from the start of the text section. On a sample binary (/bin/true) this resulted in a BasicBlock with a size of several TiB which won't terminate properly. --- src/core/InformationManager.hxx | 1 + src/disassembler/llvm/LLVMDisassembler.cxx | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/InformationManager.hxx b/src/core/InformationManager.hxx index 03cb3b8..5681842 100644 --- a/src/core/InformationManager.hxx +++ b/src/core/InformationManager.hxx @@ -50,6 +50,7 @@ public: Function* getFunction(uint64_t address); BasicBlock* getBasicBlock(uint64_t address); + bool hasFunctions() const {return functions.size() != 0;} /* Protocoll: * diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 773a518..aeca994 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -335,10 +335,12 @@ void LLVMDisassembler::disassemble() { disassembleFunctionAt(_entryAddress, s.str()); } - uint64_t text_entry; - text_section.getAddress(text_entry); - LOG4CXX_INFO(logger, "No Symbols found, starting at the beginning of the text segment"); - disassembleFunctionAt(text_entry); + if (!manager->hasFunctions()) { + uint64_t text_entry; + text_section.getAddress(text_entry); + LOG4CXX_INFO(logger, "No Symbols found, starting at the beginning of the text segment"); + disassembleFunctionAt(text_entry); + } } template -- 2.39.2