arm64 hacking

modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-main.c

	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/tmp/arm64-linux.elf-fold.map
This commit is contained in:
John Reiser 2017-03-22 16:45:09 -07:00
parent 5d6c4b475c
commit d5d7d8bc84
4 changed files with 207 additions and 165 deletions

View File

@ -1,5 +1,5 @@
/* arm64-linux.elf-fold.h /* arm64-linux.elf-fold.h
created from arm64-linux.elf-fold.bin, 2260 (0x8d4) bytes created from arm64-linux.elf-fold.bin, 2376 (0x948) 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_ARM64_LINUX_ELF_FOLD_SIZE 2260 #define STUB_ARM64_LINUX_ELF_FOLD_SIZE 2376
#define STUB_ARM64_LINUX_ELF_FOLD_ADLER32 0xacc31d97 #define STUB_ARM64_LINUX_ELF_FOLD_ADLER32 0xefec4cd1
#define STUB_ARM64_LINUX_ELF_FOLD_CRC32 0x6fdf50c9 #define STUB_ARM64_LINUX_ELF_FOLD_CRC32 0xdcaca01a
unsigned char stub_arm64_linux_elf_fold[2260] = { unsigned char stub_arm64_linux_elf_fold[2376] = {
/* 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,183, 0, 1, 0, 0, 0,188, 0, 16, 0, 0, 0, 0, 0, /* 0x0010 */ 2, 0,183, 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 */ 212, 8, 0, 0, 0, 0, 0, 0,212, 8, 0, 0, 0, 0, 0, 0, /* 0x0060 */ 72, 9, 0, 0, 0, 0, 0, 0, 72, 9, 0, 0, 0, 0, 0, 0,
/* 0x0070 */ 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, /* 0x0070 */ 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
/* 0x0080 */ 212, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0080 */ 72, 9, 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, 1, 0, 0, 0, 0, 0, /* 0x00a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
/* 0x00b0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,229, 35, 65,169, /* 0x00b0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,229, 35, 65,169,
@ -57,125 +57,132 @@ unsigned char stub_arm64_linux_elf_fold[2260] = {
/* 0x0120 */ 2,132, 0,248,194,255,255,181, 34,132, 64,248, 2,132, 0,248, /* 0x0120 */ 2,132, 0,248,194,255,255,181, 34,132, 64,248, 2,132, 0,248,
/* 0x0130 */ 194,255,255,181, 4, 32, 0,209, 2,132, 0,248,231, 3, 0,170, /* 0x0130 */ 194,255,255,181, 4, 32, 0,209, 2,132, 0,248,231, 3, 0,170,
/* 0x0140 */ 34, 12,193,168, 2, 12,129,168,194,255,255,181,224, 11, 0,249, /* 0x0140 */ 34, 12,193,168, 2, 12,129,168,194,255,255,181,224, 11, 0,249,
/* 0x0150 */ 193, 4, 64,145,129, 0, 0,249, 98, 4, 0, 24, 34, 68, 0,184, /* 0x0150 */ 193, 4, 64,145,129, 0, 0,249, 66, 4, 0, 24, 34, 68, 0,184,
/* 0x0160 */ 226,255,129, 82, 32, 4, 0, 16, 95, 0, 0,148,224, 3, 0, 16, /* 0x0160 */ 226,255,129, 82, 0, 4, 0, 16, 94, 0, 0,148,192, 3, 0, 16,
/* 0x0170 */ 1, 0,128, 82, 83, 0, 0,148,228, 3, 0, 42,224, 3, 6,170, /* 0x0170 */ 1, 0,128, 82, 82, 0, 0,148,228, 3, 0, 42,224, 3, 6,170,
/* 0x0180 */ 5, 0,128,210, 67, 2,128, 82, 34, 0,128, 82, 1, 0,130,210, /* 0x0180 */ 5, 0,128,210, 67, 2,128, 82, 34, 0,128, 82, 1, 0,130,210,
/* 0x0190 */ 73, 0, 0,148,224, 3, 4, 42, 49, 0, 0,148,230, 99, 0,145, /* 0x0190 */ 72, 0, 0,148,224, 3, 4, 42, 48, 0, 0,148,230, 99, 0,145,
/* 0x01a0 */ 255, 3, 40,209,165, 2, 0, 16,228, 3, 15,170,227, 3, 7,170, /* 0x01a0 */ 255, 3, 40,209,133, 2, 0, 16,228, 3, 15,170,227, 3, 7,170,
/* 0x01b0 */ 226, 3, 0,145,225, 3, 9, 42,224, 3, 10,170,113, 1, 0,148, /* 0x01b0 */ 226, 3, 0,145,225, 3, 9, 42,224, 3, 10,170,135, 1, 0,148,
/* 0x01c0 */ 255, 3, 40,145,253, 3, 0,170, 0, 0, 32,212,226, 15, 65,169, /* 0x01c0 */ 255, 3, 40,145,254, 3, 0,170, 0, 0, 32,212,226, 15, 65,169,
/* 0x01d0 */ 224, 7,194,168,232, 26,128, 82, 12, 0,128, 82, 67,128, 95,248, /* 0x01d0 */ 224, 7,194,168,232, 26,128, 82, 67,128, 95,248, 96, 0, 31,214,
/* 0x01e0 */ 96, 0, 31,214, 32, 32, 32, 61, 47,112,114,111, 99, 47,115,101, /* 0x01e0 */ 32, 32, 32, 61, 47,112,114,111, 99, 47,115,101,108,102, 47,101,
/* 0x01f0 */ 108,102, 47,101,120,101, 0, 0, 99, 28, 0, 18,127, 72, 1,113, /* 0x01f0 */ 120,101, 0, 0, 99, 28, 0, 18,127, 72, 1,113,129, 1, 0, 84,
/* 0x0200 */ 129, 1, 0, 84, 33,252, 66,211, 65, 1, 0,180, 33, 4, 0,209, /* 0x0200 */ 33,252, 66,211, 65, 1, 0,180, 33, 4, 0,209, 2,120, 97,184,
/* 0x0210 */ 2,120, 97,184, 67,120, 26, 83,127, 20, 0,113,129, 0, 0, 84, /* 0x0210 */ 67,120, 26, 83,127, 20, 0,113,129, 0, 0, 84, 66, 0, 1, 75,
/* 0x0220 */ 66, 0, 1, 75, 98, 20, 26, 83, 2,120, 33,184, 1,255,255,181, /* 0x0220 */ 98, 20, 26, 83, 2,120, 33,184, 1,255,255,181,192, 3, 95,214,
/* 0x0230 */ 192, 3, 95,214, 0, 0, 32,212,192, 3, 95,214,200, 11,128, 82, /* 0x0230 */ 0, 0, 32,212,192, 3, 95,214,200, 11,128, 82, 1, 0, 0,212,
/* 0x0240 */ 1, 0, 0,212,232, 7,128, 82, 1, 0, 0,212,192, 3, 95,214, /* 0x0240 */ 232, 7,128, 82, 1, 0, 0,212,192, 3, 95,214, 8, 8,128, 82,
/* 0x0250 */ 8, 8,128, 82, 1, 0, 0,212,192, 3, 95,214, 40, 7,128, 82, /* 0x0250 */ 1, 0, 0,212,192, 3, 95,214, 40, 7,128, 82, 1, 0, 0,212,
/* 0x0260 */ 1, 0, 0,212,192, 3, 95,214,104, 4,128, 82, 1, 0, 0,212, /* 0x0260 */ 192, 3, 95,214,104, 4,128, 82, 1, 0, 0,212,192, 3, 95,214,
/* 0x0270 */ 192, 3, 95,214,168, 21,128, 82, 1, 0, 0,212,192, 3, 95,214, /* 0x0270 */ 168, 21,128, 82, 1, 0, 0,212,192, 3, 95,214,200, 26,128, 82,
/* 0x0280 */ 200, 26,128, 82, 1, 0, 0,212,192, 3, 95,214,232, 26,128, 82, /* 0x0280 */ 1, 0, 0,212,192, 3, 95,214,232, 26,128, 82, 1, 0, 0,212,
/* 0x0290 */ 1, 0, 0,212,192, 3, 95,214, 72, 28,128, 82, 1, 0, 0,212, /* 0x0290 */ 192, 3, 95,214, 72, 28,128, 82, 1, 0, 0,212,192, 3, 95,214,
/* 0x02a0 */ 192, 3, 95,214,166,240,255, 24, 5, 0,128,210, 4, 0,128,146, /* 0x02a0 */ 198,240,255, 24, 5, 0,128,210, 4, 0,128,146, 99, 0, 6, 42,
/* 0x02b0 */ 99, 0, 6, 42,200, 27,128, 82, 1, 0, 0,212,192, 3, 95,214, /* 0x02b0 */ 200, 27,128, 82, 1, 0, 0,212,192, 3, 95,214,229, 3, 0,170,
/* 0x02c0 */ 229, 3, 0,170, 96, 12,128,146,228, 3, 1,170,227, 3, 2,170, /* 0x02c0 */ 96, 12,128,146,228, 3, 1,170,227, 3, 2,170,226, 3, 4,170,
/* 0x02d0 */ 226, 3, 4,170,225, 3, 5,170, 8, 7,128, 82, 1, 0, 0,212, /* 0x02d0 */ 225, 3, 5,170, 8, 7,128, 82, 1, 0, 0,212,192, 3, 95,214,
/* 0x02e0 */ 192, 3, 95,214,229, 3, 0,170, 96, 12,128,146,228, 3, 1,170, /* 0x02e0 */ 229, 3, 0,170, 96, 12,128,146,228, 3, 1,170,227, 3, 2,170,
/* 0x02f0 */ 227, 3, 2,170,226, 3, 4,170,225, 3, 5,170,200, 9,128, 82, /* 0x02f0 */ 226, 3, 4,170,225, 3, 5,170,200, 9,128, 82, 1, 0, 0,212,
/* 0x0300 */ 1, 0, 0,212, 31, 4, 64,177, 98, 0, 0, 84, 3, 0,128, 82, /* 0x0300 */ 31, 4, 64,177, 98, 0, 0, 84, 3, 0,128, 82, 67,104, 32, 56,
/* 0x0310 */ 67,104, 32, 56,192, 3, 95,214, 0, 0, 64,212, 2, 0,128, 82, /* 0x0310 */ 192, 3, 95,214, 0, 0, 64,212, 2, 0,128, 82, 8, 0,128, 82,
/* 0x0320 */ 8, 0,128, 82, 1, 0, 0,212,192, 3, 95,214,128, 1, 0,180, /* 0x0320 */ 1, 0, 0,212,192, 3, 95,214,128, 1, 0,180, 3, 0, 64,249,
/* 0x0330 */ 3, 0, 64,249,228, 3, 1, 42,127, 0, 4,235, 97, 0, 0, 84, /* 0x0330 */ 228, 3, 1, 42,127, 0, 4,235, 97, 0, 0, 84, 4, 8, 0,169,
/* 0x0340 */ 4, 8, 0,169,192, 3, 95,214, 63, 0, 31,107, 96, 24, 65,250, /* 0x0340 */ 192, 3, 95,214, 63, 0, 31,107, 96, 24, 65,250,128,255,255, 84,
/* 0x0350 */ 128,255,255, 84, 0, 64, 0,145,246,255,255, 23,192, 3, 95,214, /* 0x0350 */ 0, 64, 0,145,246,255,255, 23,192, 3, 95,214, 3, 16, 64,169,
/* 0x0360 */ 3, 16, 64,169,127, 0, 2,235, 99, 0, 0, 84, 3, 0,128,210, /* 0x0360 */ 127, 0, 2,235, 99, 0, 0, 84, 3, 0,128,210, 5, 0, 0, 20,
/* 0x0370 */ 5, 0, 0, 20,253,123,191,169,224, 15,128, 82,253, 3, 0,145, /* 0x0370 */ 253,123,191,169,224, 15,128, 82,253, 3, 0,145,175,255,255,151,
/* 0x0380 */ 175,255,255,151, 95, 0, 3,235,160, 0, 0, 84,133,104, 99, 56, /* 0x0380 */ 95, 0, 3,235,160, 0, 0, 84,133,104, 99, 56, 37,104, 35, 56,
/* 0x0390 */ 37,104, 35, 56, 99, 4, 0,145,251,255,255, 23, 1, 4, 64,249, /* 0x0390 */ 99, 4, 0,145,251,255,255, 23, 1, 4, 64,249, 33, 0, 2,139,
/* 0x03a0 */ 33, 0, 2,139, 1, 4, 0,249, 1, 0, 64,249, 34, 0, 2,203, /* 0x03a0 */ 1, 4, 0,249, 1, 0, 64,249, 34, 0, 2,203, 2, 0, 0,249,
/* 0x03b0 */ 2, 0, 0,249,192, 3, 95,214,253,123,187,169,253, 3, 0,145, /* 0x03b0 */ 192, 3, 95,214,253,123,187,169,253, 3, 0,145,243, 83, 1,169,
/* 0x03c0 */ 243, 83, 1,169,245, 91, 2,169,244, 3, 0,170,243, 3, 1,170, /* 0x03c0 */ 245, 91, 2,169,244, 3, 0,170,243, 3, 1,170,246, 3, 2,170,
/* 0x03d0 */ 246, 3, 2,170,245, 3, 3,170, 96, 2, 64,249,192, 7, 0,180, /* 0x03d0 */ 245, 3, 3,170, 96, 2, 64,249,192, 7, 0,180,161, 3, 1,145,
/* 0x03e0 */ 161, 3, 1,145,224, 3, 20,170,130, 1,128,210,221,255,255,151, /* 0x03e0 */ 224, 3, 20,170,130, 1,128,210,221,255,255,151,160, 7, 72, 41,
/* 0x03f0 */ 160, 7, 72, 41, 0, 1, 0, 53,160, 10,138, 82, 0, 43,164,114, /* 0x03f0 */ 0, 1, 0, 53,160, 10,138, 82, 0, 43,164,114, 63, 0, 0,107,
/* 0x0400 */ 63, 0, 0,107,225, 0, 0, 84,128, 2, 64,249, 64, 6, 0,180, /* 0x0400 */ 225, 0, 0, 84,128, 2, 64,249, 64, 6, 0,180, 4, 0, 0, 20,
/* 0x0410 */ 4, 0, 0, 20, 31, 0, 1,107, 36, 32, 95,122, 97, 0, 0, 84, /* 0x0410 */ 31, 0, 1,107, 36, 32, 95,122, 97, 0, 0, 84,224, 15,128, 82,
/* 0x0420 */ 224, 15,128, 82,134,255,255,151, 98, 2, 64,249, 95, 64, 32,235, /* 0x0420 */ 134,255,255,151, 98, 2, 64,249, 95, 64, 32,235,131,255,255, 84,
/* 0x0430 */ 131,255,255, 84, 31, 0, 1,107,169, 3, 0, 84,160, 63, 0,185, /* 0x0430 */ 31, 0, 1,107,169, 3, 0, 84,160, 63, 0,185,163,243, 0,145,
/* 0x0440 */ 163,243, 0,145,164, 35, 65, 57, 98, 6, 64,249,128, 6, 64,249, /* 0x0440 */ 164, 35, 65, 57, 98, 6, 64,249,128, 6, 64,249,192, 2, 63,214,
/* 0x0450 */ 192, 2, 63,214, 96,254,255, 53,160,135, 71, 41, 63, 0, 0,107, /* 0x0450 */ 96,254,255, 53,160,135, 71, 41, 63, 0, 0,107, 1,254,255, 84,
/* 0x0460 */ 1,254,255, 84,163, 39, 65, 57,191, 2, 31,235,100, 16, 95,122, /* 0x0460 */ 163, 39, 65, 57,191, 2, 31,235,100, 16, 95,122, 32, 1, 0, 84,
/* 0x0470 */ 32, 1, 0, 84, 63, 0, 8,113,136, 0, 0, 84, 96, 2, 64,249, /* 0x0470 */ 63, 0, 8,113,136, 0, 0, 84, 96, 2, 64,249, 31, 64, 33,235,
/* 0x0480 */ 31, 64, 33,235,129, 0, 0, 84,162, 43, 65, 57, 96, 6, 64,249, /* 0x0480 */ 129, 0, 0, 84,162, 43, 65, 57, 96, 6, 64,249,160, 2, 63,214,
/* 0x0490 */ 160, 2, 63,214,128, 6, 64,169,162, 71, 64,185, 33, 0, 2,139, /* 0x0490 */ 128, 6, 64,169,162, 71, 64,185, 33, 0, 2,139, 0, 0, 2,203,
/* 0x04a0 */ 0, 0, 2,203,128, 6, 0,169, 5, 0, 0, 20,226, 3, 1, 42, /* 0x04a0 */ 128, 6, 0,169, 5, 0, 0, 20,226, 3, 1, 42, 97, 6, 64,249,
/* 0x04b0 */ 97, 6, 64,249,224, 3, 20,170,170,255,255,151, 96, 6, 64,169, /* 0x04b0 */ 224, 3, 20,170,170,255,255,151, 96, 6, 64,169,162, 67, 64,185,
/* 0x04c0 */ 162, 67, 64,185, 33, 0, 2,139, 0, 0, 2,203, 96, 6, 0,169, /* 0x04c0 */ 33, 0, 2,139, 0, 0, 2,203, 96, 6, 0,169,194,255,255, 23,
/* 0x04d0 */ 194,255,255, 23,243, 83, 65,169,245, 91, 66,169,253,123,197,168, /* 0x04d0 */ 243, 83, 65,169,245, 91, 66,169,253,123,197,168,192, 3, 95,214,
/* 0x04e0 */ 192, 3, 95,214,253,123,181,169,253, 3, 0,145,247, 99, 3,169, /* 0x04e0 */ 253,123,180,169,253, 3, 0,145,247, 99, 3,169,247, 3, 0,170,
/* 0x04f0 */ 247, 3, 0,170,166, 67, 0,249, 6, 16, 64,249,249,107, 4,169, /* 0x04f0 */ 166, 75, 0,249, 6, 16, 64,249,249,107, 4,169, 25, 0, 6,139,
/* 0x0500 */ 25, 0, 6,139, 0, 32, 64,121,243, 83, 1,169, 31, 12, 0,113, /* 0x0500 */ 0, 32, 64,121,243, 83, 1,169, 31, 12, 0,113,224,114, 64,121,
/* 0x0510 */ 224,114, 64,121,244, 3, 2, 42, 2, 7,128, 82,251,115, 5,169, /* 0x0510 */ 244, 3, 2, 42, 2, 7,128, 82,251,115, 5,169, 2,124,162,155,
/* 0x0520 */ 2,124,162,155,252, 3, 3,170, 3, 2,128, 82, 99, 16,159, 26, /* 0x0520 */ 252, 3, 3,170, 3, 2,128, 82, 99, 16,159, 26, 19, 0,128,146,
/* 0x0530 */ 19, 0,128,146,245, 91, 2,169,165, 19, 6,169,246, 3, 1,170, /* 0x0530 */ 245, 91, 2,169,165,147, 6,169,246, 3, 1,170, 99,136, 0, 17,
/* 0x0540 */ 99,136, 0, 17, 1, 0,128,210, 34, 3, 2,139,224, 3, 25,170, /* 0x0540 */ 1, 0,128,210, 34, 3, 2,139,224, 3, 25,170, 31, 0, 2,235,
/* 0x0550 */ 31, 0, 2,235,160, 1, 0, 84, 4, 0, 64,185,159, 4, 0,113, /* 0x0550 */ 160, 1, 0, 84, 4, 0, 64,185,159, 4, 0,113, 1, 1, 0, 84,
/* 0x0560 */ 1, 1, 0, 84, 5, 8, 64,249, 4, 20, 64,249,127, 2, 5,235, /* 0x0560 */ 5, 8, 64,249, 4, 20, 64,249,127, 2, 5,235,164, 0, 4,139,
/* 0x0570 */ 164, 0, 4,139,115,146,133,154, 63, 0, 4,235, 33, 32,132,154, /* 0x0570 */ 115,146,133,154, 63, 0, 4,235, 33, 32,132,154, 0,224, 0,145,
/* 0x0580 */ 0,224, 0,145,243,255,255, 23,115,206,116,146, 33,252, 63,145, /* 0x0580 */ 243,255,255, 23,115,206,116,146, 33,252, 63,145, 33, 0, 19,203,
/* 0x0590 */ 33, 0, 19,203,224, 3, 19,170, 33,204,116,146, 5, 0,128,210, /* 0x0590 */ 224, 3, 19,170, 33,204,116,146, 5, 0,128,210, 4, 0,128, 18,
/* 0x05a0 */ 4, 0,128, 18, 2, 0,128, 82, 26, 0,128, 82, 66,255,255,151, /* 0x05a0 */ 2, 0,128, 82, 26, 0,128, 82, 66,255,255,151, 19, 0, 19,203,
/* 0x05b0 */ 19, 0, 19,203,223, 2, 31,235, 64, 0,128, 82, 0, 16,159, 26, /* 0x05b0 */ 96, 14, 0,145,223, 2, 31,235,160, 67, 0,249, 64, 0,128, 82,
/* 0x05c0 */ 160,127, 0,185,128, 2,159, 90, 65, 6,128, 82,160,123, 0,185, /* 0x05c0 */ 0, 16,159, 26,160,143, 0,185,128, 2,159, 90, 65, 6,128, 82,
/* 0x05d0 */ 64, 2,128, 82, 32, 16,128, 26,160,119, 0,185,224,114, 64,121, /* 0x05d0 */ 160,139, 0,185, 64, 2,128, 82, 32, 16,128, 26,160,127, 0,185,
/* 0x05e0 */ 95, 3, 0,107,106, 11, 0, 84, 32, 3, 64,185, 54, 1, 0,180, /* 0x05e0 */ 224,114, 64,121, 95, 3, 0,107,170, 12, 0, 84, 32, 3, 64,185,
/* 0x05f0 */ 31, 24, 0,113,225, 0, 0, 84, 34, 11, 64,249, 97, 0,128, 82, /* 0x05f0 */ 54, 1, 0,180, 31, 24, 0,113,225, 0, 0, 84, 34, 11, 64,249,
/* 0x0600 */ 224, 3, 28,170, 98, 2, 2,139, 73,255,255,151, 78, 0, 0, 20, /* 0x0600 */ 97, 0,128, 82,224, 3, 28,170, 98, 2, 2,139, 71,255,255,151,
/* 0x0610 */ 31, 4, 0,113,129, 9, 0, 84, 56, 7, 64,185, 1, 72,140, 82, /* 0x0610 */ 88, 0, 0, 20, 31, 4, 0,113,193, 10, 0, 84, 56, 7, 64,185,
/* 0x0620 */ 33,106,174,114, 53, 19, 64,249, 24, 11, 30, 83, 32, 36,216, 26, /* 0x0620 */ 1, 72,140, 82, 33,106,174,114, 53, 19, 64,249, 24, 11, 30, 83,
/* 0x0630 */ 160,147, 0,185, 37,211, 64,169, 27, 8, 0, 18, 32, 23, 64,249, /* 0x0630 */ 163,127, 64,185, 32, 36,216, 26,160,163, 0,185, 37,211, 64,169,
/* 0x0640 */ 116, 2, 20,139,128, 2, 0,139,160, 71, 0,249,128, 46, 64,146, /* 0x0640 */ 27, 8, 0, 18, 32, 23, 64,249,116, 2, 20,139,164,139, 64,185,
/* 0x0650 */ 181, 83, 10,169,165, 0, 0,203,181, 2, 0,139,160,127, 64,185, /* 0x0650 */ 128, 2, 0,139,160, 79, 0,249,128, 46, 64,146,181, 83, 11,169,
/* 0x0660 */ 148,206,116,146,163,147, 78, 41, 2, 0, 27, 42,225, 3, 21,170, /* 0x0660 */ 165, 0, 0,203,181, 2, 0,139,160,143, 64,185,148,206,116,146,
/* 0x0670 */ 224, 3, 20,170, 16,255,255,151,159, 2, 0,235, 96, 0, 0, 84, /* 0x0670 */ 225, 3, 21,170, 2, 0, 27, 42,224, 3, 20,170, 13,255,255,151,
/* 0x0680 */ 224, 15,128, 82,238,254,255,151,182, 0, 0,180,163, 11, 70,169, /* 0x0680 */ 159, 2, 0,235, 96, 0, 0, 84,224, 15,128, 82,235,254,255,151,
/* 0x0690 */ 161,131, 2,145,224, 3, 22,170, 72,255,255,151,160, 75, 64,249, /* 0x0690 */ 182, 0, 0,180,163,139, 70,169,161,195, 2,145,224, 3, 22,170,
/* 0x06a0 */ 227, 3, 21,203,120, 44, 64,146, 96, 0, 8, 55, 86, 1, 0,181, /* 0x06a0 */ 69,255,255,151,160, 83, 64,249,227, 3, 21,203,120, 44, 64,146,
/* 0x06b0 */ 23, 0, 0, 20,216,255,255,180,129, 2, 21,139, 0, 0,128,210, /* 0x06b0 */ 96, 0, 8, 55, 86, 1, 0,181, 32, 0, 0, 20,216,255,255,180,
/* 0x06c0 */ 63,104, 32, 56, 0, 4, 0,145, 31, 0, 24,235,161,255,255, 84, /* 0x06c0 */ 129, 2, 21,139, 0, 0,128,210, 63,104, 32, 56, 0, 4, 0,145,
/* 0x06d0 */ 247,255,255, 23, 32, 7, 64,249, 0, 1, 0,181,226, 3, 20,170, /* 0x06d0 */ 31, 0, 24,235,161,255,255, 84,247,255,255, 23, 32, 3, 64,249,
/* 0x06e0 */ 224,161,128, 82, 96, 24,178,114, 1, 0,128, 82, 64,204, 0,184, /* 0x06e0 */ 225, 3, 0,178, 0,128, 64,146, 31, 0, 1,235,193, 1, 0, 84,
/* 0x06f0 */ 224, 3, 28,170, 14,255,255,151,226, 3, 27, 42,225, 3, 21,170, /* 0x06f0 */ 32, 23, 64,249, 34, 11, 64,249,161, 67, 64,249, 2, 0, 2,139,
/* 0x0700 */ 224, 3, 20,170,229,254,255,151,192,251,255, 53,181, 2, 24,139, /* 0x0700 */ 66, 0, 1,139, 33, 19, 64,249, 66,244,126,146, 31, 0, 1,235,
/* 0x0710 */ 160, 71, 64,249,148, 2, 21,139, 31, 0, 20,235, 73, 1, 0, 84, /* 0x0710 */ 161, 0, 0, 84,224, 3, 2,203, 0, 44, 64,146, 31, 28, 0,241,
/* 0x0720 */ 1, 0, 20,203, 5, 0,128,210, 4, 0,128, 18, 67, 6,128, 82, /* 0x0720 */ 104, 3, 0, 84,226, 3, 27, 42,225, 3, 21,170,224, 3, 20,170,
/* 0x0730 */ 226, 3, 27, 42,224, 3, 20,170,223,254,255,151,159, 2, 0,235, /* 0x0730 */ 217,254,255,151,160,250,255, 53,181, 2, 24,139,160, 79, 64,249,
/* 0x0740 */ 1,250,255, 84, 57,227, 0,145, 90, 7, 0, 17,164,255,255, 23, /* 0x0740 */ 148, 2, 21,139, 31, 0, 20,235, 73, 1, 0, 84, 1, 0, 20,203,
/* 0x0750 */ 160, 67, 64,249, 64, 0, 0,180, 19, 0, 0,249,224, 14, 64,249, /* 0x0750 */ 5, 0,128,210, 4, 0,128, 18, 67, 6,128, 82,226, 3, 27, 42,
/* 0x0760 */ 245, 91, 66,169,249,107, 68,169,251,115, 69,169, 96, 2, 0,139, /* 0x0760 */ 224, 3, 20,170,211,254,255,151,159, 2, 0,235,225,248,255, 84,
/* 0x0770 */ 243, 83, 65,169,247, 99, 67,169,253,123,203,168,192, 3, 95,214, /* 0x0770 */ 57,227, 0,145, 90, 7, 0, 17,154,255,255, 23,160, 75, 64,249,
/* 0x0780 */ 253,123,184,169,253, 3, 0,145,243, 83, 1,169,243, 3, 2,170, /* 0x0780 */ 160, 1, 0,180, 19, 0, 0,249, 11, 0, 0, 20, 32, 0,128, 82,
/* 0x0790 */ 84, 0, 1,145,162,135, 5,169, 2, 0, 64,185,245, 91, 2,169, /* 0x0790 */ 1, 0,128, 82, 0,128,186,114, 64, 0, 0,185, 0,120,128, 82,
/* 0x07a0 */ 160,135, 6,169,245, 3, 3,170,160, 63, 0,249, 3, 0,128,210, /* 0x07a0 */ 224,203,186,114, 64, 4, 0,185,224, 3, 28,170,223,254,255,151,
/* 0x07b0 */ 161, 67, 1,145,160,195, 1,145,162, 43, 0,249,226, 3, 4,170, /* 0x07b0 */ 221,255,255, 23,224, 14, 64,249,245, 91, 66,169,249,107, 68,169,
/* 0x07c0 */ 246, 3, 4,170,166, 39, 0,249,247, 27, 0,249,247, 3, 5,170, /* 0x07c0 */ 251,115, 69,169, 96, 2, 0,139,243, 83, 65,169,247, 99, 67,169,
/* 0x07d0 */ 250,254,255,151,130, 10, 64,249,224, 3, 21,170, 97, 0,128, 82, /* 0x07d0 */ 253,123,204,168,192, 3, 95,214,253,123,183,169,253, 3, 0,145,
/* 0x07e0 */ 66, 0, 1,145,210,254,255,151, 98,114, 64,121,224, 3, 21,170, /* 0x07e0 */ 243, 83, 1,169,243, 3, 2,170, 84, 0, 1,145,162,135, 6,169,
/* 0x07f0 */ 161, 0,128, 82,206,254,255,151,228, 3, 22,170,227, 3, 21,170, /* 0x07f0 */ 2, 0, 64,185,245, 91, 2,169,160,135, 7,169,245, 3, 3,170,
/* 0x0800 */ 166, 35, 1,145,229, 3, 23,170, 2, 0,128, 82,161,131, 1,145, /* 0x0800 */ 160, 71, 0,249, 3, 0,128,210,161,131, 1,145,160, 3, 2,145,
/* 0x0810 */ 224, 3, 19,170, 52,255,255,151,226, 3, 0,170,246, 3, 0,170, /* 0x0810 */ 162, 51, 0,249,226, 3, 4,170,246, 3, 4,170,247, 99, 3,169,
/* 0x0820 */ 33, 1,128, 82,224, 3, 21,170, 21, 0,128, 82,192,254,255,151, /* 0x0820 */ 249, 35, 0,249,247, 3, 5,170,249, 3, 6,170,226,254,255,151,
/* 0x0830 */ 96,114, 64,121,191, 2, 0,107, 42, 4, 0, 84,128, 2, 64,185, /* 0x0830 */ 130, 10, 64,249, 97, 0,128, 82,224, 3, 21,170, 66, 0, 1,145,
/* 0x0840 */ 31, 12, 0,113, 97, 3, 0, 84,131, 10, 64,249, 2, 0,128, 82, /* 0x0840 */ 186,254,255,151, 98,114, 64,121,161, 0,128, 82,224, 3, 21,170,
/* 0x0850 */ 160, 39, 64,249, 1, 0,128, 82, 96, 0, 0,139,153,254,255,151, /* 0x0850 */ 182,254,255,151,229, 3, 23,170,228, 3, 22,170,230, 3, 25,170,
/* 0x0860 */ 247, 3, 0, 42, 96, 0,248, 54,224, 15,128, 82,116,254,255,151, /* 0x0860 */ 227, 3, 21,170, 2, 0,128, 82,161,195, 1,145,224, 3, 19,170,
/* 0x0870 */ 2,128,128,210,225, 3, 19,170,115,254,255,151, 31, 0, 16,241, /* 0x0870 */ 23, 0,128, 82, 27,255,255,151,226, 3, 0,170,246, 3, 0,170,
/* 0x0880 */ 65,255,255, 84, 6, 0,128,210, 5, 0,128,210, 4, 0,128,210, /* 0x0880 */ 33, 1,128, 82,224, 3, 21,170,168,254,255,151, 96,114, 64,121,
/* 0x0890 */ 3, 0,128,210,226, 3, 23, 42, 1, 0,128,210,224, 3, 19,170, /* 0x0890 */ 255, 2, 0,107,202, 4, 0, 84,128, 2, 64,185, 31, 12, 0,113,
/* 0x08a0 */ 17,255,255,151,246, 3, 0,170,224, 3, 23, 42,108,254,255,151, /* 0x08a0 */ 1, 4, 0, 84,128, 10, 64,249, 2, 0,128, 82, 35, 3, 64,249,
/* 0x08b0 */ 148,226, 0,145,181, 6, 0, 17,222,255,255, 23,224, 3, 22,170, /* 0x08b0 */ 1, 0,128, 82, 96, 0, 0,139,129,254,255,151,248, 3, 0, 42,
/* 0x08c0 */ 247, 27, 64,249,243, 83, 65,169,245, 91, 66,169,253,123,200,168, /* 0x08c0 */ 96, 0,248, 54,224, 15,128, 82, 92,254,255,151, 2,128,128,210,
/* 0x08d0 */ 192, 3, 95,214 /* 0x08d0 */ 225, 3, 19,170, 91,254,255,151, 31, 0, 16,241, 65,255,255, 84,
/* 0x08e0 */ 166, 99, 1,145, 5, 0,128,210, 4, 0,128,210, 3, 0,128,210,
/* 0x08f0 */ 226, 3, 24, 42, 1, 0,128,210,224, 3, 19,170,191, 47, 0,249,
/* 0x0900 */ 248,254,255,151,246, 3, 0,170,162, 47, 64,249,224, 3, 21,170,
/* 0x0910 */ 225, 0,128, 82,133,254,255,151,224, 3, 24, 42, 79,254,255,151,
/* 0x0920 */ 148,226, 0,145,247, 6, 0, 17,217,255,255, 23,224, 3, 22,170,
/* 0x0930 */ 249, 35, 64,249,243, 83, 65,169,245, 91, 66,169,247, 99, 67,169,
/* 0x0940 */ 253,123,201,168,192, 3, 95,214
}; };

View File

@ -154,7 +154,7 @@ SP_argc= 4*8 // remember the hole from PUSH3
mov x0,x10 // &b_info mov x0,x10 // &b_info
bl upx_main bl upx_main
add sp,sp,#MAX_ELF_HDR + OVERHEAD // un-alloca add sp,sp,#MAX_ELF_HDR + OVERHEAD // un-alloca
mov x29,x0 // entry address mov lr,x0 // entry address
brk #0 brk #0
POP4(x0,x1,x2,x3) // x0= ADRU; x1= LENU; x2= 1+ &Elf64_auxv_t[AT_NULL@.atype]; x3= reloc POP4(x0,x1,x2,x3) // x0= ADRU; x1= LENU; x2= 1+ &Elf64_auxv_t[AT_NULL@.atype]; x3= reloc
@ -168,7 +168,6 @@ brk #0
#endif /*}*/ #endif /*}*/
mov w8,#__NR_munmap mov w8,#__NR_munmap
mov w12,#0
ldr x3,[x2,#8 -2*8] // Elf64_auxv_t[AT_NULL@.a_type].a_val ldr x3,[x2,#8 -2*8] // Elf64_auxv_t[AT_NULL@.a_type].a_val
br x3 br x3

View File

@ -160,6 +160,40 @@ ERR_LAB
} }
} }
//DEBUG_STRCON(STR_make_hatch, "make_hatch %%p %%x\\n");
static void *
make_hatch_arm64(
Elf64_Phdr const *const phdr,
uint64_t const reloc
)
{
unsigned *hatch = 0;
//DPRINTF((STR_make_hatch(),phdr,reloc));
if (phdr->p_type==PT_LOAD && phdr->p_flags & PF_X) {
// The format of the 'if' is
// if ( ( (hatch = loc1), test_loc1 )
// || ( (hatch = loc2), test_loc2 ) ) {
// action
// }
// which uses the comma to save bytes when test_locj involves locj
// and the action is the same when either test succeeds.
// Try page fragmentation just beyond .text .
if ( ( (hatch = (void *)(~3ul & (3+ phdr->p_memsz + phdr->p_vaddr + reloc))),
( phdr->p_memsz==phdr->p_filesz // don't pollute potential .bss
&& (2*4)<=(~PAGE_MASK & -(uint64_t)hatch) ) ) // space left on page
) {
hatch[0]= 0xd4000001; // svc #0
hatch[1]= 0xd65f03c0; // ret (jmp *lr)
}
else {
hatch = 0;
}
}
return hatch;
}
#if 1 /*{*/ #if 1 /*{*/
static void static void
upx_bzero(char *p, size_t len) upx_bzero(char *p, size_t len)
@ -277,11 +311,9 @@ do_xmap(
bzero(mlen+addr, frag); // fragment at hi end bzero(mlen+addr, frag); // fragment at hi end
} }
if (xi) { if (xi) {
if (0==phdr->p_offset) { void *const hatch = make_hatch_arm64(phdr, reloc);
Elf64_Ehdr *const ehdr = (Elf64_Ehdr *)addr; if (0!=hatch) {
int *const p = (int *)&ehdr->e_ident[12]; auxv_up(av, AT_NULL, (uint64_t)hatch);
*p = 0x90c3050f; // syscall; ret; nop
auxv_up(av, AT_NULL, (uint64_t)&ehdr->e_ident[12]);
} }
if (0!=mprotect(addr, mlen, prot)) { if (0!=mprotect(addr, mlen, prot)) {
err_exit(10); err_exit(10);
@ -359,7 +391,11 @@ 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); {
Elf64_Addr i_reloc = 0;
entry = do_xmap(ehdr, 0, fdi, 0, 0, 0, &i_reloc);
auxv_up(av, AT_BASE, i_reloc);
}
close(fdi); close(fdi);
} }
} }

View File

@ -8,44 +8,44 @@ Linker script and memory map
0x00000000001000bc . = ((0x100000 + SIZEOF_HEADERS) + 0xc) 0x00000000001000bc . = ((0x100000 + SIZEOF_HEADERS) + 0xc)
.text 0x00000000001000bc 0x818 .text 0x00000000001000bc 0x88c
*(.text) *(.text)
.text 0x00000000001000bc 0x270 tmp/arm64-linux.elf-fold.o .text 0x00000000001000bc 0x26c tmp/arm64-linux.elf-fold.o
0x0000000000100234 my_bkpt 0x0000000000100230 my_bkpt
0x000000000010023c exit 0x0000000000100238 exit
0x0000000000100244 read 0x0000000000100240 read
0x0000000000100250 write 0x000000000010024c write
0x000000000010025c close 0x0000000000100258 close
0x0000000000100268 unlink 0x0000000000100264 unlink
0x0000000000100274 getpid 0x0000000000100270 getpid
0x0000000000100280 brk 0x000000000010027c brk
0x000000000010028c munmap 0x0000000000100288 munmap
0x0000000000100298 mprotect 0x0000000000100294 mprotect
0x00000000001002a4 mmap_privanon 0x00000000001002a0 mmap_privanon
0x00000000001002b4 mmap 0x00000000001002b0 mmap
0x00000000001002c0 open 0x00000000001002bc open
0x00000000001002e4 readlink 0x00000000001002e0 readlink
0x0000000000100318 __clear_cache 0x0000000000100314 __clear_cache
.text 0x000000000010032c 0x5a8 tmp/arm64-linux.elf-main.o .text 0x0000000000100328 0x620 tmp/arm64-linux.elf-main.o
0x0000000000100780 upx_main 0x00000000001007d8 upx_main
*(.data) *(.data)
.data 0x00000000001008d4 0x0 tmp/arm64-linux.elf-fold.o .data 0x0000000000100948 0x0 tmp/arm64-linux.elf-fold.o
.data 0x00000000001008d4 0x0 tmp/arm64-linux.elf-main.o .data 0x0000000000100948 0x0 tmp/arm64-linux.elf-main.o
.iplt 0x00000000001008d4 0x0 .iplt 0x0000000000100948 0x0
.iplt 0x00000000001008d4 0x0 tmp/arm64-linux.elf-fold.o .iplt 0x0000000000100948 0x0 tmp/arm64-linux.elf-fold.o
.rela.dyn 0x00000000001008d8 0x0 .rela.dyn 0x0000000000100948 0x0
.rela.iplt 0x00000000001008d8 0x0 tmp/arm64-linux.elf-fold.o .rela.iplt 0x0000000000100948 0x0 tmp/arm64-linux.elf-fold.o
.data .data
LOAD tmp/arm64-linux.elf-fold.o LOAD tmp/arm64-linux.elf-fold.o
LOAD tmp/arm64-linux.elf-main.o LOAD tmp/arm64-linux.elf-main.o
OUTPUT(tmp/arm64-linux.elf-fold.bin elf64-littleaarch64) OUTPUT(tmp/arm64-linux.elf-fold.bin elf64-littleaarch64)
.igot.plt 0x00000000001008d8 0x0 .igot.plt 0x0000000000100948 0x0
.igot.plt 0x00000000001008d8 0x0 tmp/arm64-linux.elf-fold.o .igot.plt 0x0000000000100948 0x0 tmp/arm64-linux.elf-fold.o
.bss 0x00000000001008d4 0x0 .bss 0x0000000000100948 0x0
.bss 0x00000000001008d4 0x0 tmp/arm64-linux.elf-fold.o .bss 0x0000000000100948 0x0 tmp/arm64-linux.elf-fold.o
.bss 0x00000000001008d4 0x0 tmp/arm64-linux.elf-main.o .bss 0x0000000000100948 0x0 tmp/arm64-linux.elf-main.o