[JITLink][x86-64] Fix GOTPCRELX call/jmp relaxation to use PC-relative fixup (#190179)
The GOTPCRELX optimization in `optimizeGOTAndStubAccesses()` relaxes
`call *foo@GOTPCREL(%rip)` → `addr32 call foo` and `jmp
*foo@GOTPCREL(%rip)` → `jmp foo; nop`,
but sets the edge kind to `Pointer32` (absolute). Since `e8`/`e9` are
PC-relative instructions,
`applyFixup` writes the absolute address instead of the displacement —
producing a garbage target
and SIGSEGV when JIT code is far from the callee (e.g., non-PIE
executable with an arena allocator).
**Fix:**
- Guard: `TargetInRangeForImmU32` → `DisplacementInRangeForImmS32`
(displacement must fit in signed 32-bit, not absolute address in
unsigned 32-bit)
- Edge kind: `Pointer32` → `BranchPCRel32` (so `applyFixup` writes
`Target - (Fixup + 4) + Addend`)
**Tests:**
- Updated `ELF_got_plt_optimizations.s` to validate PC-relative
displacement via `next_pc()` instead of raw absolute address. Also fixed
the jmp test which was incorrectly checking `test_call_gotpcrelx`
instead of `test_jmp_gotpcrelx`.
- Added `ELF_gotpcrelx_no_relax.s`: regression test with slab at
`0x7fff00000000` and extern at `0x00401000` — verifies relaxation is
correctly skipped when displacement is out of int32 range.
The `mov` → `lea` path (using `Delta32`) is unaffected and was already
correct.
cc: @tqchen
Co-authored-by: Michael Buch <michaelbuch12@gmail.com>