comparison backend_x86.c @ 760:656b1fded67f

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
author Michael Pavone <pavone@retrodev.com>
date Sun, 28 Jun 2015 13:30:17 -0700
parents e1dc98f7ed9f
children 381a3b2f6065
comparison
equal deleted inserted replaced
759:c47e1750c264 760:656b1fded67f
163 } else { 163 } else {
164 mov_rdispr(code, opts->scratch1, (intptr_t)memmap[chunk].buffer, opts->scratch1, tmp_size); 164 mov_rdispr(code, opts->scratch1, (intptr_t)memmap[chunk].buffer, opts->scratch1, tmp_size);
165 } 165 }
166 } else { 166 } else {
167 if (is_write) { 167 if (is_write) {
168 push_r(code, opts->scratch1); 168 push_r(code, opts->scratch2);
169 mov_ir(code, (intptr_t)memmap[chunk].buffer, opts->scratch1, SZ_PTR); 169 mov_ir(code, (intptr_t)memmap[chunk].buffer, opts->scratch2, SZ_PTR);
170 add_rr(code, opts->scratch1, opts->scratch2, SZ_PTR); 170 add_rdispr(code, RSP, 0, opts->scratch2, SZ_PTR);
171 pop_r(code, opts->scratch1);
172 mov_rrind(code, opts->scratch1, opts->scratch2, tmp_size); 171 mov_rrind(code, opts->scratch1, opts->scratch2, tmp_size);
172 if (is_write && (memmap[chunk].flags & MMAP_CODE)) {
173 pop_r(code, opts->scratch2);
174 } else {
175 add_ir(code, sizeof(void*), RSP, SZ_D);
176 }
173 } else { 177 } else {
174 push_r(code, opts->scratch2); 178 push_r(code, opts->scratch2);
175 mov_ir(code, (intptr_t)memmap[chunk].buffer, opts->scratch2, SZ_PTR); 179 mov_ir(code, (intptr_t)memmap[chunk].buffer, opts->scratch2, SZ_PTR);
176 mov_rindexr(code, opts->scratch2, opts->scratch1, 1, opts->scratch1, tmp_size); 180 mov_rindexr(code, opts->scratch2, opts->scratch1, 1, opts->scratch1, tmp_size);
177 pop_r(code, opts->scratch2); 181 pop_r(code, opts->scratch2);