diff --git a/gc_sections.cc b/gc_sections.cc index ab4e018f..d6f7c128 100644 --- a/gc_sections.cc +++ b/gc_sections.cc @@ -7,6 +7,8 @@ #include #include +typedef tbb::parallel_do_feeder 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 &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 collect_root_set() { // Mark all reachable sections static void mark(tbb::concurrent_vector roots) { Timer t("mark"); - tbb::parallel_do(roots, [&](InputSection *isec, - tbb::parallel_do_feeder &feeder) { + + tbb::parallel_do(roots, [&](InputSection *isec, Feeder &feeder) { visit(isec, feeder, 0); }); } diff --git a/main.cc b/main.cc index 80c180e9..df1a6128 100644 --- a/main.cc +++ b/main.cc @@ -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(); diff --git a/object_file.cc b/object_file.cc index 1119a240..ab93112a 100644 --- a/object_file.cc +++ b/object_file.cc @@ -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());