Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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:main
base:main
Choose a base branch
Loading
fromcjacek:symtab-altname

Conversation

cjacek
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commentedJul 18, 2025
edited
Loading

@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-lld

Author: Jacek Caban (cjacek)

Changes

Full diff:https://github.com/llvm/llvm-project/pull/149495.diff

3 Files Affected:

  • (modified) lld/COFF/Driver.cpp (+1-22)
  • (modified) lld/COFF/SymbolTable.cpp (+25)
  • (modified) lld/COFF/SymbolTable.h (+3)
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();

@cjacek
Copy link
ContributorAuthor

This is NFC preparation for alternate name fixes, for which an access toforceLazy in this code is useful to avoid an extra lookup.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mstorsjomstorsjoAwaiting requested review from mstorsjo

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@cjacek@llvmbot

[8]ページ先頭

©2009-2025 Movatter.jp