get rid of PT_DYNAMIC: not worth the space; instead, use "upx -d" then ldd

p_lx_exc.h p_lx_elf.cpp p_lx_exc.cpp p_lx_sh.cpp
	stub/l_lx_elf.c stub/l_lx_elf86.lds stub/fold_elf86.asm

committer: jreiser <jreiser> 981747384 +0000
This commit is contained in:
John Reiser
2001-02-09 19:36:24 +00:00
parent e866b2231f
commit 2ff824e631
7 changed files with 31 additions and 167 deletions
+13 -11
View File
@@ -28,6 +28,7 @@
%define szElf32_Phdr 8*4
%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_val 4
@@ -57,19 +58,20 @@ fold_begin: ; enter: %ebx= &Elf32_Ehdr of this program
mov edi, esp
call do_auxv
mov eax, [p_memsz + 2*szElf32_Phdr + szElf32_Ehdr + ebx] ; size of PT_DYNAMIC
push ebx ; save &Elf32_Ehdr of this stub
sub esp, dword MAX_ELF_HDR + OVERHEAD
mov ecx, [e_entry + ebx] ; beyond compressed data
push esp ; argument: temp space
lea eax, [szElf32_Ehdr + 3*szElf32_Phdr + szl_info + szp_info + ebx + eax] ; 1st &b_info
push edi ; argument: AT_next
sub ecx, eax ; length of compressed data
push ebp ; argument: &decompress
push ecx ; argument: sz_compressed
push eax ; argument: 1st &b_info
lea eax, [szElf32_Ehdr + 2*szElf32_Phdr + szl_info + szp_info + ebx] ; 1st &b_info
mov esi, [e_entry + ebx] ; beyond compressed data
sub esi, eax ; length of compressed data
mov ebx, [ eax] ; length of uncompressed ELF headers
mov edx, esp ;
mov ecx, [4+ eax] ; length of compressed ELF headers
add ecx, byte szb_info
pusha ; (AT_next, sz_cpr, f_expand, &tmp_ehdr, {sz_unc, &tmp}, {sz_cpr, &b1st_info} )
EXTERN upx_main
call upx_main ; entry = upx_main(b1st_info, sz_cpr, &decompress, AT_next, tmp_ehdr)
add esp, dword 5*4 + MAX_ELF_HDR + OVERHEAD ; remove 5 params, temp space
call upx_main ; returns entry address
add esp, dword 8*4 + MAX_ELF_HDR + OVERHEAD ; remove 8 params, temp space
pop ebx ; &Elf32_Ehdr of this stub
push eax ; save entry address
mov edi, [a_val + edi] ; AT_PHDR
+10 -15
View File
@@ -316,35 +316,30 @@ ERR_LAB
**************************************************************************/
void *upx_main(
char /*const*/ *const b1st_info,
Elf32_auxv_t *const av,
unsigned const sz_compressed,
f_expand *const f_decompress,
Elf32_auxv_t *const av,
Elf32_Ehdr *const ehdr
Elf32_Ehdr *const ehdr,
struct Extent xo,
struct Extent xi
) __asm__("upx_main");
void *upx_main(
char /*const*/ *const b1st_info,
Elf32_auxv_t *const av,
unsigned const sz_compressed,
f_expand *const f_decompress,
Elf32_auxv_t *const av,
Elf32_Ehdr *const ehdr // temp char[MAX_ELF_HDR+OVERHEAD]
Elf32_Ehdr *const ehdr, // temp char[MAX_ELF_HDR+OVERHEAD]
struct Extent xo, // {sz_unc, ehdr} for ELF headers
struct Extent xi // {sz_cpr, &b_info} for ELF headers
)
{
Elf32_Phdr const *phdr = (Elf32_Phdr const *)(1+ehdr);
Elf32_Phdr const *phdr = (Elf32_Phdr const *)(1+ ehdr);
Elf32_Addr entry;
struct Extent xo;
struct Extent xi = { 0, b1st_info }; // location of 1st b_info
// sizeof(Ehdr+Phdrs), uncompressed
size_t const sz_elfhdrs = ((size_t *)xi.buf)[0];
// sizeof(Ehdr+Phdrs), compressed; including b_info header
size_t const sz_pckhdrs = sizeof(struct b_info) + ((size_t *)xi.buf)[1];
size_t const sz_pckhdrs = xi.size;
// Uncompress Ehdr and Phdrs.
xo.size = sz_elfhdrs; xo.buf = (char *)ehdr;
xi.size = sz_pckhdrs;
unpackExtent(&xi, &xo, f_decompress, 0);
// Prepare to decompress the Elf headers again, into the first PT_LOAD.
+2 -1
View File
@@ -32,7 +32,8 @@ PHDRS
{
text PT_LOAD FILEHDR PHDRS ;
data PT_LOAD ; /* for setting brk(0) */
null PT_NULL; /* changed to PT_DYNAMIC for ldd */
/* 3rd Phdr was not worth it; use "upx -d" first, then apply ldd */
/*null PT_NULL;*/ /* changed to PT_DYNAMIC for ldd */
}
SECTIONS
{