diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-09-23 13:52:11 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-09-23 13:52:11 +0200 |
| commit | 5fe0a68b46ab6e4d085f1676a8cdd5c749ca54d1 (patch) | |
| tree | 0ae45c420aba9a4201fbcd2bdd8c5d0c90435301 /src | |
| parent | 61486749f83f3d5df6033bc80be1b2ecfebe11bc (diff) | |
| download | box64-5fe0a68b46ab6e4d085f1676a8cdd5c749ca54d1.tar.gz box64-5fe0a68b46ab6e4d085f1676a8cdd5c749ca54d1.zip | |
[NON4K] Try to fix elfloader when elf wants to load at an address not-compatible with pagesize
Diffstat (limited to 'src')
| -rw-r--r-- | src/elfs/elfloader.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c index a4ea5d0c..64fed8f4 100644 --- a/src/elfs/elfloader.c +++ b/src/elfs/elfloader.c @@ -240,6 +240,11 @@ int AllocLoadElfMemory(box64context_t* context, elfheader_t* head, int mainbin) image = (void*)(((uintptr_t)raw+max_align)&~max_align); } else { image = raw = mmap64((void*)head->vaddr, sz, 0, MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0); + if(head->vaddr&(box64_pagesize-1)) { + // load address might be lower + if((uintptr_t)image == head->vaddr&~(box64_pagesize-1)) + image = (void*)head->vaddr; + } } if(image!=MAP_FAILED && !head->vaddr && image!=(void*)offs) { printf_log(LOG_INFO, "%s: Mmap64 for (@%p 0x%zx) for elf \"%s\" returned %p(%p/0x%zx) instead\n", (((uintptr_t)image)&max_align)?"Error":"Warning", (void*)(head->vaddr?head->vaddr:offs), head->memsz, head->name, image, raw, head->align); |