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) {
2554
2554
e.symbolName = symtab.mangleMaybe (e.sym );
2555
2555
}
2556
2556
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 ();
2579
2558
});
2580
2559
2581
2560
ctx.forEachActiveSymtab ([&](SymbolTable &symtab) {
Original file line number Diff line number Diff line change @@ -1344,6 +1344,31 @@ void SymbolTable::parseAlternateName(StringRef s) {
1344
1344
alternateNames.insert (it, std::make_pair (from, to));
1345
1345
}
1346
1346
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
+
1347
1372
// Parses /aligncomm option argument.
1348
1373
void SymbolTable::parseAligncomm (StringRef s) {
1349
1374
auto [name, align] = s.split (' ,' );
Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ class SymbolTable {
69
69
// symbols and warn about imported local symbols.
70
70
void resolveRemainingUndefines ();
71
71
72
+ // Try to resolve undefined symbols with alternate names.
73
+ void resolveAlternateNames ();
74
+
72
75
// Load lazy objects that are needed for MinGW automatic import and for
73
76
// doing stdcall fixups.
74
77
void loadMinGWSymbols ();
You can’t perform that action at this time.
0 commit comments