@@ -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_arm64xsameaddress:
496496 if (!file->symtab .isEC ())
@@ -1902,7 +1902,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
19021902
19031903 // Handle /alternatename
19041904 for (auto *arg : args.filtered (OPT_alternatename))
1905- parseAlternateName (arg->getValue ());
1905+ mainSymtab. parseAlternateName (arg->getValue ());
19061906
19071907 // Handle /include
19081908 for (auto *arg : args.filtered (OPT_incl))
@@ -2521,32 +2521,30 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
25212521 if (e.source != ExportSource::Directives)
25222522 e.symbolName = symtab.mangleMaybe (e.sym );
25232523 }
2524- });
25252524
2526- // Add weak aliases. Weak aliases is a mechanism to give remaining
2527- // undefined symbols final chance to be resolved successfully.
2528- for (auto pair : config->alternateNames ) {
2529- StringRef from = pair.first ;
2530- StringRef to = pair.second ;
2531- Symbol *sym = ctx.symtab .find (from);
2532- if (!sym)
2533- continue ;
2534- if (auto *u = dyn_cast<Undefined>(sym)) {
2535- if (u->weakAlias ) {
2536- // On ARM64EC, anti-dependency aliases are treated as undefined
2537- // symbols unless a demangled symbol aliases a defined one, which is
2538- // part of the implementation.
2539- if (!isArm64EC (ctx.config .machine ) || !u->isAntiDep )
2540- continue ;
2541- if (!isa<Undefined>(u->weakAlias ) &&
2542- !isArm64ECMangledFunctionName (u->getName ()))
2543- continue ;
2525+ // Add weak aliases. Weak aliases is a mechanism to give remaining
2526+ // undefined symbols final chance to be resolved successfully.
2527+ for (auto pair : symtab.alternateNames ) {
2528+ StringRef from = pair.first ;
2529+ StringRef to = pair.second ;
2530+ Symbol *sym = symtab.find (from);
2531+ if (!sym)
2532+ continue ;
2533+ if (auto *u = dyn_cast<Undefined>(sym)) {
2534+ if (u->weakAlias ) {
2535+ // On ARM64EC, anti-dependency aliases are treated as undefined
2536+ // symbols unless a demangled symbol aliases a defined one, which
2537+ // is part of the implementation.
2538+ if (!symtab.isEC () || !u->isAntiDep )
2539+ continue ;
2540+ if (!isa<Undefined>(u->weakAlias ) &&
2541+ !isArm64ECMangledFunctionName (u->getName ()))
2542+ continue ;
2543+ }
2544+ u->setWeakAlias (symtab.addUndefined (to));
25442545 }
2545- u->setWeakAlias (ctx.symtab .addUndefined (to));
25462546 }
2547- }
25482547
2549- ctx.forEachSymtab ([&](SymbolTable &symtab) {
25502548 // If any inputs are bitcode files, the LTO code generator may create
25512549 // references to library functions that are not explicit in the bitcode
25522550 // file's symbol table. If any of those library functions are defined in
0 commit comments