[lld] Fix lld crash wrt generated thunks growing away from the patched code (PR #170495)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 3 08:56:22 PST 2025
================
@@ -399,6 +401,12 @@ Patch843419Section::Patch843419Section(Ctx &ctx, InputSection *p, uint64_t off)
ctx, ctx.saver.save("__CortexA53843419_" + utohexstr(getLDSTAddr())),
STT_FUNC, 0, getSize(), *this);
addSyntheticLocal(ctx, ctx.saver.save("$x"), STT_NOTYPE, 0, 0, *this);
+ retSym = addSyntheticLocal(
+ ctx, ctx.saver.save("__CortexA53843419_" + utohexstr(getLDSTAddr()) + "_ret"),
+ STT_FUNC, off + 4, 4, *p);
+
+ // Relocation must be created as soon as possible, so it'll be picked up.
----------------
smithp35 wrote:
For the comment I recommend something like:
> Use relocation for the direct branch patch return so that the Thunk code can range extend if the patch ends up too far away from the section being patched.
It will be clear to a LLD developer that adding in writeTo would be too late as that would be after Thunks had been created.
https://github.com/llvm/llvm-project/pull/170495
More information about the llvm-commits
mailing list