Skip to content

Commit 976bd23

Browse files
Ramesh Perihtyu
authored andcommitted
[llvm-ar] Fix for handling thin archive with SYM64 and a test case for it
WHen thin archives are created which have symbol table of type SYM64 then all the tools will not work since they cannot read the files properly. One can reproduce the problem as follows: 1. Take a hello world program and create an archive out of it. The SYM64_THRESHOLD=0 will force the generation of SYM64 symbol table. clang -c hello.cpp SYM64_THRESHOLD=0 llvm-ar crsT mylib.a hello.o 2. Now try to use any of the tools on this mylib.a and it will fail. llvm-nm -M mylib.a THis fix will eliminate these failures. A regression test is created in llvm/test/Object/archive-symtab.test Reviewed By: MaskRay, Ramesh Differential Revision: https://reviews.llvm.org/D107322
1 parent b4c0307 commit 976bd23

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/Object/Archive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ Expected<bool> Archive::Child::isThinMember() const {
418418
if (!NameOrErr)
419419
return NameOrErr.takeError();
420420
StringRef Name = NameOrErr.get();
421-
return Parent->IsThin && Name != "/" && Name != "//";
421+
return Parent->IsThin && Name != "/" && Name != "//" && Name != "/SYM64/";
422422
}
423423

424424
Expected<std::string> Archive::Child::getFullName() const {

llvm/test/Object/archive-symtab.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ Symbols:
5050
# RUN: llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
5151
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
5252

53+
# RUN: rm -f %t.a
54+
# RUN: env SYM64_THRESHOLD=0 llvm-ar crTs %t.a %t.elf-x86-64 %t2.elf-x86-64
55+
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
56+
# RUN: grep '/SYM64/' %t.a
57+
5358
# RUN: rm -f %t.a
5459
# RUN: env SYM64_THRESHOLD=836 llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
5560
# RUN: llvm-nm --print-armap %t.a | FileCheck %s

0 commit comments

Comments
 (0)