- Notifications
You must be signed in to change notification settings - Fork14.5k
[LLD][COFF] Move resolving alternate names to SymbolTable (NFC)#149495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
cjacek wants to merge1 commit intollvm:mainChoose a base branch fromcjacek:symtab-altname
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+29 −22
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Member
llvmbot commentedJul 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@llvm/pr-subscribers-platform-windows @llvm/pr-subscribers-lld Author: Jacek Caban (cjacek) ChangesFull diff:https://github.com/llvm/llvm-project/pull/149495.diff 3 Files Affected:
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cppindex 283aeed1a19cd..f31cf0a42abbb 100644--- a/lld/COFF/Driver.cpp+++ b/lld/COFF/Driver.cpp@@ -2527,28 +2527,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { e.symbolName = symtab.mangleMaybe(e.sym); }- // Add weak aliases. Weak aliases is a mechanism to give remaining- // undefined symbols final chance to be resolved successfully.- for (auto pair : symtab.alternateNames) {- StringRef from = pair.first;- StringRef to = pair.second;- Symbol *sym = symtab.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 (!symtab.isEC() || !u->isAntiDep)- continue;- if (!isa<Undefined>(u->weakAlias) &&- !isArm64ECMangledFunctionName(u->getName()))- continue;- }- u->setWeakAlias(symtab.addUndefined(to));- }- }+ symtab.resolveAlternateNames(); }); ctx.forEachActiveSymtab([&](SymbolTable &symtab) {diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cppindex 0062df5820e63..1cf750393e6b3 100644--- a/lld/COFF/SymbolTable.cpp+++ b/lld/COFF/SymbolTable.cpp@@ -1344,6 +1344,31 @@ 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;+ }+ u->setWeakAlias(addUndefined(to));+ }+ }+}+ // Parses /aligncomm option argument. void SymbolTable::parseAligncomm(StringRef s) { auto [name, align] = s.split(',');diff --git a/lld/COFF/SymbolTable.h b/lld/COFF/SymbolTable.hindex 15e2644a6f519..7eb067640dc85 100644--- a/lld/COFF/SymbolTable.h+++ b/lld/COFF/SymbolTable.h@@ -69,6 +69,9 @@ class SymbolTable { // symbols and warn about imported local symbols. void resolveRemainingUndefines();+ // Try to resolve undefined symbols with alternate names.+ void resolveAlternateNames();+ // Load lazy objects that are needed for MinGW automatic import and for // doing stdcall fixups. void loadMinGWSymbols(); |
This is NFC preparation for alternate name fixes, for which an access to |
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.