@@ -2852,6 +2852,13 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2852
2852
// Create dynamic sections for dynamic linking and static PIE.
2853
2853
config->hasDynSymTab = !ctx.sharedFiles .empty () || config->isPic ;
2854
2854
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
+
2855
2862
// If an entry symbol is in a static archive, pull out that file now.
2856
2863
if (Symbol *sym = symtab.find (config->entry ))
2857
2864
handleUndefined (sym, " --entry" );
@@ -2860,16 +2867,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2860
2867
for (StringRef pat : args::getStrings (args, OPT_undefined_glob))
2861
2868
handleUndefinedGlob (pat);
2862
2869
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
-
2873
2870
// Mark -init and -fini symbols so that the LTO doesn't eliminate them.
2874
2871
if (Symbol *sym = dyn_cast_or_null<Defined>(symtab.find (config->init )))
2875
2872
sym->isUsedInRegularObj = true ;
0 commit comments