static const typename ELFO::Elf_Shdr *
findNotEmptySectionByAddress(const ELFO *Obj, StringRef FileName,
uint64_t Addr) {
- for (const auto &Shdr : unwrapOrError(FileName, Obj->sections()))
+ for (const typename ELFO::Elf_Shdr &Shdr : cantFail(Obj->sections()))
if (Shdr.sh_addr == Addr && Shdr.sh_size > 0)
return &Shdr;
return nullptr;
template <class ELFO>
static const typename ELFO::Elf_Shdr *
findSectionByName(const ELFO &Obj, StringRef FileName, StringRef Name) {
- for (const auto &Shdr : unwrapOrError(FileName, Obj.sections()))
+ for (const typename ELFO::Elf_Shdr &Shdr : cantFail(Obj.sections()))
if (Name == unwrapOrError(FileName, Obj.getSectionName(&Shdr)))
return &Shdr;
return nullptr;
// Try to locate the .dynamic section in the sections header table.
const Elf_Shdr *DynamicSec = nullptr;
- for (const Elf_Shdr &Sec :
- unwrapOrError(ObjF->getFileName(), Obj->sections())) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
if (Sec.sh_type != ELF::SHT_DYNAMIC)
continue;
DynamicSec = &Sec;
ELFDumperStyle.reset(new LLVMStyle<ELFT>(Writer, this));
const ELFFile<ELFT> *Obj = ObjF->getELFFile();
- typename ELFT::ShdrRange Sections =
- unwrapOrError(ObjF->getFileName(), Obj->sections());
+ typename ELFT::ShdrRange Sections = cantFail(Obj->sections());
for (const Elf_Shdr &Sec : Sections) {
switch (Sec.sh_type) {
case ELF::SHT_SYMTAB:
"Attributes not implemented.");
DictScope BA(W, "BuildAttributes");
- for (const auto &Sec : unwrapOrError(ObjF->getFileName(), Obj->sections())) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
if (Sec.sh_type != ELF::SHT_ARM_ATTRIBUTES &&
Sec.sh_type != ELF::SHT_RISCV_ATTRIBUTES)
continue;
template <class ELFT> void ELFDumper<ELFT>::printStackMap() const {
const ELFFile<ELFT> *Obj = ObjF->getELFFile();
const Elf_Shdr *StackMapSection = nullptr;
- for (const auto &Sec : unwrapOrError(ObjF->getFileName(), Obj->sections())) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
StringRef Name =
unwrapOrError(ObjF->getFileName(), Obj->getSectionName(&Sec));
if (Name == ".llvm_stackmaps") {
if (ElfHeader->e_shnum != 0)
return to_string(ElfHeader->e_shnum);
- ArrayRef<typename ELFT::Shdr> Arr = unwrapOrError(FileName, Obj->sections());
+ ArrayRef<typename ELFT::Shdr> Arr = cantFail(Obj->sections());
if (Arr.empty())
return "0";
return "0 (" + to_string(Arr[0].sh_size) + ")";
if (ElfHeader->e_shstrndx != SHN_XINDEX)
return to_string(ElfHeader->e_shstrndx);
- ArrayRef<typename ELFT::Shdr> Arr = unwrapOrError(FileName, Obj->sections());
+ ArrayRef<typename ELFT::Shdr> Arr = cantFail(Obj->sections());
if (Arr.empty())
return "65535 (corrupt: out of range)";
return to_string(ElfHeader->e_shstrndx) + " (" + to_string(Arr[0].sh_link) +
std::vector<GroupSection> Ret;
uint64_t I = 0;
- for (const Elf_Shdr &Sec : unwrapOrError(FileName, Obj->sections())) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
++I;
if (Sec.sh_type != ELF::SHT_GROUP)
continue;
template <class ELFT> void GNUStyle<ELFT>::printRelocations(const ELFO *Obj) {
bool HasRelocSections = false;
- for (const Elf_Shdr &Sec : unwrapOrError(this->FileName, Obj->sections())) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
if (Sec.sh_type != ELF::SHT_REL && Sec.sh_type != ELF::SHT_RELA &&
Sec.sh_type != ELF::SHT_RELR && Sec.sh_type != ELF::SHT_ANDROID_REL &&
Sec.sh_type != ELF::SHT_ANDROID_RELA &&
template <class ELFT>
void GNUStyle<ELFT>::printSectionHeaders(const ELFO *Obj) {
unsigned Bias = ELFT::Is64Bits ? 0 : 8;
- ArrayRef<Elf_Shdr> Sections = unwrapOrError(this->FileName, Obj->sections());
+ ArrayRef<Elf_Shdr> Sections = cantFail(Obj->sections());
OS << "There are " << to_string(Sections.size())
<< " section headers, starting at offset "
<< "0x" << to_hexString(Obj->getHeader()->e_shoff, false) << ":\n\n";
std::string Sections;
OS << format(" %2.2d ", Phnum++);
// Check if each section is in a segment and then print mapping.
- for (const Elf_Shdr &Sec : unwrapOrError(this->FileName, Obj->sections())) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
if (Sec.sh_type == ELF::SHT_NULL)
continue;
// Display sections that do not belong to a segment.
std::string Sections;
- for (const Elf_Shdr &Sec : unwrapOrError(this->FileName, Obj->sections())) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
if (BelongsToSegment.find(&Sec) == BelongsToSegment.end())
Sections +=
unwrapOrError(this->FileName, Obj->getSectionName(&Sec)).str() + ' ';
}
};
- ArrayRef<Elf_Shdr> Sections = unwrapOrError(this->FileName, Obj->sections());
+ ArrayRef<Elf_Shdr> Sections = cantFail(Obj->sections());
if (Obj->getHeader()->e_type != ELF::ET_CORE && !Sections.empty()) {
for (const auto &S : Sections) {
if (S.sh_type != SHT_NOTE)
};
unsigned I = -1;
- for (const Elf_Shdr &Shdr : unwrapOrError(this->FileName, Obj->sections())) {
+ for (const Elf_Shdr &Shdr : cantFail(Obj->sections())) {
++I;
if (Shdr.sh_type != ELF::SHT_LLVM_DEPENDENT_LIBRARIES)
continue;
ListScope D(W, "Relocations");
int SectionNumber = -1;
- for (const Elf_Shdr &Sec : unwrapOrError(this->FileName, Obj->sections())) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
++SectionNumber;
if (Sec.sh_type != ELF::SHT_REL && Sec.sh_type != ELF::SHT_RELA &&
ListScope SectionsD(W, "Sections");
int SectionIndex = -1;
- ArrayRef<Elf_Shdr> Sections = unwrapOrError(this->FileName, Obj->sections());
std::vector<EnumEntry<unsigned>> FlagsList =
getSectionFlagsForTarget(Obj->getHeader()->e_machine);
- for (const Elf_Shdr &Sec : Sections) {
+ for (const Elf_Shdr &Sec : cantFail(Obj->sections())) {
StringRef Name = "<?>";
if (Expected<StringRef> SecNameOrErr =
Obj->getSectionName(&Sec, this->dumper()->WarningHandler))
}
};
- ArrayRef<Elf_Shdr> Sections = unwrapOrError(this->FileName, Obj->sections());
+ ArrayRef<Elf_Shdr> Sections = cantFail(Obj->sections());
if (Obj->getHeader()->e_type != ELF::ET_CORE && !Sections.empty()) {
for (const auto &S : Sections) {
if (S.sh_type != SHT_NOTE)
ListScope L(W, "LinkerOptions");
unsigned I = -1;
- for (const Elf_Shdr &Shdr : unwrapOrError(this->FileName, Obj->sections())) {
+ for (const Elf_Shdr &Shdr : cantFail(Obj->sections())) {
++I;
if (Shdr.sh_type != ELF::SHT_LLVM_LINKER_OPTIONS)
continue;