mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Delete ELFEntityIterator. NFC.
llvm-svn: 242901
This commit is contained in:
parent
7feb9eaba0
commit
60b9bc96e6
@ -55,78 +55,6 @@ public:
|
||||
typedef typename std::conditional<ELFT::Is64Bits,
|
||||
uint64_t, uint32_t>::type uintX_t;
|
||||
|
||||
/// \brief Iterate over constant sized entities.
|
||||
template <class EntT>
|
||||
class ELFEntityIterator {
|
||||
public:
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef EntT value_type;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef value_type &reference;
|
||||
typedef value_type *pointer;
|
||||
|
||||
/// \brief Default construct iterator.
|
||||
ELFEntityIterator() : EntitySize(0), Current(nullptr) {}
|
||||
ELFEntityIterator(uintX_t EntSize, const char *Start)
|
||||
: EntitySize(EntSize), Current(Start) {}
|
||||
|
||||
reference operator *() {
|
||||
assert(Current && "Attempted to dereference an invalid iterator!");
|
||||
return *reinterpret_cast<pointer>(Current);
|
||||
}
|
||||
|
||||
pointer operator ->() {
|
||||
assert(Current && "Attempted to dereference an invalid iterator!");
|
||||
return reinterpret_cast<pointer>(Current);
|
||||
}
|
||||
|
||||
bool operator ==(const ELFEntityIterator &Other) {
|
||||
return Current == Other.Current;
|
||||
}
|
||||
|
||||
bool operator !=(const ELFEntityIterator &Other) {
|
||||
return !(*this == Other);
|
||||
}
|
||||
|
||||
ELFEntityIterator &operator ++() {
|
||||
assert(Current && "Attempted to increment an invalid iterator!");
|
||||
Current += EntitySize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ELFEntityIterator &operator+(difference_type n) {
|
||||
assert(Current && "Attempted to increment an invalid iterator!");
|
||||
Current += (n * EntitySize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ELFEntityIterator &operator-(difference_type n) {
|
||||
assert(Current && "Attempted to subtract an invalid iterator!");
|
||||
Current -= (n * EntitySize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ELFEntityIterator operator ++(int) {
|
||||
ELFEntityIterator Tmp = *this;
|
||||
++*this;
|
||||
return Tmp;
|
||||
}
|
||||
|
||||
difference_type operator -(const ELFEntityIterator &Other) const {
|
||||
assert(EntitySize == Other.EntitySize &&
|
||||
"Subtracting iterators of different EntitySize!");
|
||||
return (Current - Other.Current) / EntitySize;
|
||||
}
|
||||
|
||||
const char *get() const { return Current; }
|
||||
|
||||
uintX_t getEntSize() const { return EntitySize; }
|
||||
|
||||
private:
|
||||
uintX_t EntitySize;
|
||||
const char *Current;
|
||||
};
|
||||
|
||||
typedef Elf_Ehdr_Impl<ELFT> Elf_Ehdr;
|
||||
typedef Elf_Shdr_Impl<ELFT> Elf_Shdr;
|
||||
typedef Elf_Sym_Impl<ELFT> Elf_Sym;
|
||||
|
@ -1342,8 +1342,6 @@ public:
|
||||
|
||||
private:
|
||||
typedef typename ObjectFile::Elf_Addr GOTEntry;
|
||||
typedef typename ObjectFile::template ELFEntityIterator<const GOTEntry>
|
||||
GOTIter;
|
||||
|
||||
const ObjectFile *Obj;
|
||||
StreamWriter &W;
|
||||
@ -1354,16 +1352,18 @@ private:
|
||||
llvm::Optional<uint64_t> DtJmpRel;
|
||||
|
||||
std::size_t getGOTTotal(ArrayRef<uint8_t> GOT) const;
|
||||
GOTIter makeGOTIter(ArrayRef<uint8_t> GOT, std::size_t EntryNum);
|
||||
const GOTEntry *makeGOTIter(ArrayRef<uint8_t> GOT, std::size_t EntryNum);
|
||||
|
||||
void printGotEntry(uint64_t GotAddr, GOTIter BeginIt, GOTIter It);
|
||||
void printGlobalGotEntry(uint64_t GotAddr, GOTIter BeginIt, GOTIter It,
|
||||
const Elf_Sym *Sym, StringRef StrTable,
|
||||
bool IsDynamic);
|
||||
void printPLTEntry(uint64_t PLTAddr, GOTIter BeginIt, GOTIter It,
|
||||
StringRef Purpose);
|
||||
void printPLTEntry(uint64_t PLTAddr, GOTIter BeginIt, GOTIter It,
|
||||
StringRef StrTable, const Elf_Sym *Sym);
|
||||
void printGotEntry(uint64_t GotAddr, const GOTEntry *BeginIt,
|
||||
const GOTEntry *It);
|
||||
void printGlobalGotEntry(uint64_t GotAddr, const GOTEntry *BeginIt,
|
||||
const GOTEntry *It, const Elf_Sym *Sym,
|
||||
StringRef StrTable, bool IsDynamic);
|
||||
void printPLTEntry(uint64_t PLTAddr, const GOTEntry *BeginIt,
|
||||
const GOTEntry *It, StringRef Purpose);
|
||||
void printPLTEntry(uint64_t PLTAddr, const GOTEntry *BeginIt,
|
||||
const GOTEntry *It, StringRef StrTable,
|
||||
const Elf_Sym *Sym);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1445,9 +1445,9 @@ template <class ELFT> void MipsGOTParser<ELFT>::parseGOT() {
|
||||
return;
|
||||
}
|
||||
|
||||
GOTIter GotBegin = makeGOTIter(*GOT, 0);
|
||||
GOTIter GotLocalEnd = makeGOTIter(*GOT, *DtLocalGotNum);
|
||||
GOTIter It = GotBegin;
|
||||
const GOTEntry *GotBegin = makeGOTIter(*GOT, 0);
|
||||
const GOTEntry *GotLocalEnd = makeGOTIter(*GOT, *DtLocalGotNum);
|
||||
const GOTEntry *It = GotBegin;
|
||||
|
||||
DictScope GS(W, "Primary GOT");
|
||||
|
||||
@ -1477,7 +1477,8 @@ template <class ELFT> void MipsGOTParser<ELFT>::parseGOT() {
|
||||
{
|
||||
ListScope GS(W, "Global entries");
|
||||
|
||||
GOTIter GotGlobalEnd = makeGOTIter(*GOT, *DtLocalGotNum + GlobalGotNum);
|
||||
const GOTEntry *GotGlobalEnd =
|
||||
makeGOTIter(*GOT, *DtLocalGotNum + GlobalGotNum);
|
||||
const Elf_Sym *GotDynSym = DynSymBegin + *DtGotSym;
|
||||
for (; It != GotGlobalEnd; ++It) {
|
||||
DictScope D(W, "Entry");
|
||||
@ -1522,9 +1523,9 @@ template <class ELFT> void MipsGOTParser<ELFT>::parsePLT() {
|
||||
ErrorOr<StringRef> StrTable = Obj->getStringTableForSymtab(**SymTableOrErr);
|
||||
error(StrTable.getError());
|
||||
|
||||
GOTIter PLTBegin = makeGOTIter(*PLT, 0);
|
||||
GOTIter PLTEnd = makeGOTIter(*PLT, getGOTTotal(*PLT));
|
||||
GOTIter It = PLTBegin;
|
||||
const GOTEntry *PLTBegin = makeGOTIter(*PLT, 0);
|
||||
const GOTEntry *PLTEnd = makeGOTIter(*PLT, getGOTTotal(*PLT));
|
||||
const GOTEntry *It = PLTBegin;
|
||||
|
||||
DictScope GS(W, "PLT GOT");
|
||||
{
|
||||
@ -1566,15 +1567,16 @@ std::size_t MipsGOTParser<ELFT>::getGOTTotal(ArrayRef<uint8_t> GOT) const {
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
typename MipsGOTParser<ELFT>::GOTIter
|
||||
const typename MipsGOTParser<ELFT>::GOTEntry *
|
||||
MipsGOTParser<ELFT>::makeGOTIter(ArrayRef<uint8_t> GOT, std::size_t EntryNum) {
|
||||
const char *Data = reinterpret_cast<const char *>(GOT.data());
|
||||
return GOTIter(sizeof(GOTEntry), Data + EntryNum * sizeof(GOTEntry));
|
||||
return reinterpret_cast<const GOTEntry *>(Data + EntryNum * sizeof(GOTEntry));
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
void MipsGOTParser<ELFT>::printGotEntry(uint64_t GotAddr, GOTIter BeginIt,
|
||||
GOTIter It) {
|
||||
void MipsGOTParser<ELFT>::printGotEntry(uint64_t GotAddr,
|
||||
const GOTEntry *BeginIt,
|
||||
const GOTEntry *It) {
|
||||
int64_t Offset = std::distance(BeginIt, It) * sizeof(GOTEntry);
|
||||
W.printHex("Address", GotAddr + Offset);
|
||||
W.printNumber("Access", Offset - 0x7ff0);
|
||||
@ -1582,10 +1584,9 @@ void MipsGOTParser<ELFT>::printGotEntry(uint64_t GotAddr, GOTIter BeginIt,
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
void MipsGOTParser<ELFT>::printGlobalGotEntry(uint64_t GotAddr, GOTIter BeginIt,
|
||||
GOTIter It, const Elf_Sym *Sym,
|
||||
StringRef StrTable,
|
||||
bool IsDynamic) {
|
||||
void MipsGOTParser<ELFT>::printGlobalGotEntry(
|
||||
uint64_t GotAddr, const GOTEntry *BeginIt, const GOTEntry *It,
|
||||
const Elf_Sym *Sym, StringRef StrTable, bool IsDynamic) {
|
||||
printGotEntry(GotAddr, BeginIt, It);
|
||||
|
||||
W.printHex("Value", Sym->st_value);
|
||||
@ -1602,8 +1603,9 @@ void MipsGOTParser<ELFT>::printGlobalGotEntry(uint64_t GotAddr, GOTIter BeginIt,
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
void MipsGOTParser<ELFT>::printPLTEntry(uint64_t PLTAddr, GOTIter BeginIt,
|
||||
GOTIter It, StringRef Purpose) {
|
||||
void MipsGOTParser<ELFT>::printPLTEntry(uint64_t PLTAddr,
|
||||
const GOTEntry *BeginIt,
|
||||
const GOTEntry *It, StringRef Purpose) {
|
||||
DictScope D(W, "Entry");
|
||||
int64_t Offset = std::distance(BeginIt, It) * sizeof(GOTEntry);
|
||||
W.printHex("Address", PLTAddr + Offset);
|
||||
@ -1612,8 +1614,9 @@ void MipsGOTParser<ELFT>::printPLTEntry(uint64_t PLTAddr, GOTIter BeginIt,
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
void MipsGOTParser<ELFT>::printPLTEntry(uint64_t PLTAddr, GOTIter BeginIt,
|
||||
GOTIter It, StringRef StrTable,
|
||||
void MipsGOTParser<ELFT>::printPLTEntry(uint64_t PLTAddr,
|
||||
const GOTEntry *BeginIt,
|
||||
const GOTEntry *It, StringRef StrTable,
|
||||
const Elf_Sym *Sym) {
|
||||
DictScope D(W, "Entry");
|
||||
int64_t Offset = std::distance(BeginIt, It) * sizeof(GOTEntry);
|
||||
|
Loading…
x
Reference in New Issue
Block a user