Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/tools/llvm-readobj/ELFDumper.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | unsigned getHashTableEntSize() const { | ||||||||
// EM_S390 and ELF::EM_ALPHA platforms use 8-bytes entries in SHT_HASH | // EM_S390 and ELF::EM_ALPHA platforms use 8-bytes entries in SHT_HASH | ||||||||
// sections. This violates the ELF specification. | // sections. This violates the ELF specification. | ||||||||
if (Obj.getHeader().e_machine == ELF::EM_S390 || | if (Obj.getHeader().e_machine == ELF::EM_S390 || | ||||||||
Obj.getHeader().e_machine == ELF::EM_ALPHA) | Obj.getHeader().e_machine == ELF::EM_ALPHA) | ||||||||
return 8; | return 8; | ||||||||
return 4; | return 4; | ||||||||
} | } | ||||||||
std::vector<EnumEntry<unsigned>> | |||||||||
getOtherFlagsFromSymbol(const Elf_Ehdr &Header, const Elf_Sym &Symbol) const; | |||||||||
Elf_Dyn_Range dynamic_table() const { | Elf_Dyn_Range dynamic_table() const { | ||||||||
// A valid .dynamic section contains an array of entries terminated | // A valid .dynamic section contains an array of entries terminated | ||||||||
// with a DT_NULL entry. However, sometimes the section content may | // with a DT_NULL entry. However, sometimes the section content may | ||||||||
// continue past the DT_NULL entry, so to dump the section correctly, | // continue past the DT_NULL entry, so to dump the section correctly, | ||||||||
// we first find the end of the entries by iterating over them. | // we first find the end of the entries by iterating over them. | ||||||||
Elf_Dyn_Range Table = DynamicTable.template getAsArrayRef<Elf_Dyn>(); | Elf_Dyn_Range Table = DynamicTable.template getAsArrayRef<Elf_Dyn>(); | ||||||||
size_t Size = 0; | size_t Size = 0; | ||||||||
▲ Show 20 Lines • Show All 2,989 Lines • ▼ Show 20 Lines | void ELFDumper<ELFT>::printReloc(const Relocation<ELFT> &R, unsigned RelIndex, | ||||||||
if (!Target) | if (!Target) | ||||||||
reportUniqueWarning("unable to print relocation " + Twine(RelIndex) + | reportUniqueWarning("unable to print relocation " + Twine(RelIndex) + | ||||||||
" in " + describe(Sec) + ": " + | " in " + describe(Sec) + ": " + | ||||||||
toString(Target.takeError())); | toString(Target.takeError())); | ||||||||
else | else | ||||||||
printRelRelaReloc(R, *Target); | printRelRelaReloc(R, *Target); | ||||||||
} | } | ||||||||
template <class ELFT> | |||||||||
std::vector<EnumEntry<unsigned>> | |||||||||
ELFDumper<ELFT>::getOtherFlagsFromSymbol(const Elf_Ehdr &Header, | |||||||||
const Elf_Sym &Symbol) const { | |||||||||
std::vector<EnumEntry<unsigned>> SymOtherFlags(std::begin(ElfSymOtherFlags), | |||||||||
std::end(ElfSymOtherFlags)); | |||||||||
if (Header.e_machine == EM_MIPS) { | |||||||||
// Someones in their infinite wisdom decided to make STO_MIPS_MIPS16 | |||||||||
jhenderson: Whilst moving this line, please fix the "Somones" typo (it should be "Someone"). | |||||||||
// flag overlapped with other ST_MIPS_xxx flags. So consider both | |||||||||
Same logic as above. jhenderson: Same logic as above. | |||||||||
// cases separately. | |||||||||
if ((Symbol.st_other & STO_MIPS_MIPS16) == STO_MIPS_MIPS16) | |||||||||
SymOtherFlags.insert(SymOtherFlags.end(), | |||||||||
std::begin(ElfMips16SymOtherFlags), | |||||||||
std::end(ElfMips16SymOtherFlags)); | |||||||||
else | |||||||||
SymOtherFlags.insert(SymOtherFlags.end(), | |||||||||
std::begin(ElfMipsSymOtherFlags), | |||||||||
std::end(ElfMipsSymOtherFlags)); | |||||||||
} else if (Header.e_machine == EM_AARCH64) { | |||||||||
SymOtherFlags.insert(SymOtherFlags.end(), | |||||||||
std::begin(ElfAArch64SymOtherFlags), | |||||||||
std::end(ElfAArch64SymOtherFlags)); | |||||||||
} else if (Header.e_machine == EM_RISCV) { | |||||||||
SymOtherFlags.insert(SymOtherFlags.end(), std::begin(ElfRISCVSymOtherFlags), | |||||||||
std::end(ElfRISCVSymOtherFlags)); | |||||||||
} | |||||||||
return SymOtherFlags; | |||||||||
} | |||||||||
static inline void printFields(formatted_raw_ostream &OS, StringRef Str1, | static inline void printFields(formatted_raw_ostream &OS, StringRef Str1, | ||||||||
StringRef Str2) { | StringRef Str2) { | ||||||||
OS.PadToColumn(2u); | OS.PadToColumn(2u); | ||||||||
OS << Str1; | OS << Str1; | ||||||||
OS.PadToColumn(37u); | OS.PadToColumn(37u); | ||||||||
OS << Str2 << "\n"; | OS << Str2 << "\n"; | ||||||||
OS.flush(); | OS.flush(); | ||||||||
} | } | ||||||||
▲ Show 20 Lines • Show All 3,543 Lines • ▼ Show 20 Lines | if (this->Obj.getHeader().e_machine == ELF::EM_AMDGPU && | ||||||||
W.printEnum("Type", SymbolType, makeArrayRef(AMDGPUSymbolTypes)); | W.printEnum("Type", SymbolType, makeArrayRef(AMDGPUSymbolTypes)); | ||||||||
else | else | ||||||||
W.printEnum("Type", SymbolType, makeArrayRef(ElfSymbolTypes)); | W.printEnum("Type", SymbolType, makeArrayRef(ElfSymbolTypes)); | ||||||||
if (Symbol.st_other == 0) | if (Symbol.st_other == 0) | ||||||||
// Usually st_other flag is zero. Do not pollute the output | // Usually st_other flag is zero. Do not pollute the output | ||||||||
// by flags enumeration in that case. | // by flags enumeration in that case. | ||||||||
W.printNumber("Other", 0); | W.printNumber("Other", 0); | ||||||||
else { | else { | ||||||||
std::vector<EnumEntry<unsigned>> SymOtherFlags(std::begin(ElfSymOtherFlags), | std::vector<EnumEntry<unsigned>> SymOtherFlags = | ||||||||
std::end(ElfSymOtherFlags)); | this->getOtherFlagsFromSymbol(this->Obj.getHeader(), Symbol); | ||||||||
if (this->Obj.getHeader().e_machine == EM_MIPS) { | |||||||||
// Someones in their infinite wisdom decided to make STO_MIPS_MIPS16 | |||||||||
// flag overlapped with other ST_MIPS_xxx flags. So consider both | |||||||||
// cases separately. | |||||||||
if ((Symbol.st_other & STO_MIPS_MIPS16) == STO_MIPS_MIPS16) | |||||||||
SymOtherFlags.insert(SymOtherFlags.end(), | |||||||||
std::begin(ElfMips16SymOtherFlags), | |||||||||
std::end(ElfMips16SymOtherFlags)); | |||||||||
else | |||||||||
SymOtherFlags.insert(SymOtherFlags.end(), | |||||||||
std::begin(ElfMipsSymOtherFlags), | |||||||||
std::end(ElfMipsSymOtherFlags)); | |||||||||
} else if (this->Obj.getHeader().e_machine == EM_AARCH64) { | |||||||||
SymOtherFlags.insert(SymOtherFlags.end(), | |||||||||
std::begin(ElfAArch64SymOtherFlags), | |||||||||
std::end(ElfAArch64SymOtherFlags)); | |||||||||
} else if (this->Obj.getHeader().e_machine == EM_RISCV) { | |||||||||
SymOtherFlags.insert(SymOtherFlags.end(), | |||||||||
std::begin(ElfRISCVSymOtherFlags), | |||||||||
std::end(ElfRISCVSymOtherFlags)); | |||||||||
} | |||||||||
W.printFlags("Other", Symbol.st_other, makeArrayRef(SymOtherFlags), 0x3u); | W.printFlags("Other", Symbol.st_other, makeArrayRef(SymOtherFlags), 0x3u); | ||||||||
} | } | ||||||||
printSymbolSection(Symbol, SymIndex, ShndxTable); | printSymbolSection(Symbol, SymIndex, ShndxTable); | ||||||||
} | } | ||||||||
template <class ELFT> | template <class ELFT> | ||||||||
void LLVMELFDumper<ELFT>::printSymbols(bool PrintSymbols, | void LLVMELFDumper<ELFT>::printSymbols(bool PrintSymbols, | ||||||||
bool PrintDynamicSymbols) { | bool PrintDynamicSymbols) { | ||||||||
▲ Show 20 Lines • Show All 713 Lines • Show Last 20 Lines |
Whilst moving this line, please fix the "Somones" typo (it should be "Someone").