DPRINTF for amd64

modified:   Makefile
	modified:   src/amd64-linux.elf-fold.S
	modified:   src/amd64-linux.elf-main.c

	modified:   amd64-linux.elf-fold.h
	modified:   tmp/amd64-linux.elf-fold.map
This commit is contained in:
John Reiser
2017-05-05 13:32:42 -07:00
parent fe4a8f33b1
commit 6e2a41cb26
5 changed files with 360 additions and 139 deletions
+1 -1
View File
@@ -342,7 +342,7 @@ tmp/amd64-darwin.macho-main.o : $(srcdir)/src/$$T.c
amd64-linux.elf%.h : tc_list = amd64-linux.elf default amd64-linux.elf%.h : tc_list = amd64-linux.elf default
amd64-linux.elf%.h : tc_bfdname = elf64-x86-64 amd64-linux.elf%.h : tc_bfdname = elf64-x86-64
tc.amd64-linux.elf.gcc = amd64-linux-gcc-3.4.4 -m64 -nostdinc -MMD -MT $@ tc.amd64-linux.elf.gcc = amd64-linux-gcc-3.4.4 -fPIC -m64 -nostdinc -MMD -MT $@
tc.amd64-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables tc.amd64-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
tc.amd64-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wstrict-prototypes -Wwrite-strings -Werror tc.amd64-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wstrict-prototypes -Wwrite-strings -Werror
+104 -102
View File
@@ -1,5 +1,5 @@
/* amd64-linux.elf-fold.h /* amd64-linux.elf-fold.h
created from amd64-linux.elf-fold.bin, 2032 (0x7f0) bytes created from amd64-linux.elf-fold.bin, 2059 (0x80b) bytes
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
@@ -31,20 +31,20 @@
*/ */
#define STUB_AMD64_LINUX_ELF_FOLD_SIZE 2032 #define STUB_AMD64_LINUX_ELF_FOLD_SIZE 2059
#define STUB_AMD64_LINUX_ELF_FOLD_ADLER32 0x06e1065d #define STUB_AMD64_LINUX_ELF_FOLD_ADLER32 0xee600f10
#define STUB_AMD64_LINUX_ELF_FOLD_CRC32 0xc66d4cda #define STUB_AMD64_LINUX_ELF_FOLD_CRC32 0xd07b6c06
unsigned char stub_amd64_linux_elf_fold[2032] = { unsigned char stub_amd64_linux_elf_fold[2059] = {
/* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0010 */ 2, 0, 62, 0, 1, 0, 0, 0,188, 0, 16, 0, 0, 0, 0, 0, /* 0x0010 */ 2, 0, 62, 0, 1, 0, 0, 0,188, 0, 16, 0, 0, 0, 0, 0,
/* 0x0020 */ 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0020 */ 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0030 */ 0, 0, 0, 0, 64, 0, 56, 0, 2, 0, 0, 0, 0, 0, 0, 0, /* 0x0030 */ 0, 0, 0, 0, 64, 0, 56, 0, 2, 0, 0, 0, 0, 0, 0, 0,
/* 0x0040 */ 1, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0040 */ 1, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0050 */ 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, /* 0x0050 */ 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0,
/* 0x0060 */ 240, 7, 0, 0, 0, 0, 0, 0,240, 7, 0, 0, 0, 0, 0, 0, /* 0x0060 */ 11, 8, 0, 0, 0, 0, 0, 0, 12, 8, 0, 0, 0, 0, 0, 0,
/* 0x0070 */ 0, 0, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, /* 0x0070 */ 0, 0, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
/* 0x0080 */ 240, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0080 */ 11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0090 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0090 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x00a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, /* 0x00a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0,
/* 0x00b0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,232, 89, 0, 0, /* 0x00b0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,232, 89, 0, 0,
@@ -68,99 +68,101 @@ unsigned char stub_amd64_linux_elf_fold[2032] = {
/* 0x01d0 */ 126,248, 76,137,249, 72, 41,225, 72,193,233, 3,243, 72,165, 72, /* 0x01d0 */ 126,248, 76,137,249, 72, 41,225, 72,193,233, 3,243, 72,165, 72,
/* 0x01e0 */ 141,103, 8,252, 75,141, 12, 38, 65, 89, 94, 95, 72,139, 68, 36, /* 0x01e0 */ 141,103, 8,252, 75,141, 12, 38, 65, 89, 94, 95, 72,139, 68, 36,
/* 0x01f0 */ 16, 72,129,236, 0, 8, 0, 0, 72,137,226, 73,137,232, 80,232, /* 0x01f0 */ 16, 72,129,236, 0, 8, 0, 0, 72,137,226, 73,137,232, 80,232,
/* 0x0200 */ 90, 4, 0, 0, 90, 72,129,196, 0, 8, 0, 0, 94, 95, 89, 80, /* 0x0200 */ 94, 4, 0, 0, 90, 72,129,196, 0, 8, 0, 0, 94, 95, 89, 80,
/* 0x0210 */ 106, 11, 88, 65,255,102,248,176, 11,235, 13,176, 10,235, 9,176, /* 0x0210 */ 106, 11, 88, 65,255,102,248,176, 9, 73,137,202, 15,182,192, 15,
/* 0x0220 */ 12,235, 5,176, 9, 73,137,202, 15,182,192, 15, 5, 72, 61, 0, /* 0x0220 */ 5, 72, 61, 0,240,255,255,114, 4, 72,131,200,255,195,176, 60,
/* 0x0230 */ 240,255,255,114, 4, 72,131,200,255,195,176, 0,235,234,176, 2, /* 0x0230 */ 235, 2,176, 12,235, 2,176, 3,235, 2,176, 2,235, 2,176, 11,
/* 0x0240 */ 235,230,176, 3,235,226,176, 60,235,222, 0, 0, 81, 72, 57, 23, /* 0x0240 */ 235, 2,176, 10,235, 2,176, 1,235, 2,176, 0,235,206, 0, 0,
/* 0x0250 */ 76,139, 71, 8, 72,141, 74,255,115, 10,191,127, 0, 0, 0,232, /* 0x0250 */ 81, 72, 57, 23, 76,139, 71, 8, 72,141, 74,255,115, 10,191,127,
/* 0x0260 */ 226,255,255,255, 72,131,249,255,116, 17, 65, 15,182, 0, 72,255, /* 0x0260 */ 0, 0, 0,232,198,255,255,255, 72,131,249,255,116, 17, 65, 15,
/* 0x0270 */ 201, 73,255,192,136, 6, 72,255,198,235,233, 72, 1, 87, 8, 72, /* 0x0270 */ 182, 0, 72,255,201, 73,255,192,136, 6, 72,255,198,235,233, 72,
/* 0x0280 */ 41, 23, 88,195, 65, 85, 73,137,213, 65, 84, 73,137,204, 85, 72, /* 0x0280 */ 1, 87, 8, 72, 41, 23, 88,195, 65, 85, 73,137,213, 65, 84, 73,
/* 0x0290 */ 137,253, 83, 72,137,243, 72,131,236, 40, 72,131, 62, 0, 15,132, /* 0x0290 */ 137,204, 85, 72,137,253, 83, 72,137,243, 72,131,236, 40, 72,131,
/* 0x02a0 */ 226, 0, 0, 0, 72,141,116, 36, 16,186, 12, 0, 0, 0, 72,137, /* 0x02a0 */ 62, 0, 15,132,226, 0, 0, 0, 72,141,116, 36, 16,186, 12, 0,
/* 0x02b0 */ 239,232,150,255,255,255,139, 84, 36, 16,139,116, 36, 20,133,210, /* 0x02b0 */ 0, 0, 72,137,239,232,150,255,255,255,139, 84, 36, 16,139,116,
/* 0x02c0 */ 117, 21,129,254, 85, 80, 88, 33,117, 17, 72,131,125, 0, 0, 15, /* 0x02c0 */ 36, 20,133,210,117, 21,129,254, 85, 80, 88, 33,117, 17, 72,131,
/* 0x02d0 */ 132,177, 0, 0, 0,235, 4,133,246,117, 10,191,127, 0, 0, 0, /* 0x02d0 */ 125, 0, 0, 15,132,177, 0, 0, 0,235, 4,133,246,117, 10,191,
/* 0x02e0 */ 232, 97,255,255,255, 57,214,119,242,137,208, 72, 59, 3,119,235, /* 0x02e0 */ 127, 0, 0, 0,232, 69,255,255,255, 57,214,119,242,137,208, 72,
/* 0x02f0 */ 57,214, 72,139, 67, 8,115,104,137, 84, 36, 12, 72,139,125, 8, /* 0x02f0 */ 59, 3,119,235, 57,214, 72,139, 67, 8,115,104,137, 84, 36, 12,
/* 0x0300 */ 72,141, 76, 36, 12, 68,139, 68, 36, 24, 72,137,194, 65,255,213, /* 0x0300 */ 72,139,125, 8, 72,141, 76, 36, 12, 68,139, 68, 36, 24, 72,137,
/* 0x0310 */ 133,192,117,199,139,116, 36, 12, 59,116, 36, 16,117,189, 15,182, /* 0x0310 */ 194, 65,255,213,133,192,117,199,139,116, 36, 12, 59,116, 36, 16,
/* 0x0320 */ 76, 36, 25,132,201, 15,149,194, 49,192, 77,133,228, 15,149,192, /* 0x0320 */ 117,189, 15,182, 76, 36, 25,132,201, 15,149,194, 49,192, 77,133,
/* 0x0330 */ 133,194,116, 30,129,254, 0, 2, 0, 0,119, 7,137,240, 72, 57, /* 0x0330 */ 228, 15,149,192,133,194,116, 30,129,254, 0, 2, 0, 0,119, 7,
/* 0x0340 */ 3,117, 15, 15,182, 84, 36, 26, 15,182,201, 72,139,123, 8, 65, /* 0x0340 */ 137,240, 72, 57, 3,117, 15, 15,182, 84, 36, 26, 15,182,201, 72,
/* 0x0350 */ 255,212,139, 68, 36, 20, 72, 1, 69, 8, 72, 41, 69, 0,235, 13, /* 0x0350 */ 139,123, 8, 65,255,212,139, 68, 36, 20, 72, 1, 69, 8, 72, 41,
/* 0x0360 */ 137,242, 72,137,239, 72,137,198,232,223,254,255,255,139, 84, 36, /* 0x0360 */ 69, 0,235, 13,137,242, 72,137,239, 72,137,198,232,223,254,255,
/* 0x0370 */ 16, 72,139, 3, 72, 1, 83, 8, 72, 41,208, 72,133,192, 72,137, /* 0x0370 */ 255,139, 84, 36, 16, 72,139, 3, 72, 1, 83, 8, 72, 41,208, 72,
/* 0x0380 */ 3,233, 24,255,255,255, 72,131,196, 40, 91, 93, 65, 92, 65, 93, /* 0x0380 */ 133,192, 72,137, 3,233, 24,255,255,255, 72,131,196, 40, 91, 93,
/* 0x0390 */ 195, 72,133,255, 73,137,208,116, 41, 72,139, 7,137,241, 72, 57, /* 0x0390 */ 65, 92, 65, 93,195, 72,133,255, 73,137,208,116, 41, 72,139, 7,
/* 0x03a0 */ 200,116, 17, 72,255,200, 15,148,194, 49,192,133,246, 15,149,192, /* 0x03a0 */ 137,241, 72, 57,200,116, 17, 72,255,200, 15,148,194, 49,192,133,
/* 0x03b0 */ 133,194,116, 8, 72,137, 15, 76,137, 71, 8,195, 72,131,199, 16, /* 0x03b0 */ 246, 15,149,192,133,194,116, 8, 72,137, 15, 76,137, 71, 8,195,
/* 0x03c0 */ 235,215,195, 65, 87,184, 0, 0, 0, 0, 73,137,255, 65, 86, 65, /* 0x03c0 */ 72,131,199, 16,235,215,195, 65, 87,184, 0, 0, 0, 0, 73,137,
/* 0x03d0 */ 85, 65, 84, 73,137,252, 85, 83, 72,131,236,104, 76, 3,103, 32, /* 0x03d0 */ 255, 65, 86, 65, 85, 65, 84, 73,137,252, 85, 83, 72,131,236,104,
/* 0x03e0 */ 102,131,127, 16, 3,137, 84, 36, 60, 15,183, 87, 56, 72,137, 76, /* 0x03e0 */ 76, 3,103, 32,102,131,127, 16, 3,137, 84, 36, 60, 15,183, 87,
/* 0x03f0 */ 36, 48,185, 16, 0, 0, 0, 72,137,116, 36, 64, 76,137, 68, 36, /* 0x03f0 */ 56, 72,137, 76, 36, 48,185, 16, 0, 0, 0, 72,137,116, 36, 64,
/* 0x0400 */ 40, 76,137, 76, 36, 32, 15, 68,200, 76,137,230, 72,131,205,255, /* 0x0400 */ 76,137, 68, 36, 40, 76,137, 76, 36, 32, 15, 68,200, 76,137,230,
/* 0x0410 */ 49,219,131,193, 34,255,202,120, 33,131, 62, 1,117, 22, 72,139, /* 0x0410 */ 72,131,205,255, 49,219,131,193, 34,255,202,120, 33,131, 62, 1,
/* 0x0420 */ 70, 16, 72, 57,232, 72, 15, 66,232, 72, 3, 70, 40, 72, 57,195, /* 0x0420 */ 117, 22, 72,139, 70, 16, 72, 57,232, 72, 15, 66,232, 72, 3, 70,
/* 0x0430 */ 72, 15, 66,216, 72,131,198, 56,235,219, 72,129,229, 0,240,255, /* 0x0430 */ 40, 72, 57,195, 72, 15, 66,216, 72,131,198, 56,235,219, 72,129,
/* 0x0440 */ 255, 49,210, 69, 49,201, 72, 41,235, 65,131,200,255, 72,137,239, /* 0x0440 */ 229, 0,240,255,255, 49,210, 69, 49,201, 72, 41,235, 65,131,200,
/* 0x0450 */ 72,129,195,255, 15, 0, 0, 72,129,227, 0,240,255,255, 72,137, /* 0x0450 */ 255, 72,137,239, 72,129,195,255, 15, 0, 0, 72,129,227, 0,240,
/* 0x0460 */ 222,232,189,253,255,255, 72,141, 20, 24, 72, 41,232,102, 65,131, /* 0x0460 */ 255,255, 72,137,222,232,173,253,255,255, 72,141, 20, 24, 72, 41,
/* 0x0470 */ 127, 56, 0, 72,137, 68, 36, 24,199, 68, 36, 20, 0, 0, 0, 0, /* 0x0470 */ 232,102, 65,131,127, 56, 0, 72,137, 68, 36, 24,199, 68, 36, 20,
/* 0x0480 */ 72,137, 84, 36, 72, 15,132,155, 1, 0, 0, 72,131,124, 36, 64, /* 0x0480 */ 0, 0, 0, 0, 72,137, 84, 36, 72, 15,132,155, 1, 0, 0, 72,
/* 0x0490 */ 0,116, 37, 65,131, 60, 36, 6,117, 30, 72,139, 84, 36, 24, 73, /* 0x0490 */ 131,124, 36, 64, 0,116, 37, 65,131, 60, 36, 6,117, 30, 72,139,
/* 0x04a0 */ 3, 84, 36, 16,190, 3, 0, 0, 0, 72,139,124, 36, 48,232,222, /* 0x04a0 */ 84, 36, 24, 73, 3, 84, 36, 16,190, 3, 0, 0, 0, 72,139,124,
/* 0x04b0 */ 254,255,255,233, 87, 1, 0, 0, 65,131, 60, 36, 1, 15,133, 76, /* 0x04b0 */ 36, 48,232,222,254,255,255,233, 87, 1, 0, 0, 65,131, 60, 36,
/* 0x04c0 */ 1, 0, 0, 72,139, 68, 36, 24, 73, 3, 68, 36, 16, 65,190, 64, /* 0x04c0 */ 1, 15,133, 76, 1, 0, 0, 72,139, 68, 36, 24, 73, 3, 68, 36,
/* 0x04d0 */ 98, 81,115, 65,139, 76, 36, 4, 65,131,200,255, 73,139, 84, 36, /* 0x04d0 */ 16, 65,190, 64, 98, 81,115, 65,139, 76, 36, 4, 65,131,200,255,
/* 0x04e0 */ 32, 72,137,197, 72,137, 68, 36, 88, 73,139, 68, 36, 40,131,225, /* 0x04e0 */ 73,139, 84, 36, 32, 72,137,197, 72,137, 68, 36, 88, 73,139, 68,
/* 0x04f0 */ 7, 72,137,235, 72,137, 84, 36, 80,193,225, 2,129,227,255, 15, /* 0x04f0 */ 36, 40,131,225, 7, 72,137,235, 72,137, 84, 36, 80,193,225, 2,
/* 0x0500 */ 0, 0, 72, 1,232, 65,211,238, 72, 41,221, 72,137, 68, 36, 8, /* 0x0500 */ 129,227,255, 15, 0, 0, 72, 1,232, 65,211,238, 72, 41,221, 72,
/* 0x0510 */ 73,139, 68, 36, 8, 65,131,230, 7, 76,141, 44, 26,185, 50, 0, /* 0x0510 */ 137, 68, 36, 8, 73,139, 68, 36, 8, 65,131,230, 7, 76,141, 44,
/* 0x0520 */ 0, 0, 72, 41,216, 72,131,124, 36, 64, 0,117, 7, 68,139, 68, /* 0x0520 */ 26,185, 50, 0, 0, 0, 72, 41,216, 72,131,124, 36, 64, 0,117,
/* 0x0530 */ 36, 60,177, 18, 68,137,242, 73,137,193, 76,137,238,131,202, 2, /* 0x0530 */ 7, 68,139, 68, 36, 60,177, 18, 68,137,242, 73,137,193, 76,137,
/* 0x0540 */ 72,131,124, 36, 64, 0, 72,137,239, 65, 15, 68,214,232,209,252, /* 0x0540 */ 238,131,202, 2, 72,131,124, 36, 64, 0, 72,137,239, 65, 15, 68,
/* 0x0550 */ 255,255, 72, 57,197,117,121, 72,131,124, 36, 64, 0,116, 25, 72, /* 0x0550 */ 214,232,193,252,255,255, 72, 57,197,117,121, 72,131,124, 36, 64,
/* 0x0560 */ 139, 76, 36, 32, 72,139, 84, 36, 40, 72,141,116, 36, 80, 72,139, /* 0x0560 */ 0,116, 25, 72,139, 76, 36, 32, 72,139, 84, 36, 40, 72,141,116,
/* 0x0570 */ 124, 36, 64,232, 12,253,255,255, 76,137,235, 72,247,219,129,227, /* 0x0570 */ 36, 80, 72,139,124, 36, 64,232, 12,253,255,255, 76,137,235, 72,
/* 0x0580 */ 255, 15, 0, 0, 65,246,198, 2,116, 13, 74,141,124, 45, 0, 49, /* 0x0580 */ 247,219,129,227,255, 15, 0, 0, 65,246,198, 2,116, 13, 74,141,
/* 0x0590 */ 192, 72,137,217,252,243,170, 72,131,124, 36, 64, 0,116, 59, 73, /* 0x0590 */ 124, 45, 0, 49,192, 72,137,217,252,243,170, 72,131,124, 36, 64,
/* 0x05a0 */ 131,124, 36, 8, 0,117, 23, 72,139,124, 36, 48, 72,141, 85, 12, /* 0x05a0 */ 0,116, 59, 73,131,124, 36, 8, 0,117, 23, 72,139,124, 36, 48,
/* 0x05b0 */ 199, 69, 12, 15, 5,195,144, 49,246,232,211,253,255,255, 68,137, /* 0x05b0 */ 72,141, 85, 12,199, 69, 12, 15, 5,195,144, 49,246,232,211,253,
/* 0x05c0 */ 242, 76,137,238, 72,137,239,232, 79,252,255,255,133,192,116, 10, /* 0x05c0 */ 255,255, 68,137,242, 76,137,238, 72,137,239,232,114,252,255,255,
/* 0x05d0 */ 191,127, 0, 0, 0,232,108,252,255,255, 73,141, 68, 29, 0, 72, /* 0x05d0 */ 133,192,116, 10,191,127, 0, 0, 0,232, 80,252,255,255, 73,141,
/* 0x05e0 */ 1,197, 72, 59,108, 36, 8,115, 38, 72, 41,108, 36, 8, 69, 49, /* 0x05e0 */ 68, 29, 0, 72, 1,197, 72, 59,108, 36, 8,115, 38, 72, 41,108,
/* 0x05f0 */ 201, 65,131,200,255, 72,139,116, 36, 8,185, 50, 0, 0, 0, 68, /* 0x05f0 */ 36, 8, 69, 49,201, 65,131,200,255, 72,139,116, 36, 8,185, 50,
/* 0x0600 */ 137,242, 72,137,239,232, 25,252,255,255, 72, 57,197,117,193,255, /* 0x0600 */ 0, 0, 0, 68,137,242, 72,137,239,232, 9,252,255,255, 72, 57,
/* 0x0610 */ 68, 36, 20, 65, 15,183, 71, 56, 73,131,196, 56, 57, 68, 36, 20, /* 0x0610 */ 197,117,193,255, 68, 36, 20, 65, 15,183, 71, 56, 73,131,196, 56,
/* 0x0620 */ 15,140,101,254,255,255, 72,131,188, 36,160, 0, 0, 0, 0,116, /* 0x0620 */ 57, 68, 36, 20, 15,140,101,254,255,255, 72,131,188, 36,160, 0,
/* 0x0630 */ 16, 72,139, 68, 36, 24, 72,139,148, 36,160, 0, 0, 0, 72,137, /* 0x0630 */ 0, 0, 0,116, 16, 72,139, 68, 36, 24, 72,139,148, 36,160, 0,
/* 0x0640 */ 2, 73,139, 87, 24, 72, 1, 84, 36, 24, 72,139, 68, 36, 24, 72, /* 0x0640 */ 0, 0, 72,137, 2, 73,139, 87, 24, 72, 1, 84, 36, 24, 72,139,
/* 0x0650 */ 131,196,104, 91, 93, 65, 92, 65, 93, 65, 94, 65, 95,195, 65, 87, /* 0x0650 */ 68, 36, 24, 72,131,196,104, 91, 93, 65, 92, 65, 93, 65, 94, 65,
/* 0x0660 */ 77,137,207, 65, 86, 65, 85, 77,137,197, 65, 84, 73,137,212, 85, /* 0x0660 */ 95,195, 65, 87, 77,137,207, 65, 86, 73,137,206, 49,201, 65, 85,
/* 0x0670 */ 72,141,106, 64, 83, 72,137,203, 49,201, 72,131,236, 56,139, 7, /* 0x0670 */ 77,137,197, 65, 84, 85, 72,137,213, 83, 72,141, 90, 64, 72,131,
/* 0x0680 */ 72,137, 52, 36, 72,137,116, 36, 16, 72,141,116, 36, 32, 72,137, /* 0x0680 */ 236, 56,139, 7, 72,137, 52, 36, 72,137,116, 36, 16, 72,141,116,
/* 0x0690 */ 84, 36, 40, 72,137,124, 36, 8, 76,137,194, 72,137,124, 36, 24, /* 0x0690 */ 36, 32, 72,137, 84, 36, 40, 72,137,124, 36, 8, 76,137,194, 72,
/* 0x06a0 */ 72,137,231, 72,137, 68, 36, 32,232,215,251,255,255, 72,139, 85, /* 0x06a0 */ 137,124, 36, 24, 72,137,231, 72,137, 68, 36, 32,232,215,251,255,
/* 0x06b0 */ 16,190, 3, 0, 0, 0, 72,137,223,232,211,252,255,255, 73, 15, /* 0x06b0 */ 255, 72,139, 83, 16,190, 3, 0, 0, 0, 76,137,247,232,211,252,
/* 0x06c0 */ 183, 84, 36, 56,190, 5, 0, 0, 0, 72,137,223,232,192,252,255, /* 0x06c0 */ 255,255, 72, 15,183, 85, 56,190, 5, 0, 0, 0, 76,137,247,232,
/* 0x06d0 */ 255, 69, 15,183,116, 36, 16, 65,131,254, 3,117, 62, 72,139, 84, /* 0x06d0 */ 193,252,255,255, 68, 15,183,101, 16, 65,131,252, 3,117, 57, 72,
/* 0x06e0 */ 36,112, 73, 3, 84, 36, 24,190, 9, 0, 0, 0,102, 65,199, 68, /* 0x06e0 */ 139, 84, 36,112, 72, 3, 85, 24,190, 9, 0, 0, 0,102,199, 69,
/* 0x06f0 */ 36, 16, 2, 0, 72,137,223,232,149,252,255,255, 65, 15,183, 68, /* 0x06f0 */ 16, 2, 0, 76,137,247,232,154,252,255,255, 15,183, 69, 56,133,
/* 0x0700 */ 36, 56,133,192,116, 21, 72,139, 84, 36,112, 72, 1, 85, 16, 72, /* 0x0700 */ 192,116, 21, 72,139, 84, 36,112, 72, 1, 83, 16, 72, 1, 83, 24,
/* 0x0710 */ 1, 85, 24, 72,131,197, 56,255,200,117,240, 65, 83, 77,137,249, /* 0x0710 */ 72,131,195, 56,255,200,117,240, 65, 83, 77,137,249, 77,137,232,
/* 0x0720 */ 77,137,232, 49,210, 72,137,217, 72,141, 68, 36,120, 72,141,116, /* 0x0720 */ 49,210, 76,137,241, 72,141, 68, 36,120, 72,141,116, 36, 24, 72,
/* 0x0730 */ 36, 24, 76,137,231, 80,232,136,252,255,255, 65, 89, 65,131,254, /* 0x0730 */ 137,239, 80,232,143,252,255,255, 65, 89, 65,131,252, 3, 73,137,
/* 0x0740 */ 3, 73,137,197, 65, 90,116, 16, 72,137,194,190, 9, 0, 0, 0, /* 0x0740 */ 197, 65, 90,116, 16, 72,137,194,190, 9, 0, 0, 0, 76,137,247,
/* 0x0750 */ 72,137,223,232, 57,252,255,255, 69, 49,246,102, 65,131,124, 36, /* 0x0750 */ 232, 64,252,255,255, 69, 49,255,102,131,125, 56, 0, 72,141, 93,
/* 0x0760 */ 56, 0, 73,141,108, 36, 64,116,117,131,125, 0, 3,117, 93, 72, /* 0x0760 */ 64, 15,132,146, 0, 0, 0,131, 59, 3,117,121, 72,139,124, 36,
/* 0x0770 */ 139,124, 36,112, 72, 3,125, 16, 49,210, 49,246,232,189,250,255, /* 0x0770 */ 112, 72, 3,123, 16, 49,210, 49,246,232,188,250,255,255,133,192,
/* 0x0780 */ 255,133,192,137,195,120, 23,186, 0, 4, 0, 0, 76,137,230,137, /* 0x0780 */ 65,137,196,120, 23,186, 0, 4, 0, 0, 72,137,238,137,199,232,
/* 0x0790 */ 199,232,164,250,255,255, 72, 61, 0, 4, 0, 0,116, 10,191,127, /* 0x0790 */ 182,250,255,255, 72, 61, 0, 4, 0, 0,116, 10,191,127, 0, 0,
/* 0x07a0 */ 0, 0, 0,232,158,250,255,255, 65, 80, 49,246, 69, 49,201, 69, /* 0x07a0 */ 0,232,136,250,255,255, 65, 80, 69, 49,201, 69, 49,192, 49,201,
/* 0x07b0 */ 49,192, 49,201,106, 0,137,218, 76,137,231,232, 3,252,255,255, /* 0x07b0 */ 68,137,226, 72,141, 68, 36,120, 49,246, 72,137,239, 80,232, 4,
/* 0x07c0 */ 137,223, 73,137,197,232,120,250,255,255, 94, 95, 65, 15,183, 68, /* 0x07c0 */ 252,255,255, 72,139,148, 36,128, 0, 0, 0,190, 7, 0, 0, 0,
/* 0x07d0 */ 36, 56, 65,255,198, 72,131,197, 56, 65, 57,198,114,139, 72,131, /* 0x07d0 */ 76,137,247, 73,137,197,232,186,251,255,255, 68,137,231,232, 83,
/* 0x07e0 */ 196, 56, 76,137,232, 91, 93, 65, 92, 65, 93, 65, 94, 65, 95,195 /* 0x07e0 */ 250,255,255, 94, 95, 15,183, 69, 56, 65,255,199, 72,131,195, 56,
/* 0x07f0 */ 65, 57,199, 15,130,110,255,255,255, 72,131,196, 56, 76,137,232,
/* 0x0800 */ 91, 93, 65, 92, 65, 93, 65, 94, 65, 95,195
}; };
+17 -15
View File
@@ -54,6 +54,7 @@ MAX_ELF_HDR=1024
/* 64-bit mode only! */ /* 64-bit mode only! */
__NR_read= 0 __NR_read= 0
__NR_write= 1
__NR_open= 2 __NR_open= 2
__NR_close= 3 __NR_close= 3
@@ -71,6 +72,7 @@ __NR_readlink= 89
%rsp= &{LENX,ADRX,LENU,ADRU,slide,argc,argv...,0,env...,0,auxv...,0...,strings} %rsp= &{LENX,ADRX,LENU,ADRU,slide,argc,argv...,0,env...,0,auxv...,0...,strings}
*/ */
fold_begin: fold_begin:
//// int3 // DEBUG only
call L90 # push &L90a call L90 # push &L90a
L90a: L90a:
.asciz "/proc/self/exe" .asciz "/proc/self/exe"
@@ -166,13 +168,6 @@ L90:
push $ __NR_munmap; pop %rax push $ __NR_munmap; pop %rax
jmp *-8(%r14) # goto: syscall; ret jmp *-8(%r14) # goto: syscall; ret
munmap: .globl munmap
movb $ __NR_munmap,%al; jmp sysgo
mprotect: .globl mprotect
movb $ __NR_mprotect,%al; jmp sysgo
brk: .globl brk
movb $ __NR_brk,%al; jmp sysgo
mmap: .globl mmap mmap: .globl mmap
movb $ __NR_mmap,%al movb $ __NR_mmap,%al
sysarg4: sysarg4:
@@ -185,14 +180,21 @@ sysgo: # NOTE: kernel demands 4th arg in %sys4, NOT %arg4
no_fail: no_fail:
ret ret
read: .globl read
movb $ __NR_read,%al; jmp sysgo
open: .globl open
movb $ __NR_open,%al; jmp sysgo
close: .globl close
movb $ __NR_close,%al; jmp sysgo
exit: .globl exit exit: .globl exit
movb $ __NR_exit,%al; jmp sysgo movb $ __NR_exit,%al; 5: jmp 5f
brk: .globl brk
movb $ __NR_brk,%al; 5: jmp 5f
close: .globl close
movb $ __NR_close,%al; 5: jmp 5f
open: .globl open
movb $ __NR_open,%al; 5: jmp 5f
munmap: .globl munmap
movb $ __NR_munmap,%al; 5: jmp 5f
mprotect: .globl mprotect
movb $ __NR_mprotect,%al; 5: jmp 5f
write: .globl write
mov $__NR_write,%al; 5: jmp 5f
read: .globl read
movb $ __NR_read,%al; 5: jmp sysgo
/* vim:set ts=8 sw=8 et: */ /* vim:set ts=8 sw=8 et: */
+217 -2
View File
@@ -32,6 +32,41 @@
#include "include/linux.h" #include "include/linux.h"
#ifndef DEBUG //{
#define DEBUG 0
#endif //}
#if !DEBUG //{
#define DPRINTF(fmt, args...) /*empty*/
#else //}{
// DPRINTF is defined as an expression using "({ ... })"
// so that DPRINTF can be invoked inside an expression,
// and then followed by a comma to ignore the return value.
// The only complication is that percent and backslash
// must be doubled in the format string, because the format
// string is processd twice: once at compile-time by 'asm'
// to produce the assembled value, and once at runtime to use it.
#if defined(__powerpc__) //{
#define DPRINTF(fmt, args...) ({ \
char const *r_fmt; \
asm("bl 0f; .string \"" fmt "\"; .balign 4; 0: mflr %0" \
/*out*/ : "=r"(r_fmt) \
/* in*/ : \
/*und*/ : "lr"); \
dprintf(r_fmt, args); \
})
#elif defined(__x86_64) //{
#define DPRINTF(fmt, args...) ({ \
char const *r_fmt; \
asm("call 0f; .asciz \"" fmt "\"; 0: pop %0" \
/*out*/ : "=r"(r_fmt) ); \
dprintf(r_fmt, args); \
})
#endif //}
static int dprintf(char const *fmt, ...); // forward
#endif /*}*/
/************************************************************************* /*************************************************************************
// configuration section // configuration section
@@ -176,8 +211,11 @@ upx_bzero(char *p, size_t len)
static void static void
auxv_up(Elf64_auxv_t *av, unsigned const type, uint64_t const value) auxv_up(Elf64_auxv_t *av, unsigned const type, uint64_t const value)
{ {
if (av) if (!av)
return;
DPRINTF("\\nauxv_up %%d %%p\\n", type, value);
for (;; ++av) { for (;; ++av) {
DPRINTF(" %%d %%p\\n", av->a_type, av->a_un.a_val);
if (av->a_type==type || (av->a_type==AT_IGNORE && type!=AT_NULL)) { if (av->a_type==type || (av->a_type==AT_IGNORE && type!=AT_NULL)) {
av->a_type = type; av->a_type = type;
av->a_un.a_val = value; av->a_un.a_val = value;
@@ -373,7 +411,8 @@ upx_main( // returns entry address
ERR_LAB ERR_LAB
err_exit(19); err_exit(19);
} }
entry = do_xmap(ehdr, 0, fdi, 0, 0, 0, 0); entry = do_xmap(ehdr, 0, fdi, 0, 0, 0, &reloc);
auxv_up(av, AT_BASE, reloc);
close(fdi); close(fdi);
} }
} }
@@ -381,4 +420,180 @@ ERR_LAB
return (void *)entry; return (void *)entry;
} }
#if DEBUG //{
#if defined(__powerpc64__) //{
#define __NR_write 4
typedef unsigned long size_t;
#if 0 //{
static int
write(int fd, char const *ptr, size_t len)
{
register int sys asm("r0") = __NR_write;
register int a0 asm("r3") = fd;
register void const *a1 asm("r4") = ptr;
register size_t const a2 asm("r5") = len;
__asm__ __volatile__("sc"
: "=r"(a0)
: "r"(sys), "r"(a0), "r"(a1), "r"(a2)
: "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13"
);
return a0;
}
#else //}{
static int
write(int fd, char const *ptr, size_t len)
{
register int sys asm("r0") = __NR_write;
register int a0 asm("r3") = fd;
register void const *a1 asm("r4") = ptr;
register size_t a2 asm("r5") = len;
__asm__ __volatile__("sc"
: "+r"(sys), "+r"(a0), "+r"(a1), "+r"(a2)
:
: "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13"
);
return a0;
}
#endif //}
#endif //}
#if defined(__i386__) /*{*/
#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" \
)
#elif defined(__powerpc__) || defined(__powerpc64__) /*}{*/
#define PIC_STRING(value,var) \
__asm__ ( \
"bl 0f; .asciz \"" value "\"; .balign 4; \
0: mflr %0" \
: "=r"(var) : \
)
#endif /*}*/
static int
unsimal(unsigned x, char *ptr, int n)
{
unsigned m = 10;
while (10 <= (x / m)) m *= 10;
while (10 <= x) {
unsigned d = x / m;
x -= m * d;
m /= 10;
ptr[n++] = '0' + d;
}
ptr[n++] = '0' + x;
return n;
}
static int
decimal(int x, char *ptr, int n)
{
if (x < 0) {
x = -x;
ptr[n++] = '-';
}
return unsimal(x, ptr, n);
}
static int
heximal(unsigned long x, char *ptr, int n)
{
unsigned j = -1+ 2*sizeof(unsigned long);
unsigned long m = 0xful << (4 * j);
for (; j; --j, m >>= 4) { // omit leading 0 digits
if (m & x) break;
}
for (; m; --j, m >>= 4) {
unsigned d = 0xf & (x >> (4 * j));
ptr[n++] = ((10<=d) ? ('a' - 10) : '0') + d;
}
return n;
}
#define va_arg __builtin_va_arg
#define va_end __builtin_va_end
#define va_list __builtin_va_list
#define va_start __builtin_va_start
static int
dprintf(char const *fmt, ...)
{
int n= 0;
char const *literal = 0; // NULL
char buf[24]; // ~0ull == 18446744073709551615 ==> 20 chars
va_list va; va_start(va, fmt);
for (;;) {
char c = *fmt++;
if (!c) { // end of fmt
if (literal) {
goto finish;
}
break; // goto done
}
if ('%'!=c) {
if (!literal) {
literal = fmt; // 1 beyond start of literal
}
continue;
}
// '%' == c
if (literal) {
finish:
n += write(2, -1+ literal, fmt - literal);
literal = 0; // NULL
if (!c) { // fmt already ended
break; // goto done
}
}
switch (c= *fmt++) { // deficiency: does not handle _long_
default: { // un-implemented conversion
n+= write(2, -1+ fmt, 1);
} break;
case 0: { // fmt ends with "%\0" ==> ignore
goto done;
} break;
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;
} // 'switch'
}
done:
va_end(va);
return n;
}
#endif //}
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */
+21 -19
View File
@@ -8,31 +8,33 @@ Linker script and memory map
0x00000000001000bc . = ((0x100000 + SIZEOF_HEADERS) + 0xc) 0x00000000001000bc . = ((0x100000 + SIZEOF_HEADERS) + 0xc)
.text 0x00000000001000bc 0x734 .text 0x00000000001000bc 0x750
*(.text) *(.text)
.text 0x00000000001000bc 0x18e tmp/amd64-linux.elf-fold.o .text 0x00000000001000bc 0x192 tmp/amd64-linux.elf-fold.o
0x0000000000100217 munmap 0x000000000010023e munmap
0x0000000000100223 mmap 0x0000000000100217 mmap
0x000000000010023a read 0x0000000000100246 write
0x0000000000100246 exit 0x000000000010024a read
0x000000000010021f brk 0x000000000010022e exit
0x000000000010023e open 0x0000000000100232 brk
0x000000000010021b mprotect 0x000000000010023a open
0x0000000000100242 close 0x0000000000100242 mprotect
*fill* 0x000000000010024a 0x2 00 0x0000000000100236 close
.text 0x000000000010024c 0x5a4 tmp/amd64-linux.elf-main.o *fill* 0x000000000010024e 0x2 00
0x000000000010065e upx_main .text 0x0000000000100250 0x5bb tmp/amd64-linux.elf-main.o
0x0000000000100662 upx_main
*(.data) *(.data)
.data 0x00000000001007f0 0x0 tmp/amd64-linux.elf-fold.o *fill* 0x000000000010080b 0x1 00
.data 0x00000000001007f0 0x0 tmp/amd64-linux.elf-main.o .data 0x000000000010080c 0x0 tmp/amd64-linux.elf-fold.o
.data 0x000000000010080c 0x0 tmp/amd64-linux.elf-main.o
.data .data
.bss 0x00000000001007f0 0x0 .bss 0x000000000010080c 0x0
.bss 0x00000000001007f0 0x0 tmp/amd64-linux.elf-fold.o .bss 0x000000000010080c 0x0 tmp/amd64-linux.elf-fold.o
.bss 0x00000000001007f0 0x0 tmp/amd64-linux.elf-main.o .bss 0x000000000010080c 0x0 tmp/amd64-linux.elf-main.o
.rela.dyn 0x00000000001007f0 0x0 .rela.dyn 0x0000000000100810 0x0
.rela.text 0x0000000000000000 0x0 tmp/amd64-linux.elf-fold.o .rela.text 0x0000000000000000 0x0 tmp/amd64-linux.elf-fold.o
LOAD tmp/amd64-linux.elf-fold.o LOAD tmp/amd64-linux.elf-fold.o
LOAD tmp/amd64-linux.elf-main.o LOAD tmp/amd64-linux.elf-main.o