[llvm-readobj] - Always print "Predecessors" for version definition sections.

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
This commit is contained in:
Georgii Rymar 2019-11-26 17:47:34 +03:00
parent 92d5ea5d16
commit 3b35603a56
6 changed files with 19 additions and 3 deletions
lld/test/ELF
llvm
test/tools
tools/llvm-readobj

View File

@ -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
@ -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
@ -100,6 +102,7 @@
# DSO-NEXT: Index: 3
# DSO-NEXT: Hash: 1426
# DSO-NEXT: Name: V2
# DSO-NEXT: Predecessors: []
# DSO-NEXT: }
# DSO-NEXT: ]

View File

@ -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
@ -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
@ -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
@ -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: ]

View File

@ -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
@ -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
@ -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
@ -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 [

View File

@ -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
@ -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
@ -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
@ -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
@ -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
@ -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: ]

View File

@ -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
@ -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

View File

@ -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(); });