[lld] [lld][ELF] Add range extension thunks for x86-64 (PR #180266)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 7 11:23:40 PST 2026


================
@@ -2181,8 +2181,10 @@ bool ThunkCreator::createThunks(uint32_t pass,
 
             // On AArch64 and PPC, a jump/call relocation may be encoded as
             // STT_SECTION + non-zero addend, clear the addend after
-            // redirection.
-            if (ctx.arg.emachine != EM_MIPS)
+            // redirection. On x86-64, preserve the addend as it compensates
----------------
MaskRay wrote:

The jump/call target might be a STT_SECTION symbol with an addend. The code ensures that after redirecting to a thunk, the new relocation addend satisfies the instruction requirement. If you add a `call local` (`local` is a local symbol) test, this would likely reveal a bug in your impl.

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


More information about the llvm-commits mailing list