mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[llvm-readobj] Display section names for STT_SECTION symbols.
Summary: This patch will obtain the section name for symbols that refer to a section. Prior to this patch the Name field for STT_SECTIONs was blank, now it is populated. Before: ``` Symbol table '.symtab' contains 6 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _GLOBAL_OFFSET_TABLE_ 5: 0000000000000000 0 TLS GLOBAL DEFAULT UND sym ``` With this patch: ``` Symbol table '.symtab' contains 6 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 .data 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .bss 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _GLOBAL_OFFSET_TABLE_ 5: 0000000000000000 0 TLS GLOBAL DEFAULT UND sym ``` This fixes PR40788 Reviewers: jhenderson, rupprecht, espindola Reviewed By: rupprecht Subscribers: emaste, javed.absar, arichardson, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58796 llvm-svn: 355207
This commit is contained in:
parent
1f87d3f406
commit
9fd9c8face
@ -78,7 +78,7 @@ global1:
|
||||
@ CHECK-NEXT: Section: .text
|
||||
@ CHECK-NEXT: }
|
||||
@ CHECK-NEXT: Symbol {
|
||||
@ CHECK-NEXT: Name: (0)
|
||||
@ CHECK-NEXT: Name: .text (0)
|
||||
@ CHECK-NEXT: Value: 0x0
|
||||
@ CHECK-NEXT: Size: 0
|
||||
@ CHECK-NEXT: Binding: Local (0x0)
|
||||
|
@ -107,7 +107,7 @@ leaq .Llocal1(%rip), %rdi
|
||||
// CHECK-NEXT: Section: .text
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Symbol {
|
||||
// CHECK-NEXT: Name: (0)
|
||||
// CHECK-NEXT: Name: .data (0)
|
||||
// CHECK-NOT: Symbol {
|
||||
// CHECK: }
|
||||
// CHECK-NEXT: Symbol {
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
|
||||
// Test that this file has one section too many.
|
||||
// SYMBOLS: Name: (0)
|
||||
// SYMBOLS: Name: dm (0)
|
||||
// SYMBOLS: Value: 0x0
|
||||
// SYMBOLS: Size: 0
|
||||
// SYMBOLS: Binding: Local (0x0)
|
||||
|
@ -82,7 +82,7 @@
|
||||
// CHECK-NEXT: Section: .group
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Symbol {
|
||||
// CHECK-NEXT: Name: (0)
|
||||
// CHECK-NEXT: Name: foo (0)
|
||||
// CHECK-NEXT: Value: 0x0
|
||||
// CHECK-NEXT: Size: 0
|
||||
// CHECK-NEXT: Binding: Local (0x0)
|
||||
|
@ -77,7 +77,7 @@ global1:
|
||||
// CHECK-NEXT: Section: .text
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Symbol {
|
||||
// CHECK-NEXT: Name: (0)
|
||||
// CHECK-NEXT: Name: .text (0)
|
||||
// CHECK-NEXT: Value: 0x0
|
||||
// CHECK-NEXT: Size: 0
|
||||
// CHECK-NEXT: Binding: Local
|
||||
|
@ -116,7 +116,7 @@ bar15:
|
||||
// CHECK-NEXT: Section: .text
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Symbol {
|
||||
// CHECK-NEXT: Name: (0)
|
||||
// CHECK-NEXT: Name: .text (0)
|
||||
// CHECK-NEXT: Value: 0x0
|
||||
// CHECK-NEXT: Size: 0
|
||||
// CHECK-NEXT: Binding: Local
|
||||
|
@ -128,61 +128,61 @@ ELF: ]
|
||||
|
||||
ELF: Symbols [
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .hash (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .hash
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .dynsym (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .dynsym
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .dynstr (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .dynstr
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .text (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .text
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .eh_frame (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .eh_frame
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .tdata (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .tdata
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .dynamic (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .dynamic
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .got.plt (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .got.plt
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .data (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .data
|
||||
ELF: }
|
||||
ELF: Symbol {
|
||||
ELF: Name: (0)
|
||||
ELF: Name: .bss (0)
|
||||
ELF: Binding: Local
|
||||
ELF: Type: Section
|
||||
ELF: Section: .bss
|
||||
|
@ -20,9 +20,9 @@ ELF32-NEXT: 4: 00000000 4 OBJECT GLOBAL DEFAULT 3 y
|
||||
ELF64: Symbol table '.symtab' contains 6 entries:
|
||||
ELF64-NEXT: Num: Value Size Type Bind Vis Ndx Name
|
||||
ELF64-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
|
||||
ELF64-NEXT: 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1
|
||||
ELF64-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3
|
||||
ELF64-NEXT: 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4
|
||||
ELF64-NEXT: 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text
|
||||
ELF64-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 .data
|
||||
ELF64-NEXT: 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .bss
|
||||
ELF64-NEXT: 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _GLOBAL_OFFSET_TABLE_
|
||||
ELF64-NEXT: 5: 0000000000000000 0 TLS GLOBAL DEFAULT UND sym
|
||||
|
||||
@ -42,11 +42,11 @@ NO-SYMTAB-NOT: Symbol table '.symtab'
|
||||
SYMTAB: Symbol table '.symtab' contains 12 entries:
|
||||
SYMTAB-NEXT: Num: Value Size Type Bind Vis Ndx Name
|
||||
SYMTAB-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
|
||||
SYMTAB-NEXT: 1: 00000000000000e8 0 SECTION LOCAL DEFAULT 1
|
||||
SYMTAB-NEXT: 2: 0000000000000120 0 SECTION LOCAL DEFAULT 2
|
||||
SYMTAB-NEXT: 3: 0000000000000198 0 SECTION LOCAL DEFAULT 3
|
||||
SYMTAB-NEXT: 4: 00000000000001b8 0 SECTION LOCAL DEFAULT 4
|
||||
SYMTAB-NEXT: 5: 00000000002001b8 0 SECTION LOCAL DEFAULT 5
|
||||
SYMTAB-NEXT: 1: 00000000000000e8 0 SECTION LOCAL DEFAULT 1 .gnu.hash
|
||||
SYMTAB-NEXT: 2: 0000000000000120 0 SECTION LOCAL DEFAULT 2 .dynsym
|
||||
SYMTAB-NEXT: 3: 0000000000000198 0 SECTION LOCAL DEFAULT 3 .dynstr
|
||||
SYMTAB-NEXT: 4: 00000000000001b8 0 SECTION LOCAL DEFAULT 4 .eh_frame
|
||||
SYMTAB-NEXT: 5: 00000000002001b8 0 SECTION LOCAL DEFAULT 5 .dynamic
|
||||
SYMTAB-NEXT: 6: 00000000002001b8 0 OBJECT LOCAL DEFAULT 5 _DYNAMIC
|
||||
SYMTAB-NEXT: 7: 0000000000200268 0 OBJECT LOCAL DEFAULT 5 _GLOBAL_OFFSET_TABLE_
|
||||
SYMTAB-NEXT: 8: 0000000000200268 0 NOTYPE GLOBAL DEFAULT 5 __bss_start
|
||||
|
@ -124,7 +124,7 @@ ELF-NEXT: Relocations [
|
||||
ELF-NEXT: ]
|
||||
ELF-NEXT: Symbols [
|
||||
ELF-NEXT: Symbol {
|
||||
ELF-NEXT: Name: (0)
|
||||
ELF-NEXT: Name: .text (0)
|
||||
ELF-NEXT: Value: 0x0
|
||||
ELF-NEXT: Size: 0
|
||||
ELF-NEXT: Binding: Local (0x0)
|
||||
|
@ -814,6 +814,16 @@ std::string ELFDumper<ELFT>::getFullSymbolName(const Elf_Sym *Symbol,
|
||||
bool IsDynamic) const {
|
||||
std::string SymbolName =
|
||||
maybeDemangle(unwrapOrError(Symbol->getName(StrTable)));
|
||||
|
||||
if (SymbolName.empty() && Symbol->getType() == ELF::STT_SECTION) {
|
||||
unsigned SectionIndex;
|
||||
StringRef SectionName;
|
||||
Elf_Sym_Range Syms =
|
||||
unwrapOrError(ObjF->getELFFile()->symbols(DotSymtabSec));
|
||||
getSectionNameIndex(Symbol, Syms.begin(), SectionName, SectionIndex);
|
||||
return SectionName;
|
||||
}
|
||||
|
||||
if (!IsDynamic)
|
||||
return SymbolName;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user