# HG changeset patch # User Michael Pavone # Date 1435523417 25200 # Node ID 656b1fded67f8cc700d96c369f2e598439da3268 # Parent c47e1750c26428e4a2e5b9ba8f5ed7f3fcbc3717 Fix self modifying code checks on platforms like OS X on which guest RAM ends up at an address unreachable with a 32-bit displacement diff -r c47e1750c264 -r 656b1fded67f backend_x86.c --- a/backend_x86.c Sun Jun 28 10:21:51 2015 -0700 +++ b/backend_x86.c Sun Jun 28 13:30:17 2015 -0700 @@ -165,11 +165,15 @@ } } else { if (is_write) { - push_r(code, opts->scratch1); - mov_ir(code, (intptr_t)memmap[chunk].buffer, opts->scratch1, SZ_PTR); - add_rr(code, opts->scratch1, opts->scratch2, SZ_PTR); - pop_r(code, opts->scratch1); + push_r(code, opts->scratch2); + mov_ir(code, (intptr_t)memmap[chunk].buffer, opts->scratch2, SZ_PTR); + add_rdispr(code, RSP, 0, opts->scratch2, SZ_PTR); mov_rrind(code, opts->scratch1, opts->scratch2, tmp_size); + if (is_write && (memmap[chunk].flags & MMAP_CODE)) { + pop_r(code, opts->scratch2); + } else { + add_ir(code, sizeof(void*), RSP, SZ_D); + } } else { push_r(code, opts->scratch2); mov_ir(code, (intptr_t)memmap[chunk].buffer, opts->scratch2, SZ_PTR);