[lld] [LLD][COFF] Generate X64 thunks for ARM64EC entry points and patchable functions. (PR #105499)
Jacek Caban via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 22 01:21:42 PDT 2024
================
@@ -1317,6 +1317,70 @@ void LinkerDriver::convertResources() {
f->includeResourceChunks();
}
+void LinkerDriver::maybeCreateECExportThunk(StringRef name, Symbol *&sym) {
+ Defined *def;
+ if (!sym)
+ return;
+ if (auto undef = dyn_cast<Undefined>(sym))
+ def = undef->getWeakAlias();
+ else
+ def = dyn_cast<Defined>(sym);
+ if (!def)
+ return;
+
+ if (def->getChunk()->getArm64ECRangeType() != chpe_range_type::Arm64EC)
+ return;
+ StringRef expName;
+ if (auto mangledName = getArm64ECMangledFunctionName(name))
+ expName = saver().save("EXP+" + *mangledName);
+ else
+ expName = saver().save("EXP+" + name);
+ sym = addUndefined(expName);
+ if (auto undef = dyn_cast<Undefined>(sym)) {
+ if (!undef->getWeakAlias()) {
+ auto thunk = make<ECExportThunkChunk>(def);
+ replaceSymbol<DefinedSynthetic>(undef, undef->getName(), thunk);
+ }
+ }
+}
+
+void LinkerDriver::createECExportThunks() {
+ // Check if EXP+ symbols have corresponding $hp_target symbols and use them
+ // to create export thunks when available.
+ for (auto &s : ctx.symtab.expSymbols) {
+ if (!s->isUsedInRegularObj)
+ continue;
+ auto targetName = s->getName().substr(strlen("EXP+")) + "$hp_target";
+ Symbol *expSym = ctx.symtab.find(toString(targetName));
----------------
cjacek wrote:
Yes, it's Twine, I messed it up. `toString()` is defined in `include/lld/Common/ErrorHandler.h`, but we may as well use `.str()`, so I changed that. I also renamed the variable.
https://github.com/llvm/llvm-project/pull/105499
More information about the llvm-commits
mailing list