[lld] [LLD][COFF] Generate redirection metadata for custom ARM64EC export thunks. (PR #105901)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 03:39:12 PDT 2024


================
@@ -2062,6 +2062,20 @@ void Writer::createECChunks() {
     if (auto thunk = dyn_cast<ECExportThunkChunk>(sym->getChunk())) {
       hexpthkSec->addChunk(thunk);
       exportThunks.push_back({thunk, thunk->target});
+    } else if (auto def = dyn_cast<DefinedRegular>(sym)) {
+      // Allow section chunk to be treated as an export thunk if it looks like
+      // one.
+      SectionChunk *chunk = def->getChunk();
+      if (!chunk->live || chunk->getMachine() != AMD64)
+        continue;
+      assert(sym->getName().starts_with("EXP+"));
+      StringRef targetName = sym->getName().substr(strlen("EXP+"));
+      Symbol *targetSym = ctx.symtab.find((targetName + "$hp_target").str());
+      if (!targetSym)
+        targetSym = ctx.symtab.find(targetName);
----------------
mstorsjo wrote:

Maybe add a comment here, that for an export thunk `EXP+#foo`, we're first looking for `#foo$hp_target`, but secondarily also for `#foo`. (I was wondering about this and scratching my head, overlooking the fact that we do look for the unsuffixed version two lines below...)

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


More information about the llvm-commits mailing list