};
template <typename T, typename TEnum>
- std::string printEnum(T Value, ArrayRef<EnumEntry<TEnum>> EnumValues) const {
- for (const EnumEntry<TEnum> &EnumItem : EnumValues)
- if (EnumItem.Value == Value)
- return std::string(EnumItem.AltName);
- return to_hexString(Value, false);
- }
-
- template <typename T, typename TEnum>
std::string printFlags(T Value, ArrayRef<EnumEntry<TEnum>> EnumValues,
TEnum EnumMask1 = {}, TEnum EnumMask2 = {},
TEnum EnumMask3 = {}) const {
for (int i = 0; i < ELF::EI_NIDENT; i++)
OS << format(" %02x", static_cast<int>(e.e_ident[i]));
OS << "\n";
- Str = printEnum(e.e_ident[ELF::EI_CLASS], makeArrayRef(ElfClass));
+ Str = enumToString(e.e_ident[ELF::EI_CLASS], makeArrayRef(ElfClass));
printFields(OS, "Class:", Str);
- Str = printEnum(e.e_ident[ELF::EI_DATA], makeArrayRef(ElfDataEncoding));
+ Str = enumToString(e.e_ident[ELF::EI_DATA], makeArrayRef(ElfDataEncoding));
printFields(OS, "Data:", Str);
OS.PadToColumn(2u);
OS << "Version:";
if (e.e_version == ELF::EV_CURRENT)
OS << " (current)";
OS << "\n";
- Str = printEnum(e.e_ident[ELF::EI_OSABI], makeArrayRef(ElfOSABI));
+ Str = enumToString(e.e_ident[ELF::EI_OSABI], makeArrayRef(ElfOSABI));
printFields(OS, "OS/ABI:", Str);
printFields(OS,
"ABI Version:", std::to_string(e.e_ident[ELF::EI_ABIVERSION]));
}
printFields(OS, "Type:", Str);
- Str = printEnum(e.e_machine, makeArrayRef(ElfMachineType));
+ Str = enumToString(e.e_machine, makeArrayRef(ElfMachineType));
printFields(OS, "Machine:", Str);
Str = "0x" + to_hexString(e.e_version);
printFields(OS, "Version:", Str);
unsigned char SymbolType = Symbol.getType();
if (this->Obj.getHeader().e_machine == ELF::EM_AMDGPU &&
SymbolType >= ELF::STT_LOOS && SymbolType < ELF::STT_HIOS)
- Fields[3].Str = printEnum(SymbolType, makeArrayRef(AMDGPUSymbolTypes));
+ Fields[3].Str = enumToString(SymbolType, makeArrayRef(AMDGPUSymbolTypes));
else
- Fields[3].Str = printEnum(SymbolType, makeArrayRef(ElfSymbolTypes));
+ Fields[3].Str = enumToString(SymbolType, makeArrayRef(ElfSymbolTypes));
Fields[4].Str =
- printEnum(Symbol.getBinding(), makeArrayRef(ElfSymbolBindings));
+ enumToString(Symbol.getBinding(), makeArrayRef(ElfSymbolBindings));
Fields[5].Str =
- printEnum(Symbol.getVisibility(), makeArrayRef(ElfSymbolVisibilities));
+ enumToString(Symbol.getVisibility(), makeArrayRef(ElfSymbolVisibilities));
if (Symbol.st_other & ~0x3) {
if (this->Obj.getHeader().e_machine == ELF::EM_AARCH64) {
unsigned char SymbolType = Symbol->getType();
if (this->Obj.getHeader().e_machine == ELF::EM_AMDGPU &&
SymbolType >= ELF::STT_LOOS && SymbolType < ELF::STT_HIOS)
- Fields[4].Str = printEnum(SymbolType, makeArrayRef(AMDGPUSymbolTypes));
+ Fields[4].Str = enumToString(SymbolType, makeArrayRef(AMDGPUSymbolTypes));
else
- Fields[4].Str = printEnum(SymbolType, makeArrayRef(ElfSymbolTypes));
+ Fields[4].Str = enumToString(SymbolType, makeArrayRef(ElfSymbolTypes));
Fields[5].Str =
- printEnum(Symbol->getBinding(), makeArrayRef(ElfSymbolBindings));
- Fields[6].Str =
- printEnum(Symbol->getVisibility(), makeArrayRef(ElfSymbolVisibilities));
+ enumToString(Symbol->getBinding(), makeArrayRef(ElfSymbolBindings));
+ Fields[6].Str = enumToString(Symbol->getVisibility(),
+ makeArrayRef(ElfSymbolVisibilities));
Fields[7].Str = getSymbolSectionNdx(*Symbol, SymIndex, ShndxTable);
Fields[8].Str =
this->getFullSymbolName(*Symbol, SymIndex, ShndxTable, StrTable, true);
Field Fields[8] = {2, 17, 26, 37 + Bias,
48 + Bias, 56 + Bias, 64 + Bias, 68 + Bias};
OS << "\nElf file type is "
- << printEnum(Header.e_type, makeArrayRef(ElfObjectFileType)) << "\n"
+ << enumToString(Header.e_type, makeArrayRef(ElfObjectFileType)) << "\n"
<< "Entry point " << format_hex(Header.e_entry, 3) << "\n"
<< "There are " << Header.e_phnum << " program headers,"
<< " starting at offset " << Header.e_phoff << "\n\n"
OS.PadToColumn(31 + 2 * Bias);
OS << to_string(format_hex_no_prefix(Sym.st_value, 8 + Bias));
OS.PadToColumn(40 + 3 * Bias);
- OS << printEnum(Sym.getType(), makeArrayRef(ElfSymbolTypes));
+ OS << enumToString(Sym.getType(), makeArrayRef(ElfSymbolTypes));
OS.PadToColumn(48 + 3 * Bias);
OS << getSymbolSectionNdx(Sym, &Sym - this->dynamic_symbols().begin(),
ShndxTable);
OS.PadToColumn(20 + 2 * Bias);
OS << to_string(format_hex_no_prefix(Sym.st_value, 8 + Bias));
OS.PadToColumn(29 + 3 * Bias);
- OS << printEnum(Sym.getType(), makeArrayRef(ElfSymbolTypes));
+ OS << enumToString(Sym.getType(), makeArrayRef(ElfSymbolTypes));
OS.PadToColumn(37 + 3 * Bias);
OS << getSymbolSectionNdx(Sym, &Sym - this->dynamic_symbols().begin(),
ShndxTable);
OS << "GPR size: " << getMipsRegisterSize(Flags->gpr_size) << "\n";
OS << "CPR1 size: " << getMipsRegisterSize(Flags->cpr1_size) << "\n";
OS << "CPR2 size: " << getMipsRegisterSize(Flags->cpr2_size) << "\n";
- OS << "FP ABI: " << printEnum(Flags->fp_abi, makeArrayRef(ElfMipsFpABIType))
- << "\n";
+ OS << "FP ABI: "
+ << enumToString(Flags->fp_abi, makeArrayRef(ElfMipsFpABIType)) << "\n";
OS << "ISA Extension: "
- << printEnum(Flags->isa_ext, makeArrayRef(ElfMipsISAExtType)) << "\n";
+ << enumToString(Flags->isa_ext, makeArrayRef(ElfMipsISAExtType)) << "\n";
if (Flags->ases == 0)
OS << "ASEs: None\n";
else