Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Dec 12, 2024
1 parent ea460af commit 6257f12
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/output-chunks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1931,17 +1931,14 @@ void HashSection<E>::copy_buf(Context<E> &ctx) {
Entry *buckets = hdr + 2;
Entry *chains = buckets + syms.size();

hdr[0] = hdr[1] = syms.size();

std::vector<u32> hashes(syms.size());
tbb::parallel_for((i64)1, (i64)syms.size(), [&](i64 i) {
hashes[i] = elf_hash(syms[i]->name()) % syms.size();
});

for (i64 i = 1; i < syms.size(); i++) {
i64 h = hashes[i];
chains[syms[i]->get_dynsym_idx(ctx)] = buckets[h];
buckets[h] = syms[i]->get_dynsym_idx(ctx);
hdr[0] = syms.size();
hdr[1] = syms.size();

for (Symbol<E> *sym : syms.subspan(1)) {
i64 i = sym->get_dynsym_idx(ctx);
i64 h = elf_hash(sym->name()) % syms.size();
chains[i] = buckets[h];
buckets[h] = i;
}
}

Expand Down

0 comments on commit 6257f12

Please sign in to comment.