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 @@ -2554,28 +2554,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
25542554 e.symbolName = symtab.mangleMaybe (e.sym );
25552555 }
25562556
2557- // Add weak aliases. Weak aliases is a mechanism to give remaining
2558- // undefined symbols final chance to be resolved successfully.
2559- for (auto pair : symtab.alternateNames ) {
2560- StringRef from = pair.first ;
2561- StringRef to = pair.second ;
2562- Symbol *sym = symtab.find (from);
2563- if (!sym)
2564- continue ;
2565- if (auto *u = dyn_cast<Undefined>(sym)) {
2566- if (u->weakAlias ) {
2567- // On ARM64EC, anti-dependency aliases are treated as undefined
2568- // symbols unless a demangled symbol aliases a defined one, which
2569- // is part of the implementation.
2570- if (!symtab.isEC () || !u->isAntiDep )
2571- continue ;
2572- if (!isa<Undefined>(u->weakAlias ) &&
2573- !isArm64ECMangledFunctionName (u->getName ()))
2574- continue ;
2575- }
2576- u->setWeakAlias (symtab.addUndefined (to));
2577- }
2578- }
2557+ symtab.resolveAlternateNames ();
25792558 });
25802559
25812560 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