On 16.04.2026 23:01, 'Farid Zakaria' via X86-64 System V Application Binary Interface wrote:
> Is there an appetite to support 3 additional relaxations?
> I would like to propose three new relocation types for the x86-64 ABI to
> enable linker relaxation of large code model (-mcmodel=large) sequences.
>
> This *should* allow binaries compiled with the large code model to recover
> most
> of the performance cost when targets are within +/-2 GiB, without breaking
> ABI compatibility.
>
> R_X86_64_LARGE_PC64
>
> ; before
> movabs $symbol, %rax
> ; after: when symbol is within +/-2 GiB of %rip
> lea symbol(%rip), %rax
> nop3 # 3-byte NOP padding to maintain code layout
Is this really a win, performance wise?
> R_X86_64_LARGE_CALL64
>
> ; before
> movabs $target, %r11
> call *%r11
> ; after: when symbol is within +/-2 GiB of %rip
> call target
> noop7
Some care may be needed with CALLs. When putting the NOP(s) last, the
return address put on the stack will change. This may or may not be
confusing to some specialized code. If it wasn't 7 bytes to cover,
I'd suggest using a couple of redundant prefixes, but 7 of them is
possibly too much.
> The one additional challenge with these new relaxations are they require
> two adjacent instructions (movabs + call) to be relaxed as a unit. This
> introduces a new constraint: the compiler must guarantee adjacency. LLVM
> has intrinsics to couple instructions together for the optimizer.
R_X86_64_LARGE_PC64 doesn't have this constraint, and we may want to
avoid such a constraint for the other two by instead introducing
relocation pairs (some other architectures have such, iirc). For
R_X86_64_LARGE_CALL64 this may mean using two more bytes (so the
indirect CALL can be separately replaced by a direct one). (In fact,
I wonder if it wouldn't be possible to leave the MOVABS alone, in
which case both relocations could be entirely independent.)
For R_X86_64_LARGE_GOTPCREL the MOVABS would be replaced by MOV or
LEA (plus however big of a NOP or redundant prefixes are still
needed), while the original MOV would simply become NOP.
Separate question: How does use of MOVABS fit with PIC/PIE?
Jan