File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -1676,8 +1676,9 @@ template <class ELFT> void SharedFile::parse() {
16761676
16771677 const uint16_t ver = versyms[i], idx = ver & ~VERSYM_HIDDEN;
16781678 if (sym.isUndefined ()) {
1679- // For unversioned undefined symbols, VER_NDX_GLOBAL makes more sense but
1680- // as of binutils 2.34, GNU ld produces VER_NDX_LOCAL.
1679+ // Index 0 (VER_NDX_LOCAL) is used for unversioned undefined symbols.
1680+ // GNU ld versions between 2.35 and 2.45 also generate VER_NDX_GLOBAL
1681+ // for this case (https://sourceware.org/PR33577).
16811682 if (ver != VER_NDX_LOCAL && ver != VER_NDX_GLOBAL) {
16821683 if (idx >= verneeds.size ()) {
16831684 ErrAlways (ctx) << " corrupt input file: version need index " << idx
Original file line number Diff line number Diff line change 2525
2626# CHECK-FETCH: GLOBAL DEFAULT {{[0-9]+}} foo
2727
28+ ## Unversioned undefined symbols also extract the archive definitions.
29+ # RUN: yaml2obj %t/ver.yaml -o %t4.so
30+ # RUN: ld.lld %t1.o %t4.so %t2.a -o %t.exe
31+ # RUN: llvm-readelf --dyn-symbols %t.exe | FileCheck %s --check-prefix=CHECK-FETCH
32+
2833#--- main.s
2934.text
3035.globl _start
3843
3944#--- shlib.s
4045.global foo
46+
47+ #--- ver.yaml
48+ --- !ELF
49+ FileHeader:
50+ Class: ELFCLASS64
51+ Data: ELFDATA2LSB
52+ Type: ET_DYN
53+ Machine: EM_X86_64
54+ Sections:
55+ - Name: .gnu.version
56+ Type: SHT_GNU_versym
57+ Flags: [ SHF_ALLOC ]
58+ Address: 0x0000000000200210
59+ AddressAlign: 0x0000000000000002
60+ EntSize: 0x0000000000000002
61+ ## We use both index 0 and 1 for unversioned undefined symbols.
62+ ## Index 1 simulates older LLD and GNU ld versions between 2.35 and 2.45.
63+ Entries: [ 0 , 0 , 1 ]
64+ - Name: .gnu.version_r
65+ Type: SHT_GNU_verneed
66+ Flags: [ SHF_ALLOC ]
67+ Address: 0x0000000000200250
68+ AddressAlign: 0x0000000000000004
69+ Dependencies:
70+ - Version: 1
71+ File: dso.so.0
72+ Entries:
73+ - Name: v1
74+ Hash: 1937
75+ Flags: 0
76+ Other: 3
77+ DynamicSymbols:
78+ - Name: _start
79+ Binding: STB_GLOBAL
80+ - Name: foo
81+ Binding: STB_GLOBAL
You can’t perform that action at this time.
0 commit comments