mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Don't reject an empty archive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186159 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -212,9 +212,9 @@ error_code Archive::Child::getAsBinary(OwningPtr<Binary> &Result) const {
|
|||||||
Archive::Archive(MemoryBuffer *source, error_code &ec)
|
Archive::Archive(MemoryBuffer *source, error_code &ec)
|
||||||
: Binary(Binary::ID_Archive, source), SymbolTable(end_children()) {
|
: Binary(Binary::ID_Archive, source), SymbolTable(end_children()) {
|
||||||
// Check for sufficient magic.
|
// Check for sufficient magic.
|
||||||
if (!source || source->getBufferSize()
|
assert(source);
|
||||||
< (8 + sizeof(ArchiveMemberHeader)) // Smallest archive.
|
if (source->getBufferSize() < 8 ||
|
||||||
|| StringRef(source->getBufferStart(), 8) != Magic) {
|
StringRef(source->getBufferStart(), 8) != Magic) {
|
||||||
ec = object_error::invalid_file_type;
|
ec = object_error::invalid_file_type;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
|
|||||||
child_iterator e = end_children();
|
child_iterator e = end_children();
|
||||||
|
|
||||||
if (i == e) {
|
if (i == e) {
|
||||||
ec = object_error::parse_failed;
|
ec = object_error::success;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,6 +314,8 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Archive::child_iterator Archive::begin_children(bool skip_internal) const {
|
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);
|
const char *Loc = Data->getBufferStart() + strlen(Magic);
|
||||||
Child c(this, Loc);
|
Child c(this, Loc);
|
||||||
// Skip internals at the beginning of an archive.
|
// Skip internals at the beginning of an archive.
|
||||||
|
1
test/Object/Inputs/archive-test.a-empty
Normal file
1
test/Object/Inputs/archive-test.a-empty
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!<arch>
|
@@ -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.
|
And don't crash when asked to print a non existing symtab.
|
||||||
RUN: llvm-nm -s %p/Inputs/archive-test.a-gnu-minimal
|
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
|
||||||
|
Reference in New Issue
Block a user