From 09c5e383223e6f70222b8b04fffdb79919f9c40a Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 9 Jan 2024 12:17:01 -0800 Subject: [PATCH] arm64-linux.elf ABI owns x0 at execve()? https://github.com/upx/upx/issues/758 modified: ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh modified: stub/arm64-linux.elf-fold.h modified: stub/src/amd64-linux.elf-main.c modified: stub/src/arm64-linux.elf-fold.S modified: stub/tmp/arm64-linux.elf-fold.map --- .../upx_testsuite_1-expected_sha256sums.sh | 14 +- src/stub/arm64-linux.elf-fold.h | 258 +++++++++--------- src/stub/src/amd64-linux.elf-main.c | 16 +- src/stub/src/arm64-linux.elf-fold.S | 3 +- src/stub/tmp/arm64-linux.elf-fold.map | 28 +- 5 files changed, 161 insertions(+), 158 deletions(-) diff --git a/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh b/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh index b26d4d0b..e67b4505 100644 --- a/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh +++ b/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh @@ -51,7 +51,7 @@ e9758349710ee1980f9205c96f8cc2b48baf37fbfcabf203813a8ed1063f9543 *amd64-linux.el 1bd70a3cd3b34e635a3c947cacd46c4d66bf07e0fd350cc6d1f3cf60483f75b9 *amd64-win64.pe/upx-3.95.exe ff5ce3bfae584c64e140c3a948b8dbb644c7d9a4cb6f9dbd2b2f60a82a10b648 *arm-linux.elf/upx-3.95 39c50022b8c5401c61c72834a921f2dc1ea9192bfe1474b14ae4565dfab37753 *arm-wince.pe/upx-3.91.exe -1ef378bd27eff4ee21a13593c9438cad84ca1f874f16982d591ffc95e7396587 *arm64-linux.elf/upx-3.95 +d4accb0417c51a79c59086d3f6d1f6dcacbdccb3d1be5f09df4b6e4fd488f15a *arm64-linux.elf/upx-3.95 498d988f6d693e5391464abf6b9f2680a9526af32a1ea0ebfe3617cc8cbeb59e *armeb-linux.elf/upx-3.91 3bc2653839f2d7af9fe0ce47f9500058b23fbd1227cdcc2216a17d3e9bc95511 *armeb-linux.elf/upx-3.95 4af922bc967bf31ac7fbdc31a6957ca68ae29c8fee0666d1ebb837190dd74951 *i386-dos32.djgpp2.coff/upx-3.91.exe @@ -74,7 +74,7 @@ d64c59cb82e55e5ea7e4b0999d9abdd7b454332c50da560f3103a391ab4c63c6 *amd64-linux.el 0314c6974f29d180e46e41a1004d46a3993fe96f03de7f78d45ad89ad3b2177e *amd64-win64.pe/upx-3.95.exe 1a02d22e25c9bd5be155ef91fbded024e1ae81c4e137e66225c4b9cfba507e02 *arm-linux.elf/upx-3.95 b820cc3f17e200a8d1f6d27976361c3eb82c28169bb61bfee833b3ff789bb185 *arm-wince.pe/upx-3.91.exe -cbc7fff8f906ad74188f38b436950fc13a39046ac762f585cb230b8ae621c9f8 *arm64-linux.elf/upx-3.95 +0c38daef7ffda0f35f5e00abfb44a4398fa2295207c4deb4f8f7a58b025503e4 *arm64-linux.elf/upx-3.95 65b90c588af166d0cbcbfce1d6353c037121c4caa5e141f2436a11f31d3c949f *armeb-linux.elf/upx-3.91 1fe2d49a9249c0cb1cb9703cb64751ef687a6d6ff4cf2f833532a3bbbb08de08 *armeb-linux.elf/upx-3.95 bfd11228a09dbc7c1f2e2e1c5ec7cbf0b6d3c7c6c11d4bb62d031a447e2f1399 *i386-dos32.djgpp2.coff/upx-3.91.exe @@ -97,7 +97,7 @@ expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\ 97bb5953405f3413d9ff9bdc272caf2858697168b3e85dab54213da356b5ea0f *amd64-win64.pe/upx-3.95.exe c5e074540cae1d676f038f8e17e67856262e0990bdb961fdd9437e45c15e0dbd *arm-linux.elf/upx-3.95 53aa5cfc382c11fb0165fd70d3b86e958cd272d4f907af9d78c42bf55bf77911 *arm-wince.pe/upx-3.91.exe -6c44bba37b77083519fa6a3b530c5dd45726e455ff5dbdbdca2b8555c7683832 *arm64-linux.elf/upx-3.95 +4d7ba10f2310c88e92f82ec74afca55055b445e5cf5fd32318ed4374ebc8da84 *arm64-linux.elf/upx-3.95 b8f83b92e4e97c0d191f761726e1b5e85e1b806646f67f50c9a020579c3f7f23 *armeb-linux.elf/upx-3.91 aedab9a8684807f9ca209f6b4fa2997d22b9f733ad7179d90be36e3b7e117dfc *armeb-linux.elf/upx-3.95 c20263256b2819824804ab12f1ef0497165fc056b64dbeec65979e4f5da5f2c4 *i386-dos32.djgpp2.coff/upx-3.91.exe @@ -120,7 +120,7 @@ expected_sha256sums__t140_compress_lzma_2_no_filter="\ b8815f95e92d6853a04a86069e9054115be2d9aa657fa2c8912d0f37e56c894f *amd64-win64.pe/upx-3.95.exe abd068bb3cbebb573461e70146a18cd6ddb691a2bf589a0a2e735d87a3205ca5 *arm-linux.elf/upx-3.95 245970c83aaae44f58e9131bfdb444a52e85f1c55dbe6f81ac182608bd9b5949 *arm-wince.pe/upx-3.91.exe -97a5008adb9cdff02d862b06d6ff9317d1bce8a17a05e51b710412da3766448e *arm64-linux.elf/upx-3.95 +e5236063c1c692d0f3a34040e000590e8a4ff19b500a0b72070a2509e90bc4af *arm64-linux.elf/upx-3.95 62d4a79948ac7d4e010978102678805df9516b627315ffe9741886b318f525f0 *armeb-linux.elf/upx-3.91 0d266dcf92ab036baeb66a611d2302b7993416e4cebe2bd91b599c2fe46d3449 *armeb-linux.elf/upx-3.95 6e392e442af3de591fadef2b5d1dd454398e4e9cd04ee5bb391623c1a6fd2dbf *i386-dos32.djgpp2.coff/upx-3.91.exe @@ -143,7 +143,7 @@ f346b56b3ddded1429e5598d3b0d9290b69d1d95a006a3fe9a12d387e622ac02 *amd64-linux.el 434732efb16b89114162a1787a28c128e2c11edb9835411f2b707cac5cd475ae *amd64-win64.pe/upx-3.95.exe d0e5525b61791c58515d40aa073ff005b4f50e9f96072cb92ac7e57edaf00639 *arm-linux.elf/upx-3.95 6d641a40ed8563e8505fb1b5a3efa76319e4524858916a61efe606654c7001c4 *arm-wince.pe/upx-3.91.exe -be34369e9b29886d41a2aacfc12fa9d6c8223b076501a50af6cba7ccf4fb4fa1 *arm64-linux.elf/upx-3.95 +020a2d4773b7c6c8f5af78510ff35797c9a93c22210bf5de10b6c5aa8ae5e1be *arm64-linux.elf/upx-3.95 2b067cc3c42c7cea9d8ad39c04dc8b71e7dc720e41a26db4887433c5f6cef2ca *armeb-linux.elf/upx-3.91 ffe919f62e0e79b0f64331a37f94ff487097a3f8fbdc417db9849d1e43a93a34 *armeb-linux.elf/upx-3.95 f05a9c921b3a728a2baaf896fb95993a1ffd7c2cc3be26497c874a3ba023ec19 *i386-dos32.djgpp2.coff/upx-3.91.exe @@ -166,7 +166,7 @@ e9a365024a859d0c9678ca010e9a84b7bfedc599797d34fb6dc59a3bd38b0ce9 *amd64-linux.el f38ff7edc916c1a3e82020035667de858c89d52c98d960dad0e21b4da444ed6c *amd64-win64.pe/upx-3.95.exe d1b445bbe87207a29f113471d395a3441d0d6f4efa8dd7d68ee2b8b5266fb838 *arm-linux.elf/upx-3.95 20d7b538bb030ba3a1a29eb998ef6b2fcaabbe84d46d5fde71853d2224c2d1ec *arm-wince.pe/upx-3.91.exe -2feffdfc11f31102de874a7aa68bdaa8c046ad9cb49c6603a18f6a8493ce8304 *arm64-linux.elf/upx-3.95 +45e2012809d5103ba2e2242ba737eb504d32de2a03f4b7d54122b94e98889945 *arm64-linux.elf/upx-3.95 7b84ae933ea82892f9e9a5d4ee268c7aaa77a48290c89e64e794a472c034fb49 *armeb-linux.elf/upx-3.91 a10db43eaf25abeafa0bfc5c633b09b35f60a1f6470797674b9312c9cfdce1eb *armeb-linux.elf/upx-3.95 d7a93b38803d59f0540fca4d02516dda9a21cbbf989e9213f4bb8b6d639d630b *i386-dos32.djgpp2.coff/upx-3.91.exe @@ -189,7 +189,7 @@ e53bd5d25ad817c80b6f7e0c5cd3e4781d4a96c8de007e73f09ee51447530207 *amd64-linux.el 5fccb0f5044baaa74d176efb25eefa3b5810dc737ed0f9d38084d275f7ebe7b8 *amd64-win64.pe/upx-3.95.exe c2fe085c289ad4a06e4db9d53b7c7c1537307f21c87bcc20ea13f1352de806b5 *arm-linux.elf/upx-3.95 6c1ac767d302306509639ddb549253fe826f5e57677c29b0a431d98beababd3f *arm-wince.pe/upx-3.91.exe -f2cd40e55c70ee8f4767353139ba47fa792d77971fc09a0346d8f9c98c4f42e6 *arm64-linux.elf/upx-3.95 +fdc94198559e7efc96b413c3a8b93eef8de864708ca8952265043875b6bf19e1 *arm64-linux.elf/upx-3.95 7790f133d6b2d220b060c36e17ec961b1e1db27ce602a5399f202514aefa18fa *armeb-linux.elf/upx-3.91 faa7808665335846301b2b665fa9117b5ef94908f196583d62fa617f21620b93 *armeb-linux.elf/upx-3.95 9f5602f4d26213fdbfef6b35bcf0ed00b34f7ff2891b7e8e3e3047761c1f9e5c *i386-dos32.djgpp2.coff/upx-3.91.exe diff --git a/src/stub/arm64-linux.elf-fold.h b/src/stub/arm64-linux.elf-fold.h index 6080d980..e8c338de 100644 --- a/src/stub/arm64-linux.elf-fold.h +++ b/src/stub/arm64-linux.elf-fold.h @@ -33,8 +33,8 @@ /* clang-format off */ #define STUB_ARM64_LINUX_ELF_FOLD_SIZE 2852 -#define STUB_ARM64_LINUX_ELF_FOLD_ADLER32 0xb9c6e48c -#define STUB_ARM64_LINUX_ELF_FOLD_CRC32 0xc27414ca +#define STUB_ARM64_LINUX_ELF_FOLD_ADLER32 0x1b72e8b6 +#define STUB_ARM64_LINUX_ELF_FOLD_CRC32 0x4a6bb076 unsigned char stub_arm64_linux_elf_fold[2852] = { /* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -62,134 +62,134 @@ unsigned char stub_arm64_linux_elf_fold[2852] = { /* 0x0160 */ 2,132, 0,248,194,255,255,181, 34,132, 64,248, 2,132, 0,248, /* 0x0170 */ 194,255,255,181, 4, 32, 0,209, 31,132, 0,248,231, 3, 0,170, /* 0x0180 */ 246, 3, 0,170, 34, 12,193,168, 2, 12,129,168,194,255,255,181, -/* 0x0190 */ 247, 3, 0,170,225, 3, 0,170,129, 0, 0,249,194, 6, 0, 24, -/* 0x01a0 */ 34, 68, 0,184,226,255,129, 82,128, 6, 0, 16, 97, 0, 0,148, +/* 0x0190 */ 247, 3, 0,170,225, 3, 0,170,129, 0, 0,249,226, 6, 0, 24, +/* 0x01a0 */ 34, 68, 0,184,226,255,129, 82,160, 6, 0, 16, 98, 0, 0,148, /* 0x01b0 */ 31, 4, 64,177, 66, 0, 0, 84, 95,104, 32, 56,231, 3, 20,170, -/* 0x01c0 */ 230, 3, 25,170,255, 3, 48,209, 5, 6, 0, 16,228, 3, 24,170, +/* 0x01c0 */ 230, 3, 25,170,255, 3, 48,209, 37, 6, 0, 16,228, 3, 24,170, /* 0x01d0 */ 227, 3, 22,170,226, 3, 0,145,225, 3, 29, 42,224, 3, 28,170, /* 0x01e0 */ 247, 1, 0,148,255, 3, 48,145,248, 3, 0,170, 33, 83, 64,249, /* 0x01f0 */ 224, 3, 25,170, 34, 67, 64, 57, 95, 8, 0,113, 65, 0, 0, 84, -/* 0x0200 */ 65, 0, 0,148,224, 3, 25,170, 66, 0, 0,148, 5, 0,128,210, +/* 0x0200 */ 66, 0, 0,148,224, 3, 25,170, 67, 0, 0,148, 5, 0,128,210, /* 0x0210 */ 228, 3, 21, 42,159, 0, 0,113, 11, 1, 0, 84, 67, 0,128, 82, /* 0x0220 */ 34, 0,128, 82, 1, 0,130,210, 0, 0,128,210,174,255,255,151, -/* 0x0230 */ 224, 3, 21, 42, 46, 0, 0,148,254, 3, 24,170,224, 3, 26,170, +/* 0x0230 */ 224, 3, 21, 42, 47, 0, 0,148,254, 3, 24,170,224, 3, 26,170, /* 0x0240 */ 225, 3, 27, 42,226,130, 95,248,255,127,191,169,240, 3, 31,170, /* 0x0250 */ 227, 19, 64,169,230, 31, 64,169,232, 39, 64,169,244, 87, 64,169, -/* 0x0260 */ 246, 95, 64,169,248,103, 64,169,250,111, 64,169,252,119,193,168, -/* 0x0270 */ 192, 3, 95,214, 32, 32, 32, 61, 47,112,114,111, 99, 47,115,101, -/* 0x0280 */ 108,102, 47,101,120,101, 0, 0, 99, 28, 0, 18,127, 72, 1,113, -/* 0x0290 */ 129, 1, 0, 84, 33,252, 66,211, 65, 1, 0,180, 33, 4, 0,209, -/* 0x02a0 */ 2,120, 97,184, 67,120, 26, 83,127, 20, 0,113,129, 0, 0, 84, -/* 0x02b0 */ 67, 0, 1, 75, 98,100, 0, 51, 2,120, 33,184, 1,255,255,181, -/* 0x02c0 */ 192, 3, 95,214, 0, 0, 32,212,192, 3, 95,214,168, 11,128, 82, -/* 0x02d0 */ 1, 0, 0,212,232, 7,128, 82, 1, 0, 0,212,192, 3, 95,214, -/* 0x02e0 */ 8, 8,128, 82, 1, 0, 0,212,192, 3, 95,214, 40, 7,128, 82, -/* 0x02f0 */ 1, 0, 0,212,192, 3, 95,214,168, 21,128, 82, 1, 0, 0,212, -/* 0x0300 */ 192, 3, 95,214,200, 26,128, 82, 1, 0, 0,212,192, 3, 95,214, -/* 0x0310 */ 232, 26,128, 82, 1, 0, 0,212,192, 3, 95,214, 2, 0,128,210, -/* 0x0320 */ 225, 3, 0,170, 96, 12,128, 18,104, 4,128, 82, 4, 0, 0, 20, -/* 0x0330 */ 200, 9,128, 82, 2, 0, 0, 20, 8, 7,128, 82,227, 3, 2,170, -/* 0x0340 */ 226, 3, 1,170,225, 3, 0,170, 96, 12,128,146, 1, 0, 0,212, -/* 0x0350 */ 192, 3, 95,214, 0, 0, 64,212, 2, 0,128, 82, 8, 0,128, 82, -/* 0x0360 */ 1, 0, 0,212,192, 3, 95,214,253,123,191,169, 3, 0,128,210, -/* 0x0370 */ 253, 3, 0,145, 5, 0, 64,249, 4, 4, 64,249,191, 0, 2,235, -/* 0x0380 */ 98, 0, 0, 84,224, 15,128, 82,209,255,255,151,127, 0, 2,235, -/* 0x0390 */ 160, 0, 0, 84,133,104, 99, 56, 37,104, 35, 56, 99, 4, 0,145, -/* 0x03a0 */ 251,255,255, 23, 1, 4, 64,249, 33, 0, 3,139, 1, 4, 0,249, -/* 0x03b0 */ 1, 0, 64,249, 35, 0, 3,203, 3, 0, 0,249,253,123,193,168, -/* 0x03c0 */ 192, 3, 95,214,253,123,187,169,253, 3, 0,145,243, 83, 1,169, -/* 0x03d0 */ 245, 91, 2,169,244, 3, 0,170,243, 3, 1,170,246, 3, 2,170, -/* 0x03e0 */ 245, 3, 3,170, 96, 2, 64,249,160, 8, 0,180,224, 3, 20,170, -/* 0x03f0 */ 130, 1,128,210,161, 3, 1,145,220,255,255,151,160, 67, 64,185, -/* 0x0400 */ 162, 71, 64,185, 0, 1, 0, 53,160, 10,138, 82, 0, 43,164,114, -/* 0x0410 */ 95, 0, 0,107,225, 0, 0, 84,128, 2, 64,249, 0, 7, 0,180, -/* 0x0420 */ 4, 0, 0, 20, 98, 0, 0, 52, 95, 0, 0,107,105, 0, 0, 84, -/* 0x0430 */ 224, 15,128, 82,166,255,255,151, 99, 2, 64,249,225, 3, 0, 42, -/* 0x0440 */ 63, 0, 3,235,104,255,255, 84, 95, 0, 0,107, 2, 4, 0, 84, -/* 0x0450 */ 161, 31, 0,249,225, 3, 2, 42,128, 6, 64,249,163,227, 0,145, -/* 0x0460 */ 98, 6, 64,249,164, 35, 65, 57,192, 2, 63,214, 32,254,255, 53, -/* 0x0470 */ 161, 31, 64,249,160, 67, 64,185, 63, 0, 0,235,161,253,255, 84, -/* 0x0480 */ 163, 39, 65, 57, 85, 1, 0,180, 35, 1, 0, 52, 63, 0, 8,241, -/* 0x0490 */ 136, 0, 0, 84, 96, 2, 64,249, 31, 0, 1,235,129, 0, 0, 84, -/* 0x04a0 */ 96, 6, 64,249,162, 43, 65, 57,160, 2, 63,214,163, 71, 64,185, -/* 0x04b0 */ 129, 6, 64,249,128, 2, 64,249, 33, 0, 3,139,129, 6, 0,249, -/* 0x04c0 */ 0, 0, 3,203,128, 2, 0,249, 5, 0, 0, 20, 97, 6, 64,249, -/* 0x04d0 */ 224, 3, 20,170,226, 3, 2, 42,164,255,255,151,163, 67, 64,185, -/* 0x04e0 */ 97, 6, 64,249, 96, 2, 64,249, 33, 0, 3,139, 97, 6, 0,249, -/* 0x04f0 */ 0, 0, 3,203, 96, 2, 0,249,187,255,255, 23,243, 83, 65,169, -/* 0x0500 */ 245, 91, 66,169,253,123,197,168,192, 3, 95,214, 0, 2, 0,180, -/* 0x0510 */ 224, 1, 0, 55,228, 3, 1, 42, 3, 0, 64,249,127, 0, 4,235, -/* 0x0520 */ 129, 0, 0, 84, 4, 0, 0,249, 2, 4, 0,249, 8, 0, 0, 20, -/* 0x0530 */ 127, 4, 0,241, 97, 0, 0, 84, 97, 0, 0, 52,250,255,255, 23, -/* 0x0540 */ 99, 0, 0,180, 0, 64, 0,145,244,255,255, 23,192, 3, 95,214, -/* 0x0550 */ 253,123,181,169,253, 3, 0,145,232, 39, 6,109,201, 0,103,158, -/* 0x0560 */ 6, 16, 64,249,236, 55, 8,109,245, 91, 2,169,238, 63, 9,109, -/* 0x0570 */ 246, 3, 0,170,234, 47, 7,109,251,115, 5,169, 28, 0, 6,139, -/* 0x0580 */ 245, 3, 1,170, 32, 1,102,158,249,107, 4,169,243, 83, 1,169, -/* 0x0590 */ 247, 99, 3,169, 76, 0, 39, 30,250, 3, 3,170,141, 0,103,158, -/* 0x05a0 */ 249, 3, 7,170,174, 0,103,158, 2, 0, 64,249,195, 34, 64,121, -/* 0x05b0 */ 65, 2, 0,180, 65, 16, 64,249,127, 8, 0,113, 65, 0, 1,139, -/* 0x05c0 */ 32, 36, 64,249, 64, 0, 0,203, 65, 0, 0, 84, 32, 8, 64,249, -/* 0x05d0 */ 33, 20, 64,249, 2, 0,128, 82, 67, 6,128, 82, 4, 0,128, 18, -/* 0x05e0 */ 5, 0,128,210,192,254,255,151,193, 34, 64,121, 63, 8, 0,113, -/* 0x05f0 */ 19, 16,159,154, 42, 0, 0, 20,127, 12, 0,113, 3, 2,128, 82, -/* 0x0600 */ 99, 16,159, 26,199,114, 64,121,224, 3, 2,170, 99,136, 0, 17, -/* 0x0610 */ 228, 3, 28,170, 19, 0,128,146,231, 4, 0, 81,255, 4, 0, 49, -/* 0x0620 */ 160, 1, 0, 84,133, 0, 64,185,191, 4, 0,113, 1, 1, 0, 84, -/* 0x0630 */ 136, 8, 64,249,133, 20, 64,249,127, 2, 8,235, 5, 1, 5,139, -/* 0x0640 */ 115,146,136,154, 63, 0, 5,235, 33, 32,133,154,132,224, 0,145, -/* 0x0650 */ 242,255,255, 23,228, 3, 57,170,115, 2, 25,138,129, 0, 1,139, -/* 0x0660 */ 33, 0, 19,203, 33, 0, 25,138,163, 0, 32, 55, 83, 0, 0,181, -/* 0x0670 */ 162, 0, 0,181, 0, 0,128,210, 4, 0, 0, 20,224, 3, 19,170, -/* 0x0680 */ 2, 0, 0, 20, 67, 6,128, 82, 2, 0,128, 82, 4, 0,128, 18, -/* 0x0690 */ 5, 0,128,210,148,254,255,151, 19, 0, 19,203,224, 3, 57, 42, -/* 0x06a0 */ 232, 3, 39, 30, 10, 0, 39, 30,224, 3, 57,170, 15, 0,103,158, -/* 0x06b0 */ 1, 1, 38, 30,192,114, 64,121, 63, 0, 0,107,138, 21, 0, 84, -/* 0x06c0 */ 128, 3, 64,185, 53, 1, 0,180, 31, 24, 0,113,225, 0, 0, 84, -/* 0x06d0 */ 130, 11, 64,249,224, 3, 26,170, 97, 0,128, 82, 98, 2, 2,139, -/* 0x06e0 */ 139,255,255,151,157, 0, 0, 20, 31, 4, 0,113, 97, 19, 0, 84, -/* 0x06f0 */ 128, 23, 64,249, 32, 19, 0,180,155, 7, 64,185, 0, 72,140, 82, -/* 0x0700 */ 32,106,174,114,123, 11, 30, 83, 27, 36,219, 26,121, 11, 0, 18, -/* 0x0710 */ 85, 2, 0,180,128, 7, 64,249, 0, 2, 0,181,194, 18, 64,249, -/* 0x0720 */ 224, 3, 26,170,131, 11, 64,249, 97, 0,128, 82, 98, 2, 2,139, -/* 0x0730 */ 66, 0, 3,139,118,255,255,151,194,114, 64,121,224, 3, 26,170, -/* 0x0740 */ 161, 0,128, 82,114,255,255,151,194,110, 64,121,224, 3, 26,170, -/* 0x0750 */ 129, 0,128, 82,110,255,255,151,148, 11, 64,249,191, 2, 31,235, -/* 0x0760 */ 128, 23, 64,249,130, 0,128, 18,116, 2, 20,139,151, 19, 64,249, -/* 0x0770 */ 128, 2, 0,139,183, 83, 0,249,225, 1,102,158,180, 87, 0,249, -/* 0x0780 */ 11, 0,103,158,152, 2, 23,139, 64, 1, 38, 30,135, 7, 64,249, -/* 0x0790 */ 72, 6,128, 82, 5, 0, 20, 10,148, 2, 5,203,183, 0, 23,139, -/* 0x07a0 */ 128, 2, 23,139,229, 0, 5,203,224, 3, 0,203, 0, 0, 1,138, -/* 0x07b0 */ 23, 0, 23,139, 64, 0,128, 82, 3, 16,159, 26,191, 2, 31,235, -/* 0x07c0 */ 128, 1, 38, 30, 99, 0, 25, 42, 66, 16,159, 90,191, 2, 31,235, -/* 0x07d0 */ 66, 0, 3, 10, 67, 2,128, 82,225, 3, 23,170, 4, 0,159, 90, -/* 0x07e0 */ 191, 2, 31,235, 3, 17,131, 26,224, 3, 20,170, 62,254,255,151, -/* 0x07f0 */ 159, 2, 0,235, 96, 0, 0, 84,224, 15,128, 82,180,254,255,151, -/* 0x0800 */ 213, 0, 0,180,162, 1,102,158,224, 3, 21,170,195, 1,102,158, -/* 0x0810 */ 161,131, 2,145,236,254,255,151,187, 1, 8, 54, 64, 1, 38, 30, -/* 0x0820 */ 225, 3, 24, 75, 34, 0, 0, 10, 0, 0,128,210, 98, 0, 0, 53, -/* 0x0830 */ 24, 3, 2,139, 6, 0, 0, 20, 31,107, 32, 56, 0, 4, 0,145, -/* 0x0840 */ 31, 0, 2,235,161,255,255, 84,250,255,255, 23,213, 6, 0,180, -/* 0x0850 */ 128, 3, 64,249,225, 3, 0,178, 0,128, 64,146, 31, 0, 1,235, -/* 0x0860 */ 129, 5, 0, 84,128, 23, 64,249,130, 19, 64,249,129, 11, 64,249, -/* 0x0870 */ 31, 0, 2,235,129, 1, 0, 84,123, 14, 0,145,123, 3, 0,139, -/* 0x0880 */ 66, 1, 38, 30,123, 3, 1,139,123,247,126,146,224, 3, 27, 75, -/* 0x0890 */ 0, 0, 2, 10, 31, 28, 0,113,105, 0, 0, 84, 0, 0,128, 82, -/* 0x08a0 */ 13, 0, 0, 20,128, 7, 64,249,160, 6, 0,180, 0, 0,128,210, -/* 0x08b0 */ 1, 0,130,210, 98, 0,128, 82, 67, 4,128, 82, 4, 0,128, 18, -/* 0x08c0 */ 229, 3, 0,170, 8,254,255,151,251, 3, 0,170, 32, 2, 0,180, -/* 0x08d0 */ 32, 0,128, 82, 33, 0,128, 82, 1,128,186,114, 97, 3, 0,185, -/* 0x08e0 */ 1,120,128, 82,225,203,186,114, 97, 7, 0,185,160, 0, 0, 52, -/* 0x08f0 */ 224, 3, 27,170, 1, 1,128,210,162, 0,128, 82, 1,254,255,151, -/* 0x0900 */ 64,251,127,146, 1, 0,128, 82,226, 3, 27,170, 0,255,255,151, -/* 0x0910 */ 224, 3, 20,170,225, 3, 23,170,226, 3, 25, 42,249,253,255,151, -/* 0x0920 */ 192,246,255, 53, 96, 1,102,158, 31, 3, 0,235, 98, 1, 0, 84, -/* 0x0930 */ 97, 1,102,158,224, 3, 24,170,226, 3, 25, 42, 67, 6,128, 82, -/* 0x0940 */ 4, 0,128, 18, 5, 0,128,210, 33, 0, 24,203,230,253,255,151, -/* 0x0950 */ 31, 3, 0,235, 33,245,255, 84, 0, 1, 38, 30,156,227, 0,145, -/* 0x0960 */ 0, 4, 0, 17, 8, 0, 39, 30, 82,255,255, 23, 32, 1,102,158, -/* 0x0970 */ 192, 0, 0,180, 19, 0, 0,249, 4, 0, 0, 20, 59, 0, 19,139, -/* 0x0980 */ 123, 35, 0,145,212,255,255, 23,192, 14, 64,249,232, 39, 70,109, +/* 0x0260 */ 246, 95, 64,169,248,103, 64,169,250,111, 64,169,252,119, 64,169, +/* 0x0270 */ 224, 7,193,168,192, 3, 95,214, 32, 32, 32, 61, 47,112,114,111, +/* 0x0280 */ 99, 47,115,101,108,102, 47,101,120,101, 0, 0, 99, 28, 0, 18, +/* 0x0290 */ 127, 72, 1,113,129, 1, 0, 84, 33,252, 66,211, 65, 1, 0,180, +/* 0x02a0 */ 33, 4, 0,209, 2,120, 97,184, 67,120, 26, 83,127, 20, 0,113, +/* 0x02b0 */ 129, 0, 0, 84, 67, 0, 1, 75, 98,100, 0, 51, 2,120, 33,184, +/* 0x02c0 */ 1,255,255,181,192, 3, 95,214, 0, 0, 32,212,192, 3, 95,214, +/* 0x02d0 */ 168, 11,128, 82, 1, 0, 0,212,232, 7,128, 82, 1, 0, 0,212, +/* 0x02e0 */ 192, 3, 95,214, 8, 8,128, 82, 1, 0, 0,212,192, 3, 95,214, +/* 0x02f0 */ 40, 7,128, 82, 1, 0, 0,212,192, 3, 95,214,168, 21,128, 82, +/* 0x0300 */ 1, 0, 0,212,192, 3, 95,214,200, 26,128, 82, 1, 0, 0,212, +/* 0x0310 */ 192, 3, 95,214,232, 26,128, 82, 1, 0, 0,212,192, 3, 95,214, +/* 0x0320 */ 2, 0,128,210,225, 3, 0,170, 96, 12,128, 18,104, 4,128, 82, +/* 0x0330 */ 4, 0, 0, 20,200, 9,128, 82, 2, 0, 0, 20, 8, 7,128, 82, +/* 0x0340 */ 227, 3, 2,170,226, 3, 1,170,225, 3, 0,170, 96, 12,128,146, +/* 0x0350 */ 1, 0, 0,212,192, 3, 95,214, 0, 0, 64,212, 2, 0,128, 82, +/* 0x0360 */ 8, 0,128, 82, 1, 0, 0,212,192, 3, 95,214,253,123,191,169, +/* 0x0370 */ 3, 0,128,210,253, 3, 0,145, 5, 0, 64,249, 4, 4, 64,249, +/* 0x0380 */ 191, 0, 2,235, 98, 0, 0, 84,224, 15,128, 82,209,255,255,151, +/* 0x0390 */ 127, 0, 2,235,160, 0, 0, 84,133,104, 99, 56, 37,104, 35, 56, +/* 0x03a0 */ 99, 4, 0,145,251,255,255, 23, 1, 4, 64,249, 33, 0, 3,139, +/* 0x03b0 */ 1, 4, 0,249, 1, 0, 64,249, 35, 0, 3,203, 3, 0, 0,249, +/* 0x03c0 */ 253,123,193,168,192, 3, 95,214,253,123,187,169,253, 3, 0,145, +/* 0x03d0 */ 243, 83, 1,169,245, 91, 2,169,244, 3, 0,170,243, 3, 1,170, +/* 0x03e0 */ 246, 3, 2,170,245, 3, 3,170, 96, 2, 64,249,160, 8, 0,180, +/* 0x03f0 */ 224, 3, 20,170,130, 1,128,210,161, 3, 1,145,220,255,255,151, +/* 0x0400 */ 160, 67, 64,185,162, 71, 64,185, 0, 1, 0, 53,160, 10,138, 82, +/* 0x0410 */ 0, 43,164,114, 95, 0, 0,107,225, 0, 0, 84,128, 2, 64,249, +/* 0x0420 */ 0, 7, 0,180, 4, 0, 0, 20, 98, 0, 0, 52, 95, 0, 0,107, +/* 0x0430 */ 105, 0, 0, 84,224, 15,128, 82,166,255,255,151, 99, 2, 64,249, +/* 0x0440 */ 225, 3, 0, 42, 63, 0, 3,235,104,255,255, 84, 95, 0, 0,107, +/* 0x0450 */ 2, 4, 0, 84,161, 31, 0,249,225, 3, 2, 42,128, 6, 64,249, +/* 0x0460 */ 163,227, 0,145, 98, 6, 64,249,164, 35, 65, 57,192, 2, 63,214, +/* 0x0470 */ 32,254,255, 53,161, 31, 64,249,160, 67, 64,185, 63, 0, 0,235, +/* 0x0480 */ 161,253,255, 84,163, 39, 65, 57, 85, 1, 0,180, 35, 1, 0, 52, +/* 0x0490 */ 63, 0, 8,241,136, 0, 0, 84, 96, 2, 64,249, 31, 0, 1,235, +/* 0x04a0 */ 129, 0, 0, 84, 96, 6, 64,249,162, 43, 65, 57,160, 2, 63,214, +/* 0x04b0 */ 163, 71, 64,185,129, 6, 64,249,128, 2, 64,249, 33, 0, 3,139, +/* 0x04c0 */ 129, 6, 0,249, 0, 0, 3,203,128, 2, 0,249, 5, 0, 0, 20, +/* 0x04d0 */ 97, 6, 64,249,224, 3, 20,170,226, 3, 2, 42,164,255,255,151, +/* 0x04e0 */ 163, 67, 64,185, 97, 6, 64,249, 96, 2, 64,249, 33, 0, 3,139, +/* 0x04f0 */ 97, 6, 0,249, 0, 0, 3,203, 96, 2, 0,249,187,255,255, 23, +/* 0x0500 */ 243, 83, 65,169,245, 91, 66,169,253,123,197,168,192, 3, 95,214, +/* 0x0510 */ 0, 2, 0,180,224, 1, 0, 55,228, 3, 1, 42, 3, 0, 64,249, +/* 0x0520 */ 127, 0, 4,235,129, 0, 0, 84, 4, 0, 0,249, 2, 4, 0,249, +/* 0x0530 */ 8, 0, 0, 20,127, 4, 0,241, 97, 0, 0, 84, 97, 0, 0, 52, +/* 0x0540 */ 250,255,255, 23, 99, 0, 0,180, 0, 64, 0,145,244,255,255, 23, +/* 0x0550 */ 192, 3, 95,214,253,123,181,169,253, 3, 0,145,232, 39, 6,109, +/* 0x0560 */ 201, 0,103,158, 6, 16, 64,249,236, 55, 8,109,245, 91, 2,169, +/* 0x0570 */ 238, 63, 9,109,246, 3, 0,170,234, 47, 7,109,251,115, 5,169, +/* 0x0580 */ 28, 0, 6,139,245, 3, 1,170, 32, 1,102,158,249,107, 4,169, +/* 0x0590 */ 243, 83, 1,169,247, 99, 3,169, 76, 0, 39, 30,250, 3, 3,170, +/* 0x05a0 */ 141, 0,103,158,249, 3, 7,170,174, 0,103,158, 2, 0, 64,249, +/* 0x05b0 */ 195, 34, 64,121, 65, 2, 0,180, 65, 16, 64,249,127, 8, 0,113, +/* 0x05c0 */ 65, 0, 1,139, 32, 36, 64,249, 64, 0, 0,203, 65, 0, 0, 84, +/* 0x05d0 */ 32, 8, 64,249, 33, 20, 64,249, 2, 0,128, 82, 67, 6,128, 82, +/* 0x05e0 */ 4, 0,128, 18, 5, 0,128,210,191,254,255,151,193, 34, 64,121, +/* 0x05f0 */ 63, 8, 0,113, 19, 16,159,154, 42, 0, 0, 20,127, 12, 0,113, +/* 0x0600 */ 3, 2,128, 82, 99, 16,159, 26,199,114, 64,121,224, 3, 2,170, +/* 0x0610 */ 99,136, 0, 17,228, 3, 28,170, 19, 0,128,146,231, 4, 0, 81, +/* 0x0620 */ 255, 4, 0, 49,160, 1, 0, 84,133, 0, 64,185,191, 4, 0,113, +/* 0x0630 */ 1, 1, 0, 84,136, 8, 64,249,133, 20, 64,249,127, 2, 8,235, +/* 0x0640 */ 5, 1, 5,139,115,146,136,154, 63, 0, 5,235, 33, 32,133,154, +/* 0x0650 */ 132,224, 0,145,242,255,255, 23,228, 3, 57,170,115, 2, 25,138, +/* 0x0660 */ 129, 0, 1,139, 33, 0, 19,203, 33, 0, 25,138,163, 0, 32, 55, +/* 0x0670 */ 83, 0, 0,181,162, 0, 0,181, 0, 0,128,210, 4, 0, 0, 20, +/* 0x0680 */ 224, 3, 19,170, 2, 0, 0, 20, 67, 6,128, 82, 2, 0,128, 82, +/* 0x0690 */ 4, 0,128, 18, 5, 0,128,210,147,254,255,151, 19, 0, 19,203, +/* 0x06a0 */ 224, 3, 57, 42,232, 3, 39, 30, 10, 0, 39, 30,224, 3, 57,170, +/* 0x06b0 */ 15, 0,103,158, 1, 1, 38, 30,192,114, 64,121, 63, 0, 0,107, +/* 0x06c0 */ 42, 21, 0, 84,128, 3, 64,185, 53, 1, 0,180, 31, 24, 0,113, +/* 0x06d0 */ 225, 0, 0, 84,130, 11, 64,249,224, 3, 26,170, 97, 0,128, 82, +/* 0x06e0 */ 98, 2, 2,139,139,255,255,151,154, 0, 0, 20, 31, 4, 0,113, +/* 0x06f0 */ 1, 19, 0, 84,128, 23, 64,249,192, 18, 0,180,155, 7, 64,185, +/* 0x0700 */ 0, 72,140, 82, 32,106,174,114,123, 11, 30, 83, 27, 36,219, 26, +/* 0x0710 */ 121, 11, 0, 18, 85, 2, 0,180,128, 7, 64,249, 0, 2, 0,181, +/* 0x0720 */ 194, 18, 64,249,224, 3, 26,170,131, 11, 64,249, 97, 0,128, 82, +/* 0x0730 */ 98, 2, 2,139, 66, 0, 3,139,118,255,255,151,194,114, 64,121, +/* 0x0740 */ 224, 3, 26,170,161, 0,128, 82,114,255,255,151,194,110, 64,121, +/* 0x0750 */ 224, 3, 26,170,129, 0,128, 82,110,255,255,151,148, 11, 64,249, +/* 0x0760 */ 191, 2, 31,235,128, 23, 64,249,130, 0,128, 18,116, 2, 20,139, +/* 0x0770 */ 151, 19, 64,249,128, 2, 0,139,183, 83, 0,249,225, 1,102,158, +/* 0x0780 */ 180, 87, 0,249, 11, 0,103,158,152, 2, 23,139, 64, 1, 38, 30, +/* 0x0790 */ 135, 7, 64,249, 67, 6,128, 82, 5, 0, 20, 10,148, 2, 5,203, +/* 0x07a0 */ 183, 0, 23,139,128, 2, 23,139,229, 0, 5,203,224, 3, 0,203, +/* 0x07b0 */ 0, 0, 1,138, 23, 0, 23,139, 64, 0,128, 82, 4, 16,159, 26, +/* 0x07c0 */ 191, 2, 31,235,132, 0, 25, 42, 66, 16,159, 90, 66, 0, 4, 10, +/* 0x07d0 */ 191, 2, 31,235,132, 1, 38, 30, 64, 2,128, 82, 3, 0,131, 26, +/* 0x07e0 */ 191, 2, 31,235,224, 3, 20,170,225, 3, 23,170,132, 0,159, 90, +/* 0x07f0 */ 61,254,255,151,159, 2, 0,235, 96, 0, 0, 84,224, 15,128, 82, +/* 0x0800 */ 180,254,255,151,213, 0, 0,180,162, 1,102,158,224, 3, 21,170, +/* 0x0810 */ 195, 1,102,158,161,131, 2,145,236,254,255,151,187, 1, 8, 54, +/* 0x0820 */ 64, 1, 38, 30,225, 3, 24, 75, 34, 0, 0, 10, 0, 0,128,210, +/* 0x0830 */ 98, 0, 0, 53, 24, 3, 2,139, 6, 0, 0, 20, 31,107, 32, 56, +/* 0x0840 */ 0, 4, 0,145, 31, 0, 2,235,161,255,255, 84,250,255,255, 23, +/* 0x0850 */ 117, 6, 0,180,128, 3, 64,249,225, 3, 0,178, 0,128, 64,146, +/* 0x0860 */ 31, 0, 1,235, 33, 5, 0, 84,155, 23, 64,249,129, 19, 64,249, +/* 0x0870 */ 128, 11, 64,249,127, 3, 1,235, 65, 3, 0, 84, 97, 14, 0,145, +/* 0x0880 */ 59, 0, 27,139, 65, 1, 38, 30,123, 3, 0,139,123,247,126,146, +/* 0x0890 */ 224, 3, 27, 75, 0, 0, 1, 10, 31, 44, 0,113, 41, 2, 0, 84, +/* 0x08a0 */ 0, 0,128, 82, 33, 0,128, 82, 1,128,186,114, 97, 3, 0,185, +/* 0x08b0 */ 1,252,128, 82, 33, 24,181,114, 97, 7, 0,185, 1,120,128, 82, +/* 0x08c0 */ 225,203,186,114, 97, 11, 0,185, 96, 5, 0, 52,224, 3, 27,170, +/* 0x08d0 */ 129, 1,128,210,162, 0,128, 82, 10,254,255,151, 38, 0, 0, 20, +/* 0x08e0 */ 0, 0,128,210, 1, 0,130,210, 98, 0,128, 82, 67, 4,128, 82, +/* 0x08f0 */ 4, 0,128, 18,229, 3, 0,170,251,253,255,151,251, 3, 0,170, +/* 0x0900 */ 32, 0,128, 82, 27,253,255,181,224, 3, 20,170,225, 3, 23,170, +/* 0x0910 */ 226, 3, 25, 42,251,253,255,151, 32,247,255, 53, 96, 1,102,158, +/* 0x0920 */ 31, 3, 0,235, 98, 1, 0, 84, 97, 1,102,158,224, 3, 24,170, +/* 0x0930 */ 226, 3, 25, 42, 67, 6,128, 82, 4, 0,128, 18, 5, 0,128,210, +/* 0x0940 */ 33, 0, 24,203,232,253,255,151, 31, 3, 0,235,129,245,255, 84, +/* 0x0950 */ 0, 1, 38, 30,156,227, 0,145, 0, 4, 0, 17, 8, 0, 39, 30, +/* 0x0960 */ 85,255,255, 23, 32, 1,102,158, 0, 1, 0,180, 19, 0, 0,249, +/* 0x0970 */ 6, 0, 0, 20, 64,251,127,146, 1, 0,128, 82,226, 3, 27,170, +/* 0x0980 */ 228,254,255,151,225,255,255, 23,192, 14, 64,249,232, 39, 70,109, /* 0x0990 */ 245, 91, 66,169,234, 47, 71,109, 96, 2, 0,139,236, 55, 72,109, /* 0x09a0 */ 243, 83, 65,169,238, 63, 73,109,247, 99, 67,169,249,107, 68,169, /* 0x09b0 */ 251,115, 69,169,253,123,203,168,192, 3, 95,214,253,123,182,169, @@ -199,20 +199,20 @@ unsigned char stub_arm64_linux_elf_fold[2852] = { /* 0x09f0 */ 116, 2, 1,145,163, 75, 0,249, 3, 0,128,210,160, 71, 0,249, /* 0x0a00 */ 160, 67, 2,145,161, 67, 0,249,161,195, 1,145,245, 91, 2,169, /* 0x0a10 */ 249, 35, 0,249,249, 3, 7,170,165, 47, 0,249, 22, 0,128, 82, -/* 0x0a20 */ 166, 55, 0,249,164, 51, 0,249,103,254,255,151,164, 51, 64,249, +/* 0x0a20 */ 166, 55, 0,249,164, 51, 0,249,104,254,255,151,164, 51, 64,249, /* 0x0a30 */ 161, 3, 2,145,165, 47, 64,249, 2, 0,128, 82,227, 3, 23,170, -/* 0x0a40 */ 166,163, 1,145,231, 3, 25,170,224, 3, 19,170,193,254,255,151, +/* 0x0a40 */ 166,163, 1,145,231, 3, 25,170,224, 3, 19,170,194,254,255,151, /* 0x0a50 */ 245, 3, 0,170, 33, 1,128, 82,224, 3, 23,170,226, 3, 21,170, -/* 0x0a60 */ 171,254,255,151, 96,114, 64,121,223, 2, 0,107,226, 4, 0, 84, +/* 0x0a60 */ 172,254,255,151, 96,114, 64,121,223, 2, 0,107,226, 4, 0, 84, /* 0x0a70 */ 128, 2, 64,185, 31, 12, 0,113, 33, 4, 0, 84,129, 10, 64,249, /* 0x0a80 */ 160, 55, 64,249, 32, 0, 0,139, 1, 0,128, 82,226, 3, 1, 42, -/* 0x0a90 */ 42,254,255,151,248, 3, 0, 42, 96, 0,248, 54,224, 15,128, 82, -/* 0x0aa0 */ 11,254,255,151,225, 3, 19,170, 2,128,128,210, 10,254,255,151, +/* 0x0a90 */ 43,254,255,151,248, 3, 0, 42, 96, 0,248, 54,224, 15,128, 82, +/* 0x0aa0 */ 12,254,255,151,225, 3, 19,170, 2,128,128,210, 11,254,255,151, /* 0x0ab0 */ 31, 0, 16,241, 65,255,255, 84, 1, 0,128,210,226, 3, 24, 42, /* 0x0ac0 */ 227, 3, 1,170,228, 3, 1,170,229, 3, 1,170,166,163, 1,145, -/* 0x0ad0 */ 231, 3, 25,170,224, 3, 19,170,191, 55, 0,249,157,254,255,151, +/* 0x0ad0 */ 231, 3, 25,170,224, 3, 19,170,191, 55, 0,249,158,254,255,151, /* 0x0ae0 */ 245, 3, 0,170,162, 55, 64,249,224, 3, 23,170,225, 0,128, 82, -/* 0x0af0 */ 135,254,255,151,224, 3, 24, 42,253,253,255,151,148,226, 0,145, +/* 0x0af0 */ 136,254,255,151,224, 3, 24, 42,254,253,255,151,148,226, 0,145, /* 0x0b00 */ 214, 6, 0, 17,216,255,255, 23,224, 3, 21,170,249, 35, 64,249, /* 0x0b10 */ 243, 83, 65,169,245, 91, 66,169,247, 99, 67,169,253,123,202,168, /* 0x0b20 */ 192, 3, 95,214 diff --git a/src/stub/src/amd64-linux.elf-main.c b/src/stub/src/amd64-linux.elf-main.c index 98bc792c..73015109 100644 --- a/src/stub/src/amd64-linux.elf-main.c +++ b/src/stub/src/amd64-linux.elf-main.c @@ -308,6 +308,8 @@ make_hatch_ppc64( return hatch; } #elif defined(__aarch64__) //{ +#define NBPI 4 +#define NINSTR 3 static void * make_hatch_arm64( Elf64_Phdr const *const phdr, @@ -331,19 +333,17 @@ make_hatch_arm64( // Try page fragmentation just beyond .text . ( (hatch = (void *)(~3ul & (3+ phdr->p_memsz + phdr->p_vaddr + reloc))), ( phdr->p_memsz==phdr->p_filesz // don't pollute potential .bss - && (2*4)<=(frag_mask & -(int)(uint64_t)hatch) ) ) // space left on page - // Try Elf64_Ehdr.e_ident[8..15] . warning: 'const' cast away - || ( (hatch = (void *)(&((Elf64_Ehdr *)(phdr->p_vaddr + reloc))->e_ident[8])), - (phdr->p_offset==0) ) + && (NINSTR*NBPI)<=(frag_mask & -(int)(uint64_t)hatch) ) ) // space left on page // Allocate and use a new page. || ( xprot = 1, hatch = mmap(0, 1<<12, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) ) ) { - hatch[0] = 0xd4000001; // svc #0 - hatch[1] = 0xd65f03c0; // ret (jmp *lr) + hatch[0] = 0xd4000001; // svc #0; # {addr,len,__NR_munmap} already in {x0,x1,w8} + hatch[1] = 0xa8c107e0; // ldp x0,x1,[sp],#2*NBPI # ABI owns x0? + hatch[2] = 0xd65f03c0; // ret (jmp *lr) if (xprot) { - Pprotect(hatch, 2*sizeof(unsigned), PROT_EXEC|PROT_READ); + Pprotect(hatch, NINSTR*sizeof(unsigned), PROT_EXEC|PROT_READ); } } else { @@ -353,6 +353,8 @@ make_hatch_arm64( DPRINTF("hatch=%%p\n", hatch); return hatch; } +#undef NBPI +#undef NINSTR #endif //} #if defined(__powerpc64__) || defined(__aarch64__) //{ bzero diff --git a/src/stub/src/arm64-linux.elf-fold.S b/src/stub/src/arm64-linux.elf-fold.S index b4999c73..e72e6a78 100644 --- a/src/stub/src/arm64-linux.elf-fold.S +++ b/src/stub/src/arm64-linux.elf-fold.S @@ -240,7 +240,7 @@ no_map_pse: ldp x22,x23,[sp,#0] ldp x24,x25,[sp,#0] ldp x26,x27,[sp,#0] - ldp x28,x29,[sp],#2*NBPW + ldp x28,x29,[sp] // leave 2 zero-words on-stack for popping into x0,x1 #if DEBUG //{ ldr w3,[x2,#0] // 1st instr @@ -285,6 +285,7 @@ no_map_pse: // fpsr 0x0 0x0 // fpcr 0x0 0x0 // (gdb) + ldp x0,x1,[sp],#2*NBPW // ABI owns x0? ret // "br lr"; just enter ld-linux, omitting the munmap of unfolded stub #else //}{ This should work, but fails intermittently mov w8,#__NR_munmap // munmap(ADRU, LENU) unfolded stub diff --git a/src/stub/tmp/arm64-linux.elf-fold.map b/src/stub/tmp/arm64-linux.elf-fold.map index 38fd1397..c0f347cd 100644 --- a/src/stub/tmp/arm64-linux.elf-fold.map +++ b/src/stub/tmp/arm64-linux.elf-fold.map @@ -10,25 +10,25 @@ Linker script and memory map .text 0x00000000001000bc 0xa68 *(.text) - .text 0x00000000001000bc 0x2ac tmp/arm64-linux.elf-fold.o + .text 0x00000000001000bc 0x2b0 tmp/arm64-linux.elf-fold.o 0x00000000001000c4 get_page_mask 0x00000000001000d4 mmap_privanon 0x00000000001000e4 mmap 0x0000000000100100 Pprotect 0x0000000000100100 mprotect - 0x00000000001002c4 my_bkpt - 0x00000000001002cc exit - 0x00000000001002d4 read - 0x00000000001002e0 write - 0x00000000001002ec close - 0x00000000001002f8 getpid - 0x0000000000100304 brk - 0x0000000000100310 munmap - 0x000000000010031c unlink - 0x0000000000100330 readlink - 0x0000000000100338 open - 0x0000000000100354 __clear_cache - .text 0x0000000000100368 0x7bc tmp/arm64-linux.elf-main.o + 0x00000000001002c8 my_bkpt + 0x00000000001002d0 exit + 0x00000000001002d8 read + 0x00000000001002e4 write + 0x00000000001002f0 close + 0x00000000001002fc getpid + 0x0000000000100308 brk + 0x0000000000100314 munmap + 0x0000000000100320 unlink + 0x0000000000100334 readlink + 0x000000000010033c open + 0x0000000000100358 __clear_cache + .text 0x000000000010036c 0x7b8 tmp/arm64-linux.elf-main.o 0x00000000001009bc upx_main *(.data) .data 0x0000000000100b24 0x0 tmp/arm64-linux.elf-fold.o