i386-darwin kernel expects 64-bit off_t; we always use 0 for top 32 bits.
This commit is contained in:
parent
d0cf104e43
commit
98dc886841
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/* i386-darwin.macho-fold.h
|
||||
created from i386-darwin.macho-fold.bin, 1096 (0x448) bytes
|
||||
created from i386-darwin.macho-fold.bin, 1102 (0x44e) bytes
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
*/
|
||||
|
||||
|
||||
#define STUB_I386_DARWIN_MACHO_FOLD_SIZE 1096
|
||||
#define STUB_I386_DARWIN_MACHO_FOLD_ADLER32 0xee0f0416
|
||||
#define STUB_I386_DARWIN_MACHO_FOLD_CRC32 0xa5096bf9
|
||||
#define STUB_I386_DARWIN_MACHO_FOLD_SIZE 1102
|
||||
#define STUB_I386_DARWIN_MACHO_FOLD_ADLER32 0x86e50532
|
||||
#define STUB_I386_DARWIN_MACHO_FOLD_CRC32 0x703625c8
|
||||
|
||||
unsigned char stub_i386_darwin_macho_fold[1096] = {
|
||||
unsigned char stub_i386_darwin_macho_fold[1102] = {
|
||||
/* 0x0000 */ 106, 0,137,231,141,117, 2,139, 19,137,217, 41,209,139, 89, 24,
|
||||
/* 0x0010 */ 184, 0, 8, 0, 0, 57,216,118, 2,137,195, 41,220, 96,232, 1,
|
||||
/* 0x0010 */ 184, 0, 8, 0, 0, 57,216,118, 2,137,195, 41,220, 96,232, 5,
|
||||
/* 0x0020 */ 3, 0, 0,139, 76, 36, 16,141,100, 12, 32,255, 96, 40,139, 68,
|
||||
/* 0x0030 */ 36, 4,139, 76, 36, 8,139, 16, 15,202,137, 16,131,233, 4,141,
|
||||
/* 0x0040 */ 64, 4,115,242,195, 90, 15, 52,176, 1,235, 2,176, 74,235, 2,
|
||||
@ -64,45 +64,45 @@ unsigned char stub_i386_darwin_macho_fold[1096] = {
|
||||
/* 0x0190 */ 228,139, 85, 12,199, 69,208, 0, 0, 0, 0,137, 69,224,139, 69,
|
||||
/* 0x01a0 */ 20,137, 85,220,139, 85, 24,137, 69,216,139, 93,232,139, 69,232,
|
||||
/* 0x01b0 */ 137, 85,212, 49,210,131,195, 28,199, 69,204, 0, 0, 0, 0, 59,
|
||||
/* 0x01c0 */ 80, 16, 15,131, 81, 1, 0, 0,139, 3,131,248, 1, 15,133, 24,
|
||||
/* 0x01c0 */ 80, 16, 15,131, 85, 1, 0, 0,139, 3,131,248, 1, 15,133, 28,
|
||||
/* 0x01d0 */ 1, 0, 0,139, 83, 24,139, 67, 28,139, 75, 36,137,214, 1,208,
|
||||
/* 0x01e0 */ 137, 85,240,137, 69,200,137,208, 37,255, 15, 0, 0,137,207, 41,
|
||||
/* 0x01f0 */ 198, 1,199,137, 77,236,116, 66,139, 69,228, 3, 67, 32,133,201,
|
||||
/* 0x0200 */ 80,139, 69,220,117, 3,131,200,255,131,125,224, 0, 80,117, 9,
|
||||
/* 0x0210 */ 133,201,184, 18, 0, 0, 0,117, 5,184, 18, 16, 0, 0,131,125,
|
||||
/* 0x0220 */ 224, 0, 80,106, 3,137,248,116, 3,141, 71, 3, 80, 86,232, 45,
|
||||
/* 0x0230 */ 254,255,255,131,196, 24, 57,198,117, 94,131,125,224, 0,116, 42,
|
||||
/* 0x0240 */ 131,123, 36, 0,116, 36,131,123, 32, 0,117, 11,131,125, 16, 0,
|
||||
/* 0x0250 */ 116, 5,139, 85, 16,137, 50,255,117,212,255,117,216,141, 85,236,
|
||||
/* 0x0260 */ 139, 69,224,232, 68,254,255,255, 88, 90,137,248,141, 20, 62,247,
|
||||
/* 0x0270 */ 216, 37,255, 15, 0, 0,137, 69,196,116, 8,137,193,198, 2, 0,
|
||||
/* 0x0280 */ 66,226,250,133,255,116, 24,255,115, 44, 87, 86,232,187,253,255,
|
||||
/* 0x0290 */ 255,131,196, 12,133,192,116, 7,106,127,232,169,253,255,255,139,
|
||||
/* 0x02a0 */ 85,196,141, 4, 23, 1,198, 59,117,200,115, 33,106, 0,106,255,
|
||||
/* 0x02b0 */ 104, 18, 16, 0, 0,255,115, 44, 41,117,200,255,117,200, 86,232,
|
||||
/* 0x02c0 */ 156,253,255,255,131,196, 24, 57,198,116, 58,235,203,131,125,224,
|
||||
/* 0x02d0 */ 0,116, 50,141, 71, 3, 37,255, 15, 0, 0,131,248, 3,119, 37,
|
||||
/* 0x02e0 */ 80, 86,232,105,253,255,255, 89, 94,235, 26,131,232, 4,131,248,
|
||||
/* 0x02f0 */ 1,119, 18,131,123, 8, 1,117, 12,131,123, 12, 16,117, 6,141,
|
||||
/* 0x0300 */ 67, 16,137, 69,208,255, 69,204,139, 85,232,139, 69,204, 3, 91,
|
||||
/* 0x0310 */ 4, 59, 66, 16,233,169,254,255,255,139, 69,208,141,101,244, 91,
|
||||
/* 0x0320 */ 94, 95,201,195, 85,137,229, 87, 86, 83,131,236, 32,199, 69,212,
|
||||
/* 0x0330 */ 0, 0, 0, 0,139, 85, 32,139, 69, 24,139, 93, 16,137, 69,216,
|
||||
/* 0x0340 */ 139,117, 20,141, 66, 24,137,117,232,137, 69,240,139, 69, 28,131,
|
||||
/* 0x0350 */ 232, 24,137, 69,236,139, 66, 24,139, 85,240,106, 0,137, 69,228,
|
||||
/* 0x0360 */ 139, 69,236,137, 85,224,137, 69,220,141, 85,228,141, 69,236, 83,
|
||||
/* 0x0370 */ 232, 55,253,255,255,255,117, 12, 83, 49,210,255,117, 8,141, 69,
|
||||
/* 0x0380 */ 220,106,255, 80,137,240,232,244,253,255,255, 49,210,137,195,141,
|
||||
/* 0x0390 */ 70, 28,131,196, 28,139, 78, 16, 57,202, 15,131,158, 0, 0, 0,
|
||||
/* 0x03a0 */ 131, 56, 14, 15,133,140, 0, 0, 0, 3, 64, 8,106, 0,106, 0,
|
||||
/* 0x03b0 */ 80,232,166,252,255,255,131,196, 12,133,192,137,199,120, 21,255,
|
||||
/* 0x03c0 */ 117,212,255,117,216, 86, 87,232,136,252,255,255,131,196, 16, 57,
|
||||
/* 0x03d0 */ 69,216,116, 15,106,127,232,109,252,255,255,139, 91, 8,137, 93,
|
||||
/* 0x03e0 */ 212,235,220,129, 62,202,254,186,190,117, 42, 15,182, 70, 7,141,
|
||||
/* 0x03f0 */ 94, 8,107,192, 20,131,192, 8, 80, 86,232, 47,252,255,255, 89,
|
||||
/* 0x0400 */ 90, 49,192,139, 86, 4, 57,208,115, 11,131, 59, 7,116,204, 64,
|
||||
/* 0x0410 */ 131,195, 20,235,241,106, 0,139, 85,212,106, 0,137,240,106, 0,
|
||||
/* 0x0420 */ 87,106, 0,232, 87,253,255,255, 87,137,195,232, 40,252,255,255,
|
||||
/* 0x0430 */ 131,196, 24,235, 9, 3, 64, 4, 66,233, 90,255,255,255,141,101,
|
||||
/* 0x0440 */ 244,137,216, 91, 94, 95,201,195
|
||||
/* 0x01f0 */ 198, 1,199,137, 77,236,116, 68,106, 0,139, 69,228, 3, 67, 32,
|
||||
/* 0x0200 */ 133,201, 80,139, 69,220,117, 3,131,200,255,131,125,224, 0, 80,
|
||||
/* 0x0210 */ 117, 9,133,201,184, 18, 0, 0, 0,117, 5,184, 18, 16, 0, 0,
|
||||
/* 0x0220 */ 131,125,224, 0, 80,106, 3,137,248,116, 3,141, 71, 3, 80, 86,
|
||||
/* 0x0230 */ 232, 43,254,255,255,131,196, 28, 57,198,117, 94,131,125,224, 0,
|
||||
/* 0x0240 */ 116, 42,131,123, 36, 0,116, 36,131,123, 32, 0,117, 11,131,125,
|
||||
/* 0x0250 */ 16, 0,116, 5,139, 85, 16,137, 50,255,117,212,255,117,216,141,
|
||||
/* 0x0260 */ 85,236,139, 69,224,232, 66,254,255,255, 88, 90,137,248,141, 20,
|
||||
/* 0x0270 */ 62,247,216, 37,255, 15, 0, 0,137, 69,196,116, 8,137,193,198,
|
||||
/* 0x0280 */ 2, 0, 66,226,250,133,255,116, 24,255,115, 44, 87, 86,232,185,
|
||||
/* 0x0290 */ 253,255,255,131,196, 12,133,192,116, 7,106,127,232,167,253,255,
|
||||
/* 0x02a0 */ 255,139, 85,196,141, 4, 23, 1,198, 59,117,200,115, 35,106, 0,
|
||||
/* 0x02b0 */ 106, 0,106,255,104, 18, 16, 0, 0,255,115, 44, 41,117,200,255,
|
||||
/* 0x02c0 */ 117,200, 86,232,152,253,255,255,131,196, 28, 57,198,116, 58,235,
|
||||
/* 0x02d0 */ 201,131,125,224, 0,116, 50,141, 71, 3, 37,255, 15, 0, 0,131,
|
||||
/* 0x02e0 */ 248, 3,119, 37, 80, 86,232,101,253,255,255, 89, 94,235, 26,131,
|
||||
/* 0x02f0 */ 232, 4,131,248, 1,119, 18,131,123, 8, 1,117, 12,131,123, 12,
|
||||
/* 0x0300 */ 16,117, 6,141, 67, 16,137, 69,208,255, 69,204,139, 85,232,139,
|
||||
/* 0x0310 */ 69,204, 3, 91, 4, 59, 66, 16,233,165,254,255,255,139, 69,208,
|
||||
/* 0x0320 */ 141,101,244, 91, 94, 95,201,195, 85,137,229, 87, 86, 83,131,236,
|
||||
/* 0x0330 */ 32,199, 69,212, 0, 0, 0, 0,139, 85, 32,139, 69, 24,139, 93,
|
||||
/* 0x0340 */ 16,137, 69,216,139,117, 20,141, 66, 24,137,117,232,137, 69,240,
|
||||
/* 0x0350 */ 139, 69, 28,131,232, 24,137, 69,236,139, 66, 24,139, 85,240,106,
|
||||
/* 0x0360 */ 0,137, 69,228,139, 69,236,137, 85,224,137, 69,220,141, 85,228,
|
||||
/* 0x0370 */ 141, 69,236, 83,232, 51,253,255,255,255,117, 12, 83, 49,210,255,
|
||||
/* 0x0380 */ 117, 8,141, 69,220,106,255, 80,137,240,232,240,253,255,255, 49,
|
||||
/* 0x0390 */ 210,137,195,141, 70, 28,131,196, 28,139, 78, 16, 57,202, 15,131,
|
||||
/* 0x03a0 */ 160, 0, 0, 0,131, 56, 14, 15,133,142, 0, 0, 0, 3, 64, 8,
|
||||
/* 0x03b0 */ 106, 0,106, 0, 80,232,162,252,255,255,131,196, 12,133,192,137,
|
||||
/* 0x03c0 */ 199,120, 23,106, 0,255,117,212,255,117,216, 86, 87,232,130,252,
|
||||
/* 0x03d0 */ 255,255,131,196, 20, 57, 69,216,116, 15,106,127,232,103,252,255,
|
||||
/* 0x03e0 */ 255,139, 91, 8,137, 93,212,235,218,129, 62,202,254,186,190,117,
|
||||
/* 0x03f0 */ 42, 15,182, 70, 7,141, 94, 8,107,192, 20,131,192, 8, 80, 86,
|
||||
/* 0x0400 */ 232, 41,252,255,255, 89, 90, 49,192,139, 86, 4, 57,208,115, 11,
|
||||
/* 0x0410 */ 131, 59, 7,116,204, 64,131,195, 20,235,241,106, 0,139, 85,212,
|
||||
/* 0x0420 */ 106, 0,137,240,106, 0, 87,106, 0,232, 81,253,255,255, 87,137,
|
||||
/* 0x0430 */ 195,232, 34,252,255,255,131,196, 24,235, 9, 3, 64, 4, 66,233,
|
||||
/* 0x0440 */ 88,255,255,255,141,101,244,137,216, 91, 94, 95,201,195
|
||||
};
|
||||
|
||||
@ -147,14 +147,15 @@ main:
|
||||
|
||||
push eax # length for eventual munmap
|
||||
|
||||
push 0 # offset
|
||||
push 0 # hi32(offset)
|
||||
push 0 # lo32(offset)
|
||||
push -1 # fd
|
||||
push MAP_ANON|MAP_PRIVATE
|
||||
push PROT_READ|PROT_WRITE
|
||||
push eax # length
|
||||
push 0 # addr
|
||||
call mmap
|
||||
add esp,6*4
|
||||
add esp,7*4
|
||||
|
||||
push eax # addr for eventual munmap
|
||||
|
||||
|
||||
@ -303,9 +303,12 @@ typedef union {
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define PROT_EXEC 4
|
||||
#define MAP_ANON_FD -1
|
||||
|
||||
extern char *mmap(char *, size_t, unsigned, unsigned, int, off_t);
|
||||
extern ssize_t pread(int, void *, size_t, off_t);
|
||||
// We have off_t as 32 bits, but syscalls consider off_t as 64 bits.
|
||||
// Make the top 32 bits explicit, and pass a 0.
|
||||
extern char *mmap(char *, size_t, unsigned, unsigned, int, off_t, unsigned);
|
||||
extern ssize_t pread(int, void *, size_t, off_t, unsigned);
|
||||
extern void bswap(void *, unsigned);
|
||||
|
||||
static Mach_i386_thread_state const *
|
||||
@ -339,7 +342,7 @@ do_xmap(
|
||||
VM_PROT_READ | VM_PROT_WRITE,
|
||||
MAP_FIXED | MAP_PRIVATE |
|
||||
((xi || 0==sc->filesize) ? MAP_ANON : 0),
|
||||
((0==sc->filesize) ? -1 : fdi), sc->fileoff + fat_offset) ) {
|
||||
((0==sc->filesize) ? -1 : fdi), sc->fileoff + fat_offset, 0) ) {
|
||||
err_exit(8);
|
||||
}
|
||||
if (xi && 0!=sc->filesize) {
|
||||
@ -358,7 +361,7 @@ ERR_LAB
|
||||
addr += mlen + frag; /* page boundary on hi end */
|
||||
if (addr < haddr) { // need pages for .bss
|
||||
if (addr != mmap(addr, haddr - addr, sc->initprot,
|
||||
MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0 ) ) {
|
||||
MAP_FIXED | MAP_PRIVATE | MAP_ANON, MAP_ANON_FD, 0, 0 ) ) {
|
||||
err_exit(9);
|
||||
}
|
||||
}
|
||||
@ -424,7 +427,7 @@ upx_main(
|
||||
err_exit(18);
|
||||
}
|
||||
fat:
|
||||
if ((ssize_t)sz_mhdr!=pread(fdi, (void *)mhdr, sz_mhdr, fat_offset)) {
|
||||
if ((ssize_t)sz_mhdr!=pread(fdi, (void *)mhdr, sz_mhdr, fat_offset, 0)) {
|
||||
ERR_LAB
|
||||
err_exit(19);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user