diff options
| author | Jessica Clarke <jrtc27@jrtc27.com> | 2025-07-30 17:10:45 +0100 |
|---|---|---|
| committer | Jessica Clarke <jrtc27@jrtc27.com> | 2025-07-30 17:10:45 +0100 |
| commit | 3e93964b896023b1006d3c878effb68203d4d8dd (patch) | |
| tree | 3f03bb1729e07cce41f0c46947ba94f877b97b41 /lld/COFF/SymbolTable.cpp | |
| parent | 9da811368f7e9ab07bc9aa360eebca7f2ebcd53e (diff) | |
| parent | 52ddcfd8d6c078b3e5ae3c230eea67a466d64f0f (diff) | |
[𝘀𝗽𝗿] changes introduced through rebaseusers/jrtc27/spr/main.nfcielfmips-refactor-mipsgotsection-to-avoid-explicit-writes
Created using spr 1.3.5
[skip ci]
Diffstat (limited to 'lld/COFF/SymbolTable.cpp')
| -rw-r--r-- | lld/COFF/SymbolTable.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index 0062df5820e6..189e75dfc3ff 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -1344,6 +1344,43 @@ void SymbolTable::parseAlternateName(StringRef s) { alternateNames.insert(it, std::make_pair(from, to)); } +void SymbolTable::resolveAlternateNames() { + // Add weak aliases. Weak aliases is a mechanism to give remaining + // undefined symbols final chance to be resolved successfully. + for (auto pair : alternateNames) { + StringRef from = pair.first; + StringRef to = pair.second; + Symbol *sym = find(from); + if (!sym) + continue; + if (auto *u = dyn_cast<Undefined>(sym)) { + if (u->weakAlias) { + // On ARM64EC, anti-dependency aliases are treated as undefined + // symbols unless a demangled symbol aliases a defined one, which + // is part of the implementation. + if (!isEC() || !u->isAntiDep) + continue; + if (!isa<Undefined>(u->weakAlias) && + !isArm64ECMangledFunctionName(u->getName())) + continue; + } + + // Check if the destination symbol is defined. If not, skip it. + // It may still be resolved later if more input files are added. + // Also skip anti-dependency targets, as they can't be chained anyway. + Symbol *toSym = find(to); + if (!toSym) + continue; + auto toUndef = dyn_cast<Undefined>(toSym); + if (toUndef && (!toUndef->weakAlias || toUndef->isAntiDep)) + continue; + if (toSym->isLazy()) + forceLazy(toSym); + u->setWeakAlias(toSym); + } + } +} + // Parses /aligncomm option argument. void SymbolTable::parseAligncomm(StringRef s) { auto [name, align] = s.split(','); |
