typedef typename ELFO::Elf_Sym Elf_Sym;
typedef typename ELFO::Elf_Dyn Elf_Dyn;
typedef typename ELFO::Elf_Dyn_Range Elf_Dyn_Range;
+ typedef typename ELFO::Elf_Rel Elf_Rel;
typedef typename ELFO::Elf_Rela Elf_Rela;
typedef typename ELFO::Elf_Rela_Range Elf_Rela_Range;
typedef typename ELFO::Elf_Phdr Elf_Phdr;
typedef typename ELFO::Elf_Hash Elf_Hash;
+ typedef typename ELFO::Elf_Ehdr Elf_Ehdr;
typedef typename ELFO::uintX_t uintX_t;
/// \brief Represents a region described by entries in the .dynamic table.
void printSymbol(const Elf_Sym *Symbol, StringRef StrTable, bool IsDynamic);
void printRelocations(const Elf_Shdr *Sec);
- void printRelocation(const Elf_Shdr *Sec, typename ELFO::Elf_Rela Rel);
+ void printRelocation(const Elf_Shdr *Sec, Elf_Rela Rel);
void printValue(uint64_t Type, uint64_t Value);
const Elf_Rela *dyn_rela_begin() const;
}
}
-template <class ELFT>
-static const typename ELFFile<ELFT>::Elf_Shdr *
-findSectionByAddress(const ELFFile<ELFT> *Obj, uint64_t Addr) {
+template <class ELFO>
+static const typename ELFO::Elf_Shdr *findSectionByAddress(const ELFO *Obj,
+ uint64_t Addr) {
for (const auto &Shdr : Obj->sections())
if (Shdr.sh_addr == Addr)
return &Shdr;
return nullptr;
}
-template <class ELFT>
-static const typename ELFFile<ELFT>::Elf_Shdr *
-findSectionByName(const ELFFile<ELFT> &Obj, StringRef Name) {
+template <class ELFO>
+static const typename ELFO::Elf_Shdr *findSectionByName(const ELFO &Obj,
+ StringRef Name) {
for (const auto &Shdr : Obj.sections()) {
if (Name == errorOrDefault(Obj.getSectionName(&Shdr)))
return &Shdr;
template<class ELFT>
void ELFDumper<ELFT>::printFileHeaders() {
- const typename ELFO::Elf_Ehdr *Header = Obj->getHeader();
+ const Elf_Ehdr *Header = Obj->getHeader();
{
DictScope D(W, "ElfHeader");
ListScope SectionsD(W, "Sections");
int SectionIndex = -1;
- for (const typename ELFO::Elf_Shdr &Sec : Obj->sections()) {
+ for (const Elf_Shdr &Sec : Obj->sections()) {
++SectionIndex;
StringRef Name = errorOrDefault(Obj->getSectionName(&Sec));
error(StrTableOrErr.getError());
StringRef StrTable = *StrTableOrErr;
- for (const typename ELFO::Elf_Sym &Sym : Obj->symbols()) {
+ for (const Elf_Sym &Sym : Obj->symbols()) {
ErrorOr<const Elf_Shdr *> SymSec = Obj->getSection(&Sym);
if (!SymSec)
continue;
ListScope D(W, "Relocations");
int SectionNumber = -1;
- for (const typename ELFO::Elf_Shdr &Sec : Obj->sections()) {
+ for (const Elf_Shdr &Sec : Obj->sections()) {
++SectionNumber;
if (Sec.sh_type != ELF::SHT_REL && Sec.sh_type != ELF::SHT_RELA)
void ELFDumper<ELFT>::printDynamicRelocations() {
W.startLine() << "Dynamic Relocations {\n";
W.indent();
- for (const typename ELFO::Elf_Rela &Rel : dyn_relas()) {
+ for (const Elf_Rela &Rel : dyn_relas()) {
SmallString<32> RelocName;
Obj->getRelocationTypeName(Rel.getType(Obj->isMips64EL()), RelocName);
StringRef SymbolName;
uint32_t SymIndex = Rel.getSymbol(Obj->isMips64EL());
- const typename ELFO::Elf_Sym *Sym = Obj->dynamic_symbol_begin() + SymIndex;
+ const Elf_Sym *Sym = Obj->dynamic_symbol_begin() + SymIndex;
SymbolName = errorOrDefault(Sym->getName(DynamicStringTable));
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
void ELFDumper<ELFT>::printRelocations(const Elf_Shdr *Sec) {
switch (Sec->sh_type) {
case ELF::SHT_REL:
- for (const typename ELFO::Elf_Rel &R : Obj->rels(Sec)) {
- typename ELFO::Elf_Rela Rela;
+ for (const Elf_Rel &R : Obj->rels(Sec)) {
+ Elf_Rela Rela;
Rela.r_offset = R.r_offset;
Rela.r_info = R.r_info;
Rela.r_addend = 0;
}
break;
case ELF::SHT_RELA:
- for (const typename ELFO::Elf_Rela &R : Obj->relas(Sec))
+ for (const Elf_Rela &R : Obj->relas(Sec))
printRelocation(Sec, R);
break;
}
}
template <class ELFT>
-void ELFDumper<ELFT>::printRelocation(const Elf_Shdr *Sec,
- typename ELFO::Elf_Rela Rel) {
+void ELFDumper<ELFT>::printRelocation(const Elf_Shdr *Sec, Elf_Rela Rel) {
SmallString<32> RelocName;
Obj->getRelocationTypeName(Rel.getType(Obj->isMips64EL()), RelocName);
StringRef TargetName;
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
error(StrTableOrErr.getError());
StringRef StrTable = *StrTableOrErr;
- for (const typename ELFO::Elf_Sym &Sym : Obj->symbols())
+ for (const Elf_Sym &Sym : Obj->symbols())
printSymbol(&Sym, StrTable, false);
}
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
error(StrTableOrErr.getError());
StringRef StrTable = *StrTableOrErr;
- for (const typename ELFO::Elf_Sym &Sym : Obj->dynamic_symbols())
+ for (const Elf_Sym &Sym : Obj->dynamic_symbols())
printSymbol(&Sym, StrTable, true);
}
template <class ELFT>
-void ELFDumper<ELFT>::printSymbol(const typename ELFO::Elf_Sym *Symbol,
- StringRef StrTable, bool IsDynamic) {
+void ELFDumper<ELFT>::printSymbol(const Elf_Sym *Symbol, StringRef StrTable,
+ bool IsDynamic) {
unsigned SectionIndex = 0;
StringRef SectionName;
getSectionNameIndex(*Obj, Symbol, SectionName, SectionIndex);
<< " Tag" << (Is64 ? " " : " ") << "Type"
<< " " << "Name/Value\n";
while (I != E) {
- const typename ELFO::Elf_Dyn &Entry = *I;
+ const Elf_Dyn &Entry = *I;
++I;
W.startLine()
<< " "
void ELFDumper<ELFT>::printProgramHeaders() {
ListScope L(W, "ProgramHeaders");
- for (const typename ELFO::Elf_Phdr &Phdr : Obj->program_headers()) {
+ for (const Elf_Phdr &Phdr : Obj->program_headers()) {
DictScope P(W, "ProgramHeader");
W.printHex("Type",
getElfSegmentType(Obj->getHeader()->e_machine, Phdr.p_type),
namespace {
template <class ELFT> class MipsGOTParser {
public:
- typedef object::ELFFile<ELFT> ObjectFile;
- typedef typename ObjectFile::Elf_Shdr Elf_Shdr;
- typedef typename ObjectFile::Elf_Sym Elf_Sym;
- typedef typename ObjectFile::Elf_Dyn_Range Elf_Dyn_Range;
+ typedef object::ELFFile<ELFT> ELFO;
+ typedef typename ELFO::Elf_Shdr Elf_Shdr;
+ typedef typename ELFO::Elf_Sym Elf_Sym;
+ typedef typename ELFO::Elf_Dyn_Range Elf_Dyn_Range;
+ typedef typename ELFO::Elf_Addr GOTEntry;
+ typedef typename ELFO::Elf_Rel Elf_Rel;
+ typedef typename ELFO::Elf_Rela Elf_Rela;
- MipsGOTParser(const ObjectFile *Obj, Elf_Dyn_Range DynTable, StreamWriter &W);
+ MipsGOTParser(const ELFO *Obj, Elf_Dyn_Range DynTable, StreamWriter &W);
void parseGOT();
void parsePLT();
private:
- typedef typename ObjectFile::Elf_Addr GOTEntry;
-
- const ObjectFile *Obj;
+ const ELFO *Obj;
StreamWriter &W;
llvm::Optional<uint64_t> DtPltGot;
llvm::Optional<uint64_t> DtLocalGotNum;
}
template <class ELFT>
-MipsGOTParser<ELFT>::MipsGOTParser(const ObjectFile *Obj,
- Elf_Dyn_Range DynTable, StreamWriter &W)
+MipsGOTParser<ELFT>::MipsGOTParser(const ELFO *Obj, Elf_Dyn_Range DynTable,
+ StreamWriter &W)
: Obj(Obj), W(W) {
for (const auto &Entry : DynTable) {
switch (Entry.getTag()) {
switch (PLTRelShdr->sh_type) {
case ELF::SHT_REL:
- for (const typename ObjectFile::Elf_Rel *RI = Obj->rel_begin(PLTRelShdr),
- *RE = Obj->rel_end(PLTRelShdr);
+ for (const Elf_Rel *RI = Obj->rel_begin(PLTRelShdr),
+ *RE = Obj->rel_end(PLTRelShdr);
RI != RE && It != PLTEnd; ++RI, ++It) {
const Elf_Sym *Sym =
Obj->getRelocationSymbol(&*PLTRelShdr, &*RI).second;
}
break;
case ELF::SHT_RELA:
- for (const typename ObjectFile::Elf_Rela
- *RI = Obj->rela_begin(PLTRelShdr),
- *RE = Obj->rela_end(PLTRelShdr);
+ for (const Elf_Rela *RI = Obj->rela_begin(PLTRelShdr),
+ *RE = Obj->rela_end(PLTRelShdr);
RI != RE && It != PLTEnd; ++RI, ++It) {
const Elf_Sym *Sym =
Obj->getRelocationSymbol(&*PLTRelShdr, &*RI).second;
}
template <class ELFT> void ELFDumper<ELFT>::printStackMap() const {
- const typename ELFFile<ELFT>::Elf_Shdr *StackMapSection = nullptr;
+ const Elf_Shdr *StackMapSection = nullptr;
for (const auto &Sec : Obj->sections()) {
ErrorOr<StringRef> Name = Obj->getSectionName(&Sec);
if (*Name == ".llvm_stackmaps") {