arm64 (aarch64) and PAGE_SIZE > 4KiB

Future: use prctl(PR_SET_MM, PR_SET_MM_START_BRK, addr)
https://github.com/upx/upx/issues/254
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c
This commit is contained in:
John Reiser 2019-03-01 20:31:41 -08:00
parent a9c08c6f52
commit d4e2d7e8a8
2 changed files with 4 additions and 2 deletions

View File

@ -519,7 +519,7 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
// So: pretend 4KiB pages.
upx_uint64_t const pm = (
Elf64_Ehdr::EM_X86_64 ==e_machine
|| Elf64_Ehdr::EM_AARCH64==e_machine
//|| Elf64_Ehdr::EM_AARCH64==e_machine
//|| Elf64_Ehdr::EM_PPC64 ==e_machine /* DOES NOT WORK! */
)
? ((~(upx_uint64_t)0)<<12)

View File

@ -409,7 +409,9 @@ xfind_pages(unsigned mflags, Elf64_Phdr const *phdr, int phnum,
}
}
DPRINTF(" addr=%%p lo=%%p hi=%%p\\n", addr, lo, hi);
addr = (Elf64_Addr)mmap((void *)addr, hi, PROT_NONE, mflags, -1, 0);
// PROT_WRITE allows testing of 64k pages on 4k Linux
addr = (Elf64_Addr)mmap((void *)addr, hi, (DEBUG ? PROT_WRITE : PROT_NONE), // FIXME XXX EVIL
mflags, -1, 0);
DPRINTF(" addr=%%p\\n", addr);
*p_brk = hi + addr; // the logical value of brk(0)
return (Elf64_Addr)(addr - lo);