]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Include ModRM byte in x64 RIP range check
authorDimitris Panokostas <midwan@gmail.com>
Tue, 19 May 2026 21:56:20 +0000 (23:56 +0200)
committerDimitris Panokostas <midwan@gmail.com>
Tue, 19 May 2026 21:56:20 +0000 (23:56 +0200)
jit/codegen_x86.h

index 49f76f6c3f88023b2518e12673e7c3245dd5798e..43b783f6867b9e7e14dafd1d391955cb99eb1921 100644 (file)
@@ -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;
        }