From 19e2abc2f762c85d2bb831a9baac6dbc5a7459ee Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Tue, 19 May 2026 23:56:20 +0200 Subject: [PATCH] Include ModRM byte in x64 RIP range check --- jit/codegen_x86.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; } -- 2.47.3