1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-22 02:20:51 +03:00
This commit is contained in:
Rui Ueyama 2021-03-13 20:36:23 +09:00
parent 42056c2197
commit 97092aa9a0
3 changed files with 12 additions and 10 deletions

View File

@ -7,6 +7,8 @@
#include <tbb/concurrent_vector.h>
#include <tbb/parallel_for_each.h>
typedef tbb::parallel_do_feeder<InputSection *> Feeder;
static bool is_init_fini(const InputSection &isec) {
return isec.shdr.sh_type == SHT_INIT_ARRAY ||
isec.shdr.sh_type == SHT_FINI_ARRAY ||
@ -21,9 +23,7 @@ static bool mark_section(InputSection *isec) {
return isec && isec->is_alive && !isec->is_visited.exchange(true);
}
static void visit(InputSection *isec,
tbb::parallel_do_feeder<InputSection *> &feeder,
i64 depth) {
static void visit(InputSection *isec, Feeder &feeder, i64 depth) {
assert(isec->is_visited);
// A relocation can refer either a section fragment (i.e. a piece of
@ -121,8 +121,8 @@ static tbb::concurrent_vector<InputSection *> collect_root_set() {
// Mark all reachable sections
static void mark(tbb::concurrent_vector<InputSection *> roots) {
Timer t("mark");
tbb::parallel_do(roots, [&](InputSection *isec,
tbb::parallel_do_feeder<InputSection *> &feeder) {
tbb::parallel_do(roots, [&](InputSection *isec, Feeder &feeder) {
visit(isec, feeder, 0);
});
}

View File

@ -350,8 +350,8 @@ static void convert_common_symbols() {
});
}
static void handle_mergeable_strings() {
Timer t("handle_mergeable_strings");
static void compute_merged_section_sizes() {
Timer t("compute_merged_section_sizes");
// Add an identification string to .comment.
const char *verstr = "mold linker";
@ -1128,8 +1128,8 @@ int main(int argc, char **argv) {
if (config.icf)
icf_sections();
// Merge string constants in SHF_MERGE sections.
handle_mergeable_strings();
// Compute sizes of sections containing mergeable strings.
compute_merged_section_sizes();
// Bin input sections into output sections
bin_sections();

View File

@ -823,12 +823,14 @@ void ObjectFile::convert_common_symbols() {
if (sym->file != this)
continue;
assert(sym->esym->st_value);
auto *shdr = new ElfShdr;
memset(shdr, 0, sizeof(*shdr));
shdr->sh_flags = SHF_ALLOC;
shdr->sh_type = SHT_NOBITS;
shdr->sh_size = elf_syms[i].st_size;
shdr->sh_addralign = 1;
shdr->sh_addralign = sym->esym->st_value;
InputSection *isec =
InputSection::create(*this, shdr, ".bss", sections.size());