Lines Matching +full:loongson +full:- +full:1 +full:c

1 //===- ELFDumper.cpp - ELF-specific dumper --------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// This file implements the ELF-specific dumper for llvm-readobj.
12 //===----------------------------------------------------------------------===//
18 #include "llvm-readobj.h"
136 Addr - (const uint8_t *)Obj->getMemoryBufferRef().getBufferStart();
137 const uint64_t ObjSize = Obj->getMemoryBufferRef().getBufferSize();
139 if (Size > ObjSize - Offset) {
140 Dumper->reportUniqueWarning(
162 Dumper->reportUniqueWarning(Msg);
241 // EM_S390 and ELF::EM_ALPHA platforms use 8-bytes entries in SHT_HASH
270 return DynSymRegion->template getAsArrayRef<Elf_Sym>();
451 if ((*SymtabOrErr)->sh_type != ExpectedType)
457 (*SymtabOrErr)->sh_type));
499 if (SymTabOrErr->Symbols.size() != VersionsOrErr->size())
501 Twine(VersionsOrErr->size()) +
503 Twine(SymTabOrErr->Symbols.size()) +
508 *SymTab = SymTabOrErr->Symbols;
509 *StrTab = SymTabOrErr->StringTable;
510 *SymTabSec = SymTabOrErr->SymTab;
551 Entries = DotSymtabSec->getEntityCount();
557 // visibility (STV_*) and the remainder hold other platform-specific values.
563 (const Elf_Word *)this->DynSymTabShndxRegion.Addr,
564 this->getElfObject().getELFFile().end())
565 : DataRegion<Elf_Word>(this->getShndxTable(SymtabSec));
569 printSymbol(Sym, &Sym - Syms.begin(), ShndxTable, StrTable, IsDynamic,
582 assert(&this->W.getOStream() == &llvm::fouts());
821 // Little-endian 32-bit
825 // Big-endian 32-bit
829 // Little-endian 64-bit
833 // Big-endian 64-bit
869 size_t EntryIndex = (reinterpret_cast<uintptr_t>(&Sym) -
870 reinterpret_cast<uintptr_t>(DynSymRegion->Addr)) /
879 unsigned Version = (*EntryOrErr)->vs_index;
918 getFullSymbolName(*Sym, Sym - FirstSym, getShndxTable(SymTab),
919 *StrTableOrErr, SymTab->sh_type == SHT_DYNSYM);
929 return It->second;
940 auto Warn = [&](Error E) -> std::string {
955 Expected<StringRef> NameOrErr = (*SymOrErr)->getName(*StrTabOrErr);
1001 if (!VersionOrErr->empty()) {
1032 return CreateErr("SHN_LOPROC", Ndx - ELF::SHN_LOPROC);
1034 return CreateErr("SHN_LOOS", Ndx - ELF::SHN_LOOS);
1041 return CreateErr("SHN_LORESERVE", Ndx - SHN_LORESERVE);
1066 {"32-bit", "ELF32", ELF::ELFCLASS32},
1067 {"64-bit", "ELF64", ELF::ELFCLASS64},
1085 {"SystemV", "UNIX - System V", ELF::ELFOSABI_NONE},
1086 {"HPUX", "UNIX - HP-UX", ELF::ELFOSABI_HPUX},
1087 {"NetBSD", "UNIX - NetBSD", ELF::ELFOSABI_NETBSD},
1088 {"GNU/Linux", "UNIX - GNU", ELF::ELFOSABI_LINUX},
1090 {"Solaris", "UNIX - Solaris", ELF::ELFOSABI_SOLARIS},
1091 {"AIX", "UNIX - AIX", ELF::ELFOSABI_AIX},
1092 {"IRIX", "UNIX - IRIX", ELF::ELFOSABI_IRIX},
1093 {"FreeBSD", "UNIX - FreeBSD", ELF::ELFOSABI_FREEBSD},
1094 {"TRU64", "UNIX - TRU64", ELF::ELFOSABI_TRU64},
1095 {"Modesto", "Novell - Modesto", ELF::ELFOSABI_MODESTO},
1096 {"OpenBSD", "UNIX - OpenBSD", ELF::ELFOSABI_OPENBSD},
1097 {"OpenVMS", "VMS - OpenVMS", ELF::ELFOSABI_OPENVMS},
1098 {"NSK", "HP - Non-Stop Kernel", ELF::ELFOSABI_NSK},
1102 {"CUDA", "NVIDIA - CUDA", ELF::ELFOSABI_CUDA},
1107 {"AMDGPU_HSA", "AMDGPU - HSA", ELF::ELFOSABI_AMDGPU_HSA},
1108 {"AMDGPU_PAL", "AMDGPU - PAL", ELF::ELFOSABI_AMDGPU_PAL},
1109 {"AMDGPU_MESA3D", "AMDGPU - MESA3D", ELF::ELFOSABI_AMDGPU_MESA3D}
1118 {"C6000_ELFABI", "Bare-metal C6000", ELF::ELFOSABI_C6000_ELFABI},
1133 ENUM_ENT(EM_MIPS_RS3_LE, "MIPS R3000 little-endian"),
1144 ENUM_ENT(EM_RH32, "TRW RH-32"),
1156 ENUM_ENT(EM_IA_64, "Intel IA-64"),
1157 ENUM_ENT(EM_MIPS_X, "Stanford MIPS-X"),
1168 ENUM_ENT(EM_X86_64, "Advanced Micro Devices X86-64"),
1170 ENUM_ENT(EM_PDP10, "Digital Equipment Corp. PDP-10"),
1171 ENUM_ENT(EM_PDP11, "Digital Equipment Corp. PDP-11"),
1174 ENUM_ENT(EM_ST7, "STMicroelectronics ST7 8-bit microcontroller"),
1180 ENUM_ENT(EM_ST19, "STMicroelectronics ST19 8-bit microcontroller"),
1182 ENUM_ENT(EM_CRIS, "Axis Communications 32-bit embedded processor"),
1183 ENUM_ENT(EM_JAVELIN, "Infineon Technologies 32-bit embedded cpu"),
1184 ENUM_ENT(EM_FIREPATH, "Element 14 64-bit DSP processor"),
1185 ENUM_ENT(EM_ZSP, "LSI Logic's 16-bit DSP processor"),
1186 ENUM_ENT(EM_MMIX, "Donald Knuth's educational 64-bit processor"),
1187 ENUM_ENT(EM_HUANY, "Harvard Universitys's machine-independent object format"),
1189 ENUM_ENT(EM_AVR, "Atmel AVR 8-bit microcontroller"),
1198 ENUM_ENT(EM_OPENRISC, "OpenRISC 32-bit embedded processor"),
1207 ENUM_ENT(EM_IP2K, "Ubicom IP2xxx 8-bit microcontrollers"),
1217 ENUM_ENT(EM_EXCESS, "eXcess 16/32/64-bit configurable embedded CPU"),
1232 ENUM_ENT(EM_DSP24, "New Japan Radio (NJR) 24-bit DSP Processor"),
1252 ENUM_ENT(EM_XIMO16, "New Japan Radio (NJR) 16-bit DSP Processor"),
1259 ENUM_ENT(EM_CR16, "National Semiconductor CompactRISC 16-bit processor"),
1265 ENUM_ENT(EM_AVR32, "Atmel Corporation 32-bit microprocessor family"),
1266 ENUM_ENT(EM_STM8, "STMicroeletronics STM8 8-bit microcontroller"),
1269 ENUM_ENT(EM_MICROBLAZE, "Xilinx MicroBlaze 32-bit RISC soft processor core"),
1271 ENUM_ENT(EM_TILEGX, "Tilera TILE-Gx multicore architecture family"),
1282 ENUM_ENT(EM_RISCV, "RISC-V"),
1285 ENUM_ENT(EM_VE, "NEC SX-Aurora Vector Engine"),
1323 ENUM_ENT(SHF_COMPRESSED, "C"),
1419 uint64_t Flag = Flags & -Flags;
1420 Flags -= Flag;
1428 Str += I->AltName;
1439 // Mask off all the processor-specific bits. This removes the SHF_EXCLUDE
1458 // Check potentially overlapped processor-specific program header type.
1507 return std::string("<unknown>: ") + to_string(format_hex(Type, 1));
1509 // E.g. "PT_ARM_EXIDX" -> "EXIDX".
1513 // E.g. "PT_MIPS_REGINFO" -> "REGINFO".
1521 // E.g. "PT_LOAD" -> "LOAD".
1559 ENUM_ENT(EF_MIPS_MACH_LS2E, "loongson-2e"),
1560 ENUM_ENT(EF_MIPS_MACH_LS2F, "loongson-2f"),
1561 ENUM_ENT(EF_MIPS_MACH_LS3A, "loongson-3a"),
1578 // clang-format off
1642 ENUM_ENT(EF_AMDGPU_MACH_AMDGCN_GFX9_GENERIC, "gfx9-generic"), \
1643 ENUM_ENT(EF_AMDGPU_MACH_AMDGCN_GFX10_1_GENERIC, "gfx10-1-generic"), \
1644 ENUM_ENT(EF_AMDGPU_MACH_AMDGCN_GFX10_3_GENERIC, "gfx10-3-generic"), \
1645 ENUM_ENT(EF_AMDGPU_MACH_AMDGCN_GFX11_GENERIC, "gfx11-generic"), \
1646 ENUM_ENT(EF_AMDGPU_MACH_AMDGCN_GFX12_GENERIC, "gfx12-generic")
1647 // clang-format on
1658 ENUM_ENT(EF_AMDGPU_FEATURE_XNACK_OFF_V4, "xnack-"),
1661 ENUM_ENT(EF_AMDGPU_FEATURE_SRAMECC_OFF_V4, "sramecc-"),
1680 ENUM_ENT(EF_RISCV_FLOAT_ABI_SINGLE, "single-float ABI"),
1681 ENUM_ENT(EF_RISCV_FLOAT_ABI_DOUBLE, "double-float ABI"),
1682 ENUM_ENT(EF_RISCV_FLOAT_ABI_QUAD, "quad-float ABI"),
1710 ENUM_ENT(EF_LOONGARCH_ABI_SOFT_FLOAT, "SOFT-FLOAT"),
1711 ENUM_ENT(EF_LOONGARCH_ABI_SINGLE_FLOAT, "SINGLE-FLOAT"),
1712 ENUM_ENT(EF_LOONGARCH_ABI_DOUBLE_FLOAT, "DOUBLE-FLOAT"),
1713 ENUM_ENT(EF_LOONGARCH_OBJABI_V0, "OBJ-v0"),
1714 ENUM_ENT(EF_LOONGARCH_OBJABI_V1, "OBJ-v1"),
1795 if (DynamicPhdr && ((DynamicPhdr->p_offset + DynamicPhdr->p_filesz >
1797 (DynamicPhdr->p_offset + DynamicPhdr->p_filesz <
1798 DynamicPhdr->p_offset))) {
1801 Twine::utohexstr(DynamicPhdr->p_offset) + ") + file size (0x" +
1802 Twine::utohexstr(DynamicPhdr->p_filesz) +
1810 if (DynamicSec->sh_addr + DynamicSec->sh_size >
1811 DynamicPhdr->p_vaddr + DynamicPhdr->p_memsz ||
1812 DynamicSec->sh_addr < DynamicPhdr->p_vaddr)
1817 if (DynamicSec->sh_addr != DynamicPhdr->p_vaddr)
1838 FromPhdr = cantFail(createDRI(DynamicPhdr->p_offset, DynamicPhdr->p_filesz,
1853 createDRI(DynamicSec->sh_offset, DynamicSec->sh_size, sizeof(Elf_Dyn));
1935 DynSymRegion->Context = describe(Sec);
1995 auto toMappedAddr = [&](uint64_t Tag, uint64_t VAddr) -> const uint8_t * {
1997 this->reportUniqueWarning(Msg);
2001 this->reportUniqueWarning("unable to parse DT_" +
2046 DynSymFromTable->Addr = VA;
2047 DynSymFromTable->EntSize = sizeof(Elf_Sym);
2048 DynSymFromTable->EntSizePrintName = "";
2055 this->reportUniqueWarning("DT_SYMENT value of 0x" +
2116 DynPLTRelRegion.EntSize = 1;
2138 const uint64_t Offset = (const uint8_t *)StringTableBegin - Obj.base();
2139 if (StringTableSize > FileSize - Offset)
2155 if (DynSymFromTable && DynSymFromTable->Addr != DynSymRegion->Addr)
2165 if (DynSymRegion->EntSize == 0)
2167 else if (HashTable->nchain != DynSymRegion->Size / DynSymRegion->EntSize)
2169 "hash table nchain (" + Twine(HashTable->nchain) +
2172 Twine(DynSymRegion->Size / DynSymRegion->EntSize) + ")");
2177 // checks can always be made against the section header-based properties,
2183 DynSymRegion->Addr = DynSymFromTable->Addr;
2184 DynSymRegion->EntSize = DynSymFromTable->EntSize;
2185 DynSymRegion->EntSizePrintName = DynSymFromTable->EntSizePrintName;
2194 (uint64_t)HashTable->nchain * DynSymRegion->EntSize;
2195 const uint64_t Offset = (const uint8_t *)DynSymRegion->Addr - Obj.base();
2196 if (DerivedSize > FileSize - Offset)
2203 DynSymRegion->Size = HashTable->nchain * DynSymRegion->EntSize;
2339 case 1:
2340 return "Asynchronous (1)";
2349 case 1:
2350 return "Enabled (1)";
2522 (const uint8_t *)DynamicStringTable.data() - Obj.base();
2523 if (DynamicStringTable.size() > FileSize - Offset)
2540 ": the string table is not null-terminated",
2583 const uint64_t SecOffset = (const uint8_t *)H - Obj.base();
2591 " is not supported: it contains non-standard 8 "
2593 It->AltName + " platform");
2603 // Each SHT_HASH section starts from two 32-bit fields: nbucket and nchain.
2607 *IsHeaderValid = Obj.getBufSize() - SecOffset >= HeaderSize;
2609 if (Obj.getBufSize() - SecOffset < HeaderSize)
2612 if (Obj.getBufSize() - SecOffset - HeaderSize <
2613 ((uint64_t)H->nbucket + H->nchain) * sizeof(typename ELFT::Word))
2614 return MakeError(", nbucket = " + Twine(H->nbucket) +
2615 ", nchain = " + Twine(H->nchain));
2627 uint64_t TableOffset = TableData - Obj.base();
2630 if (TableOffset + 16 + (uint64_t)GnuHashTable->nbuckets * 4 +
2631 (uint64_t)GnuHashTable->maskwords * sizeof(typename ELFT::Off) >=
2648 W.printNumber("Num Buckets", HashTable->nbucket);
2649 W.printNumber("Num Chains", HashTable->nchain);
2657 W.printList("Buckets", HashTable->buckets());
2658 W.printList("Chains", HashTable->chains());
2669 DynSymRegion->template getAsArrayRef<typename ELFT::Sym>();
2674 if (GnuHashTable->symndx < NumSyms)
2675 return GnuHashTable->values(NumSyms);
2678 // symndx set to the number of dynamic symbols + 1 (for the zero symbol)
2684 ArrayRef<typename ELFT::Word> Buckets = GnuHashTable->buckets();
2687 "the first hashed symbol index (" + Twine(GnuHashTable->symndx) +
2690 // There is no way to represent an array of (dynamic symbols count - symndx)
2704 W.printNumber("Num Buckets", GnuHashTable->nbuckets);
2705 W.printNumber("First Hashed Symbol Index", GnuHashTable->symndx);
2706 W.printNumber("Num Mask Words", GnuHashTable->maskwords);
2707 W.printNumber("Shift Count", GnuHashTable->shift2);
2715 ArrayRef<typename ELFT::Off> BloomFilter = GnuHashTable->filter();
2718 ArrayRef<Elf_Word> Buckets = GnuHashTable->buckets();
2735 if (this->HashTable) {
2736 if (Error E = checkHashTable<ELFT>(*this, this->HashTable))
2737 this->reportUniqueWarning(std::move(E));
2739 printHashHistogram(*this->HashTable);
2743 if (this->GnuHashTable) {
2744 if (Error E = checkGNUHashTable<ELFT>(this->Obj, this->GnuHashTable))
2745 this->reportUniqueWarning(std::move(E));
2747 printGnuHashHistogram(*this->GnuHashTable);
2759 size_t MaxChain = 1;
2769 for (size_t C = Buckets[B]; C < NChain; C = Chains[C]) {
2770 if (C == ELF::STN_UNDEF)
2772 if (Visited[C]) {
2773 this->reportUniqueWarning(
2774 ".hash section is invalid: bucket " + Twine(C) +
2778 Visited[C] = true;
2801 getGnuHashTableChains<ELFT>(this->DynSymRegion, &GnuHashTable);
2803 this->reportUniqueWarning("unable to print the GNU hash table histogram: " +
2811 size_t MaxChain = 1;
2822 size_t Len = 1;
2823 for (size_t C = Buckets[B] - Symndx;
2824 C < Chains.size() && (Chains[C] & 1) == 0; ++C)
2868 reportUniqueWarning("attribute printing not implemented for big-endian "
2869 "RISC-V objects");
2924 if (Error E = AttrParser->parse(Contents, Endianness))
3002 // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
3054 return createError("there is no non-empty GOT section at 0x" +
3058 GlobalNum = DynSymTotal - *DtGotSym;
3096 return createError("there is no non-empty PLTGOT section at 0x" +
3101 return createError("there is no non-empty RELPLT section at 0x" +
3107 Entries(reinterpret_cast<const Entry *>(PltContentOrErr->data()),
3108 PltContentOrErr->size() / sizeof(Entry));
3114 Obj.getSection(PltRelSec->sh_link))
3133 return GotSec->sh_addr + 0x7ff0;
3147 const Entry &E = GotEntries[1];
3148 if ((E >> (sizeof(Entry) * 8 - 1)) == 0)
3156 size_t Skip = getGotModulePointer() ? 2 : 1;
3157 if (LocalNum - Skip <= 0)
3159 return GotEntries.slice(Skip, LocalNum - Skip);
3173 size_t OtherNum = GotEntries.size() - LocalNum - GlobalNum;
3182 return GotSec->sh_addr + Offset;
3188 return Offset - 0x7ff0;
3195 return &GotDynSyms[Offset - LocalNum];
3207 return PltEntries.size() < 2 ? nullptr : &PltEntries[1];
3215 return PltEntries.slice(2, PltEntries.size() - 2);
3221 return PltSec->sh_addr + Offset;
3228 if (PltRelSec->sh_type == ELF::SHT_REL) {
3241 {"Broadcom SB-1", Mips::AFL_EXT_SB1},
3247 {"Loongson 2E", Mips::AFL_EXT_LOONGSON_2E},
3248 {"Loongson 2F", Mips::AFL_EXT_LOONGSON_2F},
3249 {"Loongson 3A", Mips::AFL_EXT_LOONGSON_3A},
3268 {"MIPS-3D", Mips::AFL_ASE_MIPS3D},
3285 {"Hard float (MIPS32r2 64-bit FPU 12 callee-saved)",
3287 {"Hard float (32-bit CPU, Any FPU)", Mips::Val_GNU_MIPS_ABI_FP_XX},
3288 {"Hard float (32-bit CPU, 64-bit FPU)", Mips::Val_GNU_MIPS_ABI_FP_64},
3289 {"Hard float compat (32-bit CPU, 64-bit FPU)",
3308 return -1;
3317 W.printHex("Co-Proc Mask0", Reginfo.ri_cprmask[0]);
3318 W.printHex("Co-Proc Mask1", Reginfo.ri_cprmask[1]);
3319 W.printHex("Co-Proc Mask2", Reginfo.ri_cprmask[2]);
3320 W.printHex("Co-Proc Mask3", Reginfo.ri_cprmask[3]);
3333 this->reportUniqueWarning(
3339 if (ContentsOrErr->size() < sizeof(Elf_Mips_RegInfo<ELFT>)) {
3340 this->reportUniqueWarning("the .reginfo section has an invalid size (0x" +
3341 Twine::utohexstr(ContentsOrErr->size()) + ")");
3347 ContentsOrErr->data()));
3360 const uint8_t Size = O->size;
3362 const uint64_t Offset = SecData.data() - SecBegin;
3371 IsSupported = O->kind == ODK_REGINFO;
3379 Twine(getElfMipsOptionsOdkType(O->kind)) +
3408 unsigned Kind = (*OptsOrErr)->kind;
3418 printMipsReginfoData(W, (*OptsOrErr)->getRegInfo());
3430 this->reportUniqueWarning("unable to read the stack map from " +
3516 if (ArrOrErr->empty())
3536 if (ArrOrErr->empty())
3555 if (InputFilenames.size() > 1 || A) {
3556 this->W.startLine() << "\n";
3557 this->W.printString("File", FileStr);
3562 const Elf_Ehdr &e = this->Obj.getHeader();
3600 Str = E->AltName.str();
3687 Str = getSectionHeadersNumString(this->Obj, this->FileName);
3689 Str = getSectionHeaderTableIndexString(this->Obj, this->FileName);
3695 const Elf_Shdr &Symtab) -> StringRef {
3714 return StrTableOrErr->data() + Sym.st_name;
3742 if (ContentsOrErr->empty())
3755 I - 1,
3765 for (uint32_t Ndx : Data.slice(1)) {
3789 std::vector<GroupSection> V = this->getGroups();
3800 this->reportUniqueWarning(
3803 Twine(MainGroup->Index) +
3823 Fields[1].Str = to_string(format_hex_no_prefix(R.Info, Width));
3826 this->Obj.getRelocationTypeName(R.Type, RelocName);
3831 to_string(format_hex_no_prefix(RelSym.Sym->getValue(), Width));
3845 Addend = " - ";
3846 RelAddend = -static_cast<uint64_t>(RelAddend);
3874 uint64_t Offset = Reg.Addr - this->Obj.base();
3880 printRelocHeaderFields<ELFT>(OS, Type, this->Obj.getHeader());
3899 (this->Obj.getHeader().e_machine == EM_AARCH64 &&
3902 auto GetEntriesNum = [&](const Elf_Shdr &Sec) -> Expected<size_t> {
3908 this->Obj.android_relas(Sec);
3911 return RelasOrErr->size();
3916 this->Obj.getSectionContents(Sec);
3919 auto NumOrErr = this->Obj.getCrelHeader(*ContentsOrErr);
3926 Expected<Elf_Relr_Range> RelrsOrErr = this->Obj.relrs(Sec);
3929 return this->Obj.decode_relrs(*RelrsOrErr).size();
3936 for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) {
3937 if (!isRelocationSec<ELFT>(Sec, this->Obj.getHeader()))
3945 this->reportUniqueWarning("unable to get the number of relocations in " +
3946 this->describe(Sec) + ": " +
3950 StringRef Name = this->getPrintableSectionName(Sec);
3962 CrelHdr = cantFail(this->Obj.getCrelHeader(
3963 cantFail(this->Obj.getSectionContents(Sec))));
3965 printRelocHeaderFields<ELFT>(OS, Sec.sh_type, this->Obj.getHeader(),
3968 this->printRelocationsHelper(Sec);
3976 Expected<Elf_Relr_Range> RangeOrErr = this->Obj.relrs(Sec);
3978 this->reportUniqueWarning("unable to read relocations from " +
3979 this->describe(Sec) + ": " +
3991 if (this->DotSymtabSec) {
3994 std::tie(Symtab, Strtab) = this->getSymtabAndStrtab();
4000 this->getFullSymbolName(Sym, I, ArrayRef<Elf_Word>(),
4016 OS << " " << Syms[I - 1].second;
4017 if (Syms[I - 1].first < Where)
4018 OS << " + 0x" << Twine::utohexstr(Where - Syms[I - 1].first);
4026 if ((Entry & 1) == 0) {
4031 for (auto Where = Base; Entry >>= 1;
4033 if (Entry & 1) {
4041 Base += (CHAR_BIT * sizeof(Entry) - 1) * sizeof(typename ELFT::uint);
4052 return "LOOS+0x" + utohexstr(Type - SHT_LOOS);
4054 return "LOPROC+0x" + utohexstr(Type - SHT_LOPROC);
4056 return "LOUSER+0x" + utohexstr(Type - SHT_LOUSER);
4067 // E.g. SHT_GNU_verneed -> VERNEED.
4086 OS << " C (compressed), x (unknown), o (OS specific), E (exclude),\n";
4098 ArrayRef<Elf_Shdr> Sections = cantFail(this->Obj.sections());
4102 this->Obj.getSectionStringTable(Sections, this->WarningHandler);
4104 this->reportUniqueWarning(SecStrTableOrErr.takeError());
4110 << "0x" << utohexstr(this->Obj.getHeader().e_shoff, /*LowerCase=*/true) << ":\n\n";
4114 {"Address", 41}, {"Off", 58 - Bias}, {"Size", 65 - Bias},
4115 {"ES", 72 - Bias}, {"Flg", 75 - Bias}, {"Lk", 79 - Bias},
4116 {"Inf", 82 - Bias}, {"Al", 86 - Bias}};
4123 this->Obj.getSectionStringTable(Sections, this->WarningHandler))
4126 this->reportUniqueWarning(SecStrTableOrErr.takeError());
4132 Fields[1].Str = "<no-strings>";
4134 Fields[1].Str = std::string(unwrapOrError<StringRef>(
4135 this->FileName, this->Obj.getSectionName(Sec, SecStrTable)));
4137 getSectionTypeString(this->Obj.getHeader().e_machine, Sec.sh_type);
4143 Fields[7].Str = getGNUFlags(this->Obj.getHeader().e_ident[ELF::EI_OSABI],
4144 this->Obj.getHeader().e_machine, Sec.sh_flags);
4151 for (int i = 1; i < 7; i++)
4164 printSectionDescription(OS, this->Obj.getHeader().e_machine);
4174 Name = this->getPrintableSectionName(*Symtab);
4217 this->reportUniqueWarning(IndexOrErr.takeError());
4243 auto Sec = this->Obj.getSection(SectionIndex);
4245 this->reportUniqueWarning(Sec.takeError());
4247 auto SecName = this->Obj.getSectionName(**Sec);
4249 this->reportUniqueWarning(SecName.takeError());
4267 Fields[1].Str =
4272 if (this->Obj.getHeader().e_machine == ELF::EM_AMDGPU &&
4284 if (this->Obj.getHeader().e_machine == ELF::EM_AARCH64) {
4293 } else if (this->Obj.getHeader().e_machine == ELF::EM_RISCV) {
4313 Fields[7].Str = this->getFullSymbolName(Symbol, SymIndex, ShndxTable,
4330 Fields[1].Str = to_string(format_decimal(Bucket, 3)) + ":";
4333 format_hex_no_prefix(Symbol->st_value, ELFT::Is64Bits ? 16 : 8));
4334 Fields[3].Str = to_string(format_decimal(Symbol->st_size, 5));
4336 unsigned char SymbolType = Symbol->getType();
4337 if (this->Obj.getHeader().e_machine == ELF::EM_AMDGPU &&
4344 enumToString(Symbol->getBinding(), ArrayRef(ElfSymbolBindings));
4346 enumToString(Symbol->getVisibility(), ArrayRef(ElfSymbolVisibilities));
4349 this->getFullSymbolName(*Symbol, SymIndex, ShndxTable, StrTable, true);
4362 // GNU readelf prints both the .dynsym and .symtab with --symbols.
4363 this->printSymbolsHelper(true, ExtraSymInfo);
4365 this->printSymbolsHelper(false, ExtraSymInfo);
4370 if (this->DynamicStringTable.empty())
4379 Elf_Sym_Range DynSyms = this->dynamic_symbols();
4382 this->reportUniqueWarning(
4385 (this->DynSymRegion ? "is empty" : "was not found"));
4390 (const Elf_Word *)this->DynSymTabShndxRegion.Addr, this->Obj.end());
4402 this->reportUniqueWarning(".hash section is invalid: bucket " +
4408 printHashedSymbol(FirstSym + Ch, Ch, ShndxTable, this->DynamicStringTable,
4417 if (this->DynamicStringTable.empty())
4420 Elf_Sym_Range DynSyms = this->dynamic_symbols();
4423 this->reportUniqueWarning(
4426 (this->DynSymRegion ? "is empty" : "was not found"));
4431 uint64_t SymsTotal) -> const Elf_Sym * {
4433 this->reportUniqueWarning(
4444 getGnuHashTableChains<ELFT>(this->DynSymRegion, &GnuHash);
4447 this->reportUniqueWarning("unable to get hash values for the SHT_GNU_HASH "
4454 (const Elf_Word *)this->DynSymTabShndxRegion.Addr, this->Obj.end());
4464 printHashedSymbol(Sym, SymIndex, ShndxTable, this->DynamicStringTable,
4470 this->reportUniqueWarning(
4479 if ((Values[SymIndex - GnuHash.symndx] & 1) == 1)
4486 if (this->HashTable) {
4488 if (Error E = checkHashTable<ELFT>(*this, this->HashTable))
4489 this->reportUniqueWarning(std::move(E));
4491 printHashTableSymbols(*this->HashTable);
4495 if (this->GnuHashTable) {
4503 if (Error E = checkGNUHashTable<ELFT>(this->Obj, this->GnuHashTable))
4504 this->reportUniqueWarning(std::move(E));
4506 printGnuHashTableSymbols(*this->GnuHashTable);
4511 ArrayRef<Elf_Shdr> Sections = cantFail(this->Obj.sections());
4515 this->Obj.getSectionStringTable(Sections, this->WarningHandler);
4517 this->reportUniqueWarning(SecStrTableOrErr.takeError());
4522 << "0x" << utohexstr(this->Obj.getHeader().e_shoff, /*LowerCase=*/true) << ":\n\n";
4547 this->Obj.getSectionStringTable(Sections, this->WarningHandler))
4550 this->reportUniqueWarning(SecStrTableOrErr.takeError());
4557 this->Obj.getSectionName(S, SecStrTable))
4560 this->reportUniqueWarning(NameOrErr.takeError());
4566 {{getSectionTypeString(this->Obj.getHeader().e_machine, S.sh_type), 7},
4591 uint64_t Flag = Flags & -Flags;
4592 Flags -= Flag;
4596 OS << LS << It->second;
4613 PrintUnknownFlags(uint64_t(-1), "UNKNOWN");
4620 Expected<ArrayRef<uint8_t>> Data = this->Obj.getSectionContents(S);
4621 if (!Data || Data->size() < sizeof(Elf_Chdr)) {
4625 this->FileName);
4630 auto *Chdr = reinterpret_cast<const Elf_Chdr *>(Data->data());
4631 if (Chdr->ch_type == ELFCOMPRESS_ZLIB)
4633 else if (Chdr->ch_type == ELFCOMPRESS_ZSTD)
4636 OS << format("[<unknown>: 0x%x]", unsigned(Chdr->ch_type));
4637 OS << ", " << format_hex_no_prefix(Chdr->ch_size, ELFT::Is64Bits ? 16 : 8)
4638 << ", " << Chdr->ch_addralign;
4676 // We get here when we have an empty section. Only non-empty sections can be
4696 const Elf_Ehdr &Header = this->Obj.getHeader();
4710 const Elf_Ehdr &Header = this->Obj.getHeader();
4729 Expected<ArrayRef<Elf_Phdr>> PhdrsOrErr = this->Obj.program_headers();
4731 this->reportUniqueWarning("unable to dump program headers: " +
4738 Fields[1].Str = to_string(format_hex(Phdr.p_offset, 8));
4744 Fields[7].Str = to_string(format_hex(Phdr.p_align, 1));
4750 this->reportUniqueWarning(
4755 if (Phdr.p_offset >= this->Obj.getBufSize()) {
4757 Twine::utohexstr(this->Obj.getBufSize()) + ")");
4762 reinterpret_cast<const char *>(this->Obj.base()) + Phdr.p_offset;
4763 size_t MaxSize = this->Obj.getBufSize() - Phdr.p_offset;
4766 ReportBadInterp("it is not null-terminated");
4782 Expected<ArrayRef<Elf_Phdr>> PhdrsOrErr = this->Obj.program_headers();
4784 this->reportUniqueWarning(
4794 for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) {
4805 unwrapOrError(this->FileName, this->Obj.getSectionName(Sec)).str() +
4816 for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) {
4819 unwrapOrError(this->FileName, this->Obj.getSectionName(Sec)).str() +
4835 const Twine &Reason) -> RelSymbol<ELFT> {
4858 const uint64_t SymOffset = ((const uint8_t *)FirstSym - Obj.base()) +
4866 Expected<StringRef> ErrOrName = Sym->getName(Dumper.getDynamicStringTable());
4884 Elf_Dyn_Range Table = this->dynamic_table();
4889 << format_hex(reinterpret_cast<const uint8_t *>(this->DynamicTable.Addr) -
4890 this->Obj.base(),
4891 1)
4895 size_t MaxTagSize = getMaxDynamicTagSize(this->Obj, Table) + 2;
4897 // spaces, where N = MaxTagSize - length of "Type" (4) + trailing
4898 // space (1) = 3.
4900 << std::string(MaxTagSize - 3, ' ') << "Name/Value\n";
4902 std::string ValueFmt = " %-" + std::to_string(MaxTagSize) + "s ";
4906 std::string("(") + this->Obj.getDynamicTagAsString(Tag) + ")";
4907 std::string Value = this->getDynamicEntry(Tag, Entry.getVal());
4914 this->printDynamicRelocationsHelper();
4924 this->forEachRelocationDo(
4930 const bool IsMips64EL = this->Obj.isMips64EL();
4935 Region.Size = Region.EntSize = 1;
4938 Region.Addr - reinterpret_cast<const uint8_t *>(
4942 Obj.decodeCrel(ArrayRef<uint8_t>(Region.Addr, ObjSize - Offset));
4946 for (const Elf_Rel &R : RelsOrRelas->first)
4948 for (const Elf_Rela &R : RelsOrRelas->second)
4954 if (this->DynCrelRegion.Addr) {
4955 printDynamicRelocHeader(ELF::SHT_CREL, "CREL", this->DynCrelRegion);
4956 DumpCrelRegion(this->DynCrelRegion);
4959 if (this->DynRelaRegion.Size > 0) {
4960 printDynamicRelocHeader(ELF::SHT_RELA, "RELA", this->DynRelaRegion);
4962 this->DynRelaRegion.template getAsArrayRef<Elf_Rela>())
4966 if (this->DynRelRegion.Size > 0) {
4967 printDynamicRelocHeader(ELF::SHT_REL, "REL", this->DynRelRegion);
4969 this->DynRelRegion.template getAsArrayRef<Elf_Rel>())
4973 if (this->DynRelrRegion.Size > 0) {
4974 printDynamicRelocHeader(ELF::SHT_REL, "RELR", this->DynRelrRegion);
4976 this->DynRelrRegion.template getAsArrayRef<Elf_Relr>();
4981 if (this->DynPLTRelRegion.Size) {
4982 if (this->DynPLTRelRegion.EntSize == sizeof(Elf_Rela)) {
4983 printDynamicRelocHeader(ELF::SHT_RELA, "PLT", this->DynPLTRelRegion);
4985 this->DynPLTRelRegion.template getAsArrayRef<Elf_Rela>())
4987 } else if (this->DynPLTRelRegion.EntSize == 1) {
4988 DumpCrelRegion(this->DynPLTRelRegion);
4990 printDynamicRelocHeader(ELF::SHT_REL, "PLT", this->DynPLTRelRegion);
4992 this->DynPLTRelRegion.template getAsArrayRef<Elf_Rel>())
5003 StringRef SecName = this->getPrintableSectionName(Sec);
5009 this->Obj.getSection(Sec.sh_link))
5010 LinkedSecName = this->getPrintableSectionName(**LinkedSecOrErr);
5012 this->reportUniqueWarning("invalid section linked to " +
5013 this->describe(Sec) + ": " +
5027 Sec->sh_size / sizeof(Elf_Versym));
5029 this->getVersionTable(*Sec, /*SymTab=*/nullptr,
5032 this->reportUniqueWarning(VerTableOrErr.takeError());
5038 this->getVersionMap())
5041 this->reportUniqueWarning(MapOrErr.takeError());
5058 Expected<StringRef> NameOrErr = this->Obj.getSymbolVersionByIndex(
5061 this->reportUniqueWarning("unable to get a version for entry " +
5062 Twine(I) + " of " + this->describe(*Sec) +
5076 OS << format("%4x%c", Ndx & VERSYM_VERSION,
5111 printGNUVersionSectionProlog(*Sec, "Version definition", Sec->sh_info);
5113 Expected<std::vector<VerDef>> V = this->Obj.getVersionDefinitions(*Sec);
5115 this->reportUniqueWarning(V.takeError());
5138 unsigned VerneedNum = Sec->sh_info;
5142 this->Obj.getVersionDependencies(*Sec, this->WarningHandler);
5144 this->reportUniqueWarning(V.takeError());
5171 OS << format("%7lu %-10lu (%5.1f%%) %5.1f%%\n", I, Count[I],
5217 if (!this->DotAddrsigSec)
5221 decodeAddrsigSection(this->Obj, *this->DotAddrsigSec);
5223 this->reportUniqueWarning(SymsOrErr.takeError());
5227 StringRef Name = this->getPrintableSectionName(*this->DotAddrsigSec);
5228 OS << "\nAddress-significant symbols section '" << Name << "'"
5229 << " contains " << SymsOrErr->size() << " entries:\n";
5236 Fields[1].Str = this->getStaticSymbolName(Sym);
5247 // DataSize - size without padding, Desc.size() - size with padding
5270 std::string VersionDesc = [Platform, Version]() -> std::string {
5273 if (Version >= (1 << (AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_LAST + 1)))
5276 std::array<StringRef, AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_LAST + 1>
5294 if (!(Version & (1ULL << I)))
5297 Twine("PointerAuth" + Flags[I] + (I == End - 1 ? "" : ", ")).str();
5327 OS << format("<application-specific type 0x%x>", Type);
5409 DumpBit(GNU_PROPERTY_X86_ISA_1_BASELINE, "x86-64-baseline");
5410 DumpBit(GNU_PROPERTY_X86_ISA_1_V2, "x86-64-v2");
5411 DumpBit(GNU_PROPERTY_X86_ISA_1_V3, "x86-64-v3");
5412 DumpBit(GNU_PROPERTY_X86_ISA_1_V4, "x86-64-v4");
5470 uint32_t Major = Words[1], Minor = Words[2], Patch = Words[3];
5492 // Return true if we were able to pretty-print the note, false otherwise.
5562 // Return true if we were able to pretty-print the note, false otherwise.
5636 return std::nullopt; // No pretty-printing yet.
5684 StrOS << "[Major: " << Version->MajorVersion
5685 << ", Minor: " << Version->MinorVersion << "]";
5701 StrOS << "[HSAIL Major: " << Properties->HSAILMajorVersion
5702 << ", HSAIL Minor: " << Properties->HSAILMinorVersion
5703 << ", Profile: " << uint32_t(Properties->Profile)
5704 << ", Machine Model: " << uint32_t(Properties->MachineModel)
5706 << uint32_t(Properties->DefaultFloatRound) << "]";
5721 Isa->VendorNameSize + Isa->ArchitectureNameSize ||
5722 Isa->VendorNameSize == 0 || Isa->ArchitectureNameSize == 0)
5727 << StringRef((const char*)Desc.data() + sizeof(IsaVersion), Isa->VendorNameSize - 1)
5729 << StringRef((const char*)Desc.data() + sizeof(IsaVersion) + Isa->VendorNameSize,
5730 Isa->ArchitectureNameSize - 1)
5731 << ", Major: " << Isa->Major << ", Minor: " << Isa->Minor
5732 << ", Stepping: " << Isa->Stepping << "]";
5740 std::string(reinterpret_cast<const char *>(Desc.data()), Desc.size() - 1)};
5821 // 1. # of file mappings (call it N)
5855 if (!Filenames.isValidOffsetForDataOfSize(FilenamesOffset, 1))
5895 {ELF::NT_GNU_HWCAP, "NT_GNU_HWCAP (DSO-supplied software HWCAP info)"},
6015 "NT_S390_VXRS_LOW (s390 vector registers 0-15 upper half)"},
6016 {ELF::NT_S390_VXRS_HIGH, "NT_S390_VXRS_HIGH (s390 vector registers 16-31)"},
6017 {ELF::NT_S390_GS_CB, "NT_S390_GS_CB (s390 guarded-storage registers)"},
6019 "NT_S390_GS_BC (s390 guarded-storage broadcast control)"},
6044 auto FindNote = [&](ArrayRef<NoteType> V) -> StringRef {
6065 if (ELFType == ELF::ET_CORE && Name.starts_with("NetBSD-CORE")) {
6184 auto ProcessNote = [&](const Elf_Note &Note, bool IsCore) -> Error {
6194 getNoteTypeName<ELFT>(Note, this->Obj.getHeader().e_type);
6201 // owners/if we fail to pretty-print the contents.
6208 OS << " " << N->Type << ": " << N->Value << '\n';
6315 auto FindAndroidNote = [&](const Elf_Note &Note, bool IsCore) -> Error {
6342 // https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst#83encoding-of-sht_aarch64_memtag_globals_dynamic
6357 uint64_t GranulesToTag = Value & ((1 << MemtagStepVarintReservedBits) - 1);
6361 1;
6365 "error decoding size-only uleb, " + Twine(DecodedBytes) +
6388 this->reportUniqueWarning("SHT_LLVM_DEPENDENT_LIBRARIES section at index " +
6392 unsigned I = -1;
6408 Warn(I, "the content is not null-terminated");
6414 OnLibEntry(Lib, I - Contents.begin());
6415 I += Lib.size() + 1;
6428 this->reportUniqueWarning(Prefix + " " + describe(Sec) + ": " +
6448 const bool IsMips64EL = this->Obj.isMips64EL();
6485 for (const Elf_Rel &R : RelsOrRelas->first)
6487 for (const Elf_Rela &R : RelsOrRelas->second)
6510 Obj.getSectionName(Sec, this->WarningHandler))
6513 this->reportUniqueWarning("unable to get the name of " + describe(Sec) +
6528 << format_hex(Current.Offset, 1) << " contains " << SecEntries.size()
6542 Current.Name = this->getPrintableSectionName(Shdr);
6548 this->printDependentLibsHelper(OnSectionStart, OnLibEntry);
6557 if (!this->AddressToIndexMap) {
6560 this->AddressToIndexMap.emplace();
6561 if (this->DotSymtabSec) {
6563 Obj.symbols(this->DotSymtabSec)) {
6564 uint32_t Index = (uint32_t)-1;
6572 ObjF.toSymbolRef(this->DotSymtabSec, Index).getAddress();
6574 std::string Name = this->getStaticSymbolName(Index);
6580 (*this->AddressToIndexMap)[*SymAddrOrErr].push_back(Index);
6589 auto Symbols = this->AddressToIndexMap->find(SymValue);
6590 if (Symbols == this->AddressToIndexMap->end())
6593 for (uint32_t Index : Symbols->second) {
6597 const Elf_Sym &Sym = *cantFail(Obj.getSymbol(this->DotSymtabSec, Index));
6599 Obj.getSection(Sym, this->DotSymtabSec,
6600 this->getShndxTable(this->DotSymtabSec))) {
6604 std::string Name = this->getStaticSymbolName(Index);
6624 this->getSymbolIndexesForFunctionAddress(SymValue, FunctionSec);
6646 FuncSymNames.push_back(this->getStaticSymbolName(Index));
6674 Expected<RelSymbol<ELFT>> TargetOrErr = this->getRelocationTarget(R, SymTab);
6680 Sym = TargetOrErr->Sym;
6685 this->Obj.getSection(*Sym, SymTab, this->getShndxTable(SymTab));
6698 RelocSymValue = Sym->st_value;
6702 if (!Data.isValidOffsetForDataOfSize(Offset, sizeof(Elf_Addr) + 1)) {
6712 this->printFunctionStackSize(SymValue, FunctionSec, StackSizeSec, Data,
6722 if (this->getPrintableSectionName(Sec) != ".stack_sizes")
6726 unwrapOrError(this->FileName, Obj.getSectionContents(Sec));
6732 if (!Data.isValidOffsetForDataOfSize(Offset, sizeof(Elf_Addr) + 1)) {
6751 auto IsMatch = [&](const Elf_Shdr &Sec) -> bool {
6787 this->FileName, Obj.getSection(StackSizesELFSec->sh_link));
6791 std::tie(IsSupportedFn, Resolver) = getRelocationResolver(this->ObjF);
6793 unwrapOrError(this->FileName, Obj.getSectionContents(*StackSizesELFSec));
6807 this->printStackSize(R, *RelocSec, Ndx, SymTab, FunctionSec,
6827 // For non-relocatable objects, look directly for sections whose name starts
6829 if (this->Obj.getHeader().e_type == ELF::ET_REL)
6830 this->printRelocatableStackSizes(PrintHeader);
6832 this->printNonRelocatableStackSizes(PrintHeader);
6886 (const Elf_Word *)this->DynSymTabShndxRegion.Addr, this->Obj.end());
6889 const Elf_Sym &FirstSym = this->dynamic_symbols()[0];
6890 std::string SymName = this->getFullSymbolName(
6891 Sym, &Sym - &FirstSym, ShndxTable, this->DynamicStringTable, false);
6904 OS << getSymbolSectionNdx(Sym, &Sym - this->dynamic_symbols().begin(),
6912 OS << "\n Number of TLS and multi-GOT entries "
6941 (const Elf_Word *)this->DynSymTabShndxRegion.Addr, this->Obj.end());
6945 this->Obj.template getEntry<Elf_Sym>(*Parser.getPltSymTable(), 0));
6946 std::string SymName = this->getFullSymbolName(
6947 Sym, &Sym - &FirstSym, ShndxTable, this->DynamicStringTable, false);
6958 OS << getSymbolSectionNdx(Sym, &Sym - this->dynamic_symbols().begin(),
6979 if (DataOrErr->size() != sizeof(Elf_Mips_ABIFlags<ELFT>))
6981 Twine(DataOrErr->size()) + ")");
6982 return reinterpret_cast<const Elf_Mips_ABIFlags<ELFT> *>(DataOrErr->data());
6991 this->reportUniqueWarning(SecOrErr.takeError());
6995 OS << "MIPS ABI Flags Version: " << Flags->version << "\n\n";
6996 OS << "ISA: MIPS" << int(Flags->isa_level);
6997 if (Flags->isa_rev > 1)
6998 OS << "r" << int(Flags->isa_rev);
7000 OS << "GPR size: " << getMipsRegisterSize(Flags->gpr_size) << "\n";
7001 OS << "CPR1 size: " << getMipsRegisterSize(Flags->cpr1_size) << "\n";
7002 OS << "CPR2 size: " << getMipsRegisterSize(Flags->cpr2_size) << "\n";
7003 OS << "FP ABI: " << enumToString(Flags->fp_abi, ArrayRef(ElfMipsFpABIType))
7006 << enumToString(Flags->isa_ext, ArrayRef(ElfMipsISAExtType)) << "\n";
7007 if (Flags->ases == 0)
7011 OS << "ASEs: " << printFlags(Flags->ases, ArrayRef(ElfMipsASEFlags))
7013 OS << "FLAGS 1: " << format_hex_no_prefix(Flags->flags1, 8, false) << "\n";
7014 OS << "FLAGS 2: " << format_hex_no_prefix(Flags->flags2, 8, false) << "\n";
7019 const Elf_Ehdr &E = this->Obj.getHeader();
7054 TypeStr = Ent->Name.str();
7137 getSectionHeadersNumString(this->Obj, this->FileName));
7139 getSectionHeaderTableIndexString(this->Obj, this->FileName));
7145 std::vector<GroupSection> V = this->getGroups();
7160 this->reportUniqueWarning(
7163 Twine(MainGroup->Index) +
7188 for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) {
7189 if (!isRelocationSec<ELFT>(Sec, this->Obj.getHeader()))
7192 StringRef Name = this->getPrintableSectionName(Sec);
7193 unsigned SecNdx = &Sec - &cantFail(this->Obj.sections()).front();
7205 W.printNumber("Symbol", !SymbolName.empty() ? SymbolName : "-", R.Symbol);
7216 << (!SymbolName.empty() ? SymbolName : "-");
7227 this->printRelocationsHelper(Sec);
7241 this->Obj.getRelocationTypeName(R.Type, RelocName);
7253 int SectionIndex = -1;
7255 getSectionFlagsForTarget(this->Obj.getHeader().e_ident[ELF::EI_OSABI],
7256 this->Obj.getHeader().e_machine);
7257 for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) {
7260 W.printNumber("Name", this->getPrintableSectionName(Sec), Sec.sh_name);
7262 object::getELFSectionTypeName(this->Obj.getHeader().e_machine,
7276 this->printRelocationsHelper(Sec);
7281 if (this->DotSymtabSec) {
7283 this->FileName,
7284 this->Obj.getStringTableForSymtab(*this->DotSymtabSec));
7285 ArrayRef<Elf_Word> ShndxTable = this->getShndxTable(this->DotSymtabSec);
7288 this->FileName, this->Obj.symbols(this->DotSymtabSec));
7291 this->FileName,
7292 this->Obj.getSection(Sym, this->DotSymtabSec, ShndxTable));
7294 printSymbol(Sym, &Sym - &Symbols[0], ShndxTable, StrTable, false,
7303 unwrapOrError(this->FileName, this->Obj.getSectionContents(Sec));
7315 auto GetSectionSpecialType = [&]() -> std::optional<StringRef> {
7337 this->getSymbolSectionIndex(Symbol, SymIndex, ShndxTable);
7342 this->reportUniqueWarning(SectionIndex.takeError());
7348 this->getSymbolSectionName(Symbol, *SectionIndex);
7352 if (!this->ObjF.sections().empty())
7353 this->reportUniqueWarning(SectionName.takeError());
7365 this->getOtherFlagsFromSymbol(this->Obj.getHeader(), Symbol);
7372 assert(Symbol.st_other == 0 && "non-zero Other Field");
7385 std::string FullSymbolName = this->getFullSymbolName(
7394 if (this->Obj.getHeader().e_machine == ELF::EM_AMDGPU &&
7412 this->printSymbolsHelper(false, ExtraSymInfo);
7416 this->printSymbolsHelper(true, ExtraSymInfo);
7421 Elf_Dyn_Range Table = this->dynamic_table();
7427 size_t MaxTagSize = getMaxDynamicTagSize(this->Obj, Table);
7429 // spaces, where N = MaxTagSize - length of "Type" (4) + trailing
7430 // space (1) = -3.
7432 << "Type" << std::string(MaxTagSize - 3, ' ') << "Name/Value\n";
7434 std::string ValueFmt = "%-" + std::to_string(MaxTagSize) + "s ";
7437 std::string Value = this->getDynamicEntry(Tag, Entry.getVal());
7441 this->Obj.getDynamicTagAsString(Tag).c_str())
7451 ListScope L(this->W, "Flags");
7454 this->W.printString(Flag.Name);
7459 this->W.printString("Name", this->getDynamicString(Entry.getVal()));
7464 this->W.printString("Library", this->getDynamicString(Entry.getVal()));
7467 this->W.printString("Object", this->getDynamicString(Entry.getVal()));
7471 StringRef Value = this->getDynamicString(Entry.getVal());
7472 ListScope L(this->W, "Path");
7475 this->W.printString(Front);
7492 Elf_Dyn_Range Table = this->dynamic_table();
7493 ListScope L(this->W, "DynamicSection");
7495 DictScope D(this->W);
7497 this->W.printHex("Tag", Tag);
7498 this->W.printString("Type", this->Obj.getDynamicTagAsString(Tag));
7499 this->W.printHex("Value", Entry.getVal());
7500 this->printAuxillaryDynamicTableEntryInfo(Entry);
7507 this->printDynamicRelocationsHelper();
7524 Expected<ArrayRef<Elf_Phdr>> PhdrsOrErr = this->Obj.program_headers();
7526 this->reportUniqueWarning("unable to dump program headers: " +
7534 segmentTypeToString(this->Obj.getHeader().e_machine, Phdr.p_type);
7557 this->getVersionTable(*Sec, &Syms, &StrTable, &SymTabSec);
7559 this->reportUniqueWarning(VerTableOrErr.takeError());
7563 if (StrTable.empty() || Syms.empty() || Syms.size() != VerTableOrErr->size())
7566 ArrayRef<Elf_Word> ShNdxTable = this->getShndxTable(SymTabSec);
7571 this->getFullSymbolName(Syms[I], I, ShNdxTable, StrTable,
7587 Expected<std::vector<VerDef>> V = this->Obj.getVersionDefinitions(*Sec);
7589 this->reportUniqueWarning(V.takeError());
7613 this->Obj.getVersionDependencies(*Sec, this->WarningHandler);
7615 this->reportUniqueWarning(V.takeError());
7667 Dumper->reportUniqueWarning(
7672 if (CGRelSection->sh_type == SHT_REL) {
7677 Dumper->reportUniqueWarning("unable to load relocations for "
7694 Dumper->reportUniqueWarning("unable to load relocations for "
7709 auto IsMatch = [](const Elf_Shdr &Sec) -> bool {
7714 this->Obj.getSectionAndRelocations(IsMatch);
7716 this->reportUniqueWarning("unable to get CG Profile section(s): " +
7726 this->Obj.template getSectionContentsAsArray<Elf_CGProfile>(*CGSection);
7728 this->reportUniqueWarning(
7736 getSymbolIndices<ELFT>(CGRelSection, this->Obj, this, SymbolIndices);
7737 if (UseReloc && SymbolIndices.size() != CGProfileOrErr->size() * 2) {
7738 this->reportUniqueWarning(
7744 for (uint32_t I = 0, Size = CGProfileOrErr->size(); I != Size; ++I) {
7749 uint32_t To = SymbolIndices[I * 2 + 1];
7750 W.printNumber("From", this->getStaticSymbolName(From), From);
7751 W.printNumber("To", this->getStaticSymbolName(To), To);
7760 bool IsRelocatable = this->Obj.getHeader().e_type == ELF::ET_REL;
7762 auto IsMatch = [](const Elf_Shdr &Sec) -> bool {
7766 this->Obj.getSectionAndRelocations(IsMatch);
7768 this->reportUniqueWarning(
7777 unwrapOrError(this->FileName, this->Obj.getSection(Sec->sh_link));
7780 this->reportUniqueWarning("unable to get relocation section for " +
7781 this->describe(*Sec));
7786 this->Obj.decodeBBAddrMap(*Sec, RelocSec, &PGOAnalyses);
7788 this->reportUniqueWarning("unable to dump " + this->describe(*Sec) +
7796 this->getSymbolIndexesForFunctionAddress(AM.getFunctionAddress(),
7800 this->reportUniqueWarning(
7803 this->describe(*Sec));
7805 FuncName = this->getStaticSymbolName(FuncSymIndex.front());
7871 if (!this->DotAddrsigSec)
7875 decodeAddrsigSection(this->Obj, *this->DotAddrsigSec);
7877 this->reportUniqueWarning(SymsOrErr.takeError());
7882 W.printNumber("Sym", this->getStaticSymbolName(Sym), Sym);
7888 // Return true if we were able to pretty-print the note, false otherwise.
7921 // Return true if we were able to pretty-print the note, false otherwise.
8013 auto ProcessNote = [&](const Elf_Note &Note, bool IsCore) -> Error {
8024 getNoteTypeName<ELFT>(Note, this->Obj.getHeader().e_type);
8032 // owners/if we fail to pretty-print the contents.
8039 W.printString(N->Type, N->Value);
8086 unsigned I = -1;
8087 for (const Elf_Shdr &Shdr : cantFail(this->Obj.sections())) {
8093 this->Obj.getSectionContents(Shdr);
8095 this->reportUniqueWarning("unable to read the content of the "
8100 if (ContentsOrErr->empty())
8103 if (ContentsOrErr->back() != 0) {
8104 this->reportUniqueWarning("SHT_LLVM_LINKER_OPTIONS section at index " +
8107 "content is not null-terminated");
8112 toStringRef(ContentsOrErr->drop_back()).split(Strings, '\0');
8114 this->reportUniqueWarning(
8117 "key-value pair was found. The last possible key was: \"" +
8123 W.printString(Strings[I], Strings[I + 1]);
8129 this->printDependentLibsHelper(
8136 if (this->Obj.getHeader().e_type == ELF::ET_REL)
8137 this->printRelocatableStackSizes([]() {});
8139 this->printNonRelocatableStackSizes([]() {});
8197 const unsigned SymIndex = &Sym - this->dynamic_symbols().begin();
8199 (const Elf_Word *)this->DynSymTabShndxRegion.Addr, this->Obj.end());
8202 std::string SymName = this->getFullSymbolName(
8203 Sym, SymIndex, ShndxTable, this->DynamicStringTable, true);
8208 W.printNumber("Number of TLS and multi-GOT entries",
8238 (const Elf_Word *)this->DynSymTabShndxRegion.Addr, this->Obj.end());
8246 printSymbolSection(Sym, &Sym - this->dynamic_symbols().begin(),
8250 this->Obj.template getEntry<Elf_Sym>(*Parser.getPltSymTable(), 0));
8251 std::string SymName = this->getFullSymbolName(
8252 Sym, &Sym - FirstSym, ShndxTable, Parser.getPltStrTable(), true);
8268 this->reportUniqueWarning(SecOrErr.takeError());
8275 W.printNumber("Version", Flags->version);
8277 if (Flags->isa_rev <= 1)
8278 OS << format("MIPS%u", Flags->isa_level);
8280 OS << format("MIPS%ur%u", Flags->isa_level, Flags->isa_rev);
8282 W.printEnum("ISA Extension", Flags->isa_ext, ArrayRef(ElfMipsISAExtType));
8283 W.printFlags("ASEs", Flags->ases, ArrayRef(ElfMipsASEFlags));
8284 W.printEnum("FP ABI", Flags->fp_abi, ArrayRef(ElfMipsFpABIType));
8285 W.printNumber("GPR size", getMipsRegisterSize(Flags->gpr_size));
8286 W.printNumber("CPR1 size", getMipsRegisterSize(Flags->cpr1_size));
8287 W.printNumber("CPR2 size", getMipsRegisterSize(Flags->cpr2_size));
8288 W.printFlags("Flags 1", Flags->flags1, ArrayRef(ElfMipsFlags1));
8289 W.printHex("Flags 2", Flags->flags2);
8296 FileScope = std::make_unique<DictScope>(this->W);
8297 DictScope D(this->W, "FileSummary");
8298 this->W.printString("File", FileStr);
8299 this->W.printString("Format", Obj.getFileFormatName());
8300 this->W.printString("Arch", Triple::getArchTypeName(Obj.getArch()));
8301 this->W.printString(
8304 this->printLoadName();
8312 this->printSymbolOtherField(Symbol);
8319 this->printExpandedRelRelaReloc(R, SymbolName, RelocName);
8326 DictScope Group(this->W);
8327 this->W.printNumber("SectionIndex", SecNdx);
8328 ListScope D(this->W, "Relocs");
8329 this->printRelocationsHelper(Sec);
8340 DictScope Grp(this->W);
8341 this->W.printString("Name", Name);
8342 this->W.printNumber("Index", Idx);