Skip to content

Commit e98d5c3

Browse files
author
Georgii Rymar
committed
[libObject,llvm-readelf/obj] - Don't use @@ when printing versions of undefined symbols.
A default version (@@) is only available for defined symbols. Currently we use "@@" for undefined symbols too. This patch fixes the issue and improves our test case. Differential revision: https://reviews.llvm.org/D95219
1 parent bfc60ac commit e98d5c3

File tree

6 files changed

+218
-80
lines changed

6 files changed

+218
-80
lines changed

lld/test/ELF/partition-synthetic-sections.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
// PART0-NEXT: {{0*}}[[INIT_ARRAY_ADDR]] {{.*}} R_X86_64_64 {{.*}} p0@@x1 + 0
107107
// PART1-NEXT: 000000000000[[DATA_SEGMENT]]148 {{.*}} R_X86_64_RELATIVE 3178
108108
// PART1-NEXT: 000000000000[[DATA_SEGMENT]]130 {{.*}} R_X86_64_64 {{.*}} f2@v2 + 0
109-
// PART1-NEXT: 000000000000[[DATA_SEGMENT]]138 {{.*}} R_X86_64_64 {{.*}} p0@@x1 + 0
110-
// PART1-NEXT: 000000000000[[DATA_SEGMENT]]140 {{.*}} R_X86_64_64 {{.*}} p0@@x1 + 0
109+
// PART1-NEXT: 000000000000[[DATA_SEGMENT]]138 {{.*}} R_X86_64_64 {{.*}} p0@x1 + 0
110+
// PART1-NEXT: 000000000000[[DATA_SEGMENT]]140 {{.*}} R_X86_64_64 {{.*}} p0@x1 + 0
111111

112112
// PART0: Relocation section '.rela.plt'
113113
// PART0-NEXT: Offset
@@ -133,7 +133,7 @@
133133
// PART0: 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f2@v2
134134
// PART0: 3: {{0*}}[[TEXT_ADDR]] 0 NOTYPE GLOBAL DEFAULT {{.*}} p0@@x1
135135
// PART1: 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f2@v2
136-
// PART1: 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND p0@@x1
136+
// PART1: 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND p0@x1
137137
// PART1: 3: {{0*}}[[TEXT_ADDR]] 0 NOTYPE GLOBAL DEFAULT {{.*}} p1@@x2
138138
// PART1: 4: {{0*}}[[TEXT_ADDR]] 0 NOTYPE GLOBAL DEFAULT {{.*}} p1alias@@x2
139139
// CHECK-EMPTY:

llvm/include/llvm/Object/ELF.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ class ELFFile {
200200
Expected<std::vector<VerNeed>> getVersionDependencies(
201201
const Elf_Shdr &Sec,
202202
WarningHandler WarnHandler = &defaultWarningHandler) const;
203-
Expected<StringRef> getSymbolVersionByIndex(
204-
uint32_t SymbolVersionIndex, bool &IsDefault,
205-
SmallVector<Optional<VersionEntry>, 0> &VersionMap) const;
203+
Expected<StringRef>
204+
getSymbolVersionByIndex(uint32_t SymbolVersionIndex, bool &IsDefault,
205+
SmallVector<Optional<VersionEntry>, 0> &VersionMap,
206+
Optional<bool> IsSymHidden) const;
206207

207208
Expected<StringRef>
208209
getStringTable(const Elf_Shdr &Section,
@@ -741,7 +742,8 @@ Expected<const T *> ELFFile<ELFT>::getEntry(const Elf_Shdr &Section,
741742
template <typename ELFT>
742743
Expected<StringRef> ELFFile<ELFT>::getSymbolVersionByIndex(
743744
uint32_t SymbolVersionIndex, bool &IsDefault,
744-
SmallVector<Optional<VersionEntry>, 0> &VersionMap) const {
745+
SmallVector<Optional<VersionEntry>, 0> &VersionMap,
746+
Optional<bool> IsSymHidden) const {
745747
size_t VersionIndex = SymbolVersionIndex & llvm::ELF::VERSYM_VERSION;
746748

747749
// Special markers for unversioned symbols.
@@ -757,10 +759,11 @@ Expected<StringRef> ELFFile<ELFT>::getSymbolVersionByIndex(
757759
Twine(VersionIndex) + " which is missing");
758760

759761
const VersionEntry &Entry = *VersionMap[VersionIndex];
760-
if (Entry.IsVerDef)
761-
IsDefault = !(SymbolVersionIndex & llvm::ELF::VERSYM_HIDDEN);
762-
else
762+
// A default version (@@) is only available for defined symbols.
763+
if (!Entry.IsVerDef || IsSymHidden.getValueOr(false))
763764
IsDefault = false;
765+
else
766+
IsDefault = !(SymbolVersionIndex & llvm::ELF::VERSYM_HIDDEN);
764767
return Entry.Name.c_str();
765768
}
766769

llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test

Lines changed: 197 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -245,47 +245,97 @@ ProgramHeaders:
245245

246246
## Case 7: Check how we dump versioned symbols. Use both -V and --dyn-symbols
247247
## to check that printed version is consistent.
248+
## A default version is one that is contained in the version table (SHT_GNU_versym)
249+
## and only available for defined symbols. We use the "@@" prefix to print it.
250+
251+
## Check how we dump undefined symbols.
252+
248253
# RUN: yaml2obj %s --docnum=6 -o %t6
249-
# RUN: llvm-readobj -V --dyn-symbols %t6 | FileCheck %s --check-prefix=VERSIONED-LLVM
250-
# RUN: llvm-readelf -V --dyn-symbols %t6 | FileCheck %s --check-prefix=VERSIONED-GNU
251-
252-
# VERSIONED-LLVM: Symbol {
253-
# VERSIONED-LLVM: Name: foo (16)
254-
# VERSIONED-LLVM-NEXT: Value: 0x0
255-
# VERSIONED-LLVM-NEXT: Size: 0
256-
# VERSIONED-LLVM-NEXT: Binding: Local (0x0)
257-
# VERSIONED-LLVM-NEXT: Type: None (0x0)
258-
# VERSIONED-LLVM-NEXT: Other: 0
259-
# VERSIONED-LLVM-NEXT: Section: Undefined (0x0)
260-
# VERSIONED-LLVM-NEXT: }
261-
# VERSIONED-LLVM-NEXT: Symbol {
262-
# VERSIONED-LLVM-NEXT: Name: bar@@Default (12)
263-
# VERSIONED-LLVM-NEXT: Value: 0x0
264-
# VERSIONED-LLVM-NEXT: Size: 0
265-
# VERSIONED-LLVM-NEXT: Binding: Local (0x0)
266-
# VERSIONED-LLVM-NEXT: Type: None (0x0)
267-
# VERSIONED-LLVM-NEXT: Other: 0
268-
# VERSIONED-LLVM-NEXT: Section: Undefined (0x0)
269-
# VERSIONED-LLVM-NEXT: }
270-
# VERSIONED-LLVM-NEXT: Symbol {
271-
# VERSIONED-LLVM-NEXT: Name: zed@NonDefault (20)
272-
# VERSIONED-LLVM-NEXT: Value: 0x0
273-
# VERSIONED-LLVM-NEXT: Size: 0
274-
# VERSIONED-LLVM-NEXT: Binding: Local (0x0)
275-
# VERSIONED-LLVM-NEXT: Type: None (0x0)
276-
# VERSIONED-LLVM-NEXT: Other: 0
277-
# VERSIONED-LLVM-NEXT: Section: Undefined (0x0)
278-
# VERSIONED-LLVM-NEXT: }
279-
# VERSIONED-LLVM: VersionSymbols [
280-
# VERSIONED-LLVM: Name: foo
281-
# VERSIONED-LLVM: Name: bar@@Default
282-
# VERSIONED-LLVM: Name: zed@NonDefault
283-
284-
# VERSIONED-GNU: Num: Value Size Type Bind Vis Ndx Name
285-
# VERSIONED-GNU: 1: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND foo
286-
# VERSIONED-GNU-NEXT: 2: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND bar@@Default
287-
# VERSIONED-GNU-NEXT: 3: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND zed@NonDefault
288-
# VERSIONED-GNU: 000: 0 (*local*) 1 (*global*) 2 (Default) 3h(NonDefault)
254+
# RUN: llvm-readobj -V --dyn-symbols %t6 | FileCheck %s --check-prefix=VERSIONED-UND-LLVM
255+
# RUN: llvm-readelf -V --dyn-symbols %t6 | FileCheck %s --check-prefix=VERSIONED-UND-GNU
256+
257+
# VERSIONED-UND-LLVM: DynamicSymbols [
258+
# VERSIONED-UND-LLVM-NEXT: Symbol {
259+
# VERSIONED-UND-LLVM-NEXT: Name: (0)
260+
# VERSIONED-UND-LLVM-NEXT: Value: 0x0
261+
# VERSIONED-UND-LLVM-NEXT: Size: 0
262+
# VERSIONED-UND-LLVM-NEXT: Binding: Local (0x0)
263+
# VERSIONED-UND-LLVM-NEXT: Type: None (0x0)
264+
# VERSIONED-UND-LLVM-NEXT: Other: 0
265+
# VERSIONED-UND-LLVM-NEXT: Section: Undefined (0x0)
266+
# VERSIONED-UND-LLVM-NEXT: }
267+
# VERSIONED-UND-LLVM-NEXT: Symbol {
268+
# VERSIONED-UND-LLVM-NEXT: Name: localversym (28)
269+
# VERSIONED-UND-LLVM-NEXT: Value: 0x0
270+
# VERSIONED-UND-LLVM-NEXT: Size: 0
271+
# VERSIONED-UND-LLVM-NEXT: Binding: Local (0x0)
272+
# VERSIONED-UND-LLVM-NEXT: Type: None (0x0)
273+
# VERSIONED-UND-LLVM-NEXT: Other: 0
274+
# VERSIONED-UND-LLVM-NEXT: Section: Undefined (0x0)
275+
# VERSIONED-UND-LLVM-NEXT: }
276+
# VERSIONED-UND-LLVM-NEXT: Symbol {
277+
# VERSIONED-UND-LLVM-NEXT: Name: globalversym (40)
278+
# VERSIONED-UND-LLVM-NEXT: Value: 0x0
279+
# VERSIONED-UND-LLVM-NEXT: Size: 0
280+
# VERSIONED-UND-LLVM-NEXT: Binding: Local (0x0)
281+
# VERSIONED-UND-LLVM-NEXT: Type: None (0x0)
282+
# VERSIONED-UND-LLVM-NEXT: Other: 0
283+
# VERSIONED-UND-LLVM-NEXT: Section: Undefined (0x0)
284+
# VERSIONED-UND-LLVM-NEXT: }
285+
# VERSIONED-UND-LLVM-NEXT: Symbol {
286+
# VERSIONED-UND-LLVM-NEXT: Name: aaa@v2 (65)
287+
# VERSIONED-UND-LLVM-NEXT: Value: 0x0
288+
# VERSIONED-UND-LLVM-NEXT: Size: 0
289+
# VERSIONED-UND-LLVM-NEXT: Binding: Local (0x0)
290+
# VERSIONED-UND-LLVM-NEXT: Type: None (0x0)
291+
# VERSIONED-UND-LLVM-NEXT: Other: 0
292+
# VERSIONED-UND-LLVM-NEXT: Section: Undefined (0x0)
293+
# VERSIONED-UND-LLVM-NEXT: }
294+
# VERSIONED-UND-LLVM-NEXT: Symbol {
295+
# VERSIONED-UND-LLVM-NEXT: Name: bbb@v3hidden (61)
296+
# VERSIONED-UND-LLVM-NEXT: Value: 0x0
297+
# VERSIONED-UND-LLVM-NEXT: Size: 0
298+
# VERSIONED-UND-LLVM-NEXT: Binding: Local (0x0)
299+
# VERSIONED-UND-LLVM-NEXT: Type: None (0x0)
300+
# VERSIONED-UND-LLVM-NEXT: Other: 0
301+
# VERSIONED-UND-LLVM-NEXT: Section: Undefined (0x0)
302+
# VERSIONED-UND-LLVM-NEXT: }
303+
# VERSIONED-UND-LLVM-NEXT: Symbol {
304+
# VERSIONED-UND-LLVM-NEXT: Name: ccc@v4 (57)
305+
# VERSIONED-UND-LLVM-NEXT: Value: 0x0
306+
# VERSIONED-UND-LLVM-NEXT: Size: 0
307+
# VERSIONED-UND-LLVM-NEXT: Binding: Local (0x0)
308+
# VERSIONED-UND-LLVM-NEXT: Type: None (0x0)
309+
# VERSIONED-UND-LLVM-NEXT: Other: 0
310+
# VERSIONED-UND-LLVM-NEXT: Section: Undefined (0x0)
311+
# VERSIONED-UND-LLVM-NEXT: }
312+
# VERSIONED-UND-LLVM-NEXT: Symbol {
313+
# VERSIONED-UND-LLVM-NEXT: Name: ddd@v5hidden (53)
314+
# VERSIONED-UND-LLVM-NEXT: Value: 0x0
315+
# VERSIONED-UND-LLVM-NEXT: Size: 0
316+
# VERSIONED-UND-LLVM-NEXT: Binding: Local (0x0)
317+
# VERSIONED-UND-LLVM-NEXT: Type: None (0x0)
318+
# VERSIONED-UND-LLVM-NEXT: Other: 0
319+
# VERSIONED-UND-LLVM-NEXT: Section: Undefined (0x0)
320+
# VERSIONED-UND-LLVM-NEXT: }
321+
# VERSIONED-UND-LLVM-NEXT: ]
322+
# VERSIONED-UND-LLVM: VersionSymbols [
323+
# VERSIONED-UND-LLVM: Name: localversym
324+
# VERSIONED-UND-LLVM: Name: globalversym
325+
# VERSIONED-UND-LLVM: Name: aaa@v2
326+
# VERSIONED-UND-LLVM: Name: bbb@v3hidden
327+
# VERSIONED-UND-LLVM: Name: ccc@v4
328+
# VERSIONED-UND-LLVM: Name: ddd@v5hidden
329+
330+
# VERSIONED-UND-GNU: Num: Value Size Type Bind Vis Ndx Name
331+
# VERSIONED-UND-GNU: 1: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND localversym
332+
# VERSIONED-UND-GNU-NEXT: 2: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND globalversym
333+
# VERSIONED-UND-GNU-NEXT: 3: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND aaa@v2
334+
# VERSIONED-UND-GNU-NEXT: 4: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND bbb@v3hidden
335+
# VERSIONED-UND-GNU-NEXT: 5: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND ccc@v4
336+
# VERSIONED-UND-GNU-NEXT: 6: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND ddd@v5hidden
337+
# VERSIONED-UND-GNU: 000: 0 (*local*) 0 (*local*) 1 (*global*) 2 (v2)
338+
# VERSIONED-UND-GNU: 004: 3h(v3hidden) 4 (v4) 5h(v5hidden)
289339

290340
--- !ELF
291341
FileHeader:
@@ -300,71 +350,154 @@ Sections:
300350
AddressAlign: 0x2
301351
EntSize: 0x2
302352
## 0x8000 is a special VERSYM_HIDDEN bit.
303-
Entries: [ 0, 1, 2, 0x8003 ]
353+
## Here we have: VER_NDX_LOCAL (0), VER_NDX_GLOBAL (1), two versions
354+
## from the SHT_GNU_verdef section (2, 0x8003) and two versions
355+
## from the SHT_GNU_verneed section (4, 0x8005).
356+
Entries: [ 0, 0, 1, 2, 0x8003, 4, 0x8005 ]
304357
- Name: .gnu.version_d
305358
Type: SHT_GNU_verdef
306359
Flags: [ SHF_ALLOC ]
307360
AddressAlign: 0x4
308361
Entries:
309362
- VersionNdx: 2
310363
Names:
311-
- Default
364+
- v2
312365
- VersionNdx: 3
313366
Names:
314-
- NonDefault
367+
- v3hidden
368+
- Name: .gnu.version_r
369+
Type: SHT_GNU_verneed
370+
Flags: [ SHF_ALLOC ]
371+
Dependencies:
372+
- Version: 1
373+
File: file1.so
374+
Entries:
375+
- Name: v4
376+
Other: 4
377+
Hash: 0
378+
Flags: 0
379+
- Version: 1
380+
File: file2.0
381+
Entries:
382+
- Name: v5hidden
383+
Other: 5
384+
Hash: 0
385+
Flags: 0
315386
DynamicSymbols:
316-
- Name: foo
317-
- Name: [[NAME=bar]]
387+
- Name: localversym
388+
Index: [[INDEX=<none>]]
389+
- Name: globalversym
390+
Index: [[INDEX=<none>]]
391+
- Name: aaa
392+
Index: [[INDEX=<none>]]
393+
- Name: [[NAME=bbb]]
394+
Type: [[TYPE=STT_NOTYPE]]
395+
Index: [[INDEX_BBB=<none>]]
396+
- Name: [[NAME=ccc]]
318397
Type: [[TYPE=STT_NOTYPE]]
319398
Index: [[INDEX=<none>]]
320-
- Name: [[NAME=zed]]
321-
Type: [[TYPE=STT_NOTYPE]]
399+
- Name: ddd
400+
Index: [[INDEX=<none>]]
401+
402+
## In this case all dynamic symbols are defined. Check that we print the
403+
## "@@" prefix for default versions as expected.
404+
405+
# RUN: yaml2obj %s --docnum=6 -DINDEX=1 -DINDEX_BBB=1 -o %t6.def
406+
# RUN: llvm-readobj -V --dyn-symbols %t6.def | FileCheck %s --check-prefix=VERSIONED-DEF-LLVM
407+
# RUN: llvm-readelf -V --dyn-symbols %t6.def | FileCheck %s --check-prefix=VERSIONED-DEF-GNU
408+
409+
# VERSIONED-DEF-LLVM: DynamicSymbols [
410+
# VERSIONED-DEF-LLVM: Symbol {
411+
# VERSIONED-DEF-LLVM: Name: localversym (28)
412+
# VERSIONED-DEF-LLVM: Section: .gnu.version (0x1)
413+
# VERSIONED-DEF-LLVM-NEXT: }
414+
# VERSIONED-DEF-LLVM-NEXT: Symbol {
415+
# VERSIONED-DEF-LLVM-NEXT: Name: globalversym (40)
416+
# VERSIONED-DEF-LLVM: Section: .gnu.version (0x1)
417+
# VERSIONED-DEF-LLVM-NEXT: }
418+
# VERSIONED-DEF-LLVM-NEXT: Symbol {
419+
# VERSIONED-DEF-LLVM-NEXT: Name: aaa@@v2 (65)
420+
# VERSIONED-DEF-LLVM: Section: .gnu.version (0x1)
421+
# VERSIONED-DEF-LLVM-NEXT: }
422+
# VERSIONED-DEF-LLVM-NEXT: Symbol {
423+
# VERSIONED-DEF-LLVM-NEXT: Name: bbb@v3hidden (61)
424+
# VERSIONED-DEF-LLVM: Section: .gnu.version (0x1)
425+
# VERSIONED-DEF-LLVM-NEXT: }
426+
# VERSIONED-DEF-LLVM-NEXT: Symbol {
427+
# VERSIONED-DEF-LLVM-NEXT: Name: ccc@v4 (57)
428+
# VERSIONED-DEF-LLVM: Section: .gnu.version (0x1)
429+
# VERSIONED-DEF-LLVM-NEXT: }
430+
# VERSIONED-DEF-LLVM-NEXT: Symbol {
431+
# VERSIONED-DEF-LLVM-NEXT: Name: ddd@v5hidden (53)
432+
# VERSIONED-DEF-LLVM: Section: .gnu.version (0x1)
433+
# VERSIONED-DEF-LLVM-NEXT: }
434+
# VERSIONED-DEF-LLVM: VersionSymbols [
435+
# VERSIONED-DEF-LLVM: Name: localversym
436+
# VERSIONED-DEF-LLVM: Name: globalversym
437+
# VERSIONED-DEF-LLVM: Name: aaa@@v2
438+
# VERSIONED-DEF-LLVM: Name: bbb@v3hidden
439+
# VERSIONED-DEF-LLVM: Name: ccc@v4
440+
# VERSIONED-DEF-LLVM: Name: ddd@v5hidden
441+
442+
# VERSIONED-DEF-GNU: Num: {{.*}} Vis Ndx Name
443+
# VERSIONED-DEF-GNU: 1: {{.*}} DEFAULT 1 localversym
444+
# VERSIONED-DEF-GNU-NEXT: 2: {{.*}} DEFAULT 1 globalversym
445+
# VERSIONED-DEF-GNU-NEXT: 3: {{.*}} DEFAULT 1 aaa@@v2
446+
# VERSIONED-DEF-GNU-NEXT: 4: {{.*}} DEFAULT 1 bbb@v3hidden
447+
# VERSIONED-DEF-GNU-NEXT: 5: {{.*}} DEFAULT 1 ccc@v4
448+
# VERSIONED-DEF-GNU-NEXT: 6: {{.*}} DEFAULT 1 ddd@v5hidden
322449

323450
## Check the behavior for unnamed versioned section symbols.
324-
# RUN: yaml2obj %s -DTYPE=STT_SECTION -DNAME="''" -DINDEX=SHN_ABS --docnum=6 -o %t6.sec.sym
451+
# RUN: yaml2obj %s -DTYPE=STT_SECTION -DNAME="''" -DINDEX_BBB=SHN_ABS --docnum=6 -o %t6.sec.sym
325452
# RUN: llvm-readobj -V --dyn-symbols %t6.sec.sym 2>&1 | \
326453
# RUN: FileCheck %s -DFILE=%t6.sec.sym --check-prefix=VERSIONED-SEC-SYM-LLVM
327454
# RUN: llvm-readelf -V --dyn-symbols %t6.sec.sym 2>&1 | \
328455
# RUN: FileCheck %s -DFILE=%t6.sec.sym --check-prefix=VERSIONED-SEC-SYM-GNU
329456

330457
# VERSIONED-SEC-SYM-LLVM: DynamicSymbols [
331-
# VERSIONED-SEC-SYM-LLVM: Name: foo (12)
458+
# VERSIONED-SEC-SYM-LLVM: Name: localversym (28)
459+
# VERSIONED-SEC-SYM-LLVM: Name: globalversym (40)
460+
# VERSIONED-SEC-SYM-LLVM: Name: aaa@v2 (57)
332461
# VERSIONED-SEC-SYM-LLVM: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
333462
# VERSIONED-SEC-SYM-LLVM: Name: <?> (0)
334463
# VERSIONED-SEC-SYM-LLVM: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF)
335464
# VERSIONED-SEC-SYM-LLVM: Name: <?> (0)
465+
# VERSIONED-SEC-SYM-LLVM: Name: ddd@v5hidden (53)
336466
# VERSIONED-SEC-SYM-LLVM: VersionSymbols [
337-
# VERSIONED-SEC-SYM-LLVM: Name: foo
467+
# VERSIONED-SEC-SYM-LLVM: Name: localversym
468+
# VERSIONED-SEC-SYM-LLVM: Name: globalversym
469+
# VERSIONED-SEC-SYM-LLVM: Name: aaa@v2
338470
# VERSIONED-SEC-SYM-LLVM: Name: <?>
339471
# VERSIONED-SEC-SYM-LLVM: Name: <?>
472+
# VERSIONED-SEC-SYM-LLVM: Name: ddd@v5hidden
340473

341-
# VERSIONED-SEC-SYM-GNU: Symbol table '.dynsym' contains 4 entries:
474+
# VERSIONED-SEC-SYM-GNU: Symbol table '.dynsym' contains 7 entries:
342475
# VERSIONED-SEC-SYM-GNU: Num: {{.*}} Ndx Name
343-
# VERSIONED-SEC-SYM-GNU: 1: {{.*}} UND foo
344-
# VERSIONED-SEC-SYM-GNU: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
345-
# VERSIONED-SEC-SYM-GNU-NEXT: 2: {{.*}} ABS <?>
476+
# VERSIONED-SEC-SYM-GNU: 1: {{.*}} UND localversym
477+
# VERSIONED-SEC-SYM-GNU-NEXT: 2: {{.*}} UND globalversym
478+
# VERSIONED-SEC-SYM-GNU-NEXT: 3: {{.*}} UND aaa@v2
479+
# VERSIONED-SEC-SYM-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
480+
# VERSIONED-SEC-SYM-GNU-NEXT: 4: {{.*}} ABS <?>
346481
# VERSIONED-SEC-SYM-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF)
347-
# VERSIONED-SEC-SYM-GNU-NEXT: 3: {{.*}} UND <?>
482+
# VERSIONED-SEC-SYM-GNU-NEXT: 5: {{.*}} UND <?>
483+
# VERSIONED-SEC-SYM-GNU-NEXT: 6: {{.*}} UND ddd@v5hidden
348484

349485
## Check we print a proper warning when an unnamed versioned section symbol has st_shndx = SHN_XINDEX, but there
350486
## is no SHT_SYMTAB_SHNDX section in the object.
351-
# RUN: yaml2obj %s -DTYPE=STT_SECTION -DNAME="''" -DINDEX=SHN_XINDEX --docnum=6 -o %t6.sec.xindex.sym
487+
# RUN: yaml2obj %s -DTYPE=STT_SECTION -DNAME="''" -DINDEX_BBB=SHN_XINDEX --docnum=6 -o %t6.sec.xindex.sym
352488
# RUN: llvm-readobj -V --dyn-symbols %t6.sec.xindex.sym 2>&1 | \
353489
# RUN: FileCheck %s -DFILE=%t6.sec.xindex.sym --check-prefix=VERSIONED-SEC-SYM-XINDEX-LLVM
354490
# RUN: llvm-readelf -V --dyn-symbols %t6.sec.xindex.sym 2>&1 | \
355491
# RUN: FileCheck %s -DFILE=%t6.sec.xindex.sym --check-prefix=VERSIONED-SEC-SYM-XINDEX-GNU
356492

357-
# VERSIONED-SEC-SYM-XINDEX-LLVM: Name: (0)
358-
# VERSIONED-SEC-SYM-XINDEX-LLVM: Name: foo (12)
359-
# VERSIONED-SEC-SYM-XINDEX-LLVM: warning: '[[FILE]]': found an extended symbol index (2), but unable to locate the extended symbol index table
493+
# VERSIONED-SEC-SYM-XINDEX-LLVM: Name: aaa@v2 (57)
494+
# VERSIONED-SEC-SYM-XINDEX-LLVM: warning: '[[FILE]]': found an extended symbol index (4), but unable to locate the extended symbol index table
360495
# VERSIONED-SEC-SYM-XINDEX-LLVM-NEXT: Symbol {
361496
# VERSIONED-SEC-SYM-XINDEX-LLVM-NEXT: Name: <?> (0)
362-
# VERSIONED-SEC-SYM-XINDEX-LLVM: Name: <?> (0)
363497

364-
# VERSIONED-SEC-SYM-XINDEX-GNU: Symbol table '.dynsym' contains 4 entries:
365-
# VERSIONED-SEC-SYM-XINDEX-GNU: Num: {{.*}} Ndx Name
366-
# VERSIONED-SEC-SYM-XINDEX-GNU: warning: '[[FILE]]': found an extended symbol index (2), but unable to locate the extended symbol index table
367-
# VERSIONED-SEC-SYM-XINDEX-GNU-NEXT: 2: {{.*}} RSV[0xffff] <?>
498+
# VERSIONED-SEC-SYM-XINDEX-GNU: 3: {{.*}} UND aaa@v2
499+
# VERSIONED-SEC-SYM-XINDEX-GNU-NEXT: warning: '[[FILE]]': found an extended symbol index (4), but unable to locate the extended symbol index table
500+
# VERSIONED-SEC-SYM-XINDEX-GNU-NEXT: 4: {{.*}} RSV[0xffff] <?>
368501

369502
## Case 8: Check what we print when:
370503
## a) The dynamic symbol table does not exist.

llvm/test/tools/llvm-readobj/ELF/versioninfo.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ DynamicSymbols:
101101
# LLVM-NEXT: }
102102
# LLVM-NEXT: Symbol {
103103
# LLVM-NEXT: Version: 2
104-
# LLVM-NEXT: Name: sym1@@VERSION1
104+
# LLVM-NEXT: Name: sym1@VERSION1
105105
# LLVM-NEXT: }
106106
# LLVM-NEXT: Symbol {
107107
# LLVM-NEXT: Version: 3
108-
# LLVM-NEXT: Name: sym2@@VERSION2
108+
# LLVM-NEXT: Name: sym2@VERSION2
109109
# LLVM-NEXT: }
110110
# LLVM-NEXT: Symbol {
111111
# LLVM-NEXT: Version: 4

llvm/tools/llvm-nm/llvm-nm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ readSymbolVersionsELF(const ELFFile<ELFT> &Obj, StringRef FileName,
17271727

17281728
bool IsDefault;
17291729
Expected<StringRef> VerOrErr = Obj.getSymbolVersionByIndex(
1730-
(*VerEntryOrErr)->vs_index, IsDefault, *MapOrErr);
1730+
(*VerEntryOrErr)->vs_index, IsDefault, *MapOrErr, /*IsSymHidden=*/None);
17311731
if (!VerOrErr)
17321732
return createError("unable to get a version for entry " + Twine(I) +
17331733
" of " + describe(Obj, *SymVerSec) + ": " +

0 commit comments

Comments
 (0)