Fix Loading of symbolless files
authorChristoph Egger <Christoph.Egger@fau.de>
Tue, 3 Mar 2015 13:10:31 +0000 (14:10 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Tue, 3 Mar 2015 14:34:25 +0000 (15:34 +0100)
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
src/disassembler/llvm/LLVMDisassembler.cxx

index 03cb3b866ec139b875ffad8a7556820b3733c2e1..5681842ba92d18165167033d81a14c22ad59b863 100644 (file)
@@ -50,6 +50,7 @@ public:
 
        Function* getFunction(uint64_t address);
        BasicBlock* getBasicBlock(uint64_t address);
+       bool hasFunctions() const {return functions.size() != 0;}
 
        /* Protocoll:
         *
index 773a5189a27a33d35085da9f698864970b3ac9ec..aeca994c1339c6c72964f334a15746d252abdc22 100644 (file)
@@ -335,10 +335,12 @@ void LLVMDisassembler<ELFT>::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 <typename ELFT>