[llvm-readobj] - Always print "Predecessors" for version definition sections.
authorGeorgii Rymar <grimar@accesssoftek.com>
Tue, 26 Nov 2019 14:47:34 +0000 (17:47 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Wed, 27 Nov 2019 09:29:55 +0000 (12:29 +0300)
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

lld/test/ELF/verdef-defaultver.s
lld/test/ELF/verdef-dependency.s
lld/test/ELF/verdef.s
llvm/test/tools/llvm-readobj/elf-versioninfo.test
llvm/test/tools/yaml2obj/ELF/verdef-section.yaml
llvm/tools/llvm-readobj/ELFDumper.cpp

index 3c10f2d..7d2a0d2 100644 (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
 # DSO-NEXT:      Index: 3
 # DSO-NEXT:      Hash: 1426
 # DSO-NEXT:      Name: V2
+# DSO-NEXT:      Predecessors: []
 # DSO-NEXT:    }
 # DSO-NEXT:  ]
 
index 479f332..d716436 100644 (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: ]
index d2aa924..dd1f1d4 100644 (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 [
index c732f7d..591dfe2 100644 (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: ]
 
index 960acbd..23bbc8e 100644 (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
index 5127939..b7bd35e 100644 (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(); });