[lld] [LLD][COFF] Add EC alias symbols for undefined x86_64 symbols on ARM64EC target (PR #114466)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 4 01:29:35 PST 2024
================
@@ -534,7 +534,22 @@ void ObjFile::initializeSymbols() {
Symbol *ObjFile::createUndefined(COFFSymbolRef sym, bool overrideLazy) {
StringRef name = check(coffObj->getSymbolName(sym));
- return ctx.symtab.addUndefined(name, this, overrideLazy);
+ Symbol *s = ctx.symtab.addUndefined(name, this, overrideLazy);
+
+ // Add an anti-dependency alias for undefined AMD64 symbols on the ARM64EC
+ // target.
+ if (isArm64EC(ctx.config.machine) && getMachineType() == AMD64) {
+ auto u = dyn_cast<Undefined>(s);
+ if (u && !u->weakAlias) {
+ if (std::optional<std::string> mangledName =
+ getArm64ECMangledFunctionName(name)) {
+ Symbol *m =
+ ctx.symtab.addUndefined(saver().save(*mangledName), this, false);
----------------
mstorsjo wrote:
Side note; literal bool parameters like false here, and true on the line below are quite hard to grasp unless you’re reading the called method at the same time. I think it may be more understandable if we’d add comments for these parameters about what they are; we have a pattern for that, `/*name=*/ false` (modulo spacing, I don’t remember what our canonical spacing is for these comments), which might make it clearer.
https://github.com/llvm/llvm-project/pull/114466
More information about the llvm-commits
mailing list