From e3e5d8a3a5167474878994e814cf1d409523cf22 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Mon, 23 Dec 2024 11:20:26 -0800 Subject: [PATCH] Try again for Android Elfxx_Shdr modified: ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh modified: p_lx_elf.cpp modified: p_lx_elf.h modified: p_unix.cpp --- .../upx_testsuite_1-expected_sha256sums.sh | 98 ++++----- src/p_lx_elf.cpp | 194 +++++++++--------- src/p_lx_elf.h | 2 + src/p_unix.cpp | 3 +- 4 files changed, 146 insertions(+), 151 deletions(-) diff --git a/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh b/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh index 3c6d4b32..c4ab31a9 100644 --- a/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh +++ b/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh @@ -46,8 +46,8 @@ b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux. a0950546dc17fca9437219431d8ddb0249ce5b08e899e0c799a87ac982adee70 *powerpc64le-linux.elf/upx-3.95 " expected_sha256sums__t110_compress_ucl_nrv2b_3_no_filter="\ -708b721547488280826dfbafc32925068bfab566babfe2114cc3b1518f7df9e7 *amd64-linux.elf/upx-3.91 -7acbf5f80390a6856f8680c1b4351fedfae5f5a59360afb354db28d408a94d42 *amd64-linux.elf/upx-3.95 +373426859a5358d5edc11aae9463b6bb353284febc638415e43f91cfa3cb068b *amd64-linux.elf/upx-3.91 +bdd5a17af3ed294b62aa02a9bec570e345c9bf4bcd672e18ec1d509a143d33a5 *amd64-linux.elf/upx-3.95 be68107b41e5ac9fdfe919f6e26b0ed83807dbe1c8f20d9e391a836be445c4fd *amd64-win64.pe/upx-3.95.exe 0d0dc8fd507c061886ef5f90a368e9abfe7df9ea6a3c56da818d41875cfe7aa1 *arm-linux.elf/upx-3.95 94422a91473a467dfb534afa3f20247bc38691aeb386a42fb3e0fd18d3d0ae08 *arm-wince.pe/upx-3.91.exe @@ -61,16 +61,16 @@ ac918e0a110287d59bd6118b77a924b44499831676946d4dfbc6d7e98228e00f *i386-linux.elf 9bc7ba34e675311527776726a98450722ac9faee73ef5df96a8e8dbd2943b734 *i386-win32.pe/upx-3.91.exe 0a33acc8fa5549c59a87897b318ab83d1eb2ffa7d6c156e92d71c4e9ab4c6483 *i386-win32.pe/upx-3.95.exe 22a6fe5e84dc759675c14314f1d72b84b64e22d106b4158969f5bc4f572288a1 *m68k-atari.tos/upx-3.91.ttp -7c37aebb9b12cc898b2d8bcc1401be06abd803a6b17d1ef7aa64ccd3789c8273 *mips-linux.elf/upx-3.95 -04c5220d96e3adf2ec1e479504d334c0485454431f100a6f1008dc6d9c449ad6 *mipsel-linux.elf/upx-3.91 -e662d19b7c45c1b8fd81f0a32150a3bbdb628b161f705c489f8eb6297eb05fb4 *mipsel-linux.elf/upx-3.95 -8f2259e506a29ee4f8ed2d4aea490d07ec756b7b06583d50f0e6e88c5532ed7f *powerpc-linux.elf/upx-3.91 -5a8083e824f01488091bb630ffb4ce79d88258a4eea4894dd2dd0cd8bae1b12e *powerpc-linux.elf/upx-3.95 +575d197b6c1df5f518cf01f6c456bf0c4fe80a07fd064f63452a751bd9ad4e52 *mips-linux.elf/upx-3.95 +8692f864ecd75d6aaa10be556dadbc22dbda2a4a2afbfd02e65280e4766ba589 *mipsel-linux.elf/upx-3.91 +5ddfd1c94f243acb77615bdfcae6a3ce32bcb2cedc119c60038f4b34e6168ead *mipsel-linux.elf/upx-3.95 +1d6febfe353c32ab89a0068d154adc2dd3f11659c628376e41060889938e5e5a *powerpc-linux.elf/upx-3.91 +bc96dede246ff7d5e2c46e4b0c15854b0d2839ebae97c8383986df0f31618d0d *powerpc-linux.elf/upx-3.95 897e07f71b02f0ef54bce5c3774077f6c2e9cbc56da1ccfbac76f284bf19c0b0 *powerpc64le-linux.elf/upx-3.95 " expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\ -9b1d9928b9f1574a3c63501bb3bc2a1ca16f03fc89c29039572d28e83a3e3a60 *amd64-linux.elf/upx-3.91 -44a0f010fea7295fb3f79d2728702f98c5ff2dd8d35c18c7884093b8a034d8d2 *amd64-linux.elf/upx-3.95 +52de22088a6ce5925d5c037d4eb81366e845a866626bb861545a395ef67af8be *amd64-linux.elf/upx-3.91 +c1129e62d850699fbd0cc86ade05652dabec4688abb2416e83fc5208375c07df *amd64-linux.elf/upx-3.95 246079a063b098268c2c0c6237d7a4d0b7e18eaace45eff33a78400e1595f066 *amd64-win64.pe/upx-3.95.exe 7c42ff9c72073d3ee1758e1d9a0bbe18d0b2b1a1a0aab1ba37b70332ffa5bbe8 *arm-linux.elf/upx-3.95 d7839b7dee866794e4ca3df32e2b1084b35aa22dee5f060fa14b5ca09c612ba3 *arm-wince.pe/upx-3.91.exe @@ -84,16 +84,16 @@ e3c5768af69ee6642a20cfc084d594dfe2eb0c227dfbff8dfe452165075af3fd *i386-linux.elf 18c0e4fb6bf6b26b5c943c54571007b4aba4d0a4ba7391c149eeada54a0a404d *i386-win32.pe/upx-3.91.exe 8501c4a677eb66b482987122febc0360fc02f6720fd7c19d311cf60314d5705e *i386-win32.pe/upx-3.95.exe b8d481769be7aa7768bb1bd8775e766512c5720813e5d8bab6decb200a916f11 *m68k-atari.tos/upx-3.91.ttp -0084938a02cc7bf5eed6b43633a35d77ddcdf9e0e851cd62b18bd5521940596a *mips-linux.elf/upx-3.95 -df6b485876182b1870538d611c4ccf4b5874709daca260e40d031d7d13808c76 *mipsel-linux.elf/upx-3.91 -441607dd7d2d10cd9a6ecd55a8f62ea14fe64cd9542459ad501a82af832339d8 *mipsel-linux.elf/upx-3.95 -14bef2fda594c615e94b83bd273df66fc6ccd2034e3b66f5ce314100a9b90579 *powerpc-linux.elf/upx-3.91 -bd69150610e0bec390a58d207cc0fd97e434395228818611471f72fa18f4ecb8 *powerpc-linux.elf/upx-3.95 +0a7b2c83752c276dbfdffc86b9694b7f8a8be67402009deb3fbd6ea290ac9a07 *mips-linux.elf/upx-3.95 +fec101583d5428d356a6bfa6de035045ca0c303018f85512c7f3ea8a0dc79b81 *mipsel-linux.elf/upx-3.91 +682fbcaf379f9dcb9ddf4406c6a68f65a3b6c1b051f5296c7e695f1c778ff519 *mipsel-linux.elf/upx-3.95 +f2081ded13416ff7f5b802f34e21c652c8a80409e379f9c1cd173ece0c18a0ea *powerpc-linux.elf/upx-3.91 +49536d52e456fab87304c0d35753aa1b50063fa0b0ae1c7613bef79e04265e46 *powerpc-linux.elf/upx-3.95 a6f6e522e68464ab3a405c2195723f09c24e34e6368cfb41bfc0422872579b56 *powerpc64le-linux.elf/upx-3.95 " expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\ -515c3739c098811792521e38567a22ffb8d3bba3483236fbc60e5719120ad6eb *amd64-linux.elf/upx-3.91 -505bbf6d6a80c4b6cd05c99e5bef0bd0d0643a0187bea48c1b21b278a931533d *amd64-linux.elf/upx-3.95 +1af861ca4eab485c7e2598a13227d905f516f6e750c036de18594986ef1849e1 *amd64-linux.elf/upx-3.91 +8703304fe1d13429b5d62798aeabc6c25d7e5cda2c9ec3f0749f13b29ee6be4b *amd64-linux.elf/upx-3.95 6caf4df19cfe55fc33b31b4e77b6ce0a5665d090de9d4210c1994b62049c66c5 *amd64-win64.pe/upx-3.95.exe ee62b96bb90a5e4e0eccdc0d7c7cfa26de19d19d9ebe1decc101d28e1f57c8b4 *arm-linux.elf/upx-3.95 8c73f5acfc70e3c518be09978af87b9bec4906240cb457a166da0eba05bea4db *arm-wince.pe/upx-3.91.exe @@ -107,16 +107,16 @@ b166dddc7c89c76432d38310b6c816c6d7df58f918ba5e1294c46d32442ae0cd *i386-linux.elf 674216006959b78ef9bfeed682a6a858f657a860123c620dc77daf5d3c46c40d *i386-win32.pe/upx-3.91.exe a47825b63e33e2ff5f07ec2b8e51991172a1e26e17fa1b2a19dc7857ab76db35 *i386-win32.pe/upx-3.95.exe 2fc38c89629269a6c5ec22113f6a84a8b91e04c861359125d1c8e44d17ac190a *m68k-atari.tos/upx-3.91.ttp -24895515d8ba1875cdc5e334823c67bb51d6b9678a76d0cfabfc20a6f22e1501 *mips-linux.elf/upx-3.95 -bd10f5174b7e55bcd95999723127a9113ffc7e4ebff8d537464c2df6c3fc712b *mipsel-linux.elf/upx-3.91 -af95c3661a433b44a4bd4c8b7cdd0c4ae6acc66c2742d6572bec0976ffc2e32f *mipsel-linux.elf/upx-3.95 -0dddb9e39f2c993b44dd140ab2fa94a696c0d8d318e0e95a3b6a1e062ea43717 *powerpc-linux.elf/upx-3.91 -38c98ef96f74ccdfa272f78475bdf486deace396a94b25b46cd933dc4d21b165 *powerpc-linux.elf/upx-3.95 +c80444fc36b31ddecb1f3da0e2888cc21958a7faab48b925cde0d13cee30a19e *mips-linux.elf/upx-3.95 +6a769fa30c7d3d3bf4503dc50f2443ea2f8e1dcb908594c1fbd3223700b01e72 *mipsel-linux.elf/upx-3.91 +7d8a05fffda3d6e5b7c0d81eda394de40339e7498fb3e6b658bc6aba3a9016ee *mipsel-linux.elf/upx-3.95 +18416b78e4c27835626dde9a73108c03db05b4f801b3f8d8779f3d471b7f9e7b *powerpc-linux.elf/upx-3.91 +6c1fd7b79acd41ce0b6e4228a4046a0e0f8b5025c1f5331e7db1aac37ed29e8a *powerpc-linux.elf/upx-3.95 1d0cba0991523adb350f02e0451c0c768be5075c059d315a68d0604204adaf8f *powerpc64le-linux.elf/upx-3.95 " expected_sha256sums__t140_compress_lzma_2_no_filter="\ -630fe839ff206fc7ce73aaf443a6ef73a05d4311666a0f368edcf097ee9cde76 *amd64-linux.elf/upx-3.91 -760bf1e8dab9a80e183b1527c2d142b645c1785d95f7601051f46cd4a28df60a *amd64-linux.elf/upx-3.95 +3958eed208b70ff1a257538e15b50a623e7de986e9f6dac13b05f7de18c26c4b *amd64-linux.elf/upx-3.91 +b73e97fecfa83bd33b23bd20ae820a0454362f5c4b6c7e56ceaf18c1588b1d9c *amd64-linux.elf/upx-3.95 b8815f95e92d6853a04a86069e9054115be2d9aa657fa2c8912d0f37e56c894f *amd64-win64.pe/upx-3.95.exe 646b3f925154c884f85436ca77bceec325711f07edf139bfa1b5e7022394ae7d *arm-linux.elf/upx-3.95 018242f330e19dd7ca2fb78687c0070ad88f1aa2e113be865c30ad3ff94a4ada *arm-wince.pe/upx-3.91.exe @@ -130,16 +130,16 @@ d87f0efee3de67a58d515acbea9789e6db99c47ba23bd33aa33992a0ef35bb67 *i386-dos32.djg a33d057a391218e62f427cdd31c5850d5637346106f23523d21addc60451e159 *i386-win32.pe/upx-3.91.exe 24ecb3b5fd2f8d81f7deeadbec1988dc62503345d36b60bd17b9a4a09f8cbfb6 *i386-win32.pe/upx-3.95.exe d81bbba6a8ede3aa9bebcd28280914c1084dc0a9ff1d000389e3f52ff05a1ac7 *m68k-atari.tos/upx-3.91.ttp -19cb73aea04a420bd1521ffa1f07e75c42d156d27ae7f4b6fc273c16acdc8c27 *mips-linux.elf/upx-3.95 -bd4e17cedac3a12057455812d3d321e180d219316c1d7b4b52c813fb0136839a *mipsel-linux.elf/upx-3.91 -67eb09611eebf49870347a6a26aa828ddf4c4db55671076b6e455b267c5971f0 *mipsel-linux.elf/upx-3.95 -4158addbb6fc96e2d15b0109a117183a1592904802892d617306344c5ebe344c *powerpc-linux.elf/upx-3.91 -3cf551294dfaee2c706da13799a8364d8daee1abfeff9a65e4f50078839f7791 *powerpc-linux.elf/upx-3.95 +ed70c060f4a3e677d00985bd980df277b263928e7465f0e50a402124ed37a831 *mips-linux.elf/upx-3.95 +d82ff2d0434a46f4c96c587acf8ebc4ccf6114e051883ca396f6bcda10ff94d4 *mipsel-linux.elf/upx-3.91 +405d71bc8bb1a068df1bcddeacc6a736b7f7309038a5659c0498b5cbea515b2c *mipsel-linux.elf/upx-3.95 +0018f6a04d3de77b15d8b81435fc1ad91d3d280e8bd46224b83fa950408aaf50 *powerpc-linux.elf/upx-3.91 +b79b083f2366f632fcb75fc73fb8d74f766a3c58a49f33a607b791b18e0f59cc *powerpc-linux.elf/upx-3.95 44704d131d85b410b8df462a6ad037f98d03c2735af1347f6f3278e4eb9cf293 *powerpc64le-linux.elf/upx-3.95 " expected_sha256sums__t150_compress_ucl_2_all_filters="\ -833b15804470cd5c9d9b88327b650d5b9386c43450006530181f1965094fb31b *amd64-linux.elf/upx-3.91 -2fa3fe02a7fbcd23f405d63aeee79f5e6374ce1142cf645cf085a05a7e23243e *amd64-linux.elf/upx-3.95 +7b9ba5bd76b61aa0b616d675d5fca259305501017130e7704cc6e67d6151bc82 *amd64-linux.elf/upx-3.91 +99657a63135aee5c7b6d3650d01a3c30bbb07c1ec0551ef4eff82a4a9011b6fe *amd64-linux.elf/upx-3.95 fa8ba95a5fcc1a0d591e9b50d26772b3334815ffbf95d0127b4daa6c74ecc28d *amd64-win64.pe/upx-3.95.exe 2c88dd73554335bc92006eb599f4ab34f9a0a51fdb333f84a8407c628f3336b1 *arm-linux.elf/upx-3.95 93e2ead9e54732a1731896681d415e3ce60b7420ad7f3c57822ad7dbd061cdd3 *arm-wince.pe/upx-3.91.exe @@ -153,16 +153,16 @@ a7b2f65597198e8b282d874afcd3d51768fa5865d05a8199771f30f3b488910a *i386-linux.elf b233f8508a150a20dffaeb6da057ccfd1cf78fbb89d9bdf3fbdd1c21716665e3 *i386-win32.pe/upx-3.91.exe 57a4ff483773e64ab95963445049bff4044e055f31c13bd74c039fba1f113401 *i386-win32.pe/upx-3.95.exe 1c8973e104c93be98db7d5411b478d0badb7b6d5373f7d28e94f435fb31faa7e *m68k-atari.tos/upx-3.91.ttp -d647a629f1252f0a2664d738b20f9f940ca1beb8c1aab3e8ea6a03e43a57e5e0 *mips-linux.elf/upx-3.95 -eb24672de44eec8731433540b39359cd0ffc6cd669ec6ee72f291c7dba4e2c4a *mipsel-linux.elf/upx-3.91 -c4dd164100191e74508d0081b74a30bdceaf8ecb41e00f855d3de8a7a4f0e410 *mipsel-linux.elf/upx-3.95 -cfb6ec0073f924610dfcbc2e5f0bce164ae1bfc3d8b5525e93b9d826cc3d2e65 *powerpc-linux.elf/upx-3.91 -b136ec191dd4d2ce3c80351bab54326bd5f830c69d58cc2f9f61642e92015e8a *powerpc-linux.elf/upx-3.95 +88e957a25fc08c9105947e7ac2623584237a56515d08c023e798c7ac35da540c *mips-linux.elf/upx-3.95 +eeba67ce9423270cad0286f5fb34f72171c3af2856531409222dfc135b138b50 *mipsel-linux.elf/upx-3.91 +8c4b02e6df8b8fdfdbc22f75a2a0d3070c11e755464d2487b1db5cacd51bdeb8 *mipsel-linux.elf/upx-3.95 +1c37b669d6ebdf459ad3ddd57e916a69549e755ad6ae4bc5904f22e34b5cc140 *powerpc-linux.elf/upx-3.91 +caf360d437faab86cb68bb6cc3f225b646ca792c68e114cd38301a36ae9d4daf *powerpc-linux.elf/upx-3.95 e57a8de675c66a9ab76114fd089f994881aafbac7e72f9b2830beebb97dd31e2 *powerpc64le-linux.elf/upx-3.95 " expected_sha256sums__t160_compress_all_methods_1_no_filter="\ -f4997e0ad4780f86994471a3ff03965b7224363228a1f8f928304a04dcce9303 *amd64-linux.elf/upx-3.91 -00a1d39e857ce4c21a95a29c3517766c684a6b63893781c60be796eca3560202 *amd64-linux.elf/upx-3.95 +59e0d93528f425f2d3a66a792fb50fa4c3fe7266830304ab013586fa30f8dad9 *amd64-linux.elf/upx-3.91 +fb0d637e0d4d749cccfee3c3049d49889f77d600848a940fedbde5955c987182 *amd64-linux.elf/upx-3.95 f38ff7edc916c1a3e82020035667de858c89d52c98d960dad0e21b4da444ed6c *amd64-win64.pe/upx-3.95.exe dab0ac8855f89bae822e4b731156ffbee607aad6045959dbf3973d9d0dadc546 *arm-linux.elf/upx-3.95 bb475839ec547696aaccf4da202b99be927c872e5de298a5eb1f0be0edc06d1d *arm-wince.pe/upx-3.91.exe @@ -176,16 +176,16 @@ beb2fb2cb9e671d100d4fd6a364849ab733232c4abce8676981c93ff29032024 *i386-linux.elf 20c9fcde690091218f83c1f9fcb9a8d211f384569724801c89f3ce5d23356004 *i386-win32.pe/upx-3.91.exe c99b42e740ca0fb80a06d2e76c0b5d9169fb76900521c5ccd8e2e5a46f5020d3 *i386-win32.pe/upx-3.95.exe 0bc481806564627f23125e3ab6fa59e8b90e35f0f117c3d185a728086ad02351 *m68k-atari.tos/upx-3.91.ttp -0382f90610286aee92065e1e0b6649545dbfa95681cd6053bac38add21f59837 *mips-linux.elf/upx-3.95 -1adb668fa4b1885c77f98b6510ecf9ea69a7e51cef64df9d13839b8cca7e1a15 *mipsel-linux.elf/upx-3.91 -66198a96052441c37bd637cde716a8d316b913067d162389bccb35751a2c1cde *mipsel-linux.elf/upx-3.95 -7023a3deeb889b646343d02c226dec9978926c5fdb7a994835b5fa12d3f1388b *powerpc-linux.elf/upx-3.91 -a5d54b64296d9f97d019a80e8c2e57f17b2a38c7000c69b4d495ff66b52b3656 *powerpc-linux.elf/upx-3.95 +3d09e4b0440e09dcc5f90298fe59c67b42e24ceccdccfac585a6668b6367cc6e *mips-linux.elf/upx-3.95 +3ad90bafdae7d299d4a5a79925d32a820c5112efabf0c173351a097d45932dec *mipsel-linux.elf/upx-3.91 +bb3a472afe84340ba4d0e963f9ee0be6f80d132e1895ca1237f0ecae3734e613 *mipsel-linux.elf/upx-3.95 +5f7eff2f85195318e5a92e6da01195b44e14fefdfeecd112c17f9584b4bbbb4d *powerpc-linux.elf/upx-3.91 +974bc605d4841fec0ba1a4fad7f025dbae2c05e0892ed584a279e5f27c9e2089 *powerpc-linux.elf/upx-3.95 37f2eb6458e7a1f7708729f3be0667a63fb249faaa881cb383522c4b5ec40f4b *powerpc64le-linux.elf/upx-3.95 " expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\ -f5275cb8bf22653bb586e6f8d4e9d1f980f430ac673ab9b5abbbc68a5d050349 *amd64-linux.elf/upx-3.91 -145eaef55cf9f409724a6464be3f0fa4c9efb1450d224bad262ee0ccbe6147bd *amd64-linux.elf/upx-3.95 +7bc777b51b66911abf31f3925f78572044a1d72c09fd25e31600adc8464e55fc *amd64-linux.elf/upx-3.91 +0d86fafa4d007fdc871b501775ff77fd32b00cf4dd0bf47ec26447d9fb3685de *amd64-linux.elf/upx-3.95 fb362f2b3ea02f9c12de7e8f19f73ea6cfebfeb7b8c316003121a9ad13d3d8ae *amd64-win64.pe/upx-3.95.exe 5fc6f4f79274aa9cfa80e5081e71b91d496069898fad06629d998eb55af43597 *arm-linux.elf/upx-3.95 56be0b4046accdfadbe534ecb6e6452b9e3a18bb9eac39da0ee8893c31d24416 *arm-wince.pe/upx-3.91.exe @@ -199,11 +199,11 @@ e3fe86f9337cf06cfe17fa2ced91cb024c0119bc625f1f87ab22da5198df4fc8 *armeb-linux.el 63afac5307a2385757b3d29753c64e0026241ea2ca1324f53e8ccb4263cc9f62 *i386-win32.pe/upx-3.91.exe eb01b6f27798690115cabb88314551579da509455232bbaa3276eddc25106d0d *i386-win32.pe/upx-3.95.exe 3a5fa857ff517e41386062a0fb2be4f8b6fa5cb79d5624b5a00947c1f2758afb *m68k-atari.tos/upx-3.91.ttp -b22100378383bd95419a99c2e2a41afe1b0b19f5ee089b69d14db2384eb68f29 *mips-linux.elf/upx-3.95 -a4b41f392d5863dce3aa5048b1ab5a358fb668b2c9d223b4ceb39c201d2c1a25 *mipsel-linux.elf/upx-3.91 -f65040df1cd756a4d109c7e4522653ac4ab95286979172d5da56179d6b61e22f *mipsel-linux.elf/upx-3.95 -1a4504932c00edcede6cb0fddb6857e2c2c7f88e5df632e4d61d21e28041eb5a *powerpc-linux.elf/upx-3.91 -da1d28cae36c85b633f4458abfcb2e33f2cc4b26960bae43f546914f5bd72d59 *powerpc-linux.elf/upx-3.95 +29e28bf0ce4f513f1d39bcce224c2689af6bac3e64aa1f7e9d0ae24789c331f9 *mips-linux.elf/upx-3.95 +f9cc8923581e30dc20ad842c517f0785f3473534e3557774bd2340ac3e45c651 *mipsel-linux.elf/upx-3.91 +525c15c7b9d316e02dee1154567a6c3eb618093b0dfdf6103965027b32534045 *mipsel-linux.elf/upx-3.95 +6de5453a367dc782aab2f548e114922ecef2c41071856fc9c0d8f269ba6f81ca *powerpc-linux.elf/upx-3.91 +2e5600655f801d5b535fa5db1265366e68b6833d72c4a3b0d1be0d58730d3bde *powerpc-linux.elf/upx-3.95 257c6f2feb18f4a3523db8eb7d12ed339e8de249942cb53d0ac6dc5114adc3da *powerpc64le-linux.elf/upx-3.95 " ########## end .sha256sums.recreate diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 416e22a7..01f9329e 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -482,18 +482,22 @@ PackLinuxElf64::elf_find_Phdr_for_va(upx_uint64_t addr, Elf64_Phdr const *phdr, unsigned PackLinuxElf32::slide_sh_offset(Elf32_Shdr *shdr) { - unsigned offset = get_te32(&shdr->sh_offset); + unsigned sh_offset = get_te32(&shdr->sh_offset); + unsigned sh_addr = get_te32(&shdr->sh_addr); if (Elf32_Shdr::SHF_WRITE & get_te32(&shdr->sh_flags) - || (offset && !get_te32(&shdr->sh_addr))) + || (sh_offset && !sh_addr)) { - unsigned newoff = so_slide + offset; + unsigned newoff = so_slide + sh_offset + (is_asl ? asl_delta : 0); if ((unsigned)this->file_size < newoff) { throwInternalError("bad slide %p %#x", shdr, (unsigned)so_slide); } set_te32(&shdr->sh_offset, newoff); + if (sh_addr) // change only if non-zero + set_te32(&shdr->sh_addr, + so_slide + sh_addr + (is_asl ? asl_delta : 0)); return newoff; } - return offset; + return sh_offset; } void @@ -508,6 +512,39 @@ PackLinuxElf32::asl_slide_Shdrs() } } +unsigned +PackLinuxElf64::slide_sh_offset(Elf64_Shdr *shdr) +{ + unsigned sh_offset = get_te64(&shdr->sh_offset); + unsigned sh_addr = get_te64(&shdr->sh_addr); + if (Elf64_Shdr::SHF_WRITE & get_te64(&shdr->sh_flags) + || (sh_offset && !sh_addr)) + { + unsigned newoff = so_slide + sh_offset + (is_asl ? asl_delta : 0); + if ((unsigned)this->file_size < newoff) { + throwInternalError("bad slide %p %#x", shdr, (unsigned)so_slide); + } + set_te64(&shdr->sh_offset, newoff); + if (sh_addr) // change only if non-zero + set_te64(&shdr->sh_addr, + so_slide + sh_addr + (is_asl ? asl_delta : 0)); + return newoff; + } + return sh_offset; +} + +void +PackLinuxElf64::asl_slide_Shdrs() +{ + Elf64_Shdr *shdr = shdro; + for (unsigned j = 0; j < e_shnum; ++shdr, ++j) { + unsigned sh_offset = get_te64_32(&shdr->sh_offset); + if (xct_off < sh_offset) { + slide_sh_offset(shdr); + } + } +} + // C_BASE covers the convex hull of the PT_LOAD of the uncompressed module. // It has (PF_W & .p_flags), and is ".bss": empty (0==.p_filesz, except a bug // in Linux kernel forces 0x1000==.p_filesz) with .p_memsz equal to the brk(0). @@ -534,8 +571,9 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft) } total_out = super::pack3(fo, ft); // loader follows compressed PT_LOADs - if (fo && xct_off && Elf32_Dyn::DT_INIT != upx_dt_init) { // patch user_init_rp - // init_array[0] must have R_$(ARCH)_RELATIVE relocation. + if (fo && xct_off && !is_asl && Elf32_Dyn::DT_INIT != upx_dt_init) { + // Patch user_init_rp. is_asl has done this already in asl_pack2_Shdrs() + // Section .init_array[0] must have R_$(ARCH)_RELATIVE relocation. fo->seek((char *)user_init_rp - (char *)&file_image[0], SEEK_SET); Elf32_Rel rel(*(Elf32_Rel const *)user_init_rp); u32_t r_info = get_te32(&((Elf32_Rel const *)user_init_rp)->r_info); @@ -545,6 +583,10 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft) : (Elf32_Ehdr::EM_MIPS == e_machine) ? R_MIPS_32 : 0; set_te32(&rel.r_info, ELF32_R_INFO(ELF32_R_SYM(r_info), r_type)); + if (is_asl) { + u32_t r_offset = get_te32(&((Elf32_Rel const *)user_init_rp)->r_offset); + set_te32(&rel.r_offset, asl_delta + r_offset); + } fo->rewrite(&rel, sizeof(rel)); fo->seek(0, SEEK_END); @@ -620,6 +662,9 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft) if (!ioff) { // first PT_LOAD must contain everything written so far set_te32(&phdr->p_filesz, sz_pack2 + lsize); // is this correct? set_te32(&phdr->p_memsz, sz_pack2 + lsize); + // so_entry._start is in 1st PT_LOAD, and must be eXecutable + unsigned p_flags = get_te32(&phdr->p_flags); + set_te32(&phdr->p_flags, Elf32_Phdr::PF_X | p_flags); } else if ((xct_off - ioff) < len) { // Change length of compressed PT_LOAD. set_te32(&phdr->p_filesz, total_out - ioff); // FIXME (sz_pack2 + lsize - ioff) ? @@ -640,8 +685,9 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft) set_te32(&phdr->p_align, align); } off = fpadN(fo, (-1 + align) & (ioff - off)); - if (!so_slide) { + if (!so_slide) { // only once so_slide = off - ((is_asl ? asl_delta : 0) + ioff); + //fprintf(stderr, "\nso_slide = %#x\n", (unsigned)so_slide); //asl_slide_Shdrs(); } set_te32(&phdr->p_offset, off); @@ -829,8 +875,9 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft) set_te64(&phdr->p_align, align); } off = fpadN(fo, (-1 + align) & (ioff - off)); - if (!so_slide) { + if (!so_slide) { // only once so_slide = off - ((is_asl ? asl_delta : 0) + ioff); + //fprintf(stderr, "\nso_slide = %#x\n", (unsigned)so_slide); //asl_slide_Shdrs(); } set_te64(&phdr->p_offset, off); @@ -1698,6 +1745,7 @@ PackLinuxElf64::buildLinuxLoader( len += snprintf(&sec[len], sizeof(sec) - len, ",%s", "EXP_TAIL"); // End of daisy-chain fall-through. + // Android on EM_AARCH64 has memfd_create(), so UMF_ANDROID not needed. len += snprintf(&sec[len], sizeof(sec) - len, ",%s", "HUMF_L,UMF_LINUX"); if (hasLoaderSection("STRCON")) { len += snprintf(&sec[len], sizeof(sec) - len, ",%s", "STRCON"); @@ -3230,7 +3278,9 @@ tribool PackLinuxElf32::canPack() if (Elf32_Ehdr::EM_ARM==get_te16(&ehdri.e_machine)) { sec_arm_attr = elf_find_section_type(Elf32_Shdr::SHT_ARM_ATTRIBUTES); if (Elf32_Ehdr::ET_DYN == e_type) { - is_asl = (!!saved_opt_android_shlib) << 1; // bit 1; see is_shlib + // See earlier comment in this function. is_asl does not work. + //is_asl = (!!saved_opt_android_shlib) << 1; // bit 1; see is_shlib + is_asl = 0; } } @@ -3246,11 +3296,6 @@ tribool PackLinuxElf32::canPack() // into good positions when building the original shared library, // and also requires ld-linux to behave. - // Apparently glibc-2.13.90 insists on 0==e_ident[EI_PAD..15], - // so compressing shared libraries may be doomed anyway. - // 2011-06-01: stub.shlib-init.S works around by installing hatch - // at end of .text. - if (/*jni_onload_sym ||*/ elf_find_dynamic(upx_dt_init)) { if (this->e_machine!=Elf32_Ehdr::EM_386 && this->e_machine!=Elf32_Ehdr::EM_MIPS @@ -3263,7 +3308,7 @@ tribool PackLinuxElf32::canPack() if (!(Elf32_Dyn::DF_1_PIE & elf_unsigned_dynamic(Elf32_Dyn::DT_FLAGS_1))) { // not explicitly PIE main program if (Elf32_Ehdr::EM_ARM == e_machine // Android is common - && !is_asl // but not explicit + && 0 && !is_asl // but not explicit ) { opt->info_mode++; info("note: use --android-shlib if appropriate"); @@ -3534,6 +3579,16 @@ tribool PackLinuxElf64::canPack() goto proceed; // calls C library init for main program } + if (Elf64_Ehdr::EM_ARM==get_te16(&ehdri.e_machine)) { + sec_arm_attr = elf_find_section_type(Elf64_Shdr::SHT_ARM_ATTRIBUTES); + if (Elf64_Ehdr::ET_DYN == e_type) { + // See comment in Elf32_Linux::canPack(). is_asl does not work. + // 64-bit ARM (aarch64) also has no ARM_ATTRIBUTES. + //is_asl = (!!saved_opt_android_shlib) << 1; // bit 1; see is_shlib + is_asl = 0; + } + } + // Heuristic HACK for shared libraries (compare Darwin (MacOS) Dylib.) // If there is an existing DT_INIT, and if everything that the dynamic // linker ld-linux needs to perform relocations before calling DT_INIT @@ -4479,7 +4534,8 @@ void PackLinuxElf64::asl_pack2_Shdrs(OutputFile *fo, unsigned pre_xct_top) // of the Shdr, any PT_NOTE above xct_off, and shstrtab. // File order: Ehdr, Phdr[], section contents below xct_off, // Shdr_copy[], PT_NOTEs.hi, shstrtab. - xct_va += asl_delta; + if (is_asl) + xct_va += asl_delta; //xct_off += asl_delta; // not until ::pack3() total_in = pre_xct_top; @@ -4712,7 +4768,8 @@ void PackLinuxElf32::asl_pack2_Shdrs(OutputFile *fo, unsigned pre_xct_top) // of the Shdr, any PT_NOTE above xct_off, and shstrtab. // File order: Ehdr, Phdr[], section contents below xct_off, // Shdr_copy[], PT_NOTEs.hi, shstrtab. - xct_va += asl_delta; + if (is_asl) + xct_va += asl_delta; //xct_off += asl_delta; // not until ::pack3() total_in = pre_xct_top; @@ -4790,6 +4847,7 @@ void PackLinuxElf32::asl_pack2_Shdrs(OutputFile *fo, unsigned pre_xct_top) upx_uint32_t sz_shstrtab = get_te32(&sec_strndx->sh_size); for (unsigned j = 0; j < e_shnum; ++j, ++shdr) { unsigned sh_type = get_te32(&shdr->sh_type); + unsigned sh_flags = get_te32(&shdr->sh_flags); upx_uint32_t sh_size = get_te32(&shdr->sh_size); upx_uint32_t sh_offset = get_te32(&shdr->sh_offset); upx_uint32_t sh_entsize = get_te32(&shdr->sh_entsize); @@ -4800,9 +4858,9 @@ void PackLinuxElf32::asl_pack2_Shdrs(OutputFile *fo, unsigned pre_xct_top) throwCantPack("bad SHT_STRNDX"); } - if (xct_off <= sh_offset && Elf32_Shdr::SHF_ALLOC & get_te32(&shdr->sh_flags)) { - //upx_uint32_t addr = get_te32(&shdr->sh_addr); - //set_te32(&shdr->sh_addr, asl_delta + addr); + if (xct_off <= sh_offset && Elf32_Shdr::SHF_ALLOC & sh_flags) { + upx_uint32_t addr = get_te32(&shdr->sh_addr); + set_te32(&shdr->sh_addr, asl_delta + addr); set_te32(&shdr->sh_offset, asl_delta + sh_offset); } switch (sh_type) { @@ -4900,14 +4958,12 @@ void PackLinuxElf32::asl_pack2_Shdrs(OutputFile *fo, unsigned pre_xct_top) set_te32(&rel->r_offset, asl_delta + r_offset); } // r_offset must be in 2nd PT_LOAD; .p_vaddr was already relocated - if (0x9055c == r_offset || 0x9155c==r_offset) { - //printf("Here!\n"); - } upx_uint32_t d = elf_get_offset_from_address(r_offset); upx_uint32_t w = get_te32(&file_image[d]); upx_uint32_t r_info = get_te32(&rel->r_info); unsigned r_type = ELF32_R_TYPE(r_info); //printf("d=%#x w=%#x r_info=%#x\n", d, w, r_info); + // FIXME: why change file_image[d] instead of lowmem[d] ? if (Elf32_Ehdr::EM_386 == e_machine) switch (r_type) { default: { char msg[90]; snprintf(msg, sizeof(msg), @@ -4966,7 +5022,7 @@ void PackLinuxElf32::asl_pack2_Shdrs(OutputFile *fo, unsigned pre_xct_top) } // end rel }; break; // end Elf32_Shdr::SHT_REL case Elf32_Shdr::SHT_NOTE: { - if (!(Elf32_Shdr::SHF_ALLOC & get_te32(&shdr->sh_flags))) { + if (!(Elf32_Shdr::SHF_ALLOC & sh_flags)) { // example: version number of 'gold' linker (static binder) if (sizeof(buf_notes) < (sh_size + len_notes)) { throwCantPack("SHT_NOTEs too big"); @@ -5777,7 +5833,10 @@ int PackLinuxElf64::pack2(OutputFile *fo, Filter &ft) { Extent x; unsigned k; - is_asl = (!!saved_opt_android_shlib) << 1; // bit 1; see is_shlib + // See comment in Elf32_Linux::canPack(). is_asl does not work. + // 64-bit ARM (aarch64) also has no ARM_ATTRIBUTES. + //is_asl = (!!saved_opt_android_shlib) << 1; // bit 1; see is_shlib + is_asl = 0; unsigned const is_shlib = (0!=xct_off) | is_asl; unsigned pre_xct_top = 0; // offset of end of PT_LOAD _before_ xct_off @@ -6036,7 +6095,7 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho) return 0; } unsigned penalty = total_out; - if (sec_arm_attr) { // Forward select _Shdr + if (sec_arm_attr) { // Forward select _Shdr. EM_ARM (and Android ?) only. // Keep _Shdr for rtld data (below xct_off). // Discard _Shdr for compressed regions, except ".text" for gdb. // Keep _Shdr for SHF_WRITE. @@ -6093,13 +6152,13 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho) ++sh_in; ++sh_out; unsigned n_sh_out = 1; for (unsigned j = 1; j < e_shnum; ++j, ++sh_in) { + unsigned sh_name = get_te32(&sh_in->sh_name); unsigned sh_type = get_te32(&sh_in->sh_type); - unsigned sh_info = get_te32(&sh_in->sh_info); unsigned sh_flags = get_te32(&sh_in->sh_flags); //unsigned sh_addr = get_te32(&sh_in->sh_addr); unsigned sh_offset = get_te32(&sh_in->sh_offset); unsigned sh_size = get_te32(&sh_in->sh_size); - unsigned sh_name = get_te32(&sh_in->sh_name); + unsigned sh_info = get_te32(&sh_in->sh_info); char const *name = &shstrtab[sh_name]; if (ask_for[j]) { // Some previous _Shdr requested me // Tell them my new index @@ -6200,6 +6259,7 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho) // because .gdb_debugdata is not present (or gets removed), // but that is separate and "just" a warning. ptr = (Elf32_Phdr *)(1+ eho); + if (0) // FIXME: This is not required? for (ptr_end = &ptr[e_phnum]; ptr < ptr_end; ++ptr) { if (is_LOAD(ptr)) { Elf32_Phdr *ptr2 = 1+ ptr; @@ -6220,41 +6280,6 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho) fo->rewrite(eho, sizeof(*eho)); fo->seek(0, SEEK_END); } - else if (sec_arm_attr) { - // Forward just ARM_ATTRIBUTES - Elf32_Shdr shdr_aa[3]; - unsigned const attr_len = get_te32(&sec_arm_attr->sh_size); - char const str_aa[] = "\x00" ".shstrtab\x00" ".ARM.attributes\x00"; - - memset(shdr_aa, 0, sizeof shdr_aa); - // shstrtab - set_te32(&shdr_aa[1].sh_name, 1); - set_te32(&shdr_aa[1].sh_type, Elf32_Shdr::SHT_STRTAB); - set_te32(&shdr_aa[1].sh_offset, total_out); - set_te32(&shdr_aa[1].sh_size, sizeof(str_aa)); - set_te32(&shdr_aa[1].sh_addralign, 1); - fo->write(str_aa, sizeof(str_aa)); total_out += sizeof(str_aa); - - // ARM_ATTRIBUTES - set_te32(&shdr_aa[2].sh_name, 11); - set_te32(&shdr_aa[2].sh_type, Elf32_Shdr::SHT_ARM_ATTRIBUTES); - set_te32(&shdr_aa[2].sh_offset, total_out); - set_te32(&shdr_aa[2].sh_size, attr_len); - set_te32(&shdr_aa[2].sh_addralign, 1); - fo->write(&file_image[get_te32(&sec_arm_attr->sh_offset)], attr_len); - total_out = fpad4(fo, total_out += attr_len); - - set_te16(&eho->e_shnum, 3); - set_te16(&eho->e_shentsize, sizeof(Elf32_Shdr)); - set_te32(&eho->e_shoff, total_out); - set_te16(&eho->e_shstrndx, 1); - fo->write(shdr_aa, sizeof(shdr_aa)); - total_out += sizeof(shdr_aa); - - fo->seek(0, SEEK_SET); - fo->rewrite(eho, sizeof(*eho)); - fo->seek(0, SEEK_END); - } penalty = total_out - penalty; info("Android penalty = %d bytes", penalty); return penalty; @@ -6266,7 +6291,8 @@ unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho) return 0; } unsigned penalty = total_out; - if (sec_arm_attr) { // Forward select _Shdr + if (Elf64_Ehdr::EM_AARCH64 == e_machine + && saved_opt_android_shlib) { // Forward select _Shdr // Keep _Shdr for rtld data (below xct_off). // Discard _Shdr for compressed regions, except ".text" for gdb. // Keep _Shdr with SHF_WRITE. @@ -6320,11 +6346,11 @@ unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho) char const *sh_name = &shstrtab[get_te32(&sh_in->sh_name)]; (void)sh_name; // debugging unsigned sh_type = get_te32(&sh_in->sh_type); - unsigned sh_info = get_te32(&sh_in->sh_info); u64_t sh_flags = get_te64(&sh_in->sh_flags); u64_t sh_addr = get_te64(&sh_in->sh_addr); u64_t sh_offset = get_te64(&sh_in->sh_offset); u64_t sh_size = get_te64(&sh_in->sh_size); + unsigned sh_info = get_te32(&sh_in->sh_info); if (ask_for[j]) { // Some previous _Shdr requested me // Tell them my new index set_te32(&sh_out0[ask_for[j]].sh_info, n_sh_out); // sh_info vs st_shndx @@ -6343,7 +6369,8 @@ unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho) if (sh_offset > xct_off) { // may slide down: earlier compression if (sh_offset >= xct_off_hi) { // easy: so_slide down if (sh_out->sh_addr) // change only if non-zero - set_te64(&sh_out->sh_addr, so_slide + sh_addr); + set_te64(&sh_out->sh_addr, so_slide + sh_addr + + (is_asl ? asl_delta : 0)); set_te64(&sh_out->sh_offset, so_slide + sh_offset); } else { // somewhere in compressed; try proportional (aligned) @@ -6442,41 +6469,6 @@ unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho) fo->rewrite(eho, sizeof(*eho)); fo->seek(0, SEEK_END); } - else if (sec_arm_attr) { - // Forward just ARM_ATTRIBUTES - Elf64_Shdr shdr_aa[3]; - u64_t const attr_len = get_te64(&sec_arm_attr->sh_size); - char const str_aa[] = "\x00" ".shstrtab\x00" ".ARM.attributes\x00"; - - memset(shdr_aa, 0, sizeof shdr_aa); - // shstrtab - set_te32(&shdr_aa[1].sh_name, 1); - set_te32(&shdr_aa[1].sh_type, Elf64_Shdr::SHT_STRTAB); - set_te64(&shdr_aa[1].sh_offset, total_out); - set_te64(&shdr_aa[1].sh_size, sizeof(str_aa)); - set_te64(&shdr_aa[1].sh_addralign, 1); - fo->write(str_aa, sizeof(str_aa)); total_out += sizeof(str_aa); - - // ARM_ATTRIBUTES - set_te32(&shdr_aa[2].sh_name, 11); - set_te32(&shdr_aa[2].sh_type, Elf64_Shdr::SHT_ARM_ATTRIBUTES); - set_te64(&shdr_aa[2].sh_offset, total_out); - set_te64(&shdr_aa[2].sh_size, attr_len); - set_te64(&shdr_aa[2].sh_addralign, 1); - fo->write(&file_image[get_te64(&sec_arm_attr->sh_offset)], attr_len); - total_out = fpad8(fo, total_out += attr_len); - - set_te16(&eho->e_shnum, 3); - set_te16(&eho->e_shentsize, sizeof(Elf64_Shdr)); - set_te64(&eho->e_shoff, total_out); - set_te16(&eho->e_shstrndx, 1); - fo->write(shdr_aa, sizeof(shdr_aa)); - total_out += sizeof(shdr_aa); - - fo->seek(0, SEEK_SET); - fo->rewrite(eho, sizeof(*eho)); - fo->seek(0, SEEK_END); - } penalty = total_out - penalty; info("Android penalty = %d bytes", penalty); return penalty; diff --git a/src/p_lx_elf.h b/src/p_lx_elf.h index 47d454dd..21b9feeb 100644 --- a/src/p_lx_elf.h +++ b/src/p_lx_elf.h @@ -330,6 +330,8 @@ protected: virtual upx_uint64_t canPack_Shdr(Elf64_Phdr const *pload_x0); virtual void pack1(OutputFile *, Filter &) override; // generate executable header virtual void asl_pack2_Shdrs(OutputFile *, unsigned pre_xct_top); // AndroidSharedLibrary processes Shdrs + virtual void asl_slide_Shdrs(); // by so_slide if above xct_off + virtual unsigned slide_sh_offset(Elf64_Shdr *shdr); virtual int pack2(OutputFile *, Filter &) override; // append compressed data virtual int pack2_shlib(OutputFile *fo, Filter &ft, unsigned pre_xct_top); virtual off_t pack3(OutputFile *, Filter &) override; // append loader diff --git a/src/p_unix.cpp b/src/p_unix.cpp index 2036898a..8e8f01d6 100644 --- a/src/p_unix.cpp +++ b/src/p_unix.cpp @@ -57,11 +57,12 @@ PackUnix::PackUnix(InputFile *f) : COMPILE_TIME_ASSERT(sizeof(p_info) == 12) // opt->o_unix.android_shlib is global, but must be hint - // that applies only when an actual ET_DYN on EM_ARM or EM_ARM64. + // that applies only when an actual ET_DYN on EM_ARM (only!). // User might say "--android-shlib" but give mulitple files // where some are ET_EXEC. saved_opt_android_shlib = opt->o_unix.android_shlib; opt->o_unix.android_shlib = 0; // Must apply selectively + // Besides, cannot figure out why asl_slide_Shdrs does not work. } PackUnix::~PackUnix()