diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -1989,11 +1989,6 @@ // Two input sections with different output sections should not be folded. // ICF runs after processSectionCommands() so that we know the output sections. if (config->icf != ICFLevel::None) { - // Compute isPreemptible early to be used by ICF. We may add more symbols - // later, so this loop cannot be merged with the later computeIsPreemptible - // pass which is used by scanRelocations(). - for (Symbol *sym : symtab->symbols()) - sym->isPreemptible = computeIsPreemptible(*sym); findKeepUniqueSections(args); doIcf(); } diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -452,6 +452,12 @@ // The main function of ICF. template void ICF::run() { + // Compute isPreemptible early. We may add more symbols later, so this loop + // cannot be merged with the later computeIsPreemptible() pass which is used + // by scanRelocations(). + for (Symbol *sym : symtab->symbols()) + sym->isPreemptible = computeIsPreemptible(*sym); + // Collect sections to merge. for (InputSectionBase *sec : inputSections) { auto *s = cast(sec);