[lld] ed1c8d7 - ELF, test: Test unversioned undefined symbols of index 0 and 1

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 22:13:40 PST 2025


Author: Fangrui Song
Date: 2025-11-18T22:13:34-08:00
New Revision: ed1c8d7a57808de7ac60f2d0ff3e2b03a765cb7f

URL: https://github.com/llvm/llvm-project/commit/ed1c8d7a57808de7ac60f2d0ff3e2b03a765cb7f
DIFF: https://github.com/llvm/llvm-project/commit/ed1c8d7a57808de7ac60f2d0ff3e2b03a765cb7f.diff

LOG: ELF,test: Test unversioned undefined symbols of index 0 and 1

My 2020 change that added versioned symbol recognition
(reviews.llvm.org/D80059) checks both VER_NDX_LOCAL and VER_NDX_GLOBAL,
though test coverage was missing. lld/test/ELF/dso-undef-extract-lazy.s
checks that the undefined symbol is indeed considered unversioned.

Added: 
    

Modified: 
    lld/test/ELF/dso-undef-extract-lazy.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/dso-undef-extract-lazy.s b/lld/test/ELF/dso-undef-extract-lazy.s
index 40b0758957d7a..5d925453f27d7 100644
--- a/lld/test/ELF/dso-undef-extract-lazy.s
+++ b/lld/test/ELF/dso-undef-extract-lazy.s
@@ -25,6 +25,11 @@
 
 # CHECK-FETCH: GLOBAL DEFAULT {{[0-9]+}} foo
 
+## Unversioned undefined symbols also extract the archive definitions.
+# RUN: yaml2obj %t/ver.yaml -o %t4.so
+# RUN: ld.lld %t1.o %t4.so %t2.a -o %t.exe
+# RUN: llvm-readelf --dyn-symbols %t.exe | FileCheck %s --check-prefix=CHECK-FETCH
+
 #--- main.s
 .text
 .globl _start
@@ -38,3 +43,39 @@ foo:
 
 #--- shlib.s
 .global foo
+
+#--- ver.yaml
+--- !ELF
+FileHeader:
+  Class: ELFCLASS64
+  Data:  ELFDATA2LSB
+  Type:  ET_DYN
+  Machine: EM_X86_64
+Sections:
+  - Name:            .gnu.version
+    Type:            SHT_GNU_versym
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x0000000000200210
+    AddressAlign:    0x0000000000000002
+    EntSize:         0x0000000000000002
+## Test both index 0 and 1 for unversioned undefined symbols.
+## https://sourceware.org/PR33577
+    Entries:         [ 0, 0, 1 ]
+  - Name:            .gnu.version_r
+    Type:            SHT_GNU_verneed
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x0000000000200250
+    AddressAlign:    0x0000000000000004
+    Dependencies:
+      - Version:         1
+        File:            dso.so.0
+        Entries:
+          - Name:            v1
+            Hash:            1937
+            Flags:           0
+            Other:           3
+DynamicSymbols:
+  - Name:    _start
+    Binding: STB_GLOBAL
+  - Name:    foo
+    Binding: STB_GLOBAL


        


More information about the llvm-commits mailing list