Do the wraparounds properly on 64-bit binaries, fixes #3421.
This commit is contained in:
@@ -657,6 +657,9 @@ uint8_t *
|
||||
getpccache(uint32_t a)
|
||||
{
|
||||
uint64_t a64 = (uint64_t) a;
|
||||
#if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)
|
||||
uint8_t *p;
|
||||
#endif
|
||||
uint32_t a2;
|
||||
|
||||
a2 = a;
|
||||
@@ -677,7 +680,12 @@ getpccache(uint32_t a)
|
||||
cpu_prefetch_cycles = cpu_mem_prefetch_cycles;
|
||||
}
|
||||
|
||||
#if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)
|
||||
p = &_mem_exec[a64 >> MEM_GRANULARITY_BITS][(uintptr_t) (a64 & MEM_GRANULARITY_PAGE) - (uintptr_t) (a2 & ~0xfff)];
|
||||
return (uint8_t *) (((uintptr_t) p & 0x00000000ffffffffULL) | ((uintptr_t) &_mem_exec[a64 >> MEM_GRANULARITY_BITS][0] & 0xffffffff00000000ULL));
|
||||
#else
|
||||
return &_mem_exec[a64 >> MEM_GRANULARITY_BITS][(uintptr_t) (a64 & MEM_GRANULARITY_PAGE) - (uintptr_t) (a2 & ~0xfff)];
|
||||
#endif
|
||||
}
|
||||
|
||||
mem_log("Bad getpccache %08X%08X\n", (uint32_t) (a64 >> 32), (uint32_t) (a64 & 0xffffffffULL));
|
||||
|
||||
Reference in New Issue
Block a user