1
/* arm-darwin.macho-entry.S -- iPhone program entry point & decompressor (Elf binary)
3
* This file is part of the UPX executable compressor.
5
* Copyright (C) 1996-2009 Markus Franz Xaver Johannes Oberhumer
6
* Copyright (C) 1996-2009 Laszlo Molnar
7
* Copyright (C) 2000-2009 John F. Reiser
10
* UPX and the UCL library are free software; you can redistribute them
11
* and/or modify them under the terms of the GNU General Public License as
12
* published by the Free Software Foundation; either version 2 of
13
* the License, or (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; see the file COPYING.
22
* If not, write to the Free Software Foundation, Inc.,
23
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
* Markus F.X.J. Oberhumer Laszlo Molnar
26
* <markus@oberhumer.com> <ml1050@users.sourceforge.net>
29
* <jreiser@users.sourceforge.net>
32
//#define SIMULATE_ON_DEBIAN_EABI4 1
33
#undef SIMULATE_ON_DEBIAN_EABI4
35
#ifdef SIMULATE_ON_DEBIAN_EABI4 /*{*/
36
#define LINUX_ARM_CACHEFLUSH 1 /* SIMULATE_ON_DEBIAN_EABI4 */
37
#define ARMEL_EABI4 1 /* SIMULATE_ON_DEBIAN_EABI4 */
38
#else /*}{ usual case */
39
#define DARWIN_ARM_CACHEFLUSH 1
40
#define ARMEL_DARWIN 1
43
#include "arch/arm/v5a/macros.S"
45
#define bkpt .long 0xe1200070
63
PAGE_SIZE = -(~0<<PAGE_SHIFT)
65
__NR_exit = 1 + __NR_SYSCALL_BASE
66
__NR_write = 4 + __NR_SYSCALL_BASE
67
__NR_mmap = 197 + __NR_SYSCALL_BASE
70
__ARM_NR_BASE = 0xf0000 + __NR_SYSCALL_BASE
71
__ARM_NR_cacheflush = 2 + __ARM_NR_BASE
73
//.long sz_pack2 // placed there by ::pack3()
76
sub sp,sp,#4 // space for mhdrp
77
stmdb sp!,{r0-r12,r14,r15} // paranoia [omit sp===r13]
86
#include "arch/arm/v4a/nrv2e_d8.S"
89
#include "arch/arm/v4a/nrv2d_d8.S"
92
#include "arch/arm/v4a/nrv2b_d8.S"
97
#include "arch/arm/v4a/lzma_d.S"
100
end_decompress: .globl end_decompress
102
/* IDENTSTR goes here */
106
ldr ldst,[lr,#sz_unc]
107
ldr lsrc,[lr,#sz_cpr]
108
add dst,lsrc,lr; add dst,dst,#sz_b_info
109
add src,ldst,lr; add src,src,#GAP+NO_LAP // defend against prefetch and overlap
111
mov r4,lsrc // loop count
112
movup: // descending copy folded_loader to higher address
118
ldr r4, [lr,#b_method]
120
PUSH {ldst}; mov ldst,sp // LZMA needs for EOF
121
mov dst,lr // unfolded result
122
sub r11,r5,#4+ L20 - _start // &sz_pack2 param to unfolded loader
123
PUSH {r4} // 5th param to decompressor
124
mov r10,lr // DEBUG ONLY
129
mov r5,lr // &f_decompress
132
/* { b_info={sz_unc, sz_cpr, {4 char}}, folded_loader...} */
134
GAP= 128 // > farthest prefetch; must match ../../p_mach.cpp
135
NO_LAP= 64 // avoid overlap for folded loader; must match ../../p_mach.cpp