From: Xing GUO Date: Tue, 12 Mar 2019 14:30:13 +0000 (+0000) Subject: [llvm-readobj] Print symbol version when dumping relocations (PR31564) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eec3206a41e721673b1fd6f85ce731e1c15a4743;p=platform%2Fupstream%2Fllvm.git [llvm-readobj] Print symbol version when dumping relocations (PR31564) Summary: This helps resolve https://bugs.llvm.org/show_bug.cgi?id=31564 Reviewers: jhenderson, grimar Reviewed By: jhenderson Subscribers: rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59175 llvm-svn: 355922 --- diff --git a/llvm/test/tools/llvm-readobj/elf-reloc-symbol-with-versioning.test b/llvm/test/tools/llvm-readobj/elf-reloc-symbol-with-versioning.test new file mode 100644 index 0000000..c542b80 --- /dev/null +++ b/llvm/test/tools/llvm-readobj/elf-reloc-symbol-with-versioning.test @@ -0,0 +1,100 @@ +# RUN: yaml2obj %s > %t.o +# RUN: llvm-readobj -demangle -r %t.o | FileCheck %s --check-prefix LLVM +# RUN: llvm-readelf -demangle -r %t.o | FileCheck %s --check-prefix GNU + +# GNU: Relocation section '.rela.plt' at offset {{.*}} contains 5 entries: +# GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend +# GNU-NEXT: 0000000000013018 0000000100000007 R_X86_64_JUMP_SLOT 0000000000000000 f1@v3 + 0 +# GNU-NEXT: 0000000000013020 0000000200000007 R_X86_64_JUMP_SLOT 0000000000000000 f2@v2 + 0 +# GNU-NEXT: 0000000000013028 0000000300000007 R_X86_64_JUMP_SLOT 0000000000000000 g1@v1 + 0 +# GNU-NEXT: 0000000000013040 0000000400000007 R_X86_64_JUMP_SLOT 0000000000000000 f1()@v3 + 0 +# GNU-NEXT: 0000000000013058 0000000500000007 R_X86_64_JUMP_SLOT 0000000000000000 f3 + 0 + +# LLVM: Relocations [ +# LLVM-NEXT: Section (3) .rela.plt { +# LLVM-NEXT: 0x13018 R_X86_64_JUMP_SLOT f1@v3 0x0 +# LLVM-NEXT: 0x13020 R_X86_64_JUMP_SLOT f2@v2 0x0 +# LLVM-NEXT: 0x13028 R_X86_64_JUMP_SLOT g1@v1 0x0 +# LLVM-NEXT: 0x13040 R_X86_64_JUMP_SLOT f1()@v3 0x0 +# LLVM-NEXT: 0x13058 R_X86_64_JUMP_SLOT f3 0x0 +# LLVM-NEXT: } +# LLVM-NEXT: ] + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000000000 +Sections: + - Name: .gnu.version + Type: SHT_GNU_versym + Flags: [ SHF_ALLOC ] + Link: .dynsym + AddressAlign: 0x0000000000000002 + EntSize: 0x0000000000000002 + Entries: [ 0, 2, 3, 4, 2 ] + - Name: .gnu.version_r + Type: SHT_GNU_verneed + Flags: [ SHF_ALLOC ] + Link: .dynstr + AddressAlign: 0x0000000000000004 + Info: 0x0000000000000002 + Dependencies: + - Version: 1 + File: verneed1.so.0 + Entries: + - Name: v2 + Hash: 1938 + Flags: 0 + Other: 3 + - Name: v3 + Hash: 1939 + Flags: 0 + Other: 2 + - Version: 1 + File: verneed2.so.0 + Entries: + - Name: v1 + Hash: 1937 + Flags: 0 + Other: 4 + - Name: .rela.plt + Type: SHT_RELA + Flags: [ SHF_ALLOC ] + Info: 0 + Link: 7 + AddressAlign: 0x0000000000000008 + EntSize: 0x0000000000000018 + Relocations: + - Offset: 0x0000000000013018 + Symbol: f1 + Type: R_X86_64_JUMP_SLOT + - Offset: 0x0000000000013020 + Symbol: f2 + Type: R_X86_64_JUMP_SLOT + - Offset: 0x0000000000013028 + Symbol: g1 + Type: R_X86_64_JUMP_SLOT + - Offset: 0x0000000000013040 + Symbol: _Z2f1v + Type: R_X86_64_JUMP_SLOT + - Offset: 0x0000000000013058 + Symbol: f3 + Type: R_X86_64_JUMP_SLOT +Symbols: + Global: + - Name: f1 + - Name: f2 + - Name: g1 + - Name: _Z2f1v + - Name: f3 +DynamicSymbols: + Global: + - Name: f1 + - Name: f2 + - Name: g1 + - Name: _Z2f1v + - Name: f3 +... diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 8566f09..0ce0799 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -2706,7 +2706,8 @@ void GNUStyle::printRelocation(const ELFO *Obj, const Elf_Shdr *SymTab, TargetName = unwrapOrError(Obj->getSectionName(Sec)); } else if (Sym) { StringRef StrTable = unwrapOrError(Obj->getStringTableForSymtab(*SymTab)); - TargetName = maybeDemangle(unwrapOrError(Sym->getName(StrTable))); + TargetName = this->dumper()->getFullSymbolName( + Sym, StrTable, SymTab->sh_type == SHT_DYNSYM /* IsDynamic */); } unsigned Width = ELFT::Is64Bits ? 16 : 8; @@ -4293,7 +4294,8 @@ void LLVMStyle::printRelocation(const ELFO *Obj, Elf_Rela Rel, TargetName = unwrapOrError(Obj->getSectionName(Sec)); } else if (Sym) { StringRef StrTable = unwrapOrError(Obj->getStringTableForSymtab(*SymTab)); - TargetName = maybeDemangle(unwrapOrError(Sym->getName(StrTable))); + TargetName = this->dumper()->getFullSymbolName( + Sym, StrTable, SymTab->sh_type == SHT_DYNSYM /* IsDynamic */); } if (opts::ExpandRelocs) {