Skip to content

Commit b890456

Browse files
committed
Simplify code and add missing wri/rdi
1 parent 622712c commit b890456

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/patchelf.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ void ElfFile<ElfFileParamNames>::rebuildGnuHashTable(const char* strTab, span<El
19121912

19131913
// The hash table includes only a subset of dynsyms
19141914
auto firstSymIdx = rdi(ght.m_hdr.symndx);
1915-
auto symsToInsert = span(dynsyms.begin() + firstSymIdx, dynsyms.end());
1915+
dynsyms = span(dynsyms.begin() + firstSymIdx, dynsyms.end());
19161916

19171917
// Only use the range of symbol versions that will be changed
19181918
auto versyms = tryGetSectionSpan<Elf_Versym>(".gnu.version");
@@ -1925,10 +1925,10 @@ void ElfFile<ElfFileParamNames>::rebuildGnuHashTable(const char* strTab, span<El
19251925
};
19261926

19271927
std::vector<Entry> entries;
1928-
entries.reserve(symsToInsert.size());
1928+
entries.reserve(dynsyms.size());
19291929

19301930
uint32_t pos = 0; // Track the original position of the symbol in the table
1931-
for (auto& sym : symsToInsert)
1931+
for (auto& sym : dynsyms)
19321932
{
19331933
Entry e;
19341934
e.hash = gnuHash(strTab + rdi(sym.st_name));
@@ -1956,7 +1956,7 @@ void ElfFile<ElfFileParamNames>::rebuildGnuHashTable(const char* strTab, span<El
19561956
dst[old2new[i]] = tmp[i];
19571957
};
19581958

1959-
reorderSpan(symsToInsert, old2new);
1959+
reorderSpan(dynsyms, old2new);
19601960
if (versyms)
19611961
reorderSpan(versyms, old2new);
19621962

@@ -1970,9 +1970,8 @@ void ElfFile<ElfFileParamNames>::rebuildGnuHashTable(const char* strTab, span<El
19701970
if (oldSymIdx >= firstSymIdx)
19711971
{
19721972
auto newSymIdx = old2new[oldSymIdx - firstSymIdx] + firstSymIdx;
1973-
if (newSymIdx != oldSymIdx) {
1973+
if (newSymIdx != oldSymIdx)
19741974
wri(r.r_info, rel_setSymId(info, newSymIdx));
1975-
}
19761975
}
19771976
}
19781977
};
@@ -1995,7 +1994,7 @@ void ElfFile<ElfFileParamNames>::rebuildGnuHashTable(const char* strTab, span<El
19951994
size_t idx = (h / ElfClass) % ght.m_bloomFilters.size();
19961995
auto val = rdi(ght.m_bloomFilters[idx]);
19971996
val |= uint64_t(1) << (h % ElfClass);
1998-
val |= uint64_t(1) << ((h >> ght.m_hdr.shift2) % ElfClass);
1997+
val |= uint64_t(1) << ((h >> rdi(ght.m_hdr.shift2)) % ElfClass);
19991998
wri(ght.m_bloomFilters[idx], val);
20001999
}
20012000

@@ -2059,8 +2058,8 @@ void ElfFile<ElfFileParamNames>::rebuildHashTable(const char* strTab, span<Elf_S
20592058
auto name = strTab + rdi(sym.st_name);
20602059
uint32_t i = &sym - dynsyms.begin();
20612060
uint32_t hash = sysvHash(name) % ht.m_buckets.size();
2062-
ht.m_chain[i] = ht.m_buckets[hash];
2063-
ht.m_buckets[hash] = i;
2061+
wri(ht.m_chain[i], rdi(ht.m_buckets[hash]));
2062+
wri(ht.m_buckets[hash], i);
20642063
}
20652064
}
20662065

0 commit comments

Comments
 (0)