Add support for archives with no symbol table or string table.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 4 Jul 2013 19:40:23 +0000 (19:40 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 4 Jul 2013 19:40:23 +0000 (19:40 +0000)
llvm-svn: 185664

llvm/lib/Object/Archive.cpp
llvm/test/Object/Inputs/archive-test.a-gnu-minimal [new file with mode: 0644]
llvm/test/Object/nm-archive.test

index 8206b0a..0b819f4 100644 (file)
@@ -104,7 +104,7 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
   : Binary(Binary::ID_Archive, source) {
   // Check for sufficient magic.
   if (!source || source->getBufferSize()
-                 < (8 + sizeof(ArchiveMemberHeader) + 2) // Smallest archive.
+                 < (8 + sizeof(ArchiveMemberHeader)) // Smallest archive.
               || StringRef(source->getBufferStart(), 8) != Magic) {
     ec = object_error::invalid_file_type;
     return;
diff --git a/llvm/test/Object/Inputs/archive-test.a-gnu-minimal b/llvm/test/Object/Inputs/archive-test.a-gnu-minimal
new file mode 100644 (file)
index 0000000..a243273
--- /dev/null
@@ -0,0 +1,2 @@
+!<arch>
+test/           1372964340  1000  1000  100664  0         `
index 869bea8..922983c 100644 (file)
@@ -9,6 +9,9 @@ RUN: llvm-nm %t2 | FileCheck %s -check-prefix BITCODE
 Test we don't error with an archive with no symtab.
 RUN: llvm-nm %p/Inputs/archive-test.a-gnu-no-symtab
 
+Or in an archive with no symtab or string table.
+RUN: llvm-nm %p/Inputs/archive-test.a-gnu-minimal
+
 COFF: trivial-object-test.coff-i386:
 COFF-NEXT: 00000000 d .data
 COFF-NEXT: 00000000 t .text