From 6e1c5c0b9d7a54e74d172765f365e081b19fca4c Mon Sep 17 00:00:00 2001 From: George Rimar Date: Fri, 11 Oct 2019 12:27:11 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374541 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/llvm-readobj/all.test | 2 +- test/tools/llvm-readobj/elf-versioninfo.test | 58 +++++++++++++--------------- test/tools/yaml2obj/versym-section.yaml | 34 +++++++--------- tools/llvm-readobj/ELFDumper.cpp | 9 +---- 4 files changed, 42 insertions(+), 61 deletions(-) diff --git a/test/tools/llvm-readobj/all.test b/test/tools/llvm-readobj/all.test index cc1aa29504a..6b1a6e9611f 100644 --- a/test/tools/llvm-readobj/all.test +++ b/test/tools/llvm-readobj/all.test @@ -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 [ diff --git a/test/tools/llvm-readobj/elf-versioninfo.test b/test/tools/llvm-readobj/elf-versioninfo.test index 606a96a9d4f..a586d2a7c1c 100644 --- a/test/tools/llvm-readobj/elf-versioninfo.test +++ b/test/tools/llvm-readobj/elf-versioninfo.test @@ -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 diff --git a/test/tools/yaml2obj/versym-section.yaml b/test/tools/yaml2obj/versym-section.yaml index bd4f61093e9..384b41708b3 100644 --- a/test/tools/yaml2obj/versym-section.yaml +++ b/test/tools/yaml2obj/versym-section.yaml @@ -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 { diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 135624539ae..a23e2156fdc 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -5607,23 +5607,16 @@ void LLVMStyle::printProgramHeaders(const ELFO *Obj) { template void LLVMStyle::printVersionSymbolSection(const ELFFile *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(Obj->base() + Sec->sh_offset); const ELFDumper *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(VersymBuf); -- 2.11.4.GIT