1
0
mirror of https://github.com/upx/upx synced 2025-10-05 19:20:23 +08:00
upx/src/stub/fold_exec86.asm
John Reiser 676cacff04 gcc-4.1.0 vs. mmap()
linux.hh
	fold_elf86.asm  l_lx_elf.c
	fold_exec86.asm l_lx_exec.c
	fold_pti86.asm  l_lx_pti.c
	fold_sh86.asm   l_lx_sh.c    l_lx_sh86.asm
	l_lx_sep.c

committer: jreiser <jreiser> 1142305438 +0000
2006-03-14 03:03:58 +00:00

75 lines
2.4 KiB
NASM

; fold_exec86.asm -- linkage to C code to process Elf binary
;
; This file is part of the UPX executable compressor.
;
; Copyright (C) 2000-2004 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
; <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
;
; John F. Reiser
; <jreiser@users.sourceforge.net>
;
BITS 32
SECTION .text
CPU 386
;; control just falls through, after this part and compiled C code
;; are uncompressed.
%define szElf32_Ehdr 0x34
%define szElf32_Phdr 8*4
%define e_entry (16 + 2*2 + 4)
%define p_vaddr 2*4
%define p_memsz 5*4
%define szl_info 12
%define szp_info 12
fold_begin: ; enter: %ebx= &Elf32_Ehdr of this program
pop eax ; discard &dstlen
pop eax ; discard dstlen
pop eax ; Pop the argument count
mov ecx, esp ; argv starts just at the current stack top
lea edx, [esp+eax*4+4] ; envp = &argv[argc + 1]
mov esi, [e_entry + ebx]
add ebx, szElf32_Ehdr + szElf32_Phdr + szl_info
sub esi, ebx ; length
lea edi, [2 + ebp] ; f_unfilter, maybe
pusha ; (f_unf, cprLen, f_decpr, xx, cprSrc, envp, argv, argc)
EXTERN upx_main
call upx_main ; Call the UPX main function
hlt ; Crash if somehow upx_main does return
%define __NR_mmap 90
global mmap
mmap:
push ebx
lea ebx, [2*4 + esp]
push byte __NR_mmap
pop eax
int 0x80
pop ebx
ret
; vi:ts=8:et:nowrap