[lld] [ELF] Fix unnecessary inclusion of unreferenced provide symbols (PR #84512)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 13:43:13 PDT 2024


================
@@ -0,0 +1,60 @@
+# REQUIRES: x86
+
+# This test verifies that garbage-collection is correctly garbage collecting
+# unused sections when the symbol of the unused section is only referred by
+# an unused PROVIDE symbol.
+
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
+# RUN: ld.lld -o a_nogc a.o -T script.t
+# RUN: llvm-readobj --sections --symbols a_nogc | FileCheck -check-prefix=NOGC %s
+# RUN: ld.lld -o a_gc a.o --gc-sections --print-gc-sections -T script.t | FileCheck --check-prefix=GC_LINK %s
+# RUN: llvm-readobj --sections --symbols a_gc | FileCheck -check-prefix=GC %s
+
+NOGC: Name: foo
+NOGC: Name: used
+NOGC: Name: bar
+NOGC: Name: baz
+NOGC: Name: another_used
+NOGC: Name: baz_ref
+NOGC-NOT: unused
----------------
partaror wrote:

Oh, thank you for informing about this. I have modified the test to use `llvm-nm` instead.

https://github.com/llvm/llvm-project/pull/84512


More information about the llvm-commits mailing list