# HG changeset patch # User Michael Pavone # Date 1483507122 28800 # Node ID 494234e7e88fd93c80694b4ba15574ac79ff94e6 # Parent be3df2d8530ae07f57c203ab54e54936811e10b2 Fix RAM flag offset calculation to take into account the existence of non-writeable MMAP_CODE chunks diff -r be3df2d8530a -r 494234e7e88f backend_x86.c --- a/backend_x86.c Tue Jan 03 20:43:35 2017 -0800 +++ b/backend_x86.c Tue Jan 03 21:18:42 2017 -0800 @@ -231,11 +231,6 @@ mov_rr(code, opts->scratch2, opts->scratch1, opts->address_size); shr_ir(code, opts->ram_flags_shift, opts->scratch1, opts->address_size); bt_rrdisp(code, opts->scratch1, opts->context_reg, ram_flags_off, opts->address_size); - if (memmap[chunk].mask == opts->address_mask) { - ram_flags_off += (memmap[chunk].end - memmap[chunk].start) / (1 << opts->ram_flags_shift) / 8; ; - } else { - ram_flags_off += (memmap[chunk].mask + 1) / (1 << opts->ram_flags_shift) / 8;; - } code_ptr not_code = code->cur + 1; jcc(code, CC_NC, code->cur + 2); if (memmap[chunk].mask != opts->address_mask) { @@ -267,6 +262,13 @@ } retn(code); } + if (memmap[chunk].flags & MMAP_CODE) { + if (memmap[chunk].mask == opts->address_mask) { + ram_flags_off += (memmap[chunk].end - memmap[chunk].start) / (1 << opts->ram_flags_shift) / 8; ; + } else { + ram_flags_off += (memmap[chunk].mask + 1) / (1 << opts->ram_flags_shift) / 8;; + } + } if (lb_jcc) { *lb_jcc = code->cur - (lb_jcc+1); lb_jcc = NULL;