for (size_t I = 0, E = A->RelocSections.size(); I != E; ++I) {
const Elf_Shdr *RA = A->RelocSections[I];
const Elf_Shdr *RB = B->RelocSections[I];
- ELFFile<ELFT> &FileA = A->File->getObj();
- ELFFile<ELFT> &FileB = B->File->getObj();
+ ELFFile<ELFT> FileA = A->File->getObj();
+ ELFFile<ELFT> FileB = B->File->getObj();
if (RA->sh_type == SHT_RELA) {
if (!relocationEq(check(FileA.relas(RA)), check(FileB.relas(RB))))
return false;
for (size_t I = 0, E = A->RelocSections.size(); I != E; ++I) {
const Elf_Shdr *RA = A->RelocSections[I];
const Elf_Shdr *RB = B->RelocSections[I];
- ELFFile<ELFT> &FileA = A->File->getObj();
- ELFFile<ELFT> &FileB = B->File->getObj();
+ ELFFile<ELFT> FileA = A->File->getObj();
+ ELFFile<ELFT> FileB = B->File->getObj();
if (RA->sh_type == SHT_RELA) {
if (!variableEq(A, B, check(FileA.relas(RA)), check(FileB.relas(RB))))
return false;
}
template <class ELFT>
-ELFFileBase<ELFT>::ELFFileBase(Kind K, MemoryBufferRef MB)
- : InputFile(K, MB), ELFObj(MB.getBuffer()) {
+ELFFileBase<ELFT>::ELFFileBase(Kind K, MemoryBufferRef MB) : InputFile(K, MB) {
EKind = getELFKind<ELFT>();
- EMachine = ELFObj.getHeader()->e_machine;
- OSABI = ELFObj.getHeader()->e_ident[llvm::ELF::EI_OSABI];
+ EMachine = getObj().getHeader()->e_machine;
+ OSABI = getObj().getHeader()->e_ident[llvm::ELF::EI_OSABI];
}
template <class ELFT>
template <class ELFT>
uint32_t ELFFileBase<ELFT>::getSectionIndex(const Elf_Sym &Sym) const {
- return check(ELFObj.getSectionIndex(&Sym, Symbols, SymtabSHNDX));
+ return check(getObj().getSectionIndex(&Sym, Symbols, SymtabSHNDX));
}
template <class ELFT>
void ELFFileBase<ELFT>::initSymtab(ArrayRef<Elf_Shdr> Sections,
const Elf_Shdr *Symtab) {
FirstNonLocal = Symtab->sh_info;
- Symbols = check(ELFObj.symbols(Symtab));
+ Symbols = check(getObj().symbols(Symtab));
if (FirstNonLocal == 0 || FirstNonLocal > Symbols.size())
fatal(getFilename(this) + ": invalid sh_info in symbol table");
- StringTable = check(ELFObj.getStringTableForSymtab(*Symtab, Sections));
+ StringTable = check(getObj().getStringTableForSymtab(*Symtab, Sections));
}
template <class ELFT>
template <class ELFT>
void elf::ObjectFile<ELFT>::parse(DenseSet<CachedHashStringRef> &ComdatGroups) {
// Read section and symbol tables.
- ArrayRef<Elf_Shdr> ObjSections = check(this->ELFObj.sections());
+ ArrayRef<Elf_Shdr> ObjSections = check(this->getObj().sections());
initializeSections(ComdatGroups, ObjSections);
initializeSymbols(ObjSections);
}
template <class ELFT>
ArrayRef<typename elf::ObjectFile<ELFT>::Elf_Word>
elf::ObjectFile<ELFT>::getShtGroupEntries(const Elf_Shdr &Sec) {
- const ELFFile<ELFT> &Obj = this->ELFObj;
+ const ELFFile<ELFT> &Obj = this->getObj();
ArrayRef<Elf_Word> Entries =
check(Obj.template getSectionContentsAsArray<Elf_Word>(&Sec));
if (Entries.empty() || Entries[0] != GRP_COMDAT)
void elf::ObjectFile<ELFT>::initializeSections(
DenseSet<CachedHashStringRef> &ComdatGroups,
ArrayRef<Elf_Shdr> ObjSections) {
- const ELFFile<ELFT> &Obj = this->ELFObj;
+ const ELFFile<ELFT> &Obj = this->getObj();
uint64_t Size = ObjSections.size();
Sections.resize(Size);
unsigned I = -1;
InputSectionBase<ELFT> *
elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec,
StringRef SectionStringTable) {
- StringRef Name = check(this->ELFObj.getSectionName(&Sec, SectionStringTable));
+ StringRef Name =
+ check(this->getObj().getSectionName(&Sec, SectionStringTable));
switch (Sec.sh_type) {
case SHT_ARM_ATTRIBUTES:
template <class ELFT>
const typename ELFT::Shdr *
SharedFile<ELFT>::getSection(const Elf_Sym &Sym) const {
- return check(this->ELFObj.getSection(&Sym, this->Symbols, this->SymtabSHNDX));
+ return check(
+ this->getObj().getSection(&Sym, this->Symbols, this->SymtabSHNDX));
}
// Partially parse the shared object file so that we can call
typedef typename ELFT::uint uintX_t;
const Elf_Shdr *DynamicSec = nullptr;
- const ELFFile<ELFT> Obj = this->ELFObj;
+ const ELFFile<ELFT> Obj = this->getObj();
ArrayRef<Elf_Shdr> Sections = check(Obj.sections());
for (const Elf_Shdr &Sec : Sections) {
switch (Sec.sh_type) {
return Verdefs;
// The location of the first global versym entry.
- Versym = reinterpret_cast<const Elf_Versym *>(this->ELFObj.base() +
- VersymSec->sh_offset) +
+ const char *Base = this->MB.getBuffer().data();
+ Versym = reinterpret_cast<const Elf_Versym *>(Base + VersymSec->sh_offset) +
this->FirstNonLocal;
// We cannot determine the largest verdef identifier without inspecting
// Build the Verdefs array by following the chain of Elf_Verdef objects
// from the start of the .gnu.version_d section.
- const uint8_t *Verdef = this->ELFObj.base() + VerdefSec->sh_offset;
+ const char *Verdef = Base + VerdefSec->sh_offset;
for (unsigned I = 0; I != VerdefCount; ++I) {
auto *CurVerdef = reinterpret_cast<const Elf_Verdef *>(Verdef);
Verdef += CurVerdef->vd_next;