mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-18 13:34:04 +00:00
Don't do a walk over the dynamic table just to find DT_SONAME.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
052b66199d
commit
04d208815c
@ -198,9 +198,8 @@ private:
|
||||
DynRegionInfo DynStrRegion;
|
||||
DynRegionInfo DynRelaRegion;
|
||||
|
||||
// Pointer to SONAME entry in dynamic string table
|
||||
// This is set the first time getLoadName is called.
|
||||
mutable const char *dt_soname = nullptr;
|
||||
// SONAME entry in dynamic string table
|
||||
StringRef DTSoname;
|
||||
|
||||
// Records for each version index the corresponding Verdef or Vernaux entry.
|
||||
// This is filled the first time LoadVersionMap() is called.
|
||||
@ -749,6 +748,7 @@ template <class ELFT> void ELFFile<ELFT>::scanDynamicTable() {
|
||||
return this->base() + Phdr.p_offset + Delta;
|
||||
};
|
||||
|
||||
uint64_t SONameOffset = 0;
|
||||
for (const Elf_Dyn &Dyn : dynamic_table()) {
|
||||
switch (Dyn.d_tag) {
|
||||
case ELF::DT_HASH:
|
||||
@ -774,8 +774,14 @@ template <class ELFT> void ELFFile<ELFT>::scanDynamicTable() {
|
||||
break;
|
||||
case ELF::DT_RELAENT:
|
||||
DynRelaRegion.EntSize = Dyn.getVal();
|
||||
break;
|
||||
case ELF::DT_SONAME:
|
||||
SONameOffset = Dyn.getVal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (SONameOffset)
|
||||
DTSoname = getDynamicString(SONameOffset);
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
@ -826,16 +832,7 @@ ELFFile<ELFT>::dynamic_table_end() const {
|
||||
|
||||
template <class ELFT>
|
||||
StringRef ELFFile<ELFT>::getLoadName() const {
|
||||
if (!dt_soname) {
|
||||
dt_soname = "";
|
||||
// Find the DT_SONAME entry
|
||||
for (const auto &Entry : dynamic_table())
|
||||
if (Entry.getTag() == ELF::DT_SONAME) {
|
||||
dt_soname = getDynamicString(Entry.getVal());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return dt_soname;
|
||||
return DTSoname;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
Loading…
x
Reference in New Issue
Block a user