diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-10 20:14:22 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-10 20:14:22 +0000 |
commit | 5159718095bd8a18c1661889e93af3aca8eaa5aa (patch) | |
tree | 0404298ed72edcfe60e8fb18c6d9a14bb3962909 /lib | |
parent | ed094c32ff2683c07d8eec558ee9defa4f0c00f6 (diff) | |
download | llvm-5159718095bd8a18c1661889e93af3aca8eaa5aa.tar.gz llvm-5159718095bd8a18c1661889e93af3aca8eaa5aa.tar.bz2 llvm-5159718095bd8a18c1661889e93af3aca8eaa5aa.tar.xz |
Don't crash in 'llvm -s' when an archive has no symtab.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186029 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Object/Archive.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index 292d50a176..91cc4efde2 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -210,7 +210,7 @@ error_code Archive::Child::getAsBinary(OwningPtr<Binary> &Result) const { } Archive::Archive(MemoryBuffer *source, error_code &ec) - : Binary(Binary::ID_Archive, source) { + : Binary(Binary::ID_Archive, source), SymbolTable(end_children()) { // Check for sufficient magic. if (!source || source->getBufferSize() < (8 + sizeof(ArchiveMemberHeader)) // Smallest archive. @@ -375,6 +375,9 @@ Archive::Symbol Archive::Symbol::getNext() const { } Archive::symbol_iterator Archive::begin_symbols() const { + if (SymbolTable == end_children()) + return symbol_iterator(Symbol(this, 0, 0)); + const char *buf = SymbolTable->getBuffer().begin(); if (kind() == K_GNU) { uint32_t symbol_count = 0; @@ -395,6 +398,9 @@ Archive::symbol_iterator Archive::begin_symbols() const { } Archive::symbol_iterator Archive::end_symbols() const { + if (SymbolTable == end_children()) + return symbol_iterator(Symbol(this, 0, 0)); + const char *buf = SymbolTable->getBuffer().begin(); uint32_t symbol_count = 0; if (kind() == K_GNU) { |