[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(
----------------
smithp35 wrote:

I think we should be able to do this without adding another symbol. Almost all sections will have a section symbol at offset 0x0. We should be able to use section symbol + addend rather than creating a new symbol.

Using an existing symbol will mean fewer test changes.

There is a member function of InputSectionBase called `getEnclosingSymbol` that could be used for this. However that can be quite expensive if called several times.

The `AArch64Err843419Patcher::init()` already traverses all the local symbols once to read the mapping symbols. It could be possible to add a map of `<InputSection*, Defined*>` where Defined is the section symbol for the InputSection. 

https://github.com/llvm/llvm-project/pull/170495


More information about the llvm-commits mailing list