[lld] [LLD][COFF] Generate X64 thunks for ARM64EC entry points and patchable functions. (PR #105499)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 14:11:47 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";
----------------
mstorsjo wrote:
Here, it'd be nice to have an assert that `s->getName()` actually does start with `EXP+`.
https://github.com/llvm/llvm-project/pull/105499
More information about the llvm-commits
mailing list