From 053c9dc0e1e2e87b16e5baf54c5a7ded0d96d9cd Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Thu, 22 Sep 2016 09:54:39 +0200 Subject: [PATCH] stub: arm64: rename some files, remove unused files. --- .../arch/{arm/v8a => arm64/v8}/lzma_d-arm.S | 0 .../src/arch/{arm/v8a => arm64/v8}/lzma_d.S | 0 .../arch/{arm/v8a => arm64/v8}/lzma_d_cf.S | 0 .../src/arch/{arm/v8a => arm64/v8}/macros.S | 0 .../src/arch/{arm/v8a => arm64/v8}/nrv2b_d8.S | 0 .../src/arch/{arm/v8a => arm64/v8}/nrv2d_d8.S | 0 .../arch/{arm/v8a => arm64/v8}/nrv2e_d32.S | 0 .../src/arch/{arm/v8a => arm64/v8}/nrv2e_d8.S | 0 src/stub/src/arm64-darwin.macho-entry.S | 12 +- src/stub/src/arm64-darwin.macho-fold.S | 4 +- src/stub/src/arm64-darwin.macho-main.c | 2 +- src/stub/src/arm64-linux.elf-entry.S | 271 ----------- src/stub/src/arm64-linux.elf-fold.S | 451 ------------------ 13 files changed, 9 insertions(+), 731 deletions(-) rename src/stub/src/arch/{arm/v8a => arm64/v8}/lzma_d-arm.S (100%) rename src/stub/src/arch/{arm/v8a => arm64/v8}/lzma_d.S (100%) rename src/stub/src/arch/{arm/v8a => arm64/v8}/lzma_d_cf.S (100%) rename src/stub/src/arch/{arm/v8a => arm64/v8}/macros.S (100%) rename src/stub/src/arch/{arm/v8a => arm64/v8}/nrv2b_d8.S (100%) rename src/stub/src/arch/{arm/v8a => arm64/v8}/nrv2d_d8.S (100%) rename src/stub/src/arch/{arm/v8a => arm64/v8}/nrv2e_d32.S (100%) rename src/stub/src/arch/{arm/v8a => arm64/v8}/nrv2e_d8.S (100%) delete mode 100644 src/stub/src/arm64-linux.elf-entry.S delete mode 100644 src/stub/src/arm64-linux.elf-fold.S diff --git a/src/stub/src/arch/arm/v8a/lzma_d-arm.S b/src/stub/src/arch/arm64/v8/lzma_d-arm.S similarity index 100% rename from src/stub/src/arch/arm/v8a/lzma_d-arm.S rename to src/stub/src/arch/arm64/v8/lzma_d-arm.S diff --git a/src/stub/src/arch/arm/v8a/lzma_d.S b/src/stub/src/arch/arm64/v8/lzma_d.S similarity index 100% rename from src/stub/src/arch/arm/v8a/lzma_d.S rename to src/stub/src/arch/arm64/v8/lzma_d.S diff --git a/src/stub/src/arch/arm/v8a/lzma_d_cf.S b/src/stub/src/arch/arm64/v8/lzma_d_cf.S similarity index 100% rename from src/stub/src/arch/arm/v8a/lzma_d_cf.S rename to src/stub/src/arch/arm64/v8/lzma_d_cf.S diff --git a/src/stub/src/arch/arm/v8a/macros.S b/src/stub/src/arch/arm64/v8/macros.S similarity index 100% rename from src/stub/src/arch/arm/v8a/macros.S rename to src/stub/src/arch/arm64/v8/macros.S diff --git a/src/stub/src/arch/arm/v8a/nrv2b_d8.S b/src/stub/src/arch/arm64/v8/nrv2b_d8.S similarity index 100% rename from src/stub/src/arch/arm/v8a/nrv2b_d8.S rename to src/stub/src/arch/arm64/v8/nrv2b_d8.S diff --git a/src/stub/src/arch/arm/v8a/nrv2d_d8.S b/src/stub/src/arch/arm64/v8/nrv2d_d8.S similarity index 100% rename from src/stub/src/arch/arm/v8a/nrv2d_d8.S rename to src/stub/src/arch/arm64/v8/nrv2d_d8.S diff --git a/src/stub/src/arch/arm/v8a/nrv2e_d32.S b/src/stub/src/arch/arm64/v8/nrv2e_d32.S similarity index 100% rename from src/stub/src/arch/arm/v8a/nrv2e_d32.S rename to src/stub/src/arch/arm64/v8/nrv2e_d32.S diff --git a/src/stub/src/arch/arm/v8a/nrv2e_d8.S b/src/stub/src/arch/arm64/v8/nrv2e_d8.S similarity index 100% rename from src/stub/src/arch/arm/v8a/nrv2e_d8.S rename to src/stub/src/arch/arm64/v8/nrv2e_d8.S diff --git a/src/stub/src/arm64-darwin.macho-entry.S b/src/stub/src/arm64-darwin.macho-entry.S index 4bd2b032..a2ac278b 100644 --- a/src/stub/src/arm64-darwin.macho-entry.S +++ b/src/stub/src/arm64-darwin.macho-entry.S @@ -1,4 +1,4 @@ -/* arm-darwin.macho-entry.S -- iPhone program entry point & decompressor (Elf binary) +/* arm64-darwin.macho-entry.S -- iPhone program entry point & decompressor (Elf binary) * * This file is part of the UPX executable compressor. * @@ -42,7 +42,7 @@ #define lr x30 -#include "arch/arm/v8a/macros.S" +#include "arch/arm64/v8/macros.S" sz_b_info= 12 sz_unc= 0 @@ -97,18 +97,18 @@ f_decompress: // empty section NRV2E -#include "arch/arm/v8a/nrv2e_d8.S" +#include "arch/arm64/v8/nrv2e_d8.S" section NRV2D -#include "arch/arm/v8a/nrv2d_d8.S" +#include "arch/arm64/v8/nrv2d_d8.S" section NRV2B -#include "arch/arm/v8a/nrv2b_d8.S" +#include "arch/arm64/v8/nrv2b_d8.S" section NRV_TAIL // empty -#include "arch/arm/v8a/lzma_d.S" +#include "arch/arm64/v8/lzma_d.S" section MACHMAINY end_decompress: .globl end_decompress diff --git a/src/stub/src/arm64-darwin.macho-fold.S b/src/stub/src/arm64-darwin.macho-fold.S index 402a3f12..8af9b0fd 100644 --- a/src/stub/src/arm64-darwin.macho-fold.S +++ b/src/stub/src/arm64-darwin.macho-fold.S @@ -1,4 +1,4 @@ -// arm-darwin.macho-fold.S -- linkage to C code to process Mach-O binary +// arm64-darwin.macho-fold.S -- linkage to C code to process Mach-O binary // // This file is part of the UPX executable compressor. // @@ -38,7 +38,7 @@ #define ARMEL_DARWIN 1 #endif /*}*/ -#include "arch/arm/v8a/macros.S" +#include "arch/arm64/v8/macros.S" sz_l_info = 12 sz_p_info = 12 diff --git a/src/stub/src/arm64-darwin.macho-main.c b/src/stub/src/arm64-darwin.macho-main.c index 34273973..376b62bb 100644 --- a/src/stub/src/arm64-darwin.macho-main.c +++ b/src/stub/src/arm64-darwin.macho-main.c @@ -1,4 +1,4 @@ -/* arm-darwin.macho-main.c -- loader stub for Mach-o ARMEL +/* arm64-darwin.macho-main.c -- loader stub for Mach-o This file is part of the UPX executable compressor. diff --git a/src/stub/src/arm64-linux.elf-entry.S b/src/stub/src/arm64-linux.elf-entry.S deleted file mode 100644 index 6a4f8cdb..00000000 --- a/src/stub/src/arm64-linux.elf-entry.S +++ /dev/null @@ -1,271 +0,0 @@ -/* aarch64-linux.elf-entry.S -- Linux program entry point & decompressor (Elf binary) -* -* This file is part of the UPX executable compressor. -* -* Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer -* Copyright (C) 1996-2015 Laszlo Molnar -* Copyright (C) 2000-2015 John F. Reiser -* All Rights Reserved. -* -* UPX and the UCL library are free software; you can redistribute them -* and/or modify them under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; see the file COPYING. -* If not, write to the Free Software Foundation, Inc., -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* Markus F.X.J. Oberhumer Laszlo Molnar -* -* -* John F. Reiser -* -*/ - -#define ARM_OLDABI 1 -#include "arch/arm/v4a/macros.S" - -#define bkpt .long 0xe7f001f0 /* reserved instr; Linux GNU eabi breakpoint */ -sz_Elf64_Ehdr= 64 -sz_Elf64_Phdr= 56 - -sz_b_info= 12 - sz_unc= 0 - sz_cpr= 4 - b_method= 8 -sz_l_info= 12 -sz_p_info= 12 - -PROT_READ= 1 -PROT_WRITE= 2 -PROT_EXEC= 4 - -MAP_FIXED= 0x10 - -PAGE_SHIFT= 12 -PAGE_SIZE = -(~0<'; strb r1,[r2],#1 - - mov r5,#3 @ rows to print -L600: @ each row - sub r0,r4,#TRACE_BUFLEN - sub r0,r0,sp - mov r0,r0,lsr #2; mov r1,#'\n'; bl trace_hex @ which block of 8 - - mov r6,#8 @ words per row -L610: @ each word - ldr r0,[r4],#4; mov r1,#' '; bl trace_hex @ next word - subs r6,r6,#1; bgt L610 - - subs r5,r5,#1; bgt L600 - - mov r0,#'\n'; strb r0,[r2],#1 - sub r2,r2,sp @ count - mov r1,sp @ buf - mov r0,#2 @ FD_STDERR -#if defined(ARMEL_EABI4) /*{*/ - mov r7,#__NR_write - swi 0 -#else /*}{*/ - swi __NR_write -#endif /*}*/ - add sp,sp,#TRACE_BUFLEN - ldmia sp!,{TRACE_REGS} - -trace_hex: // In: r0=val, r1=punctuation before, r2=ptr; Uses: r3, ip - strb r1,[r2],#1 @ punctuation - mov r3,#4*(8 -1) @ shift count - adr ip,hex -L620: - mov r1,r0,lsr r3 - and r1,r1,#0xf - ldrb r1,[ip, r1] - strb r1,[r2],#1 - subs r3,r3,#4; bge L620 - ret -hex: - .ascii "0123456789abcdef" -#endif /*}*/ - -f_decompress: -#define LINUX_ARM_CACHEFLUSH 1 - - section NRV_HEAD - // empty - section NRV_TAIL - // empty - - section NRV2E -#include "arch/arm/v4a/nrv2e_d8.S" - - section NRV2D -#include "arch/arm/v4a/nrv2d_d8.S" - - section NRV2B -#include "arch/arm/v4a/nrv2b_d8.S" - -#include "arch/arm/v4a/lzma_d.S" - - section ELFMAINY -end_decompress: .globl end_decompress - -msg_SELinux: - mov r2,#L71 - L70 // length - adr r1,L70 // message text - mov r0,#2 // fd stderr -#if defined(ARMEL_EABI4) /*{*/ - mov r7,#__NR_write - swi 0 -#else /*}{*/ - swi __NR_write -#endif /*}*/ -die: - mov r0,#127 -#if defined(ARMEL_EABI4) /*{*/ - mov r7,#__NR_exit - swi 0 -#else /*}{*/ - swi __NR_exit -#endif /*}*/ -L70: - .asciz "PROT_EXEC|PROT_WRITE failed.\n" -L71: - /* IDENTSTR goes here */ - - section ELFMAINZ -cpr0: .globl cpr0 - /* { b_info={sz_unc, sz_cpr, {4 char}}, folded_loader...} */ - -/* -vi:ts=8:et:nowrap -*/ - diff --git a/src/stub/src/arm64-linux.elf-fold.S b/src/stub/src/arm64-linux.elf-fold.S deleted file mode 100644 index 06a6d7ec..00000000 --- a/src/stub/src/arm64-linux.elf-fold.S +++ /dev/null @@ -1,451 +0,0 @@ -@ aarch64-linux.elf-fold.S -- linkage to C code to process Elf binary -@ -@ This file is part of the UPX executable compressor. -@ -@ Copyright (C) 2000-2015 John F. Reiser -@ All Rights Reserved. -@ -@ UPX and the UCL library are free software; you can redistribute them -@ and/or modify them under the terms of the GNU General Public License as -@ published by the Free Software Foundation; either version 2 of -@ the License, or (at your option) any later version. -@ -@ This program is distributed in the hope that it will be useful, -@ but WITHOUT ANY WARRANTY; without even the implied warranty of -@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -@ GNU General Public License for more details. -@ -@ You should have received a copy of the GNU General Public License -@ along with this program; see the file COPYING. -@ If not, write to the Free Software Foundation, Inc., -@ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -@ -@ Markus F.X.J. Oberhumer Laszlo Molnar -@ -@ -@ John F. Reiser -@ -@ - -#define ARM_OLDABI 1 -#include "arch/arm/v4a/macros.S" -#define bkpt .long 0xe7f001f0 /* reserved instr; Linux GNU eabi breakpoint */ - -sz_Elf64_Ehdr= 64 -sz_Elf64_Phdr= 56 -sz_l_info = 12 -sz_p_info = 12 -sz_b_info = 12 - sz_unc= 0 - sz_cpr= 4 - b_method= 8 - -MAP_PRIVATE= 0x02 -MAP_FIXED= 0x10 - -PROT_READ= 0x1 - -O_RDONLY= 0 - -PAGE_SHIFT= 12 -PAGE_SIZE = -(~0<'; strb r1,[r2],#1 - - mov r5,#3 @ rows to print -L600: @ each row - sub r0,r4,#TRACE_BUFLEN - sub r0,r0,sp - mov r0,r0,lsr #2; mov r1,#'\n'; bl trace_hex @ which block of 8 - - mov r6,#8 @ words per row -L610: @ each word - ldr r0,[r4],#4; mov r1,#' '; bl trace_hex @ next word - subs r6,r6,#1; bgt L610 - - subs r5,r5,#1; bgt L600 - - mov r0,#'\n'; strb r0,[r2],#1 - sub r2,r2,sp @ count - mov r1,sp @ buf - mov r0,#2 @ FD_STDERR -#if defined(ARMEL_EABI4) /*{*/ - mov r7,#__NR_write - swi 0 -#else /*}{*/ - swi __NR_write -#endif /*}*/ - add sp,sp,#TRACE_BUFLEN - ldmia sp!,{TRACE_REGS} - -trace_hex: // In: r0=val, r1=punctuation before, r2=ptr; Uses: r3, ip - strb r1,[r2],#1 @ punctuation - mov r3,#4*(8 -1) @ shift count - adr ip,hex -L620: - mov r1,r0,lsr r3 - and r1,r1,#0xf - ldrb r1,[ip, r1] - strb r1,[r2],#1 - subs r3,r3,#4; bge L620 - ret -hex: - .ascii "0123456789abcdef" -#endif /*}*/ - .unreq ptr - .unreq len - .unreq cto - .unreq fid - -__NR_exit = 1 + __NR_SYSCALL_BASE -__NR_read = 3 + __NR_SYSCALL_BASE -__NR_write = 4 + __NR_SYSCALL_BASE -__NR_open = 5 + __NR_SYSCALL_BASE -__NR_close = 6 + __NR_SYSCALL_BASE -__NR_unlink= 10 + __NR_SYSCALL_BASE -__NR_getpid= 20 + __NR_SYSCALL_BASE -__NR_brk = 45 + __NR_SYSCALL_BASE -__NR_readlink=85+ __NR_SYSCALL_BASE - - -__NR_mmap2 = 192 + __NR_SYSCALL_BASE -__NR_mprotect = 125 + __NR_SYSCALL_BASE -__NR_munmap = 91 + __NR_SYSCALL_BASE - -__ARM_NR_BASE = 0x0f0000 + __NR_SYSCALL_BASE -__ARM_NR_cacheflush = 2 + __ARM_NR_BASE - - .globl my_bkpt -my_bkpt: - bkpt - ret - - .globl exit -exit: - do_sys __NR_exit - - .globl read -read: - do_sys __NR_read; ret - - .globl write -write: - do_sys __NR_write; ret - - .globl open -open: - do_sys __NR_open; ret - - .globl close -close: - do_sys __NR_close; ret - - .globl unlink -unlink: - do_sys __NR_unlink; ret - - .globl getpid -getpid: - do_sys __NR_getpid; ret - - .globl brk -brk: - do_sys __NR_brk; ret - - .globl readlink -readlink: - do_sys __NR_readlink; ret - - .globl munmap -munmap: - do_sys __NR_munmap; ret - - .globl mprotect -mprotect: - do_sys __NR_mprotect; ret - - .globl __clear_cache -__clear_cache: - mov r2,#0 - do_sys2 __ARM_NR_cacheflush; ret - - .globl mmap -mmap: - str r5,[sp,#-4]!; ldr r5,[sp,#4+4] - str r4,[sp,#-4]!; ldr r4,[sp,#4+4] - mov r5,r5,lsr #12 @ convert to page number -mmap_do: - do_sys __NR_mmap2 - ldr r4,[sp],#4 - ldr r5,[sp],#4 - ret - -bits_privanon= -4+ fold_begin // entry stores: MAP_{PRIVATE|ANON} QNX vs linux - -mmap_privanon: .globl mmap_privanon - ldr r12,bits_privanon @ r12 === ip - str r5,[sp,#-4]!; mov r5,#0 @ offset= 0 - str r4,[sp,#-4]!; mvn r4,#0 @ fd= -1 - orr r3,r3,r12 @ flags |= MAP_{PRIVATE|ANON} [QNX vs Linux] - b mmap_do - - -#if DEBUG /*{*/ - -div10: .globl div10 - mov ip,r0 @ extra copy used at end - sub r1,r1,r1 @ hi - - mov r2,r0 @ copy lo - adds r0,r0,r0,lsl #3 @ 9*lo - adc r1,r1,r1,lsl #3 @ 9*hi + C - add r1,r1,r2,lsr #(32 - 3) @ bits shifted from lo to hi - - mov r2,r0 @ copy lo - adds r0,r0,r0,lsl #4 - adc r1,r1,r1,lsl #4 - add r1,r1,r2,lsr #(32 - 4) @ * 0x99 - - mov r2,r0 @ copy lo - adds r0,r0,r0,lsl #8 - adc r1,r1,r1,lsl #8 - add r1,r1,r2,lsr #(32 - 8) @ * 0x9999 - - mov r2,r0 @ copy lo - adds r0,r0,r0,lsl #16 - adc r1,r1,r1,lsl #16 - add r1,r1,r2,lsr #(32 - 16) @ * 0x99999999 - - subs r0,r0,ip,lsl #(32 - 1) @ - * 0x80000000 - sbc r1,r1,ip,lsr #1 @ * 0x19999999 - - adds r0,r0,ip - adc r0,r1,#0 @ * 0x0.1999999a - ret - -#endif /*}*/ - -@ vi:ts=8:et:nowrap -