[PATCH] D107322: Fix for handling thin archive with SYM64 and a test case for it

Ramesh Peri via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 2 20:43:07 PDT 2021


Ramesh created this revision.
Herald added a subscriber: hiraditya.
Ramesh requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107322

Files:
  llvm/lib/Object/Archive.cpp
  llvm/test/Object/archive-symtab.test


Index: llvm/test/Object/archive-symtab.test
===================================================================
--- llvm/test/Object/archive-symtab.test
+++ llvm/test/Object/archive-symtab.test
@@ -50,6 +50,11 @@
 # RUN: llvm-ar rcsU %t.a %t.elf-x86-64 %t2.elf-x86-64
 # RUN: llvm-nm -M %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 -M  %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 -M %t.a | FileCheck %s
@@ -60,6 +65,7 @@
 # RUN: llvm-nm -M %t.a | FileCheck %s
 # RUN: not grep '/SYM64/' %t.a
 
+
 # CHECK: Archive map
 # CHECK-NEXT: main in {{.*}}.elf-x86-64
 # CHECK-NEXT: foo in {{.*}}2.elf-x86-64
Index: llvm/lib/Object/Archive.cpp
===================================================================
--- llvm/lib/Object/Archive.cpp
+++ llvm/lib/Object/Archive.cpp
@@ -418,7 +418,7 @@
   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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107322.363620.patch
Type: text/x-patch
Size: 1289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210803/30b4ede2/attachment.bin>


More information about the llvm-commits mailing list