forked from OSchip/llvm-project
[llvm-readobj/libObject] - Get rid of `FirstSym` argument. NFCI.
We use `FirstSym` argument in `getExtendedSymbolTableIndex` to calculate a symbol index: ``` &Sym - &FirstSym ``` Instead, we could pass the symbol index directly. This is what this patch does, it allows to simplify another llvm-readobj API. Differential revision: https://reviews.llvm.org/D88016
This commit is contained in:
parent
82042a2c9b
commit
df3e903655
|
@ -337,19 +337,17 @@ getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
inline Expected<uint32_t>
|
inline Expected<uint32_t>
|
||||||
getExtendedSymbolTableIndex(const typename ELFT::Sym &Sym,
|
getExtendedSymbolTableIndex(const typename ELFT::Sym &Sym, unsigned SymIndex,
|
||||||
const typename ELFT::Sym &FirstSym,
|
|
||||||
ArrayRef<typename ELFT::Word> ShndxTable) {
|
ArrayRef<typename ELFT::Word> ShndxTable) {
|
||||||
assert(Sym.st_shndx == ELF::SHN_XINDEX);
|
assert(Sym.st_shndx == ELF::SHN_XINDEX);
|
||||||
unsigned Index = &Sym - &FirstSym;
|
if (SymIndex >= ShndxTable.size())
|
||||||
if (Index >= ShndxTable.size())
|
|
||||||
return createError(
|
return createError(
|
||||||
"extended symbol index (" + Twine(Index) +
|
"extended symbol index (" + Twine(SymIndex) +
|
||||||
") is past the end of the SHT_SYMTAB_SHNDX section of size " +
|
") is past the end of the SHT_SYMTAB_SHNDX section of size " +
|
||||||
Twine(ShndxTable.size()));
|
Twine(ShndxTable.size()));
|
||||||
|
|
||||||
// The size of the table was checked in getSHNDXTable.
|
// The size of the table was checked in getSHNDXTable.
|
||||||
return ShndxTable[Index];
|
return ShndxTable[SymIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
|
@ -359,7 +357,7 @@ ELFFile<ELFT>::getSectionIndex(const Elf_Sym &Sym, Elf_Sym_Range Syms,
|
||||||
uint32_t Index = Sym.st_shndx;
|
uint32_t Index = Sym.st_shndx;
|
||||||
if (Index == ELF::SHN_XINDEX) {
|
if (Index == ELF::SHN_XINDEX) {
|
||||||
Expected<uint32_t> ErrorOrIndex =
|
Expected<uint32_t> ErrorOrIndex =
|
||||||
getExtendedSymbolTableIndex<ELFT>(Sym, *Syms.begin(), ShndxTable);
|
getExtendedSymbolTableIndex<ELFT>(Sym, &Sym - Syms.begin(), ShndxTable);
|
||||||
if (!ErrorOrIndex)
|
if (!ErrorOrIndex)
|
||||||
return ErrorOrIndex.takeError();
|
return ErrorOrIndex.takeError();
|
||||||
return *ErrorOrIndex;
|
return *ErrorOrIndex;
|
||||||
|
|
|
@ -359,7 +359,7 @@ public:
|
||||||
Optional<StringRef> StrTable,
|
Optional<StringRef> StrTable,
|
||||||
bool IsDynamic) const;
|
bool IsDynamic) const;
|
||||||
Expected<unsigned> getSymbolSectionIndex(const Elf_Sym *Symbol,
|
Expected<unsigned> getSymbolSectionIndex(const Elf_Sym *Symbol,
|
||||||
const Elf_Sym *FirstSym) const;
|
unsigned SymIndex) const;
|
||||||
Expected<StringRef> getSymbolSectionName(const Elf_Sym *Symbol,
|
Expected<StringRef> getSymbolSectionName(const Elf_Sym *Symbol,
|
||||||
unsigned SectionIndex) const;
|
unsigned SectionIndex) const;
|
||||||
std::string getStaticSymbolName(uint32_t Index) const;
|
std::string getStaticSymbolName(uint32_t Index) const;
|
||||||
|
@ -711,7 +711,7 @@ void ELFDumper<ELFT>::printSymbolsHelper(bool IsDynamic) const {
|
||||||
|
|
||||||
ELFDumperStyle->printSymtabMessage(SymtabSec, Entries, NonVisibilityBitsUsed);
|
ELFDumperStyle->printSymtabMessage(SymtabSec, Entries, NonVisibilityBitsUsed);
|
||||||
for (const auto &Sym : Syms)
|
for (const auto &Sym : Syms)
|
||||||
ELFDumperStyle->printSymbol(&Sym, Syms.begin(), StrTable, IsDynamic,
|
ELFDumperStyle->printSymbol(&Sym, &Sym - Syms.begin(), StrTable, IsDynamic,
|
||||||
NonVisibilityBitsUsed);
|
NonVisibilityBitsUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ public:
|
||||||
virtual void printDynamicRelocations() = 0;
|
virtual void printDynamicRelocations() = 0;
|
||||||
virtual void printSymtabMessage(const Elf_Shdr *Symtab, size_t Offset,
|
virtual void printSymtabMessage(const Elf_Shdr *Symtab, size_t Offset,
|
||||||
bool NonVisibilityBitsUsed) {}
|
bool NonVisibilityBitsUsed) {}
|
||||||
virtual void printSymbol(const Elf_Sym *Symbol, const Elf_Sym *FirstSym,
|
virtual void printSymbol(const Elf_Sym *Symbol, unsigned SymIndex,
|
||||||
Optional<StringRef> StrTable, bool IsDynamic,
|
Optional<StringRef> StrTable, bool IsDynamic,
|
||||||
bool NonVisibilityBitsUsed) = 0;
|
bool NonVisibilityBitsUsed) = 0;
|
||||||
virtual void printProgramHeaders(bool PrintProgramHeaders,
|
virtual void printProgramHeaders(bool PrintProgramHeaders,
|
||||||
|
@ -891,7 +891,7 @@ private:
|
||||||
OS.flush();
|
OS.flush();
|
||||||
return OS;
|
return OS;
|
||||||
}
|
}
|
||||||
void printHashedSymbol(const Elf_Sym *FirstSym, uint32_t Sym,
|
void printHashedSymbol(const Elf_Sym *Sym, unsigned SymIndex,
|
||||||
StringRef StrTable, uint32_t Bucket);
|
StringRef StrTable, uint32_t Bucket);
|
||||||
void printReloc(const Relocation<ELFT> &R, unsigned RelIndex,
|
void printReloc(const Relocation<ELFT> &R, unsigned RelIndex,
|
||||||
const Elf_Shdr &Sec, const Elf_Shdr *SymTab) override;
|
const Elf_Shdr &Sec, const Elf_Shdr *SymTab) override;
|
||||||
|
@ -899,15 +899,14 @@ private:
|
||||||
|
|
||||||
void printRelRelaReloc(const Relocation<ELFT> &R,
|
void printRelRelaReloc(const Relocation<ELFT> &R,
|
||||||
const RelSymbol<ELFT> &RelSym);
|
const RelSymbol<ELFT> &RelSym);
|
||||||
void printSymbol(const Elf_Sym *Symbol, const Elf_Sym *First,
|
void printSymbol(const Elf_Sym *Symbol, unsigned SymIndex,
|
||||||
Optional<StringRef> StrTable, bool IsDynamic,
|
Optional<StringRef> StrTable, bool IsDynamic,
|
||||||
bool NonVisibilityBitsUsed) override;
|
bool NonVisibilityBitsUsed) override;
|
||||||
void printDynamicRelocHeader(unsigned Type, StringRef Name,
|
void printDynamicRelocHeader(unsigned Type, StringRef Name,
|
||||||
const DynRegionInfo &Reg) override;
|
const DynRegionInfo &Reg) override;
|
||||||
void printDynamicReloc(const Relocation<ELFT> &R) override;
|
void printDynamicReloc(const Relocation<ELFT> &R) override;
|
||||||
|
|
||||||
std::string getSymbolSectionNdx(const Elf_Sym *Symbol,
|
std::string getSymbolSectionNdx(const Elf_Sym *Symbol, unsigned SymIndex);
|
||||||
const Elf_Sym *FirstSym);
|
|
||||||
void printProgramHeaders();
|
void printProgramHeaders();
|
||||||
void printSectionMapping();
|
void printSectionMapping();
|
||||||
void printGNUVersionSectionProlog(const typename ELFT::Shdr *Sec,
|
void printGNUVersionSectionProlog(const typename ELFT::Shdr *Sec,
|
||||||
|
@ -967,8 +966,8 @@ private:
|
||||||
void printRelRelaReloc(const Relocation<ELFT> &R, StringRef SymbolName);
|
void printRelRelaReloc(const Relocation<ELFT> &R, StringRef SymbolName);
|
||||||
void printSymbols();
|
void printSymbols();
|
||||||
void printDynamicSymbols();
|
void printDynamicSymbols();
|
||||||
void printSymbolSection(const Elf_Sym *Symbol, const Elf_Sym *First);
|
void printSymbolSection(const Elf_Sym *Symbol, unsigned SymIndex);
|
||||||
void printSymbol(const Elf_Sym *Symbol, const Elf_Sym *First,
|
void printSymbol(const Elf_Sym *Symbol, unsigned SymIndex,
|
||||||
Optional<StringRef> StrTable, bool IsDynamic,
|
Optional<StringRef> StrTable, bool IsDynamic,
|
||||||
bool /*NonVisibilityBitsUsed*/) override;
|
bool /*NonVisibilityBitsUsed*/) override;
|
||||||
void printProgramHeaders();
|
void printProgramHeaders();
|
||||||
|
@ -1191,7 +1190,7 @@ std::string ELFDumper<ELFT>::getFullSymbolName(const Elf_Sym *Symbol,
|
||||||
Elf_Sym_Range Syms = unwrapOrError(
|
Elf_Sym_Range Syms = unwrapOrError(
|
||||||
ObjF->getFileName(), ObjF->getELFFile()->symbols(DotSymtabSec));
|
ObjF->getFileName(), ObjF->getELFFile()->symbols(DotSymtabSec));
|
||||||
Expected<unsigned> SectionIndex =
|
Expected<unsigned> SectionIndex =
|
||||||
getSymbolSectionIndex(Symbol, Syms.begin());
|
getSymbolSectionIndex(Symbol, Symbol - Syms.begin());
|
||||||
if (!SectionIndex) {
|
if (!SectionIndex) {
|
||||||
reportUniqueWarning(SectionIndex.takeError());
|
reportUniqueWarning(SectionIndex.takeError());
|
||||||
return "<?>";
|
return "<?>";
|
||||||
|
@ -1224,10 +1223,10 @@ std::string ELFDumper<ELFT>::getFullSymbolName(const Elf_Sym *Symbol,
|
||||||
template <typename ELFT>
|
template <typename ELFT>
|
||||||
Expected<unsigned>
|
Expected<unsigned>
|
||||||
ELFDumper<ELFT>::getSymbolSectionIndex(const Elf_Sym *Symbol,
|
ELFDumper<ELFT>::getSymbolSectionIndex(const Elf_Sym *Symbol,
|
||||||
const Elf_Sym *FirstSym) const {
|
unsigned SymIndex) const {
|
||||||
unsigned Ndx = Symbol->st_shndx;
|
unsigned Ndx = Symbol->st_shndx;
|
||||||
if (Ndx == SHN_XINDEX)
|
if (Ndx == SHN_XINDEX)
|
||||||
return object::getExtendedSymbolTableIndex<ELFT>(*Symbol, *FirstSym,
|
return object::getExtendedSymbolTableIndex<ELFT>(*Symbol, SymIndex,
|
||||||
ShndxTable);
|
ShndxTable);
|
||||||
if (Ndx != SHN_UNDEF && Ndx < SHN_LORESERVE)
|
if (Ndx != SHN_UNDEF && Ndx < SHN_LORESERVE)
|
||||||
return Ndx;
|
return Ndx;
|
||||||
|
@ -3925,7 +3924,7 @@ void GNUStyle<ELFT>::printSymtabMessage(const Elf_Shdr *Symtab, size_t Entries,
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
std::string GNUStyle<ELFT>::getSymbolSectionNdx(const Elf_Sym *Symbol,
|
std::string GNUStyle<ELFT>::getSymbolSectionNdx(const Elf_Sym *Symbol,
|
||||||
const Elf_Sym *FirstSym) {
|
unsigned SymIndex) {
|
||||||
unsigned SectionIndex = Symbol->st_shndx;
|
unsigned SectionIndex = Symbol->st_shndx;
|
||||||
switch (SectionIndex) {
|
switch (SectionIndex) {
|
||||||
case ELF::SHN_UNDEF:
|
case ELF::SHN_UNDEF:
|
||||||
|
@ -3936,7 +3935,7 @@ std::string GNUStyle<ELFT>::getSymbolSectionNdx(const Elf_Sym *Symbol,
|
||||||
return "COM";
|
return "COM";
|
||||||
case ELF::SHN_XINDEX: {
|
case ELF::SHN_XINDEX: {
|
||||||
Expected<uint32_t> IndexOrErr = object::getExtendedSymbolTableIndex<ELFT>(
|
Expected<uint32_t> IndexOrErr = object::getExtendedSymbolTableIndex<ELFT>(
|
||||||
*Symbol, *FirstSym, this->dumper()->getShndxTable());
|
*Symbol, SymIndex, this->dumper()->getShndxTable());
|
||||||
if (!IndexOrErr) {
|
if (!IndexOrErr) {
|
||||||
assert(Symbol->st_shndx == SHN_XINDEX &&
|
assert(Symbol->st_shndx == SHN_XINDEX &&
|
||||||
"getExtendedSymbolTableIndex should only fail due to an invalid "
|
"getExtendedSymbolTableIndex should only fail due to an invalid "
|
||||||
|
@ -3967,13 +3966,13 @@ std::string GNUStyle<ELFT>::getSymbolSectionNdx(const Elf_Sym *Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
void GNUStyle<ELFT>::printSymbol(const Elf_Sym *Symbol, const Elf_Sym *FirstSym,
|
void GNUStyle<ELFT>::printSymbol(const Elf_Sym *Symbol, unsigned SymIndex,
|
||||||
Optional<StringRef> StrTable, bool IsDynamic,
|
Optional<StringRef> StrTable, bool IsDynamic,
|
||||||
bool NonVisibilityBitsUsed) {
|
bool NonVisibilityBitsUsed) {
|
||||||
unsigned Bias = ELFT::Is64Bits ? 8 : 0;
|
unsigned Bias = ELFT::Is64Bits ? 8 : 0;
|
||||||
Field Fields[8] = {0, 8, 17 + Bias, 23 + Bias,
|
Field Fields[8] = {0, 8, 17 + Bias, 23 + Bias,
|
||||||
31 + Bias, 38 + Bias, 48 + Bias, 51 + Bias};
|
31 + Bias, 38 + Bias, 48 + Bias, 51 + Bias};
|
||||||
Fields[0].Str = to_string(format_decimal(Symbol - FirstSym, 6)) + ":";
|
Fields[0].Str = to_string(format_decimal(SymIndex, 6)) + ":";
|
||||||
Fields[1].Str = to_string(
|
Fields[1].Str = to_string(
|
||||||
format_hex_no_prefix(Symbol->st_value, ELFT::Is64Bits ? 16 : 8));
|
format_hex_no_prefix(Symbol->st_value, ELFT::Is64Bits ? 16 : 8));
|
||||||
Fields[2].Str = to_string(format_decimal(Symbol->st_size, 5));
|
Fields[2].Str = to_string(format_decimal(Symbol->st_size, 5));
|
||||||
|
@ -3994,7 +3993,7 @@ void GNUStyle<ELFT>::printSymbol(const Elf_Sym *Symbol, const Elf_Sym *FirstSym,
|
||||||
" [<other: " + to_string(format_hex(Symbol->st_other, 2)) + ">]";
|
" [<other: " + to_string(format_hex(Symbol->st_other, 2)) + ">]";
|
||||||
|
|
||||||
Fields[6].Column += NonVisibilityBitsUsed ? 13 : 0;
|
Fields[6].Column += NonVisibilityBitsUsed ? 13 : 0;
|
||||||
Fields[6].Str = getSymbolSectionNdx(Symbol, FirstSym);
|
Fields[6].Str = getSymbolSectionNdx(Symbol, SymIndex);
|
||||||
|
|
||||||
Fields[7].Str =
|
Fields[7].Str =
|
||||||
this->dumper()->getFullSymbolName(Symbol, StrTable, IsDynamic);
|
this->dumper()->getFullSymbolName(Symbol, StrTable, IsDynamic);
|
||||||
|
@ -4004,15 +4003,14 @@ void GNUStyle<ELFT>::printSymbol(const Elf_Sym *Symbol, const Elf_Sym *FirstSym,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
void GNUStyle<ELFT>::printHashedSymbol(const Elf_Sym *FirstSym, uint32_t Sym,
|
void GNUStyle<ELFT>::printHashedSymbol(const Elf_Sym *Symbol, unsigned SymIndex,
|
||||||
StringRef StrTable, uint32_t Bucket) {
|
StringRef StrTable, uint32_t Bucket) {
|
||||||
unsigned Bias = ELFT::Is64Bits ? 8 : 0;
|
unsigned Bias = ELFT::Is64Bits ? 8 : 0;
|
||||||
Field Fields[9] = {0, 6, 11, 20 + Bias, 25 + Bias,
|
Field Fields[9] = {0, 6, 11, 20 + Bias, 25 + Bias,
|
||||||
34 + Bias, 41 + Bias, 49 + Bias, 53 + Bias};
|
34 + Bias, 41 + Bias, 49 + Bias, 53 + Bias};
|
||||||
Fields[0].Str = to_string(format_decimal(Sym, 5));
|
Fields[0].Str = to_string(format_decimal(SymIndex, 5));
|
||||||
Fields[1].Str = to_string(format_decimal(Bucket, 3)) + ":";
|
Fields[1].Str = to_string(format_decimal(Bucket, 3)) + ":";
|
||||||
|
|
||||||
const auto Symbol = FirstSym + Sym;
|
|
||||||
Fields[2].Str = to_string(
|
Fields[2].Str = to_string(
|
||||||
format_hex_no_prefix(Symbol->st_value, ELFT::Is64Bits ? 16 : 8));
|
format_hex_no_prefix(Symbol->st_value, ELFT::Is64Bits ? 16 : 8));
|
||||||
Fields[3].Str = to_string(format_decimal(Symbol->st_size, 5));
|
Fields[3].Str = to_string(format_decimal(Symbol->st_size, 5));
|
||||||
|
@ -4028,7 +4026,7 @@ void GNUStyle<ELFT>::printHashedSymbol(const Elf_Sym *FirstSym, uint32_t Sym,
|
||||||
printEnum(Symbol->getBinding(), makeArrayRef(ElfSymbolBindings));
|
printEnum(Symbol->getBinding(), makeArrayRef(ElfSymbolBindings));
|
||||||
Fields[6].Str =
|
Fields[6].Str =
|
||||||
printEnum(Symbol->getVisibility(), makeArrayRef(ElfSymbolVisibilities));
|
printEnum(Symbol->getVisibility(), makeArrayRef(ElfSymbolVisibilities));
|
||||||
Fields[7].Str = getSymbolSectionNdx(Symbol, FirstSym);
|
Fields[7].Str = getSymbolSectionNdx(Symbol, SymIndex);
|
||||||
Fields[8].Str = this->dumper()->getFullSymbolName(Symbol, StrTable, true);
|
Fields[8].Str = this->dumper()->getFullSymbolName(Symbol, StrTable, true);
|
||||||
|
|
||||||
for (auto &Entry : Fields)
|
for (auto &Entry : Fields)
|
||||||
|
@ -4087,7 +4085,7 @@ void GNUStyle<ELFT>::printHashTableSymbols(const Elf_Hash &SysVHash) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printHashedSymbol(FirstSym, Ch, StringTable, Buc);
|
printHashedSymbol(FirstSym + Ch, Ch, StringTable, Buc);
|
||||||
Visited[Ch] = true;
|
Visited[Ch] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4118,7 +4116,8 @@ void GNUStyle<ELFT>::printGnuHashTableSymbols(const Elf_GnuHash &GnuHash) {
|
||||||
uint32_t GnuHashable = Index - GnuHash.symndx;
|
uint32_t GnuHashable = Index - GnuHash.symndx;
|
||||||
// Print whole chain
|
// Print whole chain
|
||||||
while (true) {
|
while (true) {
|
||||||
printHashedSymbol(FirstSym, Index++, StringTable, Buc);
|
uint32_t SymIndex = Index++;
|
||||||
|
printHashedSymbol(FirstSym + SymIndex, SymIndex, StringTable, Buc);
|
||||||
// Chain ends at symbol with stopper bit
|
// Chain ends at symbol with stopper bit
|
||||||
if ((GnuHash.values(DynSyms.size())[GnuHashable++] & 1) == 1)
|
if ((GnuHash.values(DynSyms.size())[GnuHashable++] & 1) == 1)
|
||||||
break;
|
break;
|
||||||
|
@ -5854,7 +5853,8 @@ void GNUStyle<ELFT>::printMipsGOT(const MipsGOTParser<ELFT> &Parser) {
|
||||||
OS.PadToColumn(40 + 3 * Bias);
|
OS.PadToColumn(40 + 3 * Bias);
|
||||||
OS << printEnum(Sym->getType(), makeArrayRef(ElfSymbolTypes));
|
OS << printEnum(Sym->getType(), makeArrayRef(ElfSymbolTypes));
|
||||||
OS.PadToColumn(48 + 3 * Bias);
|
OS.PadToColumn(48 + 3 * Bias);
|
||||||
OS << getSymbolSectionNdx(Sym, this->dumper()->dynamic_symbols().begin());
|
OS << getSymbolSectionNdx(
|
||||||
|
Sym, Sym - this->dumper()->dynamic_symbols().begin());
|
||||||
OS.PadToColumn(52 + 3 * Bias);
|
OS.PadToColumn(52 + 3 * Bias);
|
||||||
OS << SymName << "\n";
|
OS << SymName << "\n";
|
||||||
}
|
}
|
||||||
|
@ -5903,7 +5903,8 @@ void GNUStyle<ELFT>::printMipsPLT(const MipsGOTParser<ELFT> &Parser) {
|
||||||
OS.PadToColumn(29 + 3 * Bias);
|
OS.PadToColumn(29 + 3 * Bias);
|
||||||
OS << printEnum(Sym->getType(), makeArrayRef(ElfSymbolTypes));
|
OS << printEnum(Sym->getType(), makeArrayRef(ElfSymbolTypes));
|
||||||
OS.PadToColumn(37 + 3 * Bias);
|
OS.PadToColumn(37 + 3 * Bias);
|
||||||
OS << getSymbolSectionNdx(Sym, this->dumper()->dynamic_symbols().begin());
|
OS << getSymbolSectionNdx(
|
||||||
|
Sym, Sym - this->dumper()->dynamic_symbols().begin());
|
||||||
OS.PadToColumn(41 + 3 * Bias);
|
OS.PadToColumn(41 + 3 * Bias);
|
||||||
OS << SymName << "\n";
|
OS << SymName << "\n";
|
||||||
}
|
}
|
||||||
|
@ -6146,17 +6147,15 @@ template <class ELFT> void LLVMStyle<ELFT>::printSectionHeaders() {
|
||||||
StringRef StrTable = unwrapOrError(
|
StringRef StrTable = unwrapOrError(
|
||||||
this->FileName, this->Obj.getStringTableForSymtab(*Symtab));
|
this->FileName, this->Obj.getStringTableForSymtab(*Symtab));
|
||||||
|
|
||||||
for (const Elf_Sym &Sym :
|
typename ELFT::SymRange Symbols =
|
||||||
unwrapOrError(this->FileName, this->Obj.symbols(Symtab))) {
|
unwrapOrError(this->FileName, this->Obj.symbols(Symtab));
|
||||||
|
for (const Elf_Sym &Sym : Symbols) {
|
||||||
const Elf_Shdr *SymSec =
|
const Elf_Shdr *SymSec =
|
||||||
unwrapOrError(this->FileName,
|
unwrapOrError(this->FileName,
|
||||||
this->Obj.getSection(
|
this->Obj.getSection(
|
||||||
Sym, Symtab, this->dumper()->getShndxTable()));
|
Sym, Symtab, this->dumper()->getShndxTable()));
|
||||||
if (SymSec == &Sec)
|
if (SymSec == &Sec)
|
||||||
printSymbol(&Sym,
|
printSymbol(&Sym, &Sym - &Symbols[0], StrTable, false, false);
|
||||||
unwrapOrError(this->FileName, this->Obj.symbols(Symtab))
|
|
||||||
.begin(),
|
|
||||||
StrTable, false, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6173,7 +6172,7 @@ template <class ELFT> void LLVMStyle<ELFT>::printSectionHeaders() {
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
void LLVMStyle<ELFT>::printSymbolSection(const Elf_Sym *Symbol,
|
void LLVMStyle<ELFT>::printSymbolSection(const Elf_Sym *Symbol,
|
||||||
const Elf_Sym *First) {
|
unsigned SymIndex) {
|
||||||
auto GetSectionSpecialType = [&]() -> Optional<StringRef> {
|
auto GetSectionSpecialType = [&]() -> Optional<StringRef> {
|
||||||
if (Symbol->isUndefined())
|
if (Symbol->isUndefined())
|
||||||
return StringRef("Undefined");
|
return StringRef("Undefined");
|
||||||
|
@ -6196,7 +6195,7 @@ void LLVMStyle<ELFT>::printSymbolSection(const Elf_Sym *Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
Expected<unsigned> SectionIndex =
|
Expected<unsigned> SectionIndex =
|
||||||
this->dumper()->getSymbolSectionIndex(Symbol, First);
|
this->dumper()->getSymbolSectionIndex(Symbol, SymIndex);
|
||||||
if (!SectionIndex) {
|
if (!SectionIndex) {
|
||||||
assert(Symbol->st_shndx == SHN_XINDEX &&
|
assert(Symbol->st_shndx == SHN_XINDEX &&
|
||||||
"getSymbolSectionIndex should only fail due to an invalid "
|
"getSymbolSectionIndex should only fail due to an invalid "
|
||||||
|
@ -6222,7 +6221,7 @@ void LLVMStyle<ELFT>::printSymbolSection(const Elf_Sym *Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
void LLVMStyle<ELFT>::printSymbol(const Elf_Sym *Symbol, const Elf_Sym *First,
|
void LLVMStyle<ELFT>::printSymbol(const Elf_Sym *Symbol, unsigned SymIndex,
|
||||||
Optional<StringRef> StrTable, bool IsDynamic,
|
Optional<StringRef> StrTable, bool IsDynamic,
|
||||||
bool /*NonVisibilityBitsUsed*/) {
|
bool /*NonVisibilityBitsUsed*/) {
|
||||||
std::string FullSymbolName =
|
std::string FullSymbolName =
|
||||||
|
@ -6261,7 +6260,7 @@ void LLVMStyle<ELFT>::printSymbol(const Elf_Sym *Symbol, const Elf_Sym *First,
|
||||||
}
|
}
|
||||||
W.printFlags("Other", Symbol->st_other, makeArrayRef(SymOtherFlags), 0x3u);
|
W.printFlags("Other", Symbol->st_other, makeArrayRef(SymOtherFlags), 0x3u);
|
||||||
}
|
}
|
||||||
printSymbolSection(Symbol, First);
|
printSymbolSection(Symbol, SymIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
|
@ -6765,7 +6764,7 @@ void LLVMStyle<ELFT>::printMipsGOT(const MipsGOTParser<ELFT> &Parser) {
|
||||||
const Elf_Sym *Sym = Parser.getGotSym(&E);
|
const Elf_Sym *Sym = Parser.getGotSym(&E);
|
||||||
W.printHex("Value", Sym->st_value);
|
W.printHex("Value", Sym->st_value);
|
||||||
W.printEnum("Type", Sym->getType(), makeArrayRef(ElfSymbolTypes));
|
W.printEnum("Type", Sym->getType(), makeArrayRef(ElfSymbolTypes));
|
||||||
printSymbolSection(Sym, this->dumper()->dynamic_symbols().begin());
|
printSymbolSection(Sym, Sym - this->dumper()->dynamic_symbols().begin());
|
||||||
|
|
||||||
std::string SymName = this->dumper()->getFullSymbolName(
|
std::string SymName = this->dumper()->getFullSymbolName(
|
||||||
Sym, this->dumper()->getDynamicStringTable(), true);
|
Sym, this->dumper()->getDynamicStringTable(), true);
|
||||||
|
@ -6809,7 +6808,7 @@ void LLVMStyle<ELFT>::printMipsPLT(const MipsGOTParser<ELFT> &Parser) {
|
||||||
const Elf_Sym *Sym = Parser.getPltSym(&E);
|
const Elf_Sym *Sym = Parser.getPltSym(&E);
|
||||||
W.printHex("Value", Sym->st_value);
|
W.printHex("Value", Sym->st_value);
|
||||||
W.printEnum("Type", Sym->getType(), makeArrayRef(ElfSymbolTypes));
|
W.printEnum("Type", Sym->getType(), makeArrayRef(ElfSymbolTypes));
|
||||||
printSymbolSection(Sym, this->dumper()->dynamic_symbols().begin());
|
printSymbolSection(Sym, Sym - this->dumper()->dynamic_symbols().begin());
|
||||||
|
|
||||||
std::string SymName =
|
std::string SymName =
|
||||||
this->dumper()->getFullSymbolName(Sym, Parser.getPltStrTable(), true);
|
this->dumper()->getFullSymbolName(Sym, Parser.getPltStrTable(), true);
|
||||||
|
|
Loading…
Reference in New Issue