i386-linux.elf-fold fix compressed size for ET_DYN

This commit is contained in:
John Reiser 2009-02-12 12:41:10 -08:00
parent d117e442a4
commit 3664d86430
5 changed files with 1950 additions and 1946 deletions

File diff suppressed because it is too large Load Diff

View File

@ -32,8 +32,8 @@
#define STUB_I386_LINUX_ELF_FOLD_SIZE 1734
#define STUB_I386_LINUX_ELF_FOLD_ADLER32 0xf81ee9e6
#define STUB_I386_LINUX_ELF_FOLD_CRC32 0x50231c49
#define STUB_I386_LINUX_ELF_FOLD_ADLER32 0x0e93e9e6
#define STUB_I386_LINUX_ELF_FOLD_CRC32 0x8600ddca
unsigned char stub_i386_linux_elf_fold[1734] = {
/* 0x0000 */ 127, 69, 76, 70, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -44,23 +44,23 @@ unsigned char stub_i386_linux_elf_fold[1734] = {
/* 0x0050 */ 0, 16, 0, 0, 1, 0, 0, 0,198, 6, 0, 0, 0, 0, 0, 0,
/* 0x0060 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0070 */ 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0080 */ 83, 41,201,186,120, 2, 0, 0,137,230,137,231, 41,219,232,181,
/* 0x0090 */ 0, 0, 0,141, 89, 4,137,230,209,234, 25,192, 41,193,141, 36,
/* 0x00a0 */ 196,133,210,117,243,129,236, 8, 16, 0, 0,137,231,232,150, 0,
/* 0x00b0 */ 0, 0,199, 6, 32, 32, 32, 61,137, 51,186, 0, 16, 0, 0,141,
/* 0x00c0 */ 78, 4,232, 15, 0, 0, 0, 47,112,114,111, 99, 47,115,101,108,
/* 0x00d0 */ 102, 47,101,120,101, 0, 91,106, 85, 88,205,128,133,192,120, 4,
/* 0x00e0 */ 198, 4, 1, 0, 91,129,236, 0, 10, 0, 0, 83,139, 83, 72,141,
/* 0x00f0 */ 148, 26,255, 31, 0, 0,129,226, 0,240,255,255, 82, 41,192,102,
/* 0x0100 */ 131,123, 16, 3,117, 1,146, 80,139,115, 24,141,131,140, 0, 0,
/* 0x0110 */ 0, 41,198,139, 24,139, 72, 4,131,193, 12,141, 84, 36, 12, 96,
/* 0x0120 */ 71,232,106, 4, 0, 0,131,196, 36, 89, 91,129,196, 0, 10, 0,
/* 0x0130 */ 0, 80, 79, 41,192, 60,175,175,117,252, 80, 80, 80, 80, 80, 80,
/* 0x0140 */ 80, 80, 41,217,176, 91,255, 39,173,171,173,171,173,171,133,192,
/* 0x0150 */ 117,250,135,223, 1,223,173,171,133,192,117,250, 87,173,171,131,
/* 0x0160 */ 248, 32,115, 3, 15,179,194,133,192,173,171,117,240,131,239, 8,
/* 0x0170 */ 1,201, 64,243,171, 72,171,171,137,254, 95,195, 83,141, 92, 36,
/* 0x0180 */ 8,106, 90, 88,205,128, 91,195, 87, 86,137,206, 83,137,195, 57,
/* 0x0080 */ 87, 83, 41,201,186,120, 2, 0, 0,137,230,137,231, 41,219,232,
/* 0x0090 */ 177, 0, 0, 0,141, 89, 4,137,230,209,234, 25,192, 41,193,141,
/* 0x00a0 */ 36,196,133,210,117,243,129,236, 8, 16, 0, 0,137,231,232,146,
/* 0x00b0 */ 0, 0, 0,199, 6, 32, 32, 32, 61,137, 51,186, 0, 16, 0, 0,
/* 0x00c0 */ 141, 78, 4,232, 15, 0, 0, 0, 47,112,114,111, 99, 47,115,101,
/* 0x00d0 */ 108,102, 47,101,120,101, 0, 91,106, 85, 88,205,128,133,192,120,
/* 0x00e0 */ 4,198, 4, 1, 0, 91, 94,129,236, 0, 10, 0, 0, 83,139, 83,
/* 0x00f0 */ 72,141,148, 26,255, 31, 0, 0,129,226, 0,240,255,255, 82, 41,
/* 0x0100 */ 192,102,131,123, 16, 3,117, 1,146, 80,141,131,140, 0, 0, 0,
/* 0x0110 */ 139, 24,139, 72, 4,131,193, 12,141, 84, 36, 12, 96, 71,232,109,
/* 0x0120 */ 4, 0, 0,131,196, 36, 89, 91,129,196, 0, 10, 0, 0, 80, 79,
/* 0x0130 */ 41,192, 60,175,175,117,252, 80, 80, 80, 80, 80, 80, 80, 80, 41,
/* 0x0140 */ 217,176, 91,255, 39,173,171,173,171,173,171,173,171,133,192,117,
/* 0x0150 */ 250,135,223, 1,223,173,171,133,192,117,250, 87,173,171,131,248,
/* 0x0160 */ 32,115, 3, 15,179,194,133,192,173,171,117,240,131,239, 8, 1,
/* 0x0170 */ 201, 64,243,171, 72,171,171,137,254, 95,195, 83,141, 92, 36, 8,
/* 0x0180 */ 106, 90, 88,205,128, 91,195, 0, 87, 86,137,206, 83,137,195, 57,
/* 0x0190 */ 8,139,120, 4,115, 10,106,127, 91,106, 1, 88,205,128,235,254,
/* 0x01a0 */ 133,201,116, 8,138, 7, 71,136, 2, 66,226,248, 1,115, 4, 41,
/* 0x01b0 */ 51, 91, 94, 95,195, 85,137,229, 87, 86,137,198, 83,137,211,131,
@ -89,7 +89,7 @@ unsigned char stub_i386_linux_elf_fold[1734] = {
/* 0x0320 */ 20, 57,215,115, 2,137,215,131,195, 32,226,228,129,230, 0,240,
/* 0x0330 */ 255,255, 41,247,137,242,141,159,255, 15, 0, 0,129,227, 0,240,
/* 0x0340 */ 255,255,168, 16,117, 19,106, 0,106,255, 80,106, 0, 83, 86,232,
/* 0x0350 */ 40,254,255,255,131,196, 24,137,194,139, 77,224,141, 4, 26, 41,
/* 0x0350 */ 39,254,255,255,131,196, 24,137,194,139, 77,224,141, 4, 26, 41,
/* 0x0360 */ 242,199, 69,200, 0, 0, 0, 0,102,131,121, 44, 0,137, 69,240,
/* 0x0370 */ 137, 85,204, 15,132,221, 1, 0, 0,131,125,220, 0,116, 32,139,
/* 0x0380 */ 93,208,131, 59, 6,117, 24,139, 77,204,186, 3, 0, 0, 0, 3,
@ -102,7 +102,7 @@ unsigned char stub_i386_linux_elf_fold[1734] = {
/* 0x03f0 */ 192, 41,208,131,125,220, 0, 80,139, 69,228,116, 3,131,200,255,
/* 0x0400 */ 131,125,220, 1, 80, 25,192,131,224,224,131,192, 50,131,125,220,
/* 0x0410 */ 0, 80,139, 69,196,116, 3,131,200, 2,131,125,220, 0, 80,137,
/* 0x0420 */ 240,116, 3,141, 70, 3, 80, 87,232, 79,253,255,255,131,196, 24,
/* 0x0420 */ 240,116, 3,141, 70, 3, 80, 87,232, 78,253,255,255,131,196, 24,
/* 0x0430 */ 57,199, 15,133,184, 0, 0, 0,131,125,220, 0,116, 28,246, 69,
/* 0x0440 */ 196, 4,139, 69,212,117, 2, 49,192, 80,139, 69,220,255,117,228,
/* 0x0450 */ 141, 85,232,232, 93,253,255,255, 88, 90,137,243,247,219,129,227,
@ -117,7 +117,7 @@ unsigned char stub_i386_linux_elf_fold[1734] = {
/* 0x04e0 */ 137,251,137,241,139, 85,196,106,125, 88,205,128,133,192,116, 10,
/* 0x04f0 */ 106,127, 91,106, 1, 88,205,128,235,254,139, 85,188,141, 4, 22,
/* 0x0500 */ 141, 28, 7, 59, 93,192,115, 30,106, 0,106,255,106, 50,255,117,
/* 0x0510 */ 196, 41, 93,192,255,117,192, 83,232, 95,252,255,255,131,196, 24,
/* 0x0510 */ 196, 41, 93,192,255,117,192, 83,232, 94,252,255,255,131,196, 24,
/* 0x0520 */ 57,195,116, 27,235,202,131,125,220, 0,116, 19,141, 78, 3,129,
/* 0x0530 */ 225,255, 15, 0, 0,131,249, 3,119, 5,106, 91, 88,205,128,139,
/* 0x0540 */ 77,224,255, 69,200, 15,183, 65, 44,131, 69,208, 32, 57, 69,200,

View File

@ -168,7 +168,8 @@ unfold:
pop esi // &{ b_info:{sz_unc, sz_cpr, 4{byte}}, compressed_data...}
lea eax, [ebp - (4+ decompress - _start)] // 4: sizeof(int)
sub eax, [eax] // %eax= &Elf32_Ehdr of this program
mov edi, [eax] // total length of compressed data
sub eax, edi // %eax= &Elf32_Ehdr of this program
mov edx, eax // %edx= &Elf32_Ehdr of this program
// Linux requires PF_W in order to create .bss (implied by .p_filesz!=.p_memsz),

View File

@ -52,6 +52,7 @@
// are uncompressed.
fold_begin: // enter: %ebx= &Elf32_Ehdr of this program; %ebp= f_expand
// %edi=total length of compressed data
// patchLoader will modify to be
// dword sz_uncompressed, sz_compressed
// byte compressed_data...
@ -76,6 +77,7 @@ fold_begin: // enter: %ebx= &Elf32_Ehdr of this program; %ebp= f_expand
#define ET_DYN 3
push edi // save total length of compressed data
push ebx // save &Elf32_Ehdr
sub ecx, ecx
mov edx, (1<<AT_PHDR) | (1<<AT_PHENT) | (1<<AT_PHNUM) | (1<<AT_PAGESZ) | (1<<AT_ENTRY)
@ -114,6 +116,7 @@ L52:
mov byte ptr [ecx + eax], 0 // NUL terminate the link text
L55:
pop ebx // recover &Elf32_Ehdr
pop esi // recover total length of compressed data
#define OVERHEAD 2048
#define MAX_ELF_HDR 512
@ -135,9 +138,7 @@ L55:
L53:
push eax // dynbase
mov esi, [e_entry + ebx] // end of compressed data
lea eax, [szElf32_Ehdr + 2*szElf32_Phdr + szl_info + szp_info + ebx] // 1st &b_info
sub esi, eax // length of compressed data
mov ebx, [ eax] // length of uncompressed ELF headers
mov ecx, [4+ eax] // length of compressed ELF headers
add ecx, szb_info
@ -182,6 +183,7 @@ L60:
do_auxv:
// cld
lodsd; stosd // saved &Elf32_Ehdr
lodsd; stosd // saved total length of compressed data
lodsd; stosd // argc can be 0
L10: // move argv

View File

@ -169,7 +169,7 @@ Idx Name Size VMA LMA File off Algn Flags
164 ctok32.30 00000007 00000000 00000000 00001aaa 2**0 CONTENTS, RELOC, READONLY
165 ctok32.40 00000005 00000000 00000000 00001ab1 2**0 CONTENTS, RELOC, READONLY
166 LEXEC017 00000002 00000000 00000000 00001ab6 2**0 CONTENTS, READONLY
167 LEXEC020 00000080 00000000 00000000 00001ab8 2**0 CONTENTS, READONLY
167 LEXEC020 00000082 00000000 00000000 00001ab8 2**0 CONTENTS, READONLY
SYMBOL TABLE:
00000000 l d N2BSMA10 00000000 N2BSMA10
00000000 l d N2BFAS11 00000000 N2BFAS11