@@ -490,7 +490,7 @@ void LinkerDriver::parseDirectives(InputFile *file) {
490490 parseAligncomm (arg->getValue ());
491491 break ;
492492 case OPT_alternatename:
493- parseAlternateName (arg->getValue ());
493+ file-> symtab . parseAlternateName (arg->getValue ());
494494 break ;
495495 case OPT_defaultlib:
496496 if (std::optional<StringRef> path = findLibIfNew (arg->getValue ()))
@@ -1896,7 +1896,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
18961896
18971897 // Handle /alternatename
18981898 for (auto *arg : args.filtered (OPT_alternatename))
1899- parseAlternateName (arg->getValue ());
1899+ mainSymtab. parseAlternateName (arg->getValue ());
19001900
19011901 // Handle /include
19021902 for (auto *arg : args.filtered (OPT_incl))
@@ -2515,32 +2515,30 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
25152515 if (e.source != ExportSource::Directives)
25162516 e.symbolName = symtab.mangleMaybe (e.sym );
25172517 }
2518- });
25192518
2520- // Add weak aliases. Weak aliases is a mechanism to give remaining
2521- // undefined symbols final chance to be resolved successfully.
2522- for (auto pair : config->alternateNames ) {
2523- StringRef from = pair.first ;
2524- StringRef to = pair.second ;
2525- Symbol *sym = ctx.symtab .find (from);
2526- if (!sym)
2527- continue ;
2528- if (auto *u = dyn_cast<Undefined>(sym)) {
2529- if (u->weakAlias ) {
2530- // On ARM64EC, anti-dependency aliases are treated as undefined
2531- // symbols unless a demangled symbol aliases a defined one, which is
2532- // part of the implementation.
2533- if (!isArm64EC (ctx.config .machine ) || !u->isAntiDep )
2534- continue ;
2535- if (!isa<Undefined>(u->weakAlias ) &&
2536- !isArm64ECMangledFunctionName (u->getName ()))
2537- continue ;
2519+ // Add weak aliases. Weak aliases is a mechanism to give remaining
2520+ // undefined symbols final chance to be resolved successfully.
2521+ for (auto pair : symtab.alternateNames ) {
2522+ StringRef from = pair.first ;
2523+ StringRef to = pair.second ;
2524+ Symbol *sym = symtab.find (from);
2525+ if (!sym)
2526+ continue ;
2527+ if (auto *u = dyn_cast<Undefined>(sym)) {
2528+ if (u->weakAlias ) {
2529+ // On ARM64EC, anti-dependency aliases are treated as undefined
2530+ // symbols unless a demangled symbol aliases a defined one, which
2531+ // is part of the implementation.
2532+ if (!symtab.isEC () || !u->isAntiDep )
2533+ continue ;
2534+ if (!isa<Undefined>(u->weakAlias ) &&
2535+ !isArm64ECMangledFunctionName (u->getName ()))
2536+ continue ;
2537+ }
2538+ u->setWeakAlias (symtab.addUndefined (to));
25382539 }
2539- u->setWeakAlias (ctx.symtab .addUndefined (to));
25402540 }
2541- }
25422541
2543- ctx.forEachSymtab ([&](SymbolTable &symtab) {
25442542 // If any inputs are bitcode files, the LTO code generator may create
25452543 // references to library functions that are not explicit in the bitcode
25462544 // file's symbol table. If any of those library functions are defined in
0 commit comments