~ubuntu-branches/debian/sid/upx-ucl/sid

« back to all changes in this revision

Viewing changes to src/stub/src/arm-darwin.macho-entry.S

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2009-10-16 12:56:47 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20091016125647-vity1npel2qsmr9c
Tags: 3.04-1
* New upstream release:
  + FTBFS with gcc 4.4 fixed by upstream (closes: #548566).
* p_mach.cpp: Fix from upstream vcs: mach/fat needs seek() 
  after set_extent().

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  arm-darwin.macho-entry.S -- iPhone program entry point & decompressor (Elf binary)
 
2
*
 
3
*  This file is part of the UPX executable compressor.
 
4
*
 
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
 
8
*  All Rights Reserved.
 
9
*
 
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.
 
14
*
 
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.
 
19
*
 
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.
 
24
*
 
25
*  Markus F.X.J. Oberhumer              Laszlo Molnar
 
26
*  <markus@oberhumer.com>               <ml1050@users.sourceforge.net>
 
27
*
 
28
*  John F. Reiser
 
29
*  <jreiser@users.sourceforge.net>
 
30
*/
 
31
 
 
32
//#define SIMULATE_ON_DEBIAN_EABI4 1
 
33
#undef  SIMULATE_ON_DEBIAN_EABI4
 
34
 
 
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
 
41
#endif  /*}*/
 
42
 
 
43
#include "arch/arm/v5a/macros.S"
 
44
 
 
45
#define bkpt .long 0xe1200070
 
46
 
 
47
sz_b_info= 12
 
48
  sz_unc= 0
 
49
  sz_cpr= 4
 
50
  b_method= 8
 
51
sz_l_info= 12
 
52
sz_p_info= 12
 
53
 
 
54
PROT_READ=  1
 
55
PROT_WRITE= 2
 
56
PROT_EXEC=  4
 
57
 
 
58
MAP_PRIVATE= 2
 
59
MAP_FIXED=     0x10
 
60
MAP_ANONYMOUS= 0x20
 
61
 
 
62
PAGE_SHIFT= 12
 
63
PAGE_SIZE = -(~0<<PAGE_SHIFT)
 
64
 
 
65
__NR_exit =      1 + __NR_SYSCALL_BASE
 
66
__NR_write =     4 + __NR_SYSCALL_BASE
 
67
__NR_mmap  =   197 + __NR_SYSCALL_BASE
 
68
 
 
69
// DEBUG ONLY:
 
70
__ARM_NR_BASE  = 0xf0000 + __NR_SYSCALL_BASE
 
71
__ARM_NR_cacheflush =  2 + __ARM_NR_BASE
 
72
 
 
73
        //.long sz_pack2  // placed there by ::pack3()
 
74
  section MACHMAINX
 
75
_start: .globl _start
 
76
        sub sp,sp,#4  // space for mhdrp
 
77
        stmdb sp!,{r0-r12,r14,r15}  // paranoia [omit sp===r13]
 
78
        bl main
 
79
L20:
 
80
f_decompress:
 
81
 
 
82
  section NRV_HEAD
 
83
        // empty
 
84
 
 
85
  section NRV2E
 
86
#include "arch/arm/v4a/nrv2e_d8.S"
 
87
 
 
88
  section NRV2D
 
89
#include "arch/arm/v4a/nrv2d_d8.S"
 
90
 
 
91
  section NRV2B
 
92
#include "arch/arm/v4a/nrv2b_d8.S"
 
93
 
 
94
  section NRV_TAIL
 
95
        // empty
 
96
 
 
97
#include "arch/arm/v4a/lzma_d.S"
 
98
 
 
99
  section MACHMAINY
 
100
end_decompress: .globl end_decompress
 
101
 
 
102
        /* IDENTSTR goes here */
 
103
 
 
104
  section MACHMAINZ
 
105
unfold:  // lr= &L100
 
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
 
110
 
 
111
        mov r4,lsrc  // loop count
 
112
movup:  // descending copy folded_loader to higher address
 
113
        ldrb ip,[dst,#-1]!
 
114
        subs r4,r4,#1
 
115
        strb ip,[src,#-1]!
 
116
        bne movup
 
117
 
 
118
        ldr r4,  [lr,#b_method]
 
119
        add lr,lr,#GAP
 
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
 
125
        blx r5  // bx r5
 
126
          bx r10  // DEBUG ONLY
 
127
 
 
128
main:
 
129
        mov r5,lr  // &f_decompress
 
130
        bl unfold
 
131
L100:
 
132
        /* { b_info={sz_unc, sz_cpr, {4 char}}, folded_loader...} */
 
133
 
 
134
GAP= 128  // > farthest prefetch;               must match ../../p_mach.cpp
 
135
NO_LAP= 64  // avoid overlap for folded loader; must match ../../p_mach.cpp
 
136
 
 
137
/*
 
138
vi:ts=8:et:nowrap
 
139
*/
 
140
 
 
141