1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

FreeBSD 8.x got picky about MAP_ANONYMOUS

This commit is contained in:
John Reiser 2010-07-21 10:19:11 -07:00
parent 175c0a6236
commit 3c231c3c9e
5 changed files with 2060 additions and 2059 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* i386-bsd.elf-fold.h
created from i386-bsd.elf-fold.bin, 1797 (0x705) bytes
created from i386-bsd.elf-fold.bin, 1805 (0x70d) bytes
This file is part of the UPX executable compressor.
@ -31,17 +31,17 @@
*/
#define STUB_I386_BSD_ELF_FOLD_SIZE 1797
#define STUB_I386_BSD_ELF_FOLD_ADLER32 0x39b6007d
#define STUB_I386_BSD_ELF_FOLD_CRC32 0x9c62e9a4
#define STUB_I386_BSD_ELF_FOLD_SIZE 1805
#define STUB_I386_BSD_ELF_FOLD_ADLER32 0x98f4060d
#define STUB_I386_BSD_ELF_FOLD_CRC32 0xb1990cc8
unsigned char stub_i386_bsd_elf_fold[1797] = {
unsigned char stub_i386_bsd_elf_fold[1805] = {
/* 0x0000 */ 127, 69, 76, 70, 1, 1, 1, 9, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0010 */ 2, 0, 3, 0, 1, 0, 0, 0,128, 16,192, 0, 52, 0, 0, 0,
/* 0x0020 */ 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 32, 0, 2, 0, 0, 0,
/* 0x0030 */ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 16,192, 0,
/* 0x0040 */ 0, 16,192, 0, 5, 7, 0, 0, 8, 7, 0, 0, 5, 0, 0, 0,
/* 0x0050 */ 0, 16, 0, 0, 1, 0, 0, 0, 5, 7, 0, 0, 0, 0, 0, 0,
/* 0x0040 */ 0, 16,192, 0, 13, 7, 0, 0, 16, 7, 0, 0, 5, 0, 0, 0,
/* 0x0050 */ 0, 16, 0, 0, 1, 0, 0, 0, 13, 7, 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 */ 41,201,186,248, 2, 0, 0,137,230,137,231,232,137, 0, 0, 0,
@ -50,21 +50,21 @@ unsigned char stub_i386_bsd_elf_fold[1797] = {
/* 0x00b0 */ 141,148, 26,255, 31, 0, 0,129,226, 0,240,255,255, 82, 41,192,
/* 0x00c0 */ 102,131,123, 16, 3,117, 1,146, 80,139,115, 24,141,131,140, 0,
/* 0x00d0 */ 0, 0, 41,198,139, 24,139, 72, 4,131,193, 12,141, 84, 36, 12,
/* 0x00e0 */ 96, 71,232,119, 4, 0, 0,131,196, 36, 89, 91,129,196, 0, 10,
/* 0x00e0 */ 96, 71,232,129, 4, 0, 0,131,196, 36, 89, 91,129,196, 0, 10,
/* 0x00f0 */ 0, 0, 90,193,226, 12, 1,211, 80,106, 0,137,229, 41,217, 41,
/* 0x0100 */ 192, 81, 83, 80, 79, 60,175,175,117,252,255, 55, 49,255, 49,246,
/* 0x0110 */ 49,210, 49,201, 49,219,176, 73,195,173,171,173,171,133,192,117,
/* 0x0120 */ 250,173,171,133,192,117,250, 87,173,171,131,248, 32,115, 3, 15,
/* 0x0130 */ 179,194,133,192,173,171,117,240,131,239, 8, 1,201, 64,243,171,
/* 0x0140 */ 72,171,171, 95,195, 0, 0, 0, 85,137,229, 87, 86,137,206, 83,
/* 0x0150 */ 137,195, 57, 8,139,120, 4,115, 7,106,127,232, 93, 5, 0, 0,
/* 0x0150 */ 137,195, 57, 8,139,120, 4,115, 7,106,127,232,101, 5, 0, 0,
/* 0x0160 */ 133,201,116, 8,138, 7, 71,136, 2, 66,226,248, 1,115, 4, 41,
/* 0x0170 */ 51,141,101,244, 91, 94, 95,201,195, 85,137,229, 87, 86,137,198,
/* 0x0180 */ 83,137,211,131,236, 24,139, 69, 8,139,125, 12,137, 69,220,131,
/* 0x0190 */ 58, 0, 15,132,182, 0, 0, 0,141, 85,228,185, 12, 0, 0, 0,
/* 0x01a0 */ 137,240,232,161,255,255,255,139, 69,228,139, 77,232,133,192,117,
/* 0x01b0 */ 19,129,249, 85, 80, 88, 33,117, 15,131, 62, 0, 15,132,140, 0,
/* 0x01c0 */ 0, 0,235, 4,133,201,117, 7,106,127,232,238, 4, 0, 0, 57,
/* 0x01c0 */ 0, 0,235, 4,133,201,117, 7,106,127,232,246, 4, 0, 0, 57,
/* 0x01d0 */ 193,119,245, 59, 3,119,241, 57,193,115, 86,137, 69,224,141, 69,
/* 0x01e0 */ 224,255,117,236, 80,255,115, 4, 81,255,118, 4,255, 85,220,131,
/* 0x01f0 */ 196, 20,133,192,117,210,139, 85,224, 59, 85,228,117,202,138, 69,
@ -76,77 +76,77 @@ unsigned char stub_i386_bsd_elf_fold[1797] = {
/* 0x0250 */ 244, 91, 94, 95,201,195,133,192, 83,137,211,116, 29,168, 1,117,
/* 0x0260 */ 25,139, 16, 57,218,116, 7, 74,117, 11,133,219,116, 7,137, 24,
/* 0x0270 */ 137, 72, 4,235, 5,131,192, 8,235,231, 91,195, 85,137,229, 87,
/* 0x0280 */ 86, 83,131,236, 60,137, 85,224,137, 69,228,139, 85, 12,139, 69,
/* 0x0290 */ 8,199, 69,204,255,255,255,255,137, 85,216,139,125,224,139, 85,
/* 0x02a0 */ 224,137, 69,220,139, 69, 20, 3,127, 28,137, 69,212, 49,192,102,
/* 0x02b0 */ 131,122, 16, 2, 15,183, 74, 44,137,251, 15,148,192, 49,246,193,
/* 0x02c0 */ 224, 4,137,202, 5, 2, 16, 0, 0, 74,120, 30,131, 59, 1,117,
/* 0x02d0 */ 20,139, 83, 8, 59, 85,204,115, 3,137, 85,204, 3, 83, 20, 57,
/* 0x02e0 */ 214,115, 2,137,214,131,195, 32,226,226,139, 93,204,106, 0,106,
/* 0x02f0 */ 255,129,227, 0,240,255,255, 80, 41,222,106, 0,129,198,255, 15,
/* 0x0300 */ 0, 0,129,230, 0,240,255,255, 86, 83,232,137, 3, 0, 0,131,
/* 0x0310 */ 196, 24,141, 52, 48, 41,216,137, 69,208,139, 69,224,137,117,240,
/* 0x0320 */ 102,131,120, 44, 0,199, 69,200, 0, 0, 0, 0, 15,132,226, 1,
/* 0x0330 */ 0, 0,139, 7,131,248, 6,117, 34,131,125,220, 0, 15,132,187,
/* 0x0340 */ 1, 0, 0,139, 77,208,186, 3, 0, 0, 0, 3, 79, 8,139, 69,
/* 0x0350 */ 216,232, 0,255,255,255,233,163, 1, 0, 0, 72, 15,133,156, 1,
/* 0x0360 */ 0, 0,139, 69,208,199, 69,196, 64, 98, 81,115, 3, 71, 8,139,
/* 0x0370 */ 87, 20,139, 79, 24, 1,194,137, 69,236,137, 85,188,137,194,129,
/* 0x0380 */ 226,255, 15, 0, 0,131,225, 7, 41,208,193,225, 2,137, 69,192,
/* 0x0390 */ 139, 71, 4,211,109,196, 41,208,131,101,196, 7,131,125,220, 0,
/* 0x03a0 */ 139, 79, 16, 80,139, 69,228,137, 77,232,141, 52, 17,116, 3,131,
/* 0x03b0 */ 200,255,131,125,220, 1, 80, 25,192, 37, 0,240,255,255, 5, 18,
/* 0x03c0 */ 16, 0, 0,131,125,220, 0, 80,139, 69,196,116, 3,131,200, 2,
/* 0x03d0 */ 131,125,220, 0, 80,137,240,116, 3,141, 70, 3, 80,255,117,192,
/* 0x03e0 */ 232,179, 2, 0, 0,131,196, 24, 57, 69,192, 15,133,185, 0, 0,
/* 0x03f0 */ 0,131,125,220, 0,116, 28,246, 69,196, 4,139, 69,212,117, 2,
/* 0x0400 */ 49,192, 80,139, 69,220,255,117,228,141, 85,232,232,104,253,255,
/* 0x0410 */ 255, 88, 90,137,240,247,216, 37,255, 15, 0, 0,246, 69,196, 2,
/* 0x0420 */ 137, 69,184,116, 20,139, 69,192, 1,240,131,125,184, 0,116, 9,
/* 0x0430 */ 139, 77,184,198, 0, 0, 64,226,250,131,125,220, 0,116,114,131,
/* 0x0440 */ 63, 1,117, 83,246, 71, 24, 1,116, 77,139, 87, 20,139, 95, 8,
/* 0x0450 */ 141, 12, 26, 3, 77,208, 59, 87, 16,117, 14,137,200,247,216, 37,
/* 0x0460 */ 255, 15, 0, 0,131,248, 3,119, 14,107, 69,208, 52,131,127, 4,
/* 0x0470 */ 0,141, 76, 3, 12,117, 15,139, 1, 61,205,128,201,195,116, 6,
/* 0x0480 */ 199, 1,205,128,201,195,133,201,116, 13,139, 69,216, 49,210,131,
/* 0x0490 */ 224,254,232,191,253,255,255,255,117,196, 86,255,117,192,232, 54,
/* 0x04a0 */ 2, 0, 0,131,196, 12,133,192,116, 7,106,127,232, 12, 2, 0,
/* 0x04b0 */ 0,139, 85,184,139, 93,192,141, 4, 22, 1,195, 59, 93,188,115,
/* 0x04c0 */ 33,106, 0,106,255,104, 18, 16, 0, 0,255,117,196, 41, 93,188,
/* 0x04d0 */ 255,117,188, 83,232,191, 1, 0, 0,131,196, 24, 57,195,116, 30,
/* 0x04e0 */ 235,200,131,125,220, 0,116, 22,141, 70, 3, 37,255, 15, 0, 0,
/* 0x04f0 */ 131,248, 3,119, 9, 80, 83,232,217, 1, 0, 0, 89, 91,139, 85,
/* 0x0500 */ 224,131,199, 32,255, 69,200, 15,183, 66, 44, 57, 69,200, 15,140,
/* 0x0510 */ 30,254,255,255,131,125,220, 0,117, 15,255,117,228,232,175, 1,
/* 0x0520 */ 0, 0, 90,133,192,116, 21,235,129,139, 69,224,102,131,120, 16,
/* 0x0530 */ 3,116, 9,255,117,240,232,129, 1, 0, 0, 88,131,125, 16, 0,
/* 0x0540 */ 116, 8,139, 69,208,139, 85, 16,137, 2,139, 85,224,139, 82, 24,
/* 0x0550 */ 1, 85,208,139, 69,208,141,101,244, 91, 94, 95,201,195, 85,137,
/* 0x0560 */ 229, 87, 86, 83,131,236, 16,141, 85, 24,139, 69, 8,106, 0,139,
/* 0x0570 */ 125, 28,137, 69,236,139, 69, 16,139, 93, 32,141,119, 52,137, 69,
/* 0x0580 */ 232,131,192, 2,255,117,232,137, 69,228,141, 69, 32,232,231,251,
/* 0x0590 */ 255,255,139, 69, 12,185, 0, 16, 0, 0,186, 6, 0, 0, 0,137,
/* 0x05a0 */ 69, 32,139, 69,236, 41, 93, 36,232,169,252,255,255, 15,183, 79,
/* 0x05b0 */ 44,139, 69,236,186, 5, 0, 0, 0,232,152,252,255,255, 15,183,
/* 0x05c0 */ 79, 42,139, 69,236,186, 4, 0, 0, 0,232,135,252,255,255,139,
/* 0x05d0 */ 77, 40, 3, 78, 8,186, 3, 0, 0, 0,139, 69,236,131,193, 52,
/* 0x05e0 */ 232,113,252,255,255,141, 69,240,255,117,228,137,250, 80,141, 69,
/* 0x05f0 */ 32,255,117,236, 80,139, 69,232,232,127,252,255,255,186, 9, 0,
/* 0x0600 */ 0, 0,137,193,137,195,139, 69,236,232, 72,252,255,255,102,139,
/* 0x0610 */ 79, 44,131,196, 24, 49,210,102,133,201,116,112,131, 62, 3,117,
/* 0x0620 */ 96,106, 0,139, 69,240,106, 0, 3, 70, 8, 80,232,156, 0, 0,
/* 0x0630 */ 0,131,196, 12,133,192,137,195,120, 22,104, 0, 2, 0, 0, 87,
/* 0x0640 */ 80,232,127, 0, 0, 0,131,196, 12, 61, 0, 2, 0, 0,116, 7,
/* 0x0650 */ 106,127,232,102, 0, 0, 0,141, 69,240,137,250,106, 0, 80,137,
/* 0x0660 */ 216,106, 0,106, 0,232, 18,252,255,255,139, 77,240,137,195,139,
/* 0x0670 */ 69,236,186, 7, 0, 0, 0,232,218,251,255,255,131,196, 16,235,
/* 0x0680 */ 11, 66, 15,183,193,131,198, 32, 57,194,124,144,141,101,244,137,
/* 0x0690 */ 216, 91, 94, 95,201,195, 0, 0, 85,137,229, 49,192, 80,255,117,
/* 0x06a0 */ 28, 80,255,117, 24,255,117, 20,255,117, 16,255,117, 12,255,117,
/* 0x06b0 */ 8, 80,176,197, 80, 80,176,198,205,128,201,195,195,176, 1, 15,
/* 0x06c0 */ 182,192,205,128,195,176, 3,235,246,176, 4,235,242,176, 5,235,
/* 0x06d0 */ 238,176, 6,235,234,176, 73,235,230,176, 74,235,226,176, 33,235,
/* 0x06e0 */ 222,176, 20,235,218,176, 92,235,214,176, 59,235,210,176, 2,235,
/* 0x06f0 */ 206,176,130,235,202,176,116,235,198,176,240,235,194,176, 10,235,
/* 0x0700 */ 190,176, 7,235,186
/* 0x0280 */ 86, 83,131,236, 60,137, 69,228,139, 69, 8,137, 85,224,139,125,
/* 0x0290 */ 224,199, 69,204,255,255,255,255,139, 85, 12,137, 69,220,139, 69,
/* 0x02a0 */ 224,139, 77, 20,137, 85,216, 3,127, 28,139, 85,224,137, 77,212,
/* 0x02b0 */ 102,131,120, 16, 2, 15,183, 74, 44,137,251, 15,148,192, 49,246,
/* 0x02c0 */ 15,182,192,137,202,193,224, 4, 5, 2, 16, 0, 0, 74,120, 30,
/* 0x02d0 */ 131, 59, 1,117, 20,139, 83, 8, 59, 85,204,115, 3,137, 85,204,
/* 0x02e0 */ 3, 83, 20, 57,214,115, 2,137,214,131,195, 32,226,226,139, 93,
/* 0x02f0 */ 204,106, 0,106,255,129,227, 0,240,255,255, 80, 41,222,106, 0,
/* 0x0300 */ 129,198,255, 15, 0, 0,129,230, 0,240,255,255, 86, 83,232,141,
/* 0x0310 */ 3, 0, 0,139, 77,224,141, 52, 48,131,196, 24, 41,216,102,131,
/* 0x0320 */ 121, 44, 0,137,117,240,137, 69,208,199, 69,200, 0, 0, 0, 0,
/* 0x0330 */ 15,132,232, 1, 0, 0,139, 7,131,248, 6,117, 34,131,125,220,
/* 0x0340 */ 0, 15,132,193, 1, 0, 0,139, 77,208,186, 3, 0, 0, 0, 3,
/* 0x0350 */ 79, 8,139, 69,216,232,252,254,255,255,233,169, 1, 0, 0, 72,
/* 0x0360 */ 15,133,162, 1, 0, 0,139, 79, 24,199, 69,196, 64, 98, 81,115,
/* 0x0370 */ 139, 69,208,131,225, 7, 3, 71, 8,193,225, 2,139, 87, 16,211,
/* 0x0380 */ 109,196,139, 79, 20,137,198,131,101,196, 7, 1,193,137, 85,232,
/* 0x0390 */ 137, 77,188,137,193,129,225,255, 15, 0, 0,137, 69,236, 1,202,
/* 0x03a0 */ 41,206,131,125,220, 0,137, 85,192,116, 41,106, 0,139, 69,196,
/* 0x03b0 */ 106,255,104, 18, 16, 0, 0,131,200, 2, 80,137,208,131,192, 3,
/* 0x03c0 */ 80, 86,232,217, 2, 0, 0,131,196, 24, 57,198, 15,133,225, 0,
/* 0x03d0 */ 0, 0,235, 36,139, 71, 4, 41,200, 80,255,117,228,106, 18,255,
/* 0x03e0 */ 117,196,255,117,192, 86,232,181, 2, 0, 0,131,196, 24, 57,198,
/* 0x03f0 */ 15,133,189, 0, 0, 0,235, 34,131,125,220, 0,116, 28,246, 69,
/* 0x0400 */ 196, 4,139, 69,212,117, 2, 49,192, 80,139, 69,220,255,117,228,
/* 0x0410 */ 141, 85,232,232, 97,253,255,255, 88, 90,139, 69,192,247,216, 37,
/* 0x0420 */ 255, 15, 0, 0,246, 69,196, 2,137, 69,184,116, 21,131,125,184,
/* 0x0430 */ 0,139, 85,192,141, 4, 22,116, 9,139, 77,184,198, 0, 0, 64,
/* 0x0440 */ 226,250,131,125,220, 0,116,114,131, 63, 1,117, 83,246, 71, 24,
/* 0x0450 */ 1,116, 77,139, 87, 20,139, 95, 8,141, 12, 26, 3, 77,208, 59,
/* 0x0460 */ 87, 16,117, 14,137,200,247,216, 37,255, 15, 0, 0,131,248, 3,
/* 0x0470 */ 119, 14,107, 69,208, 52,131,127, 4, 0,141, 76, 3, 12,117, 15,
/* 0x0480 */ 139, 1, 61,205,128,201,195,116, 6,199, 1,205,128,201,195,133,
/* 0x0490 */ 201,116, 13,139, 69,216, 49,210,131,224,254,232,182,253,255,255,
/* 0x04a0 */ 255,117,196,255,117,192, 86,232, 53, 2, 0, 0,131,196, 12,133,
/* 0x04b0 */ 192,116, 7,106,127,232, 11, 2, 0, 0,139, 69,192, 3, 69,184,
/* 0x04c0 */ 141, 28, 6, 59, 93,188,115, 33,106, 0,106,255,104, 18, 16, 0,
/* 0x04d0 */ 0,255,117,196, 41, 93,188,255,117,188, 83,232,192, 1, 0, 0,
/* 0x04e0 */ 131,196, 24, 57,195,116, 33,235,202,131,125,220, 0,116, 25,139,
/* 0x04f0 */ 69,192,131,192, 3, 37,255, 15, 0, 0,131,248, 3,119, 9, 80,
/* 0x0500 */ 83,232,215, 1, 0, 0, 89, 91,139, 77,224,131,199, 32,255, 69,
/* 0x0510 */ 200, 15,183, 65, 44, 57, 69,200, 15,140, 24,254,255,255,131,125,
/* 0x0520 */ 220, 0,117, 15,255,117,228,232,173, 1, 0, 0, 90,133,192,116,
/* 0x0530 */ 21,235,128,139, 69,224,102,131,120, 16, 3,116, 9,255,117,240,
/* 0x0540 */ 232,127, 1, 0, 0, 88,131,125, 16, 0,116, 8,139, 77,208,139,
/* 0x0550 */ 85, 16,137, 10,139, 69,224,139, 64, 24, 1, 69,208,139, 69,208,
/* 0x0560 */ 141,101,244, 91, 94, 95,201,195, 85,137,229, 87, 86, 83,131,236,
/* 0x0570 */ 16,141, 85, 24,139, 69, 8,106, 0,139,125, 28,137, 69,236,139,
/* 0x0580 */ 69, 16,139, 93, 32,141,119, 52,137, 69,232,131,192, 2,255,117,
/* 0x0590 */ 232,137, 69,228,141, 69, 32,232,221,251,255,255,139, 69, 12,185,
/* 0x05a0 */ 0, 16, 0, 0,186, 6, 0, 0, 0,137, 69, 32,139, 69,236, 41,
/* 0x05b0 */ 93, 36,232,159,252,255,255, 15,183, 79, 44,139, 69,236,186, 5,
/* 0x05c0 */ 0, 0, 0,232,142,252,255,255, 15,183, 79, 42,139, 69,236,186,
/* 0x05d0 */ 4, 0, 0, 0,232,125,252,255,255,139, 77, 40, 3, 78, 8,186,
/* 0x05e0 */ 3, 0, 0, 0,139, 69,236,131,193, 52,232,103,252,255,255,141,
/* 0x05f0 */ 69,240,255,117,228,137,250, 80,141, 69, 32,255,117,236, 80,139,
/* 0x0600 */ 69,232,232,117,252,255,255,186, 9, 0, 0, 0,137,193,137,195,
/* 0x0610 */ 139, 69,236,232, 62,252,255,255,102,139, 79, 44,131,196, 24, 49,
/* 0x0620 */ 210,102,133,201,116,112,131, 62, 3,117, 96,106, 0,139, 69,240,
/* 0x0630 */ 106, 0, 3, 70, 8, 80,232,154, 0, 0, 0,131,196, 12,133,192,
/* 0x0640 */ 137,195,120, 22,104, 0, 2, 0, 0, 87, 80,232,125, 0, 0, 0,
/* 0x0650 */ 131,196, 12, 61, 0, 2, 0, 0,116, 7,106,127,232,100, 0, 0,
/* 0x0660 */ 0,141, 69,240,137,250,106, 0, 80,137,216,106, 0,106, 0,232,
/* 0x0670 */ 8,252,255,255,139, 77,240,137,195,139, 69,236,186, 7, 0, 0,
/* 0x0680 */ 0,232,208,251,255,255,131,196, 16,235, 11, 66, 15,183,193,131,
/* 0x0690 */ 198, 32, 57,194,124,144,141,101,244,137,216, 91, 94, 95,201,195,
/* 0x06a0 */ 85,137,229, 49,192, 80,255,117, 28, 80,255,117, 24,255,117, 20,
/* 0x06b0 */ 255,117, 16,255,117, 12,255,117, 8, 80,176,197, 80, 80,176,198,
/* 0x06c0 */ 205,128,201,195,195,176, 1, 15,182,192,205,128,195,176, 3,235,
/* 0x06d0 */ 246,176, 4,235,242,176, 5,235,238,176, 6,235,234,176, 73,235,
/* 0x06e0 */ 230,176, 74,235,226,176, 33,235,222,176, 20,235,218,176, 92,235,
/* 0x06f0 */ 214,176, 59,235,210,176, 2,235,206,176,130,235,202,176,116,235,
/* 0x0700 */ 198,176,240,235,194,176, 10,235,190,176, 7,235,186
};

View File

@ -41,7 +41,7 @@
section LEXEC000
_start: .globl _start
//// int3
//// nop; int3
/*
;; How to debug this code: Uncomment the 'int3' breakpoint instruction above.
;; Build the stubs and upx. Compress a testcase, such as a copy of /bin/date.
@ -135,8 +135,7 @@ section LEXEC020
#define PROT_READ 1
#define PROT_WRITE 2
#define PROT_EXEC 4
#define __NR_mmap 197
#define __NR_syscall 198
#define SYS_mmap 477
#define szElf32_Ehdr 0x34
#define p_memsz 5*4
@ -188,20 +187,15 @@ section LEXEC025
// mmap a page to hold the decompressed fold_elf86
xor ecx, ecx // %ecx= 0
// MAP_ANONYMOUS ==>offset is ignored, so do not push!
push ecx // pad (must be zero?)
push ecx; push ecx // 64-bit offset
push -1 // *BSD demands -1==fd for mmap(,,,MAP_ANON,,)
push MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS
mov ch, PAGE_SIZE >> 8 // %ecx= PAGE_SIZE
push PROT_READ | PROT_WRITE | PROT_EXEC
push ecx // length
push eax // destination
xor eax,eax // 0
push eax // current thread
mov al, __NR_mmap
push eax // __NR_mmap
push eax // fake return address
mov al, __NR_syscall
mov eax, SYS_mmap
int 0x80 // changes only %eax; %edx is live
jb fail_mmap
xchg eax, edx // %edx= page after .text; %eax= &Elf32_Ehdr of this program
@ -220,7 +214,8 @@ section LEXEC025
mov [4*3 + esp],eax
push esi // &compressed_data
call ebp // decompress(&src, srclen, &dst, &dstlen, b_info.misc)
add esp, (5+1 + 9)*4 // (5+1) args to decompress, 9 "args" to mmap
add esp, (5+1 + 8)*4 // (5+1) args to decompress, 8 "args" to mmap
ret // &destination
main:
pop ebp // &decompress

View File

@ -368,6 +368,8 @@ auxv_up(Elf32_auxv_t *av, unsigned const type, unsigned const value)
) >> ((pf & (PF_R|PF_W|PF_X))<<2) ))
#define MAP_ANON_FD -1
// Find convex hull of PT_LOAD (the minimal interval which covers all PT_LOAD),
// and mmap that much, to be sure that a kernel using exec-shield-randomize
// won't place the first piece in a way that leaves no room for the rest.
@ -396,7 +398,7 @@ xfind_pages(unsigned mflags, Elf32_Phdr const *phdr, int phnum,
lo -= ~PAGE_MASK & lo; // round down to page boundary
hi = PAGE_MASK & (hi - lo - PAGE_MASK -1); // page length
szlo = PAGE_MASK & (szlo - PAGE_MASK -1); // page length
addr = mmap((void *)lo, hi, PROT_NONE, mflags, -1, 0);
addr = mmap((void *)lo, hi, PROT_NONE, mflags, MAP_ANON_FD, 0);
*p_brk = hi + addr; // the logical value of brk(0)
//mprotect(szlo + addr, hi - szlo, PROT_NONE); // no access, but keep the frames!
return (unsigned long)addr - lo;
@ -430,14 +432,18 @@ do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, struct Extent *const xi,
mlen += frag;
addr -= frag;
if (addr != mmap(addr, mlen
if (addr != (xi
? mmap(addr, mlen
#if defined(__i386__) /*{*/
// Decompressor can overrun the destination by 3 bytes.
+ (xi ? 3 : 0)
// Decompressor can overrun the destination by 3 bytes.
+ 3
#endif /*}*/
, prot | (xi ? PROT_WRITE : 0),
MAP_FIXED | MAP_PRIVATE | (xi ? MAP_ANONYMOUS : 0),
(xi ? -1 : fdi), phdr->p_offset - frag) ) {
, prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS,
MAP_ANON_FD , 0 )
: mmap(addr, mlen
, prot, MAP_FIXED | MAP_PRIVATE,
fdi, phdr->p_offset - frag) ))
{
err_exit(8);
}
if (xi) {
@ -473,7 +479,7 @@ ERR_LAB
addr += mlen + frag; /* page boundary on hi end */
if (addr < haddr) { // need pages for .bss
if (addr != mmap(addr, haddr - addr, prot,
MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0 ) ) {
MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, MAP_ANON_FD, 0 ) ) {
err_exit(9);
}
}

View File

@ -172,7 +172,7 @@ Idx Name Size VMA LMA File off Algn Flags
167 LEXEC020 00000049 00000000 00000000 00001abe 2**0 CONTENTS, READONLY
168 LUNMP000 00000002 00000000 00000000 00001b07 2**0 CONTENTS, READONLY
169 LUNMP001 00000002 00000000 00000000 00001b09 2**0 CONTENTS, READONLY
170 LEXEC025 00000040 00000000 00000000 00001b0b 2**0 CONTENTS, RELOC, READONLY
170 LEXEC025 0000003e 00000000 00000000 00001b0b 2**0 CONTENTS, RELOC, READONLY
SYMBOL TABLE:
00000000 l d N2BSMA10 00000000 N2BSMA10
00000000 l d N2BFAS11 00000000 N2BFAS11
@ -660,5 +660,5 @@ OFFSET TYPE VALUE
RELOCATION RECORDS FOR [LEXEC025]:
OFFSET TYPE VALUE
0000003c R_386_PC32 LEXEC020
0000001e R_386_PC32 LEXEC020
0000003a R_386_PC32 LEXEC020
0000001c R_386_PC32 LEXEC020