File tree Expand file tree Collapse file tree 3 files changed +29
-22
lines changed
Expand file tree Collapse file tree 3 files changed +29
-22
lines changed Original file line number Diff line number Diff line change @@ -2527,28 +2527,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
25272527 e.symbolName = symtab.mangleMaybe (e.sym );
25282528 }
25292529
2530- // Add weak aliases. Weak aliases is a mechanism to give remaining
2531- // undefined symbols final chance to be resolved successfully.
2532- for (auto pair : symtab.alternateNames ) {
2533- StringRef from = pair.first ;
2534- StringRef to = pair.second ;
2535- Symbol *sym = symtab.find (from);
2536- if (!sym)
2537- continue ;
2538- if (auto *u = dyn_cast<Undefined>(sym)) {
2539- if (u->weakAlias ) {
2540- // On ARM64EC, anti-dependency aliases are treated as undefined
2541- // symbols unless a demangled symbol aliases a defined one, which
2542- // is part of the implementation.
2543- if (!symtab.isEC () || !u->isAntiDep )
2544- continue ;
2545- if (!isa<Undefined>(u->weakAlias ) &&
2546- !isArm64ECMangledFunctionName (u->getName ()))
2547- continue ;
2548- }
2549- u->setWeakAlias (symtab.addUndefined (to));
2550- }
2551- }
2530+ symtab.resolveAlternateNames ();
25522531 });
25532532
25542533 ctx.forEachActiveSymtab ([&](SymbolTable &symtab) {
Original file line number Diff line number Diff line change @@ -1344,6 +1344,31 @@ void SymbolTable::parseAlternateName(StringRef s) {
13441344 alternateNames.insert (it, std::make_pair (from, to));
13451345}
13461346
1347+ void SymbolTable::resolveAlternateNames () {
1348+ // Add weak aliases. Weak aliases is a mechanism to give remaining
1349+ // undefined symbols final chance to be resolved successfully.
1350+ for (auto pair : alternateNames) {
1351+ StringRef from = pair.first ;
1352+ StringRef to = pair.second ;
1353+ Symbol *sym = find (from);
1354+ if (!sym)
1355+ continue ;
1356+ if (auto *u = dyn_cast<Undefined>(sym)) {
1357+ if (u->weakAlias ) {
1358+ // On ARM64EC, anti-dependency aliases are treated as undefined
1359+ // symbols unless a demangled symbol aliases a defined one, which
1360+ // is part of the implementation.
1361+ if (!isEC () || !u->isAntiDep )
1362+ continue ;
1363+ if (!isa<Undefined>(u->weakAlias ) &&
1364+ !isArm64ECMangledFunctionName (u->getName ()))
1365+ continue ;
1366+ }
1367+ u->setWeakAlias (addUndefined (to));
1368+ }
1369+ }
1370+ }
1371+
13471372// Parses /aligncomm option argument.
13481373void SymbolTable::parseAligncomm (StringRef s) {
13491374 auto [name, align] = s.split (' ,' );
Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ class SymbolTable {
6969 // symbols and warn about imported local symbols.
7070 void resolveRemainingUndefines ();
7171
72+ // Try to resolve undefined symbols with alternate names.
73+ void resolveAlternateNames ();
74+
7275 // Load lazy objects that are needed for MinGW automatic import and for
7376 // doing stdcall fixups.
7477 void loadMinGWSymbols ();
You can’t perform that action at this time.
0 commit comments