1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[llvm-readelf/obj] - Stop printing invalid names for unnamed section symbols.

We have an issue with `ELFDumper<ELFT>::getSymbolSectionName`:
1) It is used deeply for both LLVM/GNU styles and might return LLVM-style only
   values to describe symbols: "Undefined", "Processor Specific", "Absolute", etc.

2) `getSymbolSectionName` is used by `getFullSymbolName` and these special values
   might appear instead of symbol names in many places.
   This occurs for unnamed section symbols currently.

This patch extracts the LLVM specific logic to `LLVMStyle<ELFT>::printSymbolSection`,
which seems to be the only place where we want to print the special values mentioned.
It also adds a meaningful new warning that is reported when we are unable to get
a section index for a section symbol.

Differential revision: https://reviews.llvm.org/D87764
This commit is contained in:
Georgii Rymar 2020-09-15 16:17:08 +03:00
parent a9b02cf295
commit 3caa549f90
6 changed files with 130 additions and 77 deletions

View File

@ -329,25 +329,30 @@ DynamicSymbols:
Type: [[TYPE=STT_NOTYPE]]
## Check the behavior for unnamed versioned section symbols.
## TODO: we should print proper symbol names instead of descriptions.
# RUN: yaml2obj %s -DTYPE=STT_SECTION -DNAME="''" -DINDEX=SHN_ABS --docnum=6 -o %t6.sec.sym
# RUN: llvm-readobj -V --dyn-symbols %t6.sec.sym | FileCheck %s --check-prefix=VERSIONED-SEC-SYM-LLVM
# RUN: llvm-readelf -V --dyn-symbols %t6.sec.sym | FileCheck %s --check-prefix=VERSIONED-SEC-SYM-GNU
# RUN: llvm-readobj -V --dyn-symbols %t6.sec.sym 2>&1 | \
# RUN: FileCheck %s -DFILE=%t6.sec.sym --check-prefix=VERSIONED-SEC-SYM-LLVM
# RUN: llvm-readelf -V --dyn-symbols %t6.sec.sym 2>&1 | \
# RUN: FileCheck %s -DFILE=%t6.sec.sym --check-prefix=VERSIONED-SEC-SYM-GNU
# VERSIONED-SEC-SYM-LLVM: DynamicSymbols [
# VERSIONED-SEC-SYM-LLVM: Name: foo (12)
# VERSIONED-SEC-SYM-LLVM: Name: Absolute (0)
# VERSIONED-SEC-SYM-LLVM: Name: Undefined (0)
# VERSIONED-SEC-SYM-LLVM: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# VERSIONED-SEC-SYM-LLVM: Name: <?> (0)
# VERSIONED-SEC-SYM-LLVM: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF)
# VERSIONED-SEC-SYM-LLVM: Name: <?> (0)
# VERSIONED-SEC-SYM-LLVM: VersionSymbols [
# VERSIONED-SEC-SYM-LLVM: Name: foo
# VERSIONED-SEC-SYM-LLVM: Name: Absolute
# VERSIONED-SEC-SYM-LLVM: Name: Undefined
# VERSIONED-SEC-SYM-LLVM: Name: <?>
# VERSIONED-SEC-SYM-LLVM: Name: <?>
# VERSIONED-SEC-SYM-GNU: Symbol table '.dynsym' contains 4 entries:
# VERSIONED-SEC-SYM-GNU: Num: {{.*}} Ndx Name
# VERSIONED-SEC-SYM-GNU: 1: {{.*}} UND foo
# VERSIONED-SEC-SYM-GNU-NEXT: 2: {{.*}} ABS Absolute
# VERSIONED-SEC-SYM-GNU-NEXT: 3: {{.*}} UND Undefined
# VERSIONED-SEC-SYM-GNU: Symbol table '.dynsym' contains 4 entries:
# VERSIONED-SEC-SYM-GNU: Num: {{.*}} Ndx Name
# VERSIONED-SEC-SYM-GNU: 1: {{.*}} UND foo
# VERSIONED-SEC-SYM-GNU: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# VERSIONED-SEC-SYM-GNU-NEXT: 2: {{.*}} ABS <?>
# VERSIONED-SEC-SYM-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF)
# VERSIONED-SEC-SYM-GNU-NEXT: 3: {{.*}} UND <?>
## Case 8: Check what we print when:
## a) The dynamic symbol table does not exist.

View File

@ -112,22 +112,24 @@ ProgramHeaders:
- Section: .dynamic
## Check what we print for unnamed section symbols.
## TODO: we should print proper symbol names instead of descriptions.
# RUN: yaml2obj --docnum=1 -DBITS=64 -DTYPE=STT_SECTION -DNAME="''" %s -o %t1-sec-syms.so
# RUN: llvm-readelf --hash-symbols %t1-sec-syms.so | FileCheck %s --check-prefix=UNNAMED-SEC-SYMS
# RUN: llvm-readelf --hash-symbols %t1-sec-syms.so 2>&1 | \
# RUN: FileCheck %s -DFILE=%t1-sec-syms.so --check-prefix=UNNAMED-SEC-SYMS
# UNNAMED-SEC-SYMS: Symbol table of .hash for image:
# UNNAMED-SEC-SYMS-NEXT: Num {{.*}} Ndx Name
# UNNAMED-SEC-SYMS-NEXT: 1 {{.*}} UND Undefined
# UNNAMED-SEC-SYMS-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF)
# UNNAMED-SEC-SYMS-NEXT: 1 {{.*}} UND <?>
# UNNAMED-SEC-SYMS-NEXT: 5 {{.*}} 1 .hash
# UNNAMED-SEC-SYMS-NEXT: 3 {{.*}} ABS Absolute
# UNNAMED-SEC-SYMS-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# UNNAMED-SEC-SYMS-NEXT: 3 {{.*}} ABS <?>
# UNNAMED-SEC-SYMS-NEXT: 2 {{.*}} 1 .hash
# UNNAMED-SEC-SYMS-NEXT: 4 {{.*}} 2 .gnu.hash
# UNNAMED-SEC-SYMS-EMPTY:
# UNNAMED-SEC-SYMS: Symbol table of .gnu.hash for image:
# UNNAMED-SEC-SYMS-NEXT: Num {{.*}} Ndx Name
# UNNAMED-SEC-SYMS-NEXT: 2 {{.*}} 1 .hash
# UNNAMED-SEC-SYMS-NEXT: 3 {{.*}} ABS Absolute
# UNNAMED-SEC-SYMS-NEXT: 3 {{.*}} ABS <?>
# UNNAMED-SEC-SYMS-NEXT: 4 {{.*}} 2 .gnu.hash
# UNNAMED-SEC-SYMS-NEXT: 5 {{.*}} 1 .hash

View File

@ -653,7 +653,6 @@ DynamicSymbols:
- Name: foo
## Check how we print global GOT entries when they are unnamed section symbols.
## TODO: we should print proper symbol names instead of descriptions.
# RUN: yaml2obj --docnum=5 %s -o %t.err8.o
# RUN: llvm-readobj -A %t.err8.o 2>&1 | FileCheck %s -DFILE=%t.err8.o --check-prefix=SEC-SYMS-LLVM
# RUN: llvm-readelf -A %t.err8.o 2>&1 | FileCheck %s -DFILE=%t.err8.o --check-prefix=SEC-SYMS-GNU
@ -661,7 +660,8 @@ DynamicSymbols:
# SEC-SYMS-LLVM: Global entries [
# SEC-SYMS-LLVM-NEXT: Entry {
# SEC-SYMS-LLVM: Section: Absolute (0xFFF1)
# SEC-SYMS-LLVM-NEXT: Name: Absolute (0)
# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# SEC-SYMS-LLVM-NEXT: Name: <?> (0)
# SEC-SYMS-LLVM-NEXT: }
# SEC-SYMS-LLVM-NEXT: Entry {
# SEC-SYMS-LLVM: Section: .got (0x1)
@ -669,15 +669,18 @@ DynamicSymbols:
# SEC-SYMS-LLVM-NEXT: }
# SEC-SYMS-LLVM-NEXT: Entry {
# SEC-SYMS-LLVM: Section: Common (0xFFF2)
# SEC-SYMS-LLVM-NEXT: Name: Common (0)
# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)
# SEC-SYMS-LLVM-NEXT: Name: <?> (0)
# SEC-SYMS-LLVM-NEXT: }
# SEC-SYMS-LLVM-NEXT: ]
# SEC-SYMS-GNU: Global entries:
# SEC-SYMS-GNU-NEXT: {{.*}} Ndx Name
# SEC-SYMS-GNU-NEXT: {{.*}} ABS Absolute
# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# SEC-SYMS-GNU-NEXT: {{.*}} ABS <?>
# SEC-SYMS-GNU-NEXT: {{.*}} 1 .got
# SEC-SYMS-GNU-NEXT: {{.*}} COM Common
# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)
# SEC-SYMS-GNU-NEXT: {{.*}} COM <?>
--- !ELF
FileHeader:

View File

@ -142,16 +142,16 @@ DynamicSymbols: []
# ERR7: error: '[[FILE]]': unable to get a string table for the SHT_DYNAMIC section with index 1: invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM
## Check how we print PLT entries when they are unnamed section symbols.
## TODO: we should print proper symbol names instead of descriptions.
# RUN: yaml2obj --docnum=3 %s -o %t.3
# RUN: llvm-readobj -A %t.3 2>&1 | FileCheck %s -DFILE=%t.err8.o --check-prefix=SEC-SYMS-LLVM
# RUN: llvm-readelf -A %t.3 2>&1 | FileCheck %s -DFILE=%t.err8.o --check-prefix=SEC-SYMS-GNU
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: llvm-readobj -A %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=SEC-SYMS-LLVM
# RUN: llvm-readelf -A %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=SEC-SYMS-GNU
# SEC-SYMS-LLVM: PLT GOT {
# SEC-SYMS-LLVM: Entries [
# SEC-SYMS-LLVM: Entry {
# SEC-SYMS-LLVM: Section: Absolute (0xFFF1)
# SEC-SYMS-LLVM-NEXT: Name: Absolute (0)
# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# SEC-SYMS-LLVM-NEXT: Name: <?> (0)
# SEC-SYMS-LLVM-NEXT: }
# SEC-SYMS-LLVM-NEXT: Entry {
# SEC-SYMS-LLVM: Section: .got.plt (0x2)
@ -159,7 +159,8 @@ DynamicSymbols: []
# SEC-SYMS-LLVM-NEXT: }
# SEC-SYMS-LLVM-NEXT: Entry {
# SEC-SYMS-LLVM: Section: Common (0xFFF2)
# SEC-SYMS-LLVM-NEXT: Name: Common (0)
# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)
# SEC-SYMS-LLVM-NEXT: Name: <?> (0)
# SEC-SYMS-LLVM-NEXT: }
# SEC-SYMS-LLVM-NEXT: ]
# SEC-SYMS-LLVM-NEXT: }
@ -167,9 +168,11 @@ DynamicSymbols: []
# SEC-SYMS-GNU: PLT GOT:
# SEC-SYMS-GNU: Entries:
# SEC-SYMS-GNU-NEXT: Address {{.*}} Ndx Name
# SEC-SYMS-GNU-NEXT: 0000000000002010 {{.*}} ABS Absolute
# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# SEC-SYMS-GNU-NEXT: 0000000000002010 {{.*}} ABS <?>
# SEC-SYMS-GNU-NEXT: 0000000000002018 {{.*}} 2 .got.plt
# SEC-SYMS-GNU-NEXT: 0000000000002020 {{.*}} COM Common
# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)
# SEC-SYMS-GNU-NEXT: 0000000000002020 {{.*}} COM <?>
--- !ELF
FileHeader:

View File

@ -95,49 +95,62 @@ Symbols:
# RUN: llvm-readelf --symbols %t1-sec | FileCheck %s --check-prefix=GNU1
## Check the behavior for unnamed section symbols.
## TODO: we should print proper symbol names instead of descriptions.
# RUN: yaml2obj --docnum=1 -DTYPE=STT_SECTION -DNAME="''" %s -o %t1-sec-unnamed
# RUN: llvm-readobj --symbols %t1-sec-unnamed | FileCheck %s --check-prefix=LLVM1-SEC-SYMS
# RUN: llvm-readelf --symbols %t1-sec-unnamed | FileCheck %s --check-prefix=GNU1-SEC-SYMS
# RUN: llvm-readobj --symbols %t1-sec-unnamed 2>&1 | \
# RUN: FileCheck %s -DFILE=%t1-sec-unnamed --check-prefix=LLVM1-SEC-SYMS
# RUN: llvm-readelf --symbols %t1-sec-unnamed 2>&1 | \
# RUN: FileCheck %s -DFILE=%t1-sec-unnamed --check-prefix=GNU1-SEC-SYMS
# LLVM1-SEC-SYMS: Symbols [
# LLVM1-SEC-SYMS-NEXT: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: (0)
# LLVM1-SEC-SYMS: Section: Undefined (0x0)
# LLVM1-SEC-SYMS: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: Undefined (0)
# LLVM1-SEC-SYMS: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF)
# LLVM1-SEC-SYMS-NEXT: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: <?> (0)
# LLVM1-SEC-SYMS: Section: Undefined (0x0)
# LLVM1-SEC-SYMS: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: .text (0)
# LLVM1-SEC-SYMS: Section: .text (0x1)
# LLVM1-SEC-SYMS: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: Common (0)
# LLVM1-SEC-SYMS: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)
# LLVM1-SEC-SYMS-NEXT: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: <?> (0)
# LLVM1-SEC-SYMS: Section: Common (0xFFF2)
# LLVM1-SEC-SYMS: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: Absolute (0)
# LLVM1-SEC-SYMS: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# LLVM1-SEC-SYMS-NEXT: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: <?> (0)
# LLVM1-SEC-SYMS: Section: Absolute (0xFFF1)
# LLVM1-SEC-SYMS: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: Processor Specific (0)
# LLVM1-SEC-SYMS: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xff01 (SHN_LOPROC+0x1)
# LLVM1-SEC-SYMS-NEXT: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: <?> (0)
# LLVM1-SEC-SYMS: Section: Processor Specific (0xFF01)
# LLVM1-SEC-SYMS: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: Operating System Specific (0)
# LLVM1-SEC-SYMS: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xff21 (SHN_LOOS+0x1)
# LLVM1-SEC-SYMS-NEXT: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: <?> (0)
# LLVM1-SEC-SYMS: Section: Operating System Specific (0xFF21)
# LLVM1-SEC-SYMS: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: Reserved (0)
# LLVM1-SEC-SYMS: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfffe (SHN_LORESERVE+0xfe)
# LLVM1-SEC-SYMS-NEXT: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: <?> (0)
# LLVM1-SEC-SYMS: Section: Reserved (0xFFFE)
# LLVM1-SEC-SYMS: Symbol {
# LLVM1-SEC-SYMS-NEXT: Name: .text (0)
# LLVM1-SEC-SYMS: Section: .text (0x1)
# GNU1-SEC-SYMS: Num: {{.*}} Ndx Name
# GNU1-SEC-SYMS-NEXT: 0: {{.*}} UND
# GNU1-SEC-SYMS-NEXT: 1: {{.*}} UND Undefined
# GNU1-SEC-SYMS-NEXT: 0: {{.*}} UND {{$}}
# GNU1-SEC-SYMS-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF)
# GNU1-SEC-SYMS-NEXT: 1: {{.*}} UND <?>
# GNU1-SEC-SYMS-NEXT: 2: {{.*}} 1 .text
# GNU1-SEC-SYMS-NEXT: 3: {{.*}} COM Common
# GNU1-SEC-SYMS-NEXT: 4: {{.*}} ABS Absolute
# GNU1-SEC-SYMS-NEXT: 5: {{.*}} PRC[0xff01] Processor Specific
# GNU1-SEC-SYMS-NEXT: 6: {{.*}} OS[0xff21] Operating System Specific
# GNU1-SEC-SYMS-NEXT: 7: {{.*}} RSV[0xfffe] Reserved
# GNU1-SEC-SYMS-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)
# GNU1-SEC-SYMS-NEXT: 3: {{.*}} COM <?>
# GNU1-SEC-SYMS-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
# GNU1-SEC-SYMS-NEXT: 4: {{.*}} ABS <?>
# GNU1-SEC-SYMS-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xff01 (SHN_LOPROC+0x1)
# GNU1-SEC-SYMS-NEXT: 5: {{.*}} PRC[0xff01] <?>
# GNU1-SEC-SYMS-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xff21 (SHN_LOOS+0x1)
# GNU1-SEC-SYMS-NEXT: 6: {{.*}} OS[0xff21] <?>
# GNU1-SEC-SYMS-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfffe (SHN_LORESERVE+0xfe)
# GNU1-SEC-SYMS-NEXT: 7: {{.*}} RSV[0xfffe] <?>
# GNU1-SEC-SYMS-NEXT: 8: {{.*}} 1 .text
## In this case, the index does not correspond to a real section. Check that GNU

View File

@ -1225,37 +1225,43 @@ template <typename ELFT>
Expected<unsigned>
ELFDumper<ELFT>::getSymbolSectionIndex(const Elf_Sym *Symbol,
const Elf_Sym *FirstSym) const {
return Symbol->st_shndx == SHN_XINDEX
? object::getExtendedSymbolTableIndex<ELFT>(*Symbol, *FirstSym,
ShndxTable)
: Symbol->st_shndx;
unsigned Ndx = Symbol->st_shndx;
if (Ndx == SHN_XINDEX)
return object::getExtendedSymbolTableIndex<ELFT>(*Symbol, *FirstSym,
ShndxTable);
if (Ndx != SHN_UNDEF && Ndx < SHN_LORESERVE)
return Ndx;
auto CreateErr = [&](const Twine &Name, Optional<unsigned> Offset = None) {
std::string Desc;
if (Offset)
Desc = (Name + "+0x" + Twine::utohexstr(*Offset)).str();
else
Desc = Name.str();
return createError(
"unable to get section index for symbol with st_shndx = 0x" +
Twine::utohexstr(Ndx) + " (" + Desc + ")");
};
if (Ndx >= ELF::SHN_LOPROC && Ndx <= ELF::SHN_HIPROC)
return CreateErr("SHN_LOPROC", Ndx - ELF::SHN_LOPROC);
if (Ndx >= ELF::SHN_LOOS && Ndx <= ELF::SHN_HIOS)
return CreateErr("SHN_LOOS", Ndx - ELF::SHN_LOOS);
if (Ndx == ELF::SHN_UNDEF)
return CreateErr("SHN_UNDEF");
if (Ndx == ELF::SHN_ABS)
return CreateErr("SHN_ABS");
if (Ndx == ELF::SHN_COMMON)
return CreateErr("SHN_COMMON");
return CreateErr("SHN_LORESERVE", Ndx - SHN_LORESERVE);
}
// If the Symbol has a reserved st_shndx other than SHN_XINDEX, return a
// descriptive interpretation of the st_shndx value. Otherwise, return the name
// of the section with index SectionIndex. This function assumes that if the
// Symbol has st_shndx == SHN_XINDEX the SectionIndex will be the value derived
// from the SHT_SYMTAB_SHNDX section.
template <typename ELFT>
Expected<StringRef>
ELFDumper<ELFT>::getSymbolSectionName(const Elf_Sym *Symbol,
unsigned SectionIndex) const {
if (Symbol->isUndefined())
return "Undefined";
if (Symbol->isProcessorSpecific())
return "Processor Specific";
if (Symbol->isOSSpecific())
return "Operating System Specific";
if (Symbol->isAbsolute())
return "Absolute";
if (Symbol->isCommon())
return "Common";
if (Symbol->isReserved() && Symbol->st_shndx != SHN_XINDEX)
return "Reserved";
const ELFFile<ELFT> *Obj = ObjF->getELFFile();
Expected<const Elf_Shdr *> SecOrErr =
Obj->getSection(SectionIndex);
Expected<const Elf_Shdr *> SecOrErr = Obj->getSection(SectionIndex);
if (!SecOrErr)
return SecOrErr.takeError();
return Obj->getSectionName(**SecOrErr);
@ -3933,7 +3939,7 @@ std::string GNUStyle<ELFT>::getSymbolSectionNdx(const Elf_Sym *Symbol,
*Symbol, *FirstSym, this->dumper()->getShndxTable());
if (!IndexOrErr) {
assert(Symbol->st_shndx == SHN_XINDEX &&
"getSymbolSectionIndex should only fail due to an invalid "
"getExtendedSymbolTableIndex should only fail due to an invalid "
"SHT_SYMTAB_SHNDX table/reference");
this->reportUniqueWarning(IndexOrErr.takeError());
return "RSV[0xffff]";
@ -6168,6 +6174,27 @@ template <class ELFT> void LLVMStyle<ELFT>::printSectionHeaders() {
template <class ELFT>
void LLVMStyle<ELFT>::printSymbolSection(const Elf_Sym *Symbol,
const Elf_Sym *First) {
auto GetSectionSpecialType = [&]() -> Optional<StringRef> {
if (Symbol->isUndefined())
return StringRef("Undefined");
if (Symbol->isProcessorSpecific())
return StringRef("Processor Specific");
if (Symbol->isOSSpecific())
return StringRef("Operating System Specific");
if (Symbol->isAbsolute())
return StringRef("Absolute");
if (Symbol->isCommon())
return StringRef("Common");
if (Symbol->isReserved() && Symbol->st_shndx != SHN_XINDEX)
return StringRef("Reserved");
return None;
};
if (Optional<StringRef> Type = GetSectionSpecialType()) {
W.printHex("Section", *Type, Symbol->st_shndx);
return;
}
Expected<unsigned> SectionIndex =
this->dumper()->getSymbolSectionIndex(Symbol, First);
if (!SectionIndex) {