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

« back to all changes in this revision

Viewing changes to src/stub/l_vmlinx.asm

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2006-06-13 21:23:23 UTC
  • mfrom: (1.3.1 upstream) (3.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20060613212323-343yzs4jt6vr5483
* New upstream version.
* Standards-Version: 3.7.2 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;  l_vmlinx.asm -- loader & decompressor for the vmlinux/i386 format
 
2
;
 
3
;  This file is part of the UPX executable compressor.
 
4
;
 
5
;  Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
 
6
;  Copyright (C) 1996-2004 Laszlo Molnar
 
7
;  Copyright (C)      2004 John 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
;  <mfx@users.sourceforge.net>          <ml1050@users.sourceforge.net>
 
27
;
 
28
;  John Reiser
 
29
;  <jreiser@users.sourceforge.net>
 
30
 
 
31
 
 
32
%define         jmps    jmp short
 
33
%define         jmpn    jmp near
 
34
%include        "macros.ash"
 
35
 
 
36
                BITS    32
 
37
                SECTION .text
 
38
                ORG     0
 
39
 
 
40
; =============
 
41
; ============= ENTRY POINT
 
42
; =============
 
43
 
 
44
start:
 
45
;  In:
 
46
;       %eax= &uncompressed [and final entry]; %ds= %es= __BOOT_DS
 
47
;       %esp: &compressed; __BOOT_CS
 
48
;       __LINUX000__
 
49
                pop     edx  ; &compressed; length at -4(%edx)
 
50
 
 
51
                push    eax     ; MATCH00(1/2)  entry address; __BOOT_CS
 
52
                push    edi     ; MATCH01  save
 
53
                push    esi     ; MATCH02  save
 
54
 
 
55
%ifdef  __LXCALLT1__
 
56
                push    eax     ; MATCH03  src unfilter
 
57
%endif; __LXDUMMY0__
 
58
%ifdef  __LXCKLLT1__
 
59
                push    eax     ; MATCH03  src unfilter
 
60
                push    byte '?'  ; MATCH04  cto unfilter
 
61
%endif; __LXMOVEUP__
 
62
                push    'ULEN'  ; MATCH05  uncompressed length
 
63
                call move_up    ; MATCH06
 
64
 
 
65
; =============
 
66
; ============= DECOMPRESSION
 
67
; =============
 
68
 
 
69
%include      "n2b_d32.ash"
 
70
%include      "n2d_d32.ash"
 
71
%include      "n2e_d32.ash"
 
72
;;%include      "cl1_d32.ash"
 
73
 
 
74
; =============
 
75
; ============= UNFILTER
 
76
; =============
 
77
 
 
78
%ifdef  __LXCKLLT9__
 
79
                pop     ecx     ; MATCH05  len
 
80
                pop     edx     ; MATCH04  cto
 
81
                pop     edi     ; MATCH03  src
 
82
 
 
83
                ckt32   edi, dl ; dl has cto8
 
84
        ;edi: adjust for the difference between 0 origin of buffer at filter,
 
85
        ;and actual origin of destination at unfilter.
 
86
        ;Filter.addvalue is 0: destination origin is unknown at filter time.
 
87
        ;The input data is still relocatable, and address is assigned later
 
88
        ;[as of 2004-12-15 it is 'always' 0x100000].
 
89
 
 
90
%endif; __LXDUMMY2__
 
91
%ifdef  __LXCALLT9__
 
92
                pop     ecx     ; MATCH05  len
 
93
                pop     edi     ; MATCH03  src
 
94
                cjt32   0
 
95
%endif; __LINUX990__
 
96
                pop     esi     ; MATCH02  restore
 
97
                pop     edi     ; MATCH01  restore
 
98
                xor     ebx, ebx        ; booting the 1st cpu
 
99
                retf    ; MATCH00  set cs
 
100
 
 
101
%define UNLAP 0x10
 
102
%define ALIGN (~0<<4)
 
103
        ; must have 0==(UNLAP &~ ALIGN)
 
104
 
 
105
move_up:
 
106
                pop esi           ; MATCH06  &decompressor
 
107
                mov ecx,[-4+ esi] ; length of decompressor+unfilter
 
108
                mov ebp,eax       ; &uncompressed
 
109
                add eax,[esp]     ; MATCH05  ULEN + base; entry to decompressor
 
110
                add eax, byte ~ALIGN + UNLAP
 
111
                and eax, byte  ALIGN
 
112
 
 
113
                std
 
114
        ; copy decompressor
 
115
                lea esi,[-1+ ecx + esi]  ; unmoved top -1 of decompressor
 
116
                lea edi,[-1+ ecx + eax]  ;   moved top -1 of decompressor
 
117
                rep
 
118
                movsb
 
119
 
 
120
                mov ecx,[-4+ edx]  ; length of compressed data
 
121
                add ecx, byte  3
 
122
                shr ecx,2          ; count of .long
 
123
        ; copy compressed data
 
124
                lea esi,[-4+ 4*ecx + edx] ; unmoved top -4 of compressed data
 
125
                lea edi,[-4+         eax] ;   moved top -4 of compressed data
 
126
                rep
 
127
                movsd
 
128
 
 
129
                cld
 
130
                lea esi,[4+ edi]   ;   &compressed [after move]
 
131
                mov edi,ebp        ; &uncompressed
 
132
                or  ebp, byte -1   ; decompressor assumption
 
133
                jmp eax            ; enter moved decompressor
 
134
 
 
135
; =============
 
136
; ============= CUT HERE
 
137
; =============
 
138
 
 
139
%include        "header.ash"
 
140
 
 
141
eof:
 
142
;       __LITHEEND__
 
143
                section .data
 
144
                dd      -1
 
145
                dw      eof
 
146
 
 
147
 
 
148
; vi:ts=8:et:nowrap