From d4e2d7e8a80e0e3d95e17bbc0bcf649bad3da19a Mon Sep 17 00:00:00 2001 From: John Reiser Date: Fri, 1 Mar 2019 20:31:41 -0800 Subject: [PATCH] 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 --- src/p_lx_elf.cpp | 2 +- src/stub/src/amd64-linux.elf-main.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index aa3479ad..f47f2c11 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -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) diff --git a/src/stub/src/amd64-linux.elf-main.c b/src/stub/src/amd64-linux.elf-main.c index a0d390a6..acf5f764 100644 --- a/src/stub/src/amd64-linux.elf-main.c +++ b/src/stub/src/amd64-linux.elf-main.c @@ -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);