[llvm-readobj] - Remove excessive fields when dumping "Version symbols".

This removes a few fields that are not useful:
"Section Name", "Address", "Offset" and "Link"
(they duplicated the information available under
the "Sections [" tag).

Differential revision: https://reviews.llvm.org/D68704

llvm-svn: 374541
This commit is contained in:
George Rimar 2019-10-11 12:27:11 +00:00
parent 885c559369
commit e6e26339ff
4 changed files with 42 additions and 61 deletions

View File

@ -11,7 +11,7 @@
# LLVM-ALL: Relocations [
# LLVM-ALL: Symbols [
# LLVM-ALL: ProgramHeaders [
# LLVM-ALL: Version symbols {
# LLVM-ALL: Version symbols [
# LLVM-ALL: SHT_GNU_verdef {
# LLVM-ALL: SHT_GNU_verneed {
# LLVM-ALL: Addrsig [

View File

@ -77,38 +77,32 @@ DynamicSymbols:
Binding: STB_GLOBAL
...
# LLVM: Version symbols {
# LLVM-NEXT: Section Name: .gnu.version
# LLVM-NEXT: Address: 0x0
# LLVM-NEXT: Offset: 0x40
# LLVM-NEXT: Link: 7
# LLVM-NEXT: Symbols [
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 0
# LLVM-NEXT: Name:
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 2
# LLVM-NEXT: Name: sym1@@VERSION1
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 3
# LLVM-NEXT: Name: sym2@@VERSION2
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 4
# LLVM-NEXT: Name: sym3@v1
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 5
# LLVM-NEXT: Name: sym4@v2
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 6
# LLVM-NEXT: Name: sym5@v3
# LLVM-NEXT: }
# LLVM-NEXT: ]
# LLVM-NEXT: }
# LLVM: Version symbols [
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 0
# LLVM-NEXT: Name:
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 2
# LLVM-NEXT: Name: sym1@@VERSION1
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 3
# LLVM-NEXT: Name: sym2@@VERSION2
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 4
# LLVM-NEXT: Name: sym3@v1
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 5
# LLVM-NEXT: Name: sym4@v2
# LLVM-NEXT: }
# LLVM-NEXT: Symbol {
# LLVM-NEXT: Version: 6
# LLVM-NEXT: Name: sym5@v3
# LLVM-NEXT: }
# LLVM-NEXT: ]
# LLVM-NEXT: SHT_GNU_verdef {
# LLVM-NEXT: Definition {
# LLVM-NEXT: Version: 1

View File

@ -4,26 +4,20 @@
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj -V %t1 | FileCheck %s
# CHECK: Version symbols {
# CHECK-NEXT: Section Name: .gnu.version
# CHECK-NEXT: Address: 0x200210
# CHECK-NEXT: Offset: 0x40
# CHECK-NEXT: Link: 6
# CHECK-NEXT: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
# CHECK-NEXT: Name:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 3
# CHECK-NEXT: Name: f1@v1
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 4
# CHECK-NEXT: Name: f2@v2
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: }
# CHECK: Version symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
# CHECK-NEXT: Name:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 3
# CHECK-NEXT: Name: f1@v1
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 4
# CHECK-NEXT: Name: f2@v2
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: SHT_GNU_verdef {
# CHECK-NEXT: }
# CHECK-NEXT: SHT_GNU_verneed {

View File

@ -5607,23 +5607,16 @@ void LLVMStyle<ELFT>::printProgramHeaders(const ELFO *Obj) {
template <class ELFT>
void LLVMStyle<ELFT>::printVersionSymbolSection(const ELFFile<ELFT> *Obj,
const Elf_Shdr *Sec) {
DictScope SS(W, "Version symbols");
ListScope SS(W, "Version symbols");
if (!Sec)
return;
StringRef SecName = unwrapOrError(this->FileName, Obj->getSectionName(Sec));
W.printNumber("Section Name", SecName, Sec->sh_name);
W.printHex("Address", Sec->sh_addr);
W.printHex("Offset", Sec->sh_offset);
W.printNumber("Link", Sec->sh_link);
const uint8_t *VersymBuf =
reinterpret_cast<const uint8_t *>(Obj->base() + Sec->sh_offset);
const ELFDumper<ELFT> *Dumper = this->dumper();
StringRef StrTable = Dumper->getDynamicStringTable();
// Same number of entries in the dynamic symbol table (DT_SYMTAB).
ListScope Syms(W, "Symbols");
for (const Elf_Sym &Sym : Dumper->dynamic_symbols()) {
DictScope S(W, "Symbol");
const Elf_Versym *Versym = reinterpret_cast<const Elf_Versym *>(VersymBuf);