mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
[Object][ELF] Add {begin,end}_elf_dynamic_symbols to non-virtually iterate over dynamic symbols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174681 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3854a5d90f
commit
2e0742f76c
@ -520,7 +520,6 @@ public:
|
||||
const char *Current;
|
||||
};
|
||||
|
||||
private:
|
||||
typedef Elf_Ehdr_Impl<ELFT> Elf_Ehdr;
|
||||
typedef Elf_Shdr_Impl<ELFT> Elf_Shdr;
|
||||
typedef Elf_Sym_Impl<ELFT> Elf_Sym;
|
||||
@ -533,7 +532,10 @@ private:
|
||||
typedef Elf_Verneed_Impl<ELFT> Elf_Verneed;
|
||||
typedef Elf_Vernaux_Impl<ELFT> Elf_Vernaux;
|
||||
typedef Elf_Versym_Impl<ELFT> Elf_Versym;
|
||||
typedef ELFEntityIterator<const Elf_Dyn> dyn_iterator;
|
||||
typedef ELFEntityIterator<const Elf_Dyn> Elf_Dyn_iterator;
|
||||
typedef ELFEntityIterator<const Elf_Sym> Elf_Sym_iterator;
|
||||
typedef ELFEntityIterator<const Elf_Rela> Elf_Rela_Iter;
|
||||
typedef ELFEntityIterator<const Elf_Rel> Elf_Rel_Iter;
|
||||
|
||||
protected:
|
||||
// This flag is used for classof, to distinguish ELFObjectFile from
|
||||
@ -542,7 +544,7 @@ protected:
|
||||
bool isDyldELFObject;
|
||||
|
||||
private:
|
||||
typedef SmallVector<const Elf_Shdr*, 1> Sections_t;
|
||||
typedef SmallVector<const Elf_Shdr *, 2> Sections_t;
|
||||
typedef DenseMap<unsigned, unsigned> IndexMap_t;
|
||||
typedef DenseMap<const Elf_Shdr*, SmallVector<uint32_t, 1> > RelocMap_t;
|
||||
|
||||
@ -700,11 +702,24 @@ public:
|
||||
virtual library_iterator begin_libraries_needed() const;
|
||||
virtual library_iterator end_libraries_needed() const;
|
||||
|
||||
dyn_iterator begin_dynamic_table() const;
|
||||
dyn_iterator end_dynamic_table() const;
|
||||
Elf_Dyn_iterator begin_dynamic_table() const;
|
||||
Elf_Dyn_iterator end_dynamic_table() const;
|
||||
|
||||
typedef ELFEntityIterator<const Elf_Rela> Elf_Rela_Iter;
|
||||
typedef ELFEntityIterator<const Elf_Rel> Elf_Rel_Iter;
|
||||
Elf_Sym_iterator begin_elf_dynamic_symbols() const {
|
||||
const Elf_Shdr *DynSymtab = SymbolTableSections[0];
|
||||
if (DynSymtab)
|
||||
return Elf_Sym_iterator(DynSymtab->sh_entsize,
|
||||
(const char *)base() + DynSymtab->sh_offset);
|
||||
return Elf_Sym_iterator(0, 0);
|
||||
}
|
||||
|
||||
Elf_Sym_iterator end_elf_dynamic_symbols() const {
|
||||
const Elf_Shdr *DynSymtab = SymbolTableSections[0];
|
||||
if (DynSymtab)
|
||||
return Elf_Sym_iterator(DynSymtab->sh_entsize, (const char *)base() +
|
||||
DynSymtab->sh_offset + DynSymtab->sh_size);
|
||||
return Elf_Sym_iterator(0, 0);
|
||||
}
|
||||
|
||||
Elf_Rela_Iter beginELFRela(const Elf_Shdr *sec) const {
|
||||
return Elf_Rela_Iter(sec->sh_entsize,
|
||||
@ -2245,29 +2260,30 @@ section_iterator ELFObjectFile<ELFT>::end_sections() const {
|
||||
}
|
||||
|
||||
template<class ELFT>
|
||||
typename ELFObjectFile<ELFT>::dyn_iterator
|
||||
typename ELFObjectFile<ELFT>::Elf_Dyn_iterator
|
||||
ELFObjectFile<ELFT>::begin_dynamic_table() const {
|
||||
if (dot_dynamic_sec)
|
||||
return dyn_iterator(dot_dynamic_sec->sh_entsize,
|
||||
(const char *)base() + dot_dynamic_sec->sh_offset);
|
||||
return dyn_iterator(0, 0);
|
||||
return Elf_Dyn_iterator(dot_dynamic_sec->sh_entsize,
|
||||
(const char *)base() + dot_dynamic_sec->sh_offset);
|
||||
return Elf_Dyn_iterator(0, 0);
|
||||
}
|
||||
|
||||
template<class ELFT>
|
||||
typename ELFObjectFile<ELFT>::dyn_iterator
|
||||
typename ELFObjectFile<ELFT>::Elf_Dyn_iterator
|
||||
ELFObjectFile<ELFT>::end_dynamic_table() const {
|
||||
if (dot_dynamic_sec)
|
||||
return dyn_iterator(dot_dynamic_sec->sh_entsize, (const char *)base() +
|
||||
dot_dynamic_sec->sh_offset + dot_dynamic_sec->sh_size);
|
||||
return dyn_iterator(0, 0);
|
||||
return Elf_Dyn_iterator(dot_dynamic_sec->sh_entsize,
|
||||
(const char *)base() + dot_dynamic_sec->sh_offset +
|
||||
dot_dynamic_sec->sh_size);
|
||||
return Elf_Dyn_iterator(0, 0);
|
||||
}
|
||||
|
||||
template<class ELFT>
|
||||
StringRef ELFObjectFile<ELFT>::getLoadName() const {
|
||||
if (!dt_soname) {
|
||||
// Find the DT_SONAME entry
|
||||
dyn_iterator it = begin_dynamic_table();
|
||||
dyn_iterator ie = end_dynamic_table();
|
||||
Elf_Dyn_iterator it = begin_dynamic_table();
|
||||
Elf_Dyn_iterator ie = end_dynamic_table();
|
||||
for (; it != ie; ++it) {
|
||||
if (it->getTag() == ELF::DT_SONAME)
|
||||
break;
|
||||
@ -2286,9 +2302,9 @@ StringRef ELFObjectFile<ELFT>::getLoadName() const {
|
||||
template<class ELFT>
|
||||
library_iterator ELFObjectFile<ELFT>::begin_libraries_needed() const {
|
||||
// Find the first DT_NEEDED entry
|
||||
dyn_iterator i = begin_dynamic_table();
|
||||
dyn_iterator e = end_dynamic_table();
|
||||
while (i != e) {
|
||||
Elf_Dyn_iterator i = begin_dynamic_table();
|
||||
Elf_Dyn_iterator e = end_dynamic_table();
|
||||
for (; i != e; ++i) {
|
||||
if (i->getTag() == ELF::DT_NEEDED)
|
||||
break;
|
||||
}
|
||||
@ -2302,16 +2318,15 @@ template<class ELFT>
|
||||
error_code ELFObjectFile<ELFT>::getLibraryNext(DataRefImpl Data,
|
||||
LibraryRef &Result) const {
|
||||
// Use the same DataRefImpl format as DynRef.
|
||||
dyn_iterator i = dyn_iterator(dot_dynamic_sec->sh_entsize,
|
||||
reinterpret_cast<const char *>(Data.p));
|
||||
dyn_iterator e = end_dynamic_table();
|
||||
Elf_Dyn_iterator i = Elf_Dyn_iterator(dot_dynamic_sec->sh_entsize,
|
||||
reinterpret_cast<const char *>(Data.p));
|
||||
Elf_Dyn_iterator e = end_dynamic_table();
|
||||
|
||||
// Skip the current dynamic table entry.
|
||||
++i;
|
||||
|
||||
// Find the next DT_NEEDED entry.
|
||||
for (; i != e && i->getTag() != ELF::DT_NEEDED; ++i)
|
||||
;
|
||||
for (; i != e && i->getTag() != ELF::DT_NEEDED; ++i);
|
||||
|
||||
DataRefImpl DRI;
|
||||
DRI.p = reinterpret_cast<uintptr_t>(i.get());
|
||||
@ -2322,8 +2337,8 @@ error_code ELFObjectFile<ELFT>::getLibraryNext(DataRefImpl Data,
|
||||
template<class ELFT>
|
||||
error_code ELFObjectFile<ELFT>::getLibraryPath(DataRefImpl Data,
|
||||
StringRef &Res) const {
|
||||
dyn_iterator i = dyn_iterator(dot_dynamic_sec->sh_entsize,
|
||||
reinterpret_cast<const char *>(Data.p));
|
||||
Elf_Dyn_iterator i = Elf_Dyn_iterator(dot_dynamic_sec->sh_entsize,
|
||||
reinterpret_cast<const char *>(Data.p));
|
||||
if (i == end_dynamic_table())
|
||||
report_fatal_error("getLibraryPath() called on iterator end");
|
||||
|
||||
@ -2343,7 +2358,7 @@ error_code ELFObjectFile<ELFT>::getLibraryPath(DataRefImpl Data,
|
||||
|
||||
template<class ELFT>
|
||||
library_iterator ELFObjectFile<ELFT>::end_libraries_needed() const {
|
||||
dyn_iterator e = end_dynamic_table();
|
||||
Elf_Dyn_iterator e = end_dynamic_table();
|
||||
DataRefImpl DRI;
|
||||
DRI.p = reinterpret_cast<uintptr_t>(e.get());
|
||||
return library_iterator(LibraryRef(DRI, this));
|
||||
|
Loading…
x
Reference in New Issue
Block a user