mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
refine pseudo-sections
committer: jreiser <jreiser> 978901287 +0000
This commit is contained in:
parent
7bffc86777
commit
c9a36d51c4
|
@ -54,6 +54,14 @@
|
||||||
|
|
||||||
%include "ident.ash"
|
%include "ident.ash"
|
||||||
|
|
||||||
|
;;;; names of pseudo-sections for addLoader:
|
||||||
|
;; LXUNFnnn Linux unfilter
|
||||||
|
;; LXNJMPnn omit filtering of 6-byte Jxx (0x0f 0x80..0x8f)
|
||||||
|
;; LXMRUnnn MostRecentlyUsed recoding of destinations
|
||||||
|
;; MRUARBnn arbitrary number of entries in wheel
|
||||||
|
;; MRUBITSn power of 2 entries in wheel (smaller code)
|
||||||
|
;; MRUBYTEn 256 entries in wheel (smallest code)
|
||||||
|
|
||||||
; /*************************************************************************
|
; /*************************************************************************
|
||||||
; // program entry point
|
; // program entry point
|
||||||
; // see glibc/sysdeps/i386/elf/start.S
|
; // see glibc/sysdeps/i386/elf/start.S
|
||||||
|
@ -81,7 +89,7 @@ _start:
|
||||||
;;
|
;;
|
||||||
call main ; push address of decompress subroutine
|
call main ; push address of decompress subroutine
|
||||||
decompress:
|
decompress:
|
||||||
;__LXMRU000__
|
;__LXUNF000__
|
||||||
jmps decompr0
|
jmps decompr0
|
||||||
;; 2+ address of decompress subroutine
|
;; 2+ address of decompress subroutine
|
||||||
;; unfilter(upx_byte *, length)
|
;; unfilter(upx_byte *, length)
|
||||||
|
@ -99,7 +107,8 @@ decompress:
|
||||||
%endif ;__LXMRU010__
|
%endif ;__LXMRU010__
|
||||||
|
|
||||||
xor edx, edx ; zero
|
xor edx, edx ; zero
|
||||||
jmp unf0
|
;__LXUNF010__
|
||||||
|
jmpn unf0
|
||||||
;__LXELF010__
|
;__LXELF010__
|
||||||
|
|
||||||
; /*************************************************************************
|
; /*************************************************************************
|
||||||
|
@ -149,11 +158,13 @@ decompr0:
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;__LXMRU020__
|
;__LXUNF020__
|
||||||
;; continuation of entry prolog for unfilter
|
;; continuation of entry prolog for unfilter
|
||||||
unf0:
|
unf0:
|
||||||
|
;__LXMRU020__
|
||||||
push edx ; tail
|
push edx ; tail
|
||||||
push ebx ; n_mru or n_mru1
|
push ebx ; n_mru or n_mru1
|
||||||
|
;__LXUNF025__
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
%define n_mru [esi]
|
%define n_mru [esi]
|
||||||
|
@ -183,6 +194,7 @@ unf1: ; allocate and clear mru[]
|
||||||
%define kh edx
|
%define kh edx
|
||||||
%define kh_l dl
|
%define kh_l dl
|
||||||
|
|
||||||
|
;__LXUNF030__
|
||||||
calltrickloop:
|
calltrickloop:
|
||||||
mov al, [edi]
|
mov al, [edi]
|
||||||
inc edi
|
inc edi
|
||||||
|
@ -198,7 +210,7 @@ calltrickloop:
|
||||||
dec ecx
|
dec ecx
|
||||||
mov byte [edi], al ; Jcc opcode
|
mov byte [edi], al ; Jcc opcode
|
||||||
inc edi
|
inc edi
|
||||||
jmps mru2
|
jmps lxunf
|
||||||
ct2:
|
ct2:
|
||||||
sub al, 0xE8 - 0x80 ; base of JMP/CALL <d32>
|
sub al, 0xE8 - 0x80 ; base of JMP/CALL <d32>
|
||||||
cmp al, 0xE9 - 0xE8 ; span of JMP/CALL <d32>
|
cmp al, 0xE9 - 0xE8 ; span of JMP/CALL <d32>
|
||||||
|
@ -209,7 +221,7 @@ ct2:
|
||||||
ja unfcount
|
ja unfcount
|
||||||
mov al, [edi]
|
mov al, [edi]
|
||||||
cmp al, cto8
|
cmp al, cto8
|
||||||
je mru2
|
je lxunf
|
||||||
unfcount:
|
unfcount:
|
||||||
dec ecx
|
dec ecx
|
||||||
jg calltrickloop
|
jg calltrickloop
|
||||||
|
@ -234,12 +246,12 @@ unfcount:
|
||||||
push edx
|
push edx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
mru2:
|
lxunf:
|
||||||
mov eax, [edi]
|
mov eax, [edi]
|
||||||
shr ax, 8
|
shr ax, 8
|
||||||
rol eax, 16
|
rol eax, 16
|
||||||
xchg al, ah
|
xchg al, ah
|
||||||
|
;__LXMRU065__
|
||||||
shr jc, 1 ; eax= jc, or mru index
|
shr jc, 1 ; eax= jc, or mru index
|
||||||
jnc mru4 ; not 1st time for this jc
|
jnc mru4 ; not 1st time for this jc
|
||||||
%ifdef __MRUBYTE3__
|
%ifdef __MRUBYTE3__
|
||||||
|
@ -256,7 +268,7 @@ mru3:
|
||||||
%endif ;__LXMRU070__
|
%endif ;__LXMRU070__
|
||||||
|
|
||||||
mov [esp + 4*hand], jc ; 1st time: mru[hand] = jc
|
mov [esp + 4*hand], jc ; 1st time: mru[hand] = jc
|
||||||
jmps mru_store
|
jmps unf_store
|
||||||
|
|
||||||
mru4: ; not 1st time for this jc
|
mru4: ; not 1st time for this jc
|
||||||
lea kh, [jc + hand] ; kh = jc + hand
|
lea kh, [jc + hand] ; kh = jc + hand
|
||||||
|
@ -311,8 +323,8 @@ mru7:
|
||||||
mru8:
|
mru8:
|
||||||
mov [esp + 4*kh ], tmp ; mru[kh] = tmp
|
mov [esp + 4*kh ], tmp ; mru[kh] = tmp
|
||||||
mov [esp + 4*hand], jc ; mru[hand] = jc
|
mov [esp + 4*hand], jc ; mru[hand] = jc
|
||||||
|
;__LXUNF040__
|
||||||
mru_store:
|
unf_store:
|
||||||
sub eax, edi
|
sub eax, edi
|
||||||
sub ecx, byte 4
|
sub ecx, byte 4
|
||||||
add eax, addvalue
|
add eax, addvalue
|
||||||
|
|
Loading…
Reference in New Issue
Block a user