mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
Simplify now that we can iterate backwards. NFC.
llvm-svn: 242715
This commit is contained in:
parent
e9061eb73e
commit
0f258e6887
@ -282,11 +282,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Elf_Dyn *dynamic_table_begin() const;
|
const Elf_Dyn *dynamic_table_begin() const;
|
||||||
/// \param NULLEnd use one past the first DT_NULL entry as the end instead of
|
const Elf_Dyn *dynamic_table_end() const;
|
||||||
/// the section size.
|
Elf_Dyn_Range dynamic_table() const {
|
||||||
const Elf_Dyn *dynamic_table_end(bool NULLEnd = false) const;
|
return make_range(dynamic_table_begin(), dynamic_table_end());
|
||||||
Elf_Dyn_Range dynamic_table(bool NULLEnd = false) const {
|
|
||||||
return make_range(dynamic_table_begin(), dynamic_table_end(NULLEnd));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Elf_Sym *dynamic_symbol_begin() const {
|
const Elf_Sym *dynamic_symbol_begin() const {
|
||||||
@ -818,24 +816,12 @@ ELFFile<ELFT>::dynamic_table_begin() const {
|
|||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
const typename ELFFile<ELFT>::Elf_Dyn *
|
const typename ELFFile<ELFT>::Elf_Dyn *
|
||||||
ELFFile<ELFT>::dynamic_table_end(bool NULLEnd) const {
|
ELFFile<ELFT>::dynamic_table_end() const {
|
||||||
uint64_t Size = DynamicRegion.Size;
|
uint64_t Size = DynamicRegion.Size;
|
||||||
if (Size % sizeof(Elf_Dyn))
|
if (Size % sizeof(Elf_Dyn))
|
||||||
report_fatal_error("Invalid dynamic table size");
|
report_fatal_error("Invalid dynamic table size");
|
||||||
|
|
||||||
const Elf_Dyn *Ret = dynamic_table_begin() + Size / sizeof(Elf_Dyn);
|
return dynamic_table_begin() + Size / sizeof(Elf_Dyn);
|
||||||
|
|
||||||
if (NULLEnd) {
|
|
||||||
const Elf_Dyn *Start = dynamic_table_begin();
|
|
||||||
while (Start != Ret && Start->getTag() != ELF::DT_NULL)
|
|
||||||
++Start;
|
|
||||||
|
|
||||||
// Include the DT_NULL.
|
|
||||||
if (Start != Ret)
|
|
||||||
++Start;
|
|
||||||
Ret = Start;
|
|
||||||
}
|
|
||||||
return Ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
|
@ -1052,9 +1052,20 @@ template <> void ELFDumper<ELFType<support::little, false>>::printUnwindInfo() {
|
|||||||
|
|
||||||
template<class ELFT>
|
template<class ELFT>
|
||||||
void ELFDumper<ELFT>::printDynamicTable() {
|
void ELFDumper<ELFT>::printDynamicTable() {
|
||||||
auto DynTable = Obj->dynamic_table(true);
|
auto I = Obj->dynamic_table_begin();
|
||||||
|
auto E = Obj->dynamic_table_end();
|
||||||
|
|
||||||
ptrdiff_t Total = std::distance(DynTable.begin(), DynTable.end());
|
if (I == E)
|
||||||
|
return;
|
||||||
|
|
||||||
|
--E;
|
||||||
|
while (I != E && E->getTag() == ELF::DT_NULL)
|
||||||
|
--E;
|
||||||
|
if (E->getTag() != ELF::DT_NULL)
|
||||||
|
++E;
|
||||||
|
++E;
|
||||||
|
|
||||||
|
ptrdiff_t Total = std::distance(I, E);
|
||||||
if (Total == 0)
|
if (Total == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1066,7 +1077,9 @@ void ELFDumper<ELFT>::printDynamicTable() {
|
|||||||
W.startLine()
|
W.startLine()
|
||||||
<< " Tag" << (Is64 ? " " : " ") << "Type"
|
<< " Tag" << (Is64 ? " " : " ") << "Type"
|
||||||
<< " " << "Name/Value\n";
|
<< " " << "Name/Value\n";
|
||||||
for (const auto &Entry : DynTable) {
|
while (I != E) {
|
||||||
|
const typename ELFO::Elf_Dyn &Entry = *I;
|
||||||
|
++I;
|
||||||
W.startLine()
|
W.startLine()
|
||||||
<< " "
|
<< " "
|
||||||
<< format(Is64 ? "0x%016" PRIX64 : "0x%08" PRIX64, Entry.getTag())
|
<< format(Is64 ? "0x%016" PRIX64 : "0x%08" PRIX64, Entry.getTag())
|
||||||
|
Loading…
Reference in New Issue
Block a user