From 9abbcb7453368fbdb30f155e99c9dd05b5a154a3 Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Wed, 12 Nov 2014 01:37:45 +0000 Subject: [PATCH] Object, support both mach-o archive t.o.c file names 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 | 2 +- .../Inputs/macho-archive-unsorted-x86_64.a | Bin 0 -> 1304 bytes test/Object/archive-symtab.test | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 test/Object/Inputs/macho-archive-unsorted-x86_64.a diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index 070fe812eec..d169dbee46e 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -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 index 0000000000000000000000000000000000000000..6a2b570f160966411c438950570370d3a82dd6f0 GIT binary patch literal 1304 zcmbVMy-EW?5T1+ihf|Xj777+8T3E$9x%dMj1`|o45Hx}ovN>ZyEHn~M6sr^>*!c)P zhNWO*=TitazJP`L&E9Tq5fSwxvokw0J2N*kWMV03*P6@rq&G9`Ix#%o%gyJ!#d+Ux zJlDDNX5>cq z%17VzTzO9zznyDeG9d&@qrNQ1=G$mVL0+6dPIF( z%QX6_N;Nx+`sz*5Xa`62=)u>$n^tjF6n|0i)RpJ2KV7Qyp12S=Zxx*P#@rLGgNc20 zpCJAT+okL0y@&XT>Yw_=SU;jf>td6v^Nf`l>L0j)*A(>Qpu3L}_7!jm`Cr6Gw%(*-DeAFHpVK#Tr~m)} literal 0 HcmV?d00001 diff --git a/test/Object/archive-symtab.test b/test/Object/archive-symtab.test index 0899828bdfb..01f17bcc8b6 100644 --- a/test/Object/archive-symtab.test +++ b/test/Object/archive-symtab.test @@ -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 -- 2.40.0