Header->getDataEncoding() == ELF::ELFDATA2LSB;
}
- Elf_Shdr_Iter begin_sections() const;
- Elf_Shdr_Iter end_sections() const;
+ Elf_Shdr_Iter section_begin() const;
+ Elf_Shdr_Iter section_end() const;
Elf_Shdr_Range sections() const {
- return make_range(begin_sections(), end_sections());
+ return make_range(section_begin(), section_end());
}
- const Elf_Sym *begin_symbols() const;
- const Elf_Sym *end_symbols() const;
+ const Elf_Sym *symbol_begin() const;
+ const Elf_Sym *symbol_end() const;
Elf_Sym_Range symbols() const {
- return make_range(begin_symbols(), end_symbols());
+ return make_range(symbol_begin(), symbol_end());
}
- Elf_Dyn_Iter begin_dynamic_table() const;
+ Elf_Dyn_Iter dynamic_table_begin() const;
/// \param NULLEnd use one past the first DT_NULL entry as the end instead of
/// the section size.
- Elf_Dyn_Iter end_dynamic_table(bool NULLEnd = false) const;
+ Elf_Dyn_Iter dynamic_table_end(bool NULLEnd = false) const;
Elf_Dyn_Range dynamic_table(bool NULLEnd = false) const {
- return make_range(begin_dynamic_table(), end_dynamic_table(NULLEnd));
+ return make_range(dynamic_table_begin(), dynamic_table_end(NULLEnd));
}
- const Elf_Sym *begin_dynamic_symbols() const {
+ const Elf_Sym *dynamic_symbol_begin() const {
if (!DynSymRegion.Addr)
return nullptr;
if (DynSymRegion.EntSize != sizeof(Elf_Sym))
return reinterpret_cast<const Elf_Sym *>(DynSymRegion.Addr);
}
- const Elf_Sym *end_dynamic_symbols() const {
+ const Elf_Sym *dynamic_symbol_end() const {
if (!DynSymRegion.Addr)
return nullptr;
return reinterpret_cast<const Elf_Sym *>(
}
Elf_Sym_Range dynamic_symbols() const {
- return make_range(begin_dynamic_symbols(), end_dynamic_symbols());
+ return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
}
- Elf_Rela_Iter begin_dyn_rela() const {
+ Elf_Rela_Iter dyn_rela_begin() const {
if (DynRelaRegion.Addr)
return Elf_Rela_Iter(DynRelaRegion.EntSize,
(const char *)DynRelaRegion.Addr);
return Elf_Rela_Iter(0, nullptr);
}
- Elf_Rela_Iter end_dyn_rela() const {
+ Elf_Rela_Iter dyn_rela_end() const {
if (DynRelaRegion.Addr)
return Elf_Rela_Iter(
DynRelaRegion.EntSize,
return Elf_Rela_Iter(0, nullptr);
}
- Elf_Rela_Iter begin_rela(const Elf_Shdr *sec) const {
+ Elf_Rela_Iter rela_begin(const Elf_Shdr *sec) const {
return Elf_Rela_Iter(sec->sh_entsize,
(const char *)(base() + sec->sh_offset));
}
- Elf_Rela_Iter end_rela(const Elf_Shdr *sec) const {
+ Elf_Rela_Iter rela_end(const Elf_Shdr *sec) const {
return Elf_Rela_Iter(
sec->sh_entsize,
(const char *)(base() + sec->sh_offset + sec->sh_size));
}
- Elf_Rel_Iter begin_rel(const Elf_Shdr *sec) const {
+ Elf_Rel_Iter rel_begin(const Elf_Shdr *sec) const {
return Elf_Rel_Iter(sec->sh_entsize,
(const char *)(base() + sec->sh_offset));
}
- Elf_Rel_Iter end_rel(const Elf_Shdr *sec) const {
+ Elf_Rel_Iter rel_end(const Elf_Shdr *sec) const {
return Elf_Rel_Iter(sec->sh_entsize,
(const char *)(base() + sec->sh_offset + sec->sh_size));
}
/// \brief Iterate over program header table.
typedef ELFEntityIterator<const Elf_Phdr> Elf_Phdr_Iter;
- Elf_Phdr_Iter begin_program_headers() const {
+ Elf_Phdr_Iter program_header_begin() const {
return Elf_Phdr_Iter(Header->e_phentsize,
(const char*)base() + Header->e_phoff);
}
- Elf_Phdr_Iter end_program_headers() const {
+ Elf_Phdr_Iter program_header_end() const {
return Elf_Phdr_Iter(Header->e_phentsize,
(const char*)base() +
Header->e_phoff +
template <class ELFT>
const typename ELFFile<ELFT>::Elf_Sym *
ELFFile<ELFT>::getSymbol(uint32_t Index) const {
- return &*(begin_symbols() + Index);
+ return &*(symbol_begin() + Index);
}
template <class ELFT>
}
// Scan program headers.
- for (Elf_Phdr_Iter PhdrI = begin_program_headers(),
- PhdrE = end_program_headers();
+ for (Elf_Phdr_Iter PhdrI = program_header_begin(),
+ PhdrE = program_header_end();
PhdrI != PhdrE; ++PhdrI) {
if (PhdrI->p_type == ELF::PT_DYNAMIC) {
DynamicRegion.Addr = base() + PhdrI->p_offset;
}
// Scan dynamic table.
- for (Elf_Dyn_Iter DynI = begin_dynamic_table(), DynE = end_dynamic_table();
- DynI != DynE; ++DynI) {
+ for (Elf_Dyn_Iter DynI = dynamic_table_begin(), DynE = dynamic_table_end();
+ DynI != DynE; ++DynI) {
switch (DynI->d_tag) {
case ELF::DT_RELA: {
uint64_t VBase = 0;
const uint8_t *FBase = nullptr;
- for (Elf_Phdr_Iter PhdrI = begin_program_headers(),
- PhdrE = end_program_headers();
- PhdrI != PhdrE; ++PhdrI) {
+ for (Elf_Phdr_Iter PhdrI = program_header_begin(),
+ PhdrE = program_header_end();
+ PhdrI != PhdrE; ++PhdrI) {
if (PhdrI->p_type != ELF::PT_LOAD)
continue;
if (DynI->getPtr() >= PhdrI->p_vaddr &&
}
template <class ELFT>
-typename ELFFile<ELFT>::Elf_Shdr_Iter ELFFile<ELFT>::begin_sections() const {
+typename ELFFile<ELFT>::Elf_Shdr_Iter ELFFile<ELFT>::section_begin() const {
return Elf_Shdr_Iter(Header->e_shentsize,
(const char *)base() + Header->e_shoff);
}
template <class ELFT>
-typename ELFFile<ELFT>::Elf_Shdr_Iter ELFFile<ELFT>::end_sections() const {
+typename ELFFile<ELFT>::Elf_Shdr_Iter ELFFile<ELFT>::section_end() const {
return Elf_Shdr_Iter(Header->e_shentsize,
(const char *)base() + Header->e_shoff +
(getNumSections() * Header->e_shentsize));
}
template <class ELFT>
-const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::begin_symbols() const {
+const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::symbol_begin() const {
if (!dot_symtab_sec)
return nullptr;
if (dot_symtab_sec->sh_entsize != sizeof(Elf_Sym))
}
template <class ELFT>
-const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::end_symbols() const {
+const typename ELFFile<ELFT>::Elf_Sym *ELFFile<ELFT>::symbol_end() const {
if (!dot_symtab_sec)
return nullptr;
return reinterpret_cast<const Elf_Sym *>(base() + dot_symtab_sec->sh_offset +
template <class ELFT>
typename ELFFile<ELFT>::Elf_Dyn_Iter
-ELFFile<ELFT>::begin_dynamic_table() const {
+ELFFile<ELFT>::dynamic_table_begin() const {
if (DynamicRegion.Addr)
return Elf_Dyn_Iter(DynamicRegion.EntSize,
(const char *)DynamicRegion.Addr);
template <class ELFT>
typename ELFFile<ELFT>::Elf_Dyn_Iter
-ELFFile<ELFT>::end_dynamic_table(bool NULLEnd) const {
+ELFFile<ELFT>::dynamic_table_end(bool NULLEnd) const {
if (!DynamicRegion.Addr)
return Elf_Dyn_Iter(0, nullptr);
Elf_Dyn_Iter Ret(DynamicRegion.EntSize,
(const char *)DynamicRegion.Addr + DynamicRegion.Size);
if (NULLEnd) {
- Elf_Dyn_Iter Start = begin_dynamic_table();
+ Elf_Dyn_Iter Start = dynamic_table_begin();
while (Start != Ret && Start->getTag() != ELF::DT_NULL)
++Start;
Result |= SymbolRef::SF_Absolute;
if (ESym->getType() == ELF::STT_FILE || ESym->getType() == ELF::STT_SECTION ||
- ESym == EF.begin_symbols() || ESym == EF.begin_dynamic_symbols())
+ ESym == EF.symbol_begin() || ESym == EF.dynamic_symbol_begin())
Result |= SymbolRef::SF_FormatSpecific;
if (EF.getHeader()->e_machine == ELF::EM_ARM) {
relocation_iterator
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
DataRefImpl RelData;
- uintptr_t SHT = reinterpret_cast<uintptr_t>(EF.begin_sections().get());
+ uintptr_t SHT = reinterpret_cast<uintptr_t>(EF.section_begin().get());
RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
RelData.d.b = 0;
return relocation_iterator(RelocationRef(RelData, this));
relocation_iterator
ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
DataRefImpl RelData;
- uintptr_t SHT = reinterpret_cast<uintptr_t>(EF.begin_sections().get());
+ uintptr_t SHT = reinterpret_cast<uintptr_t>(EF.section_begin().get());
const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize;
if (S->sh_type != ELF::SHT_RELA && S->sh_type != ELF::SHT_REL)
default:
report_fatal_error("Invalid symbol table section type!");
case ELF::SHT_SYMTAB:
- SymbolData = toDRI(EF.begin_symbols() + symbolIdx, false);
+ SymbolData = toDRI(EF.symbol_begin() + symbolIdx, false);
break;
case ELF::SHT_DYNSYM:
- SymbolData = toDRI(EF.begin_dynamic_symbols() + symbolIdx, true);
+ SymbolData = toDRI(EF.dynamic_symbol_begin() + symbolIdx, true);
break;
}
template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin_impl() const {
- DataRefImpl Sym = toDRI(EF.begin_symbols(), false);
+ DataRefImpl Sym = toDRI(EF.symbol_begin(), false);
return basic_symbol_iterator(SymbolRef(Sym, this));
}
template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end_impl() const {
- DataRefImpl Sym = toDRI(EF.end_symbols(), false);
+ DataRefImpl Sym = toDRI(EF.symbol_end(), false);
return basic_symbol_iterator(SymbolRef(Sym, this));
}
template <class ELFT>
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
- DataRefImpl Sym = toDRI(EF.begin_dynamic_symbols(), true);
+ DataRefImpl Sym = toDRI(EF.dynamic_symbol_begin(), true);
return symbol_iterator(SymbolRef(Sym, this));
}
template <class ELFT>
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
- DataRefImpl Sym = toDRI(EF.end_dynamic_symbols(), true);
+ DataRefImpl Sym = toDRI(EF.dynamic_symbol_end(), true);
return symbol_iterator(SymbolRef(Sym, this));
}
template <class ELFT>
section_iterator ELFObjectFile<ELFT>::section_begin() const {
- return section_iterator(SectionRef(toDRI(EF.begin_sections()), this));
+ return section_iterator(SectionRef(toDRI(EF.section_begin()), this));
}
template <class ELFT>
section_iterator ELFObjectFile<ELFT>::section_end() const {
- return section_iterator(SectionRef(toDRI(EF.end_sections()), this));
+ return section_iterator(SectionRef(toDRI(EF.section_end()), this));
}
template <class ELFT>
StringRef ELFObjectFile<ELFT>::getLoadName() const {
- Elf_Dyn_Iter DI = EF.begin_dynamic_table();
- Elf_Dyn_Iter DE = EF.end_dynamic_table();
+ Elf_Dyn_Iter DI = EF.dynamic_table_begin();
+ Elf_Dyn_Iter DE = EF.dynamic_table_end();
while (DI != DE && DI->getTag() != ELF::DT_SONAME)
++DI;
template <class ELFT> void printProgramHeaders(const ELFFile<ELFT> *o) {
typedef ELFFile<ELFT> ELFO;
outs() << "Program Header:\n";
- for (typename ELFO::Elf_Phdr_Iter pi = o->begin_program_headers(),
- pe = o->end_program_headers();
- pi != pe; ++pi) {
+ for (typename ELFO::Elf_Phdr_Iter pi = o->program_header_begin(),
+ pe = o->program_header_end();
+ pi != pe; ++pi) {
switch (pi->p_type) {
case ELF::PT_LOAD:
outs() << " LOAD ";
/// handling table. Use this symbol to recover the actual exception handling
/// table.
- for (Elf_Shdr_iterator SI = ELF->begin_sections(), SE = ELF->end_sections();
+ for (Elf_Shdr_iterator SI = ELF->section_begin(), SE = ELF->section_end();
SI != SE; ++SI) {
if (SI->sh_type == ELF::SHT_REL && SI->sh_info == IndexSectionIndex) {
- for (Elf_Rel_iterator RI = ELF->begin_rel(&*SI), RE = ELF->end_rel(&*SI);
+ for (Elf_Rel_iterator RI = ELF->rel_begin(&*SI), RE = ELF->rel_end(&*SI);
RI != RE; ++RI) {
if (RI->r_offset == static_cast<unsigned>(IndexTableOffset)) {
typename object::ELFFile<ET>::Elf_Rela RelA;
DictScope UI(SW, "UnwindInformation");
int SectionIndex = 0;
- for (Elf_Shdr_iterator SI = ELF->begin_sections(), SE = ELF->end_sections();
+ for (Elf_Shdr_iterator SI = ELF->section_begin(), SE = ELF->section_end();
SI != SE; ++SI, ++SectionIndex) {
if (SI->sh_type == ELF::SHT_ARM_EXIDX) {
const Elf_Shdr *IT = &(*SI);
ListScope SectionsD(W, "Sections");
int SectionIndex = -1;
- for (typename ELFO::Elf_Shdr_Iter SecI = Obj->begin_sections(),
- SecE = Obj->end_sections();
+ for (typename ELFO::Elf_Shdr_Iter SecI = Obj->section_begin(),
+ SecE = Obj->section_end();
SecI != SecE; ++SecI) {
++SectionIndex;
ListScope D(W, "Relocations");
int SectionNumber = -1;
- for (typename ELFO::Elf_Shdr_Iter SecI = Obj->begin_sections(),
- SecE = Obj->end_sections();
+ for (typename ELFO::Elf_Shdr_Iter SecI = Obj->section_begin(),
+ SecE = Obj->section_end();
SecI != SecE; ++SecI) {
++SectionNumber;
void ELFDumper<ELFT>::printDynamicRelocations() {
W.startLine() << "Dynamic Relocations {\n";
W.indent();
- for (typename ELFO::Elf_Rela_Iter RelI = Obj->begin_dyn_rela(),
- RelE = Obj->end_dyn_rela();
- RelI != RelE; ++RelI) {
+ for (typename ELFO::Elf_Rela_Iter RelI = Obj->dyn_rela_begin(),
+ RelE = Obj->dyn_rela_end();
+ RelI != RelE; ++RelI) {
SmallString<32> RelocName;
Obj->getRelocationTypeName(RelI->getType(Obj->isMips64EL()), RelocName);
StringRef SymbolName;
uint32_t SymIndex = RelI->getSymbol(Obj->isMips64EL());
- const typename ELFO::Elf_Sym *Sym = Obj->begin_dynamic_symbols() + SymIndex;
+ const typename ELFO::Elf_Sym *Sym = Obj->dynamic_symbol_begin() + SymIndex;
SymbolName = errorOrDefault(Obj->getSymbolName(Sym, true));
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
void ELFDumper<ELFT>::printRelocations(const Elf_Shdr *Sec) {
switch (Sec->sh_type) {
case ELF::SHT_REL:
- for (typename ELFO::Elf_Rel_Iter RI = Obj->begin_rel(Sec),
- RE = Obj->end_rel(Sec);
+ for (typename ELFO::Elf_Rel_Iter RI = Obj->rel_begin(Sec),
+ RE = Obj->rel_end(Sec);
RI != RE; ++RI) {
typename ELFO::Elf_Rela Rela;
Rela.r_offset = RI->r_offset;
}
break;
case ELF::SHT_RELA:
- for (typename ELFO::Elf_Rela_Iter RI = Obj->begin_rela(Sec),
- RE = Obj->end_rela(Sec);
+ for (typename ELFO::Elf_Rela_Iter RI = Obj->rela_begin(Sec),
+ RE = Obj->rela_end(Sec);
RI != RE; ++RI) {
printRelocation(Sec, *RI);
}
void ELFDumper<ELFT>::printProgramHeaders() {
ListScope L(W, "ProgramHeaders");
- for (typename ELFO::Elf_Phdr_Iter PI = Obj->begin_program_headers(),
- PE = Obj->end_program_headers();
- PI != PE; ++PI) {
+ for (typename ELFO::Elf_Phdr_Iter PI = Obj->program_header_begin(),
+ PE = Obj->program_header_end();
+ PI != PE; ++PI) {
DictScope P(W, "ProgramHeader");
W.printHex ("Type",
getElfSegmentType(Obj->getHeader()->e_machine, PI->p_type),
}
DictScope BA(W, "BuildAttributes");
- for (ELFO::Elf_Shdr_Iter SI = Obj->begin_sections(), SE = Obj->end_sections();
+ for (ELFO::Elf_Shdr_Iter SI = Obj->section_begin(), SE = Obj->section_end();
SI != SE; ++SI) {
if (SI->sh_type != ELF::SHT_ARM_ATTRIBUTES)
continue;
return;
}
- const Elf_Sym *DynSymBegin = Obj->begin_dynamic_symbols();
- const Elf_Sym *DynSymEnd = Obj->end_dynamic_symbols();
+ const Elf_Sym *DynSymBegin = Obj->dynamic_symbol_begin();
+ const Elf_Sym *DynSymEnd = Obj->dynamic_symbol_end();
std::size_t DynSymTotal = std::size_t(std::distance(DynSymBegin, DynSymEnd));
if (DtGotSym > DynSymTotal) {
// Dump symbols
bool IsFirstSym = true;
- for (auto SI = Obj.begin_symbols(), SE = Obj.end_symbols(); SI != SE; ++SI) {
+ for (auto SI = Obj.symbol_begin(), SE = Obj.symbol_end(); SI != SE; ++SI) {
if (IsFirstSym) {
IsFirstSym = false;
continue;
if (std::error_code EC = dumpCommonRelocationSection(Shdr, *S))
return EC;
- for (auto RI = Obj.begin_rel(Shdr), RE = Obj.end_rel(Shdr); RI != RE;
- ++RI) {
+ for (auto RI = Obj.rel_begin(Shdr), RE = Obj.rel_end(Shdr); RI != RE; ++RI) {
ELFYAML::Relocation R;
if (std::error_code EC = dumpRelocation(Shdr, &*RI, R))
return EC;
if (std::error_code EC = dumpCommonRelocationSection(Shdr, *S))
return EC;
- for (auto RI = Obj.begin_rela(Shdr), RE = Obj.end_rela(Shdr); RI != RE;
+ for (auto RI = Obj.rela_begin(Shdr), RE = Obj.rela_end(Shdr); RI != RE;
++RI) {
ELFYAML::Relocation R;
if (std::error_code EC = dumpRelocation(Shdr, &*RI, R))