[lld] [LLD][COFF] Redirect __imp_ Symbols to __imp_aux_ on ARM64EC for x64 sections (PR #108608)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 13:45:20 PDT 2024
================
@@ -587,6 +591,19 @@ void SymbolTable::initializeECThunks() {
sym = exitThunks.lookup(file->impECSym);
file->impchkThunk->exitThunk = dyn_cast_or_null<Defined>(sym);
}
+
+ // On ARM64EC, the __imp_ symbol references the auxiliary IAT, while the
+ // __imp_aux_ symbol references the regular IAT. However, x86_64 code expects
+ // both to reference the regular IAT, so adjust the symbol if necessary.
+ parallelForEach(ctx.objFileInstances, [&](ObjFile *file) {
+ if (file->getMachineType() != AMD64)
+ return;
+ for (auto &sym : file->getMutableSymbols()) {
+ auto impSym = dyn_cast_or_null<DefinedImportData>(sym);
+ if (impSym && impSym->file->impchkThunk && sym == impSym->file->impECSym)
+ sym = impSym->file->impSym;
----------------
mstorsjo wrote:
So, this doesn't change the `Symbol` itself, which would affect every reference to the symbol in the link, but just makes this particular `InputObject` point to another symbol instead? That sounds reasonable.
https://github.com/llvm/llvm-project/pull/108608
More information about the llvm-commits
mailing list