@@ -2852,6 +2852,13 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
28522852 // Create dynamic sections for dynamic linking and static PIE.
28532853 config->hasDynSymTab = !ctx.sharedFiles .empty () || config->isPic ;
28542854
2855+ script->addScriptReferencedSymbolsToSymTable ();
2856+
2857+ // Prevent LTO from removing any definition referenced by -u.
2858+ for (StringRef name : config->undefined )
2859+ if (Defined *sym = dyn_cast_or_null<Defined>(symtab.find (name)))
2860+ sym->isUsedInRegularObj = true ;
2861+
28552862 // If an entry symbol is in a static archive, pull out that file now.
28562863 if (Symbol *sym = symtab.find (config->entry ))
28572864 handleUndefined (sym, " --entry" );
@@ -2860,16 +2867,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
28602867 for (StringRef pat : args::getStrings (args, OPT_undefined_glob))
28612868 handleUndefinedGlob (pat);
28622869
2863- // After potential archive member extraction involving ENTRY and
2864- // -u/--undefined-glob, check whether PROVIDE symbols should be defined (the
2865- // RHS may refer to definitions in just extracted object files).
2866- script->addScriptReferencedSymbolsToSymTable ();
2867-
2868- // Prevent LTO from removing any definition referenced by -u.
2869- for (StringRef name : config->undefined )
2870- if (Defined *sym = dyn_cast_or_null<Defined>(symtab.find (name)))
2871- sym->isUsedInRegularObj = true ;
2872-
28732870 // Mark -init and -fini symbols so that the LTO doesn't eliminate them.
28742871 if (Symbol *sym = dyn_cast_or_null<Defined>(symtab.find (config->init )))
28752872 sym->isUsedInRegularObj = true ;
0 commit comments