[llvm] r355922 - [llvm-readobj] Print symbol version when dumping relocations (PR31564)
Xing GUO via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 07:30:14 PDT 2019
Author: higuoxing
Date: Tue Mar 12 07:30:13 2019
New Revision: 355922
URL: http://llvm.org/viewvc/llvm-project?rev=355922&view=rev
Log:
[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
Added:
llvm/trunk/test/tools/llvm-readobj/elf-reloc-symbol-with-versioning.test
Modified:
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Added: llvm/trunk/test/tools/llvm-readobj/elf-reloc-symbol-with-versioning.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/elf-reloc-symbol-with-versioning.test?rev=355922&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/elf-reloc-symbol-with-versioning.test (added)
+++ llvm/trunk/test/tools/llvm-readobj/elf-reloc-symbol-with-versioning.test Tue Mar 12 07:30:13 2019
@@ -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 at v3 + 0
+# GNU-NEXT: 0000000000013020 0000000200000007 R_X86_64_JUMP_SLOT 0000000000000000 f2 at v2 + 0
+# GNU-NEXT: 0000000000013028 0000000300000007 R_X86_64_JUMP_SLOT 0000000000000000 g1 at 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 at v3 0x0
+# LLVM-NEXT: 0x13020 R_X86_64_JUMP_SLOT f2 at v2 0x0
+# LLVM-NEXT: 0x13028 R_X86_64_JUMP_SLOT g1 at 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
+...
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=355922&r1=355921&r2=355922&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Tue Mar 12 07:30:13 2019
@@ -2706,7 +2706,8 @@ void GNUStyle<ELFT>::printRelocation(con
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<ELFT>::printRelocation(co
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) {
More information about the llvm-commits
mailing list