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
This commit is contained in:
Rafael Espindola
2013-07-10 20:14:22 +00:00
parent ed094c32ff
commit 5159718095
3 changed files with 39 additions and 23 deletions
+7 -1
View File
@@ -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) {