Skip to content

Commit

Permalink
[llvm-readobj] - Always print "Predecessors" for version definition s…
Browse files Browse the repository at this point in the history
…ections.

This is a follow-up discussed in D70495 thread.

The current logic is unusual for llvm-readobj. It doesn't print predecessors
list when it is empty. This is not good for machine parsers.
D70495 had to add this condition during refactoring to reduce amount of changes,
in tests, because the original code also had a similar logic.

Now seems it is time to get rid of it. This patch does it.

Differential revision: https://reviews.llvm.org/D70717
  • Loading branch information
Georgii Rymar committed Nov 27, 2019
1 parent 92d5ea5 commit 3b35603
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lld/test/ELF/verdef-defaultver.s
Expand Up @@ -84,6 +84,7 @@
# DSO-NEXT: Index: 1
# DSO-NEXT: Hash: 127830196
# DSO-NEXT: Name: shared
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: Definition {
# DSO-NEXT: Version: 1
Expand All @@ -92,6 +93,7 @@
# DSO-NEXT: Index: 2
# DSO-NEXT: Hash: 1425
# DSO-NEXT: Name: V1
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: Definition {
# DSO-NEXT: Version: 1
Expand All @@ -100,6 +102,7 @@
# DSO-NEXT: Index: 3
# DSO-NEXT: Hash: 1426
# DSO-NEXT: Name: V2
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: ]

Expand Down
4 changes: 4 additions & 0 deletions lld/test/ELF/verdef-dependency.s
Expand Up @@ -15,6 +15,7 @@
# DSO-NEXT: Index: 1
# DSO-NEXT: Hash: 127830196
# DSO-NEXT: Name: shared
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: Definition {
# DSO-NEXT: Version: 1
Expand All @@ -23,6 +24,7 @@
# DSO-NEXT: Index: 2
# DSO-NEXT: Hash: 98457184
# DSO-NEXT: Name: LIBSAMPLE_1.0
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: Definition {
# DSO-NEXT: Version: 1
Expand All @@ -31,6 +33,7 @@
# DSO-NEXT: Index: 3
# DSO-NEXT: Hash: 98456416
# DSO-NEXT: Name: LIBSAMPLE_2.0
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: Definition {
# DSO-NEXT: Version: 1
Expand All @@ -39,5 +42,6 @@
# DSO-NEXT: Index: 4
# DSO-NEXT: Hash: 98456672
# DSO-NEXT: Name: LIBSAMPLE_3.0
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: ]
4 changes: 4 additions & 0 deletions lld/test/ELF/verdef.s
Expand Up @@ -33,6 +33,7 @@
# DSO-NEXT: Index: 1
# DSO-NEXT: Hash: 127830196
# DSO-NEXT: Name: shared
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: Definition {
# DSO-NEXT: Version: 1
Expand All @@ -41,6 +42,7 @@
# DSO-NEXT: Index: 2
# DSO-NEXT: Hash: 98457184
# DSO-NEXT: Name: LIBSAMPLE_1.0
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: Definition {
# DSO-NEXT: Version: 1
Expand All @@ -49,6 +51,7 @@
# DSO-NEXT: Index: 3
# DSO-NEXT: Hash: 98456416
# DSO-NEXT: Name: LIBSAMPLE_2.0
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: Definition {
# DSO-NEXT: Version: 1
Expand All @@ -57,6 +60,7 @@
# DSO-NEXT: Index: 4
# DSO-NEXT: Hash: 98456672
# DSO-NEXT: Name: LIBSAMPLE_3.0
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: ]
# DSO-NEXT: VersionRequirements [
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/tools/llvm-readobj/elf-versioninfo.test
Expand Up @@ -148,6 +148,7 @@ DynamicSymbols:
# LLVM-NEXT: Index: 0
# LLVM-NEXT: Hash: 0
# LLVM-NEXT: Name: VERSION1
# LLVM-NEXT: Predecessors: []
# LLVM-NEXT: }
# LLVM-NEXT: Definition {
# LLVM-NEXT: Version: 1
Expand All @@ -157,6 +158,7 @@ DynamicSymbols:
# LLVM-NEXT: Index: 0
# LLVM-NEXT: Hash: 0
# LLVM-NEXT: Name: VERSION1
# LLVM-NEXT: Predecessors: []
# LLVM-NEXT: }
# LLVM-NEXT: Definition {
# LLVM-NEXT: Version: 1
Expand All @@ -166,6 +168,7 @@ DynamicSymbols:
# LLVM-NEXT: Index: 0
# LLVM-NEXT: Hash: 0
# LLVM-NEXT: Name: VERSION1
# LLVM-NEXT: Predecessors: []
# LLVM-NEXT: }
# LLVM-NEXT: Definition {
# LLVM-NEXT: Version: 1
Expand All @@ -175,6 +178,7 @@ DynamicSymbols:
# LLVM-NEXT: Index: 0
# LLVM-NEXT: Hash: 0
# LLVM-NEXT: Name: VERSION1
# LLVM-NEXT: Predecessors: []
# LLVM-NEXT: }
# LLVM-NEXT: Definition {
# LLVM-NEXT: Version: 1
Expand All @@ -186,6 +190,7 @@ DynamicSymbols:
# LLVM-NEXT: Index: 2
# LLVM-NEXT: Hash: 175630257
# LLVM-NEXT: Name: VERSION1
# LLVM-NEXT: Predecessors: []
# LLVM-NEXT: }
# LLVM-NEXT: Definition {
# LLVM-NEXT: Version: 1
Expand Down Expand Up @@ -436,6 +441,7 @@ DynamicSymbols:
# PAST-STRTAB-END-LLVM-NEXT: Index: 0
# PAST-STRTAB-END-LLVM-NEXT: Hash: 0
# PAST-STRTAB-END-LLVM-NEXT: Name: <invalid vda_name: 5>
# PAST-STRTAB-END-LLVM-NEXT: Predecessors: []
# PAST-STRTAB-END-LLVM-NEXT: }
# PAST-STRTAB-END-LLVM-NEXT: ]

Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/yaml2obj/ELF/verdef-section.yaml
Expand Up @@ -12,6 +12,7 @@
# CHECK-NEXT: Index: 1
# CHECK-NEXT: Hash: 170240160
# CHECK-NEXT: Name: dso.so.0
# CHECK-NEXT: Predecessors: []
# CHECK-NEXT: }
# CHECK-NEXT: Definition {
# CHECK-NEXT: Version: 1
Expand All @@ -21,6 +22,7 @@
# CHECK-NEXT: Index: 2
# CHECK-NEXT: Hash: 108387921
# CHECK-NEXT: Name: VERSION_1
# CHECK-NEXT: Predecessors: []
# CHECK-NEXT: }
# CHECK-NEXT: Definition {
# CHECK-NEXT: Version: 1
Expand Down
3 changes: 0 additions & 3 deletions llvm/tools/llvm-readobj/ELFDumper.cpp
Expand Up @@ -5826,9 +5826,6 @@ void LLVMStyle<ELFT>::printVersionDefinitionSection(const ELFFile<ELFT> *Obj,
W.printNumber("Index", D.Ndx);
W.printNumber("Hash", D.Hash);
W.printString("Name", D.Name.c_str());

if (D.AuxV.empty())
continue;
W.printList(
"Predecessors", D.AuxV,
[](raw_ostream &OS, const VerdAux &Aux) { OS << Aux.Name.c_str(); });
Expand Down

0 comments on commit 3b35603

Please sign in to comment.