diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/custommem.c | 5 | ||||
| -rw-r--r-- | src/elfs/elfloader.c | 2 | ||||
| -rw-r--r-- | src/include/custommem.h | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/src/custommem.c b/src/custommem.c index 77ea14f6..a389b32b 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -1217,6 +1217,7 @@ void updateProtection(uintptr_t addr, size_t size, uint32_t prot) void setProtection(uintptr_t addr, size_t size, uint32_t prot) { + size = ALIGN(size); mutex_lock(&mutex_prot); addMapMem(mapallmem, addr, addr+size-1); uintptr_t cur = addr & ~(box64_pagesize-1); @@ -1229,7 +1230,7 @@ void setProtection_mmap(uintptr_t addr, size_t size, uint32_t prot) { if(!size) return; - size = (size+box64_pagesize-1)&~(box64_pagesize-1); // round size + size = ALIGN(size); mutex_lock(&mutex_prot); addMapMem(mmapmem, addr, addr+size-1); mutex_unlock(&mutex_prot); @@ -1244,6 +1245,7 @@ void setProtection_mmap(uintptr_t addr, size_t size, uint32_t prot) void setProtection_elf(uintptr_t addr, size_t size, uint32_t prot) { + size = ALIGN(size); if(prot) setProtection(addr, size, prot); else { @@ -1308,6 +1310,7 @@ void loadProtectionFromMap() void freeProtection(uintptr_t addr, size_t size) { + size = ALIGN(size); dynarec_log(LOG_DEBUG, "freeProtection %p:%p\n", (void*)addr, (void*)(addr+size-1)); mutex_lock(&mutex_prot); removeMapMem(mapallmem, addr, addr+size-1); diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c index 461fcb0d..39c83abc 100644 --- a/src/elfs/elfloader.c +++ b/src/elfs/elfloader.c @@ -175,7 +175,7 @@ const char* ElfPath(elfheader_t* head) return NULL; return head->path; } -#define ALIGN(p) (((p)+box64_pagesize-1)&~(box64_pagesize-1)) + int AllocLoadElfMemory(box64context_t* context, elfheader_t* head, int mainbin) { uintptr_t offs = 0; diff --git a/src/include/custommem.h b/src/include/custommem.h index 38d63702..df1d652a 100644 --- a/src/include/custommem.h +++ b/src/include/custommem.h @@ -16,6 +16,8 @@ void customFree(void* p); #define krealloc customRealloc #define kfree customFree +#define ALIGN(p) (((p)+box64_pagesize-1)&~(box64_pagesize-1)) + #ifdef DYNAREC typedef struct dynablock_s dynablock_t; // custom protection flag to mark Page that are Write protected for Dynarec purpose |