diff --git a/src/stub/src/amd64-linux.elf-fold.S b/src/stub/src/amd64-linux.elf-fold.S index f184f3c7..61962810 100644 --- a/src/stub/src/amd64-linux.elf-fold.S +++ b/src/stub/src/amd64-linux.elf-fold.S @@ -80,7 +80,7 @@ is_ptinterp= (1<<0) .balign 8 PAGE_MASK: .quad -1<<12 // default -// IN: [ADRX,+LENX): compressed data; [ADRU,+LENU): expanded fold (w/ upx_main) +// IN: [ADRX,+LENX): compressed data; [ADRU,+LENU): expanded fold (w/ upx_main2) // %rsp= %rbp= &F_ADRX; %r13= O_BINFO | is_ptinterp | unmap_all_pages // no 'section', thus '.text'; also loaded first in amd64-linux.elf-fold.bin. @@ -161,8 +161,8 @@ no_env_pse: mov %arg5,%r13 # save ELFA subq $ OVERHEAD,%rsp movq %rsp,%arg3 # &ELf64_Ehdr temporary space - call upx_main # Out: %rax= entry -/* entry= upx_main( + call upx_main2 # Out: %rax= entry +/* entry= upx_main2( b_info *arg1, {%rdi} total_size arg2, {%rsi} Elf64_Ehdr *arg3, {%rdx} @@ -200,7 +200,7 @@ p_memsz= 5*NBPW mov %ebx,%edi # fd call close no_pse_map: - pop %arg1 # ADRU: unfolded upx_main etc. + pop %arg1 # ADRU: unfolded upx_main2 etc. pop %arg2 # LENU push $__NR_munmap; pop %rax /*notrack*/ jmp *(%r14) # goto: syscall; pop %rdx; ret diff --git a/src/stub/src/amd64-linux.elf-main2.c b/src/stub/src/amd64-linux.elf-main2.c index dc0738d4..8c664e89 100644 --- a/src/stub/src/amd64-linux.elf-main2.c +++ b/src/stub/src/amd64-linux.elf-main2.c @@ -652,13 +652,13 @@ ERR_LAB /************************************************************************* -// upx_main - called by our entry code +// upx_main2 - called by our entry code // // This function is optimized for size. **************************************************************************/ void * -upx_main( // returns entry address +upx_main2( // returns entry address /*arg1*/ struct b_info const *const bi, // 1st block header /*arg2*/ size_t const sz_compressed, // total length /*arg3*/ ElfW(Ehdr) *const ehdr, // temp char[sz_ehdr] for decompressing @@ -672,7 +672,7 @@ upx_main( // returns entry address #endif //} ) { - DPRINTF("upx_main b_info=%%p sz_compressed=%%p ehdr=%%p av=%%p\\n", + DPRINTF("upx_main2 b_info=%%p sz_compressed=%%p ehdr=%%p av=%%p\\n", bi, sz_compressed, ehdr, av); #if defined(__powerpc64__) DPRINTF(" p_reloc=%%p\\n", p_reloc); @@ -690,13 +690,13 @@ upx_main( // returns entry address ElfW(Addr) *const p_reloc = &elfaddr; #endif //} ElfW(Addr) page_mask = get_page_mask(); (void)page_mask; - DPRINTF("upx_main1 .e_entry=%%p p_reloc=%%p *p_reloc=%%p page_mask=%%p\\n", + DPRINTF("upx_main21 .e_entry=%%p p_reloc=%%p *p_reloc=%%p page_mask=%%p\\n", ehdr->e_entry, p_reloc, *p_reloc, page_mask); ElfW(Phdr) *phdr = (ElfW(Phdr) *)(1+ ehdr); // De-compress Ehdr again into actual position, then de-compress the rest. ElfW(Addr) entry = do_xmap(ehdr, &xi1, 0, av, p_reloc); - DPRINTF("upx_main2 entry=%%p *p_reloc=%%p\\n", entry, *p_reloc); + DPRINTF("upx_main22 entry=%%p *p_reloc=%%p\\n", entry, *p_reloc); auxv_up(av, AT_ENTRY , entry); { // Map PT_INTERP program interpreter diff --git a/src/stub/src/arm64-linux.elf-fold.S b/src/stub/src/arm64-linux.elf-fold.S index c22142c4..760c3347 100644 --- a/src/stub/src/arm64-linux.elf-fold.S +++ b/src/stub/src/arm64-linux.elf-fold.S @@ -221,7 +221,7 @@ no_env_pse: mov x2,sp // ehdr mov w1,wLENC // total size of compressed data mov x0,xADRC // &b_info - call upx_main + call upx_main2 add sp,sp,#MAX_ELF_HDR_64 + OVERHEAD // un-alloca mov xfexp,x0 // entry address diff --git a/src/stub/src/i386-linux.elf-main2.c b/src/stub/src/i386-linux.elf-main2.c index 48acfee2..4eeaf6d6 100644 --- a/src/stub/src/i386-linux.elf-main2.c +++ b/src/stub/src/i386-linux.elf-main2.c @@ -283,7 +283,7 @@ extern long upx_mmap_and_fd( // x86_64 Android emulator of i386 is not faithful // Create (or find) an escape hatch to use when munmapping ourselves the stub. // Called by do_xmap to create it; remembered in AT_NULL.d_val static char * -make_hatch_i386( +make_hatch( ElfW(Phdr) const *const phdr, char *next_unc, unsigned frag_mask @@ -321,7 +321,7 @@ extern unsigned get_sys_munmap(void); #define NBPI 4 static void * -make_hatch_arm32( +make_hatch( ElfW(Phdr) const *const phdr, char *next_unc, unsigned frag_mask @@ -358,7 +358,7 @@ make_hatch_arm32( } #elif defined(__mips__) /*}{*/ static void * -make_hatch_mips( +make_hatch( ElfW(Phdr) const *const phdr, char *next_unc, unsigned frag_mask) @@ -398,7 +398,7 @@ make_hatch_mips( } #elif defined(__powerpc__) /*}{*/ static void * -make_hatch_ppc32( +make_hatch( ElfW(Phdr) const *const phdr, char *next_unc, unsigned frag_mask) @@ -702,15 +702,7 @@ do_xmap( } if (xi && phdr->p_flags & PF_X) { -#if defined(__i386__) //{ - void *const hatch = make_hatch_i386(phdr, xo.buf, ~page_mask); -#elif defined(__powerpc__) //}{ - void *const hatch = make_hatch_ppc32(phdr, xo.buf, ~page_mask); -#elif defined(__arm__) //}{ - void *const hatch = make_hatch_arm32(phdr, xo.buf, ~page_mask); -#elif defined(__mips__) //}{ - void *const hatch = make_hatch_mips(phdr, xo.buf, ~page_mask); -#endif //} + char *hatch = make_hatch(phdr, xo.buf, ~page_mask); if (0!=hatch) { // Always update AT_NULL, especially for compressed PT_INTERP. // Clearing lo bit of av is for i386 only; else is superfluous. diff --git a/src/stub/src/powerpc64-linux.elf-fold.S b/src/stub/src/powerpc64-linux.elf-fold.S index ac2d04cd..6b5140db 100644 --- a/src/stub/src/powerpc64-linux.elf-fold.S +++ b/src/stub/src/powerpc64-linux.elf-fold.S @@ -241,8 +241,8 @@ r_reloc= 32 - 1 # used slot in register save area mr a3,r_auxv // &Elf64_auxv_t la a4,SZ_FRAME+OVERHEAD + SZ_FRAME+(r_reloc * NBPW)(sp) // &p_reloc std r_elfa,0(a4) - call upx_main // Out: a0= entry -// entry= upx_main(b_info *a0, total_size a1, Elf64_Ehdr *a2, ELf32_auxv_t *a3, + call upx_main2 // Out: a0= entry +// entry= upx_main2(b_info *a0, total_size a1, Elf64_Ehdr *a2, ELf32_auxv_t *a3, // Elf64_Addr *p_reloc) la sp,SZ_FRAME+OVERHEAD(sp) // FR_01 deallocate this frame #if USE_TOC //{ @@ -296,7 +296,7 @@ sz_auxv= 2*NBPW li r0,SYS_munmap mtlr r_exp // entry address -// BIG_ENDIAN: r2 (TOC) already is live (set after return from upx_main) +// BIG_ENDIAN: r2 (TOC) already is live (set after return from upx_main2) // LITTLE_ENDIAN: r2 never is touched // ld 2,SZ_FRAME + (-1+ 2)*NBPW(sp) // r3,r4 are a0,a1 which are parameters to munmap()