comparison backend_x86.c @ 2113:0013362c320c

Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
author Michael Pavone <pavone@retrodev.com>
date Sun, 13 Feb 2022 22:52:52 -0800
parents afc54649ebed
children 8554751f17b5
comparison
equal deleted inserted replaced
2112:3abb64bd0da6 2113:0013362c320c
336 } 336 }
337 337
338 ub_jcc = NULL; 338 ub_jcc = NULL;
339 } 339 }
340 if (memmap[chunk].flags & MMAP_CODE) { 340 if (memmap[chunk].flags & MMAP_CODE) {
341 uint32_t added_offset; 341 uint32_t size = chunk_size(opts, memmap + chunk);
342 if (memmap[chunk].mask == opts->address_mask) { 342 uint32_t size_round_mask = (1 << (opts->ram_flags_shift + 3)) - 1;
343 added_offset = (memmap[chunk].end - memmap[chunk].start) / (1 << opts->ram_flags_shift) / 8; 343 if (size & size_round_mask) {
344 } else { 344 size &= ~size_round_mask;
345 added_offset = (memmap[chunk].mask + 1) / (1 << opts->ram_flags_shift) / 8; 345 size += size_round_mask + 1;
346 } 346 }
347 if (added_offset) { 347 ram_flags_off += size >> (opts->ram_flags_shift + 3);
348 ram_flags_off += added_offset;
349 } else {
350 ram_flags_off += 1;
351 }
352 } 348 }
353 if (need_wide_jcc) { 349 if (need_wide_jcc) {
354 need_wide_jcc = 0; 350 need_wide_jcc = 0;
355 } 351 }
356 } 352 }