; fold_elf86.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 ; ; ; John F. Reiser ; ; BITS 32 SECTION .text CPU 386 %define PAGE_SIZE ( 1<<12) %define szElf32_Ehdr 0x34 %define szElf32_Phdr 8*4 %define e_type 16 %define e_entry (16 + 2*2 + 4) %define p_memsz 5*4 %define szb_info 12 %define szl_info 12 %define szp_info 12 %define a_type 0 %define a_val 4 %define sz_auxv 8 %define __NR_munmap 91 ;; control just falls through, after this part and compiled C code ;; are uncompressed. fold_begin: ; enter: %ebx= &Elf32_Ehdr of this program ; patchLoader will modify to be ; dword sz_uncompressed, sz_compressed ; byte compressed_data... ; ld-linux.so.2 depends on AT_PHDR and AT_ENTRY, for instance. ; Move argc,argv,envp down to make room for Elf_auxv table. ; Linux kernel 2.4.2 and earlier give only AT_HWCAP and AT_PLATFORM ; because we have no PT_INTERP. Linux kernel 2.4.5 (and later?) ; give not quite everything. It is simpler and smaller code for us ; to generate a "complete" table where Elf_auxv[k -1].a_type = k. ; On second thought, that wastes a lot of stack space (the entire kernel ; auxv, plus those slots that remain empty anyway). So try for minimal ; space on stack, without too much code, by doing it serially. %define AT_NULL 0 %define AT_IGNORE 1 %define AT_PHDR 3 %define AT_PHENT 4 %define AT_PHNUM 5 %define AT_PAGESZ 6 %define AT_ENTRY 9 %define ET_DYN 3 sub ecx, ecx mov edx, (1<