[llvm] 976bd23 - [llvm-ar] Fix for handling thin archive with SYM64 and a test case for it
Hongtao Yu via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 5 10:06:40 PDT 2021
Author: Ramesh Peri
Date: 2021-08-05T10:06:34-07:00
New Revision: 976bd2361237f2fafc736d26dc78d1b95cd80d94
URL: https://github.com/llvm/llvm-project/commit/976bd2361237f2fafc736d26dc78d1b95cd80d94
DIFF: https://github.com/llvm/llvm-project/commit/976bd2361237f2fafc736d26dc78d1b95cd80d94.diff
LOG: [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
Added:
Modified:
llvm/lib/Object/Archive.cpp
llvm/test/Object/archive-symtab.test
Removed:
################################################################################
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 6ff896cf347ed..5492692445e75 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -418,7 +418,7 @@ Expected<bool> Archive::Child::isThinMember() const {
if (!NameOrErr)
return NameOrErr.takeError();
StringRef Name = NameOrErr.get();
- return Parent->IsThin && Name != "/" && Name != "//";
+ return Parent->IsThin && Name != "/" && Name != "//" && Name != "/SYM64/";
}
Expected<std::string> Archive::Child::getFullName() const {
diff --git a/llvm/test/Object/archive-symtab.test b/llvm/test/Object/archive-symtab.test
index e58672157c289..9ef2ba29820dd 100644
--- a/llvm/test/Object/archive-symtab.test
+++ b/llvm/test/Object/archive-symtab.test
@@ -50,6 +50,11 @@ Symbols:
# RUN: llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
+# RUN: rm -f %t.a
+# RUN: env SYM64_THRESHOLD=0 llvm-ar crTs %t.a %t.elf-x86-64 %t2.elf-x86-64
+# RUN: llvm-nm --print-armap %t.a | FileCheck %s
+# RUN: grep '/SYM64/' %t.a
+
# RUN: rm -f %t.a
# RUN: env SYM64_THRESHOLD=836 llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
# RUN: llvm-nm --print-armap %t.a | FileCheck %s
More information about the llvm-commits
mailing list