1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

Don't reject an empty archive.

llvm-svn: 186159
This commit is contained in:
Rafael Espindola 2013-07-12 13:32:28 +00:00
parent ebffe260a7
commit f735609444
3 changed files with 9 additions and 4 deletions

View File

@ -212,9 +212,9 @@ error_code Archive::Child::getAsBinary(OwningPtr<Binary> &Result) const {
Archive::Archive(MemoryBuffer *source, error_code &ec)
: Binary(Binary::ID_Archive, source), SymbolTable(end_children()) {
// Check for sufficient magic.
if (!source || source->getBufferSize()
< (8 + sizeof(ArchiveMemberHeader)) // Smallest archive.
|| StringRef(source->getBufferStart(), 8) != Magic) {
assert(source);
if (source->getBufferSize() < 8 ||
StringRef(source->getBufferStart(), 8) != Magic) {
ec = object_error::invalid_file_type;
return;
}
@ -224,7 +224,7 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
child_iterator e = end_children();
if (i == e) {
ec = object_error::parse_failed;
ec = object_error::success;
return;
}
@ -314,6 +314,8 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
}
Archive::child_iterator Archive::begin_children(bool skip_internal) const {
if (Data->getBufferSize() == 8) // empty archive.
return end_children();
const char *Loc = Data->getBufferStart() + strlen(Magic);
Child c(this, Loc);
// Skip internals at the beginning of an archive.

Binary file not shown.

View File

@ -30,3 +30,6 @@ RUN: llvm-nm %p/Inputs/archive-test.a-gnu-minimal
And don't crash when asked to print a non existing symtab.
RUN: llvm-nm -s %p/Inputs/archive-test.a-gnu-minimal
Don't reject an empty archive.
RUN: llvm-nm %p/Inputs/archive-test.a-empty