1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-27 10:23:41 +03:00

Make GC to keep non-alloc section fragments

This commit is contained in:
Rui Ueyama 2021-03-17 23:36:19 +09:00
parent 614ddb309a
commit 942a0fe2ec

View File

@ -152,9 +152,23 @@ static void sweep() {
});
}
// Non-alloc section fragments are not subject of garbage collection.
// This function marks such fragments.
static void mark_nonalloc_fragments() {
Timer t("mark_nonalloc_fragments");
tbb::parallel_for_each(out::objs, [](ObjectFile *file) {
for (SectionFragment *frag : file->fragments)
if (!(frag->output_section.shdr.sh_flags & SHF_ALLOC))
frag->is_alive = true;
});
}
void gc_sections() {
Timer t("gc");
mark_nonalloc_fragments();
tbb::concurrent_vector<InputSection *> roots = collect_root_set();
mark(roots);
sweep();