GH-142621: JIT: Avoid memory load for symbols within 4GB on AArch64 (GH-142820)

This commit is contained in:
Mark Shannon 2025-12-17 12:07:07 +00:00 committed by GitHub
parent 248eb3efb3
commit c7dcb26520
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -432,6 +432,15 @@ patch_aarch64_33rx(unsigned char *location, uint64_t value)
loc32[1] = 0xF2A00000 | (get_bits(relaxed, 16, 16) << 5) | reg;
return;
}
int64_t page_delta = (relaxed >> 12) - ((uintptr_t)location >> 12);
if (page_delta >= -(1L << 20) &&
page_delta < (1L << 20))
{
// adrp reg, AAA; ldr reg, [reg + BBB] -> adrp reg, AAA; add reg, reg, BBB
patch_aarch64_21rx(location, relaxed);
loc32[1] = 0x91000000 | get_bits(relaxed, 0, 12) << 10 | reg << 5 | reg;
return;
}
relaxed = value - (uintptr_t)location;
if ((relaxed & 0x3) == 0 &&
(int64_t)relaxed >= -(1L << 19) &&