From: Dimitris Panokostas Date: Tue, 19 May 2026 21:56:20 +0000 (+0200) Subject: Include ModRM byte in x64 RIP range check X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=19e2abc2f762c85d2bb831a9baac6dbc5a7459ee;p=francis%2Fwinuae.git Include ModRM byte in x64 RIP range check --- diff --git a/jit/codegen_x86.h b/jit/codegen_x86.h index 49f76f6c..43b783f6 100644 --- a/jit/codegen_x86.h +++ b/jit/codegen_x86.h @@ -423,11 +423,11 @@ static inline int x86_RIP_addressing_possible(uintptr addr, uintptr offset) #if X86_TARGET_64BIT /* * address of the next instruction. - * The opcode has already been emitted, - * so this is the size of a 32-bit displacement + + * The opcode has already been emitted, but the ModR/M byte has not, + * so this is the size of the ModR/M byte + a 32-bit displacement + * the size of any immediate value that is part of the instruction (offset), */ - uintptr next = (uintptr)get_target() + 4 + offset; + uintptr next = (uintptr)get_target() + 1 + 4 + offset; if (addr >= next) { return addr - next <= 0x7fffffffULL; }