]> granicus.if.org Git - llvm/commitdiff
Object, support both mach-o archive t.o.c file names
authorNick Kledzik <kledzik@apple.com>
Wed, 12 Nov 2014 01:37:45 +0000 (01:37 +0000)
committerNick Kledzik <kledzik@apple.com>
Wed, 12 Nov 2014 01:37:45 +0000 (01:37 +0000)
For historical reasons archives on mach-o have two possible names for the
file containing the table of contents for the archive: "__.SYMDEF SORTED"
and "__.SYMDEF".  But the libObject archive reader only supported the former.

This patch fixes llvm::object::Archive to support both names.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221747 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/Archive.cpp
test/Object/Inputs/macho-archive-unsorted-x86_64.a [new file with mode: 0644]
test/Object/archive-symtab.test

index 070fe812eec23781e7ce4bdb6eed273900bf625d..d169dbee46e324804dce3bc7c31d7dcfdf7118ed 100644 (file)
@@ -240,7 +240,7 @@ Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
     if (ec)
       return;
     Name = NameOrErr.get();
-    if (Name == "__.SYMDEF SORTED") {
+    if (Name == "__.SYMDEF SORTED" || Name == "__.SYMDEF") {
       SymbolTable = i;
       ++i;
     }
diff --git a/test/Object/Inputs/macho-archive-unsorted-x86_64.a b/test/Object/Inputs/macho-archive-unsorted-x86_64.a
new file mode 100644 (file)
index 0000000..6a2b570
Binary files /dev/null and b/test/Object/Inputs/macho-archive-unsorted-x86_64.a differ
index 0899828bdfbed5b73215c016733876dacd07179b..01f17bcc8b6124e5ca2f1af63d68268d5ecbb04c 100644 (file)
@@ -61,6 +61,7 @@ RUN: llvm-ranlib %t.a
 RUN: llvm-nm -M %t.a | FileCheck %s
 
 RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
+RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
 
 BSD-MachO: Archive map
 BSD-MachO: _bar in bar.o