[lld] [LLD][COFF] Create EC alias symbols for entry points and exports (PR #114297)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 10:03:05 PDT 2024


================
@@ -696,12 +696,33 @@ void LinkerDriver::addLibSearchPaths() {
   }
 }
 
-Symbol *LinkerDriver::addUndefined(StringRef name) {
+Symbol *LinkerDriver::addUndefined(StringRef name, bool aliasEC) {
   Symbol *b = ctx.symtab.addUndefined(name);
   if (!b->isGCRoot) {
     b->isGCRoot = true;
     ctx.config.gcroot.push_back(b);
   }
+
+  // On ARM64EC, a symbol may be defined in either its mangled or demangled form
+  // (or both). Define an anti-dependency symbol that binds both forms, similar
+  // to how compiler-generated code references external functions.
+  if (aliasEC && isArm64EC(ctx.config.machine)) {
+    if (std::optional<std::string> mangledName =
+            getArm64ECMangledFunctionName(name)) {
+      auto u = dyn_cast<Undefined>(b);
+      if (u && !u->weakAlias) {
+        Symbol *t = ctx.symtab.addUndefined(saver().save(*mangledName));
+        u->setWeakAlias(t, true);
+      }
+    } else {
+      std::optional<std::string> unmangledName =
+          getArm64ECDemangledFunctionName(name);
----------------
cjacek wrote:

Fixed, thanks!

https://github.com/llvm/llvm-project/pull/114297


More information about the llvm-commits mailing list