[lld] [LLD][COFF] Redirect __imp_ Symbols to __imp_aux_ on ARM64EC for x64 sections (PR #108608)
Jacek Caban via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 14:59:45 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;
----------------
cjacek wrote:
Yes, this way if it's referenced by both x64 and ARM64EC objects, they will use different symbols.
Thanks for the review.
https://github.com/llvm/llvm-project/pull/108608
More information about the llvm-commits
mailing list