From 9b16317e1842af9b71837a43ffba04ca45689dcc Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Thu, 6 Oct 2016 09:25:43 -0700 Subject: Fix handling of MMAP_CODE chunks that also have MMAP_PTR_IDX set --- backend_x86.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'backend_x86.c') diff --git a/backend_x86.c b/backend_x86.c index 2c9f083..addc34e 100644 --- a/backend_x86.c +++ b/backend_x86.c @@ -141,10 +141,15 @@ code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t n if (opts->address_size != SZ_D) { movzx_rr(code, adr_reg, adr_reg, opts->address_size, SZ_D); } + if (is_write && (memmap[chunk].flags & MMAP_CODE)) { + push_r(code, adr_reg); + } add_rdispr(code, opts->context_reg, opts->mem_ptr_off + sizeof(void*) * memmap[chunk].ptr_index, adr_reg, SZ_PTR); if (is_write) { mov_rrind(code, opts->scratch1, opts->scratch2, size); - + if (memmap[chunk].flags & MMAP_CODE) { + pop_r(code, adr_reg); + } } else { mov_rindr(code, opts->scratch1, opts->scratch1, size); } -- cgit v1.2.3