1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-27 10:23:41 +03:00
This commit is contained in:
Rui Ueyama 2021-03-31 13:56:35 +09:00
parent a813b75e20
commit ceaab19706
2 changed files with 5 additions and 5 deletions

2
mold.h
View File

@ -1684,7 +1684,7 @@ inline u32 elf_hash(std::string_view name) {
return h;
}
inline u32 gnu_hash(std::string_view name) {
inline u32 djb_hash(std::string_view name) {
u32 h = 5381;
for (u8 c : name)
h = (h << 5) + h + c;

View File

@ -868,7 +868,7 @@ void DynsymSection<E>::sort_symbols(Context<E> &ctx) {
ctx.gnu_hash->symoffset = first_global - vec.begin();
tbb::parallel_for_each(first_global, vec.end(), [&](T &x) {
x.hash = gnu_hash(x.sym->name) % ctx.gnu_hash->num_buckets;
x.hash = djb_hash(x.sym->name) % ctx.gnu_hash->num_buckets;
});
tbb::parallel_sort(first_global, vec.end(), [&](const T &a, const T &b) {
@ -1006,12 +1006,12 @@ void GnuHashSection<E>::copy_buf(Context<E> &ctx) {
std::vector<u32> hashes(symbols.size());
for (i64 i = 0; i < symbols.size(); i++)
hashes[i] = gnu_hash(symbols[i]->name);
hashes[i] = djb_hash(symbols[i]->name);
// Write a bloom filter
u64 *bloom = (u64 *)(base + HEADER_SIZE);
typename E::word *bloom = (typename E::word *)(base + HEADER_SIZE);
for (i64 hash : hashes) {
i64 idx = (hash / 64) % num_bloom;
i64 idx = (hash / ELFCLASS_BITS) % num_bloom;
bloom[idx] |= (u64)1 << (hash % ELFCLASS_BITS);
bloom[idx] |= (u64)1 << ((hash >> BLOOM_SHIFT) % ELFCLASS_BITS);
}