diff --git a/src/p_mach.cpp b/src/p_mach.cpp index 7aa17f6c..aa9dc411 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -53,6 +53,8 @@ static const #include "stub/arm-darwin.macho-entry.h" static const #include "stub/arm-darwin.macho-fold.h" +static const +#include "stub/amd64-darwin.macho-upxmain.h" static const #include "stub/arm64-darwin.macho-entry.h" @@ -455,9 +457,17 @@ PackMachI386::buildLoader(const Filter *ft) void PackMachAMD64::buildLoader(const Filter *ft) { - buildMachLoader( - stub_amd64_darwin_macho_entry, sizeof(stub_amd64_darwin_macho_entry), - stub_amd64_darwin_macho_fold, sizeof(stub_amd64_darwin_macho_fold), ft ); + if (my_filetype==Mach_header::MH_EXECUTE) { + initLoader(NULL, 0); + linker->addSection("UPXMAIN", stub_amd64_darwin_macho_upxmain_exe, + sizeof(stub_amd64_darwin_macho_upxmain_exe), 0); + addLoader("UPXMAIN", NULL); + } + else { + buildMachLoader( + stub_amd64_darwin_macho_entry, sizeof(stub_amd64_darwin_macho_entry), + stub_amd64_darwin_macho_fold, sizeof(stub_amd64_darwin_macho_fold), ft ); + } } void @@ -1689,7 +1699,12 @@ bool PackMachBase::canPack() msegcmd = new Mach_segment_command[ncmds]; unsigned char const *ptr = (unsigned char const *)rawmseg; for (unsigned j= 0; j < ncmds; ++j) { - msegcmd[j] = *(Mach_segment_command const *)ptr; + if (lc_seg == *(unsigned const *)ptr) { + msegcmd[j] = *(Mach_segment_command const *)ptr; + } + else { + memcpy(&msegcmd[j], ptr, 2*sizeof(unsigned)); // cmd and size + } switch (((Mach_uuid_command const *)ptr)->cmd) { default: break; case Mach_segment_command::LC_UUID: { diff --git a/src/p_mach_enum.h b/src/p_mach_enum.h index 4c3577f8..5107a9c2 100644 --- a/src/p_mach_enum.h +++ b/src/p_mach_enum.h @@ -59,8 +59,9 @@ enum { // flags MH_NOUNDEFS = 1, MH_DYLDLINK = 4, /* code signing demands this */ + MH_BINDATLOAD = 0x8, // DT_BIND_NOW MH_TWOLEVEL = 0x80, - MH_PIE = 0x200000 + MH_PIE = 0x200000 // ASLR }; #endif /*}*/ diff --git a/src/stub/Makefile b/src/stub/Makefile index dc5a528c..ed202544 100644 --- a/src/stub/Makefile +++ b/src/stub/Makefile @@ -51,6 +51,7 @@ ifndef STUBS STUBS += amd64-darwin.dylib-entry.h STUBS += amd64-darwin.macho-entry.h STUBS += amd64-darwin.macho-fold.h +STUBS += amd64-darwin.macho-upxmain.h STUBS += amd64-linux.elf-entry.h STUBS += amd64-linux.elf-fold.h STUBS += amd64-linux.kernel.vmlinux-head.h @@ -313,6 +314,9 @@ amd64-darwin.macho-fold.h : tmp/$$T.o tmp/amd64-darwin.macho-main.o chmod a-x tmp/$T.bin $(call tc,bin2h) tmp/$T.bin $@ +amd64-darwin.macho-upxmain.h: amd64-darwin.macho-upxmain.exe + $(call tc,bin2h) $< $@ + tmp/amd64-darwin.macho-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c $< -o $@ $(call tc,f-objstrip,$@) diff --git a/src/stub/amd64-darwin.macho-upxmain.h b/src/stub/amd64-darwin.macho-upxmain.h new file mode 100644 index 00000000..b84577cd --- /dev/null +++ b/src/stub/amd64-darwin.macho-upxmain.h @@ -0,0 +1,608 @@ +/* amd64-darwin.macho-upxmain.h + created from amd64-darwin.macho-upxmain.exe, 9092 (0x2384) bytes + + This file is part of the UPX executable compressor. + + Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2015 Laszlo Molnar + Copyright (C) 2000-2015 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 + + */ + + +#define STUB_AMD64_DARWIN_MACHO_UPXMAIN_EXE_SIZE 9092 +#define STUB_AMD64_DARWIN_MACHO_UPXMAIN_EXE_ADLER32 0x9ab36775 +#define STUB_AMD64_DARWIN_MACHO_UPXMAIN_EXE_CRC32 0xbd632719 + +unsigned char stub_amd64_darwin_macho_upxmain_exe[9092] = { +/* 0x0000 */ 207,250,237,254, 7, 0, 0, 1, 3, 0, 0,128, 2, 0, 0, 0, +/* 0x0010 */ 15, 0, 0, 0, 0, 5, 0, 0,133, 0, 32, 0, 0, 0, 0, 0, +/* 0x0020 */ 25, 0, 0, 0, 72, 0, 0, 0, 95, 95, 80, 65, 71, 69, 90, 69, +/* 0x0030 */ 82, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0040 */ 0, 0,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0050 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0060 */ 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0,136, 1, 0, 0, +/* 0x0070 */ 95, 95, 84, 69, 88, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0080 */ 0, 0,255,255, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, +/* 0x0090 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, +/* 0x00a0 */ 7, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, +/* 0x00b0 */ 95, 95,116,101,120,116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x00c0 */ 95, 95, 84, 69, 88, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x00d0 */ 240, 7,255,255, 0, 0, 0, 0, 19, 7, 0, 0, 0, 0, 0, 0, +/* 0x00e0 */ 240, 7, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x00f0 */ 0, 4, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0100 */ 95, 95,115,116,117, 98,115, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0110 */ 95, 95, 84, 69, 88, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0120 */ 4, 15,255,255, 0, 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, +/* 0x0130 */ 4, 15, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0140 */ 8, 4, 0,128, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, +/* 0x0150 */ 95, 95,115,116,117, 98, 95,104,101,108,112,101,114, 0, 0, 0, +/* 0x0160 */ 95, 95, 84, 69, 88, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0170 */ 60, 15,255,255, 0, 0, 0, 0,106, 0, 0, 0, 0, 0, 0, 0, +/* 0x0180 */ 60, 15, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0190 */ 0, 4, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x01a0 */ 95, 95,117,110,119,105,110,100, 95,105,110,102,111, 0, 0, 0, +/* 0x01b0 */ 95, 95, 84, 69, 88, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x01c0 */ 168, 15,255,255, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, +/* 0x01d0 */ 168, 15, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x01e0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x01f0 */ 25, 0, 0, 0,136, 1, 0, 0, 95, 95, 68, 65, 84, 65, 0, 0, +/* 0x0200 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,255,255, 0, 0, 0, 0, +/* 0x0210 */ 0, 16, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, +/* 0x0220 */ 0, 16, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 3, 0, 0, 0, +/* 0x0230 */ 4, 0, 0, 0, 0, 0, 0, 0, 95, 95,110,108, 95,115,121,109, +/* 0x0240 */ 98,111,108, 95,112,116,114, 0, 95, 95, 68, 65, 84, 65, 0, 0, +/* 0x0250 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,255,255, 0, 0, 0, 0, +/* 0x0260 */ 16, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 3, 0, 0, 0, +/* 0x0270 */ 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 9, 0, 0, 0, +/* 0x0280 */ 0, 0, 0, 0, 0, 0, 0, 0, 95, 95,103,111,116, 0, 0, 0, +/* 0x0290 */ 0, 0, 0, 0, 0, 0, 0, 0, 95, 95, 68, 65, 84, 65, 0, 0, +/* 0x02a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 16, 16,255,255, 0, 0, 0, 0, +/* 0x02b0 */ 8, 0, 0, 0, 0, 0, 0, 0, 16, 16, 0, 0, 3, 0, 0, 0, +/* 0x02c0 */ 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 11, 0, 0, 0, +/* 0x02d0 */ 0, 0, 0, 0, 0, 0, 0, 0, 95, 95,108, 97, 95,115,121,109, +/* 0x02e0 */ 98,111,108, 95,112,116,114, 0, 95, 95, 68, 65, 84, 65, 0, 0, +/* 0x02f0 */ 0, 0, 0, 0, 0, 0, 0, 0, 24, 16,255,255, 0, 0, 0, 0, +/* 0x0300 */ 72, 0, 0, 0, 0, 0, 0, 0, 24, 16, 0, 0, 3, 0, 0, 0, +/* 0x0310 */ 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 12, 0, 0, 0, +/* 0x0320 */ 0, 0, 0, 0, 0, 0, 0, 0, 95, 95, 99,111,109,109,111,110, +/* 0x0330 */ 0, 0, 0, 0, 0, 0, 0, 0, 95, 95, 68, 65, 84, 65, 0, 0, +/* 0x0340 */ 0, 0, 0, 0, 0, 0, 0, 0, 96, 16,255,255, 0, 0, 0, 0, +/* 0x0350 */ 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, +/* 0x0360 */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, +/* 0x0370 */ 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 72, 0, 0, 0, +/* 0x0380 */ 95, 95, 76, 73, 78, 75, 69, 68, 73, 84, 0, 0, 0, 0, 0, 0, +/* 0x0390 */ 0, 32,255,255, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, +/* 0x03a0 */ 0, 32, 0, 0, 0, 0, 0, 0,132, 3, 0, 0, 0, 0, 0, 0, +/* 0x03b0 */ 7, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x03c0 */ 34, 0, 0,128, 48, 0, 0, 0, 0, 32, 0, 0, 8, 0, 0, 0, +/* 0x03d0 */ 8, 32, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x03e0 */ 64, 32, 0, 0,136, 0, 0, 0,200, 32, 0, 0, 96, 0, 0, 0, +/* 0x03f0 */ 2, 0, 0, 0, 24, 0, 0, 0, 56, 33, 0, 0, 19, 0, 0, 0, +/* 0x0400 */ 188, 34, 0, 0,200, 0, 0, 0, 11, 0, 0, 0, 80, 0, 0, 0, +/* 0x0410 */ 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0, +/* 0x0420 */ 8, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0430 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0440 */ 104, 34, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0450 */ 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 32, 0, 0, 0, +/* 0x0460 */ 12, 0, 0, 0, 47,117,115,114, 47,108,105, 98, 47,100,121,108, +/* 0x0470 */ 100, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 24, 0, 0, 0, +/* 0x0480 */ 23, 55,189, 7,110,207, 57, 27,146, 38,212,221,128, 33, 19, 11, +/* 0x0490 */ 36, 0, 0, 0, 16, 0, 0, 0, 0, 12, 10, 0, 0, 12, 10, 0, +/* 0x04a0 */ 42, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x04b0 */ 40, 0, 0,128, 24, 0, 0, 0,128, 14, 0, 0, 0, 0, 0, 0, +/* 0x04c0 */ 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 56, 0, 0, 0, +/* 0x04d0 */ 24, 0, 0, 0, 2, 0, 0, 0, 0, 0,214, 4, 0, 0, 1, 0, +/* 0x04e0 */ 47,117,115,114, 47,108,105, 98, 47,108,105, 98, 83,121,115,116, +/* 0x04f0 */ 101,109, 46, 66, 46,100,121,108,105, 98, 0, 0, 0, 0, 0, 0, +/* 0x0500 */ 38, 0, 0, 0, 16, 0, 0, 0, 40, 33, 0, 0, 16, 0, 0, 0, +/* 0x0510 */ 41, 0, 0, 0, 16, 0, 0, 0, 56, 33, 0, 0, 0, 0, 0, 0, +/* 0x0520 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0530 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0540 */ 0,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 0, 0, 0, 0, 0, +/* 0x0770 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0780 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0790 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x07a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x07b0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x07c0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x07d0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x07e0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x07f0 */ 85, 72,137,229, 65, 87, 65, 86, 65, 85, 65, 84, 83, 72,131,236, +/* 0x0800 */ 72, 77,137,204, 76,137,195, 72,137, 77,152, 73,137,213, 76,139, +/* 0x0810 */ 125, 16, 72,137,117,208, 72,141, 71, 24, 72,137, 69,200, 72,139, +/* 0x0820 */ 69,208, 72,131,192,232, 72,137, 69,192, 76,137,109,184,139, 71, +/* 0x0830 */ 24, 72,137, 69,176, 72,139, 69,192, 72,139, 77,200, 72,137, 77, +/* 0x0840 */ 168, 72,137, 69,160, 69, 49,246, 72,141,125,192, 72,141,117,176, +/* 0x0850 */ 49,201, 72,137,218,232, 38, 1, 0, 0, 76,137, 36, 36, 72,141, +/* 0x0860 */ 85,160,190, 0, 0, 0, 0,185,255,255,255,255, 76,137,239, 77, +/* 0x0870 */ 137,248, 73,137,217,232,198, 3, 0, 0, 72,137,195, 65,139, 77, +/* 0x0880 */ 16,133,201, 15,132,228, 0, 0, 0, 73,141, 69, 32, 15, 31, 0, +/* 0x0890 */ 131, 56, 14,116, 19, 65,255,198,139, 80, 4, 72, 1,208, 65, 57, +/* 0x08a0 */ 206,114,237,233,197, 0, 0, 0,139,120, 8, 72, 1,199, 49,246, +/* 0x08b0 */ 49,210,232,119, 6, 0, 0, 65,137,199, 69,133,255, 72,139, 93, +/* 0x08c0 */ 152,120,119, 69, 49,228, 49,201, 68,137,255, 76,137,238, 72,137, +/* 0x08d0 */ 218,232, 94, 6, 0, 0, 72, 57,216,117, 95, 77,141,117, 8, 65, +/* 0x08e0 */ 139, 69, 0, 61,190,186,254,202,116, 7, 61,202,254,186,190,117, +/* 0x08f0 */ 83, 65,139, 69, 4, 49,201,133,192, 76,137,242,116, 70,102,144, +/* 0x0900 */ 129, 58, 7, 0, 0, 1,116, 24,255,193, 72,131,194, 20, 57,193, +/* 0x0910 */ 114,238,235, 48,102,102,102, 46, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0920 */ 68,139, 98, 8, 68,137,255, 76,137,238, 72,137,218, 68,137,225, +/* 0x0930 */ 232,255, 5, 0, 0, 72, 57,216,116,165,191,127, 0, 0, 0,232, +/* 0x0940 */ 210, 5, 0, 0, 72,199, 4, 36, 0, 0, 0, 0, 49,210, 69, 49, +/* 0x0950 */ 192, 69, 49,201, 76,137,239, 68,137,230, 68,137,249,232,222, 2, +/* 0x0960 */ 0, 0, 72,137,195, 68,137,255,232,163, 5, 0, 0, 72,137,216, +/* 0x0970 */ 72,131,196, 72, 91, 65, 92, 65, 93, 65, 94, 65, 95, 93,195,144, +/* 0x0980 */ 85, 72,137,229, 65, 87, 65, 86, 65, 85, 65, 84, 83, 72,131,236, +/* 0x0990 */ 40, 72,137, 77,184, 72,137, 85,176, 73,137,244, 73,137,255, 73, +/* 0x09a0 */ 131, 60, 36, 0, 15,132,103, 2, 0, 0,102, 15, 31, 68, 0, 0, +/* 0x09b0 */ 73,139, 7, 72,131,248, 11, 15,134,109, 2, 0, 0, 73,139, 87, +/* 0x09c0 */ 8,138, 10,136, 77,200,138, 74, 1,136, 77,201,138, 74, 2,136, +/* 0x09d0 */ 77,202,138, 74, 3,136, 77,203,138, 74, 4,136, 77,204,138, 74, +/* 0x09e0 */ 5,136, 77,205,138, 74, 6,136, 77,206,138, 74, 7,136, 77,207, +/* 0x09f0 */ 138, 74, 8,136, 77,208,138, 74, 9,136, 77,209,138, 74, 10,136, +/* 0x0a00 */ 77,210,138, 74, 11,136, 77,211, 72,141,122, 12, 73,137,127, 8, +/* 0x0a10 */ 72,131,192,244, 73,137, 7, 68,139,117,200, 68,139,109,204, 77, +/* 0x0a20 */ 133,246, 15,132,219, 1, 0, 0, 65,141, 77,255, 68, 57,241, 15, +/* 0x0a30 */ 131,235, 1, 0, 0, 77, 59, 52, 36, 15,135,225, 1, 0, 0, 69, +/* 0x0a40 */ 57,245,115, 92, 68,137,117,196, 73,139, 84, 36, 8,139, 93,208, +/* 0x0a50 */ 68, 15,182,195, 68,137,238, 72,141, 77,196,255, 85,176,133,192, +/* 0x0a60 */ 15,133,186, 1, 0, 0, 68, 57,117,196, 15,133,176, 1, 0, 0, +/* 0x0a70 */ 72,131,125,184, 0,116, 28, 15,182,199,102,133,192,116, 20,193, +/* 0x0a80 */ 235, 16, 15,183,200, 73,139,124, 36, 8, 15,182,211, 68,137,246, +/* 0x0a90 */ 255, 85,184, 77, 1,111, 8, 77, 41, 47,233, 73, 1, 0, 0,144, +/* 0x0aa0 */ 76, 57,232, 15,130,129, 1, 0, 0, 69,133,237, 15,132, 41, 1, +/* 0x0ab0 */ 0, 0, 73,139,116, 36, 8, 65,131,253, 32,114, 51, 69,137,232, +/* 0x0ac0 */ 65,131,224, 31, 69, 57,197,116, 39, 74,141, 68, 42, 11, 72, 57, +/* 0x0ad0 */ 198, 15,135,151, 0, 0, 0, 74,141, 68, 46,255, 72, 57,199, 15, +/* 0x0ae0 */ 135,137, 0, 0, 0,102,102, 46, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0af0 */ 76,137,232, 72,137,241, 72,141, 80,255,168, 7,116, 36,137,198, +/* 0x0b00 */ 131,230, 7, 72,247,222,102, 46, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0b10 */ 72,255,200,138, 31,136, 25, 72,255,199, 72,255,193, 72,255,198, +/* 0x0b20 */ 117,238, 72,131,250, 7, 15,130,164, 0, 0, 0, 15, 31, 64, 0, +/* 0x0b30 */ 138, 23,136, 17,138, 87, 1,136, 81, 1,138, 87, 2,136, 81, 2, +/* 0x0b40 */ 138, 87, 3,136, 81, 3,138, 87, 4,136, 81, 4,138, 87, 5,136, +/* 0x0b50 */ 81, 5,138, 87, 6,136, 81, 6, 72,131,192,248,138, 87, 7, 72, +/* 0x0b60 */ 141,127, 8,136, 81, 7, 72,141, 73, 8,117,196,235, 98, 76,137, +/* 0x0b70 */ 235, 76, 41,195, 76,137,232, 72, 41,216, 72,141, 12, 30, 72, 1, +/* 0x0b80 */ 223, 72,131,194, 28, 72,131,198, 16, 69,137,233, 65,131,225, 31, +/* 0x0b90 */ 76,137,235, 76, 41,203,102, 46, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0ba0 */ 15, 16, 66,240, 15, 16, 10, 15, 17, 70,240, 15, 17, 14, 72,131, +/* 0x0bb0 */ 194, 32, 72,131,198, 32, 72,131,195,224,117,228, 69,133,192, 15, +/* 0x0bc0 */ 133, 49,255,255,255,102,102, 46, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0bd0 */ 73,139, 7, 73,139,127, 8, 68,139,117,200, 76, 1,239, 73,137, +/* 0x0be0 */ 127, 8, 76, 41,232, 73,137, 7, 68,137,240, 73, 1, 68, 36, 8, +/* 0x0bf0 */ 73,139, 12, 36, 72, 41,193, 73,137, 12, 36, 15,133,175,253,255, +/* 0x0c00 */ 255,235, 14, 72,133,192,117, 24, 65,129,253, 85, 80, 88, 33,117, +/* 0x0c10 */ 15, 72,131,196, 40, 91, 65, 92, 65, 93, 65, 94, 65, 95, 93,195, +/* 0x0c20 */ 191,127, 0, 0, 0,232,236, 2, 0, 0,191,127, 0, 0, 0,232, +/* 0x0c30 */ 226, 2, 0, 0,102,102,102, 46, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0c40 */ 85, 72,137,229, 65, 87, 65, 86, 65, 85, 65, 84, 83, 72,131,236, +/* 0x0c50 */ 104, 76,137, 77,128, 76,137,133,120,255,255,255,137, 77,156, 72, +/* 0x0c60 */ 137, 85,192, 72,137,125,168,139, 71, 16, 49,219,133,192,185, 0, +/* 0x0c70 */ 0, 0, 0, 72,137, 77,160, 15,132,221, 1, 0, 0, 72,139, 77, +/* 0x0c80 */ 168, 76,141,113, 32, 72,131,125,192, 0, 15,149,193, 15,182,201, +/* 0x0c90 */ 72,141, 12, 73, 72,137, 77,144,137,241, 72,137, 77,136, 49,201, +/* 0x0ca0 */ 72,137, 77,160,102,102,102, 46, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0cb0 */ 73,139, 22, 72,137,209, 72,193,233, 32,131,250, 25, 15,133, 45, +/* 0x0cc0 */ 1, 0, 0, 73,139, 86, 32, 72,133,210, 15,132,123, 1, 0, 0, +/* 0x0cd0 */ 72,137, 85,176, 73,139, 70, 48, 72,137, 69,200, 77,139,126, 24, +/* 0x0ce0 */ 76,137,125,184, 76,137,125,208, 69,137,252, 65,129,228,255, 15, +/* 0x0cf0 */ 0, 0, 77, 41,231, 73, 1,196,116, 76, 72,139, 77,144, 73,141, +/* 0x0d00 */ 52, 12, 72,133,192,185, 18, 0, 0, 0,186, 18, 16, 0, 0, 15, +/* 0x0d10 */ 68,202, 72,131,125,192, 0, 15, 69,202, 72,131,248, 1, 69, 25, +/* 0x0d20 */ 192, 68, 11, 69,156, 69,139, 78, 40, 72,139, 69,136, 65, 1,193, +/* 0x0d30 */ 186, 3, 0, 0, 0, 76,137,255,232,223, 1, 0, 0, 73, 57,199, +/* 0x0d40 */ 15,133, 39, 1, 0, 0, 72,131,125,192, 0,116, 45, 73,131,126, +/* 0x0d50 */ 48, 0,116, 38, 73,131,126, 40, 0,117, 10, 72,139,133,120,255, +/* 0x0d60 */ 255,255, 76,137, 56, 72,139,125,192, 72,141,117,200, 72,139, 85, +/* 0x0d70 */ 128, 72,139, 77, 16,232, 6,252,255,255, 69,137,229, 65,247,221, +/* 0x0d80 */ 73,129,229,255, 15, 0, 0,116, 12, 75,141, 60, 39, 76,137,238, +/* 0x0d90 */ 232,111, 1, 0, 0, 77,133,228,116, 23, 65,139, 86, 60, 76,137, +/* 0x0da0 */ 255, 76,137,230,232,121, 1, 0, 0,133,192, 15,133,188, 0, 0, +/* 0x0db0 */ 0, 72,139, 69,184, 72, 3, 69,176, 77, 1,229, 77, 1,239, 73, +/* 0x0dc0 */ 57,199,115, 78, 77,133,255,116,119, 72,137,198, 76, 41,254, 65, +/* 0x0dd0 */ 139, 86, 60,185, 18, 16, 0, 0, 65,184,255,255,255,255, 69, 49, +/* 0x0de0 */ 201, 76,137,255,232, 51, 1, 0, 0, 73, 57,199,116, 82,235,125, +/* 0x0df0 */ 131,226,254,131,250, 4,117, 83, 72,186, 4, 0, 0, 0, 42, 0, +/* 0x0e00 */ 0, 0, 73, 57, 86, 8,117, 67, 73,141, 86, 16, 72,137, 85,160, +/* 0x0e10 */ 235, 57, 72,131,125,192, 0,116, 39, 65,131,196, 3, 65,129,228, +/* 0x0e20 */ 255, 15, 0, 0, 73,131,252, 3,119, 22, 76,137,255, 76,137,230, +/* 0x0e30 */ 232,243, 0, 0, 0,102,102, 46, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0e40 */ 65,139, 78, 4, 72,139, 69,168,139, 64, 16,255,195,137,201, 73, +/* 0x0e50 */ 1,206, 57,195, 15,130, 86,254,255,255, 72,139, 69,160, 72,131, +/* 0x0e60 */ 196,104, 91, 65, 92, 65, 93, 65, 94, 65, 95, 93,195,191,127, 0, +/* 0x0e70 */ 0, 0,232,159, 0, 0, 0,102, 15, 31,132, 0, 0, 0, 0, 0, +/* 0x0e80 */ 85, 72,137,229, 65, 86, 83, 72,129,236, 32, 8, 0, 0, 76,139, +/* 0x0e90 */ 53,123, 1, 0, 0, 77,139, 54, 76,137,117,232,191,248,255,254, +/* 0x0ea0 */ 255, 72,139, 55, 72,131,199, 8, 72, 41,247, 72,141, 5,174, 1, +/* 0x0eb0 */ 0, 0, 76,139, 0, 72,141, 5,172, 1, 0, 0, 76,139, 8, 72, +/* 0x0ec0 */ 141,157,216,247,255,255, 72,137, 28, 36, 72,141,149,224,247,255, +/* 0x0ed0 */ 255,185, 0, 8, 0, 0,232, 21,249,255,255, 72,141, 13,142, 1, +/* 0x0ee0 */ 0, 0, 72,137,199, 72,137,222,255, 17, 76, 59,117,232,117, 14, +/* 0x0ef0 */ 49,192, 72,129,196, 32, 8, 0, 0, 91, 65, 94, 93,195,232, 7, +/* 0x0f00 */ 0, 0, 0,144,255, 37, 14, 1, 0, 0,255, 37, 16, 1, 0, 0, +/* 0x0f10 */ 255, 37, 18, 1, 0, 0,255, 37, 20, 1, 0, 0,255, 37, 22, 1, +/* 0x0f20 */ 0, 0,255, 37, 24, 1, 0, 0,255, 37, 26, 1, 0, 0,255, 37, +/* 0x0f30 */ 28, 1, 0, 0,255, 37, 30, 1, 0, 0, 0, 0, 76,141, 29,197, +/* 0x0f40 */ 0, 0, 0, 65, 83,255, 37,181, 0, 0, 0,144,104, 0, 0, 0, +/* 0x0f50 */ 0,233,230,255,255,255,104, 15, 0, 0, 0,233,220,255,255,255, +/* 0x0f60 */ 104, 39, 0, 0, 0,233,210,255,255,255,104, 52, 0, 0, 0,233, +/* 0x0f70 */ 200,255,255,255,104, 64, 0, 0, 0,233,190,255,255,255,104, 76, +/* 0x0f80 */ 0, 0, 0,233,180,255,255,255,104, 92, 0, 0, 0,233,170,255, +/* 0x0f90 */ 255,255,104,106, 0, 0, 0,233,160,255,255,255,104,118, 0, 0, +/* 0x0fa0 */ 0,233,150,255,255,255, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, +/* 0x0fb0 */ 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, +/* 0x0fc0 */ 2, 0, 0, 0,240, 7, 0, 0, 52, 0, 0, 0, 52, 0, 0, 0, +/* 0x0fd0 */ 4, 15, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 3, 0, 0, 0, +/* 0x0fe0 */ 12, 0, 2, 0, 20, 0, 2, 0, 0, 0, 0, 1,144, 6, 0, 0, +/* 0x0ff0 */ 33, 0, 2, 1,209, 88, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x1000 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x1010 */ 0, 0, 0, 0, 0, 0, 0, 0, 76, 15,255,255, 0, 0, 0, 0, +/* 0x1020 */ 86, 15,255,255, 0, 0, 0, 0, 96, 15,255,255, 0, 0, 0, 0, +/* 0x1030 */ 106, 15,255,255, 0, 0, 0, 0,116, 15,255,255, 0, 0, 0, 0, +/* 0x1040 */ 126, 15,255,255, 0, 0, 0, 0,136, 15,255,255, 0, 0, 0, 0, +/* 0x1050 */ 146, 15,255,255, 0, 0, 0, 0,156, 15,255,255, 0, 0, 0, 0, +/* 0x1060 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x1070 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x1080 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x1090 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x10a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x10b0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x10c0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x10d0 */ 0, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x1fe0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x1ff0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x2000 */ 17, 34, 24, 89, 0, 0, 0, 0, 17, 64, 95, 95, 95,115,116, 97, +/* 0x2010 */ 99,107, 95, 99,104,107, 95,103,117, 97,114,100, 0, 81,114, 16, +/* 0x2020 */ 144, 64,100,121,108,100, 95,115,116,117, 98, 95, 98,105,110,100, +/* 0x2030 */ 101,114, 0,128,232,255,255,255,255,255,255,255,255, 1,144, 0, +/* 0x2040 */ 114, 24, 17, 64, 95, 95, 95, 98,122,101,114,111, 0,144, 0,114, +/* 0x2050 */ 32, 17, 64, 95, 95, 95,115,116, 97, 99,107, 95, 99,104,107, 95, +/* 0x2060 */ 102, 97,105,108, 0,144, 0,114, 40, 17, 64, 95, 99,108,111,115, +/* 0x2070 */ 101, 0,144, 0,114, 48, 17, 64, 95,101,120,105,116, 0,144, 0, +/* 0x2080 */ 114, 56, 17, 64, 95,109,109, 97,112, 0,144, 0,114, 64, 17, 64, +/* 0x2090 */ 95,109,112,114,111,116,101, 99,116, 0,144, 0,114, 72, 17, 64, +/* 0x20a0 */ 95,109,117,110,109, 97,112, 0,144, 0,114, 80, 17, 64, 95,111, +/* 0x20b0 */ 112,101,110, 0,144, 0,114, 88, 17, 64, 95,112,114,101, 97,100, +/* 0x20c0 */ 0,144, 0, 0, 0, 0, 0, 0, 0, 1, 95, 0, 5, 0, 5, 95, +/* 0x20d0 */ 109,104, 95,101,120,101, 99,117,116,101, 95,104,101, 97,100,101, +/* 0x20e0 */ 114, 0, 55,117,112,120, 95,109, 97,105,110, 0, 59,109, 97,105, +/* 0x20f0 */ 110, 0, 64,102, 95, 0, 69,108, 97,117,110, 99,104, 0, 91, 2, +/* 0x2100 */ 0, 0, 0, 3, 0,240, 15, 0, 3, 0,128, 29, 0, 0, 2,101, +/* 0x2110 */ 120,112, 0, 81,117,110,102, 0, 86, 3, 0,224, 32, 0, 3, 0, +/* 0x2120 */ 232, 32, 0, 3, 0,240, 32, 0,240, 15,144, 3,192, 5,192, 4, +/* 0x2130 */ 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 14, 1, 0, 0, +/* 0x2140 */ 128, 9,255,255, 0, 0, 0, 0, 16, 0, 0, 0, 14, 1, 0, 0, +/* 0x2150 */ 64, 12,255,255, 0, 0, 0, 0, 25, 0, 0, 0, 15, 1, 16, 0, +/* 0x2160 */ 0, 0,255,255, 0, 0, 0, 0, 45, 0, 0, 0, 15, 8, 0, 0, +/* 0x2170 */ 96, 16,255,255, 0, 0, 0, 0, 52, 0, 0, 0, 15, 8, 0, 0, +/* 0x2180 */ 104, 16,255,255, 0, 0, 0, 0, 59, 0, 0, 0, 15, 8, 0, 0, +/* 0x2190 */ 112, 16,255,255, 0, 0, 0, 0, 67, 0, 0, 0, 15, 1, 0, 0, +/* 0x21a0 */ 128, 14,255,255, 0, 0, 0, 0, 73, 0, 0, 0, 15, 1, 0, 0, +/* 0x21b0 */ 240, 7,255,255, 0, 0, 0, 0, 83, 0, 0, 0, 1, 0, 0, 1, +/* 0x21c0 */ 0, 0, 0, 0, 0, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 1, +/* 0x21d0 */ 0, 0, 0, 0, 0, 0, 0, 0,110, 0, 0, 0, 1, 0, 0, 1, +/* 0x21e0 */ 0, 0, 0, 0, 0, 0, 0, 0,129, 0, 0, 0, 1, 0, 0, 1, +/* 0x21f0 */ 0, 0, 0, 0, 0, 0, 0, 0,136, 0, 0, 0, 1, 0, 0, 1, +/* 0x2200 */ 0, 0, 0, 0, 0, 0, 0, 0,142, 0, 0, 0, 1, 0, 0, 1, +/* 0x2210 */ 0, 0, 0, 0, 0, 0, 0, 0,148, 0, 0, 0, 1, 0, 0, 1, +/* 0x2220 */ 0, 0, 0, 0, 0, 0, 0, 0,158, 0, 0, 0, 1, 0, 0, 1, +/* 0x2230 */ 0, 0, 0, 0, 0, 0, 0, 0,166, 0, 0, 0, 1, 0, 0, 1, +/* 0x2240 */ 0, 0, 0, 0, 0, 0, 0, 0,172, 0, 0, 0, 1, 0, 0, 1, +/* 0x2250 */ 0, 0, 0, 0, 0, 0, 0, 0,179, 0, 0, 0, 1, 0, 0, 1, +/* 0x2260 */ 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 9, 0, 0, 0, +/* 0x2270 */ 11, 0, 0, 0, 12, 0, 0, 0, 13, 0, 0, 0, 14, 0, 0, 0, +/* 0x2280 */ 15, 0, 0, 0, 16, 0, 0, 0, 17, 0, 0, 0, 18, 0, 0, 0, +/* 0x2290 */ 0, 0, 0, 64, 10, 0, 0, 0, 8, 0, 0, 0, 9, 0, 0, 0, +/* 0x22a0 */ 11, 0, 0, 0, 12, 0, 0, 0, 13, 0, 0, 0, 14, 0, 0, 0, +/* 0x22b0 */ 15, 0, 0, 0, 16, 0, 0, 0, 17, 0, 0, 0, 32, 0, 95,117, +/* 0x22c0 */ 110,112, 97, 99,107, 69,120,116,101,110,116, 0, 95,100,111, 95, +/* 0x22d0 */ 120,109, 97,112, 0, 95, 95,109,104, 95,101,120,101, 99,117,116, +/* 0x22e0 */ 101, 95,104,101, 97,100,101,114, 0, 95,102, 95,101,120,112, 0, +/* 0x22f0 */ 95,102, 95,117,110,102, 0, 95,108, 97,117,110, 99,104, 0, 95, +/* 0x2300 */ 109, 97,105,110, 0, 95,117,112,120, 95,109, 97,105,110, 0, 95, +/* 0x2310 */ 95, 95, 98,122,101,114,111, 0, 95, 95, 95,115,116, 97, 99,107, +/* 0x2320 */ 95, 99,104,107, 95,102, 97,105,108, 0, 95, 95, 95,115,116, 97, +/* 0x2330 */ 99,107, 95, 99,104,107, 95,103,117, 97,114,100, 0, 95, 99,108, +/* 0x2340 */ 111,115,101, 0, 95,101,120,105,116, 0, 95,109,109, 97,112, 0, +/* 0x2350 */ 95,109,112,114,111,116,101, 99,116, 0, 95,109,117,110,109, 97, +/* 0x2360 */ 112, 0, 95,111,112,101,110, 0, 95,112,114,101, 97,100, 0,100, +/* 0x2370 */ 121,108,100, 95,115,116,117, 98, 95, 98,105,110,100,101,114, 0, +/* 0x2380 */ 0, 0, 0, 0 +}; diff --git a/src/stub/src/amd64-darwin.macho-upxmain.c b/src/stub/src/amd64-darwin.macho-upxmain.c new file mode 100644 index 00000000..9b2a5520 --- /dev/null +++ b/src/stub/src/amd64-darwin.macho-upxmain.c @@ -0,0 +1,663 @@ +/* amd64-darwin.macho-upxmain.c -- loader hack for Mach-o AMD64 + + This file is part of the UPX executable compressor. + + Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2015 Laszlo Molnar + Copyright (C) 2000-2015 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 + + */ + + +#include "include/darwin.h" + +#ifndef DEBUG /*{*/ +#define DEBUG 0 +#endif /*}*/ + +/************************************************************************* +// configuration section +**************************************************************************/ + +// In order to make it much easier to move this code at runtime and execute +// it at an address different from it load address: there must be no +// static data, and no string constants. + +#if !DEBUG /*{*/ +#define DPRINTF(a) /* empty: no debug drivel */ +#define DEBUG_STRCON(name, value) /* empty */ +#else /*}{ DEBUG */ +extern int write(int, void const *, size_t); +#if 0 +#include "stdarg.h" +#else +#define va_arg __builtin_va_arg +#define va_end __builtin_va_end +#define va_list __builtin_va_list +#define va_start __builtin_va_start +#endif + +#if defined(__i386__) || defined(__x86_64__) /*{*/ +#define PIC_STRING(value, var) \ + __asm__ __volatile__ ( \ + "call 0f; .asciz \"" value "\"; \ + 0: pop %0;" : "=r"(var) : \ + ) +#elif defined(__arm__) /*}{*/ +#define PIC_STRING(value, var) \ + __asm__ __volatile__ ( \ + "mov %0,pc; b 0f; \ + .asciz \"" value "\"; .balign 4; \ + 0: " : "=r"(var) \ + ) +#elif defined(__mips__) /*}{*/ +#define PIC_STRING(value, var) \ + __asm__ __volatile__ ( \ + ".set noreorder; bal 0f; move %0,$31; .set reorder; \ + .asciz \"" value "\"; .balign 4; \ + 0: " \ + : "=r"(var) : : "ra" \ + ) +#endif /*}*/ + + +#define DEBUG_STRCON(name, strcon) \ + static char const *name(void) { \ + register char const *rv; PIC_STRING(strcon, rv); \ + return rv; \ + } + + +#ifdef __arm__ /*{*/ +extern unsigned div10(unsigned); +#else /*}{*/ +static unsigned +div10(unsigned x) +{ + return x / 10u; +} +#endif /*}*/ + +static int +unsimal(unsigned x, char *ptr, int n) +{ + if (10<=x) { + unsigned const q = div10(x); + x -= 10 * q; + n = unsimal(q, ptr, n); + } + ptr[n] = '0' + x; + return 1+ n; +} + +static int +decimal(int x, char *ptr, int n) +{ + if (x < 0) { + x = -x; + ptr[n++] = '-'; + } + return unsimal(x, ptr, n); +} + +DEBUG_STRCON(STR_hex, "0123456789abcdef"); + +static int +heximal(unsigned long x, char *ptr, int n) +{ + if (16<=x) { + n = heximal(x>>4, ptr, n); + x &= 0xf; + } + ptr[n] = STR_hex()[x]; + return 1+ n; +} + + +#define DPRINTF(a) dprintf a + +static int +dprintf(char const *fmt, ...) +{ + char c; + int n= 0; + char *ptr; + char buf[20]; + va_list va; va_start(va, fmt); + ptr= &buf[0]; + while (0!=(c= *fmt++)) if ('%'!=c) goto literal; + else switch (c= *fmt++) { + default: { +literal: + n+= write(2, fmt-1, 1); + } break; + case 0: goto done; /* early */ + case 'u': { + n+= write(2, buf, unsimal(va_arg(va, unsigned), buf, 0)); + } break; + case 'd': { + n+= write(2, buf, decimal(va_arg(va, int), buf, 0)); + } break; + case 'p': { + buf[0] = '0'; + buf[1] = 'x'; + n+= write(2, buf, heximal((unsigned long)va_arg(va, void *), buf, 2)); + } break; + case 'x': { + buf[0] = '0'; + buf[1] = 'x'; + n+= write(2, buf, heximal(va_arg(va, int), buf, 2)); + } break; + } +done: + va_end(va); + return n; +} +#endif /*}*/ + + +/************************************************************************* +// "file" util +**************************************************************************/ + +typedef struct { + size_t size; // must be first to match size[0] uncompressed size + void *buf; +} Extent; + +DEBUG_STRCON(STR_xread, "xread %%p(%%x %%p) %%p %%x\\n") +DEBUG_STRCON(STR_xreadfail, "xreadfail %%p(%%x %%p) %%p %%x\\n") + +static void +xread(Extent *x, void *buf, size_t count) +{ + unsigned char *p=x->buf, *q=buf; + size_t j; + DPRINTF((STR_xread(), x, x->size, x->buf, buf, count)); + if (x->size < count) { + DPRINTF((STR_xreadfail(), x, x->size, x->buf, buf, count)); + exit(127); + } + for (j = count; 0!=j--; ++p, ++q) { + *q = *p; + } + x->buf += count; + x->size -= count; +} + + +/************************************************************************* +// util +**************************************************************************/ + +#if 1 //{ save space +#define ERR_LAB error: exit(127); +#define err_exit(a) goto error +#else //}{ save debugging time +#define ERR_LAB /*empty*/ +DEBUG_STRCON(STR_exit, "err_exit %%x\\n"); + +static void +err_exit(int a) +{ + DPRINTF((STR_exit(), a)); + (void)a; // debugging convenience + exit(127); +} +#endif //} + + +/************************************************************************* +// UPX & NRV stuff +**************************************************************************/ + +struct l_info { // 12-byte trailer for loader (after macho headers) + unsigned l_checksum; + unsigned l_magic; // UPX_MAGIC_LE32 + unsigned short l_lsize; + unsigned char l_version; + unsigned char l_format; +}; +struct p_info { // 12-byte packed program header + unsigned p_progid; + unsigned p_filesize; + unsigned p_blocksize; +}; + +struct b_info { // 12-byte header before each compressed block + unsigned sz_unc; // uncompressed_size + unsigned sz_cpr; // compressed_size + unsigned char b_method; // compression algorithm + unsigned char b_ftid; // filter id + unsigned char b_cto8; // filter parameter + unsigned char b_unused; +}; + +typedef void f_unfilter( + nrv_byte *, // also addvalue + nrv_uint, + unsigned cto8, // junk in high 24 bits + unsigned ftid +); +typedef int f_expand( + const nrv_byte *, nrv_uint, + nrv_byte *, nrv_uint *, unsigned ); + +DEBUG_STRCON(STR_unpackExtent, + "unpackExtent in=%%p(%%x %%p) out=%%p(%%x %%p) %%p %%p\\n"); +DEBUG_STRCON(STR_err5, "sz_cpr=%%x sz_unc=%%x xo->size=%%x\\n"); + +static void +unpackExtent( + Extent *const xi, // input + Extent *const xo, // output + f_expand *const f_decompress, + f_unfilter *f_unf +) +{ + DPRINTF((STR_unpackExtent(), + xi, xi->size, xi->buf, xo, xo->size, xo->buf, f_decompress, f_unf)); + while (xo->size) { + struct b_info h; + // Note: if h.sz_unc == h.sz_cpr then the block was not + // compressible and is stored in its uncompressed form. + + // Read and check block sizes. + xread(xi, (unsigned char *)&h, sizeof(h)); + if (h.sz_unc == 0) { // uncompressed size 0 -> EOF + if (h.sz_cpr != UPX_MAGIC_LE32) // h.sz_cpr must be h->magic + err_exit(2); + if (xi->size != 0) // all bytes must be written + err_exit(3); + break; + } + if (h.sz_cpr <= 0) { + err_exit(4); +ERR_LAB + } + if (h.sz_cpr > h.sz_unc + || h.sz_unc > xo->size ) { + DPRINTF((STR_err5(), h.sz_cpr, h.sz_unc, xo->size)); + err_exit(5); + } + // Now we have: + // assert(h.sz_cpr <= h.sz_unc); + // assert(h.sz_unc > 0 && h.sz_unc <= blocksize); + // assert(h.sz_cpr > 0 && h.sz_cpr <= blocksize); + + if (h.sz_cpr < h.sz_unc) { // Decompress block + nrv_uint out_len = h.sz_unc; // EOF for lzma + int const j = (*f_decompress)(xi->buf, h.sz_cpr, + xo->buf, &out_len, h.b_method); + if (j != 0 || out_len != (nrv_uint)h.sz_unc) + err_exit(7); + if (h.b_ftid!=0 && f_unf) { // have filter + (*f_unf)(xo->buf, out_len, h.b_cto8, h.b_ftid); + } + xi->buf += h.sz_cpr; + xi->size -= h.sz_cpr; + } + else { // copy literal block + xread(xi, xo->buf, h.sz_cpr); + } + xo->buf += h.sz_unc; + xo->size -= h.sz_unc; + } +} + +static void +upx_bzero(unsigned char *p, size_t len) +{ + if (len) do { + *p++= 0; + } while (--len); +} +#define bzero upx_bzero + + +// The PF_* and PROT_* bits are {1,2,4}; the conversion table fits in 32 bits. +#define REP8(x) \ + ((x)|((x)<<4)|((x)<<8)|((x)<<12)|((x)<<16)|((x)<<20)|((x)<<24)|((x)<<28)) +#define EXP8(y) \ + ((1&(y)) ? 0xf0f0f0f0 : (2&(y)) ? 0xff00ff00 : (4&(y)) ? 0xffff0000 : 0) +#define PF_TO_PROT(pf) \ + ((PROT_READ|PROT_WRITE|PROT_EXEC) & ( \ + ( (REP8(PROT_EXEC ) & EXP8(PF_X)) \ + |(REP8(PROT_READ ) & EXP8(PF_R)) \ + |(REP8(PROT_WRITE) & EXP8(PF_W)) \ + ) >> ((pf & (PF_R|PF_W|PF_X))<<2) )) + +typedef struct { + unsigned magic; + unsigned nfat_arch; +} Fat_header; +typedef struct { + unsigned cputype; + unsigned cpusubtype; + unsigned offset; + unsigned size; + unsigned align; /* shift count (log base 2) */ +} Fat_arch; + enum e8 { + FAT_MAGIC = 0xcafebabe, + FAT_CIGAM = 0xbebafeca + }; + enum e9 { + CPU_TYPE_I386 = 7, + CPU_TYPE_AMD64 = 0x01000007, + CPU_TYPE_ARM = 12, + CPU_TYPE_POWERPC = 0x00000012, + CPU_TYPE_POWERPC64 = 0x01000012 + }; + +typedef struct { + unsigned magic; + unsigned cputype; + unsigned cpysubtype; + unsigned filetype; + unsigned ncmds; + unsigned sizeofcmds; + unsigned flags; + unsigned reserved; +} Mach_header64; + enum e0 { + MH_MAGIC = 0xfeedface, + MH_MAGIC64 = 1+0xfeedface + }; + enum e2 { + MH_EXECUTE = 2 + }; + enum e3 { + MH_NOUNDEFS = 1 + }; + +typedef struct { + unsigned cmd; + unsigned cmdsize; +} Mach_load_command; + enum e4 { + LC_SEGMENT = 0x1, + LC_SEGMENT_64 = 0x19, + LC_THREAD = 0x4, + LC_UNIXTHREAD = 0x5, + LC_LOAD_DYLINKER = 0xe + }; + +typedef struct { + unsigned cmd; + unsigned cmdsize; + char segname[16]; + uint64_t vmaddr; + uint64_t vmsize; + uint64_t fileoff; + uint64_t filesize; + unsigned maxprot; + unsigned initprot; + unsigned nsects; + unsigned flags; +} Mach_segment_command; + enum e5 { + VM_PROT_READ = 1, + VM_PROT_WRITE = 2, + VM_PROT_EXECUTE = 4 + }; + +typedef struct { + uint64_t rax, rbx, rcx, rdx; + uint64_t rdi, rsi, rbp, rsp; + uint64_t r8, r9, r10, r11; + uint64_t r12, r13, r14, r15; + uint64_t rip, rflags; + uint64_t cs, fs, gs; +} Mach_AMD64_thread_state; + +typedef struct { + unsigned cmd; /* LC_THREAD or LC_UNIXTHREAD */ + unsigned cmdsize; /* total size of this command */ + unsigned flavor; + unsigned count; /* sizeof(following_thread_state)/4 */ + Mach_AMD64_thread_state state; +} Mach_thread_command; + enum e6 { + AMD64_THREAD_STATE = 4 // x86_THREAD_STATE64 + }; + enum e7 { + AMD64_THREAD_STATE_COUNT = sizeof(Mach_AMD64_thread_state)/4 + }; + +typedef union { + unsigned offset; /* from start of load command to string */ +} Mach_lc_str; + +#define MAP_FIXED 0x10 +#define MAP_PRIVATE 0x02 +#define MAP_ANON 0x1000 +//#define MAP_ANON 0x20 // x86 DEBUG ONLY +#define PROT_READ 1 +#define PROT_WRITE 2 +#define PROT_EXEC 4 +#define MAP_ANON_FD -1 + +extern void *mmap(void *, size_t, unsigned, unsigned, int, off_t); +ssize_t pread(int, void *, size_t, off_t); +#define bswap(a,b) /*EMPTY*/ +//extern void bswap(void *, unsigned); + +DEBUG_STRCON(STR_mmap, + "mmap addr=%%p len=%%p prot=%%x flags=%%x fd=%%d off=%%p\\n"); +DEBUG_STRCON(STR_do_xmap, + "do_xmap fdi=%%x mhdr=%%p xi=%%p(%%x %%p) f_unf=%%p\\n") + +static Mach_AMD64_thread_state const * +do_xmap( + Mach_header64 const *const mhdr, + off_t const fat_offset, + Extent *const xi, + int const fdi, + Mach_header64 **mhdrpp, + f_expand *const f_decompress, + f_unfilter *const f_unf +) +{ + Mach_segment_command const *sc = (Mach_segment_command const *)(1+ mhdr); + Mach_AMD64_thread_state const *entry = 0; + unsigned j; + + DPRINTF((STR_do_xmap(), + fdi, mhdr, xi, (xi? xi->size: 0), (xi? xi->buf: 0), f_unf)); + + for ( j=0; j < mhdr->ncmds; ++j, + (sc = (Mach_segment_command const *)(sc->cmdsize + (void const *)sc)) + ) if (LC_SEGMENT_64==sc->cmd && sc->vmsize!=0) { + Extent xo; + size_t mlen = xo.size = sc->filesize; + unsigned char *addr = xo.buf = (unsigned char *)sc->vmaddr; + unsigned char *haddr = sc->vmsize + addr; + size_t frag = (int)(uint64_t)addr &~ PAGE_MASK; + addr -= frag; + mlen += frag; + + if (0!=mlen) { + // Decompressor can overrun the destination by 3 bytes. [x86 only] + size_t const mlen3 = mlen + (xi ? 3 : 0); + unsigned const prot = VM_PROT_READ | VM_PROT_WRITE; + unsigned const flags = MAP_FIXED | MAP_PRIVATE | + ((xi || 0==sc->filesize) ? MAP_ANON : 0); + int const fdm = ((0==sc->filesize) ? MAP_ANON_FD : fdi); + off_t const offset = sc->fileoff + fat_offset; + + DPRINTF((STR_mmap(), addr, mlen3, prot, flags, fdm, offset)); + if (addr != mmap(addr, mlen3, prot, flags, fdm, offset)) { + err_exit(8); + } + } + if (xi && 0!=sc->filesize) { + if (0==sc->fileoff /*&& 0!=mhdrpp*/) { + *mhdrpp = (Mach_header64 *)(void *)addr; + } + unpackExtent(xi, &xo, f_decompress, f_unf); + } + /*bzero(addr, frag);*/ // fragment at lo end + frag = (-mlen) &~ PAGE_MASK; // distance to next page boundary + bzero(mlen+addr, frag); // fragment at hi end + if (0!=mlen && 0!=mprotect(addr, mlen, sc->initprot)) { + err_exit(10); +ERR_LAB + } + addr += mlen + frag; /* page boundary on hi end */ + if ( +#if defined(SIMULATE_ON_DEBIAN_EABI4) /*{*/ + 0!=addr && +#endif /*}*/ + addr < haddr) { // need pages for .bss + if (0!=addr && addr != mmap(addr, haddr - addr, sc->initprot, + MAP_FIXED | MAP_PRIVATE | MAP_ANON, MAP_ANON_FD, 0 ) ) { + err_exit(9); + } + } + else if (xi) { // cleanup if decompressor overrun crosses page boundary + mlen = ~PAGE_MASK & (3+ mlen); + if (mlen<=3) { // page fragment was overrun buffer only + munmap((char *)addr, mlen); + } + } + } + else if (LC_UNIXTHREAD==sc->cmd || LC_THREAD==sc->cmd) { + Mach_thread_command const *const thrc = (Mach_thread_command const *)sc; + if (AMD64_THREAD_STATE ==thrc->flavor + && AMD64_THREAD_STATE_COUNT==thrc->count ) { + entry = &thrc->state; + } + } + return entry; +} + + +/************************************************************************* +// upx_main - called by our entry code +// +**************************************************************************/ + +DEBUG_STRCON(STR_upx_main, + "upx_main szc=%%x f_dec=%%p f_unf=%%p " + " xo=%%p(%%x %%p) xi=%%p(%%x %%p) mhdrpp=%%p\\n") + +Mach_AMD64_thread_state const * +upx_main( + struct l_info const *const li, + size_t volatile sz_compressed, // total length + Mach_header64 *const mhdr, // temp char[sz_mhdr] for decompressing + size_t const sz_mhdr, + f_expand *const f_decompress, + f_unfilter *const f_unf, + Mach_header64 **const mhdrpp // Out: *mhdrpp= &real Mach_header64 +) +{ + Mach_AMD64_thread_state const *entry; + off_t fat_offset = 0; + Extent xi, xo, xi0; + xi.buf = CONST_CAST(unsigned char *, 1+ (struct p_info const *)(1+ li)); // &b_info + xi.size = sz_compressed - (sizeof(struct l_info) + sizeof(struct p_info)); + xo.buf = (unsigned char *)mhdr; + xo.size = ((struct b_info const *)(void const *)xi.buf)->sz_unc; + xi0 = xi; + + DPRINTF((STR_upx_main(), + sz_compressed, f_decompress, f_unf, &xo, xo.size, xo.buf, + &xi, xi.size, xi.buf, mhdrpp)); + + // Uncompress Macho headers + unpackExtent(&xi, &xo, f_decompress, 0); // never filtered? + + entry = do_xmap(mhdr, fat_offset, &xi0, MAP_ANON_FD, mhdrpp, f_decompress, f_unf); + + { // Map dyld dynamic loader + Mach_load_command const *lc = (Mach_load_command const *)(1+ mhdr); + unsigned j; + + for (j=0; j < mhdr->ncmds; ++j, + (lc = (Mach_load_command const *)(lc->cmdsize + (void const *)lc)) + ) if (LC_LOAD_DYLINKER==lc->cmd) { + char const *const dyld_name = ((Mach_lc_str const *)(1+ lc))->offset + + (char const *)lc; + int const fdi = open(dyld_name, O_RDONLY, 0); + if (0 > fdi) { + err_exit(18); + } +fat: + if ((ssize_t)sz_mhdr!=pread(fdi, (void *)mhdr, sz_mhdr, fat_offset)) { +ERR_LAB + err_exit(19); + } + switch (mhdr->magic) { + case MH_MAGIC: break; + case MH_MAGIC64: break; + case FAT_CIGAM: + case FAT_MAGIC: { + // stupid Apple: waste code and a page fault on EVERY execve + Fat_header *const fh = (Fat_header *)mhdr; + Fat_arch *fa = (Fat_arch *)(1+ fh); + bswap(fh, sizeof(*fh) + (fh->nfat_arch>>24)*sizeof(*fa)); + for (j= 0; j < fh->nfat_arch; ++j, ++fa) { + if (CPU_TYPE_AMD64==fa->cputype) { + fat_offset= fa->offset; + goto fat; + } + } + } break; + } // switch + entry = do_xmap(mhdr, fat_offset, 0, fdi, 0, 0, 0); + close(fdi); + break; + } + } + + return entry; +} + +f_expand *f_exp; +f_unfilter *f_unf; +void (*launch)(void const *, Mach_header64 **); + +// Build on Mac OS X: +// gcc -o amd64-darwin.macho-upxmain.exe \ +// -fPIC amd64-darwin.macho-upxmain.c -Wl,-pagezero_size,0xffff0000 +int +main(int argc, char *argv[]) +{ + Mach_header64 *mhdrp; + unsigned long const base = 0xffff0000ul; + size_t const len = *(size_t *)(base - sizeof(size_t)); + void const *const ptr = (void const *)(base - len); + char mhdr[2048]; + void const *entry = upx_main((struct l_info const *)ptr, len, + (Mach_header64 *)&mhdr, sizeof(mhdr), + f_exp, f_unf, &mhdrp); + launch(entry, &mhdrp); + return 0; +} + +/* +vi:ts=4:et:nowrap +*/