Compare commits
1280 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d14fa5f8a4 | |||
| 79263a52ac | |||
| ecb3f83e83 | |||
| f6aedb35ce | |||
| 3b7d25ac49 | |||
| e964d4acf3 | |||
| e306085b81 | |||
| b094ad4f2b | |||
| 19c6b969ab | |||
| acfda848cd | |||
| 52400e2561 | |||
| f62576a2be | |||
| 19bf9f59e9 | |||
| fadf7cfc7b | |||
| ec0c9399fa | |||
| 37b923245d | |||
| 38a676f6f7 | |||
| cd1df6f6b1 | |||
| 4a24fe8c53 | |||
| 6dac3dd248 | |||
| 37d393cbc8 | |||
| 27f155374a | |||
| 8102137ad7 | |||
| 9c46f4653f | |||
| 29b4752d0e | |||
| 2724039c09 | |||
| 6ae4e88475 | |||
| facabd68d7 | |||
| 18f043015e | |||
| ab259a1af9 | |||
| 1dd96a7628 | |||
| 1ee7ecb1f0 | |||
| 67548a4d9a | |||
| 9fbe95ad48 | |||
| 91c15b2475 | |||
| c9550b48d8 | |||
| a1d090a6fd | |||
| 4870765e1b | |||
| d8be2ed276 | |||
| 2b371e99bd | |||
| 005e39871b | |||
| 96dd9eeb44 | |||
| 65b06f6046 | |||
| 0515be4334 | |||
| e32de83758 | |||
| e767461f65 | |||
| 632c7c4826 | |||
| 7f9d381c7b | |||
| 4d5d6661d5 | |||
| b0b87eda02 | |||
| f63a673a8b | |||
| 290dd0c5d2 | |||
| 194bf2b852 | |||
| d6d5e7ae3d | |||
| 39a6cc4b5f | |||
| a24de15060 | |||
| eb021accd1 | |||
| 98a77dde00 | |||
| 854988bc5f | |||
| bfeed2ab9a | |||
| d11fc71e79 | |||
| f1703fa322 | |||
| 06675acc67 | |||
| 57ad6bc37d | |||
| 0192b0b7e4 | |||
| 3b098b845a | |||
| ac398f1ffe | |||
| 92dfb9c83c | |||
| 38d6cb090c | |||
| e93172bd33 | |||
| 30fcca4b64 | |||
| 4f6320d3aa | |||
| 62dbf8485f | |||
| 9331ed39d4 | |||
| 35dd9cfd22 | |||
| 0ac6c36af2 | |||
| 3c4b959f78 | |||
| a00687b092 | |||
| bb6b087862 | |||
| bfb438dc89 | |||
| cd3f69c290 | |||
| d54315392e | |||
| cfa8107ab9 | |||
| f4e5b29708 | |||
| d65fea1147 | |||
| 25a3c109c1 | |||
| b526eed346 | |||
| 59c6a71b72 | |||
| c7a2a0faa1 | |||
| bfb5ea50a9 | |||
| 149d84edca | |||
| 7636abc158 | |||
| 6eace187e7 | |||
| dd1838a7eb | |||
| dd928cf956 | |||
| 38be230467 | |||
| 1f747a28a9 | |||
| 1a7732b285 | |||
| f8ea416a4d | |||
| b9bf81d548 | |||
| 8975e2a6b5 | |||
| 394cd77bec | |||
| a9ac4b5e23 | |||
| 10e759f1f1 | |||
| 777d4f5279 | |||
| c65c882ecc | |||
| a66ee9fafd | |||
| 757401dd0c | |||
| 11e3770864 | |||
| fbb317e9c8 | |||
| 9d7698a359 | |||
| 44fd11f4dd | |||
| 8779113131 | |||
| 26cfd0a616 | |||
| 75e153dd99 | |||
| fa364d6ea3 | |||
| 13e5c13695 | |||
| 43b3b54197 | |||
| 3a16d4a12e | |||
| 50fc9235de | |||
| 70287d3c49 | |||
| 41e9f7985f | |||
| c3327977da | |||
| 905bfacf44 | |||
| 053e95033f | |||
| 5a1203be0d | |||
| 745fef7425 | |||
| c9d625a237 | |||
| 334731f56b | |||
| d5e7672a45 | |||
| e702aa0252 | |||
| 2684e815e0 | |||
| efbc93229a | |||
| 05539ad5b6 | |||
| 670aae2e11 | |||
| e6ff68dc2c | |||
| 641b116f04 | |||
| f81f7194ed | |||
| 161d20e614 | |||
| fc4dcd46db | |||
| 891dc87064 | |||
| b866631448 | |||
| 672d69c68a | |||
| 507c31ec14 | |||
| 65cc40bdda | |||
| 067895fa5f | |||
| 3f7f26c74b | |||
| 9a6b5940cf | |||
| 828f4a63bf | |||
| 707fb55625 | |||
| 8d41ae09c8 | |||
| 7ec0faca1e | |||
| 300fa29446 | |||
| 6981f7b3ae | |||
| 682a1e97e4 | |||
| 1d71dd3851 | |||
| 5edfda46e5 | |||
| d7754a97c7 | |||
| c79aa6ad8a | |||
| 525e091472 | |||
| 16f6de677d | |||
| 12c36bab6c | |||
| c429859cbf | |||
| dc76b2af97 | |||
| b75e7687f4 | |||
| ece5af2895 | |||
| 1aaa33552e | |||
| f622871eb0 | |||
| 060b01260d | |||
| 871f8a4793 | |||
| c54e03d0f2 | |||
| aaf3f75990 | |||
| 512a26cee4 | |||
| b4a793ed26 | |||
| 5d2c74008e | |||
| 7fafc68940 | |||
| d1af2af499 | |||
| a5206eb696 | |||
| 1ff0d137ab | |||
| 07aa65b55e | |||
| 0fadddec65 | |||
| 1bebe53cef | |||
| 43019c744c | |||
| c585774162 | |||
| 75e87a58da | |||
| 19e84fea62 | |||
| db39f9c4dc | |||
| dae45ae0d4 | |||
| efeffc6e01 | |||
| ebf0f2f68a | |||
| 09bd1d8c40 | |||
| 40653e40a4 | |||
| b3e4efbabe | |||
| 279101d464 | |||
| f571feee72 | |||
| 900afd1c8c | |||
| 08a72d5251 | |||
| 736a6cd955 | |||
| 75ce5e5df3 | |||
| eaf2143162 | |||
| f0bdb8dea1 | |||
| 60093cfff6 | |||
| 56bb7b53cb | |||
| 0cffeca102 | |||
| 937d4462ca | |||
| db5a39572c | |||
| ecc9c67e1f | |||
| 0901ce1b68 | |||
| be6e77379a | |||
| 726f5de778 | |||
| 98b835e0a7 | |||
| 04ffb641a6 | |||
| 1b7233b673 | |||
| eaa0f33473 | |||
| c03b382d61 | |||
| e633694255 | |||
| 278b25bad2 | |||
| f89f0838dc | |||
| b1729e3bcf | |||
| d1ab85a1a6 | |||
| 7f5b64c91a | |||
| 78b68283c4 | |||
| 9e3b1c9f8a | |||
| 5dc54c7adc | |||
| 320e5b850f | |||
| d8395d8c42 | |||
| a20c5a1e7f | |||
| 3bdfcaa541 | |||
| 7b2faf2016 | |||
| 42902dabac | |||
| 14521eb6dd | |||
| b9533f409c | |||
| 4df68aafd2 | |||
| c72ceaa979 | |||
| 8ac79ca0ad | |||
| e0bfaf1028 | |||
| b361b91ec7 | |||
| b5d1eba4c1 | |||
| ba447344d6 | |||
| 7b68aa7bdc | |||
| 5d15e57294 | |||
| 0bf8ff151e | |||
| 06fae05910 | |||
| f68ac8155b | |||
| 15484aa296 | |||
| 5b113a5041 | |||
| 1320e3efdb | |||
| d32f447bda | |||
| b74c4e4ac1 | |||
| 35333403ef | |||
| a627648249 | |||
| 127fd095e7 | |||
| f8934c09ff | |||
| 7a09c88e30 | |||
| 17526d1132 | |||
| ff7939c1c0 | |||
| 96c196b1be | |||
| adb0ca8250 | |||
| fa56a1d9cd | |||
| 3d691645a4 | |||
| e1edc5f50a | |||
| 4a8efd2e2f | |||
| 8d364c82e2 | |||
| c5059231dc | |||
| f584c91386 | |||
| b8d9c2b755 | |||
| 163377d1a0 | |||
| 8944e90175 | |||
| 33cdcb0e82 | |||
| ec870a5aeb | |||
| 0653bb5a72 | |||
| 43b6ff29e3 | |||
| a444a8a704 | |||
| 3fa18c1799 | |||
| 19147963b9 | |||
| 5056215a1f | |||
| 340b7614e2 | |||
| 8a1bd67a20 | |||
| a094df7b55 | |||
| cc893dfc11 | |||
| 8ef17da082 | |||
| 7993e619cd | |||
| 1ab8d5fb3f | |||
| 213ac3ac73 | |||
| 0a8876443a | |||
| f37a3bb9bb | |||
| 2632342f44 | |||
| 8efcf6f099 | |||
| 58343fc78d | |||
| 6c41a4c9c8 | |||
| 334be287fc | |||
| aa050e0001 | |||
| cc994326a0 | |||
| 58de07629e | |||
| 9f830e0c41 | |||
| c52d302f07 | |||
| 44049ecf30 | |||
| e1b5904196 | |||
| 88e692791a | |||
| f00667ad7d | |||
| 696d0eec64 | |||
| 513b00a30e | |||
| 0cb0dbf6d8 | |||
| 9f00515da4 | |||
| 72f31787f6 | |||
| cd686cb1d9 | |||
| d9657e9831 | |||
| 72f3e9b25a | |||
| 811b15a5b3 | |||
| ab00825f37 | |||
| e86d9179aa | |||
| 26d8e9c4c5 | |||
| 5f3ebc8a7f | |||
| 425b1b44bc | |||
| 39442e6282 | |||
| 99575e1010 | |||
| 64aa7540e2 | |||
| 3ff5dbd179 | |||
| e25d04fb12 | |||
| dd1d5a92d2 | |||
| c6e0aad40b | |||
| 99b795ceaa | |||
| 33dc60df26 | |||
| 619aeb54ff | |||
| 77ba43328b | |||
| 01a30752c7 | |||
| e56b748435 | |||
| bb4cbdff44 | |||
| 0b47e474a7 | |||
| 8e85680eb4 | |||
| fefce0d5c4 | |||
| 0ac3cb2329 | |||
| 708ab1dcd7 | |||
| 9b87ddb621 | |||
| 5dc4eb4b03 | |||
| a203c72281 | |||
| 6cf85cee6e | |||
| 1eb6a40fdd | |||
| 1bed77e4d3 | |||
| f2a68023fa | |||
| 8ccffc40e3 | |||
| dd8c1d0441 | |||
| f9f28ff176 | |||
| 3649041195 | |||
| c23c7a9379 | |||
| 9934e33b99 | |||
| 9e75fdda66 | |||
| d873a26f41 | |||
| 91aa5b55ab | |||
| 3f460a76ce | |||
| 7256ea3b32 | |||
| 4cdf77e16f | |||
| d89813e911 | |||
| 7c57b10cae | |||
| 8d1a98e03b | |||
| 65a2da4b40 | |||
| 02f6786b2a | |||
| 9da4f7a6dc | |||
| 510505a85c | |||
| 741cb3a136 | |||
| 9f5d67e27c | |||
| 93c6496ba8 | |||
| 779b648c5f | |||
| 9d5e06232d | |||
| b221c44466 | |||
| 665296f7cf | |||
| 39778d5f47 | |||
| 0af9bbb623 | |||
| fdec47a83d | |||
| 7ff913bbd2 | |||
| 94775bef9f | |||
| 3cf102334f | |||
| 627e733a30 | |||
| d31b80da5b | |||
| eb231b65f3 | |||
| 59e3b1f98d | |||
| 8b174bb272 | |||
| 4199a44bef | |||
| 777392c0fe | |||
| ede1fec5e7 | |||
| 16de3e78a5 | |||
| d7508d8c09 | |||
| 2a136c1c1d | |||
| 2578102be9 | |||
| dadee7acfb | |||
| 28f0bb4e11 | |||
| 824c8a8efb | |||
| 37f27a1262 | |||
| 2b8a7a492a | |||
| db56bbb11b | |||
| 82d26f04a4 | |||
| 5045f7eb42 | |||
| 82a6ccac4d | |||
| 2d74298001 | |||
| ce21254ed2 | |||
| 874250fe49 | |||
| c8a3acbba8 | |||
| 81e11987a2 | |||
| 668cefec2f | |||
| 212bc04257 | |||
| db401fd05e | |||
| bebe72481c | |||
| 2b9e83256d | |||
| 5763518cce | |||
| 3e4c5bab72 | |||
| bce109ab54 | |||
| 69ca635c4c | |||
| e0bf460993 | |||
| 29762a8a96 | |||
| c7ef08dc2d | |||
| 50a6698715 | |||
| 7dd2cdea1e | |||
| af87f7f2bf | |||
| 295889023f | |||
| feef2e38cf | |||
| 80d30aab32 | |||
| e910a9dc3e | |||
| 504224696c | |||
| e2acd666df | |||
| e5c0d998b7 | |||
| 63f6fef964 | |||
| 983eb6d676 | |||
| 98fedef1a1 | |||
| 75a769759d | |||
| 2354b01bad | |||
| c331b9f1e2 | |||
| afeaeeddec | |||
| ab7ef9f511 | |||
| d3ad6d25d8 | |||
| 2e29f9fa5f | |||
| 5d9f71bb13 | |||
| 82ed25bb44 | |||
| f57393c0e8 | |||
| b54cced19c | |||
| 60a0544314 | |||
| 283c1cf931 | |||
| fff53efc05 | |||
| 07d368adca | |||
| 13276d93fa | |||
| 79b1b1a586 | |||
| 2f083f3e56 | |||
| 73b0b4db9d | |||
| ca0e614b56 | |||
| 72613d06a5 | |||
| 48ad5513ff | |||
| 201d9f1346 | |||
| 1e8f1f49d0 | |||
| 65707900bc | |||
| 39c5be43aa | |||
| c4437cb293 | |||
| e2b86a49db | |||
| 8fe83be87f | |||
| 17167d4905 | |||
| 05ff7e35a1 | |||
| f67cec4752 | |||
| fd4882abcf | |||
| 0f42579e68 | |||
| 7398d8f68f | |||
| ec33109b22 | |||
| 2cfa4c1eb7 | |||
| a13b4d10d9 | |||
| 36e94e58d0 | |||
| d0a52bd483 | |||
| 38a1d3179b | |||
| 0d639d6386 | |||
| 4256057c27 | |||
| b720b47c12 | |||
| 55e4a4f086 | |||
| b4cb9f8b2f | |||
| 63298ebd6d | |||
| 73c816e468 | |||
| 0492e650ef | |||
| b8b94ee89e | |||
| 81176716d5 | |||
| 26e7ae00e9 | |||
| c75d7a685d | |||
| 4318cc22ee | |||
| 575cb720c6 | |||
| 5db34fbf92 | |||
| 7cfef2f6bf | |||
| 4603f1df4b | |||
| c69fcfff9d | |||
| 70f14101ed | |||
| a9803459ed | |||
| 43034e8e92 | |||
| ef547034f6 | |||
| e87fc60391 | |||
| 45e6e73d85 | |||
| be30c26dbb | |||
| 79e9b0762c | |||
| a9a806c418 | |||
| c7d8b6fed1 | |||
| a723efd225 | |||
| cf429dfce4 | |||
| 3fcd64a0c0 | |||
| 83cb38022b | |||
| 93c04d1f66 | |||
| 3c47898cf4 | |||
| 61e1366122 | |||
| a20636fd63 | |||
| aa8cdca0a9 | |||
| 6931a3aa70 | |||
| d001a63bce | |||
| 0d3377f48b | |||
| aeb04d97c8 | |||
| eb68ab91cd | |||
| ee242ba987 | |||
| 44a53736ff | |||
| 1b21fef081 | |||
| 5f9c50cd3e | |||
| 793d8c1d2e | |||
| 81f868a0c6 | |||
| dadbbbdc64 | |||
| bfd2153f2b | |||
| 077793fa5e | |||
| acad3c3000 | |||
| 3b4627e17e | |||
| 05976ee1a7 | |||
| c1311c78a3 | |||
| 717150b7f3 | |||
| a68c62d938 | |||
| c11f8a569a | |||
| 03436d2415 | |||
| 4ae75375e0 | |||
| 2721ef0636 | |||
| 7a232cb330 | |||
| 52f19ae330 | |||
| 275477f914 | |||
| 2ed6755d5d | |||
| 78c555b4a6 | |||
| a127125707 | |||
| f853f91c5b | |||
| e7ca5c54ff | |||
| 663d6b466b | |||
| 0e2a9de2b2 | |||
| 34df0d6ef1 | |||
| 540164849b | |||
| 252143d0bb | |||
| 480ab51650 | |||
| 972c76eb42 | |||
| e5aeea9ed2 | |||
| f204670008 | |||
| 651155c64d | |||
| 660aee6d22 | |||
| a646231630 | |||
| 1050de5171 | |||
| b7a5b9437a | |||
| 620955a724 | |||
| 2e64a277f8 | |||
| ea567a8b14 | |||
| be23f93ee6 | |||
| fcdf0e92c1 | |||
| 2d6987252e | |||
| 4a9c46253e | |||
| 5bcf9dd8af | |||
| 284adb203f | |||
| adafa841f7 | |||
| fdc5d25d03 | |||
| 294a7077de | |||
| 990d0ec543 | |||
| bb90c4dff4 | |||
| 00e3d992e8 | |||
| 937bfa4e49 | |||
| 1d9c211eed | |||
| 76ddf6b8da | |||
| 7f1f29b0d8 | |||
| 222471744f | |||
| cc100be26e | |||
| 966b571b7c | |||
| f3e710394a | |||
| bfd1f1fbfa | |||
| a09146b5e0 | |||
| bbf2b08f48 | |||
| e2dbc661f1 | |||
| 7626e09f66 | |||
| 248a6980cf | |||
| f956bfc797 | |||
| 6da79783ea | |||
| 22329e0ab2 | |||
| a94b0329c9 | |||
| be8601f8cc | |||
| bd441e83ae | |||
| 02bd9cc403 | |||
| c9f6a3583c | |||
| 076aaf829a | |||
| 85f0c5a445 | |||
| d5263a56ce | |||
| ef5b55b4d1 | |||
| d65e65b2b1 | |||
| 6aa641e5aa | |||
| 504839951a | |||
| d55746f62d | |||
| 144010295e | |||
| 181c752488 | |||
| bd4aca5c12 | |||
| ad6d73c875 | |||
| c5cc83d424 | |||
| fe949bdf67 | |||
| 766fe466d6 | |||
| 333a288248 | |||
| 613df414ed | |||
| be050693f2 | |||
| bf957f435e | |||
| 3a6f688265 | |||
| 1084a7896c | |||
| 9ea2b31541 | |||
| 09da986742 | |||
| cb70a5fef5 | |||
| 4fa6a6aeef | |||
| ab31e8dde9 | |||
| 53d7b5449f | |||
| d33a34f016 | |||
| f6ff5a2805 | |||
| 1518e5bc98 | |||
| 78f48d65d5 | |||
| b81ec224b7 | |||
| 4be6cfebcd | |||
| 98973dd8b9 | |||
| 1218b6ff2a | |||
| ba5c77c9e5 | |||
| cbaedffce2 | |||
| cb60603950 | |||
| 0a69e7803b | |||
| baa9090198 | |||
| e78a08b8fc | |||
| 7e5e6012df | |||
| 0a1d24d1d9 | |||
| 35555bfb8a | |||
| c9cb42df40 | |||
| 2be03028f4 | |||
| 214dd0a522 | |||
| 182e0796df | |||
| fb844a8ed1 | |||
| 6be3e747ca | |||
| 23f63e4196 | |||
| fd6837b267 | |||
| 1c29f921e0 | |||
| 1ab6e01de2 | |||
| 801618740c | |||
| 2469563b26 | |||
| 00139caf43 | |||
| 21d102c84f | |||
| f17d9967c2 | |||
| 0569ef37ba | |||
| 984334c9a1 | |||
| 34a25e61c7 | |||
| ed3f45953e | |||
| 80de11bc5b | |||
| c9fe84c9aa | |||
| 5f98bb0ab0 | |||
| d86d5314ba | |||
| 700c8730cf | |||
| b4429e1a42 | |||
| a8fa3ca5cf | |||
| 9aef7b0d6f | |||
| 2575eef3c0 | |||
| 8236276a90 | |||
| fdc68812c5 | |||
| 9db6d18d11 | |||
| f962afe146 | |||
| adcd569852 | |||
| d045b7f223 | |||
| 57cb6a7530 | |||
| baa1ed9be3 | |||
| 16af6e1a29 | |||
| 0af8998be6 | |||
| c32f517fa5 | |||
| 9131d5216f | |||
| fb14a7991d | |||
| ff53862dab | |||
| 49245a20c5 | |||
| 13bc031163 | |||
| 0c18c1c35c | |||
| 63dc19ce25 | |||
| 6871c2fc0a | |||
| 4ae3a8b2b0 | |||
| f2e562b5de | |||
| f7e2266c3f | |||
| 361a3056cb | |||
| ca0437556d | |||
| 51899957a9 | |||
| 7b0b760d78 | |||
| 4f5866b5a7 | |||
| a6b5033cf1 | |||
| a6296ecd67 | |||
| bb1df15958 | |||
| 249431f45f | |||
| cbe129795e | |||
| 2a135e245b | |||
| 05a0b3557a | |||
| c7cfe8b608 | |||
| 8d3e1d28a7 | |||
| 7841e15583 | |||
| dd164fbc86 | |||
| 23fe02e84a | |||
| 94e72238f2 | |||
| 8f7ac520eb | |||
| bd193201b2 | |||
| 8ced672d24 | |||
| f218812858 | |||
| 8a7b980fc0 | |||
| 385c9877f8 | |||
| 10df93536e | |||
| 6cad27896f | |||
| 052392d97b | |||
| ce6b5a0688 | |||
| 1879185e42 | |||
| a928a08f9d | |||
| 1805cb6857 | |||
| 6ce625b535 | |||
| 4702f12818 | |||
| 4f3054f07d | |||
| 0d7bd52e21 | |||
| c3466f579c | |||
| 7c105d7af5 | |||
| 924b229afb | |||
| 890d66ecf0 | |||
| 143049922b | |||
| e6ccef2cf1 | |||
| be61e9f584 | |||
| 89d0fda9fa | |||
| 6a85bab5da | |||
| c1a55b063e | |||
| 77c914bce5 | |||
| cc60f03b2e | |||
| cc9ccdbbd1 | |||
| 9dfc8f573c | |||
| 4e2fdb464a | |||
| 73b854874e | |||
| 0016512df1 | |||
| 527139978a | |||
| 47bc68fa6b | |||
| 972b670a64 | |||
| d7c416f243 | |||
| 3ace7a0468 | |||
| d305023f5e | |||
| 963392a5ae | |||
| 2f453acf5d | |||
| 4ae1576726 | |||
| 17bd0b3248 | |||
| a1ad1aee99 | |||
| a817ed0692 | |||
| 828a6cf07b | |||
| 962c35aa08 | |||
| b327645e64 | |||
| e1b42616a2 | |||
| f96638c42a | |||
| 6272152dfe | |||
| 030a200c08 | |||
| 994da63b4d | |||
| 2315bff280 | |||
| 98dddf93d8 | |||
| fd2939e18d | |||
| 80c27e0822 | |||
| b463f24eda | |||
| 2a849444db | |||
| 69e106c0c5 | |||
| 926481dace | |||
| a3b2cde58d | |||
| 30f37d2cc6 | |||
| c4d61dd9fe | |||
| 210870f840 | |||
| 4cb4bd38eb | |||
| 58c6d19f7c | |||
| f99ae94747 | |||
| 6868ca7953 | |||
| 87a5a4ef32 | |||
| c67a5d677c | |||
| 1ce6f0e6f4 | |||
| 740b4ff865 | |||
| 1059f62566 | |||
| df3193c1ee | |||
| 67860e3704 | |||
| 35fbb1ecb6 | |||
| c63a71ad42 | |||
| f33645f739 | |||
| d7ba31cab8 | |||
| 342b1b7d6c | |||
| 936013f60c | |||
| fdf2eddc73 | |||
| 4409753014 | |||
| 9172ae3d19 | |||
| e2f60adc95 | |||
| 1bb93d4fce | |||
| eb90eab632 | |||
| 0f4975fd7f | |||
| b5b1f06a11 | |||
| 86f8eb0930 | |||
| 91ad0e7572 | |||
| b034ee98fe | |||
| ded07f8781 | |||
| 849bdd87e1 | |||
| 643e48efd7 | |||
| 92f072cf70 | |||
| 95bf2e2e41 | |||
| 6a6c6d84eb | |||
| 08a689c81e | |||
| d1174385ef | |||
| cb5f590e10 | |||
| 5ed9c66ed9 | |||
| b8f52d14f4 | |||
| 5d295c24f0 | |||
| 8be9da8280 | |||
| 819c33fee2 | |||
| 75a2cc4ecb | |||
| e2833cf303 | |||
| 801de73dbe | |||
| 6a53c0b3d4 | |||
| 58b122d97d | |||
| 276b748aa6 | |||
| 23570097cf | |||
| 62a07df45e | |||
| 593a69ce25 | |||
| c33603e324 | |||
| 29fa358077 | |||
| 49766388bc | |||
| f23267bddd | |||
| 4484acf9d6 | |||
| 47ddace96a | |||
| 8aadbcd786 | |||
| 517bc9db0b | |||
| 16bfa7b846 | |||
| 570b2d0e88 | |||
| 2653a0749a | |||
| 3de0008543 | |||
| d4e2d7e8a8 | |||
| a9c08c6f52 | |||
| c2aa5c35f7 | |||
| 423f1a8758 | |||
| cc5f684e33 | |||
| b6646d319a | |||
| 3667fa4e44 | |||
| d1c80154f6 | |||
| 3c2bfc742e | |||
| d60fef753f | |||
| 70ed2d0d03 | |||
| 716d203a78 | |||
| 9719a7dd56 | |||
| c097233bf3 | |||
| 69a583281f | |||
| 8e90c9af2b | |||
| a784284b7f | |||
| 0509edf08d | |||
| 7ca20f424f | |||
| b74d51c2a8 | |||
| 58061cd121 | |||
| b8f6be5389 | |||
| 7c766b3313 | |||
| 91b81b587b | |||
| 780a4347b8 | |||
| 606ad08dd1 | |||
| 75c31dff1d | |||
| 473b90419f | |||
| f88b85e126 | |||
| b122f8e9d0 | |||
| cb8b1595a1 | |||
| 1bee919276 | |||
| 78b1da5c00 | |||
| bb8239ccda | |||
| 2a594ad0a7 | |||
| b05073550c | |||
| 37d6a34e58 | |||
| 4f0cba9bb6 | |||
| 4d1c754af9 | |||
| c1cfde21d7 | |||
| bb1f9cdecd | |||
| b259b0ca28 | |||
| 0051dfc84f | |||
| 9f294e6ce5 | |||
| 153ea8be03 | |||
| f3f7f97f8d | |||
| 9bb6854e64 | |||
| 4bba1e6cb7 | |||
| 597e8fe407 | |||
| 556c541ffb | |||
| 5963f18f7c | |||
| 0dac6b7be3 | |||
| 296ede780b | |||
| faaa19331a | |||
| 88cb5886f3 | |||
| 2fcc3f86c0 | |||
| 9362fde9eb | |||
| 56f4d781c1 | |||
| 7a3637ff5a | |||
| 2923c0968e | |||
| 98cfe99d65 | |||
| bdd97fe0b2 | |||
| 6b500bc83b | |||
| 92a12a2ec1 | |||
| 04d79040f9 | |||
| 3201ddc680 | |||
| 2f06de54c5 | |||
| 6489ec9bba | |||
| 1a5ba22fe7 | |||
| 8f9713ed53 | |||
| 90eb68b3b9 | |||
| 95fcbcb4f2 | |||
| b97688d119 | |||
| 5ea3627cab | |||
| d9288213ec | |||
| 614c86fb7d | |||
| 9f651ee40f | |||
| 774c8c3fd4 | |||
| b711d2f750 | |||
| 8a793d5942 | |||
| 99f52c60ed | |||
| 2c2e108301 | |||
| 563165e6ae | |||
| f1a31b4793 | |||
| 5e9b6bd69d | |||
| 9b990c4eae | |||
| 7a625a449a | |||
| c2b62359d5 | |||
| 6722e8972e | |||
| fefe7a3452 | |||
| 90a1322929 | |||
| d698eb69e2 | |||
| 0ef00e9b82 | |||
| 95cedb6640 | |||
| d736da4208 | |||
| be83788666 | |||
| 5a28a51abc | |||
| 8a84df752c | |||
| 85f53b210d | |||
| 5d13c6cd01 | |||
| 98a0d381e9 | |||
| e1d20fd0b5 | |||
| d1035ecd8f | |||
| 0e651facdd | |||
| 9fdddfc332 | |||
| 7d2913709c | |||
| 3623199e8d | |||
| e4b23f7a47 | |||
| f056ecdcd5 | |||
| 857a03a074 | |||
| a34deee4f5 | |||
| fc9c8ae482 | |||
| 08c63f06eb | |||
| bbff510ef1 | |||
| f747435952 | |||
| e6edad8f46 | |||
| 05e44b9644 | |||
| 16bb7ab841 | |||
| 9248f02557 | |||
| 9485a56af1 | |||
| 021c8db58a | |||
| 8ab180edf8 | |||
| ab35b685d4 | |||
| 86745721ee | |||
| c34fe09a79 | |||
| 1fa9ff2c05 | |||
| e8ef0cf63f | |||
| 8c84efb8fb | |||
| f3a7620ae8 | |||
| c7969ed5a5 | |||
| 900926c0ed | |||
| df94f4288a | |||
| 969efe687d | |||
| ee3f1292d0 | |||
| cacb239040 | |||
| 28d1789783 | |||
| 633eb98e34 | |||
| 4854c03096 | |||
| e853119c77 | |||
| 161a58bafb | |||
| f5fd94e815 | |||
| edde6210f1 | |||
| 507e19945e | |||
| 4a35bf32ea | |||
| e04bf9e4bc | |||
| c384d224c0 | |||
| 35427f998e | |||
| 1174da2bc3 | |||
| 11e8a47030 | |||
| 8c4e9bcf0d | |||
| 9dfd624901 | |||
| 79e65503a9 | |||
| 59f18b9d9f | |||
| fb3699fb89 | |||
| 9d2d59b5d2 | |||
| aefb2fa3c3 | |||
| e8aa80f904 | |||
| 990988f920 | |||
| 576d9a4e7e | |||
| 1d462ee424 | |||
| c9b09555c4 | |||
| 860b5bf967 | |||
| 5063480a38 | |||
| 3400ae9dbe | |||
| 3385264eb2 | |||
| 34646f1c6a | |||
| 50aa63a5a0 | |||
| 64557bee43 | |||
| 7c21c4513e | |||
| c6d6378005 | |||
| 4f6979967d | |||
| e633c51b50 | |||
| 143f0accef | |||
| b413f3da26 | |||
| 6eafa552bb | |||
| 7a0514d9b4 | |||
| 7e7565299e | |||
| ed34a089c6 | |||
| d14a2c5282 | |||
| f014406b65 | |||
| 58771ecca6 | |||
| 5d9dcb634b | |||
| 19c2c1edcf | |||
| 0430e7931e | |||
| bb8e607442 | |||
| e61ada944d | |||
| 46730315e3 | |||
| 4869142034 | |||
| 8e42e17bbf | |||
| 38c8b84a26 | |||
| c652626a37 | |||
| 06f6e47ebf | |||
| 403b180b1d | |||
| ee008acfbd | |||
| d149092ac0 | |||
| eafa136c69 | |||
| 402c885987 | |||
| 5e7e0508b9 | |||
| ff1d5fb794 | |||
| ad3f63b5c4 | |||
| a3e51e6dee | |||
| c1b9c79f54 | |||
| e0bc040b0a | |||
| 85eb4c7537 | |||
| 1f929d47d0 | |||
| 608662d73b | |||
| 7841d23e77 | |||
| b72dda4ada | |||
| c59c8a1ea2 | |||
| 1522293be0 | |||
| b37bc99330 | |||
| 7f905724b1 | |||
| 2bf5bb1625 | |||
| 08d3376740 | |||
| 7bace76176 | |||
| ef336dbcc6 | |||
| ca7217e717 | |||
| 3931cb7871 | |||
| 9e8de4abe5 | |||
| 26be845563 | |||
| 2f11a629fa | |||
| a295437e11 | |||
| 04597fb804 | |||
| f2f002409b | |||
| 509de877ca | |||
| 63aea4a7dc | |||
| 6470c748db | |||
| 25a6429e6a | |||
| 4fa1c2a97e | |||
| 9ad39d77cc | |||
| 92527126a8 | |||
| 02b4a4c974 | |||
| ede570be21 | |||
| 08627e9df5 | |||
| 6d9f3adc86 | |||
| 96433b4e39 | |||
| f4947cc2ae | |||
| 7b554d4f72 | |||
| 5b54544438 | |||
| ef78d23494 | |||
| ef8a7f330d | |||
| b72e0f3060 | |||
| 2a0bab938b | |||
| cd637629c4 | |||
| b9adfd801d | |||
| 69355514c9 | |||
| 33dc947c21 | |||
| 6de021d8d8 | |||
| 9be86621bf | |||
| a7a0876298 | |||
| 31b42345c3 | |||
| 1b172e729e | |||
| 3bf387a2d4 | |||
| 9f20bbb046 | |||
| 82af555974 | |||
| 50638b5213 | |||
| 650df95b72 | |||
| b2115a4162 | |||
| d67bf16a08 | |||
| a4c9b64224 | |||
| 8f572e5fe6 | |||
| e58873044b | |||
| 8ada92a69f | |||
| 3c8ed5c000 | |||
| c127d5b64a | |||
| 2d3bd0809a | |||
| eef955a9dd | |||
| e59ce39dc6 | |||
| 62815f5c3c | |||
| f496010273 | |||
| 143c4e3322 | |||
| e7f1e99a5e | |||
| 140a031515 | |||
| b7c91941b8 | |||
| 33f0b6da67 | |||
| ee18fe9bba | |||
| a51330cf07 | |||
| a67aed2744 | |||
| d979e19315 | |||
| 4c74d16795 | |||
| 6e541a432f | |||
| d8f47e248a | |||
| d1a869496b | |||
| f42a37555d | |||
| d9e019bd87 | |||
| ce194fa5d8 | |||
| b5bdf57636 | |||
| a3a81ce7c6 | |||
| 61f347401c | |||
| d985a4c250 | |||
| d31947e1f0 | |||
| e4659b7d7c | |||
| 8827a534db | |||
| ddf48b45a5 | |||
| 8eabb9b02f | |||
| 8a195a0b35 | |||
| 955206aaf0 | |||
| 082dd7d5ee | |||
| 90714cf624 | |||
| 61798d33f0 | |||
| 6e2a41cb26 | |||
| 515897e180 | |||
| fe4a8f33b1 | |||
| 304d848f53 | |||
| b5f738abf3 | |||
| 7ebed06393 | |||
| 2e56fe82bb | |||
| 32019c61aa | |||
| f7ffae565c | |||
| cd11bb1606 | |||
| 24c924d668 | |||
| 9be94e4b58 | |||
| 15e9d8c99d | |||
| 391f511094 | |||
| 5b53c11a6b | |||
| 9df4b6ea24 | |||
| a440564ba4 | |||
| 9583cfcc93 | |||
| c4a921283a | |||
| 4e05f087f9 | |||
| 40b506d2e0 | |||
| 263f384810 | |||
| d80c145a18 | |||
| 8848fe35f6 | |||
| 7a681bd20d | |||
| ed31fb184b | |||
| 360b94dd6c | |||
| 8524e73f59 | |||
| 940514e5ca | |||
| a4e47625ac | |||
| 7c16872a6e | |||
| 994c3c3552 | |||
| c34f496600 | |||
| 8bca8629be | |||
| 85fdd579d6 | |||
| e88d2ff88c | |||
| bdf08baebd | |||
| 3dcdd25177 | |||
| 491e8640b2 | |||
| b23b7ef85e | |||
| b167374f13 | |||
| cd1f6e733f | |||
| d3fc7687b8 | |||
| 17a83d58da | |||
| 18a8e1b6d6 | |||
| 2c23cbb359 | |||
| cdd58cf757 | |||
| a0df325659 | |||
| a59005e836 | |||
| 5da6a27e6b | |||
| ef97af71e3 | |||
| 6ed67f4532 | |||
| 1278d663b4 | |||
| 0395c7b407 | |||
| df3d15ffb3 | |||
| 6f673310d2 | |||
| 978c3eca23 | |||
| 20bc848bd6 | |||
| ce7f1292dc | |||
| d97ff8bb40 | |||
| 8a9b46d82f | |||
| 12e5703541 | |||
| 1b87fc2ee6 | |||
| ebd0c780a1 | |||
| bd976cd562 | |||
| 0e511c3e07 | |||
| 300d489408 | |||
| 024d081167 | |||
| 348173d3f1 | |||
| 23e3814f8a | |||
| b818e2c4b8 | |||
| 6adb3dc142 | |||
| 0e154cc759 | |||
| 9dce8d9bce | |||
| 0aa3b9c487 | |||
| dc7ab3ed30 | |||
| 254259b354 | |||
| 9651c70efd | |||
| 5840190ed5 | |||
| a807b88694 | |||
| 0db82e09e9 | |||
| e5865f171a | |||
| 166d198dcb | |||
| 445795f2ec | |||
| 6be4a87dac | |||
| 17c47053d6 | |||
| b4e18f7521 | |||
| fbe4d287c7 | |||
| 543fa3ae79 | |||
| 7cf855413c | |||
| f5d65dc0bc | |||
| 2f6211a1d9 | |||
| 513a57330a | |||
| 715ddf0620 | |||
| 6bb31e276e | |||
| b10f1df49f | |||
| f999519b13 | |||
| aedbf02830 | |||
| bd5479b250 | |||
| 9d14715652 | |||
| 72156fcf1b | |||
| 1c6eab00d1 | |||
| f9738c5b55 | |||
| 3b63083619 | |||
| d5d7d8bc84 | |||
| f26118cf5a | |||
| 5d6c4b475c | |||
| 2c4ef392f6 | |||
| 2a128fe772 | |||
| bb7d3ca3a1 | |||
| a2bdba7eda | |||
| e8aabc9980 | |||
| 9f554a14fd | |||
| 68a2b91ccb | |||
| 4089cc6e6f | |||
| 4e8848eeca | |||
| 8c6133c115 | |||
| 483db31acd | |||
| 35dae3dab7 | |||
| 8232aedf78 | |||
| d30a0a2e67 | |||
| d913fe508f | |||
| 4029903301 | |||
| 5db7e826d3 | |||
| 7f3e7da7c7 | |||
| 93cefde8fc | |||
| 02e7981e10 | |||
| 0ecec10af0 | |||
| 00b8cba987 | |||
| 8486bff918 | |||
| 5305eb5b8a | |||
| 377a3bb7de | |||
| 5a47e8d2c6 | |||
| 71f4cd7c85 | |||
| f7751684af | |||
| 59df1d39b2 | |||
| 7e5933e6a0 | |||
| 2cefd34bb7 | |||
| eac891dc3a | |||
| abd3599408 | |||
| 1bcd259c00 | |||
| c4e835266c | |||
| 685953f6a5 | |||
| 03fffbc724 | |||
| e1a8c932ee | |||
| 1aa2a6b054 | |||
| 1ad96c9c81 | |||
| f69199909f | |||
| d063e77040 | |||
| bf3ddeb1eb | |||
| fc261ad8cd | |||
| 90fc018295 | |||
| cdc01d9a69 | |||
| da7e76c07d | |||
| ba9118aa58 |
-105
@@ -1,105 +0,0 @@
|
||||
# Support for AppVeyor CI -- https://www.appveyor.com/
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
os: Visual Studio 2015
|
||||
|
||||
environment:
|
||||
global: { TRAVIS_OS_NAME: windows, CROSS: "", C: "", B: release, T: "", X: "" }
|
||||
matrix:
|
||||
- { C: msvc-10.0-x86, CL_VERSION: 16.00, VS_VERSION: 2010 }
|
||||
### - { C: msvc-10.0-x64, CL_VERSION: 16.00, VS_VERSION: 2010 } # AppVeyor: x64 compiler is not installed
|
||||
- { C: msvc-11.0-x86, CL_VERSION: 17.00, VS_VERSION: 2012 }
|
||||
### - { C: msvc-11.0-x64, CL_VERSION: 17.00, VS_VERSION: 2012 } # AppVeyor: x64 compiler is not installed
|
||||
- { C: msvc-12.0-x86, CL_VERSION: 18.00, VS_VERSION: 2013 }
|
||||
- { C: msvc-12.0-x64, CL_VERSION: 18.00, VS_VERSION: 2013 }
|
||||
- { C: msvc-14.0-x86, CL_VERSION: 19.00, VS_VERSION: 2015 }
|
||||
- { C: msvc-14.0-x64, CL_VERSION: 19.00, VS_VERSION: 2015 }
|
||||
# - { C: gcc-4.9-m32, T: SKIP }
|
||||
# - { C: gcc-4.9-m64, T: SKIP }
|
||||
UPX_AUTOMATIC_BUILDS_SSL_KEY:
|
||||
secure: PZMpVeqnEYe39kK+Zu2/fnmZ6/HG6Lvls0hh9GMVU9vCWsr8xaU7kIbHBS01puUkb4bEWPILKYvSEDuhOhguDjd/P4QdXWipvV/F2GaVax0=
|
||||
UPX_AUTOMATIC_BUILDS_SSL_IV:
|
||||
secure: ZshjJ/78dbY60mVJjZJv9Si7rHY9VQb1tfQvFd4lqvY=
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
- where bash & where cat & where chmod & where cp & where curl & where date & where file & where git & where gzip & where mkdir & where mv & where openssl & where readlink & where rm & where rmdir & where sed & where sha256sum & where sort & where ssh & where ssh-add & where ssh-agent & where ssh-keyscan & where tar
|
||||
# - bash --version & git --version & sed --version & tar --version
|
||||
- git --version & bash --version
|
||||
# - dir "c:\Program Files\Git\usr\bin"
|
||||
# - dir "c:\cygwin\bin"
|
||||
# - dir "c:\mingw\bin"
|
||||
# - dir "c:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin"
|
||||
|
||||
install:
|
||||
- cd c:\projects
|
||||
- md build build\%C% deps
|
||||
- cd c:\projects\upx
|
||||
- git submodule update --init --recursive
|
||||
- cd c:\projects\deps
|
||||
- curl -q -L --retry 5 -o ucl-1.03.tar.gz "https://github.com/upx/upx/releases/download/v3.00/ucl-1.03.tar.gz"
|
||||
- curl -q -L --retry 5 -o zlib-1.2.8.tar.gz "https://github.com/upx/upx/releases/download/v3.00/zlib-1.2.8.tar.gz"
|
||||
- git clone https://github.com/upx/upx-testsuite
|
||||
- tar -xzf ucl-1.03.tar.gz
|
||||
- tar -xzf zlib-1.2.8.tar.gz
|
||||
# patch UCL for msvc-14.0 (vsnprintf issue)
|
||||
- sed -i '/# *define.*snprintf *_v*snprintf$/d' ucl-1.03/acc/acc_auto.h
|
||||
##- curl -q -L --retry 5 -o config.guess "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"
|
||||
##- curl -q -L --retry 5 -o config.sub "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD"
|
||||
##- cp config.guess config.sub ucl-1.03/acconfig/
|
||||
# setup compiler
|
||||
- if "%C%"=="msvc-10.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 )
|
||||
- if "%C%"=="msvc-10.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 )
|
||||
- if "%C%"=="msvc-11.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86 )
|
||||
- if "%C%"=="msvc-11.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64 )
|
||||
- if "%C%"=="msvc-12.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86 )
|
||||
- if "%C%"=="msvc-12.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64 )
|
||||
- if "%C%"=="msvc-14.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 )
|
||||
- if "%C%"=="msvc-14.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 )
|
||||
|
||||
build_script:
|
||||
- cd c:\projects\upx
|
||||
- if "%C%"=="gcc-4.9-m32" set PATH=c:\cygwin\bin;%PATH%
|
||||
- if "%C%"=="gcc-4.9-m32" bash -x ./.github/travis_build.sh
|
||||
- if "%C%"=="gcc-4.9-m32" exit
|
||||
- if "%C%"=="gcc-4.9-m64" set PATH=c:\cygwin\bin;%PATH%
|
||||
- if "%C%"=="gcc-4.9-m64" bash -x ./.github/travis_build.sh
|
||||
- if "%C%"=="gcc-4.9-m64" exit
|
||||
# setup directories following the VPATH build in travis_build.sh
|
||||
- where cl & where link
|
||||
- set BDIR=c:\projects\build\%C%\%B%
|
||||
- md %BDIR% %BDIR%\ucl-1.03 %BDIR%\upx %BDIR%\upx-testsuite %BDIR%\zlib-1.2.8
|
||||
- set DEFS=-D_CRT_SECURE_NO_WARNINGS
|
||||
- git rev-parse --short=12 HEAD > %BDIR%\upx\.GITREV.txt
|
||||
# build UCL
|
||||
- cd %BDIR%\ucl-1.03
|
||||
- set s=c:\projects\deps\ucl-1.03
|
||||
- cl -MT -O2 -W4 %DEFS% -I%s%\include -I%s% -c %s%\src\*.c
|
||||
- link -lib -out:ucl.lib *.obj
|
||||
# build zlib
|
||||
- cd %BDIR%\zlib-1.2.8
|
||||
- cl -MT -O2 -W2 %DEFS% -c c:\projects\deps\zlib-1.2.8\*.c
|
||||
- link -lib -out:zlib.lib *.obj
|
||||
# build UPX
|
||||
- cd %BDIR%\upx
|
||||
- set s=c:\projects\upx\src
|
||||
- cat .GITREV.txt
|
||||
- set /p GITREV=<.GITREV.txt
|
||||
- cl -MT -EHsc -J -O2 -W4 -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -DWITH_LZMA=0x443 -DUCL_NO_ASM -I%s%\lzma-sdk -Ic:\projects\deps\ucl-1.03\include -Ic:\projects\deps\zlib-1.2.8 -Feupx.exe %s%\*.cpp %BDIR%\ucl-1.03\ucl.lib %BDIR%\zlib-1.2.8\zlib.lib
|
||||
|
||||
test_script:
|
||||
- set UPX=--no-color --no-progress
|
||||
- cd %BDIR%\upx
|
||||
# basic tests
|
||||
- .\upx.exe --version
|
||||
- .\upx.exe upx.exe -o upx_packed.exe
|
||||
- dir *.exe
|
||||
- .\upx.exe -l upx_packed.exe
|
||||
- .\upx.exe -t upx_packed.exe
|
||||
- .\upx_packed.exe --version
|
||||
# now run the UPX testsuite using bash
|
||||
- cd c:\projects\upx
|
||||
- bash ./.github/travis_testsuite_1.sh
|
||||
- bash ./.github/travis_deploy.sh
|
||||
|
||||
# vim:set ts=2 sw=2 et:
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
# Support for Circle CI -- https://circleci.com/gh/upx/upx
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
machine:
|
||||
environment:
|
||||
TRAVIS_OS_NAME: linux
|
||||
CROSS:
|
||||
C: gcc-4.8-m64
|
||||
B: release
|
||||
T:
|
||||
X:
|
||||
|
||||
checkout:
|
||||
post:
|
||||
- git submodule update --init --recursive
|
||||
|
||||
dependencies:
|
||||
pre:
|
||||
- mkdir -p ../deps
|
||||
- cd ../deps && wget -q -O - https://github.com/upx/upx/releases/download/v3.00/ucl-1.03.tar.xz | tar -xJ
|
||||
- cd ../deps && wget -q -O - https://github.com/upx/upx/releases/download/v3.00/zlib-1.2.8.tar.xz | tar -xJ
|
||||
- cd ../deps && git clone https://github.com/upx/upx-testsuite
|
||||
override:
|
||||
- mkdir -p ../build/travis
|
||||
- bash ./.github/travis_build.sh
|
||||
|
||||
test:
|
||||
override:
|
||||
- bash ./.github/travis_testsuite_1.sh
|
||||
|
||||
# vim:set ts=2 sw=2 et:
|
||||
@@ -0,0 +1,50 @@
|
||||
# "Gofmt's style is nobody's favourite, but gofmt is everybody's favourite." --Rob Pike
|
||||
#
|
||||
# for clang-format-15.0.6 from https://github.com/upx/upx-stubtools/releases
|
||||
---
|
||||
BasedOnStyle: LLVM
|
||||
ColumnLimit: 100
|
||||
IndentWidth: 4
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignConsecutiveMacros: AcrossComments
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
AttributeMacros:
|
||||
- __acc_cdecl
|
||||
- __acc_cdecl_atexit
|
||||
- __acc_cdecl_qsort
|
||||
- __acc_cdecl_sighandler
|
||||
- __acc_forceinline
|
||||
- __acc_noinline
|
||||
- __acc_static_forceinline
|
||||
- __acc_static_noinline
|
||||
- DELETED_FUNCTION
|
||||
- XSPAN_DELETED_FUNCTION
|
||||
- forceinline
|
||||
- may_throw
|
||||
- noinline
|
||||
- static_forceinline
|
||||
- static_noinline
|
||||
EmptyLineBeforeAccessModifier: Leave
|
||||
SortIncludes: false
|
||||
SpaceAfterCStyleCast: true
|
||||
Standard: Cpp03
|
||||
StatementMacros:
|
||||
- ACCCHK_ASSERT
|
||||
- ACCCHK_ASSERT_IS_SIGNED_T
|
||||
- ACCCHK_ASSERT_IS_UNSIGNED_T
|
||||
- ACCCHK_ASSERT_SIGN_T
|
||||
- ACC_BLOCK_BEGIN
|
||||
- ACC_COMPILE_TIME_ASSERT
|
||||
- ACC_COMPILE_TIME_ASSERT_HEADER
|
||||
- ACC_CXX_DISABLE_NEW_DELETE
|
||||
- ACC_CXX_TRIGGER_FUNCTION
|
||||
- ACC_CXX_TRIGGER_FUNCTION_IMPL
|
||||
- CLANG_FORMAT_DUMMY_STATEMENT
|
||||
- COMPILE_TIME_ASSERT
|
||||
- COMPILE_TIME_ASSERT_ALIGNED1
|
||||
WhitespaceSensitiveMacros:
|
||||
- ACC_PP_MACRO_EXPAND
|
||||
- ACC_PP_STRINGIZE
|
||||
...
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-branch-clone,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-empty-catch,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-reserved-identifier,
|
||||
-bugprone-sizeof-expression,
|
||||
-bugprone-suspicious-include,
|
||||
-bugprone-suspicious-memory-comparison,
|
||||
-bugprone-suspicious-string-compare,
|
||||
-bugprone-switch-missing-default-case,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-optin.performance.Padding,
|
||||
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
-clang-analyzer-security.insecureAPI.strcpy,
|
||||
clang-diagnostics-*',
|
||||
performance-*,
|
||||
-performance-avoid-endl,
|
||||
-performance-unnecessary-value-param,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
InheritParentConfig: false
|
||||
...
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# see http://editorconfig.org/
|
||||
#
|
||||
# see https://editorconfig.org/
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# see https://github.com/github-linguist/linguist
|
||||
#
|
||||
# HINT: check settings with
|
||||
# git ls-files | git check-attr --stdin --all
|
||||
|
||||
#
|
||||
# tell diff tools that these files are generated automatically
|
||||
#
|
||||
|
||||
/doc/upx.1 linguist-generated
|
||||
/doc/upx-doc.* linguist-generated
|
||||
|
||||
/src/stub/*.h linguist-generated
|
||||
/src/stub/src/arch/**/lzma_d_c[fns].S linguist-generated
|
||||
/src/stub/tmp/** linguist-generated
|
||||
|
||||
#
|
||||
# make GitHub language detection more accurate
|
||||
#
|
||||
|
||||
/src/*.h linguist-language=C++
|
||||
/src/*/*.h linguist-language=C++
|
||||
|
||||
/src/stub/**/*.ash linguist-language=Assembly
|
||||
/src/stub/**/*.asm linguist-language=Assembly
|
||||
/src/stub/**/*.S linguist-language=Assembly
|
||||
|
||||
/src/stub/tmp/** linguist-vendored
|
||||
@@ -0,0 +1,11 @@
|
||||
* @markus-oberhumer @jreiser
|
||||
|
||||
/src/p_elf* @jreiser
|
||||
/src/p_lx_* @jreiser
|
||||
/src/p_mach* @jreiser
|
||||
/src/p_unix* @jreiser
|
||||
/src/p_vmlin* @jreiser
|
||||
|
||||
/src/stub/src/*bsd.* @jreiser
|
||||
/src/stub/src/*darwin.* @jreiser
|
||||
/src/stub/src/*linux.* @jreiser
|
||||
@@ -1,3 +1,15 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
This issue tracker is **ONLY** used for reporting bugs.
|
||||
Please use [stackoverflow](https://stackoverflow.com) for supporting issues.
|
||||
|
||||
<!---
|
||||
|
||||
IF YOU REMOVE THIS TEMPLATE WE WILL CLOSE YOUR ISSUE WITHOUT RESPONSE.
|
||||
@@ -27,5 +39,7 @@ Just read it and fill in the details we're asking, it saves so much of our time.
|
||||
## Please tell us details about your environment.
|
||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||
* UPX version used (`upx --version`):
|
||||
* Operating System and version:
|
||||
* CPU architecture:
|
||||
* Host Operating System and version:
|
||||
* Host CPU architecture:
|
||||
* Target Operating System and version:
|
||||
* Target CPU architecture:
|
||||
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
||||
@@ -0,0 +1,45 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
This issue tracker is **ONLY** used for requesting sensible features.
|
||||
Please use [stackoverflow](https://stackoverflow.com) for supporting issues.
|
||||
|
||||
<!---
|
||||
|
||||
IF YOU REMOVE THIS TEMPLATE WE WILL CLOSE YOUR ISSUE WITHOUT RESPONSE.
|
||||
Just read it and fill in the details we're asking, it saves so much of our time. Thanks!
|
||||
|
||||
-->
|
||||
|
||||
## What's the problem (or question)?
|
||||
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||
|
||||
## What should have happened?
|
||||
<!--- If you're describing a bug, tell us what should happen -->
|
||||
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
||||
|
||||
## Do you have an idea for a solution?
|
||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||
<!--- or ideas how to implement the addition or change -->
|
||||
|
||||
## How can we reproduce the issue?
|
||||
<!--- Provide unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant -->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
## Please tell us details about your environment.
|
||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||
* UPX version used (`upx --version`):
|
||||
* Host Operating System and version:
|
||||
* Host CPU architecture:
|
||||
* Target Operating System and version:
|
||||
* Target CPU architecture:
|
||||
@@ -0,0 +1,8 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: 'github-actions'
|
||||
directory: '/'
|
||||
schedule:
|
||||
# Check for updates to GitHub Actions every Wednesday
|
||||
interval: 'weekly'
|
||||
day: 'wednesday'
|
||||
@@ -0,0 +1,14 @@
|
||||
UPX PULL REQUEST NOTES
|
||||
======================
|
||||
|
||||
Handling pull requests is actually quite time consuming, so please
|
||||
|
||||
- if you want to contribute **a real C++ code bug-fix** then open an issue
|
||||
on the main UPX issue tracker first
|
||||
|
||||
- if you want to contribute **a new feature** then by all means open an issue
|
||||
on the main UPX issue tracker first before starting any coding!
|
||||
|
||||
- please refuse the temptation to "improve" the docs, scripts, CI, makefiles,
|
||||
cmake build system, spelling errors, etc - we will NOT merge this; only open
|
||||
an issue if you're sure there is a **real bug**
|
||||
@@ -0,0 +1,15 @@
|
||||
# Security Context
|
||||
|
||||
IMPORTANT NOTE: UPX inherits the security context of any files it handles.
|
||||
|
||||
This means that packing, unpacking, or even testing or listing a file requires
|
||||
the same security considerations as actually executing the file.
|
||||
|
||||
Use UPX on trusted files only!
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| --------- | ------------------ |
|
||||
| git HEAD | :white_check_mark: |
|
||||
| any other | :x: |
|
||||
@@ -1,139 +0,0 @@
|
||||
#! /bin/bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
|
||||
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
if [[ $TRAVIS_OS_NAME == osx ]]; then
|
||||
argv0=$0; argv0abs=$(greadlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
|
||||
else
|
||||
argv0=$0; argv0abs=$(readlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
|
||||
fi
|
||||
source "$argv0dir/travis_init.sh" || exit 1
|
||||
|
||||
# create dirs
|
||||
cd / || exit 1
|
||||
mkbuilddirs $upx_BUILDDIR $ucl_BUILDDIR $upx_testsuite_BUILDDIR $zlib_BUILDDIR
|
||||
cd / && cd $upx_SRCDIR || exit 1
|
||||
|
||||
echo
|
||||
print_settings
|
||||
echo
|
||||
echo "$CC --version"; $CC --version
|
||||
echo "$CXX --version"; $CXX --version
|
||||
echo
|
||||
|
||||
# check whitespace
|
||||
if [[ $TRAVIS_OS_NAME == linux ]]; then
|
||||
cd / && cd $upx_SRCDIR || exit 1
|
||||
echo "Checking source code for whitespace violations..."
|
||||
bash ./src/stub/scripts/check_whitespace.sh || exit 1
|
||||
echo " Passed."
|
||||
fi # linux
|
||||
|
||||
set -x
|
||||
|
||||
#
|
||||
# rebuild UPX stubs (needs upx-stubtools)
|
||||
#
|
||||
|
||||
if [[ $BM_X =~ (^|\+)rebuild-stubs($|\+) ]]; then
|
||||
bin_upx=$(readlink -en -- "$upx_SRCDIR/../deps/bin-upx-20160918")
|
||||
cd / && cd $upx_SRCDIR || exit 1
|
||||
make -C src/stub maintainer-clean
|
||||
failed=0
|
||||
PATH="$bin_upx:$PATH" make -C src/stub all || failed=1
|
||||
if [[ $failed != 0 ]]; then
|
||||
echo "UPX-ERROR: FATAL: rebuild-stubs failed"
|
||||
exit 1
|
||||
fi
|
||||
if ! git diff --quiet; then
|
||||
git status || true
|
||||
git diff || true
|
||||
echo "UPX-ERROR: FATAL: rebuild-stubs git status mismatch. See log file."
|
||||
exit 1
|
||||
fi
|
||||
if [[ $BM_X == rebuild-stubs ]]; then
|
||||
echo "X=rebuild-stubs done. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
unset bin_upx failed
|
||||
fi
|
||||
|
||||
#
|
||||
# build UCL
|
||||
#
|
||||
|
||||
cd / && cd $ucl_BUILDDIR || exit 1
|
||||
if [[ -n $BM_CROSS || $TRAVIS_OS_NAME == windows ]]; then
|
||||
# ucl-1.03/configure is too old - build manually
|
||||
rm -f ./*.o libucl.a
|
||||
$CC -O2 -I$ucl_SRCDIR/include -I$ucl_SRCDIR -c $ucl_SRCDIR/src/*.c
|
||||
$AR rcs libucl.a *.o
|
||||
mkdir -p src/.libs
|
||||
cp libucl.a src/.libs
|
||||
else
|
||||
if [[ ! -f config.status ]]; then
|
||||
$ucl_SRCDIR/configure --enable-static --disable-shared --disable-asm
|
||||
fi
|
||||
make
|
||||
fi
|
||||
|
||||
#
|
||||
# build zlib
|
||||
#
|
||||
|
||||
if [[ $BUILD_LOCAL_ZLIB == 1 ]]; then
|
||||
cd / && cd $zlib_BUILDDIR || exit 1
|
||||
# build manually
|
||||
rm -f ./*.o libz.a
|
||||
$CC -O2 -c $zlib_SRCDIR/*.c
|
||||
$AR rcs libz.a *.o
|
||||
fi
|
||||
|
||||
#
|
||||
# build UPX
|
||||
#
|
||||
|
||||
export UPX_UCLDIR="$ucl_SRCDIR"
|
||||
cd / && cd $upx_BUILDDIR || exit 1
|
||||
make="make -f $upx_SRCDIR/src/Makefile"
|
||||
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DUCL_NO_ASM"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$ucl_BUILDDIR/src/.libs"
|
||||
if [[ $BUILD_LOCAL_ZLIB == 1 ]]; then
|
||||
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -I$zlib_SRCDIR"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$zlib_BUILDDIR"
|
||||
fi
|
||||
if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then
|
||||
EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -fprofile-arcs -ftest-coverage"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
|
||||
fi
|
||||
if [[ $BM_B =~ (^|\+)debug($|\+) ]]; then
|
||||
make="$make BUILD_TYPE_DEBUG=1"
|
||||
fi
|
||||
if [[ $BM_B =~ (^|\+)sanitize($|\+) ]]; then
|
||||
case $TRAVIS_OS_NAME-$CC in linux-gcc*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fuse-ld=gold" ;; esac
|
||||
make="$make BUILD_TYPE_SANITIZE=1"
|
||||
fi
|
||||
if [[ $BM_B =~ (^|\+)scan-build($|\+) ]]; then
|
||||
make="$SCAN_BUILD $make"
|
||||
fi
|
||||
if [[ $BM_B =~ (^|\+)valgrind($|\+) ]]; then
|
||||
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DWITH_VALGRIND"
|
||||
fi
|
||||
if [[ $BM_B =~ (^|\+)ALLOW_FAIL($|\+) ]]; then
|
||||
echo "ALLOW_FAIL"
|
||||
set +e
|
||||
fi
|
||||
export EXTRA_CPPFLAGS EXTRA_CXXFLAGS EXTRA_LDFLAGS
|
||||
|
||||
[[ -z $upx_exeext ]] && upx_exeext=.out
|
||||
$make exeext=$upx_exeext
|
||||
|
||||
pwd
|
||||
ls -l upx${upx_exeext}
|
||||
$SIZE upx${upx_exeext} || true
|
||||
file upx${upx_exeext}
|
||||
|
||||
exit 0
|
||||
@@ -1,174 +0,0 @@
|
||||
#! /bin/bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
|
||||
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
if [[ $TRAVIS_OS_NAME == osx ]]; then
|
||||
argv0=$0; argv0abs=$(greadlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
|
||||
else
|
||||
argv0=$0; argv0abs=$(readlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
|
||||
fi
|
||||
source "$argv0dir/travis_init.sh" || exit 1
|
||||
|
||||
set -x # debug
|
||||
|
||||
if [[ $BM_X == rebuild-stubs ]]; then exit 0; fi
|
||||
# save space
|
||||
if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then exit 0; fi
|
||||
if [[ $BM_B =~ (^|\+)debug($|\+) ]]; then exit 0; fi
|
||||
if [[ $BM_B =~ (^|\+)sanitize($|\+) ]]; then exit 0; fi
|
||||
if [[ $BM_B =~ (^|\+)scan-build($|\+) ]]; then exit 0; fi
|
||||
if [[ $BM_B =~ (^|\+)valgrind($|\+) ]]; then exit 0; fi
|
||||
|
||||
# prepare $subdir and $branch
|
||||
subdir=
|
||||
branch=
|
||||
if [[ -n $APPVEYOR_JOB_ID ]]; then
|
||||
branch=$APPVEYOR_REPO_BRANCH
|
||||
if [[ -n $APPVEYOR_PULL_REQUEST_NUMBER ]]; then exit 0; fi
|
||||
elif [[ -n $GITLAB_CI ]]; then
|
||||
subdir=$CI_BUILD_NAME
|
||||
branch=$CI_BUILD_REF_NAME
|
||||
else
|
||||
branch=$TRAVIS_BRANCH
|
||||
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then exit 0; fi
|
||||
fi
|
||||
subdir=${subdir%%:*}; subdir=${subdir%%/*}; subdir=${subdir%%-*}
|
||||
case $branch in
|
||||
devel*) ;;
|
||||
master*) ;;
|
||||
travis*) ;;
|
||||
*) exit 0;;
|
||||
esac
|
||||
|
||||
# get $rev, $branch and $git_user
|
||||
cd / && cd $upx_SRCDIR || exit 1
|
||||
rev=$(git rev-parse --verify HEAD)
|
||||
timestamp=$(git log -n1 --format='%at' HEAD)
|
||||
date=$(TZ=UTC0 date -d "@$timestamp" '+%Y%m%d-%H%M%S')
|
||||
#branch="$branch-$date-${rev:0:6}"
|
||||
# make the branch name a little bit shorter so that it looks nice on GitHub
|
||||
branch="$branch-${date:0:8}-${rev:0:7}"
|
||||
if [[ -n $APPVEYOR_JOB_ID ]]; then
|
||||
branch="$branch-appveyor"
|
||||
git_user="AppVeyor CI"
|
||||
elif [[ -n $GITLAB_CI ]]; then
|
||||
branch="$branch-gitlab"
|
||||
git_user="GitLab CI"
|
||||
else
|
||||
branch="$branch-travis"
|
||||
git_user="Travis CI"
|
||||
fi
|
||||
unset timestamp date
|
||||
|
||||
# /***********************************************************************
|
||||
# // prepare directory $d
|
||||
# ************************************************************************/
|
||||
|
||||
cd / && cd $upx_BUILDDIR || exit 1
|
||||
|
||||
mkdir deploy || exit 1
|
||||
chmod 700 deploy
|
||||
cd deploy || exit 1
|
||||
|
||||
if [[ -n $BM_CROSS ]]; then
|
||||
d=$BM_CROSS
|
||||
else
|
||||
cpu=unknown
|
||||
case $BM_C in
|
||||
clang*-m32 | gcc*-m32) cpu=i386;;
|
||||
clang*-m64 | gcc*-m64) cpu=amd64;;
|
||||
clang*-mx32 | gcc*-mx32) cpu=amd64;;
|
||||
msvc*-x86) cpu=i386;;
|
||||
msvc*-x64) cpu=amd64;;
|
||||
esac
|
||||
os=$TRAVIS_OS_NAME
|
||||
if [[ $os == osx ]]; then
|
||||
os=darwin
|
||||
elif [[ $os == windows ]]; then
|
||||
[[ $cpu == i386 ]] && os=win32
|
||||
[[ $cpu == amd64 ]] && os=win64
|
||||
fi
|
||||
d=$cpu-$os
|
||||
fi
|
||||
d=$d-$BM_C-$BM_B
|
||||
|
||||
mkdir $d || exit 1
|
||||
for exeext in .exe .out; do
|
||||
f=$upx_BUILDDIR/upx$exeext
|
||||
if [[ -f $f ]]; then
|
||||
cp -p -i $f $d/upx-git-${rev:0:12}$exeext
|
||||
sha256sum -b $d/upx-git-${rev:0:12}$exeext
|
||||
fi
|
||||
done
|
||||
|
||||
# /***********************************************************************
|
||||
# // clone, add files & push
|
||||
# ************************************************************************/
|
||||
|
||||
new_branch=0
|
||||
if ! git clone -b $branch --single-branch https://github.com/upx/upx-automatic-builds.git; then
|
||||
git clone -b master --single-branch https://github.com/upx/upx-automatic-builds.git
|
||||
new_branch=1
|
||||
fi
|
||||
cd upx-automatic-builds || exit 1
|
||||
chmod 700 .git
|
||||
git config user.name "$git_user"
|
||||
git config user.email "none@none"
|
||||
if [[ $new_branch == 1 ]]; then
|
||||
git checkout --orphan $branch
|
||||
git reset --hard
|
||||
fi
|
||||
|
||||
if [[ -n $subdir ]]; then
|
||||
[[ -d $subdir ]] || mkdir $subdir
|
||||
mv ../$d $subdir/
|
||||
git add $subdir/$d
|
||||
else
|
||||
mv ../$d .
|
||||
git add $d
|
||||
fi
|
||||
|
||||
if git diff --cached --exit-code --quiet >/dev/null; then
|
||||
# nothing to do ???
|
||||
exit 0
|
||||
fi
|
||||
|
||||
now=$(date '+%s')
|
||||
##date=$(TZ=UTC0 date -d "@$now" '+%Y-%m-%d %H:%M:%S')
|
||||
git commit --date="$now" -m "Automatic build $d"
|
||||
git ls-files
|
||||
#git log --pretty=fuller
|
||||
|
||||
umask 077
|
||||
[[ -d ~/.ssh ]] || mkdir ~/.ssh
|
||||
repo=$(git config remote.origin.url)
|
||||
ssh_repo=${repo/https:\/\/github.com\//git@github.com:}
|
||||
eval $(ssh-agent -s)
|
||||
set +x # IMPORTANT
|
||||
openssl aes-256-cbc -d -a -K "$UPX_AUTOMATIC_BUILDS_SSL_KEY" -iv "$UPX_AUTOMATIC_BUILDS_SSL_IV" -in "$upx_SRCDIR/.github/upx-automatic-builds@github.com.enc" -out .git/deploy.key
|
||||
set -x
|
||||
chmod 600 .git/deploy.key
|
||||
ssh-add .git/deploy.key
|
||||
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
|
||||
|
||||
let i=0 || true
|
||||
while true; do
|
||||
if [[ $i -ge 10 ]]; then
|
||||
echo "ERROR: git push failed"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $new_branch == 1 ]]; then
|
||||
if git push -u $ssh_repo $branch; then break; fi
|
||||
else
|
||||
if git push $ssh_repo $branch; then break; fi
|
||||
fi
|
||||
git fetch -v origin $branch
|
||||
git rebase origin/$branch
|
||||
sleep $((RANDOM % 5 + 1))
|
||||
let i+=1
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -1,240 +0,0 @@
|
||||
## vim:set ts=4 sw=4 et:
|
||||
|
||||
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
#set -x # debug
|
||||
umask 022
|
||||
export GIT_PAGER=
|
||||
|
||||
# rename short variables to more readable Build-Matrix BM_ names
|
||||
# C is COMPILER
|
||||
# B is BUILD_OPTIONS
|
||||
# T is TESTSUITE_OPTIONS
|
||||
# X is EXTRA_OPTIONS
|
||||
BM_CROSS=$CROSS; BM_C=$C; BM_B=$B; BM_T=$T; BM_X=$X
|
||||
unset CROSS C B T X
|
||||
[[ -z $BM_C ]] && BM_C=gcc
|
||||
[[ -z $BM_B ]] && BM_B=release
|
||||
|
||||
# just in case, unset variable for passing extra UPX options
|
||||
export UPX=
|
||||
# un-export some vars
|
||||
declare +x UPX_AUTOMATIC_BUILDS_SSL_KEY UPX_AUTOMATIC_BUILDS_SSL_IV
|
||||
|
||||
# compatibility wrappers
|
||||
if [[ $TRAVIS_OS_NAME == osx ]]; then
|
||||
# use GNU coreutils ("brew install coreutils")
|
||||
date() {
|
||||
gdate "$@"
|
||||
}
|
||||
readlink() {
|
||||
greadlink "$@"
|
||||
}
|
||||
sha256sum() {
|
||||
gsha256sum "$@"
|
||||
}
|
||||
fi
|
||||
if [[ -n $APPVEYOR_JOB_ID ]]; then
|
||||
openssl() {
|
||||
/usr/bin/openssl "$@"
|
||||
}
|
||||
sort() {
|
||||
/usr/bin/sort "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# set CC and CXX from BM_C and BM_CROSS
|
||||
if [[ -z $CC_OVERRIDE ]]; then
|
||||
CC=false CXX=false SCAN_BUILD=false
|
||||
AR=ar SIZE=size
|
||||
if [[ -n $APPVEYOR_JOB_ID ]]; then
|
||||
BUILD_LOCAL_ZLIB=1
|
||||
if [[ $BM_C =~ (^|\-)(clang|gcc)($|\-) ]]; then
|
||||
export upx_EXTRA_LDFLAGS="-static-libgcc -static-libstdc++"
|
||||
fi
|
||||
upx_exeext=.exe
|
||||
# dir c:\cygwin
|
||||
case $BM_C in
|
||||
gcc-m32 | gcc-4.9-m32)
|
||||
x=i686-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m32"; CXX="$x-g++ -m32" ;;
|
||||
gcc-m64 | gcc-4.9-m64)
|
||||
x=x86_64-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m64"; CXX="$x-g++ -m64" ;;
|
||||
msvc | msvc-*)
|
||||
AR="link -lib"; CC="cl"; CXX="cl" ;; # standard system compiler
|
||||
esac
|
||||
fi # APPVEYOR_JOB_ID
|
||||
if [[ -n $BM_CROSS ]]; then
|
||||
BUILD_LOCAL_ZLIB=1
|
||||
if [[ $BM_C =~ (^|\-)(clang|gcc)($|\-) ]]; then
|
||||
export upx_EXTRA_LDFLAGS="-static-libgcc -static-libstdc++"
|
||||
fi
|
||||
cat /etc/os-release || true
|
||||
if egrep -q '^PRETTY_NAME="?Ubuntu .*12\.04' /etc/os-release; then
|
||||
case $BM_CROSS-$BM_C in
|
||||
arm-linux-gnueabi-gcc | arm-linux-gnueabi-gcc-4.6)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-arm -L /usr/arm-linux-gnueabi"
|
||||
x=arm-linux-gnueabi; AR="$x-ar"; CC="$x-gcc"; CXX="$x-g++" ;;
|
||||
arm-linux-gnueabihf-gcc | arm-linux-gnueabihf-gcc-4.6)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-arm -L /usr/arm-linux-gnueabihf"
|
||||
x=arm-linux-gnueabihf; AR="$x-ar"; CC="$x-gcc"; CXX="$x-g++" ;;
|
||||
i[36]86-w64-mingw32-gcc | i[36]86-w64-mingw32-gcc-4.6)
|
||||
upx_exeext=.exe
|
||||
[[ -z $upx_wine ]] && upx_wine="wine"
|
||||
x=i686-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m32"; CXX="$x-g++ -m32" ;;
|
||||
x86_64-w64-mingw32-gcc | x86_64-w64-mingw32-gcc-4.6)
|
||||
upx_exeext=.exe
|
||||
[[ -z $upx_wine ]] && upx_wine="wine"
|
||||
x=x86_64-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m64"; CXX="$x-g++ -m64" ;;
|
||||
esac
|
||||
elif egrep -q '^PRETTY_NAME="?Ubuntu 16\.04' /etc/os-release; then
|
||||
case $BM_CROSS-$BM_C in
|
||||
aarch64-linux-gnu-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-aarch64 -L /usr/aarch64-linux-gnu"
|
||||
x=aarch64-linux-gnu; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
arm-linux-gnueabi-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-arm -L /usr/arm-linux-gnueabi"
|
||||
x=arm-linux-gnueabi; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
arm-linux-gnueabihf-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-arm -L /usr/arm-linux-gnueabihf"
|
||||
x=arm-linux-gnueabihf; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
i[36]86-w64-mingw32-gcc-5)
|
||||
upx_exeext=.exe
|
||||
[[ -z $upx_wine ]] && upx_wine="wine"
|
||||
x=i686-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m32"; CXX="$x-g++ -m32" ;;
|
||||
mips-linux-gnu-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-mips -L /usr/mips-linux-gnu"
|
||||
x=mips-linux-gnu; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
mipsel-linux-gnu-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-mipsel -L /usr/mipsel-linux-gnu"
|
||||
x=mipsel-linux-gnu; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
powerpc-linux-gnu-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-ppc -L /usr/powerpc-linux-gnu"
|
||||
x=powerpc-linux-gnu; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
powerpc64-linux-gnu-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-ppc64 -L /usr/powerpc64-linux-gnu"
|
||||
x=powerpc64-linux-gnu; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
powerpc64le-linux-gnu-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-ppc64le -L /usr/powerpc64le-linux-gnu"
|
||||
x=powerpc64le-linux-gnu; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
s390x-linux-gnu-gcc-5)
|
||||
[[ -z $upx_qemu ]] && upx_qemu="qemu-s390x -L /usr/s390x-linux-gnu"
|
||||
x=s390x-linux-gnu; AR="$x-ar"; CC="$x-gcc-5"; CXX="$x-g++-5" ;;
|
||||
x86_64-w64-mingw32-gcc-5)
|
||||
upx_exeext=.exe
|
||||
[[ -z $upx_wine ]] && upx_wine="wine"
|
||||
x=x86_64-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m64"; CXX="$x-g++ -m64" ;;
|
||||
esac
|
||||
fi
|
||||
fi # BM_CROSS
|
||||
if [[ "$CC" == "false" ]]; then # generic
|
||||
if [[ -z $BM_CROSS ]]; then
|
||||
case $BM_C in
|
||||
clang | clang-m?? | clang-3.4-m?? | clang-[678][0-9][0-9]-m??)
|
||||
CC="clang"; CXX="clang++" ;; # standard system compiler
|
||||
clang-[3].[0-9]-m??)
|
||||
v=${BM_C:6:3}; CC="clang-$v"; CXX="clang++-$v"; SCAN_BUILD="scan-build-$v" ;;
|
||||
gcc | gcc-m?? | gcc-mx32)
|
||||
CC="gcc"; CXX="g++" ;; # standard system compiler
|
||||
gcc-[34].[0-9]-m?? | gcc-[34].[0-9]-mx32)
|
||||
v=${BM_C:4:3}; CC="gcc-$v"; CXX="g++-$v" ;;
|
||||
gcc-[56]-m?? | gcc-[56]-mx32)
|
||||
v=${BM_C:4:1}; CC="gcc-$v"; CXX="g++-$v" ;;
|
||||
esac
|
||||
fi
|
||||
fi # generic
|
||||
case $BM_C in
|
||||
clang*-m32) CC="$CC -m32"; CXX="$CXX -m32" ;;
|
||||
clang*-m64) CC="$CC -m64"; CXX="$CXX -m64" ;;
|
||||
gcc*-m32) CC="$CC -m32"; CXX="$CXX -m32" ;;
|
||||
gcc*-m64) CC="$CC -m64"; CXX="$CXX -m64" ;;
|
||||
gcc*-mx32) CC="$CC -mx32"; CXX="$CXX -mx32" ;;
|
||||
esac
|
||||
if [[ $BM_C =~ (^|\-)(clang|gcc)($|\-) ]]; then
|
||||
CC="$CC -std=gnu89"
|
||||
fi
|
||||
unset v x
|
||||
export AR CC CXX
|
||||
fi # CC_OVERRIDE
|
||||
|
||||
# source dirs
|
||||
[[ -z $upx_SRCDIR ]] && upx_SRCDIR=$(readlink -mn -- $argv0dir/..)
|
||||
[[ -z $ucl_SRCDIR ]] && ucl_SRCDIR=$(readlink -mn -- $upx_SRCDIR/../deps/ucl-1.03)
|
||||
[[ -z $upx_testsuite_SRCDIR ]] && upx_testsuite_SRCDIR=$(readlink -mn -- $upx_SRCDIR/../deps/upx-testsuite)
|
||||
[[ -z $zlib_SRCDIR ]] && zlib_SRCDIR=$(readlink -mn -- $upx_SRCDIR/../deps/zlib-1.2.8)
|
||||
|
||||
# build dirs
|
||||
mkbuilddirs() {
|
||||
local d
|
||||
for d in "$@"; do
|
||||
mkdir -p -v "$d" || exit 1
|
||||
[[ -f "$d/.mfxnobackup" ]] || touch "$d/.mfxnobackup"
|
||||
done
|
||||
}
|
||||
# search for an existing $toptop_builddir
|
||||
if [[ -z $toptop_builddir ]]; then
|
||||
for d in . ..; do
|
||||
for subdir in "local" appveyor circle gitlab travis .; do
|
||||
dd=$d/build/$subdir
|
||||
if [[ -d $dd ]]; then
|
||||
toptop_builddir=$(readlink -en -- "$dd")
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
unset d subdir dd
|
||||
fi
|
||||
[[ -z $toptop_builddir ]] && toptop_builddir=$(readlink -mn -- ./build)
|
||||
[[ -z $toptop_bdir ]] && toptop_bdir=$(readlink -mn -- "$toptop_builddir/${BM_CROSS:+$BM_CROSS-}$BM_C/$BM_B")
|
||||
[[ -z $upx_BUILDDIR ]] && upx_BUILDDIR=$(readlink -mn -- "$toptop_bdir/upx")
|
||||
[[ -z $ucl_BUILDDIR ]] && ucl_BUILDDIR=$(readlink -mn -- "$toptop_bdir/ucl-1.03")
|
||||
[[ -z $upx_testsuite_BUILDDIR ]] && upx_testsuite_BUILDDIR=$(readlink -mn -- "$toptop_bdir/upx-testsuite")
|
||||
[[ -z $zlib_BUILDDIR ]] && zlib_BUILDDIR=$(readlink -mn -- "$toptop_bdir/zlib-1.2.8")
|
||||
[[ -z $lcov_OUTPUTDIR ]] && lcov_OUTPUTDIR=$(readlink -mn -- "$toptop_bdir/.lcov-results")
|
||||
unset toptop_builddir toptop_bdir
|
||||
|
||||
# ensure absolute directories
|
||||
make_absolute() {
|
||||
local d
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ -n ${!1} ]]; then
|
||||
d=$(readlink -mn -- "${!1}")
|
||||
eval $1="$d"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
}
|
||||
for var_prefix in ucl upx upx_testsuite zlib; do
|
||||
for var_suffix in _BUILDDIR _SRCDIR; do
|
||||
make_absolute ${var_prefix}${var_suffix}
|
||||
done
|
||||
done
|
||||
make_absolute lcov_OUTPUTDIR
|
||||
unset var_prefix var_suffix
|
||||
|
||||
print_settings() {
|
||||
local v var_prefix var_suffix
|
||||
# Build Matrix
|
||||
for v in TRAVIS_OS_NAME BM_CROSS BM_C BM_B BM_T; do
|
||||
[[ -n ${!v} ]] && echo "${v}='${!v}'"
|
||||
done
|
||||
# BM_C related
|
||||
for v in AR CC CXX CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LIBS SCAN_BUILD; do
|
||||
[[ -n ${!v} ]] && echo "${v}='${!v}'"
|
||||
v=EXTRA_${v}
|
||||
[[ -n ${!v} ]] && echo "${v}='${!v}'"
|
||||
done
|
||||
# directories and other info
|
||||
for v in TRAVIS_XCODE_SDK UPX_UCLDIR lcov_OUTPUTDIR; do
|
||||
[[ -n ${!v} ]] && echo "${v}='${!v}'"
|
||||
done
|
||||
for var_prefix in ucl upx upx_testsuite zlib; do
|
||||
for var_suffix in _BUILDDIR _SRCDIR; do
|
||||
v=${var_prefix}${var_suffix}
|
||||
[[ -n ${!v} ]] && echo "${v}='${!v}'"
|
||||
done
|
||||
done
|
||||
##env | LC_ALL=C sort
|
||||
}
|
||||
|
||||
true
|
||||
@@ -1,381 +0,0 @@
|
||||
#! /bin/bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
|
||||
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
#
|
||||
# very first version of the upx-testsuite
|
||||
#
|
||||
|
||||
if [[ $TRAVIS_OS_NAME == osx ]]; then
|
||||
argv0=$0; argv0abs=$(greadlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
|
||||
else
|
||||
argv0=$0; argv0abs=$(readlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
|
||||
fi
|
||||
source "$argv0dir/travis_init.sh" || exit 1
|
||||
|
||||
if [[ $BM_T =~ (^|\+)SKIP($|\+) ]]; then
|
||||
echo "UPX testsuite SKIPPED."
|
||||
exit 0
|
||||
fi
|
||||
if [[ $BM_X == rebuild-stubs ]]; then
|
||||
exit 0
|
||||
fi
|
||||
[[ -f $upx_exe ]] && upx_exe=$(readlink -en -- "$upx_exe")
|
||||
|
||||
# create dirs
|
||||
cd / || exit 1
|
||||
mkbuilddirs $upx_testsuite_BUILDDIR
|
||||
cd / && cd $upx_testsuite_BUILDDIR || exit 1
|
||||
if [[ ! -d $upx_testsuite_SRCDIR/files/packed ]]; then exit 1; fi
|
||||
|
||||
# /***********************************************************************
|
||||
# // support functions
|
||||
# ************************************************************************/
|
||||
|
||||
testsuite_header() {
|
||||
local x="==========="; x="$x$x$x$x$x$x$x"
|
||||
echo -e "\n${x}\n${1}\n${x}\n"
|
||||
}
|
||||
|
||||
testsuite_split_f() {
|
||||
fd=$(dirname "$1")
|
||||
fb=$(basename "$1")
|
||||
fsubdir=$(basename "$fd")
|
||||
# sanity checks
|
||||
if [[ ! -f $f || -z $fsubdir || -z $fb ]]; then
|
||||
fd= fb= fsubdir=
|
||||
fi
|
||||
}
|
||||
|
||||
testsuite_check_sha() {
|
||||
(cd "$1" && sha256sum -b */* | LC_ALL=C sort -k2) > $1/.sha256sums.current
|
||||
echo
|
||||
cat $1/.sha256sums.current
|
||||
if ! cmp -s $1/.sha256sums.expected $1/.sha256sums.current; then
|
||||
echo "UPX-ERROR: $1 FAILED: checksum mismatch"
|
||||
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
|
||||
exit_code=1
|
||||
let num_errors+=1 || true
|
||||
all_errors="${all_errors} $1"
|
||||
#exit 1
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
testsuite_check_sha_decompressed() {
|
||||
(cd "$1" && sha256sum -b */* | LC_ALL=C sort -k2) > $1/.sha256sums.current
|
||||
if ! cmp -s $1/.sha256sums.expected $1/.sha256sums.current; then
|
||||
cat $1/.sha256sums.current
|
||||
echo "UPX-ERROR: FATAL: $1 FAILED: decompressed checksum mismatch"
|
||||
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
testsuite_use_canonicalized=1
|
||||
testsuite_run_compress() {
|
||||
testsuite_header $testdir
|
||||
local files f
|
||||
if [[ $testsuite_use_canonicalized == 1 ]]; then
|
||||
files=t020_canonicalized/*/*
|
||||
else
|
||||
files=t010_decompressed/*/*
|
||||
fi
|
||||
for f in $files; do
|
||||
testsuite_split_f $f
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p $testdir/$fsubdir $testdir/.decompressed/$fsubdir
|
||||
$upx_run -qq --prefer-ucl "$@" $f -o $testdir/$fsubdir/$fb
|
||||
$upx_run -qq -d $testdir/$fsubdir/$fb -o $testdir/.decompressed/$fsubdir/$fb
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
$upx_run -qq -l $testdir/*/*
|
||||
$upx_run -qq --file-info $testdir/*/*
|
||||
$upx_run -q -t $testdir/*/*
|
||||
if [[ $testsuite_use_canonicalized == 1 ]]; then
|
||||
# check that after decompression the file matches the canonicalized version
|
||||
cp t020_canonicalized/.sha256sums.expected $testdir/.decompressed/
|
||||
testsuite_check_sha_decompressed $testdir/.decompressed
|
||||
rm -rf "./$testdir/.decompressed"
|
||||
fi
|
||||
}
|
||||
|
||||
# /***********************************************************************
|
||||
# // expected checksums
|
||||
# //
|
||||
# // To ease maintenance of this script in case of updates this section
|
||||
# // can be automatically re-created from the current checksums -
|
||||
# // see call of function recreate_expected_sha256sums below.
|
||||
# ************************************************************************/
|
||||
|
||||
recreate_expected_sha256sums() {
|
||||
local o="$1"
|
||||
local files f d
|
||||
echo "########## begin .sha256sums.recreate" > "$o"
|
||||
files=*/.sha256sums.current
|
||||
for f in $files; do
|
||||
d=$(dirname "$f")
|
||||
echo "expected_sha256sums__${d}="'"\' >> "$o"
|
||||
cat "$f" >> "$o"
|
||||
echo '"' >> "$o"
|
||||
done
|
||||
echo "########## end .sha256sums.recreate" >> "$o"
|
||||
}
|
||||
|
||||
########## begin .sha256sums.recreate
|
||||
expected_sha256sums__t010_decompressed="\
|
||||
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
|
||||
28d7ca8f0dfca8159e637eaf2057230b6e6719e07751aca1d19a45b5efed817c *arm-wince.pe/upx-3.91.exe
|
||||
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
|
||||
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
|
||||
0dbc3c267ca8cd35ee3ea138b59c8b1ae35872c918be6d17df1a892b75710f9b *i386-win32.pe/upx-3.91.exe
|
||||
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
|
||||
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
|
||||
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
expected_sha256sums__t020_canonicalized="\
|
||||
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
|
||||
28d7ca8f0dfca8159e637eaf2057230b6e6719e07751aca1d19a45b5efed817c *arm-wince.pe/upx-3.91.exe
|
||||
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
|
||||
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
|
||||
0dbc3c267ca8cd35ee3ea138b59c8b1ae35872c918be6d17df1a892b75710f9b *i386-win32.pe/upx-3.91.exe
|
||||
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
|
||||
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
|
||||
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
expected_sha256sums__t110_compress_ucl_nrv2b_3_no_filter="\
|
||||
52d0189f9ed16162332fbe359d723753ca1b7d7374a249d6b16144e363073384 *amd64-linux.elf/upx-3.91
|
||||
0af0b3df9ca5b34ebc8ed06b3bf46807e585032961f053abfeefcb60bd63907e *arm-wince.pe/upx-3.91.exe
|
||||
851ea686cc1d6ef7c63978829f0bfe40c761d00e9f07c3d4f9ce59201da4409c *armeb-linux.elf/upx-3.91
|
||||
3345fda466927211ed3291ea1255fa09937fcfad974ffb1120deeefe6f655a9e *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
8631629945812b6766da0187390b4d26e830f39a79d80aacda196e678a4be10c *i386-linux.elf/upx-3.91
|
||||
06794bdb9a8085ca5ef577648bf39402868a507f2a0bd02285c807929499aba4 *i386-win32.pe/upx-3.91.exe
|
||||
6c9e164baa12c45ca8d55788b34e8fabdddb52374200444d42ff48c1d84103eb *m68k-atari.tos/upx-3.91.ttp
|
||||
1f3ae2bde7c72e60d3c12fccf572c5aa5dbee566d1d28029e62a8b921c6d77bd *mipsel-linux.elf/upx-3.91
|
||||
181345ff1dd1c35944ec79d1197ee223913617cdd148a576cd3b9b776b8e86c2 *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\
|
||||
d90f1e94fb8a1d5c123e1c13b30db148870c36ff6f00fc5677bd9f05bae1fc02 *amd64-linux.elf/upx-3.91
|
||||
e09a089e642f33502a35ab9a416142d3db4dbb67930366054e25c390678c3f7c *arm-wince.pe/upx-3.91.exe
|
||||
b794cc520ab507887324fe04e1c36e1ed0b63ecdb29241213a3a3cf980e16cc2 *armeb-linux.elf/upx-3.91
|
||||
ea5df377a14457fc4a4791e67859f77f8fe8b94ed81fd13666618fc690d70987 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
5f0876049576446707270baa651eaa724891cccbee268e18450812d5be5e9990 *i386-linux.elf/upx-3.91
|
||||
4a65a19b430d50b9f15786342e3de86feb3627af07743b50a9ebfedb10c59a08 *i386-win32.pe/upx-3.91.exe
|
||||
d7514121a811a36112cb2f3e42c3284e03a7807e972778229c62c075656d796f *m68k-atari.tos/upx-3.91.ttp
|
||||
0effcd336be6dcb092e37bafc9611c99c1d19c1c53a8ca6a26834d9f5f9eb56c *mipsel-linux.elf/upx-3.91
|
||||
dfe218814633aa9ed47477bf021ac0bae0b491ebf9d4ff44194f3d7195e5a200 *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\
|
||||
00b67a1cc766b13a6167e0f672cf46b62f0879b6318ed9f548f670b011b3f185 *amd64-linux.elf/upx-3.91
|
||||
a377c263a3d981af1ec278a418fcdd09298d76cece0e7c7c9af63f20ccba769d *arm-wince.pe/upx-3.91.exe
|
||||
dbf2fa9b4fa5319c52b25d34aa6f57577b2a63e7241b6d4600915de0f3400190 *armeb-linux.elf/upx-3.91
|
||||
4d925cff00b8959324c0838284f4619831b8080136cef05131906149fdec5bbc *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
b114b257ff5de11b75eb4489d2cb2bd3be6cf9cf141e36f02b0ab781d0f9a3ff *i386-linux.elf/upx-3.91
|
||||
ce874eafe18c0f09928992a3aa1f5fe9f0be9d89b87b39ecbcf1c460e4b8e0f7 *i386-win32.pe/upx-3.91.exe
|
||||
c60b3faccc59ff37c2e1e3c908d4fe01a2532e7ac1abd4c4ec4ecee974a0e8bd *m68k-atari.tos/upx-3.91.ttp
|
||||
2b74a6a831c7f9f4df22c65f8a5748a2b6cf6fd68232b0d250737938de27efc6 *mipsel-linux.elf/upx-3.91
|
||||
47ddad5acc39e21d66e471c8af8d9b52e8dd8d7ad89631f771c2ea4d218f441e *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
expected_sha256sums__t140_compress_lzma_2_no_filter="\
|
||||
f67ce2b6d4d36367a249faeb802df51dbc56019754c0f4606b5a6f97b72a54d1 *amd64-linux.elf/upx-3.91
|
||||
57be6aa4f1e5ee6ef6f5eb8694b22eb07c3ea5cc9b9ebfde75db4c9a04a71a5a *arm-wince.pe/upx-3.91.exe
|
||||
ef18c1ae56a037d15f0494f4b835c1336a43745edba87c783f62745488008783 *armeb-linux.elf/upx-3.91
|
||||
54a6158bc6bd8cc28d3abc53cc5cf9b63c3c63ae884e96fb6d6ea974c7426206 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
801d1761289f94d7f51effb88e100832d14ae96398844084b9d10852886c4731 *i386-linux.elf/upx-3.91
|
||||
f828953a66d7b3394dd2514b5972680a0cc651bd198b7607f6d3f6f6cc390a0e *i386-win32.pe/upx-3.91.exe
|
||||
587b5f1f529da60f5820b8f811743aaad59e3fa9407930de1ab433863f7262a4 *m68k-atari.tos/upx-3.91.ttp
|
||||
84c811f5d27bac393610bfad4180258494c43d691c13eb57394ab95d4736e621 *mipsel-linux.elf/upx-3.91
|
||||
ed83830ab5e1753a742cf4981401fd8d5bdaabcfdeb385a2e8087aeb46f93512 *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
expected_sha256sums__t150_compress_ucl_2_all_filters="\
|
||||
2849771c8799d7a446b54ad9914d679e315a9f0d9440f9728c6d5ab6541ed494 *amd64-linux.elf/upx-3.91
|
||||
7ccbe7d7822cd9fed9b3c902c2bcb80f85df4f5bbb4e9e850257435ffa375a38 *arm-wince.pe/upx-3.91.exe
|
||||
c6849deffc7bb1976c18a4815bca0b8fd0b6d19e4136965108daa6382efae2d5 *armeb-linux.elf/upx-3.91
|
||||
c04818c54d68c99f345ee7995634dffbe7f1c2f2db8f2b510bba461d9125f5a9 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
a3758350a0454fb78060b6d6e48d8f000e17a628b6041e8c82e3990e0b3aabe9 *i386-linux.elf/upx-3.91
|
||||
b4f27ba234a5c9b4f68e2067602a180c02f95fb044830f54a45267fe1c50bb83 *i386-win32.pe/upx-3.91.exe
|
||||
dd9fb59d57a7157af1a44559f6ebd8a293b0988c66b4d0951c949f88f814bf8f *m68k-atari.tos/upx-3.91.ttp
|
||||
c0bc81487114b9d158ffe1dbd4081b9e3636695c63f11b3e204033b56fc69706 *mipsel-linux.elf/upx-3.91
|
||||
0a700713f0c7ff19a534963f5ab95a63d2f185f82d0c42ce8c1a485aba4c1147 *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
expected_sha256sums__t160_compress_all_methods_1_no_filter="\
|
||||
831b0dd82d2c8fb058e8300bda5dd51657a709e76c45e0c372d9cf83c2e06f31 *amd64-linux.elf/upx-3.91
|
||||
057b08389af5a31a0bf4baf03d09eb07f4698f8ddec615ae35795cec62132966 *arm-wince.pe/upx-3.91.exe
|
||||
49b6b8d4f04d9078686372a315e7768fc882ad66bebb67225fa0b2255b5dd1c9 *armeb-linux.elf/upx-3.91
|
||||
aef085cb86ef29d7aa380a3daea403f53659af1615ceeaa76e609dc793f50cfd *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
52087d4a2c17445b0e8d5238ec3abd2ca5cd909513cff76bf42232f33d93903f *i386-linux.elf/upx-3.91
|
||||
e669d7c4fec901130dd387dc8f95e3b3f5e739d6ef0bfac10080dbd257084ae6 *i386-win32.pe/upx-3.91.exe
|
||||
40cd5a94039a1703986a68dd404290aa7c27fd8c184fa4c651467b8c2d621a5d *m68k-atari.tos/upx-3.91.ttp
|
||||
b1db1d04e350972aa06216ec43d12a451abf5c928c885b0c442f9436c804e84e *mipsel-linux.elf/upx-3.91
|
||||
65602c3e1e3e152d44d9f803281d4021bfd91aab825b72d8901faf4d7d9b593e *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\
|
||||
bce397f12372437802d887d203bb2f8e4755dbe1a0e3c6bb9fa9cccd3306eef7 *amd64-linux.elf/upx-3.91
|
||||
84b1fe14dbff7d4e2f1bcfee9b6e3c73f68eb5b95b37cbf2c655340bd959bfa3 *arm-wince.pe/upx-3.91.exe
|
||||
1b6ac9c0893b3093d47e403a14a5d346ae3a0f135ecdbe3bb04fc0542abd469b *armeb-linux.elf/upx-3.91
|
||||
d27237cd4b55c80d2b6c7da8d70ffc4f390290fcc550eec06c795e92d934b72a *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
2032623990d22b2cf8df5f2c0b581de5fd53869869b65818ea023a6857c4eff0 *i386-linux.elf/upx-3.91
|
||||
51e91ff8226517ad8cd06d240e2c6c2f3d3e4033af1e593a5b294356d1bb5d33 *i386-win32.pe/upx-3.91.exe
|
||||
b371684bbb2693797dd1164159de3bff9618bf6b99536542f57da07093dbb649 *m68k-atari.tos/upx-3.91.ttp
|
||||
7c1fa54b86f3e5f3410216aa627bd32680d7bd8210776a14762566cb2ea37d52 *mipsel-linux.elf/upx-3.91
|
||||
5c60d0817feeb4dde55be90e552ccddc81591fbaecb899c3a21afc91c0ceb3b9 *powerpc-linux.elf/upx-3.91
|
||||
"
|
||||
########## end .sha256sums.recreate
|
||||
|
||||
# /***********************************************************************
|
||||
# // init
|
||||
# ************************************************************************/
|
||||
|
||||
#set -x # debug
|
||||
exit_code=0
|
||||
num_errors=0
|
||||
all_errors=
|
||||
|
||||
if [[ $BM_T =~ (^|\+)ALLOW_FAIL($|\+) ]]; then
|
||||
echo "ALLOW_FAIL"
|
||||
set +e
|
||||
fi
|
||||
|
||||
[[ -z $upx_exe && -f $upx_BUILDDIR/upx.out ]] && upx_exe=$upx_BUILDDIR/upx.out
|
||||
[[ -z $upx_exe && -f $upx_BUILDDIR/upx.exe ]] && upx_exe=$upx_BUILDDIR/upx.exe
|
||||
if [[ -z $upx_exe ]]; then exit 1; fi
|
||||
upx_run=$upx_exe
|
||||
if [[ $BM_T =~ (^|\+)qemu($|\+) && -n $upx_qemu ]]; then
|
||||
upx_run="$upx_qemu $upx_qemu_flags -- $upx_exe"
|
||||
fi
|
||||
if [[ $BM_T =~ (^|\+)wine($|\+) && -n $upx_wine ]]; then
|
||||
upx_run="$upx_wine $upx_wine_flags $upx_exe"
|
||||
fi
|
||||
if [[ $BM_T =~ (^|\+)valgrind($|\+) ]]; then
|
||||
if [[ -z $upx_valgrind ]]; then
|
||||
upx_valgrind="valgrind"
|
||||
fi
|
||||
if [[ -z $upx_valgrind_flags ]]; then
|
||||
#upx_valgrind_flags="--leak-check=full --show-reachable=yes"
|
||||
#upx_valgrind_flags="-q --leak-check=no --error-exitcode=1"
|
||||
upx_valgrind_flags="--leak-check=no --error-exitcode=1"
|
||||
fi
|
||||
upx_run="$upx_valgrind $upx_valgrind_flags $upx_exe"
|
||||
fi
|
||||
|
||||
if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then
|
||||
(cd / && cd $upx_BUILDDIR && lcov -d . --zerocounters)
|
||||
fi
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
|
||||
# let's go
|
||||
if ! $upx_run --version; then echo "UPX-ERROR: FATAL: upx --version FAILED"; exit 1; fi
|
||||
if ! $upx_run -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! $upx_run --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
rm -rf ./testsuite_1
|
||||
mkbuilddirs testsuite_1
|
||||
cd testsuite_1 || exit 1
|
||||
|
||||
# /***********************************************************************
|
||||
# // decompression tests
|
||||
# ************************************************************************/
|
||||
|
||||
testdir=t010_decompressed
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
|
||||
testsuite_header $testdir
|
||||
for f in $upx_testsuite_SRCDIR/files/packed/*/upx-3.91*; do
|
||||
testsuite_split_f $f
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p $testdir/$fsubdir
|
||||
$upx_run -qq -d $f -o $testdir/$fsubdir/$fb
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
|
||||
|
||||
# run one pack+unpack step to canonicalize the files
|
||||
testdir=t020_canonicalized
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
|
||||
testsuite_header $testdir
|
||||
for f in t010_decompressed/*/*; do
|
||||
testsuite_split_f $f
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p $testdir/$fsubdir/.packed
|
||||
$upx_run -qq --prefer-ucl -1 $f -o $testdir/$fsubdir/.packed/$fb
|
||||
$upx_run -qq -d $testdir/$fsubdir/.packed/$fb -o $testdir/$fsubdir/$fb
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
|
||||
# /***********************************************************************
|
||||
# // compression tests
|
||||
# // info: we use fast compression levels because we want to
|
||||
# // test UPX and not the compression libraries
|
||||
# ************************************************************************/
|
||||
|
||||
testdir=t110_compress_ucl_nrv2b_3_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --nrv2b -3 --no-filter
|
||||
|
||||
testdir=t120_compress_ucl_nrv2d_3_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --nrv2d -3 --no-filter
|
||||
|
||||
testdir=t130_compress_ucl_nrv2e_3_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --nrv2e -3 --no-filter
|
||||
|
||||
testdir=t140_compress_lzma_2_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --lzma -2 --no-filter
|
||||
|
||||
testdir=t150_compress_ucl_2_all_filters
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress -2 --all-filters
|
||||
|
||||
testdir=t160_compress_all_methods_1_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --all-methods -1 --no-filter
|
||||
|
||||
testdir=t170_compress_all_methods_no_lzma_5_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --all-methods --no-lzma -5 --no-filter
|
||||
|
||||
# /***********************************************************************
|
||||
# // summary
|
||||
# ************************************************************************/
|
||||
|
||||
# recreate checkums from current version for an easy update in case of changes
|
||||
recreate_expected_sha256sums .sha256sums.recreate
|
||||
|
||||
testsuite_header "UPX testsuite summary"
|
||||
if ! $upx_run --version; then
|
||||
echo "UPX-ERROR: upx --version FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
echo "upx_exe='$upx_exe'"
|
||||
if [[ "$upx_run" != "$upx_exe" ]]; then
|
||||
echo "upx_run='$upx_run'"
|
||||
fi
|
||||
if [[ -f "$upx_exe" ]]; then
|
||||
ls -l "$upx_exe"
|
||||
file "$upx_exe" || true
|
||||
fi
|
||||
echo "upx_testsuite_SRCDIR='$upx_testsuite_SRCDIR'"
|
||||
echo "upx_testsuite_BUILDDIR='$upx_testsuite_BUILDDIR'"
|
||||
echo ".sha256sums.{expected,current}:"
|
||||
cat */.sha256sums.expected | LC_ALL=C sort | wc
|
||||
cat */.sha256sums.current | LC_ALL=C sort | wc
|
||||
echo
|
||||
if [[ $exit_code == 0 ]]; then
|
||||
echo "UPX testsuite passed. All done."
|
||||
else
|
||||
echo "UPX-ERROR: UPX testsuite FAILED:${all_errors}"
|
||||
echo "UPX-ERROR: UPX testsuite FAILED with $num_errors error(s). See log file."
|
||||
fi
|
||||
exit $exit_code
|
||||
@@ -0,0 +1,43 @@
|
||||
# see https://github.com/crate-ci/typos
|
||||
|
||||
# a generic spell-checker that works on source code is quite
|
||||
# tricky, so some false positives are fine
|
||||
|
||||
[files]
|
||||
extend-exclude = ["LICENSE", "misc/*podman*/*/packages.txt"]
|
||||
|
||||
# misc variable names & symbols
|
||||
[default.extend-identifiers]
|
||||
acc_spawnve = "acc_spawnve"
|
||||
ba = "ba"
|
||||
fo = "fo"
|
||||
fof = "fof"
|
||||
O_WRONLY = "O_WRONLY"
|
||||
# optin: clang-analyzer-optin.cplusplus
|
||||
optin = "optin"
|
||||
sidelen = "sidelen"
|
||||
# macOS 11 "Big Sur"
|
||||
Sur = "Sur"
|
||||
tpos = "tpos"
|
||||
# assembly sources
|
||||
hda = "hda"
|
||||
Larg = "Larg"
|
||||
pard = "pard"
|
||||
suble = "suble"
|
||||
|
||||
# identifiers are intelligently split into words and then checked again
|
||||
[default.extend-words]
|
||||
delt = "delt"
|
||||
FO = "FO"
|
||||
fo = "fo"
|
||||
# parm is used like param
|
||||
PARM = "PARM"
|
||||
parm = "parm"
|
||||
# rela: ELF relocations
|
||||
RELA = "RELA"
|
||||
rela = "rela"
|
||||
# siz is used for size
|
||||
siz = "siz"
|
||||
# SEH: Structured Exception Handling
|
||||
SEH = "SEH"
|
||||
seh = "seh"
|
||||
@@ -1,68 +0,0 @@
|
||||
uqz4mAtKkF5Ex7Zt2tRP9mhQsAYn5+Xbupfuhee/s+2yVdBBdlXXRN2Q2AhMxF01
|
||||
myhEuAtRNoQ4m7eyNgNU01pKb+dlyw2xiS+izm9+5fxuuEZfiuv76tQToQLltSdq
|
||||
jP3Gt08MloJGcWraFiAXXji0S45MasJO3VOdygz09PbzIvGVp/NskGCMCU9lJlRt
|
||||
2CsItWR+iHs6HNurWEKtEZz4qR8+HZ6RU5IquOnnHnI357lVUiC1w2qRcxmNVWuI
|
||||
qS7GPvgisv0m4XMxe+l4L3b6a7laZr/hqHjFQqu/aO9Kmy5WmYRe3Bx4hTv5vqRi
|
||||
OBDOUzwUcrdlUu2wqcvZhVxPaxxqA5u8G63Z3O30VCtWPZVU4yx9TRzcy/0lwxol
|
||||
dw1b5t7Bl8uIzNyLsFMVS1MpnBspUrxBko6TqLAhv/DvUQmWGJRkP4Ar9naB4myS
|
||||
vX6sim+Jn57Fr8aZMlvJbqlNindjxnX6+13u51C80GaYJBjHLkAIPaTTNLviOWpj
|
||||
rbACDifaFloAsgJqz0KK/T7eohJBH2jVe2d9YxU6wZq6THDKJaeQ+nG5MWYvlkWa
|
||||
K3N+jN8KI1GWqNpUtD8rbLPY1UZo05wQFZBCfdvEZoYdzJFVIS3t6kr0/gOIZu0D
|
||||
AAIfIcopnpWpUk52MOEekzRRjJuF8fUMkiPX1oVs9HMKW+TU+yx/sFia+ke76w3i
|
||||
1oiHKJJJNaoCjQXlAcT40rGLmSTLgL0ACCWIMGjK1QJYkpER8GCBCh9/whrJ3k1Q
|
||||
0hm5hYiGty2ysRJFLIFPkYjangz7hIVzgOUSTYhVjJmIA62W2LmNKcixGX+sssCJ
|
||||
/DK/Zs0uPiEX4gjkiomDksn7Dy8vAtHe7PzWpZA83mgPK+6zxoM6dgpM7FSe5q1/
|
||||
tyf394l4nB7eayRUnx3NfK2/PTwrJcms5yAD9Hm2h72cp26TXh+RDVYWOgVX5/N0
|
||||
dIsDRYo+/077pRTKwiCPrMxTxys53HHV7r5APd+FPmxikXvuszZvYTZ9K2MZB/1L
|
||||
S2MCJ/u4GTTCwcbvfEjKVs3Fbqu7c2D/tVzakVEmMXloEAGPN/NrzOJsMMEDhWiw
|
||||
g1wneAg5qF5nG+7R5WqstAeaRCYdXl46xay7iePZQ7viwHA8Zjuke18eHmh7J5jz
|
||||
uzdh81rxCL3beoXb+BEr1/yKWfrJVTl33+m6c+zxdrV0B7O/ijlYxjke7Wo+ESac
|
||||
WM2a4xU/WgXMi2+83XqcSZcRPdusZKA6bcTvAcYc/r8t7O1wjfPsTVj0WaM2DwL0
|
||||
P1QTU4INmVn94zIV0+fGfyN0qI3YiS5iuOoPwLOVB13YECIyXnZz2/VJF7ZASOpS
|
||||
701or4uF7GVEZxw19ow0AQttk6J/bEzbr7rZ5Um1yCMeQQ1TMHepJfuUbxle4W4S
|
||||
8w8yC/Ytcy/e4rbiLG2/cY5b35LxtH1TCuaEtuiqa7vkmzr36qqD6fRWnXWC9QdR
|
||||
0nWyJNj0xIIyMyilnBY2clAjDdT9qd2tMfpoz9hyBkTZPltzDw6Xd/IhhyL1URav
|
||||
h0NCABGqXbpg8q7KCrIzIE6dJIh+7glfQuWkynmInntN4+fqk9Ked0haHkq5oGH5
|
||||
vN5ZQNWPyQ67LaXQ4kW8iksgkgl7JEQsuie8oMuQZe13D4S3PWGFKchrBFGwN2xY
|
||||
ut2+PCs5Al2BHU0qaCKdV7nCqv2tPC8G4uXNw081R2KwyoRlbKhowgFBYBTQIobJ
|
||||
pc1GLU7HKm9tC61xIZ4u9oij/Bz1+gxx9vLxfx++EC/8UI23oMGygaYdda4gdEtm
|
||||
v1wt8ldpzO4owI+9peFSolGLwKztwSPxln+5bvOsdsaZ6z5uW37N5ch/EwSwdmfo
|
||||
Sm1i7fv/zQuZjmZkJXRJGvTd+sKdu7+IZUrTpu5W+jUfMAgmPc+AuYmSOn00K9dv
|
||||
IJKY973ggNDaJKEw1uKzckl9uk/HRrgk+wgZPaWVRhOulj1npyFf+WmrZ2r3nTq0
|
||||
koEI8UEselRuKJmojl4O0bz8fXZNgPtpLB/A0cdrj0Ist5TR+qRW9h3eSsybDYRS
|
||||
GWP4UzFLAIwHflwNX0Q+9/u0uOxaXX6dKXzoddWksInBzh1pmQfrtUM3y7bHQYG5
|
||||
zqnAMNMwm4WmtmF/mpjg0fKpiwFUU1geygkOwUsaK5Qcp5F0FPocdPRWVxUG0t3Y
|
||||
QsmSpU5STb99YCs4TvhfUnQmdB2r+d0pZhlMte3v5lcpekSb2FxbUwdX3t9S2uGy
|
||||
ho9CYmUj1+8ivUizjTLirOu/B8ohQT6kwvNqRSiQwU+YPa5DpxA1DYamIg6ehuX5
|
||||
6u/dF4Eht+Cn6hasyzFviIUnV1y4ixLfSb0EGw+YoLbHgr8X4Uv4guaNQduKJyEu
|
||||
g6p1v40fDhZ8AuQly+BOLL0yBlQoDrkY9+3HcIZAC5NmJFU5hle4Hz4gLzS6DwXo
|
||||
2u8tqIELdtP9Zo4SKM7/yNy+rjl2RNRUEUNjidZsWuIC4bEeL3sUImP0Wt+zpdV0
|
||||
y0RK1/wPW4dES5xFTCUp9xdP08dsSMtIrYJeBXbHrTZswnuOvk4MYGpmn/qy+qwc
|
||||
GnkJtzJVm+uNspYuD0cW+JbJz5T+w1eNbejjZ+QVhqmE7ctSHndQUSueIyOcm79E
|
||||
23jLzIoHMSHsiBJ8KeHN5bTfe66Gl8y3LIOpfchYd5XzkqxS7M01PxkWGZDWGYdl
|
||||
6Gx64mg7ojPrSNaOzAu3da8oLvGi/YIf3wdJenZqiTzBnSzRsBnTpohQddHbB1Hj
|
||||
uogDJSoad0ZSY0lLcvxncPB29hKpljFZ4IHO2UKOyO9+LFKsfK8/RbdSx/sHcUaH
|
||||
hblVkVTSRReHmShxSw6abYZHivGNV0tXNXkY6uEzOMe+Vck9j9dTBSK0bFS/2Xdd
|
||||
ZII/KFQH10+WEYyw+FurMUeVwU/FER4qpy+13r1PjxMSHfnJviEb8EjgvrcwAUDX
|
||||
G9JNVtL4Vui6NMFV1u2qkbEMZK763YAIKYZC9UZYjbbhhgYTTMEfRcNvwVCix8nH
|
||||
2TlWGhivuw5abE9QFduT1fHXJL+1uCn2GMhS8v3fxUrnGDQFit0YLlGEMm5/wVaM
|
||||
PIZH5JDHlINUC0vbUrMXCz8Ztg3qhpOLiExlBHTD4vqYt9kniHLXOQfexegSC85C
|
||||
AKiugEOdoHHYJGjNyXj6c0jTuMAe0CBwAKddUqPQztoKclNb02G2a9l5ColE29Uz
|
||||
jXAb8PFANNqn4Nnm6oPPF1KxB45vLdT6+F1SRzXZunJ6p9N4E9KBtEOR+ixlcphL
|
||||
InLJSg5iKTfWhXlSK6eldvVsP2GeoyjliERsKLgq1YGMiCW076dmoxR2Z5iPlD2V
|
||||
G7Hz5nWjPBIoFhABEnONDxbrYB6ryeunILYcHpAaXSYq4OueRo6QGO8NRqFcNutG
|
||||
WpwBfIlnu6rl9MDO053SJ1ah6D97n/D5aQa2JMMha0faZz84+MH3cnudAgpPjsG9
|
||||
9G/2fEP08lQNAFiyY91wW3Mtj2No9+OJVYmwFORJm7IOu5nfuQZbzz9OFPcZLU5Y
|
||||
DVo86icZgXayytW2XZtCKzVBDse+yi0xblGSNtwHlQIN8gKDVpa0I34DxUkIn1Cl
|
||||
bk9S6+m6APF9ynN/kVCwMu9Nq3lwzmY6JCb/KX0d66uyVwYG3BN1UEWqJhDJjGep
|
||||
a2JmHnG1aVhYaE/2EsOc+YP89Oub+KeuCj2dHJj2dH3QDCjr2xZUbLO7mw1tsATH
|
||||
dPjNEBvxet9UU/RXqhhkfkv1XGr/umWrkjKbFqDNl5Tav/00+I59rboW7C/cWRxN
|
||||
CVbadLPJlPNRR8+54G+VkDZgqaQprPwYih5a7d2MEzrMtZbU0uCJc839dqMgsf++
|
||||
k4maampkcDLhxt8bBg43WoDgWxiQ+KVWyEBGmTOT2q4WYeLI9PZLseA9eNJbpt9J
|
||||
oxtNNdqkU48YZWsq/3L1L0eXdGvv5TIMto4bH3SWuvQ2sepwMRxxwTg8qFrutk9K
|
||||
OLOUbO1Z2ivh1g6+DAgs3RFmy9hPzzqPmJk8cL6F5tcd/VwGcow3UBJ1+Xn3SE5Y
|
||||
UCHNrSfSrvDaA3N8jyvS/uPq0qRgp7LQRqrhh5cVPi67goDx/ku/fVbMbcrarO/e
|
||||
Czv6CX7Id2QliOSMGGVId+ECXBvuIGAb2d4til+zTnfhBE2+uS5WQ7MjzH9PKZ7n
|
||||
TDuV36mA1FDCX+WShPau7R0SGXSqKyeHJ8XSuFHbGwr1Zxwoq4GBYIcAxWjp9HA4
|
||||
dhBE2x5WSTbnqh1sClxfOeE8MHxi+EUonCcvfvm30NOcC4zw1dCDc6SKLoMJYrFz
|
||||
EdR3Kt1SJ9M0Jl3dD/gCTKG5kObJzqmo9BladIpQt6c=
|
||||
@@ -0,0 +1,499 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
# note: GitHub Actions runner images are frequently updated, and
|
||||
# unfortunately this sometimes breaks builds in mysterious ways...
|
||||
# see https://github.com/actions/runner-images.git
|
||||
|
||||
name: 'CI'
|
||||
|
||||
on: [push, workflow_dispatch]
|
||||
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_BUILD_FLAGS: --verbose
|
||||
# 2023-11-01
|
||||
ZIG_DIST_VERSION: 0.12.0-dev.1369+a09ba455c
|
||||
|
||||
jobs:
|
||||
job-rebuild-and-verify-stubs:
|
||||
name: 'Rebuild stubs'
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: 'Install extra packages'
|
||||
run: |
|
||||
uname -a; pwd; id; umask
|
||||
mkdir ../deps; cd ../deps; mkdir packages
|
||||
if ! test -e /usr/bin/python2; then
|
||||
####sudo apt-get update && sudo apt-get install -y --no-install-recommends python2-minimal
|
||||
# install python2-minimal packages from Debian-11
|
||||
wget -q 'https://ftp.debian.org/debian/pool/main/p/python2.7/libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb'
|
||||
wget -q 'https://ftp.debian.org/debian/pool/main/p/python2.7/python2.7-minimal_2.7.18-8+deb11u1_amd64.deb'
|
||||
sudo dpkg -i ./*python2*.deb && rm ./*python2*.deb && sudo ldconfig
|
||||
sudo ln -s -v python2.7 /usr/bin/python2
|
||||
fi
|
||||
# manually unpack and install compat libs from Ubuntu-16.04
|
||||
wget -q 'https://archive.kernel.org/ubuntu-archive/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.6-1_amd64.deb'
|
||||
for f in ./*.deb; do dpkg -x $f ./packages; done
|
||||
sudo mv -v -n ./packages/usr/lib/x86_64-linux-gnu/lib* /usr/lib/x86_64-linux-gnu/
|
||||
rm -rf ./*.deb ./packages
|
||||
sudo ldconfig
|
||||
# install upx-stubtools
|
||||
wget -q -O - https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz | tar -xJ
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Rebuild and verify stubs'
|
||||
run: |
|
||||
export PATH="$(readlink -en ../deps/bin-upx-20221212):$PATH"
|
||||
make -C src/stub maintainer-clean extra-clean
|
||||
git status || true
|
||||
make -C src/stub extra-all all
|
||||
if ! git diff --quiet; then git diff; exit 1; fi
|
||||
- name: 'Check source code formatting'
|
||||
run: |
|
||||
bash ./misc/scripts/check_whitespace_git.sh
|
||||
UPX_CLANG_FORMAT="$PWD/../deps/bin-upx-20221212/clang-format-15.0.6" make -C src clang-format
|
||||
if ! git diff --quiet; then git diff; exit 1; fi
|
||||
|
||||
job-linux-cmake: # uses cmake + make
|
||||
if: true
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('{0} cmake', matrix.os) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-22.04, use_m32: true }
|
||||
- { os: ubuntu-20.04, use_m32: false } # use_m32 also works here, but save some CI time
|
||||
steps:
|
||||
- name: 'Install extra 32-bit and Windows packages'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y g++-multilib g++-mingw-w64-i686 g++-mingw-w64-x86-64
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Check out test suite'
|
||||
run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite'
|
||||
- name: 'Build cmake extra/gcc/debug'
|
||||
run: 'make build/extra/gcc/debug'
|
||||
- name: 'Build cmake extra/gcc/release'
|
||||
run: 'make build/extra/gcc/release'
|
||||
- name: 'Build cmake extra/clang/debug'
|
||||
run: 'make build/extra/clang/debug'
|
||||
- name: 'Build cmake extra/clang/release'
|
||||
run: 'make build/extra/clang/release'
|
||||
- name: 'Build cmake extra/gcc-m32/debug'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
run: 'make build/extra/gcc-m32/debug'
|
||||
- name: 'Build cmake extra/gcc-m32/release'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
run: 'make build/extra/gcc-m32/release'
|
||||
- name: 'Build cmake extra/cross-windows-mingw32/release'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
run: 'make build/extra/cross-windows-mingw32/release'
|
||||
- name: 'Build cmake extra/cross-windows-mingw64/release'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
run: 'make build/extra/cross-windows-mingw64/release'
|
||||
- name: 'Make artifact'
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
|
||||
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run install tests'
|
||||
run: |
|
||||
(cd build/extra/gcc/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
|
||||
(cd build/extra/gcc/release && DESTDIR=$PWD/Install-with-make make install)
|
||||
- name: 'Run basic tests'
|
||||
run: |
|
||||
make -C build/extra/gcc/debug test
|
||||
make -C build/extra/gcc/release test
|
||||
make -C build/extra/clang/debug test
|
||||
make -C build/extra/clang/release test
|
||||
- name: 'Run basic tests 32-bit'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
run: |
|
||||
make -C build/extra/gcc-m32/debug test
|
||||
make -C build/extra/gcc-m32/release test
|
||||
- name: 'Run file system test suite'
|
||||
run: |
|
||||
env -C build/extra/gcc/release bash "$PWD"/misc/testsuite/test_symlinks.sh
|
||||
- name: 'Run test suite build/extra/gcc/release'
|
||||
run: |
|
||||
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
|
||||
testsuite_1="$(readlink -en ./misc/testsuite/upx_testsuite_1.sh)"
|
||||
env -C build/extra/gcc/release upx_exe=./upx bash "$testsuite_1"
|
||||
|
||||
job-macos-cmake: # uses cmake + make
|
||||
if: true
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('{0} cmake', matrix.os) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# NOTE: macos does not have "env -C"; only with coreutils
|
||||
# NOTE: macos-11 does not have "readlink -f"; only on macos >= 12 or with coreutils
|
||||
- { os: macos-11, gcc: gcc-10, gxx: 'g++-10', testsuite: true }
|
||||
- { os: macos-12, gcc: gcc-11, gxx: 'g++-11', testsuite: true }
|
||||
- { os: macos-13, gcc: gcc-12, gxx: 'g++-12', testsuite: true }
|
||||
steps:
|
||||
- name: 'Install brew packages'
|
||||
if: ${{ matrix.testsuite }}
|
||||
run: |
|
||||
# testsuite needs working "readlink -en" and "sha256sum -b"
|
||||
if ! test -e /usr/local/opt/coreutils/libexec/gnubin/readlink; then
|
||||
echo "===== brew leaves:"; brew leaves; echo "===== brew list:"; brew list
|
||||
# only run "brew update" if needed
|
||||
if ! brew install coreutils; then brew update && brew install coreutils; fi
|
||||
fi
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Check out test suite'
|
||||
if: ${{ matrix.testsuite }}
|
||||
run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite'
|
||||
- name: 'Build cmake extra/clang/debug'
|
||||
run: 'make build/extra/clang/debug'
|
||||
- name: 'Build cmake extra/clang/release'
|
||||
run: 'make build/extra/clang/release'
|
||||
- name: 'Build cmake extra/gcc/debug'
|
||||
if: ${{ matrix.gcc != '' }}
|
||||
run: 'make build/extra/gcc/debug CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"'
|
||||
- name: 'Build cmake extra/gcc/release'
|
||||
if: ${{ matrix.gcc != '' }}
|
||||
run: 'make build/extra/gcc/release CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"'
|
||||
- name: 'Build cmake xtarget/cross-darwin-arm64/debug'
|
||||
run: |
|
||||
CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" \
|
||||
make UPX_XTARGET=cross-darwin-arm64 xtarget/debug
|
||||
- name: 'Build cmake xtarget/cross-darwin-arm64/release'
|
||||
run: |
|
||||
CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" \
|
||||
make UPX_XTARGET=cross-darwin-arm64 xtarget/release
|
||||
- name: 'Make artifact'
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && rsync -R -a */*/*/upx "../tmp/artifact/$N/")
|
||||
(cd tmp/artifact && gtar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run install tests'
|
||||
run: |
|
||||
(cd build/extra/clang/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
|
||||
(cd build/extra/clang/release && DESTDIR=$PWD/Install-with-make make install)
|
||||
- name: 'Run basic tests'
|
||||
if: ${{ !contains(matrix.os, 'macos-13') }} # FIXME: UPX on macos-13 is broken => disable self-test for now
|
||||
run: |
|
||||
make -C build/extra/clang/debug test
|
||||
# make -C build/extra/clang/release test
|
||||
- name: 'Run file system test suite'
|
||||
if: ${{ matrix.testsuite }} # for coreutils readlink
|
||||
run: |
|
||||
## macos-11 does not have "readlink -f"
|
||||
## testsuite="$(readlink -fn ./misc/testsuite/test_symlinks.sh)"
|
||||
## (cd build/extra/clang/release && upx_exe=./upx bash "$testsuite")
|
||||
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
|
||||
env -C build/extra/clang/release bash "$PWD"/misc/testsuite/test_symlinks.sh
|
||||
- name: 'Run test suite build/extra/clang/release'
|
||||
if: ${{ matrix.testsuite }}
|
||||
run: |
|
||||
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
|
||||
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
|
||||
testsuite_1="$(readlink -en ./misc/testsuite/upx_testsuite_1.sh)"
|
||||
env -C build/extra/clang/release upx_exe=./upx bash "$testsuite_1"
|
||||
|
||||
job-windows-cmake: # uses cmake + msbuild
|
||||
if: true
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('{0} cmake', matrix.name) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { name: windows-2019-amd64, os: windows-2019, vsversion: 2019, arch: amd64 }
|
||||
- { name: windows-2022-amd64, os: windows-2022, vsversion: 2022, arch: amd64 }
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Check out test suite'
|
||||
run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite'
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
|
||||
with:
|
||||
vsversion: ${{ matrix.vsversion }}
|
||||
arch: ${{ matrix.arch }}
|
||||
- name: 'Build cmake debug'
|
||||
run: 'make build/debug'
|
||||
- name: 'Build cmake release'
|
||||
run: 'make build/release'
|
||||
- name: 'Make artifact'
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && cp -ai --parents */*/upx.exe "../tmp/artifact/$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run basic tests'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
run: |
|
||||
ctest --test-dir build/debug -C Debug
|
||||
ctest --test-dir build/release -C Release
|
||||
- name: 'Run test suite build/release'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
shell: bash
|
||||
run: |
|
||||
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
|
||||
testsuite_1="$(readlink -en ./misc/testsuite/upx_testsuite_1.sh)"
|
||||
env -C build/release/Release upx_exe=./upx bash "$testsuite_1"
|
||||
|
||||
job-windows-toolchains: # build "by hand" using cmd.exe
|
||||
if: true
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('windows {0}', matrix.name) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
C: ${{ matrix.name }}
|
||||
B: release
|
||||
H: 'd:\a\upx\upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { name: amd64-win64-vs2019, os: windows-2019, vsversion: 2019, arch: amd64 }
|
||||
- { name: amd64-win64-vs2022, os: windows-2022, vsversion: 2022, arch: amd64 }
|
||||
- { name: arm64-win64-vs2019, os: windows-2019, vsversion: 2019, arch: amd64_arm64 }
|
||||
- { name: arm64-win64-vs2022, os: windows-2022, vsversion: 2022, arch: amd64_arm64 }
|
||||
- { name: arm64ec-win64-vs2022, os: windows-2022, vsversion: 2022, arch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64ec' }
|
||||
# { name: arm64x-win64-vs2022, os: windows-2022, vsversion: 2022, arch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64x' }
|
||||
- { name: i386-win32-vs2019, os: windows-2019, vsversion: 2019, arch: amd64_x86 }
|
||||
- { name: i386-win32-vs2022, os: windows-2022, vsversion: 2022, arch: amd64_x86 }
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Prepare sources and Check out test suite'
|
||||
shell: bash
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite
|
||||
mkdir -p -v build/$C/$B/{bzip2,ucl,upx,zlib,zstd}
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
|
||||
with:
|
||||
vsversion: ${{ matrix.vsversion }}
|
||||
arch: ${{ matrix.arch }}
|
||||
- name: 'Build by hand'
|
||||
shell: cmd
|
||||
run: |
|
||||
@REM ===== set vars =====
|
||||
where cl & where link
|
||||
set RUN_CL=cl ${{ matrix.cl_machine_flags }} -MT
|
||||
set RUN_LIB=link -lib ${{ matrix.link_machine_flags }}
|
||||
@rem UPX only uses the very basic Windows API
|
||||
set DEFS=-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0400
|
||||
set BDIR=%H%\build\%C%\%B%
|
||||
git rev-parse --short=12 HEAD > %BDIR%\upx\.GITREV.txt
|
||||
@REM ===== build bzip2 =====
|
||||
cd %BDIR%\bzip2
|
||||
@rem %RUN_CL% -J -O2 -W4 -wd4127 -wd4244 -wd4267 -WX %DEFS% -c %H%\vendor\bzip2\*.c
|
||||
@rem %RUN_LIB% -out:bzip2.lib *.obj
|
||||
@REM ===== build UCL =====
|
||||
cd %BDIR%\ucl
|
||||
set s=%H%\vendor\ucl
|
||||
%RUN_CL% -J -O2 -W4 -WX %DEFS% -I%s%\include -I%s% -c %s%\src\*.c
|
||||
%RUN_LIB% -out:ucl.lib *.obj
|
||||
@REM ===== build zlib =====
|
||||
cd %BDIR%\zlib
|
||||
%RUN_CL% -J -O2 -W3 -WX %DEFS% -DHAVE_VSNPRINTF -c %H%\vendor\zlib\*.c
|
||||
%RUN_LIB% -out:zlib.lib *.obj
|
||||
@REM ===== build zstd =====
|
||||
cd %BDIR%\zstd
|
||||
set s=%H%\vendor\zstd\lib
|
||||
@rem %RUN_CL% -J -O2 -W4 -WX %DEFS% -DDYNAMIC_BMI2=0 -DZSTD_DISABLE_ASM -c %s%\common\*.c %s%\compress\*.c %s%\decompress\*.c
|
||||
@rem %RUN_LIB% -out:zstd.lib *.obj
|
||||
@REM ===== build UPX =====
|
||||
cd %BDIR%\upx
|
||||
set s=%H%\src
|
||||
cat .GITREV.txt
|
||||
set /p GITREV=<.GITREV.txt
|
||||
set UPX_DEFS=-DUPX_CONFIG_DISABLE_WSTRICT=0 -DUPX_CONFIG_DISABLE_WERROR=0 -DWITH_BZIP2=0 -DWITH_ZSTD=0
|
||||
set UPX_LIBS=%BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib
|
||||
@rem set UPX_LIBS=%BDIR%\bzip2\bzip2.lib %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib %BDIR%\zstd\zstd.lib
|
||||
set sources=%s%\*.cpp %s%\check\*.cpp %s%\compress\*.cpp %s%\console\*.cpp %s%\filter\*.cpp %s%\util\*.cpp
|
||||
%RUN_CL% -J -O2 -W4 -WX -std:c++17 -Zc:__cplusplus -EHsc -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% %UPX_DEFS% -I%H%\vendor -Feupx.exe %sources% %UPX_LIBS% /link ${{ matrix.link_machine_flags }} setargv.obj
|
||||
- name: 'Make artifact'
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-windows-${{ matrix.name }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N/$B"
|
||||
cp -ai build/$C/$B/upx/upx*.exe "tmp/artifact/$N/$B"
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run basic tests'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
run: |
|
||||
$ErrorActionPreference = 'stop'
|
||||
$ErrorView = 'NormalView'
|
||||
cd $Env:H\build\$Env:C\$Env:B\upx
|
||||
$Env:UPX = "--no-color --no-progress"
|
||||
.\upx.exe --version
|
||||
.\upx.exe upx.exe -o upx_packed.exe
|
||||
dir *.exe
|
||||
.\upx.exe -l upx_packed.exe
|
||||
.\upx.exe -t upx_packed.exe
|
||||
.\upx_packed.exe --version
|
||||
- name: 'Run test suite'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
shell: bash
|
||||
run: |
|
||||
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
|
||||
testsuite_1="$(readlink -en ./misc/testsuite/upx_testsuite_1.sh)"
|
||||
env -C build/$C/$B/upx upx_exe=./upx.exe bash "$testsuite_1"
|
||||
|
||||
job-linux-zigcc: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: 'alpine:3.18' # older versions such as alpine:3.12 also work; no-container also works
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# only build a few targets => more targets are tested in the Weekly CI
|
||||
- { zig_target: aarch64-linux-musl }
|
||||
# { zig_target: aarch64-linux-musl, zig_pic: -fPIE }
|
||||
# { zig_target: aarch64-macos-none }
|
||||
- { zig_target: aarch64-macos.11.0-none }
|
||||
# { zig_target: aarch64-macos.12.0-none }
|
||||
# { zig_target: aarch64-macos.13.0-none }
|
||||
- { zig_target: aarch64-windows-gnu }
|
||||
- { zig_target: arm-linux-musleabihf }
|
||||
# { zig_target: arm-linux-musleabihf, zig_pic: -fPIE }
|
||||
# { zig_target: i386-linux-musl }
|
||||
# { zig_target: i386-linux-musl, zig_pic: -fPIE }
|
||||
- { zig_target: i386-windows-gnu }
|
||||
# { zig_target: mips-linux-musl }
|
||||
# { zig_target: mipsel-linux-musl }
|
||||
# { zig_target: powerpc-linux-musl }
|
||||
# { zig_target: powerpc64-linux-musl }
|
||||
# { zig_target: powerpc64le-linux-musl }
|
||||
- { zig_target: x86_64-linux-musl }
|
||||
# { zig_target: x86_64-linux-musl, zig_pic: -fPIE }
|
||||
# { zig_target: x86_64-macos-none }
|
||||
- { zig_target: x86_64-macos.11.0-none }
|
||||
# { zig_target: x86_64-macos.12.0-none }
|
||||
# { zig_target: x86_64-macos.13.0-none }
|
||||
- { zig_target: x86_64-windows-gnu }
|
||||
env:
|
||||
# for zig-cc wrapper scripts (see below):
|
||||
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING
|
||||
ZIG_FLAGS: ${{ matrix.zig_flags }}
|
||||
ZIG_PIC: ${{ matrix.zig_pic }}
|
||||
ZIG_TARGET: ${{ matrix.zig_target }}
|
||||
steps:
|
||||
- name: 'Install Alpine Linux container packages'
|
||||
if: ${{ job.container }}
|
||||
shell: sh
|
||||
run: |
|
||||
apk update && apk upgrade && apk add bash cmake file git make tar xz
|
||||
# set PATH like in Ubuntu
|
||||
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: ${{ format('Install Zig {0}', env.ZIG_DIST_VERSION) }}
|
||||
shell: bash
|
||||
run: |
|
||||
# GitHub Actions magic: set "UPX_GITREV_SHORT" environment value for use in steps below
|
||||
rev=$(git rev-parse --short=7 HEAD)
|
||||
echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV
|
||||
# update ZIG_TARGET (i386 => x86)
|
||||
ZIG_TARGET=${ZIG_TARGET/i386-/x86-}
|
||||
echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV
|
||||
# install zig; note that ~/.local/bin is included in the default $PATH on Ubuntu
|
||||
mkdir -p -v ~/.local/bin
|
||||
cd ~/.local/bin
|
||||
ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION}
|
||||
wget -q https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz
|
||||
ls -l ${ZIG_DIST_NAME}.tar.xz
|
||||
tar -xoJf ${ZIG_DIST_NAME}.tar.xz
|
||||
rm ${ZIG_DIST_NAME}.tar.xz
|
||||
ln -s -v ${ZIG_DIST_NAME}/zig zig
|
||||
#echo "PATH=$PATH" && which zig
|
||||
echo -n 'zig version: '; zig version
|
||||
# create wrapper scripts (needed for CMake)
|
||||
echo -e '#!/bin/sh\nexec zig ar "$@"' > zig-ar
|
||||
echo -e '#!/bin/sh\nexec zig cc -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CFLAGS "$@"' > zig-cc
|
||||
echo -e '#!/bin/sh\nexec zig c++ -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CXXFLAGS "$@"' > zig-cxx
|
||||
echo -e '#!/bin/sh\nexec zig ranlib "$@"' > zig-ranlib
|
||||
chmod +x zig-ar zig-cc zig-cxx zig-ranlib
|
||||
ls -la; head zig-ar zig-cc zig-cxx zig-ranlib
|
||||
- name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }}
|
||||
run: |
|
||||
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/release
|
||||
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release
|
||||
cmake ../../../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_RELEASE
|
||||
cmake --build . --config Release --parallel --verbose
|
||||
file ./upx*
|
||||
- name: ${{ format('Build Debug with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }}
|
||||
run: |
|
||||
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/debug
|
||||
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug
|
||||
cmake ../../../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_DEBUG
|
||||
cmake --build . --config Debug --parallel --verbose
|
||||
file ./upx*
|
||||
- name: ${{ format('Make artifact from upx-{0}-{1}', github.ref_name, env.UPX_GITREV_SHORT) }}
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-zigcc-${{ matrix.zig_target }}${ZIG_PIC}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
|
||||
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run install tests'
|
||||
if: ${{ contains(matrix.zig_target, '-linux') }}
|
||||
run: |
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-make make install)
|
||||
@@ -0,0 +1,39 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
# see https://docs.github.com/en/actions/managing-issues-and-pull-requests/closing-inactive-issues
|
||||
# see https://github.com/actions/stale
|
||||
|
||||
# Automatically closing issues is far from perfect, but then we only
|
||||
# have limited resources and this approach favors issues that people
|
||||
# actually care about.
|
||||
#
|
||||
# also see:
|
||||
# "Should I Stale or Should I Close? An Analysis of a Bot that Closes
|
||||
# Abandoned Issues and Pull Request".
|
||||
# https://igorwiese.com/images/papers/Paper_BotSE_19.pdf
|
||||
|
||||
name: 'GitHub - Close inactive issues'
|
||||
on:
|
||||
schedule: [cron: '50 0 * * 3'] # run weekly Wednesday 00:50 UTC
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
job-close-inactive-issues:
|
||||
if: github.repository_owner == 'upx'
|
||||
name: 'Close inactive issues'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v8
|
||||
with:
|
||||
operations-per-run: 300
|
||||
exempt-all-milestones: true
|
||||
exempt-issue-labels: 'blocker,bug,enhancement,help wanted,regression'
|
||||
days-before-stale: 60
|
||||
days-before-close: 30
|
||||
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Please remove the stale label or add a comment or this issue will be closed in 30 days.'
|
||||
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Please remove the stale label or add a comment or this PR will be closed in 30 days.'
|
||||
close-issue-message: 'This issue was closed because it has been stalled for 30 days with no activity. Please feel free to reopen.'
|
||||
close-pr-message: 'This PR was closed because it has been stalled for 30 days with no activity. Please feel free to reopen.'
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
name: 'GitHub - Close pull requests'
|
||||
on:
|
||||
#pull_request:
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
job-close-pull-requests:
|
||||
if: github.repository_owner == 'upx'
|
||||
name: 'Close pull requests'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: 'Close pull requests'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh pr list --repo='${{ github.repository }}' --state=open --json=number | jq '.[].number' | xargs -r -n1 -- gh pr close --repo='${{ github.repository }}'
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# see https://github.com/crate-ci/typos
|
||||
|
||||
name: 'Misc - Spell check'
|
||||
on:
|
||||
schedule: [cron: '55 0 * * 3'] # run weekly Wednesday 00:55 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
jobs:
|
||||
job-spell-check:
|
||||
if: github.repository_owner == 'upx'
|
||||
name: 'Spell check'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: false }
|
||||
- name: 'Spell check with crate-ci/typos'
|
||||
uses: crate-ci/typos@47dd2976043bd5c76a33aa9300b328a176a1d6f7 # v1.16.21
|
||||
with: { config: ./.github/typos_config.toml }
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
name: 'Static Analyzer - clang-analyzer'
|
||||
on:
|
||||
schedule: [cron: '10 4 * * 3'] # run weekly Wednesday 04:10 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-analyze-clang-analyzer: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- container: 'alpine:3.16'
|
||||
- container: 'alpine:3.17'
|
||||
- container: 'alpine:3.18'
|
||||
- container: 'alpine:edge'
|
||||
- container: 'i386/alpine:3.18'
|
||||
- container: 'i386/alpine:edge'
|
||||
name: ${{ format('Analyze clang-analyzer {0}', matrix.container) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0}', matrix.container) }}
|
||||
run: 'apk update && apk upgrade && apk add clang clang-analyzer cmake g++ git make'
|
||||
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
|
||||
git submodule update --init
|
||||
- name: 'Perform clang-analyzer scan-build Analysis Debug'
|
||||
run: 'make build/analyze/clang-analyzer/debug'
|
||||
- name: 'Perform clang-analyzer scan-build Analysis Release'
|
||||
if: success() || failure() # run this step even if the previous step failed
|
||||
run: 'make build/analyze/clang-analyzer/release'
|
||||
@@ -0,0 +1,39 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
name: 'Static Analyzer - clang-tidy'
|
||||
on:
|
||||
schedule: [cron: '30 4 * * 3'] # run weekly Wednesday 04:30 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-analyze-clang-tidy: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- container: 'alpine:3.18'
|
||||
- container: 'alpine:edge'
|
||||
- container: 'i386/alpine:3.18'
|
||||
- container: 'i386/alpine:edge'
|
||||
name: ${{ format('Analyze clang-tidy {0}', matrix.container) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0}', matrix.container) }}
|
||||
run: 'apk update && apk upgrade && apk add clang clang-extra-tools cmake g++ git make python3'
|
||||
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
|
||||
git submodule update --init
|
||||
- name: 'Perform clang-tidy Analysis Debug'
|
||||
run: 'make -k build/analyze/clang-tidy/debug'
|
||||
- name: 'Perform clang-tidy Analysis Release'
|
||||
if: success() || failure() # run this step even if the previous step failed
|
||||
run: 'make -k build/analyze/clang-tidy/release'
|
||||
@@ -0,0 +1,36 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
name: 'Static Analyzer - CodeQL'
|
||||
on:
|
||||
schedule: [cron: '50 4 * * 3'] # run weekly Wednesday 04:50 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-analyze-codeql:
|
||||
if: github.repository_owner == 'upx'
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
@@ -0,0 +1,66 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# test minimal number of packages required for building UPX under Alpine Linux
|
||||
# clang: apk add clang cmake make
|
||||
# gcc: apk add cmake g++ make
|
||||
|
||||
name: 'Test - Minimal Alpine build'
|
||||
on: [workflow_dispatch]
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-alpine-clang: # uses cmake + make
|
||||
if: true
|
||||
strategy: { matrix: { container: ['alpine:edge','i386/alpine:edge'] } }
|
||||
name: ${{ format('clang {0}', matrix.container) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Build clang {0}', matrix.container) }}
|
||||
run: |
|
||||
apk update && apk upgrade && apk add clang cmake make
|
||||
wget https://github.com/upx/upx/releases/download/v4.2.0/upx-4.2.0-src.tar.xz
|
||||
tar -xoaf upx-*-src.tar.xz
|
||||
cd upx-*-src
|
||||
make build/debug CC="clang -static" CXX="clang++ -static"
|
||||
make build/release CC="clang -static" CXX="clang++ -static"
|
||||
make -C build/debug test
|
||||
make -C build/release test
|
||||
make -C build/release install DESTDIR="$PWD/Install"
|
||||
N=$(echo "upx-test-alpine-linux-clang-${{ matrix.container }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: missing nodejs on host
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: 'upx*/build/*/upx'
|
||||
|
||||
job-alpine-gcc: # uses cmake + make
|
||||
if: true
|
||||
strategy: { matrix: { container: ['alpine:edge','i386/alpine:edge'] } }
|
||||
name: ${{ format('gcc {0}', matrix.container) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Build gcc {0}', matrix.container) }}
|
||||
run: |
|
||||
apk update && apk upgrade && apk add cmake g++ make
|
||||
wget https://github.com/upx/upx/releases/download/v4.2.0/upx-4.2.0-src.tar.xz
|
||||
tar -xoaf upx-*-src.tar.xz
|
||||
cd upx-*-src
|
||||
make build/debug CC="gcc -static" CXX="g++ -static"
|
||||
make build/release CC="gcc -static" CXX="g++ -static"
|
||||
make -C build/debug test
|
||||
make -C build/release test
|
||||
make -C build/release install DESTDIR="$PWD/Install"
|
||||
N=$(echo "upx-test-alpine-linux-gcc-${{ matrix.container }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: missing nodejs on host
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: 'upx*/build/*/upx'
|
||||
@@ -0,0 +1,133 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
name: 'Test - CMake default build type'
|
||||
on: [workflow_dispatch]
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
|
||||
#
|
||||
# single-config generators - these use and respect CMAKE_BUILD_TYPE
|
||||
#
|
||||
|
||||
cmake-make:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Config, build, test and install'
|
||||
run: |
|
||||
cmake -S . -B build/default -G "Unix Makefiles"
|
||||
cmake --build build/default --parallel --verbose
|
||||
ctest --test-dir build/default
|
||||
(cd build/default && DESTDIR=$PWD/Install-default cmake --install .)
|
||||
# "make test" also works
|
||||
env -C build/default make test
|
||||
# "make install" also works
|
||||
env -C build/default DESTDIR=./Install-with-make make install
|
||||
|
||||
cmake-ninja:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Config, build, test and install'
|
||||
run: |
|
||||
test -f /usr/bin/ninja || sudo apt-get install -y ninja-build
|
||||
cmake -S . -B build/default -G Ninja
|
||||
cmake --build build/default --parallel --verbose
|
||||
ctest --test-dir build/default
|
||||
(cd build/default && DESTDIR=$PWD/Install-default cmake --install .)
|
||||
# "ninja test" also works
|
||||
env -C build/default ninja test
|
||||
# "ninja install" also works
|
||||
env -C build/default DESTDIR=./Install-with-ninja ninja install
|
||||
|
||||
cmake-nmake:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
|
||||
with:
|
||||
vsversion: 2022
|
||||
arch: amd64
|
||||
- name: 'Config, build, test and install'
|
||||
run: |
|
||||
cmake -S . -B build/default -G "NMake Makefiles"
|
||||
cmake --build build/default --parallel --verbose
|
||||
ctest --test-dir build/default
|
||||
# "cmake --install" works on Windows as well, nice
|
||||
env -C build/default DESTDIR=./Install-default cmake --install .
|
||||
# "nmake test" also works
|
||||
env -C build/default nmake test
|
||||
# "nmake install" also works
|
||||
env -C build/default DESTDIR=./Install-with-nmake nmake install
|
||||
|
||||
#
|
||||
# multi-config generators - these use CMAKE_CONFIGURATION_TYPES, but the defaults seem inconsistent
|
||||
# => when using multi-config generators always explicitly pass the requested build-config
|
||||
#
|
||||
|
||||
# ninja-multi-config seems to use the *first* element of CMAKE_CONFIGURATION_TYPES; nice
|
||||
cmake-ninja-multi-config:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Config, build, test and install'
|
||||
run: |
|
||||
test -f /usr/bin/ninja || sudo apt-get install -y ninja-build
|
||||
cmake -S . -B build/default -G "Ninja Multi-Config"
|
||||
cmake --build build/default --parallel --verbose
|
||||
# multi-config: ctest NEEDS a config
|
||||
ctest --test-dir build/default -C Release
|
||||
(cd build/default && DESTDIR=$PWD/Install-default cmake --install .)
|
||||
# "ninja test" also works with multi-config
|
||||
env -C build/default ninja test
|
||||
# "ninja install" also works with multi-config
|
||||
env -C build/default DESTDIR=./Install-with-ninja ninja install
|
||||
|
||||
# vsstudio-multi-config (msbuild) seems to use "Debug" by default
|
||||
cmake-vsstudio-multi-config:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
|
||||
with:
|
||||
vsversion: 2022
|
||||
arch: amd64
|
||||
- name: 'Config, build and test'
|
||||
run: |
|
||||
cmake -S . -B build/default
|
||||
cmake --build build/default --parallel --verbose
|
||||
# multi-config: ctest NEEDS a config
|
||||
ctest --test-dir build/default -C Debug
|
||||
# TODO: does cmake --install work?
|
||||
|
||||
# xcode-multi-config (xcodebuild) seems to use "Debug" by default, except for "cmake --install" (BUG?)
|
||||
cmake-xcode-multi-config:
|
||||
runs-on: macos-12
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Config, build, test and install'
|
||||
run: |
|
||||
cmake -S . -B build/default -G Xcode
|
||||
cmake --build build/default --parallel --verbose
|
||||
# multi-config: ctest NEEDS a config
|
||||
ctest --test-dir build/default -C Debug
|
||||
# BUG(?) multi-config: cmake --install defaults to "Release" !!
|
||||
(cd build/default && DESTDIR=$PWD/Install-default cmake --install . --config Debug)
|
||||
@@ -0,0 +1,16 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
name: 'Test - Unused'
|
||||
on: [workflow_dispatch]
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-unused: # uses cmake + make
|
||||
if: true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: |
|
||||
true
|
||||
@@ -0,0 +1,48 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
name: 'Test - YAML check'
|
||||
on: [workflow_dispatch]
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-yaml-check:
|
||||
if: true
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- container: 'alpine:3.16'
|
||||
- container: 'alpine:3.17'
|
||||
- container: 'alpine:3.18'
|
||||
- container: 'alpine:edge'
|
||||
name: ${{ format('{0}', matrix.container) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0}', matrix.container) }}
|
||||
run: |
|
||||
apk update && apk upgrade && apk add bash git yq
|
||||
case ${{ matrix.container }} in
|
||||
*:edge) apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing ytt ;;
|
||||
esac
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: false }
|
||||
- name: ${{ format('YAML check {0}', matrix.container) }}
|
||||
shell: bash
|
||||
run: |
|
||||
for f in $(find . -type f -iname '*.yml' | LC_ALL=C sort); do
|
||||
echo "===== checking file"
|
||||
echo " yq $f"
|
||||
yq < "$f" > /dev/null
|
||||
if command -v ytt > /dev/null; then
|
||||
echo " ytt $f"
|
||||
ytt -f- < "$f" > /dev/null
|
||||
fi
|
||||
done
|
||||
echo "All done."
|
||||
@@ -0,0 +1,165 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# BS BuildSystem: build "by hand" using a POSIX-compliant shell
|
||||
|
||||
name: 'Weekly CI BS - By Hand'
|
||||
on:
|
||||
schedule: [cron: '00 1 * * 3'] # run weekly Wednesday 01:00 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
VERBOSE: 1
|
||||
|
||||
jobs:
|
||||
job-by-hand-alpine-linux-gcc: # uses a POSIX-compliant shell
|
||||
# ...and also uses a subdirectory "upx with space" in order to detect possible quoting issues
|
||||
# ...and also uses ccache as we are running the same build-script again and again
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy: { matrix: { container: ['alpine:3.9','alpine:3.18','alpine:edge','i386/alpine:edge'] } }
|
||||
name: ${{ format('by-hand gcc {0}', matrix.container) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0}', matrix.container) }}
|
||||
run: |
|
||||
# install ccache, g++, git and various POSIX shells
|
||||
shells="bash dash loksh mksh zsh"
|
||||
case ${{ matrix.container }} in
|
||||
*:3.18 | *:edge) shells="$shells oksh yash" ;;
|
||||
esac
|
||||
echo "installing shells: $shells"
|
||||
apk update && apk upgrade && apk add ccache g++ git $shells
|
||||
# enable ccache and some warnings
|
||||
xflags="-static -Wall -Wextra -Werror"
|
||||
echo -e "CC=ccache gcc $xflags\nCXX=ccache g++ -std=gnu++17 $xflags" >> $GITHUB_ENV
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
# create user upx:upx 2000:2000 for file system tests below ("sudo")
|
||||
adduser upx -u 2000 -D && cd /home/upx && chmod 00700 . && chown -R upx:upx .
|
||||
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" "upx with space"
|
||||
git -C "upx with space" submodule update --init
|
||||
- name: 'Build by-hand with /bin/sh'
|
||||
run: '/bin/sh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with bash'
|
||||
run: 'bash "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with bash --posix'
|
||||
run: 'bash --posix "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with busybox ash'
|
||||
run: 'busybox ash "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with busybox sh'
|
||||
run: 'busybox sh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with dash'
|
||||
run: 'dash "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with loksh'
|
||||
run: 'ksh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with loksh -o posix'
|
||||
run: 'ksh -o posix "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with loksh -o sh'
|
||||
run: 'ksh -o sh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with mksh'
|
||||
run: 'mksh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with mksh -o posix'
|
||||
run: 'mksh -o posix "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with mksh -o sh'
|
||||
run: 'mksh -o sh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with oksh'
|
||||
if: endsWith(matrix.container, ':3.18') || endsWith(matrix.container, ':edge')
|
||||
run: 'oksh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with oksh -o posix'
|
||||
if: endsWith(matrix.container, ':3.18') || endsWith(matrix.container, ':edge')
|
||||
run: 'oksh -o posix "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with oksh -o sh'
|
||||
if: endsWith(matrix.container, ':3.18') || endsWith(matrix.container, ':edge')
|
||||
run: 'oksh -o sh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with yash'
|
||||
if: endsWith(matrix.container, ':3.18') || endsWith(matrix.container, ':edge')
|
||||
run: 'yash "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with zsh'
|
||||
run: 'zsh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with zsh --emulate ksh'
|
||||
run: 'zsh --emulate ksh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with zsh --emulate sh'
|
||||
run: 'zsh --emulate sh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Show ccache stats'
|
||||
run: |
|
||||
ccache -s
|
||||
ccache -p
|
||||
- name: 'Run file system test suite (busybox)'
|
||||
run: |
|
||||
apk add bash sudo
|
||||
testsuite="$(readlink -fn "upx with space"/misc/testsuite/test_symlinks.sh)"
|
||||
cd "upx with space"/build/by-hand
|
||||
# IMPORTANT: do NOT run as user root!
|
||||
chmod a+w . && sudo -u upx bash "$testsuite"
|
||||
- name: 'Run file system test suite (coreutils)'
|
||||
run: |
|
||||
apk add bash coreutils sudo
|
||||
testsuite="$(readlink -fn "upx with space"/misc/testsuite/test_symlinks.sh)"
|
||||
cd "upx with space"/build/by-hand
|
||||
# IMPORTANT: do NOT run as user root!
|
||||
chmod a+w . && sudo -u upx bash "$testsuite"
|
||||
|
||||
job-by-hand-macos-clang: # uses a POSIX-compliant shell
|
||||
# ...and also uses a subdirectory "upx with space" in order to detect possible quoting issues
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: macos-11, run_fs_test: false } # macos-11 does not have "readlink -f"
|
||||
- { os: macos-12, run_fs_test: true }
|
||||
- { os: macos-13, run_fs_test: true }
|
||||
name: ${{ format('by-hand clang {0}', matrix.os) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: 'Install brew packages'
|
||||
run: |
|
||||
# install ccache
|
||||
if ! command -v ccache > /dev/null; then
|
||||
# only run "brew update" if needed
|
||||
if ! brew install ccache; then brew update && brew install ccache; fi
|
||||
fi
|
||||
xflags="-Wall -Wextra -Werror"
|
||||
echo -e "CC=ccache clang $xflags\nCXX=ccache clang++ -std=gnu++17 $xflags" >> $GITHUB_ENV
|
||||
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" "upx with space"
|
||||
git -C "upx with space" submodule update --init
|
||||
- name: 'Build by-hand with /bin/sh'
|
||||
run: 'top_srcdir="$PWD/upx with space" /bin/sh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with bash'
|
||||
run: 'top_srcdir="$PWD/upx with space" bash "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Build by-hand with zsh'
|
||||
run: 'top_srcdir="$PWD/upx with space" zsh "./upx with space/misc/scripts/build_upx_by_hand.sh"'
|
||||
- name: 'Run file system test suite'
|
||||
if: ${{ matrix.run_fs_test }}
|
||||
run: |
|
||||
testsuite="$(readlink -fn "upx with space"/misc/testsuite/test_symlinks.sh)"
|
||||
cd "upx with space"/build/by-hand
|
||||
bash "$testsuite"
|
||||
|
||||
job-by-hand-windows-gcc: # uses a POSIX-compliant shell
|
||||
# ...and also uses a subdirectory "upx with space" in order to detect possible quoting issues
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: windows-2019 }
|
||||
- { os: windows-2022 }
|
||||
name: ${{ format('by-hand gcc {0}', matrix.os) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
|
||||
shell: bash
|
||||
run: |
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" "upx with space"
|
||||
git -C "upx with space" submodule update --init
|
||||
- name: 'Build by-hand with bash'
|
||||
shell: bash
|
||||
run: |
|
||||
xflags="-static -Wall -Wextra -Werror"
|
||||
CC="gcc $xflags" CXX="g++ -std=gnu++17 $xflags" bash "./upx with space/misc/scripts/build_upx_by_hand.sh"
|
||||
@@ -0,0 +1,56 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# BS BuildSystem: build on macOS with 'cmake -G Xcode'
|
||||
|
||||
name: 'Weekly CI BS - cmake macOS Xcode'
|
||||
on:
|
||||
schedule: [cron: '10 1 * * 3'] # run weekly Wednesday 01:10 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-cmake-macos-xcode: # uses cmake + xcodebuild
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: macos-11, run_test: true }
|
||||
- { os: macos-12, run_test: true }
|
||||
- { os: macos-13, run_test: false } # TODO: enable once UPX fully works on macos-13
|
||||
name: ${{ format('{0} cmake Xcode', matrix.os) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- { name: 'Config cmake Xcode', run: 'cmake -S . -B build/xcode -G Xcode' }
|
||||
- { name: 'Build cmake Xcode default', run: 'cmake --build build/xcode --parallel --verbose' }
|
||||
- { name: 'Build cmake Xcode Debug', run: 'cmake --build build/xcode --parallel --verbose --config Debug' }
|
||||
- { name: 'Build cmake Xcode Release', run: 'cmake --build build/xcode --parallel --verbose --config Release' }
|
||||
- name: 'Make artifact'
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-xcode-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && rsync -R -a */*/upx "../tmp/artifact/$N/")
|
||||
(cd tmp/artifact && gtar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run basic tests'
|
||||
if: ${{ matrix.run_test }}
|
||||
run: |
|
||||
ctest --test-dir build/xcode -C Debug
|
||||
# ctest --test-dir build/xcode -C Release
|
||||
- name: 'Run install tests'
|
||||
run: |
|
||||
(cd build/xcode && DESTDIR=$PWD/Install-default cmake --install .)
|
||||
(cd build/xcode && DESTDIR=$PWD/Install-debug cmake --install . --config Debug)
|
||||
(cd build/xcode && DESTDIR=$PWD/Install-release cmake --install . --config Release)
|
||||
ls -l build/xcode/Install-*/usr/local/bin/upx
|
||||
@@ -0,0 +1,95 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# BS BuildSystem: build on Windows with 'cmake -G "Unix Makefiles"'
|
||||
|
||||
name: 'Weekly CI BS - cmake Windows make'
|
||||
on:
|
||||
schedule: [cron: '20 1 * * 3'] # run weekly Wednesday 01:20 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_BUILD_FLAGS: --verbose
|
||||
UPX_CMAKE_CONFIG_FLAGS: -G "Unix Makefiles"
|
||||
|
||||
jobs:
|
||||
job-cmake-windows-make: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# INFO: the following don't work with GNU make (probably some quoting problems with spaces or backslashes)
|
||||
# => use Ninja generator instead; see weekly-ci-bs-cmake-windows-ninja.yml
|
||||
# # cl (MSVC)
|
||||
# - { os: windows-2019, cc: cl, cxx: cl, vsversion: 2019, arch: amd64 }
|
||||
# - { os: windows-2019, cc: cl, cxx: cl, vsversion: 2019, arch: amd64_arm64 }
|
||||
# - { os: windows-2019, cc: cl, cxx: cl, vsversion: 2019, arch: amd64_x86 }
|
||||
# - { os: windows-2022, cc: cl, cxx: cl, vsversion: 2022, arch: amd64 }
|
||||
# - { os: windows-2022, cc: cl, cxx: cl, vsversion: 2022, arch: amd64_arm64 }
|
||||
# - { os: windows-2022, cc: cl, cxx: cl, vsversion: 2022, arch: amd64_x86 }
|
||||
# # clang-cl
|
||||
# - { os: windows-2019, cc: clang-cl, cxx: clang-cl, vsversion: 2019, arch: amd64 }
|
||||
# - { os: windows-2022, cc: clang-cl, cxx: clang-cl, vsversion: 2022, arch: amd64 }
|
||||
# clang
|
||||
- { os: windows-2019, cc: clang, cxx: 'clang++', arch: amd64, xflags: '-static' }
|
||||
- { os: windows-2022, cc: clang, cxx: 'clang++', arch: amd64, xflags: '-static' }
|
||||
# gcc (mingw-gcc)
|
||||
- { os: windows-2019, cc: gcc, cxx: 'g++', arch: amd64, xflags: '-static' }
|
||||
- { os: windows-2022, cc: gcc, cxx: 'g++', arch: amd64, xflags: '-static' }
|
||||
env:
|
||||
CC: ${{ matrix.cc }} ${{ matrix.xflags }}
|
||||
CXX: ${{ matrix.cxx }} ${{ matrix.xflags }}
|
||||
name: ${{ format('{0} {1} {2}', matrix.cc, matrix.vsversion, matrix.arch) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
if: matrix.vsversion
|
||||
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
|
||||
with:
|
||||
vsversion: ${{ matrix.vsversion }}
|
||||
arch: ${{ matrix.arch }}
|
||||
- name: 'Init environment'
|
||||
shell: bash
|
||||
run: |
|
||||
xtarget="${{ matrix.os }}-make-${{ matrix.cc }}-${{ matrix.vsversion }}-${{ matrix.arch}}"
|
||||
echo "xtarget=$xtarget" >> $GITHUB_ENV
|
||||
- name: 'Build cmake Make Debug'
|
||||
shell: bash
|
||||
run: |
|
||||
make UPX_XTARGET=$xtarget xtarget/debug
|
||||
ls -l build/xtarget/$xtarget/debug/upx.exe
|
||||
file build/xtarget/$xtarget/debug/upx.exe || true
|
||||
- name: 'Build cmake Make Release'
|
||||
shell: bash
|
||||
run: |
|
||||
make UPX_XTARGET=$xtarget xtarget/release
|
||||
ls -l build/xtarget/$xtarget/release/upx.exe
|
||||
file build/xtarget/$xtarget/release/upx.exe || true
|
||||
- name: 'Make artifact'
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-make-${xtarget}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && cp -ai --parents xtarget/*/*/upx.exe "../tmp/artifact/$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run basic tests'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
shell: bash
|
||||
run: |
|
||||
ctest --test-dir build/xtarget/$xtarget/debug
|
||||
ctest --test-dir build/xtarget/$xtarget/release
|
||||
- name: 'Run install tests'
|
||||
shell: bash
|
||||
run: |
|
||||
env DESTDIR=./Install-debug cmake --install build/xtarget/$xtarget/debug
|
||||
env DESTDIR=./Install-release cmake --install build/xtarget/$xtarget/release
|
||||
@@ -0,0 +1,94 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# BS BuildSystem: build on Windows with 'cmake -G Ninja'
|
||||
|
||||
name: 'Weekly CI BS - cmake Windows Ninja'
|
||||
on:
|
||||
schedule: [cron: '30 1 * * 3'] # run weekly Wednesday 01:30 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_BUILD_FLAGS: --verbose
|
||||
UPX_CMAKE_CONFIG_FLAGS: -G Ninja
|
||||
|
||||
jobs:
|
||||
job-cmake-windows-ninja: # uses cmake + ninja
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# cl (MSVC)
|
||||
- { os: windows-2019, cc: cl, cxx: cl, vsversion: 2019, arch: amd64 }
|
||||
- { os: windows-2019, cc: cl, cxx: cl, vsversion: 2019, arch: amd64_arm64 }
|
||||
- { os: windows-2019, cc: cl, cxx: cl, vsversion: 2019, arch: amd64_x86 }
|
||||
- { os: windows-2022, cc: cl, cxx: cl, vsversion: 2022, arch: amd64 }
|
||||
- { os: windows-2022, cc: cl, cxx: cl, vsversion: 2022, arch: amd64_arm64 }
|
||||
- { os: windows-2022, cc: cl, cxx: cl, vsversion: 2022, arch: amd64_x86 }
|
||||
# clang-cl
|
||||
- { os: windows-2019, cc: clang-cl, cxx: clang-cl, vsversion: 2019, arch: amd64 }
|
||||
- { os: windows-2022, cc: clang-cl, cxx: clang-cl, vsversion: 2022, arch: amd64 }
|
||||
# clang
|
||||
- { os: windows-2019, cc: clang, cxx: 'clang++', arch: amd64, xflags: '-static' }
|
||||
- { os: windows-2022, cc: clang, cxx: 'clang++', arch: amd64, xflags: '-static' }
|
||||
# gcc (mingw-gcc)
|
||||
- { os: windows-2019, cc: gcc, cxx: 'g++', arch: amd64, xflags: '-static' }
|
||||
- { os: windows-2022, cc: gcc, cxx: 'g++', arch: amd64, xflags: '-static' }
|
||||
env:
|
||||
CC: ${{ matrix.cc }} ${{ matrix.xflags }}
|
||||
CXX: ${{ matrix.cxx }} ${{ matrix.xflags }}
|
||||
name: ${{ format('{0} {1} {2}', matrix.cc, matrix.vsversion, matrix.arch) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
if: matrix.vsversion
|
||||
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
|
||||
with:
|
||||
vsversion: ${{ matrix.vsversion }}
|
||||
arch: ${{ matrix.arch }}
|
||||
- name: 'Init environment'
|
||||
shell: bash
|
||||
run: |
|
||||
command -v ninja >/dev/null || choco install -y --no-progress ninja
|
||||
xtarget="${{ matrix.os }}-ninja-${{ matrix.cc }}-${{ matrix.vsversion }}-${{ matrix.arch}}"
|
||||
echo "xtarget=$xtarget" >> $GITHUB_ENV
|
||||
- name: 'Build cmake Ninja Debug'
|
||||
shell: bash
|
||||
run: |
|
||||
make UPX_XTARGET=$xtarget xtarget/debug
|
||||
ls -l build/xtarget/$xtarget/debug/upx.exe
|
||||
file build/xtarget/$xtarget/debug/upx.exe || true
|
||||
- name: 'Build cmake Ninja Release'
|
||||
shell: bash
|
||||
run: |
|
||||
make UPX_XTARGET=$xtarget xtarget/release
|
||||
ls -l build/xtarget/$xtarget/release/upx.exe
|
||||
file build/xtarget/$xtarget/release/upx.exe || true
|
||||
- name: 'Make artifact'
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-ninja-${xtarget}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && cp -ai --parents xtarget/*/*/upx.exe "../tmp/artifact/$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run basic tests'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
shell: bash
|
||||
run: |
|
||||
ctest --test-dir build/xtarget/$xtarget/debug
|
||||
ctest --test-dir build/xtarget/$xtarget/release
|
||||
- name: 'Run install tests'
|
||||
shell: bash
|
||||
run: |
|
||||
env DESTDIR=./Install-debug cmake --install build/xtarget/$xtarget/debug
|
||||
env DESTDIR=./Install-release cmake --install build/xtarget/$xtarget/release
|
||||
@@ -0,0 +1,78 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# BS BuildSystem: build on Windows with 'cmake -G "NMake Makefiles"'
|
||||
|
||||
name: 'Weekly CI BS - cmake Windows NMake'
|
||||
on:
|
||||
schedule: [cron: '40 1 * * 3'] # run weekly Wednesday 01:40 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-cmake-windows-nmake: # uses cmake + nmake
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# clang-cl
|
||||
- { os: windows-2022, vsversion: 2022, arch: amd64, clang_cl: true }
|
||||
# msvc
|
||||
- { os: windows-2019, vsversion: 2019, arch: amd64 }
|
||||
- { os: windows-2019, vsversion: 2019, arch: amd64_arm64 }
|
||||
- { os: windows-2019, vsversion: 2019, arch: amd64_x86 }
|
||||
- { os: windows-2022, vsversion: 2022, arch: amd64 }
|
||||
- { os: windows-2022, vsversion: 2022, arch: amd64_arm64 }
|
||||
- { os: windows-2022, vsversion: 2022, arch: amd64_x86 }
|
||||
name: ${{ format('vs{0} {1} {2}', matrix.vsversion, matrix.arch, matrix.clang_cl && 'clang-cl' || '') }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1
|
||||
with:
|
||||
vsversion: ${{ matrix.vsversion }}
|
||||
arch: ${{ matrix.arch }}
|
||||
- name: 'Build cmake NMake Debug'
|
||||
shell: cmd
|
||||
run: |
|
||||
set X=${{ matrix.clang_cl && '-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl' || '' }}
|
||||
cmake -S . -B build/debug -G "NMake Makefiles" -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug %X%
|
||||
cd build/debug
|
||||
nmake
|
||||
dir *.exe
|
||||
- name: 'Build cmake NMake Release'
|
||||
shell: cmd
|
||||
run: |
|
||||
set X=${{ matrix.clang_cl && '-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl' || '' }}
|
||||
cmake -S . -B build/release -G "NMake Makefiles" -DCMAKE_VERBOSE_MAKEFILE=ON %X%
|
||||
cd build/release
|
||||
nmake
|
||||
dir *.exe
|
||||
- name: 'Make artifact'
|
||||
shell: bash
|
||||
run: |
|
||||
X="${{ matrix.clang_cl && '-clang-cl' || '' }}"
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-nmake-vs${{ matrix.vsversion }}-${{ matrix.arch }}$X" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && cp -ai --parents */upx.exe "../tmp/artifact/$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run basic tests'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
run: |
|
||||
ctest --test-dir build/debug
|
||||
ctest --test-dir build/release
|
||||
- name: 'Run install tests'
|
||||
run: |
|
||||
env DESTDIR=./Install-debug cmake --install build/debug
|
||||
env DESTDIR=./Install-release cmake --install build/release
|
||||
@@ -0,0 +1,110 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# BS BuildSystem: build with misc flags
|
||||
|
||||
name: 'Weekly CI BS - Misc'
|
||||
on:
|
||||
schedule: [cron: '50 1 * * 3'] # run weekly Wednesday 01:50 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_BUILD_FLAGS: --verbose
|
||||
|
||||
jobs:
|
||||
BS0:
|
||||
runs-on: ubuntu-latest
|
||||
container: 'alpine:edge'
|
||||
steps:
|
||||
- name: 'Install packages'
|
||||
run: |
|
||||
apk update && apk upgrade && apk add bash git perl yq
|
||||
git config --global --add safe.directory '*'
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
|
||||
- name: 'Misc checks'
|
||||
run: |
|
||||
cat ./.github/*.yml | yq > /dev/null
|
||||
cat ./.github/*/*.yml | yq > /dev/null
|
||||
bash ./misc/scripts/check_whitespace_git.sh
|
||||
echo "All done."
|
||||
|
||||
BS1: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
container:
|
||||
- 'alpine:edge'
|
||||
- 'i386/alpine:edge'
|
||||
cc:
|
||||
- 'clang'
|
||||
- 'gcc'
|
||||
cppflags:
|
||||
- '-DWITH_XSPAN=0'
|
||||
- '-DWITH_XSPAN=1'
|
||||
- '-DWITH_XSPAN=2'
|
||||
- '-DDOCTEST_CONFIG_DISABLE'
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0}', matrix.container) }}
|
||||
run: 'apk update && apk upgrade && apk add clang cmake g++ git make'
|
||||
- name: ${{ format('Check out {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
|
||||
git submodule update --init
|
||||
# prepare environment
|
||||
xflags="-static ${{ matrix.cppflags }}"
|
||||
case ${{ matrix.cc }} in
|
||||
clang) CC="clang $xflags"; CXX="clang++ $xflags" ;;
|
||||
gcc) CC="gcc $xflags"; CXX="g++ $xflags" ;;
|
||||
*) exit 99 ;;
|
||||
esac
|
||||
echo -e "CC=$CC\nCXX=$CXX" >> $GITHUB_ENV
|
||||
- name: 'Build and test Debug'
|
||||
run: 'echo -e "CC=$CC;\nCXX=$CXX;" && make build/debug && ctest --test-dir build/debug'
|
||||
- name: 'Build and test Release'
|
||||
if: success() || failure() # run this step even if the previous step failed
|
||||
run: 'echo -e "CC=$CC;\nCXX=$CXX;" && make build/release && ctest --test-dir build/release'
|
||||
|
||||
BS2: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
container:
|
||||
- 'alpine:edge'
|
||||
cc:
|
||||
- 'clang'
|
||||
- 'gcc'
|
||||
cxxflags:
|
||||
- '-std=gnu++20'
|
||||
- '-std=gnu++23'
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0}', matrix.container) }}
|
||||
run: 'apk update && apk upgrade && apk add clang cmake g++ git make'
|
||||
- name: ${{ format('Check out {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
|
||||
git submodule update --init
|
||||
# prepare environment
|
||||
xflags="-static"
|
||||
case ${{ matrix.cc }} in
|
||||
clang) CC="clang $xflags"; CXX="clang++ $xflags ${{ matrix.cxxflags }}" ;;
|
||||
gcc) CC="gcc $xflags"; CXX="g++ $xflags ${{ matrix.cxxflags }}" ;;
|
||||
*) exit 99 ;;
|
||||
esac
|
||||
echo -e "CC=$CC\nCXX=$CXX" >> $GITHUB_ENV
|
||||
echo "UPX_CONFIG_DISABLE_C_STANDARD=ON" >> $GITHUB_ENV
|
||||
echo "UPX_CONFIG_DISABLE_CXX_STANDARD=ON" >> $GITHUB_ENV
|
||||
- name: 'Build and test Debug'
|
||||
run: 'echo -e "CC=$CC;\nCXX=$CXX;" && make build/debug && ctest --test-dir build/debug'
|
||||
- name: 'Build and test Release'
|
||||
if: success() || failure() # run this step even if the previous step failed
|
||||
run: 'echo -e "CC=$CC;\nCXX=$CXX;" && make build/release && ctest --test-dir build/release'
|
||||
@@ -0,0 +1,215 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# CC CompilationCheck: test various clang and gcc versions
|
||||
|
||||
# Build under various Alpine Linux versions with clang and gcc, and
|
||||
# also test building with C++20, C++23 and LTO.
|
||||
|
||||
# And also uses a subdirectory "upx with space" that contains whitespace in order
|
||||
# to detect possible quoting issues.
|
||||
|
||||
# info: Alpine Linux 3.9 (released Jan 2019) has clang-5, cmake-3.13.0
|
||||
# and gcc-8, which nicely matches our minimal build requirements
|
||||
|
||||
name: 'Weekly CI CC - Alpine Linux C++23'
|
||||
on:
|
||||
schedule: [cron: '00 2 * * 3'] # run weekly Wednesday 02:00 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_CONFIG_FLAGS: -DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
UPX_TESTSUITE_LEVEL: 4
|
||||
|
||||
jobs:
|
||||
job-alpine-cmake: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { container: 'alpine:3.9' , use_cxx20: 0, use_cxx2b: 0, use_lto: 0 } # Jan 2019: C++17; clang-5 & gcc-8
|
||||
- { container: 'alpine:3.10', use_cxx20: 0, use_cxx2b: 0, use_lto: 0 }
|
||||
- { container: 'alpine:3.11', use_cxx20: 0, use_cxx2b: 0, use_lto: 0 }
|
||||
- { container: 'alpine:3.12', use_cxx20: 0, use_cxx2b: 0, use_lto: 0 }
|
||||
- { container: 'alpine:3.13', use_cxx20: 1, use_cxx2b: 0, use_lto: 0 } # Jan 2021: C++20; clang-10 & gcc-10
|
||||
- { container: 'alpine:3.14', use_cxx20: 1, use_cxx2b: 0, use_lto: 0 }
|
||||
- { container: 'alpine:3.15', use_cxx20: 1, use_cxx2b: 0, use_lto: 1 } # Nov 2021: LTO; clang-12 & gcc-10 & binutils-2.37
|
||||
- { container: 'alpine:3.16', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 } # May 2022: C++2b; clang-13 & gcc-11
|
||||
- { container: 'alpine:3.17', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 }
|
||||
- { container: 'alpine:3.18', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 }
|
||||
- { container: 'alpine:edge', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 }
|
||||
- { container: 'i386/alpine:edge', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 }
|
||||
# more 32-bit i386 versions, just for testing
|
||||
# { container: 'i386/alpine:3.9' } # clang-5, gcc-8; BROKEN: clang -m32 problem
|
||||
- { container: 'i386/alpine:3.10' } # clang-8, gcc-8
|
||||
- { container: 'i386/alpine:3.11' } # clang-9, gcc-9
|
||||
- { container: 'i386/alpine:3.12' } # clang-10, gcc-9
|
||||
- { container: 'i386/alpine:3.13' } # clang-10, gcc-10
|
||||
- { container: 'i386/alpine:3.14' } # clang-11, gcc-10
|
||||
- { container: 'i386/alpine:3.15' } # clang-12, gcc-10
|
||||
- { container: 'i386/alpine:3.16' } # clang-13, gcc-11
|
||||
- { container: 'i386/alpine:3.17' } # clang-15, gcc-12
|
||||
- { container: 'i386/alpine:3.18' } # clang-16, gcc-12
|
||||
name: ${{ format('container {0}', matrix.container) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0}', matrix.container) }}
|
||||
run: |
|
||||
apk update && apk upgrade && apk add clang cmake g++ git make
|
||||
case ${{ matrix.container }} in
|
||||
# clang-dev is needed on Alpine versions <= 3.11 for clang headers like <emmintrin.h>
|
||||
*:3.[0-9] | *:3.1[0-1]) apk add clang-dev ;;
|
||||
esac
|
||||
case ${{ matrix.container }}-${{ matrix.use_lto }} in
|
||||
# llvm-dev is needed on Alpine versions <= 3.18 for -flto
|
||||
*:3.[0-9]-1 | *:3.1[0-8]-1) apk add llvm-dev ;;
|
||||
esac
|
||||
# set environment vars
|
||||
x="$(apk list -I "$(apk info -Wq "$(which clang)")")"; echo "clang_package=${x%% *}" >> $GITHUB_ENV
|
||||
x="$(apk list -I "$(apk info -Wq "$(which gcc)")")"; echo "gcc_package=${x%% *}" >> $GITHUB_ENV
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-alpine-${{ matrix.container }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
# create user upx:upx 2000:2000 for file system tests below ("sudo")
|
||||
adduser upx -u 2000 -D && cd /home/upx && chmod 00700 . && chown -R upx:upx .
|
||||
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" "upx with space"
|
||||
git -C "upx with space" submodule update --init
|
||||
|
||||
# build with default C11 and C++17
|
||||
- name: ${{ format('Build clang Release with {0}', env.clang_package) }}
|
||||
run: 'make -C "upx with space" UPX_XTARGET=clang-static CC="clang -static" CXX="clang++ -static"'
|
||||
- name: ${{ format('Build clang Debug with {0}', env.clang_package) }}
|
||||
run: 'make -C "upx with space" UPX_XTARGET=clang-static CC="clang -static" CXX="clang++ -static" xtarget/debug'
|
||||
- name: ${{ format('Build gcc Release with {0}', env.gcc_package) }}
|
||||
run: 'make -C "upx with space" UPX_XTARGET=gcc-static CC="gcc -static" CXX="g++ -static"'
|
||||
- name: ${{ format('Build gcc Debug with {0}', env.gcc_package) }}
|
||||
run: 'make -C "upx with space" UPX_XTARGET=gcc-static CC="gcc -static" CXX="g++ -static" xtarget/debug'
|
||||
|
||||
# build with C17 and C++20
|
||||
- name: ${{ format('Build clang C++20 Release with {0}', env.clang_package) }}
|
||||
if: matrix.use_cxx20
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_C_STANDARD=ON UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
make -C "upx with space" UPX_XTARGET=clang-static-cxx20 CC="clang -static -std=gnu17" CXX="clang++ -static -std=gnu++20"
|
||||
- name: ${{ format('Build clang C++20 Debug with {0}', env.clang_package) }}
|
||||
if: matrix.use_cxx20
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_C_STANDARD=ON UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
make -C "upx with space" UPX_XTARGET=clang-static-cxx20 CC="clang -static -std=gnu17" CXX="clang++ -static -std=gnu++20" xtarget/debug
|
||||
- name: ${{ format('Build gcc C++20 Release with {0}', env.gcc_package) }}
|
||||
if: matrix.use_cxx20
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_C_STANDARD=ON UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
make -C "upx with space" UPX_XTARGET=gcc-static-cxx20 CC="gcc -static -std=gnu17" CXX="g++ -static -std=gnu++20"
|
||||
- name: ${{ format('Build gcc C++20 Debug with {0}', env.gcc_package) }}
|
||||
if: matrix.use_cxx20
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_C_STANDARD=ON UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
make -C "upx with space" UPX_XTARGET=gcc-static-cxx20 CC="gcc -static -std=gnu17" CXX="g++ -static -std=gnu++20" xtarget/debug
|
||||
|
||||
# build with C23 and C++23
|
||||
- name: ${{ format('Build clang C++23 Release with {0}', env.clang_package) }}
|
||||
if: matrix.use_cxx23 || matrix.use_cxx2b
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_C_STANDARD=ON UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
a=gnu23; b=gnu++23; if test "X${{ matrix.use_cxx2b }}" = X1; then a=gnu2x; b=gnu++2b; fi
|
||||
make -C "upx with space" UPX_XTARGET=clang-static-cxx23 CC="clang -static -std=$a" CXX="clang++ -static -std=$b"
|
||||
- name: ${{ format('Build clang C++23 Debug with {0}', env.clang_package) }}
|
||||
if: matrix.use_cxx23 || matrix.use_cxx2b
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_C_STANDARD=ON UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
a=gnu23; b=gnu++23; if test "X${{ matrix.use_cxx2b }}" = X1; then a=gnu2x; b=gnu++2b; fi
|
||||
make -C "upx with space" UPX_XTARGET=clang-static-cxx23 CC="clang -static -std=$a" CXX="clang++ -static -std=$b" xtarget/debug
|
||||
- name: ${{ format('Build gcc C++23 Release with {0}', env.gcc_package) }}
|
||||
if: matrix.use_cxx23 || matrix.use_cxx2b
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_C_STANDARD=ON UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
a=gnu23; b=gnu++23; if test "X${{ matrix.use_cxx2b }}" = X1; then a=gnu2x; b=gnu++2b; fi
|
||||
make -C "upx with space" UPX_XTARGET=gcc-static-cxx23 CC="gcc -static -std=$a" CXX="g++ -static -std=$b"
|
||||
- name: ${{ format('Build gcc C++23 Debug with {0}', env.gcc_package) }}
|
||||
if: matrix.use_cxx23 || matrix.use_cxx2b
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_C_STANDARD=ON UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
a=gnu23; b=gnu++23; if test "X${{ matrix.use_cxx2b }}" = X1; then a=gnu2x; b=gnu++2b; fi
|
||||
make -C "upx with space" UPX_XTARGET=gcc-static-cxx23 CC="gcc -static -std=$a" CXX="g++ -static -std=$b" xtarget/debug
|
||||
|
||||
# build with -flto
|
||||
- name: ${{ format('Build clang LTO Release with {0}', env.clang_package) }}
|
||||
if: matrix.use_lto
|
||||
run: |
|
||||
make -C "upx with space" UPX_XTARGET=clang-static-cxxlto CC="clang -static -flto" CXX="clang++ -static -flto"
|
||||
- name: ${{ format('Build clang LTO Debug with {0}', env.clang_package) }}
|
||||
if: matrix.use_lto
|
||||
run: |
|
||||
make -C "upx with space" UPX_XTARGET=clang-static-cxxlto CC="clang -static -flto" CXX="clang++ -static -flto" xtarget/debug
|
||||
- name: ${{ format('Build gcc LTO Release with {0}', env.gcc_package) }}
|
||||
if: matrix.use_lto
|
||||
run: |
|
||||
make -C "upx with space" UPX_XTARGET=gcc-static-cxxlto CC="gcc -static -flto" CXX="g++ -static -flto"
|
||||
- name: ${{ format('Build gcc LTO Debug with {0}', env.gcc_package) }}
|
||||
if: matrix.use_lto
|
||||
run: |
|
||||
make -C "upx with space" UPX_XTARGET=gcc-static-cxxlto CC="gcc -static -flto" CXX="g++ -static -flto" xtarget/debug
|
||||
|
||||
- { name: 'Strip release binaries', run: 'strip -p --strip-unneeded "upx with space"/build/*/*/release/upx' }
|
||||
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: missing nodejs on host
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: 'upx with space*/build/*/*/*/upx'
|
||||
|
||||
- name: 'Run install tests'
|
||||
run: |
|
||||
(cd "upx with space"/build/xtarget/clang-static/debug && DESTDIR="$PWD/Install with cmake" cmake --install .)
|
||||
(cd "upx with space"/build/xtarget/clang-static/debug && DESTDIR="$PWD/Install with make" make install)
|
||||
(cd "upx with space"/build/xtarget/clang-static/release && DESTDIR="$PWD/Install with cmake" cmake --install .)
|
||||
(cd "upx with space"/build/xtarget/clang-static/release && DESTDIR="$PWD/Install with make" make install)
|
||||
(cd "upx with space"/build/xtarget/gcc-static/debug && DESTDIR="$PWD/Install with cmake" cmake --install .)
|
||||
(cd "upx with space"/build/xtarget/gcc-static/debug && DESTDIR="$PWD/Install with make" make install)
|
||||
(cd "upx with space"/build/xtarget/gcc-static/release && DESTDIR="$PWD/Install with cmake" cmake --install .)
|
||||
(cd "upx with space"/build/xtarget/gcc-static/release && DESTDIR="$PWD/Install with make" make install)
|
||||
|
||||
- { name: 'Run basic tests clang Debug', run: 'make -C "upx with space"/build/xtarget/clang-static/debug test' }
|
||||
- { name: 'Run basic tests clang Release', run: 'make -C "upx with space"/build/xtarget/clang-static/release test' }
|
||||
- { name: 'Run basic tests gcc Debug', run: 'make -C "upx with space"/build/xtarget/gcc-static/debug test' }
|
||||
- { name: 'Run basic tests gcc Release', run: 'make -C "upx with space"/build/xtarget/gcc-static/release test' }
|
||||
|
||||
- name: 'Run basic tests C++20, C++23 and LTO'
|
||||
if: matrix.use_cxx20 || matrix.use_cxx23 || matrix.use_cxx2b || matrix.use_lto
|
||||
run: |
|
||||
for dir in "upx with space"/build/xtarget/*-cxx*/*; do
|
||||
echo "===== $dir"
|
||||
make -C "$dir" test
|
||||
done
|
||||
|
||||
- name: 'Run file system test suite (busybox)'
|
||||
run: |
|
||||
apk add bash sudo
|
||||
testsuite="$(readlink -fn "upx with space"/misc/testsuite/test_symlinks.sh)"
|
||||
cd "upx with space"/build/xtarget/gcc-static/release
|
||||
# IMPORTANT: do NOT run as user root!
|
||||
chmod a+w . && sudo -u upx bash "$testsuite"
|
||||
|
||||
# test suite
|
||||
- name: ${{ format('Run test suite level {0}', env.UPX_TESTSUITE_LEVEL) }}
|
||||
run: |
|
||||
# testsuite needs bash and working "readlink -en" and "sha256sum -b"
|
||||
apk add bash coreutils
|
||||
# use a directory that contains whitespace to detect possible quoting issues
|
||||
git clone --depth=1 https://github.com/upx/upx-testsuite "upx-testsuite with space"
|
||||
export upx_testsuite_SRCDIR="$(readlink -fn "upx-testsuite with space")"
|
||||
testsuite_1="$(readlink -fn "upx with space"/misc/testsuite/upx_testsuite_1.sh)"
|
||||
(cd "upx with space"/build/xtarget/gcc-static/release && upx_exe=./upx bash "$testsuite_1")
|
||||
|
||||
- name: 'Run file system test suite (coreutils)'
|
||||
run: |
|
||||
apk add bash coreutils sudo
|
||||
testsuite="$(readlink -fn "upx with space"/misc/testsuite/test_symlinks.sh)"
|
||||
cd "upx with space"/build/xtarget/gcc-static/release
|
||||
# IMPORTANT: do NOT run as user root!
|
||||
chmod a+w . && sudo -u upx bash "$testsuite"
|
||||
@@ -0,0 +1,174 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# CC CompilationCheck: compile with various mingw-gcc versions and run tests under Wine
|
||||
|
||||
name: 'Weekly CI CC - Alpine Linux MinGW'
|
||||
on:
|
||||
schedule: [cron: '20 2 * * 3'] # run weekly Wednesday 02:20 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_CONFIG_FLAGS: -DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
|
||||
jobs:
|
||||
job-alpine-mingw: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { container: 'alpine:3.11', wine: false, i686_mingw: false } # skip Wine testsuite; TODO: internal error: doctest check failed
|
||||
- { container: 'alpine:3.12', wine: false, i686_mingw: false } # skip Wine testsuite; TODO: internal error: doctest check failed
|
||||
- { container: 'alpine:3.13', wine: true, i686_mingw: false } # wine-4.0.3
|
||||
- { container: 'alpine:3.14', wine: true, i686_mingw: false } # wine-6.18
|
||||
- { container: 'alpine:3.15', wine: true, i686_mingw: false } # wine-6.23
|
||||
- { container: 'alpine:3.16', wine: true, i686_mingw: false } # wine-7.8
|
||||
- { container: 'alpine:3.17', wine: true, i686_mingw: false } # wine-7.21
|
||||
# Wine >= 8.0 can run i686 32-bit programs in WOW64 mode on pure 64-bit systems
|
||||
- { container: 'alpine:3.18', wine: true, i686_mingw: true } # wine-8.13
|
||||
- { container: 'alpine:edge', wine: true, i686_mingw: true } # wine-8.17
|
||||
name: ${{ format('container {0}', matrix.container) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0}', matrix.container) }}
|
||||
run: |
|
||||
apk update && apk upgrade && apk add bash cmake coreutils file git make tar xz
|
||||
apk add mingw-w64-gcc
|
||||
test "${{ matrix.i686_mingw }}" = "true" && apk add i686-mingw-w64-gcc
|
||||
test "${{ matrix.wine }}" = "true" && apk add wine
|
||||
true
|
||||
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
# this seems to be needed for Wine when running in a container (beause of UID mismatch??)
|
||||
mkdir -p -v ~/.wine
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
|
||||
git submodule update --init
|
||||
- name: 'Build cmake extra/cross-windows-mingw32/debug'
|
||||
if: ${{ matrix.i686_mingw }}
|
||||
run: 'make build/extra/cross-windows-mingw32/debug'
|
||||
- name: 'Build cmake extra/cross-windows-mingw32/release'
|
||||
if: ${{ matrix.i686_mingw }}
|
||||
run: 'make build/extra/cross-windows-mingw32/release'
|
||||
- name: 'Build cmake extra/cross-windows-mingw64/debug'
|
||||
run: |
|
||||
# on Alpine 3.11 and 3.12 CMake does not find AR; Alpine >= 3.13 (with CMake 3.18.4) works
|
||||
X=
|
||||
case ${{ matrix.container }} in
|
||||
*:3.1[12]) X="CMAKE_AR=/usr/bin/x86_64-w64-mingw32-ar" ;;
|
||||
esac
|
||||
make build/extra/cross-windows-mingw64/debug $X
|
||||
- name: 'Build cmake extra/cross-windows-mingw64/release'
|
||||
run: |
|
||||
# on Alpine 3.11 and 3.12 CMake does not find AR; Alpine >= 3.13 (with CMake 3.18.4) works
|
||||
X=
|
||||
case ${{ matrix.container }} in
|
||||
*:3.1[12]) X="CMAKE_AR=/usr/bin/x86_64-w64-mingw32-ar" ;;
|
||||
esac
|
||||
make build/extra/cross-windows-mingw64/release $X
|
||||
- name: 'Make artifact'
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-alpine-mingw-${{ matrix.container }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
|
||||
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
|
||||
- name: ${{ format('Run test suite under Wine') }}
|
||||
if: ${{ matrix.wine }}
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/upx/upx-testsuite ../upx-testsuite
|
||||
testsuite_1="$(readlink -fn ./misc/testsuite/upx_testsuite_1.sh)"
|
||||
export upx_exe_runner="wine64"
|
||||
if test "${{ matrix.i686_mingw }}" = "true"; then
|
||||
UPX_TESTSUITE_LEVEL=2 \
|
||||
env -C build/extra/cross-windows-mingw32/debug upx_exe=./upx.exe bash "$testsuite_1"
|
||||
UPX_TESTSUITE_LEVEL=4 \
|
||||
env -C build/extra/cross-windows-mingw32/release upx_exe=./upx.exe bash "$testsuite_1"
|
||||
fi
|
||||
UPX_TESTSUITE_LEVEL=2 \
|
||||
env -C build/extra/cross-windows-mingw64/debug upx_exe=./upx.exe bash "$testsuite_1"
|
||||
UPX_TESTSUITE_LEVEL=4 \
|
||||
env -C build/extra/cross-windows-mingw64/release upx_exe=./upx.exe bash "$testsuite_1"
|
||||
|
||||
- name: 'Run basic tests under Wine - mingw32/debug'
|
||||
if: ${{ matrix.wine && matrix.i686_mingw }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -ex -o pipefail
|
||||
cd build/extra/cross-windows-mingw32/debug
|
||||
[[ -f upx && ! -f upx.exe ]] && mv -i -v upx upx.exe
|
||||
pwd; file ./upx.exe
|
||||
wine=wine64
|
||||
tt='./upx.exe'
|
||||
$wine ./upx.exe --version-short
|
||||
$wine ./upx.exe -3 $tt -o tt.packed.exe
|
||||
$wine ./upx.exe -l tt.packed.exe
|
||||
$wine ./upx.exe -t tt.packed.exe
|
||||
$wine ./upx.exe -d tt.packed.exe -o tt.unpacked.exe
|
||||
$wine ./tt.packed.exe --version-short
|
||||
$wine ./tt.unpacked.exe --version-short
|
||||
|
||||
- name: 'Run basic tests under Wine - mingw32/release'
|
||||
if: ${{ matrix.wine && matrix.i686_mingw }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -ex -o pipefail
|
||||
cd build/extra/cross-windows-mingw32/release
|
||||
[[ -f upx && ! -f upx.exe ]] && mv -i -v upx upx.exe
|
||||
pwd; file ./upx.exe
|
||||
wine=wine64
|
||||
tt='./upx.exe'
|
||||
$wine ./upx.exe --version-short
|
||||
$wine ./upx.exe -3 $tt -o tt.packed.exe
|
||||
$wine ./upx.exe -l tt.packed.exe
|
||||
$wine ./upx.exe -t tt.packed.exe
|
||||
$wine ./upx.exe -d tt.packed.exe -o tt.unpacked.exe
|
||||
$wine ./tt.packed.exe --version-short
|
||||
$wine ./tt.unpacked.exe --version-short
|
||||
|
||||
- name: 'Run basic tests under Wine - mingw64/debug'
|
||||
if: ${{ matrix.wine }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -ex -o pipefail
|
||||
cd build/extra/cross-windows-mingw64/debug
|
||||
[[ -f upx && ! -f upx.exe ]] && mv -i -v upx upx.exe
|
||||
pwd; file ./upx.exe
|
||||
wine=wine64
|
||||
tt='./upx.exe'
|
||||
$wine ./upx.exe --version-short
|
||||
$wine ./upx.exe -3 $tt -o tt.packed.exe
|
||||
$wine ./upx.exe -l tt.packed.exe
|
||||
$wine ./upx.exe -t tt.packed.exe
|
||||
$wine ./upx.exe -d tt.packed.exe -o tt.unpacked.exe
|
||||
$wine ./tt.packed.exe --version-short
|
||||
$wine ./tt.unpacked.exe --version-short
|
||||
|
||||
- name: 'Run basic tests under Wine - mingw64/release'
|
||||
if: ${{ matrix.wine }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -ex -o pipefail
|
||||
cd build/extra/cross-windows-mingw64/release
|
||||
[[ -f upx && ! -f upx.exe ]] && mv -i -v upx upx.exe
|
||||
pwd; file ./upx.exe
|
||||
wine=wine64
|
||||
tt='./upx.exe'
|
||||
$wine ./upx.exe --version-short
|
||||
$wine ./upx.exe -3 $tt -o tt.packed.exe
|
||||
$wine ./upx.exe -l tt.packed.exe
|
||||
$wine ./upx.exe -t tt.packed.exe
|
||||
$wine ./upx.exe -d tt.packed.exe -o tt.unpacked.exe
|
||||
$wine ./tt.packed.exe --version-short
|
||||
$wine ./tt.unpacked.exe --version-short
|
||||
@@ -0,0 +1,83 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# CC CompilationCheck: test llvm-mingw
|
||||
|
||||
# see https://github.com/mstorsjo/llvm-mingw
|
||||
|
||||
name: 'Weekly CI CC - llvm-mingw'
|
||||
on:
|
||||
schedule: [cron: '30 2 * * 3'] # run weekly Wednesday 02:30 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_CONFIG_FLAGS: -DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
|
||||
jobs:
|
||||
job-llvm-mingw: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: llvm-mingw-20230614-msvcrt
|
||||
llvm_version: 16.0.6
|
||||
url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20230614/llvm-mingw-20230614-msvcrt-ubuntu-20.04-x86_64.tar.xz'
|
||||
- name: llvm-mingw-20230614-ucrt
|
||||
llvm_version: 16.0.6
|
||||
url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20230614/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64.tar.xz'
|
||||
- name: llvm-mingw-20231017-msvcrt
|
||||
llvm_version: 17.0.3
|
||||
url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20231017/llvm-mingw-20231017-msvcrt-ubuntu-20.04-x86_64.tar.xz'
|
||||
- name: llvm-mingw-20231017-ucrt
|
||||
llvm_version: 17.0.3
|
||||
url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20231017/llvm-mingw-20231017-ucrt-ubuntu-20.04-x86_64.tar.xz'
|
||||
name: ${{ format('{0} {1}', matrix.name, matrix.llvm_version) }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: ${{ format('Install {0} {1}', matrix.name, matrix.llvm_version) }}
|
||||
run: |
|
||||
mkdir -p -v ~/.local/bin
|
||||
cd ~/.local/bin
|
||||
wget -q '${{ matrix.url }}'
|
||||
ls -l ./llvm-mingw*.tar.*
|
||||
tar -xoaf ./llvm-mingw*.tar.*
|
||||
rm ./llvm-mingw*.tar.*
|
||||
# update PATH
|
||||
cd ./llvm-mingw*/bin
|
||||
echo "PATH=$PWD:$PATH" >> $GITHUB_ENV
|
||||
- name: 'Build clang aarch64'
|
||||
run: |
|
||||
export CC="aarch64-w64-mingw32-clang -static" CXX="aarch64-w64-mingw32-clang++ -static"
|
||||
CC="$CC -D_WIN32_WINNT=0x0400"; CXX="$CXX -D_WIN32_WINNT=0x0400"
|
||||
make UPX_XTARGET=aarch64-w64-mingw32-clang xtarget/debug xtarget/release
|
||||
- name: 'Build clang armv7'
|
||||
run: |
|
||||
export CC="armv7-w64-mingw32-clang -static" CXX="armv7-w64-mingw32-clang++ -static"
|
||||
CC="$CC -D_WIN32_WINNT=0x0400"; CXX="$CXX -D_WIN32_WINNT=0x0400"
|
||||
make UPX_XTARGET=armv7-w64-mingw32-clang xtarget/debug xtarget/release
|
||||
- name: 'Build clang i686'
|
||||
run: |
|
||||
export CC="i686-w64-mingw32-clang -static" CXX="i686-w64-mingw32-clang++ -static"
|
||||
CC="$CC -D_WIN32_WINNT=0x0400"; CXX="$CXX -D_WIN32_WINNT=0x0400"
|
||||
make UPX_XTARGET=i686-w64-mingw32-clang xtarget/debug xtarget/release
|
||||
- name: 'Build clang x86_64'
|
||||
run: |
|
||||
export CC="x86_64-w64-mingw32-clang -static" CXX="x86_64-w64-mingw32-clang++ -static"
|
||||
CC="$CC -D_WIN32_WINNT=0x0400"; CXX="$CXX -D_WIN32_WINNT=0x0400"
|
||||
make UPX_XTARGET=x86_64-w64-mingw32-clang xtarget/debug xtarget/release
|
||||
- name: 'Make artifact'
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-${{ matrix.name }}-${{ matrix.llvm_version }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && cp -ai --parents */*/*/upx.exe "../tmp/artifact/$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
@@ -0,0 +1,130 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# CC CompilationCheck: test zigcc
|
||||
|
||||
# build with "zig cc"; see https://ziglang.org/download/
|
||||
|
||||
name: 'Weekly CI CC - zigcc'
|
||||
on:
|
||||
schedule: [cron: '40 2 * * 3'] # run weekly Wednesday 02:40 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
# 2023-11-01
|
||||
ZIG_DIST_VERSION: 0.12.0-dev.1369+a09ba455c
|
||||
|
||||
jobs:
|
||||
job-linux-zigcc: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# zig BUG: -fPIE is currently broken
|
||||
- { zig_target: aarch64-linux-musl }
|
||||
# { zig_target: aarch64-linux-musl, zig_pic: -fPIE }
|
||||
- { zig_target: aarch64-macos-none }
|
||||
- { zig_target: aarch64-macos.11.0-none }
|
||||
- { zig_target: aarch64-macos.12.0-none }
|
||||
- { zig_target: aarch64-macos.13.0-none }
|
||||
- { zig_target: aarch64-windows-gnu }
|
||||
- { zig_target: arm-linux-musleabihf }
|
||||
# { zig_target: arm-linux-musleabihf, zig_pic: -fPIE }
|
||||
- { zig_target: i386-linux-musl }
|
||||
# { zig_target: i386-linux-musl, zig_pic: -fPIE }
|
||||
- { zig_target: i386-windows-gnu }
|
||||
- { zig_target: mips-linux-musl }
|
||||
- { zig_target: mipsel-linux-musl }
|
||||
- { zig_target: powerpc-linux-musl }
|
||||
- { zig_target: powerpc64-linux-musl }
|
||||
- { zig_target: powerpc64le-linux-musl }
|
||||
- { zig_target: x86_64-linux-musl }
|
||||
# { zig_target: x86_64-linux-musl, zig_pic: -fPIE }
|
||||
- { zig_target: x86_64-macos-none }
|
||||
- { zig_target: x86_64-macos.11.0-none }
|
||||
- { zig_target: x86_64-macos.12.0-none }
|
||||
- { zig_target: x86_64-macos.13.0-none }
|
||||
- { zig_target: x86_64-windows-gnu }
|
||||
name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: 'alpine:3.18' # older versions such as alpine:3.12 also work; no-container also works
|
||||
env:
|
||||
# for zig-cc wrapper scripts (see below):
|
||||
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING
|
||||
ZIG_FLAGS: ${{ matrix.zig_flags }}
|
||||
ZIG_PIC: ${{ matrix.zig_pic }}
|
||||
ZIG_TARGET: ${{ matrix.zig_target }}
|
||||
steps:
|
||||
- name: 'Install Alpine Linux container packages'
|
||||
if: ${{ job.container }}
|
||||
shell: sh
|
||||
run: |
|
||||
apk update && apk upgrade && apk add bash cmake file git make tar xz
|
||||
# set PATH like in Ubuntu
|
||||
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: ${{ format('Install Zig {0}', env.ZIG_DIST_VERSION) }}
|
||||
shell: bash
|
||||
run: |
|
||||
# GitHub Actions magic: set "UPX_GITREV_SHORT" environment value for use in steps below
|
||||
rev=$(git rev-parse --short=7 HEAD)
|
||||
echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV
|
||||
# update ZIG_TARGET (i386 => x86)
|
||||
ZIG_TARGET=${ZIG_TARGET/i386-/x86-}
|
||||
echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV
|
||||
# install zig; note that ~/.local/bin is included in the default $PATH on Ubuntu
|
||||
mkdir -p -v ~/.local/bin
|
||||
cd ~/.local/bin
|
||||
ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION}
|
||||
wget -q https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz
|
||||
ls -l ${ZIG_DIST_NAME}.tar.xz
|
||||
tar -xoJf ${ZIG_DIST_NAME}.tar.xz
|
||||
rm ${ZIG_DIST_NAME}.tar.xz
|
||||
ln -s -v ${ZIG_DIST_NAME}/zig zig
|
||||
#echo "PATH=$PATH" && which zig
|
||||
echo -n 'zig version: '; zig version
|
||||
# create wrapper scripts (needed for CMake)
|
||||
echo -e '#!/bin/sh\nexec zig ar "$@"' > zig-ar
|
||||
echo -e '#!/bin/sh\nexec zig cc -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CFLAGS "$@"' > zig-cc
|
||||
echo -e '#!/bin/sh\nexec zig c++ -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CXXFLAGS "$@"' > zig-cxx
|
||||
echo -e '#!/bin/sh\nexec zig ranlib "$@"' > zig-ranlib
|
||||
chmod +x zig-ar zig-cc zig-cxx zig-ranlib
|
||||
ls -la; head zig-ar zig-cc zig-cxx zig-ranlib
|
||||
- name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }}
|
||||
run: |
|
||||
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/release
|
||||
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release
|
||||
cmake ../../../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_RELEASE
|
||||
cmake --build . --config Release --parallel --verbose
|
||||
file ./upx*
|
||||
- name: ${{ format('Build Debug with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }}
|
||||
run: |
|
||||
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/debug
|
||||
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug
|
||||
cmake ../../../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_DEBUG
|
||||
cmake --build . --config Debug --parallel --verbose
|
||||
file ./upx*
|
||||
- name: ${{ format('Make artifact from upx-{0}-{1}', github.ref_name, env.UPX_GITREV_SHORT) }}
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-zigcc-${{ matrix.zig_target }}${ZIG_PIC}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
|
||||
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run install tests'
|
||||
if: ${{ contains(matrix.zig_target, '-linux') }}
|
||||
run: |
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-make make install)
|
||||
@@ -0,0 +1,108 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# RT RunTime checks
|
||||
|
||||
# runs ASAN, MSAN, qemu and valgrind checkers; slow!
|
||||
|
||||
name: 'Weekly CI RT - ASAN MSAN Valgrind'
|
||||
on:
|
||||
schedule: [cron: '00 3 * * 3'] # run weekly Wednesday 03:00 UTC
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CMAKE_REQUIRED_QUIET: "OFF"
|
||||
CTEST_OUTPUT_ON_FAILURE: "ON"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
jobs:
|
||||
job-runtime-checkers: # uses cmake + make
|
||||
if: github.repository_owner == 'upx'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { container: 'alpine:3.18', release: debug, qemu: 'qemu-x86_64 -cpu Westmere' }
|
||||
- { container: 'alpine:3.18', release: release, qemu: 'qemu-x86_64 -cpu Westmere' }
|
||||
- { container: 'alpine:edge', release: release, qemu: 'qemu-x86_64 -cpu Westmere' }
|
||||
- { container: 'i386/alpine:edge', release: release, qemu: 'qemu-i386' }
|
||||
name: ${{ format('{0} {1}', matrix.container, matrix.release) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
env:
|
||||
release: ${{ matrix.release }}
|
||||
steps:
|
||||
- name: ${{ format('Install packages {0} {1}', matrix.container, matrix.release) }}
|
||||
run: |
|
||||
apk update && apk upgrade
|
||||
apk add bash clang cmake compiler-rt coreutils g++ git make qemu-i386 qemu-x86_64 tar valgrind
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
- name: ${{ format('Check out UPX {0} source code', github.ref_name) }}
|
||||
run: |
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
|
||||
git submodule update --init
|
||||
git clone --depth=1 https://github.com/upx/upx-testsuite ../upx-testsuite
|
||||
|
||||
- name: 'Build clang-static'
|
||||
run: |
|
||||
export CC="clang -static" CXX="clang++ -static"
|
||||
make UPX_XTARGET=clang-static xtarget/$release
|
||||
- name: 'Build clang-asan'
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: ASAN not supported
|
||||
run: |
|
||||
# unfortunately ASAN does not support static linking
|
||||
flags="-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fno-omit-frame-pointer"
|
||||
export CC="clang $flags" CXX="clang++ $flags"
|
||||
make UPX_XTARGET=clang-asan xtarget/$release
|
||||
- name: 'Build clang-msan'
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: MSAN not supported
|
||||
run: |
|
||||
# unfortunately MSAN does not support static linking
|
||||
flags="-fsanitize=memory -fsanitize=undefined -fno-omit-frame-pointer -DDOCTEST_CONFIG_DISABLE=1"
|
||||
export CC="clang $flags" CXX="clang++ $flags"
|
||||
make UPX_XTARGET=clang-msan xtarget/$release
|
||||
|
||||
- name: 'Make artifact'
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-runtime-checkers-${{ matrix.container }}-${{ matrix.release }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && cp -ai --parents */*/*/upx "../tmp/artifact/$N")
|
||||
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
|
||||
# GitHub Actions magic: set "artifact_name" environment value for use in next step
|
||||
echo "artifact_name=$N" >> $GITHUB_ENV
|
||||
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: missing nodejs on host
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
|
||||
- name: 'Run basic tests clang-static'
|
||||
run: 'make -C build/xtarget/clang-static/$release test'
|
||||
- name: 'Run basic tests clang-asan'
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: ASAN not supported
|
||||
run: 'make -C build/xtarget/clang-asan/$release test'
|
||||
- name: 'Run basic tests clang-msan'
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: MSAN not supported
|
||||
run: 'make -C build/xtarget/clang-msan/$release test'
|
||||
|
||||
- name: 'Run testsuite clang-asan'
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: ASAN not supported
|
||||
run: |
|
||||
export ASAN_OPTIONS="detect_invalid_pointer_pairs=2"
|
||||
env -C build/xtarget/clang-asan/$release "$PWD"/misc/testsuite/upx_testsuite_1.sh
|
||||
- name: 'Run testsuite clang-msan'
|
||||
if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: MSAN not supported
|
||||
run: |
|
||||
env -C build/xtarget/clang-msan/$release "$PWD"/misc/testsuite/upx_testsuite_1.sh
|
||||
- name: 'Run testsuite clang-static - QEMU'
|
||||
if: ${{ matrix.qemu }}
|
||||
run: |
|
||||
export upx_exe_runner="${{ matrix.qemu }}"
|
||||
env -C build/xtarget/clang-static/$release "$PWD"/misc/testsuite/upx_testsuite_1.sh
|
||||
- name: 'Run testsuite clang-static - Valgrind'
|
||||
if: true # very slow
|
||||
run: |
|
||||
export upx_exe_runner="valgrind --error-exitcode=1 --quiet"
|
||||
# on current GitHub CI, takes about 30 minutes for release and 80 minutes for debug builds
|
||||
# reduce time for debug builds to about 30 minutes
|
||||
test "$release" = "debug" && export UPX_TESTSUITE_LEVEL=4
|
||||
env -C build/xtarget/clang-static/$release "$PWD"/misc/testsuite/upx_testsuite_1.sh
|
||||
+24
-28
@@ -1,58 +1,54 @@
|
||||
/.bzr*
|
||||
/.hg*
|
||||
/.vscode*
|
||||
/Makevars.global*
|
||||
/Testing*
|
||||
/build*
|
||||
/maint*
|
||||
/vendor*
|
||||
|
||||
.depend
|
||||
GNUmakefile
|
||||
MMakefile
|
||||
GNUmakefile*
|
||||
MMakefile*
|
||||
Makevars.local*
|
||||
tmp-testsuite*
|
||||
compile_flags*.txt
|
||||
Tmp*
|
||||
tmp*
|
||||
|
||||
*.a
|
||||
*.bz2
|
||||
*.d
|
||||
*.dll
|
||||
*.dylib
|
||||
*.exe
|
||||
*.gz
|
||||
*.lib
|
||||
*.map
|
||||
*.o
|
||||
*.obj
|
||||
*.out
|
||||
*.patch
|
||||
*.py[cdo]
|
||||
*.rar
|
||||
*.so
|
||||
*.swp
|
||||
*.tmp
|
||||
*.ttp
|
||||
*.xz
|
||||
*.zip
|
||||
*.zst
|
||||
|
||||
doc/*.1
|
||||
doc/*.doc
|
||||
doc/*.html
|
||||
doc/*.man
|
||||
doc/*.ps
|
||||
doc/*.tex
|
||||
|
||||
src/compress_nrv*
|
||||
src/*.mft
|
||||
src/*.rc
|
||||
|
||||
src/*.d
|
||||
src/*.exe
|
||||
src/*.map
|
||||
src/*.o
|
||||
src/*.obj
|
||||
src/*.out
|
||||
src/*.res
|
||||
src/*.ttp
|
||||
|
||||
src/stub/**/.*-stamp
|
||||
src/stub/**/MMakefile
|
||||
src/stub/tmp*/*.bin
|
||||
src/stub/tmp*/*.bin.bindump
|
||||
src/stub/tmp*/*.bin.disasm
|
||||
src/stub/tmp*/*.d
|
||||
src/stub/tmp*/*.map
|
||||
src/stub/tmp*/*.o
|
||||
src/stub/tmp*/*.o.disasm
|
||||
src/stub/tmp*/mips.r3000-*.[is]
|
||||
src/stub/tmp*/mipsel.r3000-*.[is]
|
||||
src/stub/src/**/tmp*/*
|
||||
|
||||
src/stub/tools/armpe/armpe_tester.exe
|
||||
src/stub/tools/armpe/armpe_tester.out
|
||||
|
||||
src/stub/tools/sstrip/amd64-linux-sstrip
|
||||
src/stub/tools/sstrip/i386-linux-sstrip
|
||||
src/stub/tools/sstrip/sstrip
|
||||
|
||||
-295
@@ -1,295 +0,0 @@
|
||||
# Support for GibLab CI -- https://gitlab.com/
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
before_script:
|
||||
- export TRAVIS_OS_NAME=linux
|
||||
- unset CROSS C B T X
|
||||
- uname -a; pwd; id; umask
|
||||
- cat /etc/os-release || true
|
||||
- |
|
||||
if [[ $CI_BUILD_NAME =~ ^(CentOS|Fedora|OpenSUSE) ]]; then
|
||||
time rpm -qa | LC_ALL=C sort
|
||||
fi
|
||||
- |
|
||||
if [[ $CI_BUILD_NAME =~ ^(Debian|Ubuntu) ]]; then
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
time dpkg -l
|
||||
if [[ $CI_BUILD_NAME =~ ^Ubuntu1604- ]]; then
|
||||
dpkg --add-architecture i386
|
||||
fi;
|
||||
time apt-get -yq update
|
||||
fi
|
||||
-
|
||||
if [[ $CI_BUILD_NAME =~ ^CentOS5- ]]; then
|
||||
time rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm;
|
||||
time yum install -y
|
||||
coreutils curl diffutils grep gzip sed
|
||||
bzip2 file findutils git openssh-clients openssl perl tar wget which xz
|
||||
gcc gcc-c++ make valgrind
|
||||
glibc-devel libstdc++-devel zlib-devel
|
||||
glibc-devel.i386 libstdc++-devel.i386 zlib-devel.i386;
|
||||
fi
|
||||
-
|
||||
if [[ $CI_BUILD_NAME =~ ^CentOS6- ]]; then
|
||||
time yum install -y
|
||||
coreutils curl diffutils grep gzip sed
|
||||
bzip2 file findutils git openssh-clients openssl perl tar wget which xz
|
||||
gcc gcc-c++ make valgrind
|
||||
glibc-devel libstdc++-devel zlib-devel
|
||||
glibc-devel.i686 libstdc++-devel.i686 zlib-devel.i686;
|
||||
fi
|
||||
-
|
||||
if [[ $CI_BUILD_NAME =~ ^CentOS7- ]]; then
|
||||
time yum install -y
|
||||
coreutils curl diffutils grep gzip sed
|
||||
bzip2 file findutils git openssh-clients openssl perl tar wget which xz
|
||||
clang gcc gcc-c++ make valgrind
|
||||
glibc-devel libasan libstdc++-devel zlib-devel
|
||||
glibc-devel.i686 libasan.i686 libstdc++-devel.i686 zlib-devel.i686;
|
||||
fi
|
||||
-
|
||||
if [[ $CI_BUILD_NAME =~ ^Fedora ]]; then
|
||||
time dnf install -y --best --allowerasing
|
||||
coreutils curl diffutils grep gzip sed
|
||||
bzip2 file findutils git openssh-clients openssl perl tar wget which xz
|
||||
clang gcc gcc-c++ lcov make valgrind
|
||||
glibc-devel libasan libstdc++-devel libubsan zlib-devel
|
||||
glibc-devel.i686 libasan.i686 libstdc++-devel.i686 libubsan.i686 zlib-devel.i686;
|
||||
fi
|
||||
-
|
||||
if [[ $CI_BUILD_NAME =~ ^OpenSUSE42.2- ]]; then
|
||||
time zypper update -y;
|
||||
time zypper install -y
|
||||
coreutils curl diffutils grep gzip sed
|
||||
bzip2 file findutils git openssh openssl perl tar wget which xz
|
||||
llvm-clang gcc gcc-32bit gcc-c++ gcc-c++-32bit lcov make valgrind
|
||||
glibc-devel libstdc++-devel libz1 zlib-devel
|
||||
glibc-devel-32bit libstdc++-devel-32bit libz1-32bit zlib-devel-32bit;
|
||||
fi
|
||||
-
|
||||
if [[ $CI_BUILD_NAME =~ ^(Debian|Ubuntu) ]]; then
|
||||
time apt-get -yq --no-install-suggests --no-install-recommends --force-yes upgrade;
|
||||
time apt-get -yq --no-install-suggests --no-install-recommends --force-yes install
|
||||
build-essential ca-certificates curl file git openssh-client openssl wget xz-utils zlib1g-dev;
|
||||
fi
|
||||
-
|
||||
if [[ $CI_BUILD_NAME =~ ^Ubuntu1604- ]]; then
|
||||
time apt-get -yq --no-install-suggests --no-install-recommends --force-yes install
|
||||
g++-multilib
|
||||
libstdc++-5-dev:i386 zlib1g-dev:i386
|
||||
libx32stdc++-5-dev libx32z1-dev;
|
||||
fi
|
||||
-
|
||||
if [[ $CI_BUILD_NAME =~ ^Ubuntu1604-cross ]]; then
|
||||
time apt-get -yq --no-install-suggests --no-install-recommends --force-yes install
|
||||
crossbuild-essential-arm64 crossbuild-essential-armel crossbuild-essential-armhf
|
||||
crossbuild-essential-powerpc crossbuild-essential-ppc64el crossbuild-essential-s390x
|
||||
binutils-mingw-w64-i686 g++-mingw-w64-i686
|
||||
binutils-mingw-w64-x86-64 g++-mingw-w64-x86-64
|
||||
binutils-mips-linux-gnu g++-mips-linux-gnu
|
||||
binutils-mipsel-linux-gnu g++-mipsel-linux-gnu
|
||||
binutils-powerpc-linux-gnu g++-powerpc-linux-gnu
|
||||
binutils-powerpc64-linux-gnu g++-powerpc64-linux-gnu
|
||||
qemu-user qemu-utils wine;
|
||||
fi
|
||||
- git --version && bash --version
|
||||
- umask 022; mkdir -p ../deps ../build/gitlab
|
||||
- time git submodule update --init --recursive
|
||||
- cd ../deps && time wget -q -O - https://github.com/upx/upx/releases/download/v3.00/ucl-1.03.tar.xz | tar -x --use-compress-program=xz
|
||||
- cd ../deps && time wget -q -O - https://github.com/upx/upx/releases/download/v3.00/zlib-1.2.8.tar.xz | tar -x --use-compress-program=xz
|
||||
- cd ../deps && time git clone https://github.com/upx/upx-testsuite
|
||||
- |
|
||||
if [[ $CI_BUILD_NAME =~ ^Fedora ]]; then
|
||||
time dnf install -y --best --allowerasing python
|
||||
cd ../deps && time wget -q -O - https://github.com/upx/upx-stubtools/releases/download/v20160918/bin-upx-20160918.tar.xz | tar -x --use-compress-program=xz
|
||||
fi
|
||||
- cd $CI_PROJECT_DIR; pwd
|
||||
|
||||
CentOS5-gcc-m32+m64: # gcc-4.1
|
||||
image: centos:5
|
||||
script:
|
||||
# patch src/Makefile for gcc-4.1
|
||||
- perl -i -p -e 's/ -Wmissing-declarations / /; s/ -Wvla / /;' src/Makefile
|
||||
- time C=gcc-m32 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
CentOS6-gcc-m32+m64: # gcc-4.4
|
||||
image: centos:6
|
||||
script:
|
||||
- time C=gcc-m32 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
CentOS7-clang+gcc-m32+m64: # clang-3.4, gcc-4.8
|
||||
image: centos:7
|
||||
script:
|
||||
- time C=clang-m32 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_build.sh
|
||||
- time C=clang-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_build.sh
|
||||
- time C=clang-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=clang-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Debian7-gcc-m64: # gcc-4.7
|
||||
image: debian:7
|
||||
script:
|
||||
- time C=gcc-4.7-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-4.7-m64 bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Debian8-gcc-m64: # gcc-4.9
|
||||
image: debian:8
|
||||
script:
|
||||
- time C=gcc-4.9-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-4.9-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-4.9-m64 bash ./.github/travis_deploy.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Fedora23-clang+gcc-m32+m64: # clang-3.7, gcc-5
|
||||
image: fedora:23
|
||||
script:
|
||||
- time X=rebuild-stubs bash ./.github/travis_build.sh
|
||||
- time C=clang-m32 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_build.sh
|
||||
- time C=clang-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 B=sanitize bash ./.github/travis_build.sh
|
||||
- time C=clang-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=clang-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 B=sanitize bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 T=valgrind bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Fedora24-clang+gcc-m32+m64: # clang-3.8, gcc-6
|
||||
image: fedora:24
|
||||
script:
|
||||
- time X=rebuild-stubs bash ./.github/travis_build.sh
|
||||
- time C=clang-m32 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_build.sh
|
||||
- time C=clang-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 B=sanitize bash ./.github/travis_build.sh
|
||||
- time C=clang-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=clang-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 B=sanitize bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 T=valgrind bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Fedora25-clang+gcc-m32+m64: # clang-3.8, gcc-6
|
||||
image: fedora:25
|
||||
script:
|
||||
- time X=rebuild-stubs bash ./.github/travis_build.sh
|
||||
- time C=clang-m32 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_build.sh
|
||||
- time C=clang-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-m64 B=sanitize bash ./.github/travis_build.sh
|
||||
- time C=clang-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=clang-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 B=sanitize bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-m64 T=valgrind bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
OpenSUSE42.2-clang+gcc-m32+m64: # clang-3.8, gcc-4.8
|
||||
image: opensuse:42.2
|
||||
script:
|
||||
- time C=clang-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-4.8-m32 bash ./.github/travis_build.sh
|
||||
- time C=gcc-4.8-m64 bash ./.github/travis_build.sh
|
||||
- time C=clang-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-4.8-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-4.8-m64 bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Ubuntu1204-gcc-m64: # gcc-4.6
|
||||
image: ubuntu:12.04
|
||||
script:
|
||||
- time C=gcc-4.6-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-4.6-m64 bash ./.github/travis_testsuite_1.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Ubuntu1404-gcc-m64: # gcc-4.8
|
||||
image: ubuntu:14.04
|
||||
script:
|
||||
- time C=gcc-4.8-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-4.8-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-4.8-m64 bash ./.github/travis_deploy.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Ubuntu1604-gcc-m32+m64: # gcc-5
|
||||
image: ubuntu:16.04
|
||||
script:
|
||||
- time C=gcc-5-m32 bash ./.github/travis_build.sh
|
||||
- time C=gcc-5-m64 bash ./.github/travis_build.sh
|
||||
- time C=gcc-5-m32 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-5-m64 bash ./.github/travis_testsuite_1.sh
|
||||
- time C=gcc-5-m32 bash ./.github/travis_deploy.sh
|
||||
- time C=gcc-5-m64 bash ./.github/travis_deploy.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
Ubuntu1604-cross: # gcc-5
|
||||
image: ubuntu:16.04
|
||||
script:
|
||||
- time CROSS=aarch64-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=arm-linux-gnueabi C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=arm-linux-gnueabihf C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=i686-w64-mingw32 C=gcc-5 T=wine bash ./.github/travis_build.sh
|
||||
- time CROSS=mips-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=mipsel-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=powerpc-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=powerpc64-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=powerpc64le-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=s390x-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_build.sh
|
||||
- time CROSS=x86_64-w64-mingw32 C=gcc-5 T=wine bash ./.github/travis_build.sh
|
||||
- time CROSS=aarch64-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
- time CROSS=arm-linux-gnueabi C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
- time CROSS=arm-linux-gnueabihf C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
# - time CROSS=i686-w64-mingw32 C=gcc-5 T=wine bash ./.github/travis_testsuite_1.sh
|
||||
# - time CROSS=mips-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
- time CROSS=mipsel-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
# - time CROSS=powerpc-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
# - time CROSS=powerpc64-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
# - time CROSS=powerpc64le-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
# - time CROSS=s390x-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_testsuite_1.sh
|
||||
# - time CROSS=x86_64-w64-mingw32 C=gcc-5 T=wine bash ./.github/travis_testsuite_1.sh
|
||||
- time CROSS=aarch64-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=arm-linux-gnueabi C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=arm-linux-gnueabihf C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=i686-w64-mingw32 C=gcc-5 T=wine bash ./.github/travis_deploy.sh
|
||||
- time CROSS=mips-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=mipsel-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=powerpc-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=powerpc64-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=powerpc64le-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=s390x-linux-gnu C=gcc-5 T=qemu bash ./.github/travis_deploy.sh
|
||||
- time CROSS=x86_64-w64-mingw32 C=gcc-5 T=wine bash ./.github/travis_deploy.sh
|
||||
tags: [ shared ]
|
||||
except: [ tags ]
|
||||
|
||||
# vim:set ts=2 sw=2 et:
|
||||
+25
-4
@@ -1,4 +1,25 @@
|
||||
[submodule "src/lzma-sdk"]
|
||||
path = src/lzma-sdk
|
||||
url = https://github.com/upx/upx-lzma-sdk.git
|
||||
branch = master
|
||||
[submodule "vendor/doctest"]
|
||||
path = vendor/doctest
|
||||
url = https://github.com/upx/upx-vendor-doctest.git
|
||||
branch = upx-vendor
|
||||
shallow = true
|
||||
[submodule "vendor/lzma-sdk"]
|
||||
path = vendor/lzma-sdk
|
||||
url = https://github.com/upx/upx-vendor-lzma-sdk.git
|
||||
branch = upx-vendor
|
||||
shallow = true
|
||||
[submodule "vendor/ucl"]
|
||||
path = vendor/ucl
|
||||
url = https://github.com/upx/upx-vendor-ucl.git
|
||||
branch = upx-vendor
|
||||
shallow = true
|
||||
[submodule "vendor/valgrind"]
|
||||
path = vendor/valgrind
|
||||
url = https://github.com/upx/upx-vendor-valgrind.git
|
||||
branch = upx-vendor
|
||||
shallow = true
|
||||
[submodule "vendor/zlib"]
|
||||
path = vendor/zlib
|
||||
url = https://github.com/upx/upx-vendor-zlib.git
|
||||
branch = upx-vendor
|
||||
shallow = true
|
||||
|
||||
-258
@@ -1,258 +0,0 @@
|
||||
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
sudo: false
|
||||
language: cpp
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
on_failure: change
|
||||
|
||||
.ubuntu_toolchain_sources: &S
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
- llvm-toolchain-precise-3.6
|
||||
- llvm-toolchain-precise-3.7
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
env:
|
||||
global:
|
||||
- CROSS= C= B= T= X=
|
||||
- secure: "YXHLXK+CM5d8yELIUSSs+P0/CoefClO7/AUX1oBj5W75g+YzR5uS2doVsB8UH8S8/GdNxk4P9Jgn4EiEVnjfGgn2eAD9MVpDPIxyJs5vI+5G77asq3QNdSl6QFv3O9I/6yBoVCewgPFPqsMd7Yvs/Ea3LcQkqalVhrC8ybYtmfs6VL2w33gn2J3b3TCn/s21L0ijklM0xvP1GNMDtuUpTSish5wvGOHE/91rwtdUDbJR8u31QY7fTASDiNnL/7ihgEIZ5XxpDYXviX1GC+nemhX1fWpmVmuT8m30Ruodi0yJVGASw9i2SaKv/VX/fJ/w2vlCfspL5LMZKkVLlfpIo3mQGqmMHFxv7mNy+hRu50ptoWNSkWArcqifwveh2liHUpl4jTvWaVll5Tw5VUGJhAUdzCTnqLIbWFnKIgCedL3iRFi4+EbyWNxel8lFESMOTDZFfJG5yEiDJbgbLsUaT2GmrsOphwAG7zDcZzvYTdjg/lF4Wh0MUnQJ+0MhDpii8Ahjp49lAPdw8uRQyyY7d7ksYKXVIkbgl6dRCC5vZSPucJiFjq2BClqIoEmzZPvHveDbovzFkNhJX9tFLrHLcXbPPcegww1FGoQ3wBM6JwJ+TvSD6N4OdCmou05aDuuQeznHi3GxOScjGwxdMIU28fdJDCTDg2rOihm22kHVajo="
|
||||
- secure: "JpSv3+QRmHcfN/bmT3mVkqET44NCPhM/qpcUssCVXnd2GW0qWURoyPHzVMn/gbeAkUjR6djtN3OzJ+M181QmlmTmE26pZC9Q6r1buNDWdkIH1FcpMCa67BBAjmq+yDwulDtvCMv0lbz60v57lzHBOLczF3yMxBVTjXxt1RsrzDLHzzVaDR5lEe+sQUNeRL7Vaq8crimPNTr4ZhMe59eweTO/3AWovuSPf250k1flfv7I8audZgrVZdbVKvj5C3Sziy1AGXcu8mDfET9/Ya2XBCQHWODjiKlnhSxqthhP3gQuacaLjpS2FjvQlamd+I9x6BBoLSeNbiXD9vgCydDUKvmUrU+zQs64U1hHk9WZWVC19kG7lTtTdanGDIUlIUtFZgqE4AQpJaIUWkUmHGyHi61JMvduzX21eL5c5j9DoJteX42FPb1n3xK/JSnUkLMpbFdQuy5inhzefhDfeNzaYxt8nPwHnJqrF73SW4PLDKeRyzvg/P+zqcou8nXrHfA1z9/FlnYzf7Qc9meai9Q/JARX3Q1ZKu5uyG+RuBLe2POq0192w6pflTr1ZlLJsKNSc1147PviKfmpla1lg3/6uVzMp5tgwbve/hx9SDXiRueGttKw/ymsY662+8G24NRKo4fxNklWFHaB4owM84edDzXDckPXbPgue8/HQT8BFio="
|
||||
matrix:
|
||||
- TRAVIS_EMPTY_JOB_WORKAROUND=true
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
exclude:
|
||||
- env: TRAVIS_EMPTY_JOB_WORKAROUND=true
|
||||
include:
|
||||
- os: linux
|
||||
sudo: required
|
||||
dist: trusty
|
||||
compiler: gcc
|
||||
env: X=rebuild-stubs
|
||||
addons: { apt: { packages: [ "g++-multilib", "lib32z1" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.4-m32
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.4-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.4-m64
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.4" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.5-m32
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.5-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.5-m64
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.5" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.6-m32
|
||||
addons: { apt: { packages: [ "g++-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.6-m64
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.7-m32
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.7-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.7-m64
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.7" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.8-m32
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.8-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.8-m64
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.8" ] } }
|
||||
# - os: linux
|
||||
# sudo: required
|
||||
# dist: trusty
|
||||
# compiler: gcc
|
||||
# env: C=gcc-4.8-mx32
|
||||
# addons: { apt: { packages: [ "g++-multilib", "libx32stdc++-4.8-dev", "libx32z1-dev" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.9-m32
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.9-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-4.9-m64
|
||||
addons: { apt: { sources: *S, packages: [ "g++-4.9" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-5-m32
|
||||
addons: { apt: { sources: *S, packages: [ "g++-5-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-5-m64
|
||||
addons: { apt: { sources: *S, packages: [ "g++-5" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-6-m32
|
||||
addons: { apt: { sources: *S, packages: [ "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-6-m64
|
||||
addons: { apt: { sources: *S, packages: [ "g++-6" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-6-m32 B=debug
|
||||
addons: { apt: { sources: *S, packages: [ "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-6-m64 B=debug
|
||||
addons: { apt: { sources: *S, packages: [ "g++-6" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-6-m64 B=debug+sanitize
|
||||
addons: { apt: { sources: *S, packages: [ "g++-6" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-6-m64 B=sanitize
|
||||
addons: { apt: { sources: *S, packages: [ "g++-6" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: C=gcc-6-m64 B=valgrind T=valgrind
|
||||
addons: { apt: { sources: *S, packages: [ "g++-6", valgrind ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.4-m32
|
||||
addons: { apt: { packages: [ "g++-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.4-m64
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.5-m32
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.5", "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.5-m64
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.5" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.6-m32
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.6", "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.6-m64
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.6" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.7-m32
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.7", "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.7-m64
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.7" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.8-m32
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.8", "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.8-m64
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.8" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.8-m64 B=debug+sanitize
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.8" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.8-m64 B=sanitize
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.8" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.8-m64 B=debug+scan-build
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.8" ] } }
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: C=clang-3.8-m64 B=scan-build
|
||||
addons: { apt: { sources: *S, packages: [ "clang-3.8" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: CROSS=arm-linux-gnueabi C=gcc-4.6 T=SKIP
|
||||
addons: { apt: { packages: [ "g++-arm-linux-gnueabi", "qemu-user" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: CROSS=arm-linux-gnueabihf C=gcc-4.6 T=SKIP
|
||||
addons: { apt: { packages: [ "g++-arm-linux-gnueabihf", "qemu-user" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: CROSS=i386-w64-mingw32 C=gcc-4.6 T=wine
|
||||
addons: { apt: { packages: [ "binutils-mingw-w64-i686", "g++-mingw-w64-i686", "wine" ] } }
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: CROSS=x86_64-w64-mingw32 C=gcc-4.6 T=wine
|
||||
addons: { apt: { packages: [ "binutils-mingw-w64-x86-64", "g++-mingw-w64-x86-64", "wine" ] } }
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
compiler: clang
|
||||
# must use debug build or else we get "ld: internal error: atom not found" when linking
|
||||
env: C=clang-602-m32 B=debug
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
compiler: clang
|
||||
# must use debug build or else we get "ld: internal error: atom not found" when linking
|
||||
env: C=clang-602-m64 B=debug
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
compiler: clang
|
||||
env: C=clang-703-m32
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
compiler: clang
|
||||
env: C=clang-703-m64
|
||||
- os: osx
|
||||
osx_image: xcode8.2
|
||||
compiler: clang
|
||||
env: C=clang-800-m32
|
||||
- os: osx
|
||||
osx_image: xcode8.2
|
||||
compiler: clang
|
||||
env: C=clang-800-m64
|
||||
|
||||
install:
|
||||
- uname -a; pwd; id; umask
|
||||
- cat /etc/os-release || true
|
||||
- |
|
||||
cd /
|
||||
if [[ $TRAVIS_OS_NAME == linux ]]; then
|
||||
if [[ $B =~ (^|\+)coverage($|\+) ]]; then
|
||||
travis_retry pip install --user cpp-coveralls
|
||||
fi
|
||||
fi
|
||||
if [[ $TRAVIS_OS_NAME == osx ]]; then
|
||||
if ! gsha256sum </bin/sh >/dev/null 2>/dev/null; then travis_retry brew install coreutils; fi
|
||||
if [[ $B =~ (^|\+)coverage($|\+) ]]; then
|
||||
travis_retry brew install lcov
|
||||
travis_retry pip install --user cpp-coveralls
|
||||
fi
|
||||
fi
|
||||
- git --version && bash --version
|
||||
- umask 022; cd $TRAVIS_BUILD_DIR && mkdir -p ../deps ../build/travis
|
||||
- cd ../deps && travis_retry wget -q -O - https://github.com/upx/upx/releases/download/v3.00/ucl-1.03.tar.xz | tar -xJ
|
||||
- cd ../deps && travis_retry wget -q -O - https://github.com/upx/upx/releases/download/v3.00/zlib-1.2.8.tar.xz | tar -xJ
|
||||
- cd ../deps && travis_retry git clone https://github.com/upx/upx-testsuite
|
||||
- |
|
||||
if [[ $X =~ (^|\+)rebuild-stubs($|\+) ]]; then
|
||||
cd ../deps && travis_retry wget -q -O - https://github.com/upx/upx-stubtools/releases/download/v20160918/bin-upx-20160918.tar.xz | tar -xJ
|
||||
fi
|
||||
|
||||
script:
|
||||
- cd $TRAVIS_BUILD_DIR && bash ./.github/travis_build.sh
|
||||
- cd $TRAVIS_BUILD_DIR && bash ./.github/travis_testsuite_1.sh
|
||||
after_success:
|
||||
- cd $TRAVIS_BUILD_DIR && bash ./.github/travis_deploy.sh
|
||||
|
||||
# vim:set ts=2 sw=2 et:
|
||||
+628
@@ -0,0 +1,628 @@
|
||||
#
|
||||
# UPX "CMake" build file; see https://cmake.org/
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
# Build requirements:
|
||||
# A C++ compiler that fully implements C++17: clang-5, gcc-8 or msvc-2019-16.11
|
||||
# (older or other compilers may work but are unsupported, use at your own risk)
|
||||
|
||||
# CMake version check; using a somewhat current CMake version is highly recommended
|
||||
if(DEFINED UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION)
|
||||
cmake_minimum_required(VERSION "${UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION}" FATAL_ERROR)
|
||||
else()
|
||||
cmake_minimum_required(VERSION "3.8" FATAL_ERROR) # CMake >= 3.8 is needed for CXX_STANDARD 17
|
||||
endif()
|
||||
|
||||
# Sections of this CMakeLists.txt:
|
||||
# - options
|
||||
# - init
|
||||
# - common compilation flags
|
||||
# - targets
|
||||
# - target compilation flags
|
||||
# - test
|
||||
# - install
|
||||
# - print summary
|
||||
|
||||
#***********************************************************************
|
||||
# options
|
||||
#***********************************************************************
|
||||
|
||||
# compilation config options
|
||||
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
# permissive config defaults when building from source code tarball
|
||||
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info." ON)
|
||||
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options." ON)
|
||||
option(UPX_CONFIG_DISABLE_WSTRICT "Do not compile with strict compiler warnings." ON)
|
||||
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option." ON)
|
||||
else()
|
||||
# strict config defaults for Git developer builds
|
||||
message(STATUS "===== UPX info: strict config defaults enabled")
|
||||
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info." OFF)
|
||||
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options." OFF)
|
||||
option(UPX_CONFIG_DISABLE_WSTRICT "Do not compile with strict compiler warnings." OFF)
|
||||
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option." OFF)
|
||||
endif()
|
||||
|
||||
# test config options (see below)
|
||||
# IMPORTANT NOTE: self-pack test can only work if the host executable format is supported by UPX!
|
||||
option(UPX_CONFIG_DISABLE_SELF_PACK_TEST "Do not test packing UPX with itself" OFF)
|
||||
|
||||
#***********************************************************************
|
||||
# init
|
||||
#***********************************************************************
|
||||
|
||||
# Disallow in-source builds. Note that you will still have to manually
|
||||
# clean up a few files if you accidentally try an in-source build.
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
||||
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
||||
if(",${CMAKE_CURRENT_SOURCE_DIR}," STREQUAL ",${CMAKE_CURRENT_BINARY_DIR},")
|
||||
message(FATAL_ERROR "ERROR: In-source builds are not allowed, please use an extra build dir.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# useful for CI jobs: allow settings via environment and cache result
|
||||
function(upx_cache_bool_vars)
|
||||
set(default_value "${ARGV0}")
|
||||
list(REMOVE_AT ARGV 0)
|
||||
foreach(var ${ARGV})
|
||||
set(value ${default_value})
|
||||
if(DEFINED UPX_CACHE_${var}) # cached
|
||||
set(value "${UPX_CACHE_${var}}")
|
||||
elseif(DEFINED ${var}) # defined via "cmake -DXXX=YYY"
|
||||
set(value "${${var}}")
|
||||
elseif("$ENV{${var}}" MATCHES "^(0|1|OFF|ON|FALSE|TRUE)$") # environment
|
||||
set(value "$ENV{${var}}")
|
||||
set(UPX_CACHE_ORIGIN_FROM_ENV_${var} TRUE CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
if(value)
|
||||
set(value ON)
|
||||
else()
|
||||
set(value OFF)
|
||||
endif()
|
||||
if(UPX_CACHE_ORIGIN_FROM_ENV_${var})
|
||||
message(STATUS "setting from environment: ${var} = ${value}")
|
||||
endif()
|
||||
set(${var} "${value}" PARENT_SCOPE)
|
||||
set(UPX_CACHE_${var} "${value}" CACHE INTERNAL "" FORCE)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# global settings
|
||||
if(${CMAKE_VERSION} VERSION_GREATER "3.14.7" AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
endif()
|
||||
# global CMake settings that default to ON
|
||||
upx_cache_bool_vars(ON
|
||||
CMAKE_C_STANDARD_REQUIRED CMAKE_CXX_STANDARD_REQUIRED
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS CMAKE_REQUIRED_QUIET
|
||||
)
|
||||
# internal UPX settings that default to OFF
|
||||
upx_cache_bool_vars(OFF
|
||||
UPX_CONFIG_CMAKE_DISABLE_TEST UPX_CONFIG_CMAKE_DISABLE_INSTALL
|
||||
UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK
|
||||
UPX_CONFIG_DISABLE_C_STANDARD UPX_CONFIG_DISABLE_CXX_STANDARD
|
||||
)
|
||||
|
||||
# determine Git revision
|
||||
set(GITREV_SHORT "")
|
||||
set(GITREV_PLUS "")
|
||||
set(GIT_DESCRIBE "")
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git" AND NOT UPX_CONFIG_DISABLE_GITREV)
|
||||
find_package(Git)
|
||||
if(Git_FOUND)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" rev-parse --short=12 HEAD
|
||||
RESULT_VARIABLE result ERROR_QUIET
|
||||
OUTPUT_VARIABLE GITREV_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string(LENGTH "${GITREV_SHORT}" l)
|
||||
if(${result} EQUAL 0 AND ${l} EQUAL 12)
|
||||
execute_process(RESULT_VARIABLE result COMMAND "${GIT_EXECUTABLE}" diff --quiet)
|
||||
if(NOT ${result} EQUAL 0)
|
||||
set(GITREV_PLUS "+")
|
||||
endif()
|
||||
else()
|
||||
set(GITREV_SHORT "")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --match "v*.*.*" --tags --dirty
|
||||
RESULT_VARIABLE result ERROR_QUIET
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-g(.+)$")
|
||||
set(GIT_DESCRIBE "${CMAKE_MATCH_1}-devel.${CMAKE_MATCH_2}+git-${CMAKE_MATCH_3}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(GITREV_SHORT)
|
||||
message(STATUS "UPX_VERSION_GITREV = \"${GITREV_SHORT}${GITREV_PLUS}\"")
|
||||
if(GIT_DESCRIBE)
|
||||
message(STATUS "UPX_VERSION_GIT_DESCRIBE = \"${GIT_DESCRIBE}\"")
|
||||
endif()
|
||||
elseif(UPX_CONFIG_DISABLE_GITREV)
|
||||
message(STATUS "UPX_VERSION_GITREV: disabled")
|
||||
else()
|
||||
message(STATUS "UPX_VERSION_GITREV: not set")
|
||||
endif()
|
||||
|
||||
# set the default build type to "Release"
|
||||
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT is_multi_config AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
|
||||
endif()
|
||||
|
||||
# CMake init
|
||||
project(upx VERSION 4.2.1 LANGUAGES C CXX)
|
||||
|
||||
# set the default multi-config build type to "Release"
|
||||
if(is_multi_config)
|
||||
set(c "${CMAKE_CONFIGURATION_TYPES}")
|
||||
list(INSERT c 0 "Release")
|
||||
list(INSERT c 1 "Debug")
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
list(INSERT c 0 "${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
list(REMOVE_DUPLICATES c)
|
||||
set(CMAKE_CONFIGURATION_TYPES "${c}" CACHE STRING "List of supported configuration types." FORCE)
|
||||
endif()
|
||||
|
||||
# set MSVC_FRONTEND and MINGW
|
||||
if(NOT DEFINED MSVC_FRONTEND AND (MSVC OR CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC"))
|
||||
set(MSVC_FRONTEND 1)
|
||||
endif()
|
||||
if(NOT DEFINED MINGW AND CMAKE_C_PLATFORM_ID MATCHES "^MinGW")
|
||||
set(MINGW 1)
|
||||
endif()
|
||||
|
||||
#***********************************************************************
|
||||
# common compilation flags
|
||||
#***********************************************************************
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckStructHasMember)
|
||||
include(CheckSymbolExists)
|
||||
|
||||
if(NOT DEFINED HAVE_UNISTD_H)
|
||||
check_include_file("unistd.h" HAVE_UNISTD_H)
|
||||
endif()
|
||||
if(NOT DEFINED HAVE_UTIMENSAT)
|
||||
# proper checking for utimensat() is somewhat messy
|
||||
check_function_exists(utimensat HAVE_UTIMENSAT_FUNCTION__)
|
||||
if(HAVE_UTIMENSAT_FUNCTION__)
|
||||
check_symbol_exists(utimensat "sys/types.h;fcntl.h;sys/stat.h" HAVE_UTIMENSAT_SYMBOL__)
|
||||
if(HAVE_UTIMENSAT_SYMBOL__)
|
||||
CHECK_STRUCT_HAS_MEMBER("struct stat" "st_mtim.tv_nsec" "sys/types.h;fcntl.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC) # POSIX.1-2008
|
||||
if(NOT HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
|
||||
CHECK_STRUCT_HAS_MEMBER("struct stat" "st_mtimespec.tv_nsec" "sys/types.h;fcntl.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC) # macOS
|
||||
endif()
|
||||
if(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC OR HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
|
||||
set(HAVE_UTIMENSAT 1)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(UPX_CONFIG_DISABLE_WSTRICT)
|
||||
# enable all basic warnings
|
||||
set(warn_Wall -Wall)
|
||||
set(warn_WN -W3)
|
||||
else()
|
||||
# enable all basic warnings, and enable lots of strict warnings
|
||||
set(warn_Wall -Wall -Wextra -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wshadow -Wvla -Wwrite-strings)
|
||||
set(warn_WN -W4)
|
||||
endif()
|
||||
if(UPX_CONFIG_DISABLE_WERROR)
|
||||
# warnings are just warnings
|
||||
set(warn_Werror "")
|
||||
set(warn_WX "")
|
||||
else()
|
||||
# warnings are fatal errors; annoy developers to keep the source code warning-free
|
||||
set(warn_Werror -Werror)
|
||||
set(warn_WX -WX)
|
||||
endif()
|
||||
if(MSVC_FRONTEND)
|
||||
# disable warning C5105 which may get triggered by some older versions of <windows.h>
|
||||
set(warn_WX -wd5105 ${warn_WX})
|
||||
endif()
|
||||
|
||||
function(upx_add_definitions_with_prefix)
|
||||
set(flag_prefix "${ARGV0}")
|
||||
if(flag_prefix MATCHES "^empty$") # need "empty" to work around bug in old CMake versions
|
||||
set(flag_prefix "")
|
||||
endif()
|
||||
list(REMOVE_AT ARGV 0)
|
||||
set(failed "")
|
||||
foreach(f ${ARGV})
|
||||
set(flag "${flag_prefix}${f}")
|
||||
string(REGEX REPLACE "[^0-9a-zA-Z_]" "_" cache_var "HAVE_CFLAG_${flag}")
|
||||
check_c_compiler_flag("${flag}" ${cache_var})
|
||||
if(${cache_var})
|
||||
#message(STATUS "add_definitions: ${flag}")
|
||||
add_definitions("${flag}")
|
||||
else()
|
||||
list(APPEND failed "${f}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(failed_flags "${failed}" PARENT_SCOPE) # return value
|
||||
endfunction()
|
||||
|
||||
function(upx_add_definitions)
|
||||
set(failed_flags "")
|
||||
if(MSVC_FRONTEND AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# for clang-cl try "-clang:" flag prefix first
|
||||
upx_add_definitions_with_prefix("-clang:" ${ARGV})
|
||||
upx_add_definitions_with_prefix("empty" ${failed_flags})
|
||||
else()
|
||||
upx_add_definitions_with_prefix("empty" ${ARGV})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(NOT CMAKE_C_COMPILER_ID MATCHES "^MSVC")
|
||||
# use -O2 instead of -O3 to reduce code size
|
||||
string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" a "${CMAKE_C_FLAGS_RELEASE}")
|
||||
string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" b "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${a}" CACHE STRING "Flags used by the C compiler during RELEASE builds." FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${b}" CACHE STRING "Flags used by the CXX compiler during RELEASE builds." FORCE)
|
||||
endif()
|
||||
if(MSVC_FRONTEND OR WIN32 OR MINGW OR CYGWIN)
|
||||
# disable silly warnings about using "deprecated" POSIX functions like fopen()
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
endif()
|
||||
if(MSVC_FRONTEND)
|
||||
# use -funsigned-char; set __cplusplus according to selected C++ standard
|
||||
add_definitions(-J -Zc:__cplusplus)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "^MSVC")
|
||||
upx_add_definitions(-Zc:preprocessor) # use new preprocessor
|
||||
endif()
|
||||
endif()
|
||||
if(NOT CMAKE_C_COMPILER_ID MATCHES "^MSVC")
|
||||
# protect against security threats caused by misguided compiler "optimizations"
|
||||
upx_add_definitions(-fno-delete-null-pointer-checks -fno-lifetime-dse)
|
||||
upx_add_definitions(-fno-strict-aliasing -fno-strict-overflow -funsigned-char)
|
||||
# disable overambitious auto-vectorization until this actually gains something
|
||||
upx_add_definitions(-fno-tree-vectorize)
|
||||
# disable annoying clang warnings which get added by the macOS Xcode cmake generator
|
||||
if(CMAKE_GENERATOR MATCHES "Xcode")
|
||||
upx_add_definitions(-Wno-shorten-64-to-32)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# compile a target with -O2 optimization even in Debug build
|
||||
function(upx_compile_target_debug_with_O2)
|
||||
foreach(t ${ARGV})
|
||||
if(MSVC_FRONTEND)
|
||||
# MSVC uses some Debug compilation options like -RTC1 that are incompatible with -O2
|
||||
else()
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-O2>)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# compile a source file with -O2 optimization even in Debug build; messy because of CMake limitations
|
||||
function(upx_compile_source_debug_with_O2)
|
||||
set(flags "$<$<CONFIG:Debug>:-O2>")
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.8")
|
||||
# 3.8: The COMPILE_FLAGS source file property learned to support generator expressions
|
||||
if(is_multi_config OR NOT CMAKE_BUILD_TYPE MATCHES "^Debug$")
|
||||
return()
|
||||
endif()
|
||||
set(flags "-O2")
|
||||
endif()
|
||||
if(CMAKE_GENERATOR MATCHES "Xcode") # multi-config
|
||||
# NOTE: Xcode does not support per-config per-source COMPILE_FLAGS (as of CMake 3.27.7)
|
||||
return()
|
||||
endif()
|
||||
foreach(t ${ARGV})
|
||||
if(MSVC_FRONTEND)
|
||||
# MSVC uses some Debug compilation options like -RTC1 that are incompatible with -O2
|
||||
else()
|
||||
get_source_file_property(prop ${t} COMPILE_FLAGS)
|
||||
if(prop MATCHES "^(NOTFOUND)?$")
|
||||
set_source_files_properties(${t} PROPERTIES COMPILE_FLAGS "${flags}")
|
||||
else()
|
||||
set_source_files_properties(${t} PROPERTIES COMPILE_FLAGS "${prop} ${flags}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# sanitize a target
|
||||
function(upx_sanitize_target)
|
||||
foreach(t ${ARGV})
|
||||
if(UPX_CONFIG_DISABLE_SANITIZE)
|
||||
# no-op
|
||||
elseif(MSVC_FRONTEND)
|
||||
# MSVC uses -GS (similar to -fstack-protector) by default
|
||||
elseif(MINGW OR CYGWIN)
|
||||
# avoid link errors with current MinGW-w64 versions
|
||||
# see https://www.mingw-w64.org/contribute/#sanitizers-asan-tsan-usan
|
||||
else()
|
||||
# default sanitizer for Debug builds
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>)
|
||||
# default sanitizer for Release builds
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:MinSizeRel>:-fstack-protector>)
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Release>:-fstack-protector>)
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:RelWithDebInfo>:-fstack-protector>)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
#***********************************************************************
|
||||
# targets
|
||||
#***********************************************************************
|
||||
|
||||
# internal settings; these may change in a future versions
|
||||
set(UPX_CONFIG_DISABLE_THREADS ON) # multithreading is currently not used; maybe in UPX version 5
|
||||
set(UPX_CONFIG_DISABLE_BZIP2 ON) # bzip2 is currently not used; we might need it to decompress linux kernels
|
||||
set(UPX_CONFIG_DISABLE_ZSTD ON) # zstd is currently not used; maybe in UPX version 5
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_THREADS)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_BZIP2)
|
||||
file(GLOB bzip2_SOURCES "vendor/bzip2/*.c")
|
||||
list(SORT bzip2_SOURCES)
|
||||
add_library(upx_vendor_bzip2 STATIC ${bzip2_SOURCES})
|
||||
if(NOT UPX_CONFIG_DISABLE_C_STANDARD)
|
||||
set_property(TARGET upx_vendor_bzip2 PROPERTY C_STANDARD 11)
|
||||
endif()
|
||||
endif() # UPX_CONFIG_DISABLE_BZIP2
|
||||
|
||||
file(GLOB ucl_SOURCES "vendor/ucl/src/*.c")
|
||||
list(SORT ucl_SOURCES)
|
||||
add_library(upx_vendor_ucl STATIC ${ucl_SOURCES})
|
||||
if(NOT UPX_CONFIG_DISABLE_C_STANDARD)
|
||||
set_property(TARGET upx_vendor_ucl PROPERTY C_STANDARD 11)
|
||||
endif()
|
||||
|
||||
file(GLOB zlib_SOURCES "vendor/zlib/*.c")
|
||||
list(SORT zlib_SOURCES)
|
||||
add_library(upx_vendor_zlib STATIC ${zlib_SOURCES})
|
||||
if(NOT UPX_CONFIG_DISABLE_C_STANDARD)
|
||||
set_property(TARGET upx_vendor_zlib PROPERTY C_STANDARD 11)
|
||||
endif()
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_ZSTD)
|
||||
file(GLOB zstd_SOURCES "vendor/zstd/lib/*/*.c")
|
||||
list(SORT zstd_SOURCES)
|
||||
add_library(upx_vendor_zstd STATIC ${zstd_SOURCES})
|
||||
if(NOT UPX_CONFIG_DISABLE_C_STANDARD)
|
||||
set_property(TARGET upx_vendor_zstd PROPERTY C_STANDARD 11)
|
||||
endif()
|
||||
endif() # UPX_CONFIG_DISABLE_ZSTD
|
||||
|
||||
file(GLOB upx_SOURCES "src/*.cpp" "src/[cfu]*/*.cpp")
|
||||
list(SORT upx_SOURCES)
|
||||
add_executable(upx ${upx_SOURCES})
|
||||
if(NOT UPX_CONFIG_DISABLE_CXX_STANDARD)
|
||||
set_property(TARGET upx PROPERTY CXX_STANDARD 17)
|
||||
endif()
|
||||
target_link_libraries(upx upx_vendor_ucl upx_vendor_zlib)
|
||||
if(NOT UPX_CONFIG_DISABLE_BZIP2)
|
||||
target_link_libraries(upx upx_vendor_bzip2)
|
||||
endif()
|
||||
if(NOT UPX_CONFIG_DISABLE_ZSTD)
|
||||
target_link_libraries(upx upx_vendor_zstd)
|
||||
endif()
|
||||
if(Threads_FOUND)
|
||||
target_link_libraries(upx Threads::Threads)
|
||||
endif()
|
||||
|
||||
#***********************************************************************
|
||||
# target compilation flags
|
||||
#***********************************************************************
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_BZIP2)
|
||||
set(t upx_vendor_bzip2)
|
||||
upx_compile_target_debug_with_O2(${t})
|
||||
upx_sanitize_target(${t})
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_WN} -wd4127 -wd4244 -wd4267 ${warn_WX})
|
||||
else()
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} -Wno-implicit-fallthrough ${warn_Werror})
|
||||
endif()
|
||||
endif() # UPX_CONFIG_DISABLE_BZIP2
|
||||
|
||||
set(t upx_vendor_ucl)
|
||||
target_include_directories(${t} PRIVATE vendor/ucl/include vendor/ucl)
|
||||
upx_compile_target_debug_with_O2(${t})
|
||||
upx_sanitize_target(${t})
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_WN} ${warn_WX})
|
||||
else()
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
||||
endif()
|
||||
|
||||
set(t upx_vendor_zlib)
|
||||
upx_compile_target_debug_with_O2(${t})
|
||||
upx_sanitize_target(${t})
|
||||
target_compile_definitions(${t} PRIVATE HAVE_VSNPRINTF=1)
|
||||
if(HAVE_UNISTD_H)
|
||||
target_compile_definitions(${t} PRIVATE HAVE_UNISTD_H=1)
|
||||
endif()
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE -W3 ${warn_WX})
|
||||
else()
|
||||
target_compile_options(${t} PRIVATE -Wall ${warn_Werror})
|
||||
##target_compile_options(${t} PRIVATE ${warn_Wall} -Wno-cast-align -Wno-cast-qual ${warn_Werror})
|
||||
endif()
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_ZSTD)
|
||||
set(t upx_vendor_zstd)
|
||||
upx_compile_target_debug_with_O2(${t})
|
||||
upx_sanitize_target(${t})
|
||||
target_compile_definitions(${t} PRIVATE DYNAMIC_BMI2=0 ZSTD_DISABLE_ASM=1)
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_WN} ${warn_WX})
|
||||
else()
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
||||
endif()
|
||||
endif() # UPX_CONFIG_DISABLE_ZSTD
|
||||
|
||||
set(t upx)
|
||||
target_include_directories(${t} PRIVATE vendor)
|
||||
target_compile_definitions(${t} PRIVATE $<$<CONFIG:Debug>:DEBUG=1>)
|
||||
if(GITREV_SHORT)
|
||||
target_compile_definitions(${t} PRIVATE UPX_VERSION_GITREV="${GITREV_SHORT}${GITREV_PLUS}")
|
||||
if(GIT_DESCRIBE)
|
||||
target_compile_definitions(${t} PRIVATE UPX_VERSION_GIT_DESCRIBE="${GIT_DESCRIBE}")
|
||||
endif()
|
||||
endif()
|
||||
if(Threads_FOUND)
|
||||
target_compile_definitions(${t} PRIVATE WITH_THREADS=1)
|
||||
endif()
|
||||
if(NOT UPX_CONFIG_DISABLE_WSTRICT)
|
||||
target_compile_definitions(${t} PRIVATE UPX_CONFIG_DISABLE_WSTRICT=0)
|
||||
endif()
|
||||
if(NOT UPX_CONFIG_DISABLE_WERROR)
|
||||
target_compile_definitions(${t} PRIVATE UPX_CONFIG_DISABLE_WERROR=0)
|
||||
endif()
|
||||
if(NOT UPX_CONFIG_DISABLE_BZIP2)
|
||||
target_compile_definitions(${t} PRIVATE WITH_BZIP2=0) # FIXME TODO
|
||||
endif()
|
||||
if(NOT UPX_CONFIG_DISABLE_ZSTD)
|
||||
target_compile_definitions(${t} PRIVATE WITH_ZSTD=1)
|
||||
endif()
|
||||
if(HAVE_UTIMENSAT)
|
||||
target_compile_definitions(${t} PRIVATE USE_UTIMENSAT=1)
|
||||
if(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
|
||||
target_compile_definitions(${t} PRIVATE HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC=1)
|
||||
endif()
|
||||
endif()
|
||||
# improve speed of the Debug versions
|
||||
upx_compile_source_debug_with_O2(src/compress/compress_lzma.cpp)
|
||||
upx_compile_source_debug_with_O2(src/filter/filter_impl.cpp)
|
||||
#upx_compile_target_debug_with_O2(${t})
|
||||
upx_sanitize_target(${t})
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE -EHsc ${warn_WN} ${warn_WX})
|
||||
else()
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
||||
endif()
|
||||
|
||||
#***********************************************************************
|
||||
# test
|
||||
# ctest
|
||||
# make test
|
||||
# ninja test
|
||||
#***********************************************************************
|
||||
|
||||
if(NOT UPX_CONFIG_CMAKE_DISABLE_TEST)
|
||||
|
||||
include(CTest)
|
||||
# TODO later: check CMAKE_CROSSCOMPILING_EMULATOR
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
add_test(NAME upx-version COMMAND upx --version)
|
||||
add_test(NAME upx-help COMMAND upx --help)
|
||||
endif()
|
||||
if(NOT CMAKE_CROSSCOMPILING AND NOT UPX_CONFIG_DISABLE_SELF_PACK_TEST)
|
||||
# IMPORTANT NOTE: these tests can only work if the host executable format is supported by UPX!
|
||||
function(upx_add_test)
|
||||
set(name "${ARGV0}")
|
||||
list(REMOVE_AT ARGV 0)
|
||||
add_test(NAME "${name}" COMMAND ${ARGV})
|
||||
set_tests_properties("${name}" PROPERTIES RUN_SERIAL TRUE) # run these tests sequentially
|
||||
endfunction()
|
||||
set(exe ${CMAKE_EXECUTABLE_SUFFIX})
|
||||
set(upx_self_exe "$<TARGET_FILE:upx>")
|
||||
set(fo "--force-overwrite")
|
||||
upx_add_test(upx-self-pack upx -3 "${upx_self_exe}" ${fo} -o upx-packed${exe})
|
||||
upx_add_test(upx-self-pack-n2b upx -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-n2b${exe})
|
||||
upx_add_test(upx-self-pack-n2d upx -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-n2d${exe})
|
||||
upx_add_test(upx-self-pack-n2e upx -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-n2e${exe})
|
||||
upx_add_test(upx-self-pack-lzma upx -1 --lzma "${upx_self_exe}" ${fo} -o upx-packed-lzma${exe})
|
||||
upx_add_test(upx-list upx -l upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe})
|
||||
upx_add_test(upx-fileinfo upx --fileinfo upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe})
|
||||
upx_add_test(upx-test upx -t upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe})
|
||||
upx_add_test(upx-unpack upx -d upx-packed${exe} ${fo} -o upx-unpacked${exe})
|
||||
upx_add_test(upx-run-unpacked ./upx-unpacked${exe} --version-short)
|
||||
upx_add_test(upx-run-packed ./upx-packed${exe} --version-short)
|
||||
endif()
|
||||
|
||||
endif() # UPX_CONFIG_CMAKE_DISABLE_TEST
|
||||
|
||||
#***********************************************************************
|
||||
# install
|
||||
# cmake --install .
|
||||
# make install
|
||||
# ninja install
|
||||
#***********************************************************************
|
||||
|
||||
if(NOT UPX_CONFIG_CMAKE_DISABLE_INSTALL)
|
||||
|
||||
# installation prefix and directories
|
||||
if(NOT CMAKE_INSTALL_PREFIX)
|
||||
#message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined")
|
||||
message(WARNING "WARNING: CMAKE_INSTALL_PREFIX is not defined")
|
||||
endif()
|
||||
if(CMAKE_INSTALL_PREFIX)
|
||||
include(GNUInstallDirs)
|
||||
endif()
|
||||
if(CMAKE_INSTALL_PREFIX AND DEFINED CMAKE_INSTALL_FULL_BINDIR)
|
||||
install(TARGETS upx DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
|
||||
install(FILES
|
||||
COPYING LICENSE NEWS README doc/THANKS.txt doc/upx-doc.html doc/upx-doc.txt
|
||||
DESTINATION "${CMAKE_INSTALL_FULL_DOCDIR}"
|
||||
)
|
||||
install(FILES doc/upx.1 DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1")
|
||||
endif()
|
||||
|
||||
endif() # UPX_CONFIG_CMAKE_DISABLE_INSTALL
|
||||
|
||||
#***********************************************************************
|
||||
# show summary
|
||||
# print some info about the build configuration
|
||||
#***********************************************************************
|
||||
|
||||
function(print_var)
|
||||
foreach(var ${ARGV})
|
||||
if(DEFINED ${var} AND NOT ",${${var}}," STREQUAL ",,")
|
||||
if(${var})
|
||||
message(STATUS "${var} = ${${var}}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.maint.txt")
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.maint.txt")
|
||||
endif()
|
||||
|
||||
print_var(CMAKE_VERSION UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION CMAKE_GENERATOR)
|
||||
if(NOT UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO)
|
||||
print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION)
|
||||
print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_CROSSCOMPILING)
|
||||
print_var(CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION CMAKE_C_COMPILER_FRONTEND_VARIANT CMAKE_C_COMPILER_ARCHITECTURE_ID CMAKE_C_PLATFORM_ID CMAKE_C_COMPILER_ABI)
|
||||
print_var(CMAKE_CXX_COMPILER_ID CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_COMPILER_FRONTEND_VARIANT CMAKE_CXX_COMPILER_ARCHITECTURE_ID CMAKE_CXX_PLATFORM_ID CMAKE_CXX_COMPILER_ABI)
|
||||
print_var(CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
print_var(CYGWIN GNUC MINGW MSVC MSVC_FRONTEND MSVC_IDE WIN32 WIN64)
|
||||
endif() # UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO
|
||||
print_var(CMAKE_INSTALL_PREFIX CMAKE_CONFIGURATION_TYPES CMAKE_BUILD_TYPE)
|
||||
if(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|None|Release)$")
|
||||
message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"")
|
||||
endif()
|
||||
|
||||
# extra sanity checks to detect incompatible C vs CXX settings
|
||||
if(NOT UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK)
|
||||
if(NOT ",${CMAKE_C_PLATFORM_ID}," STREQUAL ",${CMAKE_CXX_PLATFORM_ID},")
|
||||
message(FATAL_ERROR "ERROR: CMAKE_C_PLATFORM_ID CMAKE_CXX_PLATFORM_ID mismatch")
|
||||
endif()
|
||||
if(NOT ",${CMAKE_C_COMPILER_ABI}," STREQUAL ",${CMAKE_CXX_COMPILER_ABI},")
|
||||
message(FATAL_ERROR "ERROR: CMAKE_C_COMPILER_ABI CMAKE_CXX_COMPILER_ABI mismatch")
|
||||
endif()
|
||||
if(NOT ",${CMAKE_C_COMPILER_FRONTEND_VARIANT}," STREQUAL ",${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},")
|
||||
message(FATAL_ERROR "ERROR: CMAKE_C_COMPILER_FRONTEND_VARIANT CMAKE_CXX_COMPILER_FRONTEND_VARIANT mismatch")
|
||||
endif()
|
||||
endif() # UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK
|
||||
|
||||
# vim:set ft=cmake ts=4 sw=4 tw=0 et:
|
||||
@@ -1,36 +1,69 @@
|
||||
#
|
||||
# UPX toplevel Makefile - needs GNU make 3.81 or better
|
||||
#
|
||||
# Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
# UPX top-level Makefile - needs GNU make and CMake >= 3.13
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
MAKEFLAGS += -rR
|
||||
# INFO: this Makefile is just a convenience wrapper for calling CMake
|
||||
|
||||
# HINT: if you only have an older CMake 3.x then you can invoke cmake manually like this:
|
||||
# mkdir -p build/release
|
||||
# cd build/release
|
||||
# cmake ../.. # run config
|
||||
# make -j # and run build
|
||||
|
||||
CMAKE = cmake
|
||||
UPX_CMAKE_BUILD_FLAGS += --parallel
|
||||
ifneq ($(VERBOSE),)
|
||||
#UPX_CMAKE_BUILD_FLAGS += --verbose # requires CMake >= 3.14
|
||||
UPX_CMAKE_CONFIG_FLAGS += -DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
endif
|
||||
# enable this if you prefer Ninja for the actual builds:
|
||||
#UPX_CMAKE_CONFIG_FLAGS += -G Ninja
|
||||
|
||||
#***********************************************************************
|
||||
# default
|
||||
#***********************************************************************
|
||||
|
||||
run_cmake_config = $(CMAKE) -S . -B $1 $(UPX_CMAKE_CONFIG_FLAGS) -DCMAKE_BUILD_TYPE=$2
|
||||
run_cmake_build = $(CMAKE) --build $1 $(UPX_CMAKE_BUILD_FLAGS) --config $2
|
||||
# avoid re-running run_cmake_config if CMakeCache.txt already exists
|
||||
run_config = $(if $(wildcard $1/CMakeCache.txt),,$(call run_cmake_config,$1,$2))
|
||||
run_build = $(call run_cmake_build,$1,$2)
|
||||
|
||||
.DEFAULT_GOAL = build/release
|
||||
|
||||
build/debug: PHONY
|
||||
$(call run_config,$@,Debug)
|
||||
$(call run_build,$@,Debug)
|
||||
|
||||
build/release: PHONY
|
||||
$(call run_config,$@,Release)
|
||||
$(call run_build,$@,Release)
|
||||
|
||||
.NOTPARALLEL: # because the actual builds use "cmake --parallel"
|
||||
.PHONY: PHONY
|
||||
.SECONDEXPANSION:
|
||||
.SUFFIXES:
|
||||
export SHELL = /bin/sh
|
||||
|
||||
srcdir = .
|
||||
top_srcdir = .
|
||||
include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
|
||||
# shortcuts (all => debug + release)
|
||||
debug: build/debug
|
||||
release: build/release
|
||||
all build/all: build/debug build/release
|
||||
build/%/all: $$(dir $$@)debug $$(dir $$@)release ;
|
||||
|
||||
# info: src/stub needs special build tools from https://github.com/upx/upx-stubtools
|
||||
BUILD_STUB = 0
|
||||
ifneq ($(wildcard $(HOME)/local/bin/bin-upx/upx-stubtools-check-version),)
|
||||
BUILD_STUB = 1
|
||||
endif
|
||||
ifneq ($(wildcard $(HOME)/bin/bin-upx/upx-stubtools-check-version),)
|
||||
BUILD_STUB = 1
|
||||
#
|
||||
# END of Makefile
|
||||
#
|
||||
|
||||
# extra pre-defined build configurations and some utility; optional
|
||||
ifneq ($(MAKEFILE_LIST),)
|
||||
include $(dir $(lastword $(MAKEFILE_LIST)))/misc/make/Makefile-extra.mk
|
||||
else
|
||||
include ./misc/make/Makefile-extra.mk
|
||||
endif
|
||||
|
||||
default:
|
||||
@echo "UPX info: please choose a target for 'make'"
|
||||
|
||||
all mostlyclean clean distclean maintainer-clean:
|
||||
ifeq ($(BUILD_STUB),1)
|
||||
$(MAKE) -C src/stub $@
|
||||
endif
|
||||
# developer convenience
|
||||
ifneq ($(wildcard /usr/bin/env),) # needs bash, perl, xargs, etc.
|
||||
check-whitespace clang-format run-testsuite run-testsuite-debug run-testsuite-release: PHONY src/Makefile
|
||||
$(MAKE) -C src $@
|
||||
$(MAKE) -C doc $@
|
||||
|
||||
.PHONY: default all mostlyclean clean distclean maintainer-clean
|
||||
|
||||
# vim:set ts=8 sw=8 noet:
|
||||
endif
|
||||
|
||||
@@ -2,12 +2,66 @@
|
||||
User visible changes for UPX
|
||||
==================================================================
|
||||
|
||||
Changes in 4.2.1 (01 Nov 2023):
|
||||
* linux: /proc/self/exe now is optional
|
||||
* windows: use SetFileTime to preserve sub-second file timestamps
|
||||
* official Windows builds: revert activeCodePage change introduced in 4.2.0
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/14
|
||||
|
||||
Changes in 4.2.0 (26 Oct 2023):
|
||||
* win32/pe and win64/pe: stricter relocation checks; please report regressions
|
||||
* unix: use utimensat to preserve sub-second file timestamps
|
||||
* new option '--link' to preserve hard-links (Unix only; use with care)
|
||||
* add support for NO_COLOR env var; see https://no-color.org/
|
||||
* disable macOS support until we fix compatibility with macOS 13+
|
||||
* official Windows builds: set activeCodePage to UTF-8
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/13
|
||||
|
||||
Changes in 4.1.0 (08 Aug 2023):
|
||||
* ELF: handle shared libraries with more than 2 PT_LOAD segments
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/11
|
||||
|
||||
Changes in 4.0.2 (30 Jan 2023):
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/9
|
||||
|
||||
Changes in 4.0.1 (16 Nov 2022):
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/8
|
||||
|
||||
Changes in 4.0.0 (28 Oct 2022):
|
||||
* Switch to semantic versioning
|
||||
* SECURITY NOTES: emphasize the security context in the docs
|
||||
* Support easy building from source code with CMake
|
||||
* Support easy rebuilding the stubs from source with Podman/Docker
|
||||
* Add integrated doctest C++ testing framework
|
||||
* Add support for EFI files (PE x86; Kornel Pal)
|
||||
* win32/pe and win64/pe: set correct SizeOfHeaders in the PE header
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/6
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/7
|
||||
|
||||
Changes in 3.96 (23 Jan 2020):
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/5
|
||||
|
||||
Changes in 3.95 (26 Aug 2018):
|
||||
* Flag --android-shlib to work around bad design in Android
|
||||
* Flag --force-pie when ET_DYN main program is not marked as DF_1_PIE
|
||||
* Better compatibility with varying layout of address space on Linux
|
||||
* Support for 4 PT_LOAD layout in ELF generated by binutils-2.31
|
||||
* bug fixes, particularly better diagnosis of malformed input
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/4
|
||||
|
||||
Changes in 3.94 (12 May 2017):
|
||||
* Add support for arm64-linux (aka "aarch64").
|
||||
* Add support for --lzma compression on 64-bit PowerPC (Thierry Fauck).
|
||||
* For Mach, "upx -d" will unpack a prefix of the file (and warn).
|
||||
* Various improvements to the ELF formats.
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/3
|
||||
|
||||
Changes in 3.93 (29 Jan 2017):
|
||||
* UPX has moved to GitHub - the new home page is https://upx.github.io
|
||||
* fixed some win32/pe and win64/pe regressions introduced in 3.92
|
||||
* Fixed some win32/pe and win64/pe regressions introduced in 3.92
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/2
|
||||
|
||||
Changes in 3.92 (11 Dec 2016):
|
||||
* UPX has moved to GitHub - the new home page is https://upx.github.io
|
||||
* INFO: UPX has moved to GitHub - the new home page is https://upx.github.io
|
||||
* IMPORTANT: all PE formats: internal changes: reunited the diverged source
|
||||
files - please report all regressions into the bug tracker and try UPX 3.91
|
||||
in case of problems.
|
||||
@@ -19,7 +73,7 @@ Changes in 3.92 (11 Dec 2016):
|
||||
by Codenomicon to NCSC-FI on 2015-01-08.
|
||||
The vulnerabilities were discovered by Joonas Kuorilehto and
|
||||
Antti Häyrynen from Codenomicon.
|
||||
* bug fixes
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/1
|
||||
|
||||
Changes in 3.91 (30 Sep 2013):
|
||||
* Added experimental support for Windows 64-bit PE files, based on
|
||||
@@ -40,7 +94,7 @@ Changes in 3.08 (12 Dec 2011):
|
||||
* Compress shared library on ELF i386 only [ld.so threatens even this case].
|
||||
* Attempt to support ELF on QNX 6.3.0 for armel (experimental).
|
||||
* Better diagnostic when ELF -fPIC is needed.
|
||||
* PT_NOTE improvements for *BSD.
|
||||
* PT_NOTE improvements for BSD.
|
||||
* Preserve more ELF .e_flags on ARM.
|
||||
* Minor code improvements for ELF stubs.
|
||||
* Defend against another flavor of corrupt PE header.
|
||||
@@ -103,7 +157,7 @@ Changes in 2.93 beta (08 Mar 2007):
|
||||
you have to explicitly use '--lzma' even for '--ultra-brute' here
|
||||
because runtime decompression is about 30 times slower than NRV -
|
||||
which is really noticeable on old machines.
|
||||
* dos/exe: fixed a rarely occuring bug in relocation handling
|
||||
* dos/exe: fixed a rarely occurring bug in relocation handling
|
||||
* win32/pe & arm/pe: better icon compression handling
|
||||
|
||||
Changes in 2.92 beta (23 Jan 2007):
|
||||
@@ -114,7 +168,7 @@ Changes in 2.92 beta (23 Jan 2007):
|
||||
|
||||
Changes in 2.91 beta (29 Nov 2006):
|
||||
* assorted bug fixes
|
||||
* arm/pe: fix "missing" icon & version info resource problem for wince 5
|
||||
* wince/arm: fix "missing" icon & version info resource problem for WinCE 5
|
||||
* win32/pe & arm/pe: added option --compress-icons=3 to compress all icons
|
||||
|
||||
Changes in 2.90 beta (08 Oct 2006):
|
||||
@@ -168,7 +222,7 @@ Changes in 1.95 beta (09 Apr 2006):
|
||||
* win32/pe: really worked around R6002 runtime errors
|
||||
|
||||
Changes in 1.94 beta (11 Mar 2006):
|
||||
* new format: added support for arm/pe (ARM executables running on WinCE)
|
||||
* new format: added support for wince/arm (ARM executables running on WinCE)
|
||||
* new format: added support for linux elf/amd64
|
||||
* new format: added support for linux elf/ppc32
|
||||
* new format: added support for mach/ppc32 (Apple Mac OS X)
|
||||
@@ -220,7 +274,7 @@ Changes in 1.11 beta (20 Dec 2000):
|
||||
==================================================================
|
||||
|
||||
Changes in 1.25 (29 Jun 2004)
|
||||
* INFO: http://upx.sourceforge.net is the permanent UPX home page
|
||||
* INFO: http://upx.sourceforge.net is the new UPX home page
|
||||
* watcom/le: don't crash on files without relocations
|
||||
* win32/pe: stricter checks of some PE values
|
||||
* source code: much improved portability using ACC, the
|
||||
@@ -336,6 +390,8 @@ Changes in 0.99 (25 Feb 2000)
|
||||
* dos/com and dos/sys: fixed a bad decompressor problem
|
||||
* linux/386: the counter for the progress indicator was off by one
|
||||
|
||||
==================================================================
|
||||
|
||||
Changes in 0.94 (06 Dec 1999)
|
||||
* win32/pe: the stub now calls ExitProcess in case of import errors
|
||||
* under DOS and Windows, the environment variable UPX now accepts
|
||||
@@ -483,12 +539,12 @@ Changes in 0.40 (05 Oct 1998)
|
||||
* fixed a small but fatal bug in dos/sys introduced in 0.30
|
||||
* fixed a rare bug in dos/exe
|
||||
* worked around a bug in djgpp's strip 2.8
|
||||
* djgpp/coff: Allegro packfile support should work now
|
||||
* djgpp2/coff: Allegro packfile support should work now
|
||||
* added dos/exeh compression method (works on 386+)
|
||||
|
||||
Changes in 0.30 (27 Jul 1998)
|
||||
* fixed a serious bug in the 32-bit compressors - please don't use
|
||||
djgpp/coff and watcom/le compressed files from previous versions,
|
||||
djgpp2/coff and watcom/le compressed files from previous versions,
|
||||
some of them are possibly damaged !
|
||||
* the 16-bit uncompressors are a little bit shorter & faster
|
||||
* fixed progress indicator for VESA and SVGA text modes
|
||||
@@ -499,6 +555,5 @@ Changes in 0.20 (05 Jul 1998)
|
||||
|
||||
Changes in 0.05 (26 May 1998)
|
||||
* first public beta release
|
||||
|
||||
|
||||
# vim:set syntax=off tw=0 ts=4 sw=4 et: -*- coding: utf-8 -*-
|
||||
* based on experience gained from our previous packers DJP (djgpp2/coff, 1996),
|
||||
lzop (1996) and mfxpak (atari/tos, 1990)
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
ooooo ooo ooooooooo. ooooooo ooooo
|
||||
`888' `8' `888 `Y88. `8888 d8'
|
||||
888 8 888 .d88' Y888..8P
|
||||
888 8 888ooo88P' `8888'
|
||||
888 8 888 .8PY888.
|
||||
`88. .8' 888 d8' `888b
|
||||
`YbodP' o888o o888o o88888o
|
||||
|
||||
|
||||
The Ultimate Packer for eXecutables
|
||||
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
https://upx.github.io
|
||||
|
||||
|
||||
Here are some possible projects from which you can choose if you'd like to
|
||||
contribute to UPX. Be sure to get in touch with us first to avoid
|
||||
duplicate efforts.
|
||||
|
||||
|
||||
User interface:
|
||||
---------------
|
||||
|
||||
- Write a nifty Win32 GUI (in C++), but try to keep the size of the
|
||||
final executable small. Compression should be in a separate
|
||||
thread that calls do_one_file() [see src/work.cpp].
|
||||
|
||||
- Draw a nice UPX icon.
|
||||
|
||||
|
||||
More formats:
|
||||
-------------
|
||||
|
||||
- Amiga
|
||||
|
||||
- BeOS
|
||||
|
||||
- C64
|
||||
|
||||
- elks/8086 (this is a 16-bit linux-8086 kernel)
|
||||
See http://www.elks.ecs.soton.ac.uk/
|
||||
|
||||
- freebsd/386 (generic), freebsd/elf386 (specialized).
|
||||
Probably could share most of the linux code.
|
||||
|
||||
- add support for self-extracting HTML pages using a Javascript stub
|
||||
(like the AlgART HTML Packer "AHP")
|
||||
|
||||
|
||||
Existing formats:
|
||||
-----------------
|
||||
|
||||
- djgpp2/coff: add support for DLX dynamic loading
|
||||
(see SEAL http://www.home.sk/public/seal/ )
|
||||
|
||||
- dos/com: add support for very long files - convert to exe if necessary
|
||||
|
||||
- dos/exe: implement filter support
|
||||
|
||||
- linux/i386:
|
||||
- use the new assembly preprocessor stuff (ie. process the file
|
||||
headers internally)
|
||||
- UPX uncompressor daemon
|
||||
- rewrite the stub in assembly (not sure if this is a good idea...)
|
||||
|
||||
- watcom/le: add support for per section compression, LX support, VXD
|
||||
|
||||
- win32/pe: display a nice dialog box in the stub in case
|
||||
of problems (like importing a DLL or function fails)
|
||||
- win32/pe: per section compression
|
||||
|
||||
|
||||
Compression ratio:
|
||||
------------------
|
||||
|
||||
- invent more effective filters
|
||||
|
||||
- I (Markus) will continue to work on better compression algorithms,
|
||||
so be sure to do better than me if you plan working on this ;-)
|
||||
|
||||
|
||||
Other:
|
||||
------
|
||||
|
||||
- anything else you think that could improve UPX...
|
||||
|
||||
|
||||
Thanks for your contribution.
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
ooooo ooo ooooooooo. ooooooo ooooo
|
||||
`888' `8' `888 `Y88. `8888 d8'
|
||||
888 8 888 .d88' Y888..8P
|
||||
888 8 888ooo88P' `8888'
|
||||
888 8 888 .8PY888.
|
||||
`88. .8' 888 d8' `888b
|
||||
`YbodP' o888o o888o o88888o
|
||||
ooooo ooo ooooooooo. ooooooo ooooo
|
||||
`888' `8' `888 `Y88. `8888 d8'
|
||||
888 8 888 .d88' Y888..8P
|
||||
888 8 888ooo88P' `8888'
|
||||
888 8 888 .8PY888.
|
||||
`88. .8' 888 d8' `888b
|
||||
`YbodP' o888o o888o o88888o
|
||||
|
||||
|
||||
The Ultimate Packer for eXecutables
|
||||
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
Copyright (c) 1996-2023 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
https://upx.github.io
|
||||
|
||||
|
||||
@@ -18,10 +18,8 @@ WELCOME
|
||||
|
||||
Welcome to UPX !
|
||||
|
||||
Please don't forget to read the file LICENSE - UPX is distributed
|
||||
under the GNU General Public License (GPL) with special exceptions
|
||||
allowing the distribution of all compressed executables, including
|
||||
commercial programs.
|
||||
UPX is a free, secure, portable, extendable, high-performance
|
||||
executable packer for several executable formats.
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
@@ -37,86 +35,73 @@ and run exactly as before, with no runtime or memory penalty for most
|
||||
of the supported formats.
|
||||
|
||||
UPX supports a number of different executable formats, including
|
||||
Windows 95/98/ME/NT/2000/XP/CE programs and DLLs, DOS programs,
|
||||
and Linux executables and kernels.
|
||||
Windows programs and DLLs, and Linux executables.
|
||||
|
||||
UPX is free software distributed under the term of the GNU General
|
||||
Public License. Full source code is available.
|
||||
|
||||
UPX may be distributed and used freely, even with commercial applications.
|
||||
See the UPX License Agreement for details.
|
||||
See the UPX License Agreements for details.
|
||||
|
||||
UPX is rated number one in the well known Archive Comparison Test. Visit
|
||||
http://compression.ca/ .
|
||||
|
||||
UPX aims to be Commercial Quality Freeware.
|
||||
SECURITY CONTEXT
|
||||
================
|
||||
|
||||
IMPORTANT NOTE: UPX inherits the security context of any files it handles.
|
||||
|
||||
This means that packing, unpacking, or even testing or listing a file requires
|
||||
the same security considerations as actually executing the file.
|
||||
|
||||
Use UPX on trusted files only!
|
||||
|
||||
|
||||
SHORT DOCUMENTATION
|
||||
===================
|
||||
|
||||
'upx program.exe' will compress a program or DLL. For best compression
|
||||
results try 'upx --brute program.exe'.
|
||||
results try 'upx --best program.exe' or 'upx --brute program.exe'.
|
||||
|
||||
Please see the file UPX.DOC for the full documentation. The files
|
||||
NEWS and BUGS also contain various tidbits of information.
|
||||
|
||||
|
||||
DISCLAIMER
|
||||
==========
|
||||
|
||||
UPX comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE.
|
||||
|
||||
Having said that, we think that UPX is quite stable now. Indeed we
|
||||
have compressed lots of files without any problems. Also, the
|
||||
current version has undergone several months of beta testing -
|
||||
actually it's almost 8 years since our first public beta.
|
||||
|
||||
This is the first production quality release, and we plan that future
|
||||
releases will be backward compatible with this version.
|
||||
|
||||
Please report all problems or suggestions to the authors. Thanks.
|
||||
|
||||
|
||||
THE FUTURE
|
||||
==========
|
||||
|
||||
- AArch64 (64-bit ARM) for Linux and iOS.
|
||||
- Stay up-to-date with ongoing OS and executable format changes
|
||||
|
||||
- The Linux approach could probably get ported to a lot of other Unix
|
||||
variants, at least for other i386 architectures it shouldn't be too
|
||||
much work. If someone sends me a fresh hard disk and an official
|
||||
FreeBSD/OpenBSD/NetBSD/Solaris/BeOS... CD I might take a look at it ;-)
|
||||
- RISC-V 64 for Linux
|
||||
|
||||
- ARM64 for Windows (help wanted)
|
||||
|
||||
- We will *NOT* add any sort of protection and/or encryption.
|
||||
This only gives people a false feeling of security because
|
||||
by definition all protectors/compressors can be broken.
|
||||
And don't trust any advertisement of authors of other executable
|
||||
compressors about this topic - just do a websearch on "unpackers"...
|
||||
all "protectors" can be broken by definition.
|
||||
|
||||
- Fix all remaining bugs - keep your reports coming ;-)
|
||||
|
||||
- See the file PROJECTS in the source code distribution if you want
|
||||
to contribute.
|
||||
- Fix all remaining bugs - please report any issues
|
||||
https://github.com/upx/upx/issues
|
||||
|
||||
|
||||
COPYRIGHT
|
||||
=========
|
||||
|
||||
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2017 Laszlo Molnar
|
||||
Copyright (C) 2000-2017 John F. Reiser
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2023 Laszlo Molnar
|
||||
Copyright (C) 2000-2023 John F. Reiser
|
||||
|
||||
This program may be used freely, and you are welcome to
|
||||
redistribute it under certain conditions.
|
||||
UPX is distributed with full source code under the terms of the
|
||||
GNU General Public License v2+; either under the pure GPLv2+ (see
|
||||
the file COPYING), or (at your option) under the GPLv+2 with special
|
||||
exceptions and restrictions granting the free usage for all binaries
|
||||
including commercial programs (see the file LICENSE).
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
UPX License Agreement for more details.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
You should have received a copy of the UPX License Agreement along
|
||||
with this program; see the file LICENSE. If not, visit the UPX home page.
|
||||
You should have received a copy of the UPX License Agreements along
|
||||
with this program; see the files COPYING and LICENSE. If not,
|
||||
visit the UPX home page.
|
||||
|
||||
|
||||
Share and enjoy,
|
||||
@@ -133,7 +118,3 @@ Markus & Laszlo & John
|
||||
[ The term UPX is a shorthand for the Ultimate Packer for eXecutables
|
||||
and holds no connection with potential owners of registered trademarks
|
||||
or other rights. ]
|
||||
|
||||
[ Feel free to contact us if you have commercial compression requirements
|
||||
or interesting job offers. ]
|
||||
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
ooooo ooo ooooooooo. ooooooo ooooo
|
||||
`888' `8' `888 `Y88. `8888 d8'
|
||||
888 8 888 .d88' Y888..8P
|
||||
888 8 888ooo88P' `8888'
|
||||
888 8 888 .8PY888.
|
||||
`88. .8' 888 d8' `888b
|
||||
`YbodP' o888o o888o o88888o
|
||||
|
||||
|
||||
The Ultimate Packer for eXecutables
|
||||
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
https://upx.github.io
|
||||
|
||||
|
||||
MAJOR NEWS IN UPX 3
|
||||
===================
|
||||
|
||||
The main news since UPX 2 are:
|
||||
|
||||
* new format: added support for linux elf/arm
|
||||
|
||||
* better compression using the LZMA algorithm (option '--lzma')
|
||||
|
||||
* better support for MacOS
|
||||
+47
-56
@@ -27,21 +27,6 @@ Foreword
|
||||
Markus & Laszlo
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Welcome to the UPX source code release!
|
||||
|
||||
UPX is not a toy for kids. Apart from basic knowledge about executables
|
||||
and data compression you will need to be firm in C++, assembler,
|
||||
Perl and Makefiles. Probably some other things as well.
|
||||
|
||||
If you can't manage to compile it then the sources are
|
||||
probably not for you. Don't email us for help.
|
||||
|
||||
The authors use Linux for development. You might want to as well.
|
||||
|
||||
|
||||
Short overview
|
||||
--------------
|
||||
|
||||
@@ -56,49 +41,68 @@ Short overview
|
||||
are #included by the individual executable format handlers.
|
||||
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
- first of all you need to build the UCL compression library
|
||||
http://www.oberhumer.com/opensource/ucl/
|
||||
|
||||
|
||||
Tools needed to build/modify the UPX sources
|
||||
--------------------------------------------
|
||||
|
||||
- A C++ compiler: gcc >= 3.3 or clang.
|
||||
- A C++ compiler that fully implements C++17: clang-5, gcc-8 or msvc-2019-16.11
|
||||
(older or other compilers may work but are unsupported, use at your own risk)
|
||||
|
||||
- GNU make 3.81 or better
|
||||
- GNU make
|
||||
|
||||
- zlib and zlib-devel [or zlib-dev] software packages for your
|
||||
host environment
|
||||
|
||||
- LZMA SDK from https://github.com/upx/upx-lzma-sdk
|
||||
When using git run 'git submodule update --init --recursive'.
|
||||
- CMake 3.13 or better; see https://cmake.org/
|
||||
|
||||
|
||||
To compile the packer sources
|
||||
-----------------------------
|
||||
|
||||
Set the environment variable UPX_UCLDIR to point to your
|
||||
UCL build directory, e.g.
|
||||
|
||||
set UPX_UCLDIR=c:\src\ucl-1.03 (DOS / Windows)
|
||||
export UPX_UCLDIR=$HOME/local/src/ucl-1.03 (Unix)
|
||||
|
||||
Finally type
|
||||
|
||||
make
|
||||
- just run "make" in the top-level source directory
|
||||
|
||||
|
||||
If you want to modify the stub sources you'll also need
|
||||
-------------------------------------------------------
|
||||
|
||||
- Perl & Python
|
||||
- Podman/Docker: see misc/podman/rebuild-stubs - this
|
||||
is the preferred way of rebuilding the stubs
|
||||
|
||||
- otherwise you will need:
|
||||
- a Linux host system with Perl, Python2 and some older compat-libs
|
||||
- upx-stubtools - a number of cross-assemblers and cross-compilers.
|
||||
Precompiled binaries for amd64-linux hosts are available from
|
||||
https://github.com/upx/upx-stubtools/releases
|
||||
|
||||
|
||||
Developer quick start
|
||||
---------------------
|
||||
1) $ mkdir my-upx; cd my-upx # new directory for safety and convenience
|
||||
2) $ git clone https://github.com/upx/upx.git
|
||||
3) $ git clone https://github.com/upx/upx-testsuite.git
|
||||
4) # Optional for re-building stubs:
|
||||
4a) $ pushd upx/src/stub # my-upx/upx/src/stub
|
||||
4b) $ wget https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz
|
||||
# Extract to $HOME/bin/bin-upx or $HOME/local/bin/bin-upx.
|
||||
# See directions in: https://github.com/upx/upx-stubtools
|
||||
4c) $ make clean; make # verify that you can re-build stubs
|
||||
4d) $ popd # my-upx
|
||||
5) $ cd upx # my-upx/upx
|
||||
6) $ git submodule update --init # compression algorithms, etc.
|
||||
# DO NOT TOUCH vendor/...
|
||||
# After a git merge/pull/etc, then use "git status"
|
||||
# to check whether the vendor directory is clean;
|
||||
# if not, then update via "git submodule update".
|
||||
# If stuck, then reset via "rm -rf vendor; git submodule update --init".
|
||||
7) $ mkdir -p build/debug build/release
|
||||
8) $ pushd build/debug # my-upx/upx/build/debug
|
||||
9) $ cmake ../.. # configure cmake
|
||||
10) $ cmake --build . --verbose # optional "--verbose"
|
||||
# This relies on stub/*.h, which YOU must re-build if necessary.
|
||||
# When in doubt, then use "cd src/stub; make clean; make".
|
||||
11) $ popd # my-upx/upx
|
||||
12) $ cd src # my-upx/upx/src
|
||||
12a) On MacOS: install homebrew (https:://brew.sh), then "brew install coreutils"
|
||||
and put <some_prefix>/opt/coreutils/libexec/gnubin into PATH so that
|
||||
"readlink -en" and "sha256sum -b" work.
|
||||
13) $ make run-testsuite 2>&1 | tee testsuite.log
|
||||
|
||||
- upx-stubtools - a number of cross-assemblers and cross-compilers.
|
||||
Precompiled binaries for i386-linux hosts are available from
|
||||
https://github.com/upx/upx-stubtools/releases
|
||||
|
||||
|
||||
Misc. notes
|
||||
@@ -114,9 +118,9 @@ Misc. notes
|
||||
- Use gcc extensions and other compiler specific stuff only through
|
||||
macros.
|
||||
|
||||
***
|
||||
|
||||
Some conventions:
|
||||
-----------------
|
||||
|
||||
- follow our coding style
|
||||
- indent level = 4
|
||||
@@ -125,17 +129,4 @@ Some conventions:
|
||||
- Use throwSomeException() functions instead of throw SomeException():
|
||||
this makes the code shorter if used often.
|
||||
|
||||
***
|
||||
|
||||
Patches/Contributions
|
||||
|
||||
- Please send us bug fixes/contributions only using
|
||||
|
||||
diff -u oldfile newfile
|
||||
|
||||
or
|
||||
|
||||
diff -uNr olddirectory newdirectory
|
||||
|
||||
|
||||
# vim:set ts=4 sw=4 et:
|
||||
|
||||
+8
-9
@@ -1,14 +1,14 @@
|
||||
ooooo ooo ooooooooo. ooooooo ooooo
|
||||
`888' `8' `888 `Y88. `8888 d8'
|
||||
888 8 888 .d88' Y888..8P
|
||||
888 8 888ooo88P' `8888'
|
||||
888 8 888 .8PY888.
|
||||
`88. .8' 888 d8' `888b
|
||||
`YbodP' o888o o888o o88888o
|
||||
ooooo ooo ooooooooo. ooooooo ooooo
|
||||
`888' `8' `888 `Y88. `8888 d8'
|
||||
888 8 888 .d88' Y888..8P
|
||||
888 8 888ooo88P' `8888'
|
||||
888 8 888 .8PY888.
|
||||
`88. .8' 888 d8' `888b
|
||||
`YbodP' o888o o888o o88888o
|
||||
|
||||
|
||||
The Ultimate Packer for eXecutables
|
||||
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
Copyright (c) 1996-2023 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
https://upx.github.io
|
||||
|
||||
|
||||
@@ -48,4 +48,3 @@ win32/pe
|
||||
* certificates in the image
|
||||
* compressing files which contain a big BSS requires lots of memory
|
||||
during compression
|
||||
|
||||
+34
-40
@@ -1,21 +1,8 @@
|
||||
#
|
||||
# UPX doc Makefile - needs GNU make 3.81 or better
|
||||
# UPX doc Makefile - needs GNU make, pod2html, pod2man and pod2text
|
||||
#
|
||||
|
||||
MAKEFLAGS += -rR
|
||||
.SUFFIXES:
|
||||
SHELL = /bin/sh
|
||||
|
||||
# internal make variables
|
||||
comma := ,
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
tab := $(empty) $(empty)
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# //
|
||||
# ************************************************************************/
|
||||
BUILT_SOURCES = upx.1 upx-doc.html upx-doc.txt
|
||||
|
||||
top_srcdir ?= ..
|
||||
|
||||
@@ -23,55 +10,62 @@ PACKAGE = upx
|
||||
VERSION_DATE := $(shell sed -n 's/^.*UPX_VERSION_DATE_ISO .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
|
||||
VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
|
||||
|
||||
# internal make variables
|
||||
comma := ,
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
tab := $(empty) $(empty)
|
||||
|
||||
RTRIM := sed -e 's/[ $(tab)]*$$//'
|
||||
DETAB2 := sed -e 's/$(tab)/ /g'
|
||||
|
||||
BUILT_SOURCES = upx.1 upx.doc upx.html upx.man upx.ps upx.tex
|
||||
BUILT_SOURCES = upx.1 upx.doc upx.html
|
||||
#***********************************************************************
|
||||
# targets
|
||||
#***********************************************************************
|
||||
|
||||
.DEFAULT_GOAL = all
|
||||
|
||||
###
|
||||
### targets
|
||||
###
|
||||
all: $(BUILT_SOURCES) PHONY
|
||||
|
||||
all: $(BUILT_SOURCES)
|
||||
mostlyclean clean distclean maintainer-clean: PHONY
|
||||
rm -f $(BUILT_SOURCES) ./pod2htm*
|
||||
|
||||
mostlyclean clean distclean maintainer-clean:
|
||||
rm -f $(BUILT_SOURCES) pod2htm*
|
||||
#***********************************************************************
|
||||
# rules
|
||||
#***********************************************************************
|
||||
|
||||
.PHONY: all mostlyclean clean distclean maintainer-clean
|
||||
|
||||
|
||||
###
|
||||
### rules
|
||||
###
|
||||
|
||||
.SUFFIXES: .1 .doc .html .man .pod .ps .tex
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .1 .html .man .pod .ps .tex .txt
|
||||
|
||||
%.1 : %.pod
|
||||
pod2man --center=" " --release="$(PACKAGE) $(VERSION)" --date="$(VERSION_DATE)" $< | $(RTRIM) > $@
|
||||
test -s $@
|
||||
|
||||
%.doc : %.pod
|
||||
pod2text < $< | $(RTRIM) > $@
|
||||
|
||||
%.html : %.pod
|
||||
%-doc.html : %.pod
|
||||
pod2html --noindex $< | $(RTRIM) | $(DETAB2) > $@
|
||||
@rm -f pod2htm*
|
||||
@rm -f ./pod2htm*
|
||||
test -s $@
|
||||
|
||||
%.man : %.1
|
||||
nroff -man $< | $(RTRIM) > $@
|
||||
test -s $@
|
||||
|
||||
%.ps : %.1
|
||||
groff -man $< | $(RTRIM) > $@
|
||||
test -s $@
|
||||
|
||||
%.tex : %.pod
|
||||
pod2latex $<
|
||||
test -s $@
|
||||
|
||||
%-doc.txt : %.pod
|
||||
pod2text < $< | $(RTRIM) > $@
|
||||
test -s $@
|
||||
|
||||
###
|
||||
### dependencies
|
||||
###
|
||||
#***********************************************************************
|
||||
# dependencies
|
||||
#***********************************************************************
|
||||
|
||||
$(BUILT_SOURCES): $(top_srcdir)/src/version.h $(MAKEFILE_LIST)
|
||||
.DELETE_ON_ERROR: $(BUILT_SOURCES)
|
||||
|
||||
.PHONY: PHONY
|
||||
|
||||
+12
-11
@@ -1,14 +1,14 @@
|
||||
ooooo ooo ooooooooo. ooooooo ooooo
|
||||
`888' `8' `888 `Y88. `8888 d8'
|
||||
888 8 888 .d88' Y888..8P
|
||||
888 8 888ooo88P' `8888'
|
||||
888 8 888 .8PY888.
|
||||
`88. .8' 888 d8' `888b
|
||||
`YbodP' o888o o888o o88888o
|
||||
ooooo ooo ooooooooo. ooooooo ooooo
|
||||
`888' `8' `888 `Y88. `8888 d8'
|
||||
888 8 888 .d88' Y888..8P
|
||||
888 8 888ooo88P' `8888'
|
||||
888 8 888 .8PY888.
|
||||
`88. .8' 888 d8' `888b
|
||||
`YbodP' o888o o888o o88888o
|
||||
|
||||
|
||||
The Ultimate Packer for eXecutables
|
||||
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
Copyright (c) 1996-2023 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
https://upx.github.io
|
||||
|
||||
|
||||
@@ -41,12 +41,14 @@ Joergen Ibsen <jibz@hotmail.com> and d'b
|
||||
for the relocation & address optimization ideas
|
||||
John S. Fine <johnfine@erols.com>
|
||||
for the new version of the dos/exe decompressor
|
||||
Kornel Pal
|
||||
for the EFI support
|
||||
Lukundoo <Lukundoo@softhome.net>
|
||||
for beta testing
|
||||
Michael Devore
|
||||
for initial dos/exe device driver support
|
||||
Oleg V. Volkov <rover@lglobus.ru>
|
||||
for various FreeBSD specific informations
|
||||
for various FreeBSD specific information
|
||||
The Owl & G-RoM
|
||||
for the --compress-icons fix
|
||||
Ralph Roth <RalphRoth@gmx.net>
|
||||
@@ -55,7 +57,6 @@ Salvador Eduardo Tropea
|
||||
for beta testing
|
||||
Stefan Widmann
|
||||
for the win32/pe TLS callback support
|
||||
The WINE project (http://www.winehq.com/)
|
||||
The WINE project (https://www.winehq.com/)
|
||||
for lots of useful information found in their PE loader sources
|
||||
Natascha
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
Decompressing ELF Directly to Memory on Linux/x86
|
||||
Copyright (C) 2000-2017 John F. Reiser jreiser@BitWagon.com
|
||||
Copyright (C) 2000-2023 John F. Reiser jreiser@BitWagon.com
|
||||
|
||||
References:
|
||||
<elf.h> definitions for the ELF file format
|
||||
|
||||
Generated
+807
@@ -0,0 +1,807 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>upx - compress or expand executable files</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:root@localhost" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<h1 id="NAME">NAME</h1>
|
||||
|
||||
<p>upx - compress or expand executable files</p>
|
||||
|
||||
<h1 id="SYNOPSIS">SYNOPSIS</h1>
|
||||
|
||||
<p><b>upx</b> <span style="white-space: nowrap;">[ <i>command</i> ]</span> <span style="white-space: nowrap;">[ <i>options</i> ]</span> <i>filename</i>...</p>
|
||||
|
||||
<h1 id="ABSTRACT">ABSTRACT</h1>
|
||||
|
||||
<pre><code> The Ultimate Packer for eXecutables
|
||||
Copyright (c) 1996-2023 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
https://upx.github.io</code></pre>
|
||||
|
||||
<p><b>UPX</b> is a portable, extendable, high-performance executable packer for several different executable formats. It achieves an excellent compression ratio and offers <i>*very*</i> fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported, because of in-place decompression.</p>
|
||||
|
||||
<h1 id="DISCLAIMER">DISCLAIMER</h1>
|
||||
|
||||
<p><b>UPX</b> comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING.</p>
|
||||
|
||||
<p>Please report all problems or suggestions to the authors. Thanks.</p>
|
||||
|
||||
<h1 id="SECURITY-CONTEXT">SECURITY CONTEXT</h1>
|
||||
|
||||
<p>IMPORTANT NOTE: <b>UPX</b> inherits the security context of any files it handles.</p>
|
||||
|
||||
<p>This means that packing, unpacking, or even testing or listing a file requires the same security considerations as actually executing the file.</p>
|
||||
|
||||
<p>Use <b>UPX</b> on trusted files only!</p>
|
||||
|
||||
<h1 id="DESCRIPTION">DESCRIPTION</h1>
|
||||
|
||||
<p><b>UPX</b> is a versatile executable packer with the following features:</p>
|
||||
|
||||
<pre><code>- secure: as UPX is documented Open Source since many years any relevant
|
||||
Security/Antivirus software is able to peek inside UPX compressed
|
||||
apps to verify them
|
||||
|
||||
- excellent compression ratio: typically compresses better than Zip,
|
||||
use UPX to decrease the size of your distribution !
|
||||
|
||||
- very fast decompression: more than 500 MB/sec on any reasonably modern
|
||||
machine
|
||||
|
||||
- no memory overhead for your compressed executables for most of the
|
||||
supported formats because of in-place decompression
|
||||
|
||||
- safe: you can list, test and unpack your executables.
|
||||
Also, a checksum of both the compressed and uncompressed file is
|
||||
maintained internally.
|
||||
|
||||
- universal: UPX can pack a number of executable formats, including
|
||||
Windows programs and DLLs, macOS apps and Linux executables
|
||||
|
||||
- portable: UPX is written in portable endian-neutral C++
|
||||
|
||||
- extendable: because of the class layout it's very easy to support
|
||||
new executable formats or add new compression algorithms
|
||||
|
||||
- free: UPX is distributed with full source code under the GNU General
|
||||
Public License v2+, with special exceptions granting the free usage
|
||||
for commercial programs</code></pre>
|
||||
|
||||
<p>You probably understand now why we call <b>UPX</b> the "<i>ultimate</i>" executable packer.</p>
|
||||
|
||||
<h1 id="COMMANDS">COMMANDS</h1>
|
||||
|
||||
<h2 id="Compress">Compress</h2>
|
||||
|
||||
<p>This is the default operation, eg. <b>upx yourfile.exe</b> will compress the file specified on the command line.</p>
|
||||
|
||||
<h2 id="Decompress">Decompress</h2>
|
||||
|
||||
<p>All <b>UPX</b> supported file formats can be unpacked using the <b>-d</b> switch, eg. <b>upx -d yourfile.exe</b> will uncompress the file you've just compressed.</p>
|
||||
|
||||
<h2 id="Test">Test</h2>
|
||||
|
||||
<p>The <b>-t</b> command tests the integrity of the compressed and uncompressed data, eg. <b>upx -t yourfile.exe</b> check whether your file can be safely decompressed. Note, that this command doesn't check the whole file, only the part that will be uncompressed during program execution. This means that you should not use this command instead of a virus checker.</p>
|
||||
|
||||
<h2 id="List">List</h2>
|
||||
|
||||
<p>The <b>-l</b> command prints out some information about the compressed files specified on the command line as parameters, eg <b>upx -l yourfile.exe</b> shows the compressed / uncompressed size and the compression ratio of <i>yourfile.exe</i>.</p>
|
||||
|
||||
<h1 id="OPTIONS">OPTIONS</h1>
|
||||
|
||||
<p><b>-q</b>: be quiet, suppress warnings</p>
|
||||
|
||||
<p><b>-q -q</b> (or <b>-qq</b>): be very quiet, suppress errors</p>
|
||||
|
||||
<p><b>-q -q -q</b> (or <b>-qqq</b>): produce no output at all</p>
|
||||
|
||||
<p><b>--help</b>: prints the help</p>
|
||||
|
||||
<p><b>--version</b>: print the version of <b>UPX</b></p>
|
||||
|
||||
<p><b>--exact</b>: when compressing, require to be able to get a byte-identical file after decompression with option <b>-d</b>. [NOTE: this is work in progress and is not supported for all formats yet. If you do care, as a workaround you can compress and then decompress your program a first time - any further compress-decompress steps should then yield byte-identical results as compared to the first decompressed version.]</p>
|
||||
|
||||
<p><b>-k</b>: keep backup files</p>
|
||||
|
||||
<p><b>-o file</b>: write output to file</p>
|
||||
|
||||
<p>[ ...more docs need to be written... - type `<b>upx --help</b>' for now ]</p>
|
||||
|
||||
<h1 id="COMPRESSION-LEVELS-TUNING">COMPRESSION LEVELS & TUNING</h1>
|
||||
|
||||
<p><b>UPX</b> offers ten different compression levels from <b>-1</b> to <b>-9</b>, and <b>--best</b>. The default compression level is <b>-8</b> for files smaller than 512 KiB, and <b>-7</b> otherwise.</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><p>Compression levels 1, 2 and 3 are pretty fast.</p>
|
||||
|
||||
</li>
|
||||
<li><p>Compression levels 4, 5 and 6 achieve a good time/ratio performance.</p>
|
||||
|
||||
</li>
|
||||
<li><p>Compression levels 7, 8 and 9 favor compression ratio over speed.</p>
|
||||
|
||||
</li>
|
||||
<li><p>Compression level <b>--best</b> may take a long time.</p>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>Note that compression level <b>--best</b> can be somewhat slow for large files, but you definitely should use it when releasing a final version of your program.</p>
|
||||
|
||||
<p>Quick info for achieving the best compression ratio:</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><p>Try <b>upx --brute --no-lzma myfile.exe</b> or even <b>upx --ultra-brute --no-lzma myfile.exe</b>.</p>
|
||||
|
||||
</li>
|
||||
<li><p>The option <b>--lzma</b> enables LZMA compression, which compresses better but is *significantly slower* at decompression. You probably do not want to use it for large files.</p>
|
||||
|
||||
<p>(Note that <b>--lzma</b> is automatically enabled by <b>--all-methods</b> and <b>--brute</b>, use <b>--no-lzma</b> to override.)</p>
|
||||
|
||||
</li>
|
||||
<li><p>Try if <b>--overlay=strip</b> works.</p>
|
||||
|
||||
</li>
|
||||
<li><p>For win32/pe programs there's <b>--strip-relocs=0</b>. See notes below.</p>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h1 id="OVERLAY-HANDLING-OPTIONS">OVERLAY HANDLING OPTIONS</h1>
|
||||
|
||||
<p>Info: An "overlay" means auxiliary data attached after the logical end of an executable, and it often contains application specific data (this is a common practice to avoid an extra data file, though it would be better to use resource sections).</p>
|
||||
|
||||
<p><b>UPX</b> handles overlays like many other executable packers do: it simply copies the overlay after the compressed image. This works with some files, but doesn't work with others, depending on how an application actually accesses this overlaid data.</p>
|
||||
|
||||
<pre><code>--overlay=copy Copy any extra data attached to the file. [DEFAULT]
|
||||
|
||||
--overlay=strip Strip any overlay from the program instead of
|
||||
copying it. Be warned, this may make the compressed
|
||||
program crash or otherwise unusable.
|
||||
|
||||
--overlay=skip Refuse to compress any program which has an overlay.</code></pre>
|
||||
|
||||
<h1 id="ENVIRONMENT-VARIABLE">ENVIRONMENT VARIABLE</h1>
|
||||
|
||||
<p>The environment variable <b>UPX</b> can hold a set of default options for <b>UPX</b>. These options are interpreted first and can be overwritten by explicit command line parameters. For example:</p>
|
||||
|
||||
<pre><code>for DOS/Windows: set UPX=-9 --compress-icons#0
|
||||
for sh/ksh/zsh: UPX="-9 --compress-icons=0"; export UPX
|
||||
for csh/tcsh: setenv UPX "-9 --compress-icons=0"</code></pre>
|
||||
|
||||
<p>Under DOS/Windows you must use '#' instead of '=' when setting the environment variable because of a COMMAND.COM limitation.</p>
|
||||
|
||||
<p>Not all of the options are valid in the environment variable - <b>UPX</b> will tell you.</p>
|
||||
|
||||
<p>You can explicitly use the <b>--no-env</b> option to ignore the environment variable.</p>
|
||||
|
||||
<h1 id="NOTES-FOR-THE-SUPPORTED-EXECUTABLE-FORMATS">NOTES FOR THE SUPPORTED EXECUTABLE FORMATS</h1>
|
||||
|
||||
<h2 id="NOTES-FOR-ATARI-TOS">NOTES FOR ATARI/TOS</h2>
|
||||
|
||||
<p>This is the executable format used by the Atari ST/TT, a Motorola 68000 based personal computer which was popular in the late '80s. Support of this format is only because of nostalgic feelings of one of the authors and serves no practical purpose :-). See https://freemint.github.io for more info.</p>
|
||||
|
||||
<p>Packed programs will be byte-identical to the original after uncompression. All debug information will be stripped, though.</p>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-BVMLINUZ-I386">NOTES FOR BVMLINUZ/I386</h2>
|
||||
|
||||
<p>Same as vmlinuz/i386.</p>
|
||||
|
||||
<h2 id="NOTES-FOR-DOS-COM">NOTES FOR DOS/COM</h2>
|
||||
|
||||
<p>Obviously <b>UPX</b> won't work with executables that want to read data from themselves (like some commandline utilities that ship with Win95/98/ME).</p>
|
||||
|
||||
<p>Compressed programs only work on a 286+.</p>
|
||||
|
||||
<p>Packed programs will be byte-identical to the original after uncompression.</p>
|
||||
|
||||
<p>Maximum uncompressed size: ~65100 bytes.</p>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--8086 Create an executable that works on any 8086 CPU.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-DOS-EXE">NOTES FOR DOS/EXE</h2>
|
||||
|
||||
<p>dos/exe stands for all "normal" 16-bit DOS executables.</p>
|
||||
|
||||
<p>Obviously <b>UPX</b> won't work with executables that want to read data from themselves (like some command line utilities that ship with Win95/98/ME).</p>
|
||||
|
||||
<p>Compressed programs only work on a 286+.</p>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--8086 Create an executable that works on any 8086 CPU.
|
||||
|
||||
--no-reloc Use no relocation records in the exe header.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-DOS-SYS">NOTES FOR DOS/SYS</h2>
|
||||
|
||||
<p>Compressed programs only work on a 286+.</p>
|
||||
|
||||
<p>Packed programs will be byte-identical to the original after uncompression.</p>
|
||||
|
||||
<p>Maximum uncompressed size: ~65350 bytes.</p>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--8086 Create an executable that works on any 8086 CPU.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-DJGPP2-COFF">NOTES FOR DJGPP2/COFF</h2>
|
||||
|
||||
<p>First of all, it is recommended to use <b>UPX</b> *instead* of <b>strip</b>. strip has the very bad habit of replacing your stub with its own (outdated) version. Additionally <b>UPX</b> corrects a bug/feature in strip v2.8.x: it will fix the 4 KiB alignment of the stub.</p>
|
||||
|
||||
<p><b>UPX</b> includes the full functionality of stubify. This means it will automatically stubify your COFF files. Use the option <b>--coff</b> to disable this functionality (see below).</p>
|
||||
|
||||
<p><b>UPX</b> automatically handles Allegro packfiles.</p>
|
||||
|
||||
<p>The DLM format (a rather exotic shared library extension) is not supported.</p>
|
||||
|
||||
<p>Packed programs will be byte-identical to the original after uncompression. All debug information and trailing garbage will be stripped, though.</p>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--coff Produce COFF output instead of EXE. By default
|
||||
UPX keeps your current stub.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-LINUX-general">NOTES FOR LINUX [general]</h2>
|
||||
|
||||
<p>Introduction</p>
|
||||
|
||||
<pre><code>Linux/386 support in UPX consists of 3 different executable formats,
|
||||
one optimized for ELF executables ("linux/elf386"), one optimized
|
||||
for shell scripts ("linux/sh386"), and one generic format
|
||||
("linux/386").
|
||||
|
||||
We will start with a general discussion first, but please
|
||||
also read the relevant docs for each of the individual formats.
|
||||
|
||||
Also, there is special support for bootable kernels - see the
|
||||
description of the vmlinuz/386 format.</code></pre>
|
||||
|
||||
<p>General user's overview</p>
|
||||
|
||||
<pre><code>Running a compressed executable program trades less space on a
|
||||
``permanent'' storage medium (such as a hard disk, floppy disk,
|
||||
CD-ROM, flash memory, EPROM, etc.) for more space in one or more
|
||||
``temporary'' storage media (such as RAM, swap space, /tmp, etc.).
|
||||
Running a compressed executable also requires some additional CPU
|
||||
cycles to generate the compressed executable in the first place,
|
||||
and to decompress it at each invocation.
|
||||
|
||||
How much space is traded? It depends on the executable, but many
|
||||
programs save 30% to 50% of permanent disk space. How much CPU
|
||||
overhead is there? Again, it depends on the executable, but
|
||||
decompression speed generally is at least many megabytes per second,
|
||||
and frequently is limited by the speed of the underlying disk
|
||||
or network I/O.
|
||||
|
||||
Depending on the statistics of usage and access, and the relative
|
||||
speeds of CPU, RAM, swap space, /tmp, and file system storage, then
|
||||
invoking and running a compressed executable can be faster than
|
||||
directly running the corresponding uncompressed program.
|
||||
The operating system might perform fewer expensive I/O operations
|
||||
to invoke the compressed program. Paging to or from swap space
|
||||
or /tmp might be faster than paging from the general file system.
|
||||
``Medium-sized'' programs which access about 1/3 to 1/2 of their
|
||||
stored program bytes can do particularly well with compression.
|
||||
Small programs tend not to benefit as much because the absolute
|
||||
savings is less. Big programs tend not to benefit proportionally
|
||||
because each invocation may use only a small fraction of the program,
|
||||
yet UPX decompresses the entire program before invoking it.
|
||||
But in environments where disk or flash memory storage is limited,
|
||||
then compression may win anyway.
|
||||
|
||||
Currently, executables compressed by UPX do not share RAM at runtime
|
||||
in the way that executables mapped from a file system do. As a
|
||||
result, if the same program is run simultaneously by more than one
|
||||
process, then using the compressed version will require more RAM and/or
|
||||
swap space. So, shell programs (bash, csh, etc.) and ``make''
|
||||
might not be good candidates for compression.
|
||||
|
||||
UPX recognizes three executable formats for Linux: Linux/elf386,
|
||||
Linux/sh386, and Linux/386. Linux/386 is the most generic format;
|
||||
it accommodates any file that can be executed. At runtime, the UPX
|
||||
decompression stub re-creates in /tmp a copy of the original file,
|
||||
and then the copy is (re-)executed with the same arguments.
|
||||
ELF binary executables prefer the Linux/elf386 format by default,
|
||||
because UPX decompresses them directly into RAM, uses only one
|
||||
exec, does not use space in /tmp, and does not use /proc.
|
||||
Shell scripts where the underlying shell accepts a ``-c'' argument
|
||||
can use the Linux/sh386 format. UPX decompresses the shell script
|
||||
into low memory, then maps the shell and passes the entire text of the
|
||||
script as an argument with a leading ``-c''.</code></pre>
|
||||
|
||||
<p>General benefits:</p>
|
||||
|
||||
<pre><code>- UPX can compress all executables, be it AOUT, ELF, libc4, libc5,
|
||||
libc6, Shell/Perl/Python/... scripts, standalone Java .class
|
||||
binaries, or whatever...
|
||||
All scripts and programs will work just as before.
|
||||
|
||||
- Compressed programs are completely self-contained. No need for
|
||||
any external program.
|
||||
|
||||
- UPX keeps your original program untouched. This means that
|
||||
after decompression you will have a byte-identical version,
|
||||
and you can use UPX as a file compressor just like gzip.
|
||||
[ Note that UPX maintains a checksum of the file internally,
|
||||
so it is indeed a reliable alternative. ]
|
||||
|
||||
- As the stub only uses syscalls and isn't linked against libc it
|
||||
should run under any Linux configuration that can run ELF
|
||||
binaries.
|
||||
|
||||
- For the same reason compressed executables should run under
|
||||
FreeBSD and other systems which can run Linux binaries.
|
||||
[ Please send feedback on this topic ]</code></pre>
|
||||
|
||||
<p>General drawbacks:</p>
|
||||
|
||||
<pre><code>- It is not advisable to compress programs which usually have many
|
||||
instances running (like `sh' or `make') because the common segments of
|
||||
compressed programs won't be shared any longer between different
|
||||
processes.
|
||||
|
||||
- `ldd' and `size' won't show anything useful because all they
|
||||
see is the statically linked stub. Since version 0.82 the section
|
||||
headers are stripped from the UPX stub and `size' doesn't even
|
||||
recognize the file format. The file patches/patch-elfcode.h has a
|
||||
patch to fix this bug in `size' and other programs which use GNU BFD.</code></pre>
|
||||
|
||||
<p>General notes:</p>
|
||||
|
||||
<pre><code>- As UPX leaves your original program untouched it is advantageous
|
||||
to strip it before compression.
|
||||
|
||||
- If you compress a script you will lose platform independence -
|
||||
this could be a problem if you are using NFS mounted disks.
|
||||
|
||||
- Compression of suid, guid and sticky-bit programs is rejected
|
||||
because of possible security implications.
|
||||
|
||||
- For the same reason there is no sense in making any compressed
|
||||
program suid.
|
||||
|
||||
- Obviously UPX won't work with executables that want to read data
|
||||
from themselves. E.g., this might be a problem for Perl scripts
|
||||
which access their __DATA__ lines.
|
||||
|
||||
- In case of internal errors the stub will abort with exitcode 127.
|
||||
Typical reasons for this to happen are that the program has somehow
|
||||
been modified after compression.
|
||||
Running `strace -o strace.log compressed_file' will tell you more.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-LINUX-ELF386">NOTES FOR LINUX/ELF386</h2>
|
||||
|
||||
<p>Please read the general Linux description first.</p>
|
||||
|
||||
<p>The linux/elf386 format decompresses directly into RAM, uses only one exec, does not use space in /tmp, and does not use /proc.</p>
|
||||
|
||||
<p>Linux/elf386 is automatically selected for Linux ELF executables.</p>
|
||||
|
||||
<p>Packed programs will be byte-identical to the original after uncompression.</p>
|
||||
|
||||
<p>How it works:</p>
|
||||
|
||||
<pre><code>For ELF executables, UPX decompresses directly to memory, simulating
|
||||
the mapping that the operating system kernel uses during exec(),
|
||||
including the PT_INTERP program interpreter (if any).
|
||||
The brk() is set by a special PT_LOAD segment in the compressed
|
||||
executable itself. UPX then wipes the stack clean except for
|
||||
arguments, environment variables, and Elf_auxv entries (this is
|
||||
required by bugs in the startup code of /lib/ld-linux.so as of
|
||||
May 2000), and transfers control to the program interpreter or
|
||||
the e_entry address of the original executable.
|
||||
|
||||
The UPX stub is about 1700 bytes long, partly written in assembler
|
||||
and only uses kernel syscalls. It is not linked against any libc.</code></pre>
|
||||
|
||||
<p>Specific drawbacks:</p>
|
||||
|
||||
<pre><code>- For linux/elf386 and linux/sh386 formats, you will be relying on
|
||||
RAM and swap space to hold all of the decompressed program during
|
||||
the lifetime of the process. If you already use most of your swap
|
||||
space, then you may run out. A system that is "out of memory"
|
||||
can become fragile. Many programs do not react gracefully when
|
||||
malloc() returns 0. With newer Linux kernels, the kernel
|
||||
may decide to kill some processes to regain memory, and you
|
||||
may not like the kernel's choice of which to kill. Running
|
||||
/usr/bin/top is one way to check on the usage of swap space.</code></pre>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>(none)</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-LINUX-SH386">NOTES FOR LINUX/SH386</h2>
|
||||
|
||||
<p>Please read the general Linux description first.</p>
|
||||
|
||||
<p>Shell scripts where the underling shell accepts a ``-c'' argument can use the Linux/sh386 format. <b>UPX</b> decompresses the shell script into low memory, then maps the shell and passes the entire text of the script as an argument with a leading ``-c''. It does not use space in /tmp, and does not use /proc.</p>
|
||||
|
||||
<p>Linux/sh386 is automatically selected for shell scripts that use a known shell.</p>
|
||||
|
||||
<p>Packed programs will be byte-identical to the original after uncompression.</p>
|
||||
|
||||
<p>How it works:</p>
|
||||
|
||||
<pre><code>For shell script executables (files beginning with "#!/" or "#! /")
|
||||
where the shell is known to accept "-c <command>", UPX decompresses
|
||||
the file into low memory, then maps the shell (and its PT_INTERP),
|
||||
and passes control to the shell with the entire decompressed file
|
||||
as the argument after "-c". Known shells are sh, ash, bash, bsh, csh,
|
||||
ksh, tcsh, pdksh. Restriction: UPX cannot use this method
|
||||
for shell scripts which use the one optional string argument after
|
||||
the shell name in the script (example: "#! /bin/sh option3\n".)
|
||||
|
||||
The UPX stub is about 1700 bytes long, partly written in assembler
|
||||
and only uses kernel syscalls. It is not linked against any libc.</code></pre>
|
||||
|
||||
<p>Specific drawbacks:</p>
|
||||
|
||||
<pre><code>- For linux/elf386 and linux/sh386 formats, you will be relying on
|
||||
RAM and swap space to hold all of the decompressed program during
|
||||
the lifetime of the process. If you already use most of your swap
|
||||
space, then you may run out. A system that is "out of memory"
|
||||
can become fragile. Many programs do not react gracefully when
|
||||
malloc() returns 0. With newer Linux kernels, the kernel
|
||||
may decide to kill some processes to regain memory, and you
|
||||
may not like the kernel's choice of which to kill. Running
|
||||
/usr/bin/top is one way to check on the usage of swap space.</code></pre>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>(none)</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-LINUX-386">NOTES FOR LINUX/386</h2>
|
||||
|
||||
<p>Please read the general Linux description first.</p>
|
||||
|
||||
<p>The generic linux/386 format decompresses to /tmp and needs /proc file system support. It starts the decompressed program via the execve() syscall.</p>
|
||||
|
||||
<p>Linux/386 is only selected if the specialized linux/elf386 and linux/sh386 won't recognize a file.</p>
|
||||
|
||||
<p>Packed programs will be byte-identical to the original after uncompression.</p>
|
||||
|
||||
<p>How it works:</p>
|
||||
|
||||
<pre><code>For files which are not ELF and not a script for a known "-c" shell,
|
||||
UPX uses kernel execve(), which first requires decompressing to a
|
||||
temporary file in the file system. Interestingly -
|
||||
because of the good memory management of the Linux kernel - this
|
||||
often does not introduce a noticeable delay, and in fact there
|
||||
will be no disk access at all if you have enough free memory as
|
||||
the entire process takes places within the file system buffers.
|
||||
|
||||
A compressed executable consists of the UPX stub and an overlay
|
||||
which contains the original program in a compressed form.
|
||||
|
||||
The UPX stub is a statically linked ELF executable and does
|
||||
the following at program startup:
|
||||
|
||||
1) decompress the overlay to a temporary location in /tmp
|
||||
2) open the temporary file for reading
|
||||
3) try to delete the temporary file and start (execve)
|
||||
the uncompressed program in /tmp using /proc/<pid>/fd/X as
|
||||
attained by step 2)
|
||||
4) if that fails, fork off a subprocess to clean up and
|
||||
start the program in /tmp in the meantime
|
||||
|
||||
The UPX stub is about 1700 bytes long, partly written in assembler
|
||||
and only uses kernel syscalls. It is not linked against any libc.</code></pre>
|
||||
|
||||
<p>Specific drawbacks:</p>
|
||||
|
||||
<pre><code>- You need additional free disk space for the uncompressed program
|
||||
in your /tmp directory. This program is deleted immediately after
|
||||
decompression, but you still need it for the full execution time
|
||||
of the program.
|
||||
|
||||
- You must have /proc file system support as the stub wants to open
|
||||
/proc/<pid>/exe and needs /proc/<pid>/fd/X. This also means that you
|
||||
cannot compress programs that are used during the boot sequence
|
||||
before /proc is mounted.
|
||||
|
||||
- Utilities like `top' will display numerical values in the process
|
||||
name field. This is because Linux computes the process name from
|
||||
the first argument of the last execve syscall (which is typically
|
||||
something like /proc/<pid>/fd/3).
|
||||
|
||||
- Because of temporary decompression to disk the decompression speed
|
||||
is not as fast as with the other executable formats. Still, I can see
|
||||
no noticeable delay when starting programs like my ~3 MiB emacs (which
|
||||
is less than 1 MiB when compressed :-).</code></pre>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--force-execve Force the use of the generic linux/386 "execve"
|
||||
format, i.e. do not try the linux/elf386 and
|
||||
linux/sh386 formats.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-PS1-EXE">NOTES FOR PS1/EXE</h2>
|
||||
|
||||
<p>This is the executable format used by the Sony PlayStation (PSone), a MIPS R3000 based gaming console which is popular since the late '90s. Support of this format is very similar to the Atari one, because of nostalgic feelings of one of the authors.</p>
|
||||
|
||||
<p>Packed programs will be byte-identical to the original after uncompression, until further notice.</p>
|
||||
|
||||
<p>Maximum uncompressed size: ~1.89 / ~7.60 MiB.</p>
|
||||
|
||||
<p>Notes:</p>
|
||||
|
||||
<pre><code>- UPX creates as default a suitable executable for CD-Mastering
|
||||
and console transfer. For a CD-Master main executable you could also try
|
||||
the special option "--boot-only" as described below.
|
||||
It has been reported that upx packed executables are fully compatible with
|
||||
the Sony PlayStation 2 (PS2, PStwo) and Sony PlayStation Portable (PSP) in
|
||||
Sony PlayStation (PSone) emulation mode.
|
||||
|
||||
- Normally the packed files use the same memory areas like the uncompressed
|
||||
versions, so they will not override other memory areas while unpacking.
|
||||
If this isn't possible UPX will abort showing a 'packed data overlap'
|
||||
error. With the "--force" option UPX will relocate the loading address
|
||||
for the packed file, but this isn't a real problem if it is a single or
|
||||
the main executable.</code></pre>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--8-bit Uses 8 bit size compression [default: 32 bit]
|
||||
|
||||
--8mib-ram PSone has 8 MiB ram available [default: 2 MiB]
|
||||
|
||||
--boot-only This format is for main exes and CD-Mastering only !
|
||||
It may slightly improve the compression ratio,
|
||||
decompression routines are faster than default ones.
|
||||
But it cannot be used for console transfer !
|
||||
|
||||
--no-align This option disables CD mode 2 data sector format
|
||||
alignment. May slightly improves the compression ratio,
|
||||
but the compressed executable will not boot from a CD.
|
||||
Use it for console transfer only !</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-RTM32-PE-and-ARM-PE">NOTES FOR RTM32/PE and ARM/PE</h2>
|
||||
|
||||
<p>Same as win32/pe.</p>
|
||||
|
||||
<h2 id="NOTES-FOR-TMT-ADAM">NOTES FOR TMT/ADAM</h2>
|
||||
|
||||
<p>This format is used by the TMT Pascal compiler - see http://www.tmt.com/ .</p>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-VMLINUZ-386">NOTES FOR VMLINUZ/386</h2>
|
||||
|
||||
<p>The vmlinuz/386 and bvmlinuz/386 formats take a gzip-compressed bootable Linux kernel image ("vmlinuz", "zImage", "bzImage"), gzip-decompress it and re-compress it with the <b>UPX</b> compression method.</p>
|
||||
|
||||
<p>vmlinuz/386 is completely unrelated to the other Linux executable formats, and it does not share any of their drawbacks.</p>
|
||||
|
||||
<p>Notes:</p>
|
||||
|
||||
<pre><code>- Be sure that "vmlinuz/386" or "bvmlinuz/386" is displayed
|
||||
during compression - otherwise a wrong executable format
|
||||
may have been used, and the kernel won't boot.</code></pre>
|
||||
|
||||
<p>Benefits:</p>
|
||||
|
||||
<pre><code>- Better compression (but note that the kernel was already compressed,
|
||||
so the improvement is not as large as with other formats).
|
||||
Still, the bytes saved may be essential for special needs like
|
||||
boot disks.
|
||||
|
||||
For example, this is what I get for my 2.2.16 kernel:
|
||||
1589708 vmlinux
|
||||
641073 bzImage [original]
|
||||
560755 bzImage.upx [compressed by "upx -9"]
|
||||
|
||||
- Much faster decompression at kernel boot time (but kernel
|
||||
decompression speed is not really an issue these days).</code></pre>
|
||||
|
||||
<p>Drawbacks:</p>
|
||||
|
||||
<pre><code>(none)</code></pre>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-WATCOM-LE">NOTES FOR WATCOM/LE</h2>
|
||||
|
||||
<p><b>UPX</b> has been successfully tested with the following extenders: DOS4G, DOS4GW, PMODE/W, DOS32a, CauseWay. The WDOS/X extender is partly supported (for details see the file bugs BUGS).</p>
|
||||
|
||||
<p>DLLs and the LX format are not supported.</p>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--le Produce an unbound LE output instead of
|
||||
keeping the current stub.</code></pre>
|
||||
|
||||
<h2 id="NOTES-FOR-WIN32-PE">NOTES FOR WIN32/PE</h2>
|
||||
|
||||
<p>The PE support in <b>UPX</b> is quite stable now, but probably there are still some incompatibilities with some files.</p>
|
||||
|
||||
<p>Because of the way <b>UPX</b> (and other packers for this format) works, you can see increased memory usage of your compressed files because the whole program is loaded into memory at startup. If you start several instances of huge compressed programs you're wasting memory because the common segments of the program won't get shared across the instances. On the other hand if you're compressing only smaller programs, or running only one instance of larger programs, then this penalty is smaller, but it's still there.</p>
|
||||
|
||||
<p>If you're running executables from network, then compressed programs will load faster, and require less bandwidth during execution.</p>
|
||||
|
||||
<p>DLLs are supported. But UPX compressed DLLs can not share common data and code when they got used by multiple applications. So compressing msvcrt.dll is a waste of memory, but compressing the dll plugins of a particular application may be a better idea.</p>
|
||||
|
||||
<p>Screensavers are supported, with the restriction that the filename must end with ".scr" (as screensavers are handled slightly different than normal exe files).</p>
|
||||
|
||||
<p>UPX compressed PE files have some minor memory overhead (usually in the 10 - 30 KiB range) which can be seen by specifying the "-i" command line switch during compression.</p>
|
||||
|
||||
<p>Extra options available for this executable format:</p>
|
||||
|
||||
<pre><code>--compress-exports=0 Don't compress the export section.
|
||||
Use this if you plan to run the compressed
|
||||
program under Wine.
|
||||
--compress-exports=1 Compress the export section. [DEFAULT]
|
||||
Compression of the export section can improve the
|
||||
compression ratio quite a bit but may not work
|
||||
with all programs (like winword.exe).
|
||||
UPX never compresses the export section of a DLL
|
||||
regardless of this option.
|
||||
|
||||
--compress-icons=0 Don't compress any icons.
|
||||
--compress-icons=1 Compress all but the first icon.
|
||||
--compress-icons=2 Compress all icons which are not in the
|
||||
first icon directory. [DEFAULT]
|
||||
--compress-icons=3 Compress all icons.
|
||||
|
||||
--compress-resources=0 Don't compress any resources at all.
|
||||
|
||||
--keep-resource=list Don't compress resources specified by the list.
|
||||
The members of the list are separated by commas.
|
||||
A list member has the following format: I<type[/name]>.
|
||||
I<Type> is the type of the resource. Standard types
|
||||
must be specified as decimal numbers, user types can be
|
||||
specified by decimal IDs or strings. I<Name> is the
|
||||
identifier of the resource. It can be a decimal number
|
||||
or a string. For example:
|
||||
|
||||
--keep-resource=2/MYBITMAP,5,6/12345
|
||||
|
||||
UPX won't compress the named bitmap resource "MYBITMAP",
|
||||
it leaves every dialog (5) resource uncompressed, and
|
||||
it won't touch the string table resource with identifier
|
||||
12345.
|
||||
|
||||
--force Force compression even when there is an
|
||||
unexpected value in a header field.
|
||||
Use with care.
|
||||
|
||||
--strip-relocs=0 Don't strip relocation records.
|
||||
--strip-relocs=1 Strip relocation records. [DEFAULT]
|
||||
This option only works on executables with base
|
||||
address greater or equal to 0x400000. Usually the
|
||||
compressed files becomes smaller, but some files
|
||||
may become larger. Note that the resulting file will
|
||||
not work under Windows 3.x (Win32s).
|
||||
UPX never strips relocations from a DLL
|
||||
regardless of this option.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.</code></pre>
|
||||
|
||||
<h1 id="DIAGNOSTICS">DIAGNOSTICS</h1>
|
||||
|
||||
<p>Exit status is normally 0; if an error occurs, exit status is 1. If a warning occurs, exit status is 2.</p>
|
||||
|
||||
<p><b>UPX</b>'s diagnostics are intended to be self-explanatory.</p>
|
||||
|
||||
<h1 id="BUGS">BUGS</h1>
|
||||
|
||||
<p>Please report all bugs immediately to the authors.</p>
|
||||
|
||||
<h1 id="AUTHORS">AUTHORS</h1>
|
||||
|
||||
<pre><code>Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
http://www.oberhumer.com
|
||||
|
||||
Laszlo Molnar <ezerotven+github@gmail.com>
|
||||
|
||||
John F. Reiser <jreiser@BitWagon.com>
|
||||
|
||||
Jens Medoch <jssg@users.sourceforge.net></code></pre>
|
||||
|
||||
<h1 id="COPYRIGHT">COPYRIGHT</h1>
|
||||
|
||||
<p>Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer</p>
|
||||
|
||||
<p>Copyright (C) 1996-2023 Laszlo Molnar</p>
|
||||
|
||||
<p>Copyright (C) 2000-2023 John F. Reiser</p>
|
||||
|
||||
<p>Copyright (C) 2002-2023 Jens Medoch</p>
|
||||
|
||||
<p><b>UPX</b> is distributed with full source code under the terms of the GNU General Public License v2+; either under the pure GPLv2+ (see the file COPYING), or (at your option) under the GPLv+2 with special exceptions and restrictions granting the free usage for all binaries including commercial programs (see the file LICENSE).</p>
|
||||
|
||||
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p>
|
||||
|
||||
<p>You should have received a copy of the UPX License Agreements along with this program; see the files COPYING and LICENSE. If not, visit the UPX home page.</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
Generated
+842
@@ -0,0 +1,842 @@
|
||||
NAME
|
||||
upx - compress or expand executable files
|
||||
|
||||
SYNOPSIS
|
||||
upx [ *command* ] [ *options* ] *filename*...
|
||||
|
||||
ABSTRACT
|
||||
The Ultimate Packer for eXecutables
|
||||
Copyright (c) 1996-2023 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
https://upx.github.io
|
||||
|
||||
UPX is a portable, extendable, high-performance executable packer for
|
||||
several different executable formats. It achieves an excellent
|
||||
compression ratio and offers **very** fast decompression. Your
|
||||
executables suffer no memory overhead or other drawbacks for most of the
|
||||
formats supported, because of in-place decompression.
|
||||
|
||||
DISCLAIMER
|
||||
UPX comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING.
|
||||
|
||||
Please report all problems or suggestions to the authors. Thanks.
|
||||
|
||||
SECURITY CONTEXT
|
||||
IMPORTANT NOTE: UPX inherits the security context of any files it
|
||||
handles.
|
||||
|
||||
This means that packing, unpacking, or even testing or listing a file
|
||||
requires the same security considerations as actually executing the
|
||||
file.
|
||||
|
||||
Use UPX on trusted files only!
|
||||
|
||||
DESCRIPTION
|
||||
UPX is a versatile executable packer with the following features:
|
||||
|
||||
- secure: as UPX is documented Open Source since many years any relevant
|
||||
Security/Antivirus software is able to peek inside UPX compressed
|
||||
apps to verify them
|
||||
|
||||
- excellent compression ratio: typically compresses better than Zip,
|
||||
use UPX to decrease the size of your distribution !
|
||||
|
||||
- very fast decompression: more than 500 MB/sec on any reasonably modern
|
||||
machine
|
||||
|
||||
- no memory overhead for your compressed executables for most of the
|
||||
supported formats because of in-place decompression
|
||||
|
||||
- safe: you can list, test and unpack your executables.
|
||||
Also, a checksum of both the compressed and uncompressed file is
|
||||
maintained internally.
|
||||
|
||||
- universal: UPX can pack a number of executable formats, including
|
||||
Windows programs and DLLs, macOS apps and Linux executables
|
||||
|
||||
- portable: UPX is written in portable endian-neutral C++
|
||||
|
||||
- extendable: because of the class layout it's very easy to support
|
||||
new executable formats or add new compression algorithms
|
||||
|
||||
- free: UPX is distributed with full source code under the GNU General
|
||||
Public License v2+, with special exceptions granting the free usage
|
||||
for commercial programs
|
||||
|
||||
You probably understand now why we call UPX the "*ultimate*" executable
|
||||
packer.
|
||||
|
||||
COMMANDS
|
||||
Compress
|
||||
This is the default operation, eg. upx yourfile.exe will compress the
|
||||
file specified on the command line.
|
||||
|
||||
Decompress
|
||||
All UPX supported file formats can be unpacked using the -d switch, eg.
|
||||
upx -d yourfile.exe will uncompress the file you've just compressed.
|
||||
|
||||
Test
|
||||
The -t command tests the integrity of the compressed and uncompressed
|
||||
data, eg. upx -t yourfile.exe check whether your file can be safely
|
||||
decompressed. Note, that this command doesn't check the whole file, only
|
||||
the part that will be uncompressed during program execution. This means
|
||||
that you should not use this command instead of a virus checker.
|
||||
|
||||
List
|
||||
The -l command prints out some information about the compressed files
|
||||
specified on the command line as parameters, eg upx -l yourfile.exe
|
||||
shows the compressed / uncompressed size and the compression ratio of
|
||||
*yourfile.exe*.
|
||||
|
||||
OPTIONS
|
||||
-q: be quiet, suppress warnings
|
||||
|
||||
-q -q (or -qq): be very quiet, suppress errors
|
||||
|
||||
-q -q -q (or -qqq): produce no output at all
|
||||
|
||||
--help: prints the help
|
||||
|
||||
--version: print the version of UPX
|
||||
|
||||
--exact: when compressing, require to be able to get a byte-identical
|
||||
file after decompression with option -d. [NOTE: this is work in progress
|
||||
and is not supported for all formats yet. If you do care, as a
|
||||
workaround you can compress and then decompress your program a first
|
||||
time - any further compress-decompress steps should then yield
|
||||
byte-identical results as compared to the first decompressed version.]
|
||||
|
||||
-k: keep backup files
|
||||
|
||||
-o file: write output to file
|
||||
|
||||
[ ...more docs need to be written... - type `upx --help' for now ]
|
||||
|
||||
COMPRESSION LEVELS & TUNING
|
||||
UPX offers ten different compression levels from -1 to -9, and --best.
|
||||
The default compression level is -8 for files smaller than 512 KiB, and
|
||||
-7 otherwise.
|
||||
|
||||
* Compression levels 1, 2 and 3 are pretty fast.
|
||||
|
||||
* Compression levels 4, 5 and 6 achieve a good time/ratio performance.
|
||||
|
||||
* Compression levels 7, 8 and 9 favor compression ratio over speed.
|
||||
|
||||
* Compression level --best may take a long time.
|
||||
|
||||
Note that compression level --best can be somewhat slow for large files,
|
||||
but you definitely should use it when releasing a final version of your
|
||||
program.
|
||||
|
||||
Quick info for achieving the best compression ratio:
|
||||
|
||||
* Try upx --brute --no-lzma myfile.exe or even upx --ultra-brute
|
||||
--no-lzma myfile.exe.
|
||||
|
||||
* The option --lzma enables LZMA compression, which compresses better
|
||||
but is *significantly slower* at decompression. You probably do not
|
||||
want to use it for large files.
|
||||
|
||||
(Note that --lzma is automatically enabled by --all-methods and
|
||||
--brute, use --no-lzma to override.)
|
||||
|
||||
* Try if --overlay=strip works.
|
||||
|
||||
* For win32/pe programs there's --strip-relocs=0. See notes below.
|
||||
|
||||
OVERLAY HANDLING OPTIONS
|
||||
Info: An "overlay" means auxiliary data attached after the logical end
|
||||
of an executable, and it often contains application specific data (this
|
||||
is a common practice to avoid an extra data file, though it would be
|
||||
better to use resource sections).
|
||||
|
||||
UPX handles overlays like many other executable packers do: it simply
|
||||
copies the overlay after the compressed image. This works with some
|
||||
files, but doesn't work with others, depending on how an application
|
||||
actually accesses this overlaid data.
|
||||
|
||||
--overlay=copy Copy any extra data attached to the file. [DEFAULT]
|
||||
|
||||
--overlay=strip Strip any overlay from the program instead of
|
||||
copying it. Be warned, this may make the compressed
|
||||
program crash or otherwise unusable.
|
||||
|
||||
--overlay=skip Refuse to compress any program which has an overlay.
|
||||
|
||||
ENVIRONMENT VARIABLE
|
||||
The environment variable UPX can hold a set of default options for UPX.
|
||||
These options are interpreted first and can be overwritten by explicit
|
||||
command line parameters. For example:
|
||||
|
||||
for DOS/Windows: set UPX=-9 --compress-icons#0
|
||||
for sh/ksh/zsh: UPX="-9 --compress-icons=0"; export UPX
|
||||
for csh/tcsh: setenv UPX "-9 --compress-icons=0"
|
||||
|
||||
Under DOS/Windows you must use '#' instead of '=' when setting the
|
||||
environment variable because of a COMMAND.COM limitation.
|
||||
|
||||
Not all of the options are valid in the environment variable - UPX will
|
||||
tell you.
|
||||
|
||||
You can explicitly use the --no-env option to ignore the environment
|
||||
variable.
|
||||
|
||||
NOTES FOR THE SUPPORTED EXECUTABLE FORMATS
|
||||
NOTES FOR ATARI/TOS
|
||||
This is the executable format used by the Atari ST/TT, a Motorola 68000
|
||||
based personal computer which was popular in the late '80s. Support of
|
||||
this format is only because of nostalgic feelings of one of the authors
|
||||
and serves no practical purpose :-). See https://freemint.github.io for
|
||||
more info.
|
||||
|
||||
Packed programs will be byte-identical to the original after
|
||||
uncompression. All debug information will be stripped, though.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
NOTES FOR BVMLINUZ/I386
|
||||
Same as vmlinuz/i386.
|
||||
|
||||
NOTES FOR DOS/COM
|
||||
Obviously UPX won't work with executables that want to read data from
|
||||
themselves (like some commandline utilities that ship with Win95/98/ME).
|
||||
|
||||
Compressed programs only work on a 286+.
|
||||
|
||||
Packed programs will be byte-identical to the original after
|
||||
uncompression.
|
||||
|
||||
Maximum uncompressed size: ~65100 bytes.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--8086 Create an executable that works on any 8086 CPU.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.
|
||||
|
||||
NOTES FOR DOS/EXE
|
||||
dos/exe stands for all "normal" 16-bit DOS executables.
|
||||
|
||||
Obviously UPX won't work with executables that want to read data from
|
||||
themselves (like some command line utilities that ship with
|
||||
Win95/98/ME).
|
||||
|
||||
Compressed programs only work on a 286+.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--8086 Create an executable that works on any 8086 CPU.
|
||||
|
||||
--no-reloc Use no relocation records in the exe header.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
NOTES FOR DOS/SYS
|
||||
Compressed programs only work on a 286+.
|
||||
|
||||
Packed programs will be byte-identical to the original after
|
||||
uncompression.
|
||||
|
||||
Maximum uncompressed size: ~65350 bytes.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--8086 Create an executable that works on any 8086 CPU.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.
|
||||
|
||||
NOTES FOR DJGPP2/COFF
|
||||
First of all, it is recommended to use UPX *instead* of strip. strip has
|
||||
the very bad habit of replacing your stub with its own (outdated)
|
||||
version. Additionally UPX corrects a bug/feature in strip v2.8.x: it
|
||||
will fix the 4 KiB alignment of the stub.
|
||||
|
||||
UPX includes the full functionality of stubify. This means it will
|
||||
automatically stubify your COFF files. Use the option --coff to disable
|
||||
this functionality (see below).
|
||||
|
||||
UPX automatically handles Allegro packfiles.
|
||||
|
||||
The DLM format (a rather exotic shared library extension) is not
|
||||
supported.
|
||||
|
||||
Packed programs will be byte-identical to the original after
|
||||
uncompression. All debug information and trailing garbage will be
|
||||
stripped, though.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--coff Produce COFF output instead of EXE. By default
|
||||
UPX keeps your current stub.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.
|
||||
|
||||
NOTES FOR LINUX [general]
|
||||
Introduction
|
||||
|
||||
Linux/386 support in UPX consists of 3 different executable formats,
|
||||
one optimized for ELF executables ("linux/elf386"), one optimized
|
||||
for shell scripts ("linux/sh386"), and one generic format
|
||||
("linux/386").
|
||||
|
||||
We will start with a general discussion first, but please
|
||||
also read the relevant docs for each of the individual formats.
|
||||
|
||||
Also, there is special support for bootable kernels - see the
|
||||
description of the vmlinuz/386 format.
|
||||
|
||||
General user's overview
|
||||
|
||||
Running a compressed executable program trades less space on a
|
||||
``permanent'' storage medium (such as a hard disk, floppy disk,
|
||||
CD-ROM, flash memory, EPROM, etc.) for more space in one or more
|
||||
``temporary'' storage media (such as RAM, swap space, /tmp, etc.).
|
||||
Running a compressed executable also requires some additional CPU
|
||||
cycles to generate the compressed executable in the first place,
|
||||
and to decompress it at each invocation.
|
||||
|
||||
How much space is traded? It depends on the executable, but many
|
||||
programs save 30% to 50% of permanent disk space. How much CPU
|
||||
overhead is there? Again, it depends on the executable, but
|
||||
decompression speed generally is at least many megabytes per second,
|
||||
and frequently is limited by the speed of the underlying disk
|
||||
or network I/O.
|
||||
|
||||
Depending on the statistics of usage and access, and the relative
|
||||
speeds of CPU, RAM, swap space, /tmp, and file system storage, then
|
||||
invoking and running a compressed executable can be faster than
|
||||
directly running the corresponding uncompressed program.
|
||||
The operating system might perform fewer expensive I/O operations
|
||||
to invoke the compressed program. Paging to or from swap space
|
||||
or /tmp might be faster than paging from the general file system.
|
||||
``Medium-sized'' programs which access about 1/3 to 1/2 of their
|
||||
stored program bytes can do particularly well with compression.
|
||||
Small programs tend not to benefit as much because the absolute
|
||||
savings is less. Big programs tend not to benefit proportionally
|
||||
because each invocation may use only a small fraction of the program,
|
||||
yet UPX decompresses the entire program before invoking it.
|
||||
But in environments where disk or flash memory storage is limited,
|
||||
then compression may win anyway.
|
||||
|
||||
Currently, executables compressed by UPX do not share RAM at runtime
|
||||
in the way that executables mapped from a file system do. As a
|
||||
result, if the same program is run simultaneously by more than one
|
||||
process, then using the compressed version will require more RAM and/or
|
||||
swap space. So, shell programs (bash, csh, etc.) and ``make''
|
||||
might not be good candidates for compression.
|
||||
|
||||
UPX recognizes three executable formats for Linux: Linux/elf386,
|
||||
Linux/sh386, and Linux/386. Linux/386 is the most generic format;
|
||||
it accommodates any file that can be executed. At runtime, the UPX
|
||||
decompression stub re-creates in /tmp a copy of the original file,
|
||||
and then the copy is (re-)executed with the same arguments.
|
||||
ELF binary executables prefer the Linux/elf386 format by default,
|
||||
because UPX decompresses them directly into RAM, uses only one
|
||||
exec, does not use space in /tmp, and does not use /proc.
|
||||
Shell scripts where the underlying shell accepts a ``-c'' argument
|
||||
can use the Linux/sh386 format. UPX decompresses the shell script
|
||||
into low memory, then maps the shell and passes the entire text of the
|
||||
script as an argument with a leading ``-c''.
|
||||
|
||||
General benefits:
|
||||
|
||||
- UPX can compress all executables, be it AOUT, ELF, libc4, libc5,
|
||||
libc6, Shell/Perl/Python/... scripts, standalone Java .class
|
||||
binaries, or whatever...
|
||||
All scripts and programs will work just as before.
|
||||
|
||||
- Compressed programs are completely self-contained. No need for
|
||||
any external program.
|
||||
|
||||
- UPX keeps your original program untouched. This means that
|
||||
after decompression you will have a byte-identical version,
|
||||
and you can use UPX as a file compressor just like gzip.
|
||||
[ Note that UPX maintains a checksum of the file internally,
|
||||
so it is indeed a reliable alternative. ]
|
||||
|
||||
- As the stub only uses syscalls and isn't linked against libc it
|
||||
should run under any Linux configuration that can run ELF
|
||||
binaries.
|
||||
|
||||
- For the same reason compressed executables should run under
|
||||
FreeBSD and other systems which can run Linux binaries.
|
||||
[ Please send feedback on this topic ]
|
||||
|
||||
General drawbacks:
|
||||
|
||||
- It is not advisable to compress programs which usually have many
|
||||
instances running (like `sh' or `make') because the common segments of
|
||||
compressed programs won't be shared any longer between different
|
||||
processes.
|
||||
|
||||
- `ldd' and `size' won't show anything useful because all they
|
||||
see is the statically linked stub. Since version 0.82 the section
|
||||
headers are stripped from the UPX stub and `size' doesn't even
|
||||
recognize the file format. The file patches/patch-elfcode.h has a
|
||||
patch to fix this bug in `size' and other programs which use GNU BFD.
|
||||
|
||||
General notes:
|
||||
|
||||
- As UPX leaves your original program untouched it is advantageous
|
||||
to strip it before compression.
|
||||
|
||||
- If you compress a script you will lose platform independence -
|
||||
this could be a problem if you are using NFS mounted disks.
|
||||
|
||||
- Compression of suid, guid and sticky-bit programs is rejected
|
||||
because of possible security implications.
|
||||
|
||||
- For the same reason there is no sense in making any compressed
|
||||
program suid.
|
||||
|
||||
- Obviously UPX won't work with executables that want to read data
|
||||
from themselves. E.g., this might be a problem for Perl scripts
|
||||
which access their __DATA__ lines.
|
||||
|
||||
- In case of internal errors the stub will abort with exitcode 127.
|
||||
Typical reasons for this to happen are that the program has somehow
|
||||
been modified after compression.
|
||||
Running `strace -o strace.log compressed_file' will tell you more.
|
||||
|
||||
NOTES FOR LINUX/ELF386
|
||||
Please read the general Linux description first.
|
||||
|
||||
The linux/elf386 format decompresses directly into RAM, uses only one
|
||||
exec, does not use space in /tmp, and does not use /proc.
|
||||
|
||||
Linux/elf386 is automatically selected for Linux ELF executables.
|
||||
|
||||
Packed programs will be byte-identical to the original after
|
||||
uncompression.
|
||||
|
||||
How it works:
|
||||
|
||||
For ELF executables, UPX decompresses directly to memory, simulating
|
||||
the mapping that the operating system kernel uses during exec(),
|
||||
including the PT_INTERP program interpreter (if any).
|
||||
The brk() is set by a special PT_LOAD segment in the compressed
|
||||
executable itself. UPX then wipes the stack clean except for
|
||||
arguments, environment variables, and Elf_auxv entries (this is
|
||||
required by bugs in the startup code of /lib/ld-linux.so as of
|
||||
May 2000), and transfers control to the program interpreter or
|
||||
the e_entry address of the original executable.
|
||||
|
||||
The UPX stub is about 1700 bytes long, partly written in assembler
|
||||
and only uses kernel syscalls. It is not linked against any libc.
|
||||
|
||||
Specific drawbacks:
|
||||
|
||||
- For linux/elf386 and linux/sh386 formats, you will be relying on
|
||||
RAM and swap space to hold all of the decompressed program during
|
||||
the lifetime of the process. If you already use most of your swap
|
||||
space, then you may run out. A system that is "out of memory"
|
||||
can become fragile. Many programs do not react gracefully when
|
||||
malloc() returns 0. With newer Linux kernels, the kernel
|
||||
may decide to kill some processes to regain memory, and you
|
||||
may not like the kernel's choice of which to kill. Running
|
||||
/usr/bin/top is one way to check on the usage of swap space.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
(none)
|
||||
|
||||
NOTES FOR LINUX/SH386
|
||||
Please read the general Linux description first.
|
||||
|
||||
Shell scripts where the underling shell accepts a ``-c'' argument can
|
||||
use the Linux/sh386 format. UPX decompresses the shell script into low
|
||||
memory, then maps the shell and passes the entire text of the script as
|
||||
an argument with a leading ``-c''. It does not use space in /tmp, and
|
||||
does not use /proc.
|
||||
|
||||
Linux/sh386 is automatically selected for shell scripts that use a known
|
||||
shell.
|
||||
|
||||
Packed programs will be byte-identical to the original after
|
||||
uncompression.
|
||||
|
||||
How it works:
|
||||
|
||||
For shell script executables (files beginning with "#!/" or "#! /")
|
||||
where the shell is known to accept "-c <command>", UPX decompresses
|
||||
the file into low memory, then maps the shell (and its PT_INTERP),
|
||||
and passes control to the shell with the entire decompressed file
|
||||
as the argument after "-c". Known shells are sh, ash, bash, bsh, csh,
|
||||
ksh, tcsh, pdksh. Restriction: UPX cannot use this method
|
||||
for shell scripts which use the one optional string argument after
|
||||
the shell name in the script (example: "#! /bin/sh option3\n".)
|
||||
|
||||
The UPX stub is about 1700 bytes long, partly written in assembler
|
||||
and only uses kernel syscalls. It is not linked against any libc.
|
||||
|
||||
Specific drawbacks:
|
||||
|
||||
- For linux/elf386 and linux/sh386 formats, you will be relying on
|
||||
RAM and swap space to hold all of the decompressed program during
|
||||
the lifetime of the process. If you already use most of your swap
|
||||
space, then you may run out. A system that is "out of memory"
|
||||
can become fragile. Many programs do not react gracefully when
|
||||
malloc() returns 0. With newer Linux kernels, the kernel
|
||||
may decide to kill some processes to regain memory, and you
|
||||
may not like the kernel's choice of which to kill. Running
|
||||
/usr/bin/top is one way to check on the usage of swap space.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
(none)
|
||||
|
||||
NOTES FOR LINUX/386
|
||||
Please read the general Linux description first.
|
||||
|
||||
The generic linux/386 format decompresses to /tmp and needs /proc file
|
||||
system support. It starts the decompressed program via the execve()
|
||||
syscall.
|
||||
|
||||
Linux/386 is only selected if the specialized linux/elf386 and
|
||||
linux/sh386 won't recognize a file.
|
||||
|
||||
Packed programs will be byte-identical to the original after
|
||||
uncompression.
|
||||
|
||||
How it works:
|
||||
|
||||
For files which are not ELF and not a script for a known "-c" shell,
|
||||
UPX uses kernel execve(), which first requires decompressing to a
|
||||
temporary file in the file system. Interestingly -
|
||||
because of the good memory management of the Linux kernel - this
|
||||
often does not introduce a noticeable delay, and in fact there
|
||||
will be no disk access at all if you have enough free memory as
|
||||
the entire process takes places within the file system buffers.
|
||||
|
||||
A compressed executable consists of the UPX stub and an overlay
|
||||
which contains the original program in a compressed form.
|
||||
|
||||
The UPX stub is a statically linked ELF executable and does
|
||||
the following at program startup:
|
||||
|
||||
1) decompress the overlay to a temporary location in /tmp
|
||||
2) open the temporary file for reading
|
||||
3) try to delete the temporary file and start (execve)
|
||||
the uncompressed program in /tmp using /proc/<pid>/fd/X as
|
||||
attained by step 2)
|
||||
4) if that fails, fork off a subprocess to clean up and
|
||||
start the program in /tmp in the meantime
|
||||
|
||||
The UPX stub is about 1700 bytes long, partly written in assembler
|
||||
and only uses kernel syscalls. It is not linked against any libc.
|
||||
|
||||
Specific drawbacks:
|
||||
|
||||
- You need additional free disk space for the uncompressed program
|
||||
in your /tmp directory. This program is deleted immediately after
|
||||
decompression, but you still need it for the full execution time
|
||||
of the program.
|
||||
|
||||
- You must have /proc file system support as the stub wants to open
|
||||
/proc/<pid>/exe and needs /proc/<pid>/fd/X. This also means that you
|
||||
cannot compress programs that are used during the boot sequence
|
||||
before /proc is mounted.
|
||||
|
||||
- Utilities like `top' will display numerical values in the process
|
||||
name field. This is because Linux computes the process name from
|
||||
the first argument of the last execve syscall (which is typically
|
||||
something like /proc/<pid>/fd/3).
|
||||
|
||||
- Because of temporary decompression to disk the decompression speed
|
||||
is not as fast as with the other executable formats. Still, I can see
|
||||
no noticeable delay when starting programs like my ~3 MiB emacs (which
|
||||
is less than 1 MiB when compressed :-).
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--force-execve Force the use of the generic linux/386 "execve"
|
||||
format, i.e. do not try the linux/elf386 and
|
||||
linux/sh386 formats.
|
||||
|
||||
NOTES FOR PS1/EXE
|
||||
This is the executable format used by the Sony PlayStation (PSone), a
|
||||
MIPS R3000 based gaming console which is popular since the late '90s.
|
||||
Support of this format is very similar to the Atari one, because of
|
||||
nostalgic feelings of one of the authors.
|
||||
|
||||
Packed programs will be byte-identical to the original after
|
||||
uncompression, until further notice.
|
||||
|
||||
Maximum uncompressed size: ~1.89 / ~7.60 MiB.
|
||||
|
||||
Notes:
|
||||
|
||||
- UPX creates as default a suitable executable for CD-Mastering
|
||||
and console transfer. For a CD-Master main executable you could also try
|
||||
the special option "--boot-only" as described below.
|
||||
It has been reported that upx packed executables are fully compatible with
|
||||
the Sony PlayStation 2 (PS2, PStwo) and Sony PlayStation Portable (PSP) in
|
||||
Sony PlayStation (PSone) emulation mode.
|
||||
|
||||
- Normally the packed files use the same memory areas like the uncompressed
|
||||
versions, so they will not override other memory areas while unpacking.
|
||||
If this isn't possible UPX will abort showing a 'packed data overlap'
|
||||
error. With the "--force" option UPX will relocate the loading address
|
||||
for the packed file, but this isn't a real problem if it is a single or
|
||||
the main executable.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--8-bit Uses 8 bit size compression [default: 32 bit]
|
||||
|
||||
--8mib-ram PSone has 8 MiB ram available [default: 2 MiB]
|
||||
|
||||
--boot-only This format is for main exes and CD-Mastering only !
|
||||
It may slightly improve the compression ratio,
|
||||
decompression routines are faster than default ones.
|
||||
But it cannot be used for console transfer !
|
||||
|
||||
--no-align This option disables CD mode 2 data sector format
|
||||
alignment. May slightly improves the compression ratio,
|
||||
but the compressed executable will not boot from a CD.
|
||||
Use it for console transfer only !
|
||||
|
||||
NOTES FOR RTM32/PE and ARM/PE
|
||||
Same as win32/pe.
|
||||
|
||||
NOTES FOR TMT/ADAM
|
||||
This format is used by the TMT Pascal compiler - see http://www.tmt.com/
|
||||
.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.
|
||||
|
||||
NOTES FOR VMLINUZ/386
|
||||
The vmlinuz/386 and bvmlinuz/386 formats take a gzip-compressed bootable
|
||||
Linux kernel image ("vmlinuz", "zImage", "bzImage"), gzip-decompress it
|
||||
and re-compress it with the UPX compression method.
|
||||
|
||||
vmlinuz/386 is completely unrelated to the other Linux executable
|
||||
formats, and it does not share any of their drawbacks.
|
||||
|
||||
Notes:
|
||||
|
||||
- Be sure that "vmlinuz/386" or "bvmlinuz/386" is displayed
|
||||
during compression - otherwise a wrong executable format
|
||||
may have been used, and the kernel won't boot.
|
||||
|
||||
Benefits:
|
||||
|
||||
- Better compression (but note that the kernel was already compressed,
|
||||
so the improvement is not as large as with other formats).
|
||||
Still, the bytes saved may be essential for special needs like
|
||||
boot disks.
|
||||
|
||||
For example, this is what I get for my 2.2.16 kernel:
|
||||
1589708 vmlinux
|
||||
641073 bzImage [original]
|
||||
560755 bzImage.upx [compressed by "upx -9"]
|
||||
|
||||
- Much faster decompression at kernel boot time (but kernel
|
||||
decompression speed is not really an issue these days).
|
||||
|
||||
Drawbacks:
|
||||
|
||||
(none)
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.
|
||||
|
||||
NOTES FOR WATCOM/LE
|
||||
UPX has been successfully tested with the following extenders: DOS4G,
|
||||
DOS4GW, PMODE/W, DOS32a, CauseWay. The WDOS/X extender is partly
|
||||
supported (for details see the file bugs BUGS).
|
||||
|
||||
DLLs and the LX format are not supported.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--le Produce an unbound LE output instead of
|
||||
keeping the current stub.
|
||||
|
||||
NOTES FOR WIN32/PE
|
||||
The PE support in UPX is quite stable now, but probably there are still
|
||||
some incompatibilities with some files.
|
||||
|
||||
Because of the way UPX (and other packers for this format) works, you
|
||||
can see increased memory usage of your compressed files because the
|
||||
whole program is loaded into memory at startup. If you start several
|
||||
instances of huge compressed programs you're wasting memory because the
|
||||
common segments of the program won't get shared across the instances. On
|
||||
the other hand if you're compressing only smaller programs, or running
|
||||
only one instance of larger programs, then this penalty is smaller, but
|
||||
it's still there.
|
||||
|
||||
If you're running executables from network, then compressed programs
|
||||
will load faster, and require less bandwidth during execution.
|
||||
|
||||
DLLs are supported. But UPX compressed DLLs can not share common data
|
||||
and code when they got used by multiple applications. So compressing
|
||||
msvcrt.dll is a waste of memory, but compressing the dll plugins of a
|
||||
particular application may be a better idea.
|
||||
|
||||
Screensavers are supported, with the restriction that the filename must
|
||||
end with ".scr" (as screensavers are handled slightly different than
|
||||
normal exe files).
|
||||
|
||||
UPX compressed PE files have some minor memory overhead (usually in the
|
||||
10 - 30 KiB range) which can be seen by specifying the "-i" command line
|
||||
switch during compression.
|
||||
|
||||
Extra options available for this executable format:
|
||||
|
||||
--compress-exports=0 Don't compress the export section.
|
||||
Use this if you plan to run the compressed
|
||||
program under Wine.
|
||||
--compress-exports=1 Compress the export section. [DEFAULT]
|
||||
Compression of the export section can improve the
|
||||
compression ratio quite a bit but may not work
|
||||
with all programs (like winword.exe).
|
||||
UPX never compresses the export section of a DLL
|
||||
regardless of this option.
|
||||
|
||||
--compress-icons=0 Don't compress any icons.
|
||||
--compress-icons=1 Compress all but the first icon.
|
||||
--compress-icons=2 Compress all icons which are not in the
|
||||
first icon directory. [DEFAULT]
|
||||
--compress-icons=3 Compress all icons.
|
||||
|
||||
--compress-resources=0 Don't compress any resources at all.
|
||||
|
||||
--keep-resource=list Don't compress resources specified by the list.
|
||||
The members of the list are separated by commas.
|
||||
A list member has the following format: I<type[/name]>.
|
||||
I<Type> is the type of the resource. Standard types
|
||||
must be specified as decimal numbers, user types can be
|
||||
specified by decimal IDs or strings. I<Name> is the
|
||||
identifier of the resource. It can be a decimal number
|
||||
or a string. For example:
|
||||
|
||||
--keep-resource=2/MYBITMAP,5,6/12345
|
||||
|
||||
UPX won't compress the named bitmap resource "MYBITMAP",
|
||||
it leaves every dialog (5) resource uncompressed, and
|
||||
it won't touch the string table resource with identifier
|
||||
12345.
|
||||
|
||||
--force Force compression even when there is an
|
||||
unexpected value in a header field.
|
||||
Use with care.
|
||||
|
||||
--strip-relocs=0 Don't strip relocation records.
|
||||
--strip-relocs=1 Strip relocation records. [DEFAULT]
|
||||
This option only works on executables with base
|
||||
address greater or equal to 0x400000. Usually the
|
||||
compressed files becomes smaller, but some files
|
||||
may become larger. Note that the resulting file will
|
||||
not work under Windows 3.x (Win32s).
|
||||
UPX never strips relocations from a DLL
|
||||
regardless of this option.
|
||||
|
||||
--all-methods Compress the program several times, using all
|
||||
available compression methods. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default method gives the best results anyway.
|
||||
|
||||
--all-filters Compress the program several times, using all
|
||||
available preprocessing filters. This may improve
|
||||
the compression ratio in some cases, but usually
|
||||
the default filter gives the best results anyway.
|
||||
|
||||
DIAGNOSTICS
|
||||
Exit status is normally 0; if an error occurs, exit status is 1. If a
|
||||
warning occurs, exit status is 2.
|
||||
|
||||
UPX's diagnostics are intended to be self-explanatory.
|
||||
|
||||
BUGS
|
||||
Please report all bugs immediately to the authors.
|
||||
|
||||
AUTHORS
|
||||
Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
http://www.oberhumer.com
|
||||
|
||||
Laszlo Molnar <ezerotven+github@gmail.com>
|
||||
|
||||
John F. Reiser <jreiser@BitWagon.com>
|
||||
|
||||
Jens Medoch <jssg@users.sourceforge.net>
|
||||
|
||||
COPYRIGHT
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
Copyright (C) 1996-2023 Laszlo Molnar
|
||||
|
||||
Copyright (C) 2000-2023 John F. Reiser
|
||||
|
||||
Copyright (C) 2002-2023 Jens Medoch
|
||||
|
||||
UPX is distributed with full source code under the terms of the GNU
|
||||
General Public License v2+; either under the pure GPLv2+ (see the file
|
||||
COPYING), or (at your option) under the GPLv+2 with special exceptions
|
||||
and restrictions granting the free usage for all binaries including
|
||||
commercial programs (see the file LICENSE).
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
You should have received a copy of the UPX License Agreements along with
|
||||
this program; see the files COPYING and LICENSE. If not, visit the UPX
|
||||
home page.
|
||||
|
||||
+61
-61
@@ -13,8 +13,8 @@ B<upx> S<[ I<command> ]> S<[ I<options> ]> I<filename>...
|
||||
=head1 ABSTRACT
|
||||
|
||||
The Ultimate Packer for eXecutables
|
||||
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
http://upx.sourceforge.net
|
||||
Copyright (c) 1996-2023 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||
https://upx.github.io
|
||||
|
||||
|
||||
B<UPX> is a portable, extendable, high-performance executable packer for
|
||||
@@ -23,75 +23,59 @@ ratio and offers I<*very*> fast decompression. Your executables suffer
|
||||
no memory overhead or other drawbacks for most of the formats supported,
|
||||
because of in-place decompression.
|
||||
|
||||
While you may use B<UPX> freely for both non-commercial and commercial
|
||||
executables (for details see the file LICENSE), we would highly
|
||||
appreciate if you credit B<UPX> and ourselves in the documentation,
|
||||
possibly including a reference to the B<UPX> home page. Thanks.
|
||||
|
||||
[ Using B<UPX> in non-OpenSource applications without proper credits
|
||||
is considered not politically correct ;-) ]
|
||||
|
||||
|
||||
|
||||
=head1 DISCLAIMER
|
||||
|
||||
B<UPX> comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE.
|
||||
|
||||
This is the first production quality release, and we plan that future 1.xx
|
||||
releases will be backward compatible with this version.
|
||||
B<UPX> comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING.
|
||||
|
||||
Please report all problems or suggestions to the authors. Thanks.
|
||||
|
||||
|
||||
|
||||
=head1 SECURITY CONTEXT
|
||||
|
||||
IMPORTANT NOTE: B<UPX> inherits the security context of any files it handles.
|
||||
|
||||
This means that packing, unpacking, or even testing or listing a file requires
|
||||
the same security considerations as actually executing the file.
|
||||
|
||||
Use B<UPX> on trusted files only!
|
||||
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<UPX> is a versatile executable packer with the following features:
|
||||
|
||||
- excellent compression ratio: compresses better than zip/gzip,
|
||||
- secure: as UPX is documented Open Source since many years any relevant
|
||||
Security/Antivirus software is able to peek inside UPX compressed
|
||||
apps to verify them
|
||||
|
||||
- excellent compression ratio: typically compresses better than Zip,
|
||||
use UPX to decrease the size of your distribution !
|
||||
|
||||
- very fast decompression: about 10 MiB/sec on an ancient Pentium 133,
|
||||
about 200 MiB/sec on an Athlon XP 2000+.
|
||||
- very fast decompression: more than 500 MB/sec on any reasonably modern
|
||||
machine
|
||||
|
||||
- no memory overhead for your compressed executables for most of the
|
||||
supported formats
|
||||
supported formats because of in-place decompression
|
||||
|
||||
- safe: you can list, test and unpack your executables
|
||||
- safe: you can list, test and unpack your executables.
|
||||
Also, a checksum of both the compressed and uncompressed file is
|
||||
maintained internally.
|
||||
|
||||
- universal: UPX can pack a number of executable formats:
|
||||
* atari/tos
|
||||
* bvmlinuz/386 [bootable Linux kernel]
|
||||
* djgpp2/coff
|
||||
* dos/com
|
||||
* dos/exe
|
||||
* dos/sys
|
||||
* linux/386
|
||||
* linux/elf386
|
||||
* linux/sh386
|
||||
* ps1/exe
|
||||
* rtm32/pe
|
||||
* tmt/adam
|
||||
* vmlinuz/386 [bootable Linux kernel]
|
||||
* vmlinux/386
|
||||
* watcom/le (supporting DOS4G, PMODE/W, DOS32a and CauseWay)
|
||||
* win32/pe (exe and dll)
|
||||
* win64/pe (exe and dll)
|
||||
* arm/pe (exe and dll)
|
||||
* linux/elfamd64
|
||||
* linux/elfppc32
|
||||
* mach/elfppc32
|
||||
- universal: UPX can pack a number of executable formats, including
|
||||
Windows programs and DLLs, macOS apps and Linux executables
|
||||
|
||||
- portable: UPX is written in portable endian-neutral C++
|
||||
|
||||
- extendable: because of the class layout it's very easy to support
|
||||
new executable formats or add new compression algorithms
|
||||
|
||||
- free: UPX can be distributed and used freely. And from version 0.99
|
||||
the full source code of UPX is released under the GNU General Public
|
||||
License (GPL) !
|
||||
- free: UPX is distributed with full source code under the GNU General
|
||||
Public License v2+, with special exceptions granting the free usage
|
||||
for commercial programs
|
||||
|
||||
You probably understand now why we call B<UPX> the "I<ultimate>"
|
||||
executable packer.
|
||||
@@ -146,7 +130,11 @@ compress and then decompress your program a first time - any further
|
||||
compress-decompress steps should then yield byte-identical results
|
||||
as compared to the first decompressed version.]
|
||||
|
||||
[ ...to be written... - type `B<upx --help>' for now ]
|
||||
B<-k>: keep backup files
|
||||
|
||||
B<-o file>: write output to file
|
||||
|
||||
[ ...more docs need to be written... - type `B<upx --help>' for now ]
|
||||
|
||||
|
||||
|
||||
@@ -186,7 +174,17 @@ Quick info for achieving the best compression ratio:
|
||||
|
||||
=item *
|
||||
|
||||
Try B<upx --brute myfile.exe> or even B<upx --ultra-brute myfile.exe>.
|
||||
Try B<upx --brute --no-lzma myfile.exe> or even
|
||||
B<upx --ultra-brute --no-lzma myfile.exe>.
|
||||
|
||||
=item *
|
||||
|
||||
The option B<--lzma> enables LZMA compression, which compresses better but
|
||||
is *significantly slower* at decompression. You probably do not want
|
||||
to use it for large files.
|
||||
|
||||
(Note that B<--lzma> is automatically enabled by B<--all-methods> and
|
||||
B<--brute>, use B<--no-lzma> to override.)
|
||||
|
||||
=item *
|
||||
|
||||
@@ -210,7 +208,7 @@ it would be better to use resource sections).
|
||||
B<UPX> handles overlays like many other executable packers do: it simply
|
||||
copies the overlay after the compressed image. This works with some
|
||||
files, but doesn't work with others, depending on how an application
|
||||
actually accesses this overlayed data.
|
||||
actually accesses this overlaid data.
|
||||
|
||||
--overlay=copy Copy any extra data attached to the file. [DEFAULT]
|
||||
|
||||
@@ -222,7 +220,7 @@ actually accesses this overlayed data.
|
||||
|
||||
|
||||
|
||||
=head1 ENVIRONMENT
|
||||
=head1 ENVIRONMENT VARIABLE
|
||||
|
||||
The environment variable B<UPX> can hold a set of default
|
||||
options for B<UPX>. These options are interpreted first and
|
||||
@@ -252,7 +250,7 @@ This is the executable format used by the Atari ST/TT, a Motorola 68000
|
||||
based personal computer which was popular in the late '80s. Support
|
||||
of this format is only because of nostalgic feelings of one of
|
||||
the authors and serves no practical purpose :-).
|
||||
See http://www.freemint.de for more info.
|
||||
See https://freemint.github.io for more info.
|
||||
|
||||
Packed programs will be byte-identical to the original after uncompression.
|
||||
All debug information will be stripped, though.
|
||||
@@ -675,7 +673,7 @@ Extra options available for this executable format:
|
||||
=head2 NOTES FOR PS1/EXE
|
||||
|
||||
This is the executable format used by the Sony PlayStation (PSone),
|
||||
a Mips R3000 based gaming console which is popular since the late '90s.
|
||||
a MIPS R3000 based gaming console which is popular since the late '90s.
|
||||
Support of this format is very similar to the Atari one, because of
|
||||
nostalgic feelings of one of the authors.
|
||||
|
||||
@@ -934,22 +932,24 @@ Please report all bugs immediately to the authors.
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
Copyright (C) 1996-2017 Laszlo Molnar
|
||||
Copyright (C) 1996-2023 Laszlo Molnar
|
||||
|
||||
Copyright (C) 2000-2017 John F. Reiser
|
||||
Copyright (C) 2000-2023 John F. Reiser
|
||||
|
||||
Copyright (C) 2002-2017 Jens Medoch
|
||||
Copyright (C) 2002-2023 Jens Medoch
|
||||
|
||||
This program may be used freely, and you are welcome to
|
||||
redistribute it under certain conditions.
|
||||
B<UPX> is distributed with full source code under the terms of the
|
||||
GNU General Public License v2+; either under the pure GPLv2+ (see
|
||||
the file COPYING), or (at your option) under the GPLv+2 with special
|
||||
exceptions and restrictions granting the free usage for all binaries
|
||||
including commercial programs (see the file LICENSE).
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
B<UPX License Agreement> for more details.
|
||||
|
||||
You should have received a copy of the UPX License Agreement along
|
||||
with this program; see the file LICENSE. If not, visit the UPX home page.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
You should have received a copy of the UPX License Agreements along
|
||||
with this program; see the files COPYING and LICENSE. If not,
|
||||
visit the UPX home page.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-branch-clone,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-reserved-identifier,
|
||||
-bugprone-switch-missing-default-case,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||
-clang-analyzer-core.uninitialized.Assign,
|
||||
-clang-analyzer-security.insecureAPI.strcpy,
|
||||
clang-diagnostics-*',
|
||||
performance-*,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
InheritParentConfig: false
|
||||
...
|
||||
@@ -0,0 +1,20 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-reserved-identifier,
|
||||
-bugprone-sizeof-expression,
|
||||
-bugprone-suspicious-include,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-diagnostics-*',
|
||||
performance-*,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
InheritParentConfig: false
|
||||
...
|
||||
@@ -0,0 +1,21 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-reserved-identifier,
|
||||
-bugprone-switch-missing-default-case,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-optin.performance.Padding,
|
||||
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-diagnostics-*',
|
||||
performance-*,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
InheritParentConfig: false
|
||||
...
|
||||
@@ -0,0 +1,25 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-branch-clone,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-misplaced-widening-cast,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-reserved-identifier,
|
||||
-bugprone-switch-missing-default-case,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||
-clang-analyzer-deadcode.DeadStores,
|
||||
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-diagnostics-*',
|
||||
performance-*,
|
||||
-performance-no-int-to-ptr,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
InheritParentConfig: false
|
||||
...
|
||||
Executable
+549
@@ -0,0 +1,549 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# ===- run-clang-tidy.py - Parallel clang-tidy runner --------*- python -*--===#
|
||||
#
|
||||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
# ===-----------------------------------------------------------------------===#
|
||||
# FIXME: Integrate with clang-tidy-diff.py
|
||||
|
||||
|
||||
"""
|
||||
Parallel clang-tidy runner
|
||||
==========================
|
||||
|
||||
Runs clang-tidy over all files in a compilation database. Requires clang-tidy
|
||||
and clang-apply-replacements in $PATH.
|
||||
|
||||
Example invocations.
|
||||
- Run clang-tidy on all files in the current working directory with a default
|
||||
set of checks and show warnings in the cpp files and all project headers.
|
||||
run-clang-tidy.py $PWD
|
||||
|
||||
- Fix all header guards.
|
||||
run-clang-tidy.py -fix -checks=-*,llvm-header-guard
|
||||
|
||||
- Fix all header guards included from clang-tidy and header guards
|
||||
for clang-tidy headers.
|
||||
run-clang-tidy.py -fix -checks=-*,llvm-header-guard extra/clang-tidy \
|
||||
-header-filter=extra/clang-tidy
|
||||
|
||||
Compilation database setup:
|
||||
http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import json
|
||||
import multiprocessing
|
||||
import os
|
||||
import queue
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import traceback
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
yaml = None
|
||||
|
||||
|
||||
def strtobool(val):
|
||||
"""Convert a string representation of truth to a bool following LLVM's CLI argument parsing."""
|
||||
|
||||
val = val.lower()
|
||||
if val in ["", "true", "1"]:
|
||||
return True
|
||||
elif val in ["false", "0"]:
|
||||
return False
|
||||
|
||||
# Return ArgumentTypeError so that argparse does not substitute its own error message
|
||||
raise argparse.ArgumentTypeError(
|
||||
"'{}' is invalid value for boolean argument! Try 0 or 1.".format(val)
|
||||
)
|
||||
|
||||
|
||||
def find_compilation_database(path):
|
||||
"""Adjusts the directory until a compilation database is found."""
|
||||
result = os.path.realpath("./")
|
||||
while not os.path.isfile(os.path.join(result, path)):
|
||||
parent = os.path.dirname(result)
|
||||
if result == parent:
|
||||
print("Error: could not find compilation database.")
|
||||
sys.exit(1)
|
||||
result = parent
|
||||
return result
|
||||
|
||||
|
||||
def make_absolute(f, directory):
|
||||
if os.path.isabs(f):
|
||||
return f
|
||||
return os.path.normpath(os.path.join(directory, f))
|
||||
|
||||
|
||||
def get_tidy_invocation(
|
||||
f,
|
||||
clang_tidy_binary,
|
||||
checks,
|
||||
tmpdir,
|
||||
build_path,
|
||||
header_filter,
|
||||
allow_enabling_alpha_checkers,
|
||||
extra_arg,
|
||||
extra_arg_before,
|
||||
quiet,
|
||||
config_file_path,
|
||||
config,
|
||||
line_filter,
|
||||
use_color,
|
||||
plugins,
|
||||
warnings_as_errors,
|
||||
):
|
||||
"""Gets a command line for clang-tidy."""
|
||||
start = [clang_tidy_binary]
|
||||
if allow_enabling_alpha_checkers:
|
||||
start.append("-allow-enabling-analyzer-alpha-checkers")
|
||||
if header_filter is not None:
|
||||
start.append("-header-filter=" + header_filter)
|
||||
if line_filter is not None:
|
||||
start.append("-line-filter=" + line_filter)
|
||||
if use_color is not None:
|
||||
if use_color:
|
||||
start.append("--use-color")
|
||||
else:
|
||||
start.append("--use-color=false")
|
||||
if checks:
|
||||
start.append("-checks=" + checks)
|
||||
if tmpdir is not None:
|
||||
start.append("-export-fixes")
|
||||
# Get a temporary file. We immediately close the handle so clang-tidy can
|
||||
# overwrite it.
|
||||
(handle, name) = tempfile.mkstemp(suffix=".yaml", dir=tmpdir)
|
||||
os.close(handle)
|
||||
start.append(name)
|
||||
for arg in extra_arg:
|
||||
start.append("-extra-arg=%s" % arg)
|
||||
for arg in extra_arg_before:
|
||||
start.append("-extra-arg-before=%s" % arg)
|
||||
start.append("-p=" + build_path)
|
||||
if quiet:
|
||||
start.append("-quiet")
|
||||
if config_file_path:
|
||||
start.append("--config-file=" + config_file_path)
|
||||
elif config:
|
||||
start.append("-config=" + config)
|
||||
for plugin in plugins:
|
||||
start.append("-load=" + plugin)
|
||||
if warnings_as_errors:
|
||||
start.append("--warnings-as-errors=" + warnings_as_errors)
|
||||
start.append(f)
|
||||
return start
|
||||
|
||||
|
||||
def merge_replacement_files(tmpdir, mergefile):
|
||||
"""Merge all replacement files in a directory into a single file"""
|
||||
# The fixes suggested by clang-tidy >= 4.0.0 are given under
|
||||
# the top level key 'Diagnostics' in the output yaml files
|
||||
mergekey = "Diagnostics"
|
||||
merged = []
|
||||
for replacefile in glob.iglob(os.path.join(tmpdir, "*.yaml")):
|
||||
content = yaml.safe_load(open(replacefile, "r"))
|
||||
if not content:
|
||||
continue # Skip empty files.
|
||||
merged.extend(content.get(mergekey, []))
|
||||
|
||||
if merged:
|
||||
# MainSourceFile: The key is required by the definition inside
|
||||
# include/clang/Tooling/ReplacementsYaml.h, but the value
|
||||
# is actually never used inside clang-apply-replacements,
|
||||
# so we set it to '' here.
|
||||
output = {"MainSourceFile": "", mergekey: merged}
|
||||
with open(mergefile, "w") as out:
|
||||
yaml.safe_dump(output, out)
|
||||
else:
|
||||
# Empty the file:
|
||||
open(mergefile, "w").close()
|
||||
|
||||
|
||||
def find_binary(arg, name, build_path):
|
||||
"""Get the path for a binary or exit"""
|
||||
if arg:
|
||||
if shutil.which(arg):
|
||||
return arg
|
||||
else:
|
||||
raise SystemExit(
|
||||
"error: passed binary '{}' was not found or is not executable".format(
|
||||
arg
|
||||
)
|
||||
)
|
||||
|
||||
built_path = os.path.join(build_path, "bin", name)
|
||||
binary = shutil.which(name) or shutil.which(built_path)
|
||||
if binary:
|
||||
return binary
|
||||
else:
|
||||
raise SystemExit(
|
||||
"error: failed to find {} in $PATH or at {}".format(name, built_path)
|
||||
)
|
||||
|
||||
|
||||
def apply_fixes(args, clang_apply_replacements_binary, tmpdir):
|
||||
"""Calls clang-apply-fixes on a given directory."""
|
||||
invocation = [clang_apply_replacements_binary]
|
||||
invocation.append("-ignore-insert-conflict")
|
||||
if args.format:
|
||||
invocation.append("-format")
|
||||
if args.style:
|
||||
invocation.append("-style=" + args.style)
|
||||
invocation.append(tmpdir)
|
||||
subprocess.call(invocation)
|
||||
|
||||
|
||||
def run_tidy(args, clang_tidy_binary, tmpdir, build_path, queue, lock, failed_files):
|
||||
"""Takes filenames out of queue and runs clang-tidy on them."""
|
||||
while True:
|
||||
name = queue.get()
|
||||
invocation = get_tidy_invocation(
|
||||
name,
|
||||
clang_tidy_binary,
|
||||
args.checks,
|
||||
tmpdir,
|
||||
build_path,
|
||||
args.header_filter,
|
||||
args.allow_enabling_alpha_checkers,
|
||||
args.extra_arg,
|
||||
args.extra_arg_before,
|
||||
args.quiet,
|
||||
args.config_file,
|
||||
args.config,
|
||||
args.line_filter,
|
||||
args.use_color,
|
||||
args.plugins,
|
||||
args.warnings_as_errors,
|
||||
)
|
||||
|
||||
proc = subprocess.Popen(
|
||||
invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
output, err = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
if proc.returncode < 0:
|
||||
msg = "%s: terminated by signal %d\n" % (name, -proc.returncode)
|
||||
err += msg.encode("utf-8")
|
||||
failed_files.append(name)
|
||||
with lock:
|
||||
sys.stdout.write(" ".join(invocation) + "\n" + output.decode("utf-8"))
|
||||
if len(err) > 0:
|
||||
sys.stdout.flush()
|
||||
sys.stderr.write(err.decode("utf-8"))
|
||||
queue.task_done()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Runs clang-tidy over all files "
|
||||
"in a compilation database. Requires "
|
||||
"clang-tidy and clang-apply-replacements in "
|
||||
"$PATH or in your build directory."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-allow-enabling-alpha-checkers",
|
||||
action="store_true",
|
||||
help="allow alpha checkers from " "clang-analyzer.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-clang-tidy-binary", metavar="PATH", help="path to clang-tidy binary"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-clang-apply-replacements-binary",
|
||||
metavar="PATH",
|
||||
help="path to clang-apply-replacements binary",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-checks",
|
||||
default=None,
|
||||
help="checks filter, when not specified, use clang-tidy " "default",
|
||||
)
|
||||
config_group = parser.add_mutually_exclusive_group()
|
||||
config_group.add_argument(
|
||||
"-config",
|
||||
default=None,
|
||||
help="Specifies a configuration in YAML/JSON format: "
|
||||
" -config=\"{Checks: '*', "
|
||||
' CheckOptions: {x: y}}" '
|
||||
"When the value is empty, clang-tidy will "
|
||||
"attempt to find a file named .clang-tidy for "
|
||||
"each source file in its parent directories.",
|
||||
)
|
||||
config_group.add_argument(
|
||||
"-config-file",
|
||||
default=None,
|
||||
help="Specify the path of .clang-tidy or custom config "
|
||||
"file: e.g. -config-file=/some/path/myTidyConfigFile. "
|
||||
"This option internally works exactly the same way as "
|
||||
"-config option after reading specified config file. "
|
||||
"Use either -config-file or -config, not both.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-header-filter",
|
||||
default=None,
|
||||
help="regular expression matching the names of the "
|
||||
"headers to output diagnostics from. Diagnostics from "
|
||||
"the main file of each translation unit are always "
|
||||
"displayed.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-line-filter",
|
||||
default=None,
|
||||
help="List of files with line ranges to filter the" "warnings.",
|
||||
)
|
||||
if yaml:
|
||||
parser.add_argument(
|
||||
"-export-fixes",
|
||||
metavar="file_or_directory",
|
||||
dest="export_fixes",
|
||||
help="A directory or a yaml file to store suggested fixes in, "
|
||||
"which can be applied with clang-apply-replacements. If the "
|
||||
"parameter is a directory, the fixes of each compilation unit are "
|
||||
"stored in individual yaml files in the directory.",
|
||||
)
|
||||
else:
|
||||
parser.add_argument(
|
||||
"-export-fixes",
|
||||
metavar="directory",
|
||||
dest="export_fixes",
|
||||
help="A directory to store suggested fixes in, which can be applied "
|
||||
"with clang-apply-replacements. The fixes of each compilation unit are "
|
||||
"stored in individual yaml files in the directory.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-j",
|
||||
type=int,
|
||||
default=0,
|
||||
help="number of tidy instances to be run in parallel.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"files", nargs="*", default=[".*"], help="files to be processed (regex on path)"
|
||||
)
|
||||
parser.add_argument("-fix", action="store_true", help="apply fix-its")
|
||||
parser.add_argument(
|
||||
"-format", action="store_true", help="Reformat code " "after applying fixes"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-style",
|
||||
default="file",
|
||||
help="The style of reformat " "code after applying fixes",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-use-color",
|
||||
type=strtobool,
|
||||
nargs="?",
|
||||
const=True,
|
||||
help="Use colors in diagnostics, overriding clang-tidy's"
|
||||
" default behavior. This option overrides the 'UseColor"
|
||||
"' option in .clang-tidy file, if any.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", dest="build_path", help="Path used to read a compile command database."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-extra-arg",
|
||||
dest="extra_arg",
|
||||
action="append",
|
||||
default=[],
|
||||
help="Additional argument to append to the compiler " "command line.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-extra-arg-before",
|
||||
dest="extra_arg_before",
|
||||
action="append",
|
||||
default=[],
|
||||
help="Additional argument to prepend to the compiler " "command line.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-quiet", action="store_true", help="Run clang-tidy in quiet mode"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-load",
|
||||
dest="plugins",
|
||||
action="append",
|
||||
default=[],
|
||||
help="Load the specified plugin in clang-tidy.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-warnings-as-errors",
|
||||
default=None,
|
||||
help="Upgrades warnings to errors. Same format as " "'-checks'",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
db_path = "compile_commands.json"
|
||||
|
||||
if args.build_path is not None:
|
||||
build_path = args.build_path
|
||||
else:
|
||||
# Find our database
|
||||
build_path = find_compilation_database(db_path)
|
||||
|
||||
clang_tidy_binary = find_binary(args.clang_tidy_binary, "clang-tidy", build_path)
|
||||
|
||||
if args.fix:
|
||||
clang_apply_replacements_binary = find_binary(
|
||||
args.clang_apply_replacements_binary, "clang-apply-replacements", build_path
|
||||
)
|
||||
|
||||
combine_fixes = False
|
||||
export_fixes_dir = None
|
||||
delete_fixes_dir = False
|
||||
if args.export_fixes is not None:
|
||||
# if a directory is given, create it if it does not exist
|
||||
if args.export_fixes.endswith(os.path.sep) and not os.path.isdir(
|
||||
args.export_fixes
|
||||
):
|
||||
os.makedirs(args.export_fixes)
|
||||
|
||||
if not os.path.isdir(args.export_fixes):
|
||||
if not yaml:
|
||||
raise RuntimeError(
|
||||
"Cannot combine fixes in one yaml file. Either install PyYAML or specify an output directory."
|
||||
)
|
||||
|
||||
combine_fixes = True
|
||||
|
||||
if os.path.isdir(args.export_fixes):
|
||||
export_fixes_dir = args.export_fixes
|
||||
|
||||
if export_fixes_dir is None and (args.fix or combine_fixes):
|
||||
export_fixes_dir = tempfile.mkdtemp()
|
||||
delete_fixes_dir = True
|
||||
|
||||
# Load the database and extract all files.
|
||||
database = json.load(open(os.path.join(build_path, db_path)))
|
||||
files = set(
|
||||
[make_absolute(entry["file"], entry["directory"]) for entry in database]
|
||||
)
|
||||
|
||||
# Build up a big regexy filter from all command line arguments.
|
||||
file_name_re = re.compile("|".join(args.files))
|
||||
|
||||
# filter files with mo.group(0), and sort files
|
||||
matched_files = []
|
||||
for name in files:
|
||||
mo = file_name_re.search(name)
|
||||
if mo and mo.group(0):
|
||||
matched_files.append(name)
|
||||
files = sorted(matched_files)
|
||||
if not files:
|
||||
if delete_fixes_dir:
|
||||
shutil.rmtree(export_fixes_dir)
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
invocation = get_tidy_invocation(
|
||||
"",
|
||||
clang_tidy_binary,
|
||||
args.checks,
|
||||
None,
|
||||
build_path,
|
||||
args.header_filter,
|
||||
args.allow_enabling_alpha_checkers,
|
||||
args.extra_arg,
|
||||
args.extra_arg_before,
|
||||
args.quiet,
|
||||
args.config_file,
|
||||
args.config,
|
||||
args.line_filter,
|
||||
args.use_color,
|
||||
args.plugins,
|
||||
args.warnings_as_errors,
|
||||
)
|
||||
invocation.append("-list-checks")
|
||||
invocation.append("-")
|
||||
if args.quiet:
|
||||
# Even with -quiet we still want to check if we can call clang-tidy.
|
||||
with open(os.devnull, "w") as dev_null:
|
||||
subprocess.check_call(invocation, stdout=dev_null)
|
||||
else:
|
||||
subprocess.check_call(invocation)
|
||||
except:
|
||||
print("Unable to run clang-tidy.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
max_task = args.j
|
||||
if max_task == 0:
|
||||
max_task = multiprocessing.cpu_count()
|
||||
|
||||
return_code = 0
|
||||
try:
|
||||
# Spin up a bunch of tidy-launching threads.
|
||||
task_queue = queue.Queue(max_task)
|
||||
# List of files with a non-zero return code.
|
||||
failed_files = []
|
||||
lock = threading.Lock()
|
||||
for _ in range(max_task):
|
||||
t = threading.Thread(
|
||||
target=run_tidy,
|
||||
args=(
|
||||
args,
|
||||
clang_tidy_binary,
|
||||
export_fixes_dir,
|
||||
build_path,
|
||||
task_queue,
|
||||
lock,
|
||||
failed_files,
|
||||
),
|
||||
)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
# Fill the queue with files.
|
||||
for name in files:
|
||||
if file_name_re.search(name):
|
||||
task_queue.put(name)
|
||||
|
||||
# Wait for all threads to be done.
|
||||
task_queue.join()
|
||||
if len(failed_files):
|
||||
return_code = 1
|
||||
|
||||
except KeyboardInterrupt:
|
||||
# This is a sad hack. Unfortunately subprocess goes
|
||||
# bonkers with ctrl-c and we start forking merrily.
|
||||
print("\nCtrl-C detected, goodbye.")
|
||||
if delete_fixes_dir:
|
||||
shutil.rmtree(export_fixes_dir)
|
||||
os.kill(0, 9)
|
||||
|
||||
if combine_fixes:
|
||||
print("Writing fixes to " + args.export_fixes + " ...")
|
||||
try:
|
||||
merge_replacement_files(export_fixes_dir, args.export_fixes)
|
||||
except:
|
||||
print("Error exporting fixes.\n", file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
return_code = 1
|
||||
|
||||
if args.fix:
|
||||
print("Applying fixes ...")
|
||||
try:
|
||||
apply_fixes(args, clang_apply_replacements_binary, export_fixes_dir)
|
||||
except:
|
||||
print("Error applying fixes.\n", file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
return_code = 1
|
||||
|
||||
if delete_fixes_dir:
|
||||
shutil.rmtree(export_fixes_dir)
|
||||
sys.exit(return_code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,256 @@
|
||||
#
|
||||
# UPX top-level Makefile - needs GNU make and CMake >= 3.13
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
ifeq ($(UPX_MAKEFILE_EXTRA_MK_INCLUDED),)
|
||||
UPX_MAKEFILE_EXTRA_MK_INCLUDED := 1
|
||||
|
||||
#***********************************************************************
|
||||
# extra builds: some pre-defined build configurations
|
||||
#***********************************************************************
|
||||
|
||||
define run_config_and_build
|
||||
$(call run_config,$1,$2)
|
||||
$(call run_build,$1,$2)
|
||||
endef
|
||||
|
||||
# force building with clang/clang++
|
||||
build/extra/clang/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang/%: export CC = clang
|
||||
build/extra/clang/%: export CXX = clang++
|
||||
|
||||
# force building with clang/clang++ -m32
|
||||
build/extra/clang-m32/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-m32/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-m32/%: export CC = clang -m32
|
||||
build/extra/clang-m32/%: export CXX = clang++ -m32
|
||||
|
||||
# force building with clang/clang++ -mx32
|
||||
build/extra/clang-mx32/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-mx32/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-mx32/%: export CC = clang -mx32
|
||||
build/extra/clang-mx32/%: export CXX = clang++ -mx32
|
||||
|
||||
# force building with clang/clang++ -m64
|
||||
build/extra/clang-m64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-m64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-m64/%: export CC = clang -m64
|
||||
build/extra/clang-m64/%: export CXX = clang++ -m64
|
||||
|
||||
# force building with clang/clang++ -static
|
||||
build/extra/clang-static/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-static/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-static/%: export CC = clang -static
|
||||
build/extra/clang-static/%: export CXX = clang++ -static
|
||||
|
||||
# force building with clang/clang++ -static -flto
|
||||
build/extra/clang-static-lto/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-static-lto/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-static-lto/%: export CC = clang -static -flto
|
||||
build/extra/clang-static-lto/%: export CXX = clang++ -static -flto
|
||||
|
||||
# force building with clang/clang++ C17/C++20
|
||||
build/extra/clang-std-cxx20/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-std-cxx20/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-std-cxx20/%: export CC = clang -std=gnu17
|
||||
build/extra/clang-std-cxx20/%: export CXX = clang++ -std=gnu++20
|
||||
build/extra/clang-std-cxx20/%: export UPX_CONFIG_DISABLE_C_STANDARD=ON
|
||||
build/extra/clang-std-cxx20/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
|
||||
# force building with clang/clang++ C23/C++23
|
||||
build/extra/clang-std-cxx23/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-std-cxx23/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-std-cxx23/%: export CC = clang -std=gnu2x
|
||||
build/extra/clang-std-cxx23/%: export CXX = clang++ -std=gnu++2b
|
||||
build/extra/clang-std-cxx23/%: export UPX_CONFIG_DISABLE_C_STANDARD=ON
|
||||
build/extra/clang-std-cxx23/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
|
||||
# force building with gcc/g++
|
||||
build/extra/gcc/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc/%: export CC = gcc
|
||||
build/extra/gcc/%: export CXX = g++
|
||||
|
||||
# force building with gcc/g++ -m32
|
||||
build/extra/gcc-m32/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-m32/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-m32/%: export CC = gcc -m32
|
||||
build/extra/gcc-m32/%: export CXX = g++ -m32
|
||||
|
||||
# force building with gcc/g++ -mx32
|
||||
build/extra/gcc-mx32/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-mx32/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-mx32/%: export CC = gcc -mx32
|
||||
build/extra/gcc-mx32/%: export CXX = g++ -mx32
|
||||
|
||||
# force building with gcc/g++ -m64
|
||||
build/extra/gcc-m64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-m64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-m64/%: export CC = gcc -m64
|
||||
build/extra/gcc-m64/%: export CXX = g++ -m64
|
||||
|
||||
# force building with gcc/g++ -static
|
||||
build/extra/gcc-static/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-static/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-static/%: export CC = gcc -static
|
||||
build/extra/gcc-static/%: export CXX = g++ -static
|
||||
|
||||
# force building with gcc/g++ -static -flto
|
||||
build/extra/gcc-static-lto/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-static-lto/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-static-lto/%: export CC = gcc -static -flto
|
||||
build/extra/gcc-static-lto/%: export CXX = g++ -static -flto
|
||||
|
||||
# force building with gcc/g++ C17/C++20
|
||||
build/extra/gcc-std-cxx20/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-std-cxx20/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-std-cxx20/%: export CC = gcc -std=gnu17
|
||||
build/extra/gcc-std-cxx20/%: export CXX = g++ -std=gnu++20
|
||||
build/extra/gcc-std-cxx20/%: export UPX_CONFIG_DISABLE_C_STANDARD=ON
|
||||
build/extra/gcc-std-cxx20/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
|
||||
# force building with gcc/g++ C23/C++23
|
||||
build/extra/gcc-std-cxx23/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-std-cxx23/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-std-cxx23/%: export CC = gcc -std=gnu2x
|
||||
build/extra/gcc-std-cxx23/%: export CXX = g++ -std=gnu++23
|
||||
build/extra/gcc-std-cxx23/%: export UPX_CONFIG_DISABLE_C_STANDARD=ON
|
||||
build/extra/gcc-std-cxx23/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON
|
||||
|
||||
# cross compiler: Linux glibc aarch64-linux-gnu (arm64)
|
||||
build/extra/cross-linux-gnu-aarch64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/cross-linux-gnu-aarch64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/cross-linux-gnu-aarch64/%: export CC = aarch64-linux-gnu-gcc
|
||||
build/extra/cross-linux-gnu-aarch64/%: export CXX = aarch64-linux-gnu-g++
|
||||
|
||||
# cross compiler: Linux glibc arm-linux-gnueabihf
|
||||
build/extra/cross-linux-gnu-arm-eabihf/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/cross-linux-gnu-arm-eabihf/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/cross-linux-gnu-arm-eabihf/%: export CC = arm-linux-gnueabihf-gcc
|
||||
build/extra/cross-linux-gnu-arm-eabihf/%: export CXX = arm-linux-gnueabihf-g++ -Wno-psabi
|
||||
|
||||
# cross compiler: Windows x86 win32 MinGW (i386)
|
||||
build/extra/cross-windows-mingw32/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/cross-windows-mingw32/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/cross-windows-mingw32/%: export CC = i686-w64-mingw32-gcc -static -D_WIN32_WINNT=0x0400
|
||||
build/extra/cross-windows-mingw32/%: export CXX = i686-w64-mingw32-g++ -static -D_WIN32_WINNT=0x0400
|
||||
|
||||
# cross compiler: Windows x64 win64 MinGW (amd64)
|
||||
build/extra/cross-windows-mingw64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/cross-windows-mingw64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/cross-windows-mingw64/%: export CC = x86_64-w64-mingw32-gcc -static -D_WIN32_WINNT=0x0400
|
||||
build/extra/cross-windows-mingw64/%: export CXX = x86_64-w64-mingw32-g++ -static -D_WIN32_WINNT=0x0400
|
||||
|
||||
# cross compiler: macOS arm64 (aarch64)
|
||||
build/extra/cross-darwin-arm64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/cross-darwin-arm64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/cross-darwin-arm64/%: export CC = clang -target arm64-apple-darwin
|
||||
build/extra/cross-darwin-arm64/%: export CXX = clang++ -target arm64-apple-darwin
|
||||
|
||||
# cross compiler: macOS x86_64 (amd64)
|
||||
build/extra/cross-darwin-x86_64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/cross-darwin-x86_64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/cross-darwin-x86_64/%: export CC = clang -target x86_64-apple-darwin
|
||||
build/extra/cross-darwin-x86_64/%: export CXX = clang++ -target x86_64-apple-darwin
|
||||
|
||||
#***********************************************************************
|
||||
# C/C++ static analyzers
|
||||
#***********************************************************************
|
||||
|
||||
# force building with clang Static Analyzer (scan-build)
|
||||
SCAN_BUILD = scan-build
|
||||
build/analyze/clang-analyzer/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/analyze/clang-analyzer/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/analyze/clang-analyzer/%: override CMAKE := $(SCAN_BUILD) $(CMAKE)
|
||||
build/analyze/clang-analyzer/%: export CCC_CC ?= clang
|
||||
build/analyze/clang-analyzer/%: export CCC_CXX ?= clang++
|
||||
|
||||
# run clang-tidy: uses file compile_commands.json from an existing clang build
|
||||
# does not create any actual files, so purely PHONY
|
||||
RUN_CLANG_TIDY = time python3 ./misc/analyze/clang-tidy/run-clang-tidy.py -p $<
|
||||
RUN_CLANG_TIDY_WERROR = $(RUN_CLANG_TIDY) '-warnings-as-errors=*'
|
||||
build/analyze/clang-tidy-upx/debug build/analyze/clang-tidy-upx/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY_WERROR) -config-file ./.clang-tidy '/src/.*\.cpp'
|
||||
build/analyze/clang-tidy-bzip2/debug build/analyze/clang-tidy-bzip2/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY) -config-file ./misc/analyze/clang-tidy/clang-tidy-bzip2.yml /vendor/bzip2/
|
||||
build/analyze/clang-tidy-ucl/debug build/analyze/clang-tidy-ucl/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY_WERROR) -config-file ./misc/analyze/clang-tidy/clang-tidy-ucl.yml /vendor/ucl/
|
||||
build/analyze/clang-tidy-zlib/debug build/analyze/clang-tidy-zlib/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY_WERROR) -config-file ./misc/analyze/clang-tidy/clang-tidy-zlib.yml /vendor/zlib/
|
||||
build/analyze/clang-tidy-zstd/debug build/analyze/clang-tidy-zstd/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY) -config-file ./misc/analyze/clang-tidy/clang-tidy-zstd.yml /vendor/zstd/
|
||||
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-upx/$$(notdir $$@)
|
||||
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-bzip2/$$(notdir $$@)
|
||||
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-ucl/$$(notdir $$@)
|
||||
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-zlib/$$(notdir $$@)
|
||||
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-zstd/$$(notdir $$@)
|
||||
|
||||
# OLD names [deprecated]
|
||||
build/extra/scan-build/debug: build/analyze/clang-analyzer/debug
|
||||
build/extra/scan-build/release: build/analyze/clang-analyzer/release
|
||||
|
||||
#***********************************************************************
|
||||
# advanced: generic extra target
|
||||
#***********************************************************************
|
||||
|
||||
# usage:
|
||||
# make UPX_XTARGET=my-target CC="my-cc -flags" CXX="my-cxx -flags"
|
||||
# make UPX_XTARGET=my-target CC="my-cc -flags" CXX="my-cxx -flags" xtarget/debug
|
||||
|
||||
ifneq ($(UPX_XTARGET),)
|
||||
ifneq ($(CC),)
|
||||
ifneq ($(CXX),)
|
||||
|
||||
UPX_XTARGET := $(UPX_XTARGET)
|
||||
build/xtarget/$(UPX_XTARGET)/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/xtarget/$(UPX_XTARGET)/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/xtarget/$(UPX_XTARGET)/%: export CC
|
||||
build/xtarget/$(UPX_XTARGET)/%: export CXX
|
||||
# shortcuts
|
||||
xtarget/all: xtarget/debug xtarget/release
|
||||
xtarget/debug: build/xtarget/$(UPX_XTARGET)/debug
|
||||
xtarget/release: build/xtarget/$(UPX_XTARGET)/release
|
||||
# set new default
|
||||
.DEFAULT_GOAL = xtarget/release
|
||||
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#***********************************************************************
|
||||
# assemble cmake config flags; useful for CI jobs
|
||||
#***********************************************************************
|
||||
|
||||
ifneq ($(origin UPX_CMAKE_CONFIG_FLAGS),command line) # needed to work around a GNU make bug
|
||||
|
||||
# info: by default CMake only honors the CC and CXX environment variables; make
|
||||
# it easy to set other variables like CMAKE_AR or CMAKE_RANLIB
|
||||
__add_cmake_config = $(and $($1),-D$1="$($1)")
|
||||
# pass common CMake settings from environment/make to cmake
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_AR)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_NM)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_RANLIB)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_OBJCOPY)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_OBJDUMP)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_STRIP)
|
||||
# pass UPX config options from environment/make to cmake; see CMakeLists.txt
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_GITREV)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_SANITIZE)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_WSTRICT)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_WERROR)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_SELF_PACK_TEST)
|
||||
|
||||
endif # bug work-around
|
||||
|
||||
#***********************************************************************
|
||||
# check git submodules
|
||||
#***********************************************************************
|
||||
|
||||
SUBMODULES = doctest lzma-sdk ucl valgrind zlib
|
||||
|
||||
dummy := $(foreach m,$(SUBMODULES),$(if $(wildcard vendor/$m/[CL]*),$m,\
|
||||
$(error ERROR: missing git submodule '$m'; run 'git submodule update --init')))
|
||||
|
||||
endif # UPX_MAKEFILE_EXTRA_MK_INCLUDED
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# create the image from Dockerfile
|
||||
# using a rootless Podman container
|
||||
|
||||
# NOTE: this image is based on rebuild-stubs/upx-stubtools-20221212-v6,
|
||||
# so you have to create that image first
|
||||
# WARNING: we install many packages, so the resulting image needs A LOT of disk space!
|
||||
image=upx-cross-compile-ubuntu2204-20230721-v1
|
||||
[[ $1 == --print-image ]] && echo "$image" && exit 0
|
||||
|
||||
podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir"
|
||||
|
||||
podman image list "$image"
|
||||
echo
|
||||
podman image tree "$image"
|
||||
@@ -0,0 +1,40 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# list all system packages that are installed in the image
|
||||
# using a rootless Podman container
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
podman image list "$image"
|
||||
echo
|
||||
podman image tree "$image"
|
||||
|
||||
echo 'Packages:'
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
podman run "${flags[@]}" "$image" bash -c $'dpkg -l | sed \'s/ *$//\' | LC_ALL=C sort'
|
||||
|
||||
echo
|
||||
echo 'Packages sorted by Installed-Size:'
|
||||
podman run "${flags[@]}" "$image" bash -c $'awk \'
|
||||
BEGIN {
|
||||
arch = "UNKNOWN"; size = 0; package = "UNKNOWN";
|
||||
}
|
||||
{
|
||||
if ($1 == "Architecture:") arch = $2;
|
||||
if ($1 == "Installed-Size:") size = $2;
|
||||
if ($1 == "Package:") package = $2;
|
||||
if ($1 == "") {
|
||||
printf("%9d %-40s %s\\n", size, package, arch);
|
||||
count += 1; total += size;
|
||||
arch = "UNKNOWN"; size = 0; package = "UNKNOWN";
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("%9d ===== TOTAL (%d packages)\\n", total, count);
|
||||
}
|
||||
\' /var/lib/dpkg/status | LC_ALL=C sort -rn'
|
||||
@@ -0,0 +1,60 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# run an interactive shell in the image
|
||||
# using a rootless Podman container
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
flags+=( -ti -e TERM="$TERM" ) # allocate an interactive pseudo-tty and pass $TERM
|
||||
if [[ 1 == 1 ]]; then
|
||||
# run as user upx 2000:2000
|
||||
flags+=( --user 2000 )
|
||||
# map container users 0..999 to subuid-users 1..1000, and map container user 2000 to current host user
|
||||
flags+=( --uidmap=0:1:1000 --uidmap=2000:0:1 )
|
||||
# map container groups 0..999 to subgid-groups 1..1000, and map container group 2000 to current host group
|
||||
flags+=( --gidmap=0:1:1000 --gidmap=2000:0:1 )
|
||||
# NOTE: we mount the upx top-level directory read-write under /home/upx/src/upx
|
||||
# INFO: SELinux users *may* have to add ":z" to the volume mount flags; check the docs!
|
||||
flags+=( -v "${argv0dir}/../../..:/home/upx/src/upx" )
|
||||
flags+=( -w /home/upx/src/upx ) # set working directory
|
||||
flags+=( --tmpfs /home/upx/.cache:rw,exec ) # mount a writeable tmpfs
|
||||
flags+=( --tmpfs /home/upx/.local:rw,exec ) # mount a writeable tmpfs
|
||||
else
|
||||
# run as user root 0:0
|
||||
# ONLY FOR DEBUGGING THE IMAGE
|
||||
# map container user/group 0 to current host user/group
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# now we can cross-compile UPX for Windows:
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/cross-windows-mingw64/release
|
||||
# make build/extra/cross-windows-mingw64/release
|
||||
|
||||
# and we can run the clang Static Analyzer (scan-build)
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/scan-build/release
|
||||
# make build/extra/scan-build/release
|
||||
|
||||
# and lots of other cross-compilers are installed; see "ls /usr/bin/*g++*"
|
||||
|
||||
# and finally see
|
||||
# ./misc/podman/cross-compile-upx-ubuntu/build-all-inside-container.sh
|
||||
# after running that script we can do cool things like:
|
||||
# cd /home/upx/src/upx/build/cross-compile-upx-ubuntu2204/alpha-linux-gnu/debug
|
||||
# qemu-alpha -L /usr/alpha-linux-gnu ./upx --version
|
||||
# cd /home/upx/src/upx/build/cross-compile-upx-ubuntu2204/hppa-linux-gnu/debug
|
||||
# qemu-hppa -L /usr/hppa-linux-gnu ./upx --version
|
||||
# (similar for many other architectures/builds)
|
||||
@@ -0,0 +1,54 @@
|
||||
# NOTE: this image is based on rebuild-stubs/upx-stubtools-20221212-v6,
|
||||
# so you have to create that image first
|
||||
# WARNING: we install many packages, so the resulting image needs A LOT of disk space!
|
||||
FROM localhost/upx-stubtools-20221212-v6
|
||||
ENV UPX_CONTAINER_IMAGE_NAME=upx-cross-compile-ubuntu2204-20230721-v1
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
USER root
|
||||
|
||||
# Ubuntu 22.04
|
||||
RUN apt-get update && apt-get upgrade -y \
|
||||
&& apt-get install -y \
|
||||
# Linux glibc cross compilers
|
||||
g++-aarch64-linux-gnu \
|
||||
g++-alpha-linux-gnu \
|
||||
g++-arm-linux-gnueabi \
|
||||
g++-arm-linux-gnueabihf \
|
||||
g++-hppa-linux-gnu \
|
||||
g++-i686-linux-gnu \
|
||||
g++-m68k-linux-gnu \
|
||||
g++-mips-linux-gnu \
|
||||
g++-mipsel-linux-gnu \
|
||||
g++-mips64-linux-gnuabi64 \
|
||||
g++-mips64el-linux-gnuabi64 \
|
||||
g++-powerpc-linux-gnu \
|
||||
g++-powerpc64-linux-gnu \
|
||||
g++-powerpc64le-linux-gnu \
|
||||
g++-riscv64-linux-gnu \
|
||||
g++-s390x-linux-gnu \
|
||||
g++-sh4-linux-gnu \
|
||||
g++-sparc64-linux-gnu \
|
||||
# Linux glibc cross compilers - ILP32 on 64-bit CPUs
|
||||
g++-x86-64-linux-gnux32 \
|
||||
# Windows cross compilers
|
||||
g++-mingw-w64-i686 \
|
||||
g++-mingw-w64-x86-64 \
|
||||
&& true
|
||||
RUN apt-get install -y \
|
||||
# clang-14 and tools
|
||||
clang-14 clang-format-14 clang-tidy-14 clang-tools-14 lldb-14 llvm-14 \
|
||||
# QEMU and Wine
|
||||
qemu-system qemu-user wine wine32:i386 wine64 \
|
||||
# misc
|
||||
gdb lsb-release valgrind \
|
||||
&& true
|
||||
RUN cd /usr/bin \
|
||||
# create unversioned clang symlinks in /usr/local/bin
|
||||
&& for f in clang*-14 llvm-*-14 scan-*-14; do ln -s -v ../../bin/$f /usr/local/bin/${f%-14}; done \
|
||||
&& ln -s -v ../../bin/obj2yaml-14 /usr/local/bin/llvm-obj2yaml \
|
||||
&& ln -s -v ../../bin/yaml2obj-14 /usr/local/bin/llvm-yaml2obj \
|
||||
&& true
|
||||
|
||||
# switch back to default user upx:upx 2000:2000
|
||||
USER upx
|
||||
@@ -0,0 +1,99 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# build UPX for 21 targets; must be run inside the container!
|
||||
# using a rootless Podman container
|
||||
|
||||
# simple sanity check that we are indeed running inside the container
|
||||
if [[ $UPX_CONTAINER_IMAGE_NAME != upx-cross-compile-* ]]; then
|
||||
echo "$argv0: NOTE: please run this script *inside* the container"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# go to upx top-level directory
|
||||
cd "$argv0dir/../../.." || exit 1
|
||||
pwd
|
||||
test -f doc/upx.pod || exit 1 # sanity check
|
||||
test -f src/version.h || exit 1 # sanity check
|
||||
|
||||
function run_config_and_build {
|
||||
# requires: AR CC CXX RANLIB
|
||||
local toolchain=$1
|
||||
local cmake_config_flags build_type bdir
|
||||
# cmake flags
|
||||
cmake_config_flags=
|
||||
case $toolchain in
|
||||
# these old architectures do not support sanitize
|
||||
alpha-linux-gnu) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;;
|
||||
hppa-linux-gnu) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;;
|
||||
# avoid sanitize link errors with current MinGW-w64 versions; link libstdc++ statically
|
||||
i686-w64-mingw32)
|
||||
cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON
|
||||
CC="$CC -static"; CXX="$CXX -static" ;;
|
||||
x86_64-w64-mingw32)
|
||||
cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON
|
||||
CC="$CC -static"; CXX="$CXX -static" ;;
|
||||
# avoid warnings about arm libstdc++ ABI change in gcc-7
|
||||
arm-linux-*) CXX="$CXX -Wno-psabi" ;;
|
||||
esac
|
||||
if [[ 1 == 1 ]]; then
|
||||
# prefer building with Ninja (ninja-build)
|
||||
cmake_config_flags="$cmake_config_flags -G Ninja -DUPX_CONFIG_CMAKE_DISABLE_INSTALL=ON"
|
||||
fi
|
||||
# for all build types
|
||||
for build_type in Debug Release; do
|
||||
bdir="build/cross-compile-upx-ubuntu2204/$toolchain/${build_type,,}"
|
||||
mkdir -p "$bdir"
|
||||
# run_config
|
||||
if [[ ! -f $bdir/CMakeCache.txt ]]; then
|
||||
export CMAKE_REQUIRED_QUIET=OFF
|
||||
cmake -S . -B "$bdir" -DCMAKE_BUILD_TYPE=$build_type -DCMAKE_AR="$AR" -DCMAKE_RANLIB="$RANLIB" $cmake_config_flags
|
||||
fi
|
||||
# run_build
|
||||
cmake --build "$bdir" --config $build_type --parallel
|
||||
done
|
||||
}
|
||||
|
||||
# see Dockerfile for packages
|
||||
for package in \
|
||||
g++-aarch64-linux-gnu \
|
||||
g++-alpha-linux-gnu \
|
||||
g++-arm-linux-gnueabi \
|
||||
g++-arm-linux-gnueabihf \
|
||||
g++-hppa-linux-gnu \
|
||||
g++-i686-linux-gnu \
|
||||
g++-m68k-linux-gnu \
|
||||
g++-mips-linux-gnu \
|
||||
g++-mipsel-linux-gnu \
|
||||
g++-mips64-linux-gnuabi64 \
|
||||
g++-mips64el-linux-gnuabi64 \
|
||||
g++-powerpc-linux-gnu \
|
||||
g++-powerpc64-linux-gnu \
|
||||
g++-powerpc64le-linux-gnu \
|
||||
g++-riscv64-linux-gnu \
|
||||
g++-s390x-linux-gnu \
|
||||
g++-sh4-linux-gnu \
|
||||
g++-sparc64-linux-gnu \
|
||||
g++-x86-64-linux-gnux32 \
|
||||
g++-mingw-w64-i686 \
|
||||
g++-mingw-w64-x86-64
|
||||
do
|
||||
# setup toolchain and environment variables
|
||||
toolchain=$package
|
||||
toolchain=${toolchain/-x86-64/-x86_64}
|
||||
toolchain=${toolchain/g++-/}
|
||||
case $toolchain in
|
||||
mingw-w64-i686) toolchain=i686-w64-mingw32 ;;
|
||||
mingw-w64-x86_64) toolchain=x86_64-w64-mingw32 ;;
|
||||
esac
|
||||
echo "========== $toolchain"
|
||||
export AR=/usr/bin/${toolchain}-ar
|
||||
export CC=/usr/bin/${toolchain}-gcc
|
||||
export CXX=/usr/bin/${toolchain}-g++
|
||||
export RANLIB=/usr/bin/${toolchain}-ranlib
|
||||
ls -l "$AR" "$CC" "$CXX" "$RANLIB"
|
||||
run_config_and_build $toolchain
|
||||
unset AR CC CXX RANLIB
|
||||
done
|
||||
File diff suppressed because it is too large
Load Diff
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# create the image from Dockerfile
|
||||
# using a rootless Podman container
|
||||
|
||||
image=upx-stubtools-20221212-v6
|
||||
[[ $1 == --print-image ]] && echo "$image" && exit 0
|
||||
|
||||
podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir"
|
||||
|
||||
podman image list "$image"
|
||||
echo
|
||||
podman image tree "$image"
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# list all system packages that are installed in the image
|
||||
# using a rootless Podman container
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
podman image list "$image"
|
||||
echo
|
||||
podman image tree "$image"
|
||||
|
||||
echo 'Packages:'
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
podman run "${flags[@]}" "$image" bash -c $'dpkg -l | sed \'s/ *$//\' | LC_ALL=C sort'
|
||||
|
||||
echo
|
||||
echo 'Packages sorted by Installed-Size:'
|
||||
podman run "${flags[@]}" "$image" bash -c $'awk \'
|
||||
BEGIN {
|
||||
arch = "UNKNOWN"; size = 0; package = "UNKNOWN";
|
||||
}
|
||||
{
|
||||
if ($1 == "Architecture:") arch = $2;
|
||||
if ($1 == "Installed-Size:") size = $2;
|
||||
if ($1 == "Package:") package = $2;
|
||||
if ($1 == "") {
|
||||
printf("%9d %-40s %s\\n", size, package, arch);
|
||||
count += 1; total += size;
|
||||
arch = "UNKNOWN"; size = 0; package = "UNKNOWN";
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("%9d ===== TOTAL (%d packages)\\n", total, count);
|
||||
}
|
||||
\' /var/lib/dpkg/status | LC_ALL=C sort -rn'
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# run an interactive shell in the image
|
||||
# using a rootless Podman container
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
flags+=( -ti -e TERM="$TERM" ) # allocate an interactive pseudo-tty and pass $TERM
|
||||
if [[ 1 == 1 ]]; then
|
||||
# run as user upx 2000:2000
|
||||
flags+=( --user 2000 )
|
||||
# map container users 0..999 to subuid-users 1..1000, and map container user 2000 to current host user
|
||||
flags+=( --uidmap=0:1:1000 --uidmap=2000:0:1 )
|
||||
# map container groups 0..999 to subgid-groups 1..1000, and map container group 2000 to current host group
|
||||
flags+=( --gidmap=0:1:1000 --gidmap=2000:0:1 )
|
||||
# NOTE: we mount the upx top-level directory read-write under /home/upx/src/upx
|
||||
# INFO: SELinux users *may* have to add ":z" to the volume mount flags; check the docs!
|
||||
flags+=( -v "${argv0dir}/../../..:/home/upx/src/upx" )
|
||||
flags+=( -w /home/upx/src/upx ) # set working directory
|
||||
flags+=( --tmpfs /home/upx/.cache:rw,exec ) # mount a writeable tmpfs
|
||||
flags+=( --tmpfs /home/upx/.local:rw,exec ) # mount a writeable tmpfs
|
||||
else
|
||||
# run as user root 0:0
|
||||
# ONLY FOR DEBUGGING THE IMAGE
|
||||
# map container user/group 0 to current host user/group
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# now we can rebuild the UPX stubs:
|
||||
# cd /home/upx/src/upx/src/stub
|
||||
# # make sure that git is clean:
|
||||
# git status .
|
||||
# # remove stub files and make sure that they got deleted:
|
||||
# make maintainer-clean extra-clean
|
||||
# git status .
|
||||
# # rebuild
|
||||
# make extra-all all
|
||||
# # make sure that the stub files did rebuild correctly:
|
||||
# git status .
|
||||
# git diff .
|
||||
|
||||
# we can also build UPX in the container:
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/gcc/release
|
||||
# make build/extra/gcc/release
|
||||
# # run tests
|
||||
# ./build/extra/gcc/release/upx --version
|
||||
# make -C build/extra/gcc/release test
|
||||
|
||||
# and we can also build UPX with -m32:
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/gcc-m32/release
|
||||
# make build/extra/gcc-m32/release
|
||||
# # run tests
|
||||
# ./build/extra/gcc-m32/release/upx --version
|
||||
# make -C build/extra/gcc-m32/release test
|
||||
|
||||
# and we can also build UPX with -mx32: (NOTE: needs CONFIG_X86_X32_ABI on host kernel!)
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/gcc-mx32/release
|
||||
# make build/extra/gcc-mx32/release
|
||||
# # run tests (needs CONFIG_X86_X32_ABI on host kernel)
|
||||
# ./build/extra/gcc-mx32/release/upx --version
|
||||
# make -C build/extra/gcc-mx32/release test
|
||||
|
||||
# and we can also rebuild the UPX docs the container:
|
||||
# cd /home/upx/src/upx/doc
|
||||
# make clean all
|
||||
# git status .
|
||||
# git diff .
|
||||
@@ -0,0 +1,66 @@
|
||||
FROM docker.io/library/ubuntu:22.04
|
||||
ENV UPX_CONTAINER_IMAGE_NAME=upx-stubtools-20221212-v6
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
# install system packages
|
||||
RUN dpkg --add-architecture i386 \
|
||||
&& apt-get update && apt-get upgrade -y \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
aria2 bash bash-completion ca-certificates dash git less libmpc3 libncurses5 \
|
||||
make ncurses-term perl-base python2-minimal time wget xz-utils \
|
||||
libc6:i386 zlib1g:i386 \
|
||||
# the following packages are not required for rebuilding the stubs, but
|
||||
# they do make the image *much* more convenient and also allow building
|
||||
# the full UPX binary inside the container via CMake:
|
||||
7zip bfs busybox bzip2 cabextract ccache chrpath cmake cpio curl elfutils fd-find file fzf \
|
||||
g++ gawk gdb gojq ht htop hyperfine jq libzstd-dev lsb-release lz4 lzip lzop \
|
||||
mksh moreutils ninja-build p7zip parallel patch patchelf pax-utils paxctl \
|
||||
python3 python3-pyasn1 python3-pycryptodome python3-zstd \
|
||||
re2c ripgrep rsync screen universal-ctags unzip vim yash zip zlib1g-dev zsh zstd \
|
||||
# extra packages for compiling with "gcc -m32" and and "gcc -mx32":
|
||||
g++-multilib gcc-multilib \
|
||||
&& true
|
||||
|
||||
# manually unpack and install compat libs from Ubuntu-16.04; REQUIRED
|
||||
RUN cd /root \
|
||||
&& aria2c --checksum=sha-256=de22baf3dd851a10e16fbf66a243e70149ca46e06b2939fdc79429196cefc090 \
|
||||
'https://archive.kernel.org/ubuntu-archive/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.6-1_amd64.deb' \
|
||||
&& mkdir packages \
|
||||
&& for f in ./*.deb; do dpkg -x $f ./packages; done \
|
||||
&& mv -v -n ./packages/usr/lib/x86_64-linux-gnu/lib* /usr/lib/x86_64-linux-gnu/ \
|
||||
&& rm -rf ./*.deb ./packages \
|
||||
&& ldconfig \
|
||||
&& true
|
||||
|
||||
# install upx-stubtools into /usr/local/bin/bin-upx-20221212; REQUIRED
|
||||
RUN cd /root \
|
||||
&& aria2c --checksum=sha-256=509e06639118a79d8e79489a400e134c6d3ca36bad2c6ec29648d7c1e5b81afa \
|
||||
'https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz' \
|
||||
&& cd /usr/local/bin \
|
||||
&& tar -xoaf /root/bin-upx-20221212.tar.xz \
|
||||
&& rm /root/bin-upx-20221212.tar.xz \
|
||||
&& true
|
||||
|
||||
# install official UPX release binaries into /usr/local/bin; not required but convenient for testing
|
||||
RUN cd /root \
|
||||
&& wget -q https://github.com/upx/upx/releases/download/v3.91/upx-3.91-amd64_linux.tar.bz2 \
|
||||
&& xzlist="3.92 3.93 3.94 3.95 3.96 4.0.0 4.0.1 4.0.2 4.1.0 4.2.0 4.2.1" \
|
||||
&& for v in $xzlist; do wget -q https://github.com/upx/upx/releases/download/v${v}/upx-${v}-amd64_linux.tar.xz; done \
|
||||
&& for f in ./upx-*.tar.*; do tar -xoaf $f; done \
|
||||
&& for v in 3.91 $xzlist; do d=upx-${v}-amd64_linux; ./$d/upx -qq -d $d/upx -o /usr/local/bin/upx-${v}; done \
|
||||
&& rm -r ./upx-*.tar.* ./upx-*linux \
|
||||
&& true
|
||||
|
||||
# create default user upx:upx 2000:2000
|
||||
RUN useradd upx -U --uid 2000 --shell /bin/bash -m \
|
||||
&& cd /home/upx && chmod 00700 . \
|
||||
# prepare ~/.cache and ~/.local for possible tmpfs mounts
|
||||
&& mkdir -p .cache/tmp .local/bin src/upx \
|
||||
&& for d in ccache fontconfig go-build mesa_shader_cache tmp wine zig; do mkdir -p .cache/$d; done \
|
||||
&& for d in bin include lib share state; do mkdir -p .local/$d; done \
|
||||
&& ln -s .cache/wine .wine && ln -s .cache/tmp tmp \
|
||||
&& ln -s /usr/local/bin/bin-upx-20221212 .local/bin/bin-upx \
|
||||
&& chown -R upx:upx . \
|
||||
&& true
|
||||
USER upx
|
||||
@@ -0,0 +1,657 @@
|
||||
Packages:
|
||||
+++-===========================-=======================================-============-================================================================================
|
||||
Desired=Unknown/Install/Remove/Purge/Hold
|
||||
ii 7zip 21.07+dfsg-4 amd64 7-Zip file archiver with a high compression ratio
|
||||
ii adduser 3.118ubuntu5 all add and remove users and groups
|
||||
ii apt 2.4.10 amd64 commandline package manager
|
||||
ii aria2 1.36.0-1 amd64 High speed download utility
|
||||
ii base-files 12ubuntu4.4 amd64 Debian base system miscellaneous files
|
||||
ii base-passwd 3.5.52build1 amd64 Debian base system master password and group files
|
||||
ii bash 5.1-6ubuntu1 amd64 GNU Bourne Again SHell
|
||||
ii bash-completion 1:2.11-5ubuntu1 all programmable completion for the bash shell
|
||||
ii bfs 2.3.1-1 amd64 Breadth-first version of find(1)
|
||||
ii binutils 2.38-4ubuntu2.3 amd64 GNU assembler, linker and binary utilities
|
||||
ii binutils-common:amd64 2.38-4ubuntu2.3 amd64 Common files for the GNU assembler, linker and binary utilities
|
||||
ii binutils-x86-64-linux-gnu 2.38-4ubuntu2.3 amd64 GNU binary utilities, for x86-64-linux-gnu target
|
||||
ii bsdutils 1:2.37.2-4ubuntu3 amd64 basic utilities from 4.4BSD-Lite
|
||||
ii busybox 1:1.30.1-7ubuntu3 amd64 Tiny utilities for small and embedded systems
|
||||
ii bzip2 1.0.8-5build1 amd64 high-quality block-sorting file compressor - utilities
|
||||
ii ca-certificates 20230311ubuntu0.22.04.1 all Common CA certificates
|
||||
ii cabextract 1.9-3 amd64 Microsoft Cabinet file unpacker
|
||||
ii ccache 4.5.1-1 amd64 Compiler cache for fast recompilation of C/C++ code
|
||||
ii chrpath 0.16-2 amd64 Tool to edit the rpath in ELF binaries
|
||||
ii cmake 3.22.1-1ubuntu1.22.04.1 amd64 cross-platform, open-source make system
|
||||
ii cmake-data 3.22.1-1ubuntu1.22.04.1 all CMake data files (modules, templates and documentation)
|
||||
ii coreutils 8.32-4.1ubuntu1 amd64 GNU core utilities
|
||||
ii cpio 2.13+dfsg-7 amd64 GNU cpio -- a program to manage archives of files
|
||||
ii cpp 4:11.2.0-1ubuntu1 amd64 GNU C preprocessor (cpp)
|
||||
ii cpp-11 11.4.0-1ubuntu1~22.04 amd64 GNU C preprocessor
|
||||
ii curl 7.81.0-1ubuntu1.14 amd64 command line tool for transferring data with URL syntax
|
||||
ii dash 0.5.11+git20210903+057cd650a4ed-3build1 amd64 POSIX-compliant shell
|
||||
ii debconf 1.5.79ubuntu1 all Debian configuration management system
|
||||
ii debianutils 5.5-1ubuntu2 amd64 Miscellaneous utilities specific to Debian
|
||||
ii dh-elpa-helper 2.0.9ubuntu1 all helper package for emacs lisp extensions
|
||||
ii diffutils 1:3.8-0ubuntu2 amd64 File comparison utilities
|
||||
ii distro-info-data 0.52ubuntu0.5 all information about the distributions' releases (data files)
|
||||
ii dpkg 1.21.1ubuntu2.2 amd64 Debian package management system
|
||||
ii e2fsprogs 1.46.5-2ubuntu1.1 amd64 ext2/ext3/ext4 file system utilities
|
||||
ii elfutils 0.186-1build1 amd64 collection of utilities to handle ELF objects
|
||||
ii emacsen-common 3.0.4 all Common facilities for all emacsen
|
||||
ii fd-find 8.3.1-1ubuntu0.1 amd64 Simple, fast and user-friendly alternative to find
|
||||
ii file 1:5.41-3ubuntu0.1 amd64 Recognize the type of data in a file using "magic" numbers
|
||||
ii findutils 4.8.0-1ubuntu3 amd64 utilities for finding files--find, xargs
|
||||
ii fzf 0.29.0-1 amd64 general-purpose command-line fuzzy finder
|
||||
ii g++ 4:11.2.0-1ubuntu1 amd64 GNU C++ compiler
|
||||
ii g++-11 11.4.0-1ubuntu1~22.04 amd64 GNU C++ compiler
|
||||
ii g++-11-multilib 11.4.0-1ubuntu1~22.04 amd64 GNU C++ compiler (multilib support)
|
||||
ii g++-multilib 4:11.2.0-1ubuntu1 amd64 GNU C++ compiler (multilib files)
|
||||
ii gawk 1:5.1.0-1ubuntu0.1 amd64 GNU awk, a pattern scanning and processing language
|
||||
ii gcc 4:11.2.0-1ubuntu1 amd64 GNU C compiler
|
||||
ii gcc-11 11.4.0-1ubuntu1~22.04 amd64 GNU C compiler
|
||||
ii gcc-11-base:amd64 11.4.0-1ubuntu1~22.04 amd64 GCC, the GNU Compiler Collection (base package)
|
||||
ii gcc-11-multilib 11.4.0-1ubuntu1~22.04 amd64 GNU C compiler (multilib support)
|
||||
ii gcc-12-base:amd64 12.3.0-1ubuntu1~22.04 amd64 GCC, the GNU Compiler Collection (base package)
|
||||
ii gcc-12-base:i386 12.3.0-1ubuntu1~22.04 i386 GCC, the GNU Compiler Collection (base package)
|
||||
ii gcc-multilib 4:11.2.0-1ubuntu1 amd64 GNU C compiler (multilib files)
|
||||
ii gdb 12.1-0ubuntu1~22.04 amd64 GNU Debugger
|
||||
ii git 1:2.34.1-1ubuntu1.10 amd64 fast, scalable, distributed revision control system
|
||||
ii git-man 1:2.34.1-1ubuntu1.10 all fast, scalable, distributed revision control system (manual pages)
|
||||
ii gojq 0.12.6-1 amd64 pure Go implementation of jq (program)
|
||||
ii gpgv 2.2.27-3ubuntu2.1 amd64 GNU privacy guard - signature verification tool
|
||||
ii grep 3.7-1build1 amd64 GNU grep, egrep and fgrep
|
||||
ii gzip 1.10-4ubuntu4.1 amd64 GNU compression utilities
|
||||
ii hostname 3.23ubuntu2 amd64 utility to set/show the host name or domain name
|
||||
ii ht 2.1.0+repack1-5 amd64 Viewer/editor/analyser (mostly) for executables
|
||||
ii htop 3.0.5-7build2 amd64 interactive processes viewer
|
||||
ii hyperfine 1.12.0-3ubuntu0.1 amd64 Command-line benchmarking tool
|
||||
ii init-system-helpers 1.62 all helper tools for all init systems
|
||||
ii jq 1.6-2.1ubuntu3 amd64 lightweight and flexible command-line JSON processor
|
||||
ii less 590-1ubuntu0.22.04.1 amd64 pager program similar to more
|
||||
ii lib32asan6 11.4.0-1ubuntu1~22.04 amd64 AddressSanitizer -- a fast memory error detector (32bit)
|
||||
ii lib32atomic1 12.3.0-1ubuntu1~22.04 amd64 support library providing __atomic built-in functions (32bit)
|
||||
ii lib32gcc-11-dev 11.4.0-1ubuntu1~22.04 amd64 GCC support library (32 bit development files)
|
||||
ii lib32gcc-s1 12.3.0-1ubuntu1~22.04 amd64 GCC support library (32 bit Version)
|
||||
ii lib32gomp1 12.3.0-1ubuntu1~22.04 amd64 GCC OpenMP (GOMP) support library (32bit)
|
||||
ii lib32itm1 12.3.0-1ubuntu1~22.04 amd64 GNU Transactional Memory Library (32bit)
|
||||
ii lib32quadmath0 12.3.0-1ubuntu1~22.04 amd64 GCC Quad-Precision Math Library (32bit)
|
||||
ii lib32stdc++-11-dev 11.4.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (development files)
|
||||
ii lib32stdc++6 12.3.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (32 bit Version)
|
||||
ii lib32ubsan1 12.3.0-1ubuntu1~22.04 amd64 UBSan -- undefined behaviour sanitizer (32bit)
|
||||
ii libacl1:amd64 2.3.1-1 amd64 access control list - shared library
|
||||
ii libapt-pkg6.0:amd64 2.4.10 amd64 package management runtime library
|
||||
ii libarchive13:amd64 3.6.0-1ubuntu1 amd64 Multi-format archive and compression library (shared library)
|
||||
ii libaria2-0:amd64 1.36.0-1 amd64 C++ library interface to aria2
|
||||
ii libasan6:amd64 11.4.0-1ubuntu1~22.04 amd64 AddressSanitizer -- a fast memory error detector
|
||||
ii libasm1:amd64 0.186-1build1 amd64 library with a programmable assembler interface
|
||||
ii libatomic1:amd64 12.3.0-1ubuntu1~22.04 amd64 support library providing __atomic built-in functions
|
||||
ii libattr1:amd64 1:2.5.1-1build1 amd64 extended attribute handling - shared library
|
||||
ii libaudit-common 1:3.0.7-1build1 all Dynamic library for security auditing - common files
|
||||
ii libaudit1:amd64 1:3.0.7-1build1 amd64 Dynamic library for security auditing
|
||||
ii libbabeltrace1:amd64 1.5.8-2build1 amd64 Babeltrace conversion libraries
|
||||
ii libbinutils:amd64 2.38-4ubuntu2.3 amd64 GNU binary utilities (private shared library)
|
||||
ii libblkid1:amd64 2.37.2-4ubuntu3 amd64 block device ID library
|
||||
ii libboost-regex1.74.0:amd64 1.74.0-14ubuntu3 amd64 regular expression library for C++
|
||||
ii libbrotli1:amd64 1.0.9-2build6 amd64 library implementing brotli encoder and decoder (shared libraries)
|
||||
ii libbsd0:amd64 0.11.5-1 amd64 utility functions from BSD systems - shared library
|
||||
ii libbz2-1.0:amd64 1.0.8-5build1 amd64 high-quality block-sorting file compressor library - runtime
|
||||
ii libc-ares2:amd64 1.18.1-1ubuntu0.22.04.2 amd64 asynchronous name resolver
|
||||
ii libc-bin 2.35-0ubuntu3.4 amd64 GNU C Library: Binaries
|
||||
ii libc-dev-bin 2.35-0ubuntu3.4 amd64 GNU C Library: Development binaries
|
||||
ii libc6-dev-i386 2.35-0ubuntu3.4 amd64 GNU C Library: 32-bit development libraries for AMD64
|
||||
ii libc6-dev-x32 2.35-0ubuntu3.4 amd64 GNU C Library: X32 ABI Development Libraries for AMD64
|
||||
ii libc6-dev:amd64 2.35-0ubuntu3.4 amd64 GNU C Library: Development Libraries and Header Files
|
||||
ii libc6-i386 2.35-0ubuntu3.4 amd64 GNU C Library: 32-bit shared libraries for AMD64
|
||||
ii libc6-x32 2.35-0ubuntu3.4 amd64 GNU C Library: X32 ABI Shared libraries for AMD64
|
||||
ii libc6:amd64 2.35-0ubuntu3.4 amd64 GNU C Library: Shared libraries
|
||||
ii libc6:i386 2.35-0ubuntu3.4 i386 GNU C Library: Shared libraries
|
||||
ii libcap-ng0:amd64 0.7.9-2.2build3 amd64 An alternate POSIX capabilities library
|
||||
ii libcap2:amd64 1:2.44-1ubuntu0.22.04.1 amd64 POSIX 1003.1e capabilities (library)
|
||||
ii libcc1-0:amd64 12.3.0-1ubuntu1~22.04 amd64 GCC cc1 plugin for GDB
|
||||
ii libcom-err2:amd64 1.46.5-2ubuntu1.1 amd64 common error description library
|
||||
ii libcrypt-dev:amd64 1:4.4.27-1 amd64 libcrypt development files
|
||||
ii libcrypt1:amd64 1:4.4.27-1 amd64 libcrypt shared library
|
||||
ii libcrypt1:i386 1:4.4.27-1 i386 libcrypt shared library
|
||||
ii libctf-nobfd0:amd64 2.38-4ubuntu2.3 amd64 Compact C Type Format library (runtime, no BFD dependency)
|
||||
ii libctf0:amd64 2.38-4ubuntu2.3 amd64 Compact C Type Format library (runtime, BFD dependency)
|
||||
ii libcurl3-gnutls:amd64 7.81.0-1ubuntu1.14 amd64 easy-to-use client-side URL transfer library (GnuTLS flavour)
|
||||
ii libcurl4:amd64 7.81.0-1ubuntu1.14 amd64 easy-to-use client-side URL transfer library (OpenSSL flavour)
|
||||
ii libdb5.3:amd64 5.3.28+dfsg1-0.8ubuntu3 amd64 Berkeley v5.3 Database Libraries [runtime]
|
||||
ii libdebconfclient0:amd64 0.261ubuntu1 amd64 Debian Configuration Management System (C-implementation library)
|
||||
ii libdebuginfod-common 0.186-1build1 all configuration to enable the Debian debug info server
|
||||
ii libdebuginfod1:amd64 0.186-1build1 amd64 library to interact with debuginfod (development files)
|
||||
ii libdw1:amd64 0.186-1build1 amd64 library that provides access to the DWARF debug information
|
||||
ii libelf1:amd64 0.186-1build1 amd64 library to read and write ELF files
|
||||
ii liberror-perl 0.17029-1 all Perl module for error/exception handling in an OO-ish way
|
||||
ii libexpat1:amd64 2.4.7-1ubuntu0.2 amd64 XML parsing C library - runtime library
|
||||
ii libext2fs2:amd64 1.46.5-2ubuntu1.1 amd64 ext2/ext3/ext4 file system libraries
|
||||
ii libffi8:amd64 3.4.2-4 amd64 Foreign Function Interface library runtime
|
||||
ii libgcc-11-dev:amd64 11.4.0-1ubuntu1~22.04 amd64 GCC support library (development files)
|
||||
ii libgcc-s1:amd64 12.3.0-1ubuntu1~22.04 amd64 GCC support library
|
||||
ii libgcc-s1:i386 12.3.0-1ubuntu1~22.04 i386 GCC support library
|
||||
ii libgcrypt20:amd64 1.9.4-3ubuntu3 amd64 LGPL Crypto library - runtime library
|
||||
ii libgdbm-compat4:amd64 1.23-1 amd64 GNU dbm database routines (legacy support runtime version)
|
||||
ii libgdbm6:amd64 1.23-1 amd64 GNU dbm database routines (runtime version)
|
||||
ii libglib2.0-0:amd64 2.72.4-0ubuntu2.2 amd64 GLib library of C routines
|
||||
ii libgmp10:amd64 2:6.2.1+dfsg-3ubuntu1 amd64 Multiprecision arithmetic library
|
||||
ii libgnutls30:amd64 3.7.3-4ubuntu1.2 amd64 GNU TLS library - main runtime library
|
||||
ii libgomp1:amd64 12.3.0-1ubuntu1~22.04 amd64 GCC OpenMP (GOMP) support library
|
||||
ii libgpg-error0:amd64 1.43-3 amd64 GnuPG development runtime library
|
||||
ii libgpm2:amd64 1.20.7-10build1 amd64 General Purpose Mouse - shared library
|
||||
ii libgssapi-krb5-2:amd64 1.19.2-2ubuntu0.2 amd64 MIT Kerberos runtime libraries - krb5 GSS-API Mechanism
|
||||
ii libhiredis0.14:amd64 0.14.1-2 amd64 minimalistic C client library for Redis
|
||||
ii libhogweed6:amd64 3.7.3-1build2 amd64 low level cryptographic library (public-key cryptos)
|
||||
ii libicu70:amd64 70.1-2 amd64 International Components for Unicode
|
||||
ii libidn2-0:amd64 2.3.2-2build1 amd64 Internationalized domain names (IDNA2008/TR46) library
|
||||
ii libio-pty-perl 1:1.15-2build2 amd64 Perl module for pseudo tty IO
|
||||
ii libipc-run-perl 20200505.0-1 all Perl module for running processes
|
||||
ii libipt2 2.0.5-1 amd64 Intel Processor Trace Decoder Library
|
||||
ii libisl23:amd64 0.24-2build1 amd64 manipulating sets and relations of integer points bounded by linear constraints
|
||||
ii libitm1:amd64 12.3.0-1ubuntu1~22.04 amd64 GNU Transactional Memory Library
|
||||
ii libjansson4:amd64 2.13.1-1.1build3 amd64 C library for encoding, decoding and manipulating JSON data
|
||||
ii libjq1:amd64 1.6-2.1ubuntu3 amd64 lightweight and flexible command-line JSON processor - shared library
|
||||
ii libjsoncpp25:amd64 1.9.5-3 amd64 library for reading and writing JSON for C++
|
||||
ii libk5crypto3:amd64 1.19.2-2ubuntu0.2 amd64 MIT Kerberos runtime libraries - Crypto Library
|
||||
ii libkeyutils1:amd64 1.6.1-2ubuntu3 amd64 Linux Key Management Utilities (library)
|
||||
ii libkrb5-3:amd64 1.19.2-2ubuntu0.2 amd64 MIT Kerberos runtime libraries
|
||||
ii libkrb5support0:amd64 1.19.2-2ubuntu0.2 amd64 MIT Kerberos runtime libraries - Support library
|
||||
ii libldap-2.5-0:amd64 2.5.16+dfsg-0ubuntu0.22.04.1 amd64 OpenLDAP libraries
|
||||
ii liblsan0:amd64 12.3.0-1ubuntu1~22.04 amd64 LeakSanitizer -- a memory leak detector (runtime)
|
||||
ii liblz4-1:amd64 1.9.3-2build2 amd64 Fast LZ compression algorithm library - runtime
|
||||
ii liblzma5:amd64 5.2.5-2ubuntu1 amd64 XZ-format compression library
|
||||
ii liblzo2-2:amd64 2.10-2build3 amd64 data compression library
|
||||
ii libmagic-mgc 1:5.41-3ubuntu0.1 amd64 File type determination library using "magic" numbers (compiled magic file)
|
||||
ii libmagic1:amd64 1:5.41-3ubuntu0.1 amd64 Recognize the type of data in a file using "magic" numbers - library
|
||||
ii libmd0:amd64 1.0.4-1build1 amd64 message digest functions from BSD systems - shared library
|
||||
ii libmount1:amd64 2.37.2-4ubuntu3 amd64 device mounting library
|
||||
ii libmpc3:amd64 1.2.1-2build1 amd64 multiple precision complex floating-point library
|
||||
ii libmpdec3:amd64 2.5.1-2build2 amd64 library for decimal floating point arithmetic (runtime library)
|
||||
ii libmpfr6:amd64 4.1.0-3build3 amd64 multiple precision floating-point computation
|
||||
ii libmspack0:amd64 0.10.1-2build2 amd64 library for Microsoft compression formats (shared library)
|
||||
ii libncurses5:amd64 6.3-2ubuntu0.1 amd64 shared libraries for terminal handling (legacy version)
|
||||
ii libncurses6:amd64 6.3-2ubuntu0.1 amd64 shared libraries for terminal handling
|
||||
ii libncursesw6:amd64 6.3-2ubuntu0.1 amd64 shared libraries for terminal handling (wide character support)
|
||||
ii libnettle8:amd64 3.7.3-1build2 amd64 low level cryptographic library (symmetric and one-way cryptos)
|
||||
ii libnghttp2-14:amd64 1.43.0-1build3 amd64 library implementing HTTP/2 protocol (shared library)
|
||||
ii libnl-3-200:amd64 3.5.0-0.1 amd64 library for dealing with netlink sockets
|
||||
ii libnl-genl-3-200:amd64 3.5.0-0.1 amd64 library for dealing with netlink sockets - generic netlink
|
||||
ii libnsl-dev:amd64 1.3.0-2build2 amd64 libnsl development files
|
||||
ii libnsl2:amd64 1.3.0-2build2 amd64 Public client interface for NIS(YP) and NIS+
|
||||
ii libonig5:amd64 6.9.7.1-2build1 amd64 regular expressions library
|
||||
ii libp11-kit0:amd64 0.24.0-6build1 amd64 library for loading and coordinating access to PKCS#11 modules - runtime
|
||||
ii libpam-modules-bin 1.4.0-11ubuntu2.3 amd64 Pluggable Authentication Modules for PAM - helper binaries
|
||||
ii libpam-modules:amd64 1.4.0-11ubuntu2.3 amd64 Pluggable Authentication Modules for PAM
|
||||
ii libpam-runtime 1.4.0-11ubuntu2.3 all Runtime support for the PAM library
|
||||
ii libpam0g:amd64 1.4.0-11ubuntu2.3 amd64 Pluggable Authentication Modules library
|
||||
ii libpcre2-8-0:amd64 10.39-3ubuntu0.1 amd64 New Perl Compatible Regular Expression Library- 8 bit runtime files
|
||||
ii libpcre3:amd64 2:8.39-13ubuntu0.22.04.1 amd64 Old Perl 5 Compatible Regular Expression Library - runtime files
|
||||
ii libperl5.34:amd64 5.34.0-3ubuntu1.2 amd64 shared Perl library
|
||||
ii libpopt0:amd64 1.18-3build1 amd64 lib for parsing cmdline parameters
|
||||
ii libprocps8:amd64 2:3.3.17-6ubuntu2 amd64 library for accessing process information from /proc
|
||||
ii libpsl5:amd64 0.21.0-1.2build2 amd64 Library for Public Suffix List (shared libraries)
|
||||
ii libpython2.7-minimal:amd64 2.7.18-13ubuntu1.1 amd64 Minimal subset of the Python language (version 2.7)
|
||||
ii libpython3-stdlib:amd64 3.10.6-1~22.04 amd64 interactive high-level object-oriented language (default python3 version)
|
||||
ii libpython3.10-minimal:amd64 3.10.12-1~22.04.2 amd64 Minimal subset of the Python language (version 3.10)
|
||||
ii libpython3.10-stdlib:amd64 3.10.12-1~22.04.2 amd64 Interactive high-level object-oriented language (standard library, version 3.10)
|
||||
ii libpython3.10:amd64 3.10.12-1~22.04.2 amd64 Shared Python runtime library (version 3.10)
|
||||
ii libquadmath0:amd64 12.3.0-1ubuntu1~22.04 amd64 GCC Quad-Precision Math Library
|
||||
ii libreadline8:amd64 8.1.2-1 amd64 GNU readline and history libraries, run-time libraries
|
||||
ii librhash0:amd64 1.4.2-1ubuntu1 amd64 shared library for hash functions computing
|
||||
ii librtmp1:amd64 2.4+20151223.gitfa8646d.1-2build4 amd64 toolkit for RTMP streams (shared library)
|
||||
ii libsasl2-2:amd64 2.1.27+dfsg2-3ubuntu1.2 amd64 Cyrus SASL - authentication abstraction library
|
||||
ii libsasl2-modules-db:amd64 2.1.27+dfsg2-3ubuntu1.2 amd64 Cyrus SASL - pluggable authentication modules (DB)
|
||||
ii libseccomp2:amd64 2.5.3-2ubuntu2 amd64 high level interface to Linux seccomp filter
|
||||
ii libselinux1:amd64 3.3-1build2 amd64 SELinux runtime shared libraries
|
||||
ii libsemanage-common 3.3-1build2 all Common files for SELinux policy management libraries
|
||||
ii libsemanage2:amd64 3.3-1build2 amd64 SELinux policy management library
|
||||
ii libsensors-config 1:3.6.0-7ubuntu1 all lm-sensors configuration files
|
||||
ii libsensors5:amd64 1:3.6.0-7ubuntu1 amd64 library to read temperature/voltage/fan sensors
|
||||
ii libsepol2:amd64 3.3-1build1 amd64 SELinux library for manipulating binary security policies
|
||||
ii libsigsegv2:amd64 2.13-1ubuntu3 amd64 Library for handling page faults in a portable way
|
||||
ii libsmartcols1:amd64 2.37.2-4ubuntu3 amd64 smart column output alignment library
|
||||
ii libsodium23:amd64 1.0.18-1build2 amd64 Network communication, cryptography and signaturing library
|
||||
ii libsource-highlight-common 3.1.9-4.1build2 all architecture-independent files for source highlighting library
|
||||
ii libsource-highlight4v5 3.1.9-4.1build2 amd64 source highlighting library
|
||||
ii libsqlite3-0:amd64 3.37.2-2ubuntu0.1 amd64 SQLite 3 shared library
|
||||
ii libss2:amd64 1.46.5-2ubuntu1.1 amd64 command-line interface parsing library
|
||||
ii libssh-4:amd64 0.9.6-2ubuntu0.22.04.1 amd64 tiny C SSH library (OpenSSL flavor)
|
||||
ii libssh2-1:amd64 1.10.0-3 amd64 SSH2 client-side library
|
||||
ii libssl3:amd64 3.0.2-0ubuntu1.12 amd64 Secure Sockets Layer toolkit - shared libraries
|
||||
ii libstdc++-11-dev:amd64 11.4.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (development files)
|
||||
ii libstdc++6:amd64 12.3.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3
|
||||
ii libsystemd0:amd64 249.11-0ubuntu3.11 amd64 systemd utility library
|
||||
ii libtasn1-6:amd64 4.18.0-4build1 amd64 Manage ASN.1 structures (runtime)
|
||||
ii libtime-duration-perl 1.21-1 all module for rounded or exact English expression of durations
|
||||
ii libtimedate-perl 2.3300-2 all collection of modules to manipulate date/time information
|
||||
ii libtinfo5:amd64 6.3-2ubuntu0.1 amd64 shared low-level terminfo library (legacy version)
|
||||
ii libtinfo6:amd64 6.3-2ubuntu0.1 amd64 shared low-level terminfo library for terminal handling
|
||||
ii libtirpc-common 1.3.2-2ubuntu0.1 all transport-independent RPC library - common files
|
||||
ii libtirpc-dev:amd64 1.3.2-2ubuntu0.1 amd64 transport-independent RPC library - development files
|
||||
ii libtirpc3:amd64 1.3.2-2ubuntu0.1 amd64 transport-independent RPC library
|
||||
ii libtsan0:amd64 11.4.0-1ubuntu1~22.04 amd64 ThreadSanitizer -- a Valgrind-based detector of data races (runtime)
|
||||
ii libubsan1:amd64 12.3.0-1ubuntu1~22.04 amd64 UBSan -- undefined behaviour sanitizer (runtime)
|
||||
ii libudev1:amd64 249.11-0ubuntu3.11 amd64 libudev shared library
|
||||
ii libunistring2:amd64 1.0-1 amd64 Unicode string library for C
|
||||
ii libutempter0:amd64 1.2.1-2build2 amd64 privileged helper for utmp/wtmp updates (runtime)
|
||||
ii libuuid1:amd64 2.37.2-4ubuntu3 amd64 Universally Unique ID library
|
||||
ii libuv1:amd64 1.43.0-1 amd64 asynchronous event notification library - runtime library
|
||||
ii libx11-6:amd64 2:1.7.5-1ubuntu0.3 amd64 X11 client-side library
|
||||
ii libx11-data 2:1.7.5-1ubuntu0.3 all X11 client-side library
|
||||
ii libx32asan6 11.4.0-1ubuntu1~22.04 amd64 AddressSanitizer -- a fast memory error detector (x32)
|
||||
ii libx32atomic1 12.3.0-1ubuntu1~22.04 amd64 support library providing __atomic built-in functions (x32)
|
||||
ii libx32gcc-11-dev 11.4.0-1ubuntu1~22.04 amd64 GCC support library (x32 development files)
|
||||
ii libx32gcc-s1 12.3.0-1ubuntu1~22.04 amd64 GCC support library (x32)
|
||||
ii libx32gomp1 12.3.0-1ubuntu1~22.04 amd64 GCC OpenMP (GOMP) support library (x32)
|
||||
ii libx32itm1 12.3.0-1ubuntu1~22.04 amd64 GNU Transactional Memory Library (x32)
|
||||
ii libx32quadmath0 12.3.0-1ubuntu1~22.04 amd64 GCC Quad-Precision Math Library (x32)
|
||||
ii libx32stdc++-11-dev 11.4.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (development files)
|
||||
ii libx32stdc++6 12.3.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (x32)
|
||||
ii libx32ubsan1 12.3.0-1ubuntu1~22.04 amd64 UBSan -- undefined behaviour sanitizer (x32)
|
||||
ii libxau6:amd64 1:1.0.9-1build5 amd64 X11 authorisation library
|
||||
ii libxcb1:amd64 1.14-3ubuntu3 amd64 X C Binding
|
||||
ii libxdmcp6:amd64 1:1.1.3-0ubuntu5 amd64 X11 Display Manager Control Protocol library
|
||||
ii libxml2:amd64 2.9.13+dfsg-1ubuntu0.3 amd64 GNOME XML library
|
||||
ii libxxhash0:amd64 0.8.1-1 amd64 shared library for xxhash
|
||||
ii libyaml-0-2:amd64 0.2.2-1build2 amd64 Fast YAML 1.1 parser and emitter library
|
||||
ii libzstd-dev:amd64 1.4.8+dfsg-3build1 amd64 fast lossless compression algorithm -- development files
|
||||
ii libzstd1:amd64 1.4.8+dfsg-3build1 amd64 fast lossless compression algorithm
|
||||
ii linux-libc-dev:amd64 5.15.0-88.98 amd64 Linux Kernel Headers for development
|
||||
ii login 1:4.8.1-2ubuntu2.1 amd64 system login tools
|
||||
ii logsave 1.46.5-2ubuntu1.1 amd64 save the output of a command in a log file
|
||||
ii lsb-base 11.1.0ubuntu4 all Linux Standard Base init script functionality
|
||||
ii lsb-release 11.1.0ubuntu4 all Linux Standard Base version reporting utility
|
||||
ii lz4 1.9.3-2build2 amd64 Fast LZ compression algorithm library - tool
|
||||
ii lzip 1.23-1 amd64 lossless data compressor based on the LZMA algorithm
|
||||
ii lzop 1.04-2build2 amd64 fast compression program
|
||||
ii make 4.3-4.1build1 amd64 utility for directing compilation
|
||||
ii mawk 1.3.4.20200120-3 amd64 Pattern scanning and text processing language
|
||||
ii media-types 7.0.0 all List of standard media types and their usual file extension
|
||||
ii mksh 59c-16 amd64 MirBSD Korn Shell
|
||||
ii moreutils 0.66-1 amd64 additional Unix utilities
|
||||
ii mount 2.37.2-4ubuntu3 amd64 tools for mounting and manipulating filesystems
|
||||
ii ncurses-base 6.3-2ubuntu0.1 all basic terminal type definitions
|
||||
ii ncurses-bin 6.3-2ubuntu0.1 amd64 terminal-related programs and man pages
|
||||
ii ncurses-term 6.3-2ubuntu0.1 all additional terminal type definitions
|
||||
ii ninja-build 1.10.1-1 amd64 small build system closest in spirit to Make
|
||||
ii openssl 3.0.2-0ubuntu1.12 amd64 Secure Sockets Layer toolkit - cryptographic utility
|
||||
ii p7zip 16.02+dfsg-8 amd64 7zr file archiver with high compression ratio
|
||||
ii parallel 20210822+ds-2 all build and execute command lines from standard input in parallel
|
||||
ii passwd 1:4.8.1-2ubuntu2.1 amd64 change and administer password and group data
|
||||
ii patch 2.7.6-7build2 amd64 Apply a diff file to an original
|
||||
ii patchelf 0.14.3-1 amd64 modify properties of ELF executables
|
||||
ii pax-utils 1.2.9-1 amd64 Security-focused ELF files checking tool
|
||||
ii paxctl 0.9-1build1 amd64 new PaX control program for using the PT_PAX_FLAGS marking
|
||||
ii perl 5.34.0-3ubuntu1.2 amd64 Larry Wall's Practical Extraction and Report Language
|
||||
ii perl-base 5.34.0-3ubuntu1.2 amd64 minimal Perl system
|
||||
ii perl-modules-5.34 5.34.0-3ubuntu1.2 all Core Perl modules
|
||||
ii procps 2:3.3.17-6ubuntu2 amd64 /proc file system utilities
|
||||
ii python2-minimal 2.7.18-3 amd64 minimal subset of the Python2 language
|
||||
ii python2.7-minimal 2.7.18-13ubuntu1.1 amd64 Minimal subset of the Python language (version 2.7)
|
||||
ii python3 3.10.6-1~22.04 amd64 interactive high-level object-oriented language (default python3 version)
|
||||
ii python3-minimal 3.10.6-1~22.04 amd64 minimal subset of the Python language (default python3 version)
|
||||
ii python3-pyasn1 0.4.8-1 all ASN.1 library for Python (Python 3 module)
|
||||
ii python3-pycryptodome 3.11.0+dfsg1-3build1 amd64 cryptographic Python library (Python 3)
|
||||
ii python3-zstd 1.5.0.2-1build1 amd64 python bindings to Yann Collet ZSTD compression library
|
||||
ii python3.10 3.10.12-1~22.04.2 amd64 Interactive high-level object-oriented language (version 3.10)
|
||||
ii python3.10-minimal 3.10.12-1~22.04.2 amd64 Minimal subset of the Python language (version 3.10)
|
||||
ii re2c 3.0-1 amd64 lexer generator for C, C++, Go and Rust
|
||||
ii readline-common 8.1.2-1 all GNU readline and history libraries, common files
|
||||
ii ripgrep 13.0.0-2ubuntu0.1 amd64 Recursively searches directories for a regex pattern
|
||||
ii rpcsvc-proto 1.4.2-0ubuntu6 amd64 RPC protocol compiler and definitions
|
||||
ii rsync 3.2.7-0ubuntu0.22.04.2 amd64 fast, versatile, remote (and local) file-copying tool
|
||||
ii screen 4.9.0-1 amd64 terminal multiplexer with VT100/ANSI terminal emulation
|
||||
ii sed 4.8-1ubuntu2 amd64 GNU stream editor for filtering/transforming text
|
||||
ii sensible-utils 0.0.17 all Utilities for sensible alternative selection
|
||||
ii sysstat 12.5.2-2ubuntu0.2 amd64 system performance tools for Linux
|
||||
ii sysvinit-utils 3.01-1ubuntu1 amd64 System-V-like utilities
|
||||
ii tar 1.34+dfsg-1ubuntu0.1.22.04.1 amd64 GNU version of the tar archiving utility
|
||||
ii time 1.9-0.1build2 amd64 GNU time program for measuring CPU resource usage
|
||||
ii ubuntu-keyring 2021.03.26 all GnuPG keys of the Ubuntu archive
|
||||
ii ucf 3.0043 all Update Configuration File(s): preserve user changes to config files
|
||||
ii universal-ctags 5.9.20210829.0-1 amd64 build tag file indexes of source code definitions
|
||||
ii unzip 6.0-26ubuntu3.1 amd64 De-archiver for .zip files
|
||||
ii usrmerge 25ubuntu2 all Convert the system to the merged /usr directories scheme
|
||||
ii util-linux 2.37.2-4ubuntu3 amd64 miscellaneous system utilities
|
||||
ii vim 2:8.2.3995-1ubuntu2.13 amd64 Vi IMproved - enhanced vi editor
|
||||
ii vim-common 2:8.2.3995-1ubuntu2.13 all Vi IMproved - Common files
|
||||
ii vim-runtime 2:8.2.3995-1ubuntu2.13 all Vi IMproved - Runtime files
|
||||
ii wget 1.21.2-2ubuntu1 amd64 retrieves files from the web
|
||||
ii xxd 2:8.2.3995-1ubuntu2.13 amd64 tool to make (or reverse) a hex dump
|
||||
ii xz-utils 5.2.5-2ubuntu1 amd64 XZ-format compression utilities
|
||||
ii yash 2.51-1 amd64 yet another shell
|
||||
ii zip 3.0-12build2 amd64 Archiver for .zip files
|
||||
ii zlib1g-dev:amd64 1:1.2.11.dfsg-2ubuntu9.2 amd64 compression library - development
|
||||
ii zlib1g:amd64 1:1.2.11.dfsg-2ubuntu9.2 amd64 compression library - runtime
|
||||
ii zlib1g:i386 1:1.2.11.dfsg-2ubuntu9.2 i386 compression library - runtime
|
||||
ii zsh 5.8.1-1 amd64 shell with lots of features
|
||||
ii zsh-common 5.8.1-1 all architecture independent files for Zsh
|
||||
ii zstd 1.4.8+dfsg-3build1 amd64 fast lossless compression algorithm -- CLI tool
|
||||
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|
||||
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
|
||||
||/ Name Version Architecture Description
|
||||
|
||||
Packages sorted by Installed-Size:
|
||||
754091 ===== TOTAL (324 packages)
|
||||
52747 gcc-11 amd64
|
||||
34444 libicu70 amd64
|
||||
32782 vim-runtime all
|
||||
28891 g++-11 amd64
|
||||
28441 libperl5.34 amd64
|
||||
26284 cpp-11 amd64
|
||||
20742 cmake amd64
|
||||
18759 libstdc++-11-dev amd64
|
||||
18468 git amd64
|
||||
17671 perl-modules-5.34 all
|
||||
15293 zsh-common all
|
||||
13895 libgcc-11-dev amd64
|
||||
13592 libc6 amd64
|
||||
13037 libc6-dev amd64
|
||||
12561 libc6-x32 amd64
|
||||
12479 libc6 i386
|
||||
12200 libc6-i386 amd64
|
||||
11311 gdb amd64
|
||||
10877 lib32stdc++-11-dev amd64
|
||||
10439 binutils-x86-64-linux-gnu amd64
|
||||
10390 libx32stdc++-11-dev amd64
|
||||
9866 cmake-data all
|
||||
8248 libc6-dev-x32 amd64
|
||||
8119 libpython3.10-stdlib amd64
|
||||
7948 lib32gcc-11-dev amd64
|
||||
7730 perl-base amd64
|
||||
7518 libasan6 amd64
|
||||
7262 libc6-dev-i386 amd64
|
||||
7255 libtsan0 amd64
|
||||
7128 libmagic-mgc amd64
|
||||
7112 coreutils amd64
|
||||
6988 libx32gcc-11-dev amd64
|
||||
6802 linux-libc-dev amd64
|
||||
6733 dpkg amd64
|
||||
6667 lib32asan6 amd64
|
||||
6570 libx32asan6 amd64
|
||||
5905 python3.10-minimal amd64
|
||||
5828 libssl3 amd64
|
||||
5768 libpython3.10 amd64
|
||||
5103 libpython3.10-minimal amd64
|
||||
4249 ncurses-term all
|
||||
4156 apt amd64
|
||||
4147 ripgrep amd64
|
||||
4082 libglib2.0-0 amd64
|
||||
3930 vim amd64
|
||||
3643 python2.7-minimal amd64
|
||||
3542 python3-pycryptodome amd64
|
||||
3506 re2c amd64
|
||||
3487 gojq amd64
|
||||
3405 libmpfr6 amd64
|
||||
3399 util-linux amd64
|
||||
3347 libaria2-0 amd64
|
||||
3181 libapt-pkg6.0 amd64
|
||||
3013 libboost-regex1.74.0 amd64
|
||||
2961 liblsan0 amd64
|
||||
2943 parallel all
|
||||
2801 elfutils amd64
|
||||
2784 libpython2.7-minimal amd64
|
||||
2776 libbinutils amd64
|
||||
2755 libstdc++6 amd64
|
||||
2676 libubsan1 amd64
|
||||
2662 lib32stdc++6 amd64
|
||||
2537 libc-bin amd64
|
||||
2518 libx32ubsan1 amd64
|
||||
2510 fd-find amd64
|
||||
2499 lib32ubsan1 amd64
|
||||
2468 zsh amd64
|
||||
2450 libx32stdc++6 amd64
|
||||
2428 fzf amd64
|
||||
2396 7zip amd64
|
||||
2325 passwd amd64
|
||||
2284 libgnutls30 amd64
|
||||
2191 ht amd64
|
||||
2159 libisl23 amd64
|
||||
2097 libxml2 amd64
|
||||
2053 openssl amd64
|
||||
2009 universal-ctags amd64
|
||||
1958 git-man all
|
||||
1864 bash amd64
|
||||
1854 aria2 amd64
|
||||
1750 libdb5.3 amd64
|
||||
1746 libunistring2 amd64
|
||||
1680 gawk amd64
|
||||
1655 zstd amd64
|
||||
1602 libsqlite3-0 amd64
|
||||
1516 e2fsprogs amd64
|
||||
1508 mksh amd64
|
||||
1472 sysstat amd64
|
||||
1464 bash-completion all
|
||||
1445 hyperfine amd64
|
||||
1430 libx11-data all
|
||||
1429 yash amd64
|
||||
1388 procps amd64
|
||||
1387 libx11-6 amd64
|
||||
1354 libgcrypt20 amd64
|
||||
1343 ccache amd64
|
||||
1328 libzstd-dev amd64
|
||||
1292 libp11-kit0 amd64
|
||||
1138 libpam-modules amd64
|
||||
1052 libkrb5-3 amd64
|
||||
1005 screen amd64
|
||||
995 libsystemd0 amd64
|
||||
990 p7zip amd64
|
||||
984 wget amd64
|
||||
960 tar amd64
|
||||
888 login amd64
|
||||
876 libarchive13 amd64
|
||||
846 libzstd1 amd64
|
||||
794 rsync amd64
|
||||
791 busybox amd64
|
||||
787 libcurl4 amd64
|
||||
784 libbrotli1 amd64
|
||||
771 libcurl3-gnutls amd64
|
||||
743 python3-zstd amd64
|
||||
735 libsepol2 amd64
|
||||
729 libdw1 amd64
|
||||
720 libtirpc-dev amd64
|
||||
717 perl amd64
|
||||
686 lib32quadmath0 amd64
|
||||
683 libpcre3 amd64
|
||||
646 ncurses-bin amd64
|
||||
632 python3.10 amd64
|
||||
621 libpcre2-8-0 amd64
|
||||
620 findutils amd64
|
||||
615 libonig5 amd64
|
||||
610 libsource-highlight4v5 amd64
|
||||
608 adduser all
|
||||
592 zlib1g-dev amd64
|
||||
574 libext2fs2 amd64
|
||||
565 libldap-2.5-0 amd64
|
||||
558 libtinfo6 amd64
|
||||
544 libtinfo5 amd64
|
||||
544 libgmp10 amd64
|
||||
531 zip amd64
|
||||
512 debconf all
|
||||
504 binutils-common amd64
|
||||
502 libbabeltrace1 amd64
|
||||
496 grep amd64
|
||||
486 libssh-4 amd64
|
||||
461 libreadline8 amd64
|
||||
455 libgssapi-krb5-2 amd64
|
||||
443 curl amd64
|
||||
433 libexpat1 amd64
|
||||
424 diffutils amd64
|
||||
422 libncursesw6 amd64
|
||||
416 make amd64
|
||||
402 libsodium23 amd64
|
||||
394 base-files amd64
|
||||
393 ncurses-base all
|
||||
390 python3-pyasn1 all
|
||||
390 ca-certificates all
|
||||
389 mount amd64
|
||||
382 libmount1 amd64
|
||||
381 vim-common all
|
||||
376 unzip amd64
|
||||
372 xz-utils amd64
|
||||
368 libssh2-1 amd64
|
||||
356 libnettle8 amd64
|
||||
350 ninja-build amd64
|
||||
347 libudev1 amd64
|
||||
347 libnsl-dev amd64
|
||||
347 libjq1 amd64
|
||||
336 libhogweed6 amd64
|
||||
334 lib32gomp1 amd64
|
||||
334 htop amd64
|
||||
334 bsdutils amd64
|
||||
329 libncurses6 amd64
|
||||
328 sed amd64
|
||||
324 gpgv amd64
|
||||
324 cpio amd64
|
||||
323 libblkid1 amd64
|
||||
321 less amd64
|
||||
320 libgomp1 amd64
|
||||
320 libcrypt-dev amd64
|
||||
318 libncurses5 amd64
|
||||
312 libpam-runtime all
|
||||
312 libctf-nobfd0 amd64
|
||||
307 libsource-highlight-common all
|
||||
306 libx32gomp1 amd64
|
||||
300 libsemanage2 amd64
|
||||
298 libc-dev-bin amd64
|
||||
296 libquadmath0 amd64
|
||||
295 libx32quadmath0 amd64
|
||||
292 libk5crypto3 amd64
|
||||
290 pax-utils amd64
|
||||
290 liblzma5 amd64
|
||||
279 xxd amd64
|
||||
273 gcc-11-base amd64
|
||||
272 gcc-12-base i386
|
||||
272 gcc-12-base amd64
|
||||
252 libuv1 amd64
|
||||
252 libipc-run-perl all
|
||||
252 libcrypt1 i386
|
||||
250 libmpdec3 amd64
|
||||
248 libpam-modules-bin amd64
|
||||
245 rpcsvc-proto amd64
|
||||
243 debianutils amd64
|
||||
243 base-passwd amd64
|
||||
240 moreutils amd64
|
||||
240 gzip amd64
|
||||
239 libctf0 amd64
|
||||
235 libpam0g amd64
|
||||
235 libjsoncpp25 amd64
|
||||
232 ucf all
|
||||
230 lz4 amd64
|
||||
229 patch amd64
|
||||
229 mawk amd64
|
||||
229 libmagic1 amd64
|
||||
225 libcrypt1 amd64
|
||||
221 bfs amd64
|
||||
220 libidn2-0 amd64
|
||||
219 libtirpc3 amd64
|
||||
219 librhash0 amd64
|
||||
214 dash amd64
|
||||
209 libsmartcols1 amd64
|
||||
207 libselinux1 amd64
|
||||
206 libxcb1 amd64
|
||||
203 libnghttp2-14 amd64
|
||||
200 usrmerge all
|
||||
192 libelf1 amd64
|
||||
189 libgpg-error0 amd64
|
||||
182 patchelf amd64
|
||||
180 libnl-3-200 amd64
|
||||
171 zlib1g i386
|
||||
170 libsasl2-2 amd64
|
||||
167 libgcc-s1 i386
|
||||
164 zlib1g amd64
|
||||
164 libkrb5support0 amd64
|
||||
163 lib32gcc-s1 amd64
|
||||
161 lzip amd64
|
||||
159 lzop amd64
|
||||
159 liblzo2-2 amd64
|
||||
156 libaudit1 amd64
|
||||
145 libseccomp2 amd64
|
||||
145 liblz4-1 amd64
|
||||
144 libyaml-0-2 amd64
|
||||
144 libcc1-0 amd64
|
||||
141 librtmp1 amd64
|
||||
140 libgcc-s1 amd64
|
||||
136 libbsd0 amd64
|
||||
135 libx32gcc-s1 amd64
|
||||
134 libuuid1 amd64
|
||||
133 libtasn1-6 amd64
|
||||
133 init-system-helpers all
|
||||
132 libipt2 amd64
|
||||
131 libprocps8 amd64
|
||||
126 time amd64
|
||||
125 libmpc3 amd64
|
||||
123 libtimedate-perl all
|
||||
123 libnsl2 amd64
|
||||
122 python3-minimal amd64
|
||||
120 libpopt0 amd64
|
||||
115 libitm1 amd64
|
||||
114 bzip2 amd64
|
||||
113 libss2 amd64
|
||||
113 lib32itm1 amd64
|
||||
112 libc-ares2 amd64
|
||||
112 binutils amd64
|
||||
110 libio-pty-perl amd64
|
||||
105 python2-minimal amd64
|
||||
105 libx32itm1 amd64
|
||||
101 libcom-err2 amd64
|
||||
100 libgdbm6 amd64
|
||||
100 libbz2-1.0 amd64
|
||||
100 jq amd64
|
||||
97 media-types all
|
||||
97 logsave amd64
|
||||
97 libxxhash0 amd64
|
||||
96 libsensors5 amd64
|
||||
96 libmspack0 amd64
|
||||
95 libpsl5 amd64
|
||||
93 libsasl2-modules-db amd64
|
||||
92 libhiredis0.14 amd64
|
||||
91 libjansson4 amd64
|
||||
90 python3 amd64
|
||||
84 file amd64
|
||||
83 sysvinit-utils amd64
|
||||
82 cabextract amd64
|
||||
80 readline-common all
|
||||
79 libdebconfclient0 amd64
|
||||
74 libasm1 amd64
|
||||
71 libmd0 amd64
|
||||
71 liberror-perl all
|
||||
69 libffi8 amd64
|
||||
67 libacl1 amd64
|
||||
67 cpp amd64
|
||||
66 lsb-release all
|
||||
65 libgpm2 amd64
|
||||
65 libdebuginfod1 amd64
|
||||
65 libcap2 amd64
|
||||
62 emacsen-common all
|
||||
61 libnl-genl-3-200 amd64
|
||||
59 sensible-utils all
|
||||
58 lsb-base all
|
||||
57 libattr1 amd64
|
||||
51 libutempter0 amd64
|
||||
51 hostname amd64
|
||||
50 gcc amd64
|
||||
49 libsigsegv2 amd64
|
||||
47 libkeyutils1 amd64
|
||||
45 libgdbm-compat4 amd64
|
||||
45 libcap-ng0 amd64
|
||||
45 libatomic1 amd64
|
||||
43 libxdmcp6 amd64
|
||||
43 libx32atomic1 amd64
|
||||
42 libsensors-config all
|
||||
41 ubuntu-keyring all
|
||||
41 libdebuginfod-common all
|
||||
39 libpython3-stdlib amd64
|
||||
39 lib32atomic1 amd64
|
||||
37 libsemanage-common all
|
||||
37 chrpath amd64
|
||||
35 libxau6 amd64
|
||||
35 libtime-duration-perl all
|
||||
32 libtirpc-common all
|
||||
30 paxctl amd64
|
||||
27 dh-elpa-helper all
|
||||
23 libaudit-common all
|
||||
20 distro-info-data all
|
||||
16 g++ amd64
|
||||
8 gcc-multilib amd64
|
||||
6 gcc-11-multilib amd64
|
||||
6 g++-multilib amd64
|
||||
6 g++-11-multilib amd64
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
#! /bin/sh
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e
|
||||
|
||||
#
|
||||
# build UPX "by hand", using a POSIX-compliant shell and
|
||||
# a minimal number of compilation flags
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
# uses optional environment variables: AR, CC, CXX, OPTIMIZE, VERBOSE, top_srcdir
|
||||
|
||||
# shell init
|
||||
### set -x # enable logging
|
||||
DUALCASE=1; export DUALCASE # for MKS sh
|
||||
test -n "${ZSH_VERSION+set}" && emulate sh # for zsh
|
||||
my_argv0="$0"
|
||||
|
||||
# toolchain settings and compilation flags
|
||||
AR="${AR:-ar}"
|
||||
CC="${CC:-cc}"
|
||||
CXX="${CXX:-c++ -std=gnu++17}"
|
||||
# HINT: use "export AR=false" if "$AR rcs" does not work on your system; see below
|
||||
if test "x$AR" = "x0" || test "x$AR" = "xfalse" || test "x$AR" = "x/bin/false"; then
|
||||
AR="" # do not use $AR
|
||||
fi
|
||||
# protect against security threats caused by misguided compiler "optimizations"
|
||||
mandatory_flags="-fno-strict-aliasing -fno-strict-overflow -funsigned-char"
|
||||
# not mandatory but good practice when using <windows.h>:
|
||||
mandatory_flags="$mandatory_flags -DWIN32_LEAN_AND_MEAN"
|
||||
if test "x$OPTIMIZE" != "x" && test "x$OPTIMIZE" != "x0"; then
|
||||
# not mandatory and not minimal, but usually a good idea:
|
||||
mandatory_flags="-Wall -O2 $mandatory_flags"
|
||||
fi
|
||||
CC="$CC $mandatory_flags"
|
||||
CXX="$CXX $mandatory_flags"
|
||||
|
||||
# go to upx top-level directory
|
||||
# HINT: set "top_srcdir" manually if your system does not have "readlink"
|
||||
if test "x$top_srcdir" = "x"; then
|
||||
my_argv0abs="$(readlink -fn "$my_argv0")"
|
||||
test "x$my_argv0abs" = "x" && exit 1
|
||||
my_argv0dir="$(dirname "$my_argv0abs")"
|
||||
test "x$my_argv0dir" = "x" && exit 1
|
||||
cd "$my_argv0dir/../.." || exit 1
|
||||
else
|
||||
cd "$top_srcdir" || exit 1
|
||||
fi
|
||||
top_srcdir="$(pwd)" # absolute
|
||||
rel_top_srcdir=. # relative top_srcdir
|
||||
echo "# current directory: '$(pwd)'"
|
||||
test -f doc/upx.pod || exit 1 # sanity check
|
||||
test -f src/version.h || exit 1 # sanity check
|
||||
rm -rf ./build/by-hand # WARNING: existing build-directory gets deleted!
|
||||
|
||||
# helper function
|
||||
run() {
|
||||
if test 0 = 1; then
|
||||
# DEBUG dry-run: print command, but don't actually run unless $1 is "+"
|
||||
if test "x$1" = "x+"; then
|
||||
shift; echo "$@"; "$@"; return
|
||||
fi
|
||||
shift; echo "$@"; return
|
||||
fi
|
||||
# print short info and run command
|
||||
test "x$1" != "x" && test "x$1" != "x+" && echo "$1"
|
||||
shift
|
||||
if test "x$VERBOSE" != "x" && test "x$VERBOSE" != "x0"; then
|
||||
# print full command
|
||||
echo " $@"
|
||||
fi
|
||||
"$@"
|
||||
}
|
||||
|
||||
# helper function
|
||||
check_submodule() {
|
||||
#local ff # "local" seems unsupported by some versions of ksh
|
||||
for ff in COPYING LICENSE LICENSE.txt; do
|
||||
if test -f "$rel_top_srcdir/vendor/$1/$ff"; then
|
||||
# create and enter build directory; updates global $rel_top_srcdir
|
||||
run "+" cd "$rel_top_srcdir" || exit 1
|
||||
rel_top_srcdir=.
|
||||
echo "#==== build $1 ====="
|
||||
run "+" mkdir "build/by-hand/$1"
|
||||
run "+" cd "build/by-hand/$1" || exit 1
|
||||
rel_top_srcdir=../../..
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# build
|
||||
run "+" mkdir -p "build/by-hand"
|
||||
if check_submodule bzip2; then
|
||||
for f in "$rel_top_srcdir"/vendor/bzip2/*.c; do
|
||||
run "CC $f" $CC -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule ucl; then
|
||||
for f in "$rel_top_srcdir"/vendor/ucl/src/*.c; do
|
||||
run "CC $f" $CC -I"$rel_top_srcdir"/vendor/ucl/include -I"$rel_top_srcdir"/vendor/ucl -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule zlib; then
|
||||
for f in "$rel_top_srcdir"/vendor/zlib/*.c; do
|
||||
run "CC $f" $CC -DHAVE_UNISTD_H -DHAVE_VSNPRINTF -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule zstd; then
|
||||
for f in "$rel_top_srcdir"/vendor/zstd/lib/*/*.c; do
|
||||
run "CC $f" $CC -DDYNAMIC_BMI2=0 -DZSTD_DISABLE_ASM -c "$f"
|
||||
done
|
||||
fi
|
||||
run "+" cd "$rel_top_srcdir" || exit 1
|
||||
rel_top_srcdir=.
|
||||
echo "#==== build UPX ====="
|
||||
run "+" cd "build/by-hand" || exit 1
|
||||
rel_top_srcdir=../..
|
||||
for f in "$rel_top_srcdir"/src/*.cpp "$rel_top_srcdir"/src/*/*.cpp; do
|
||||
run "CXX $f" $CXX -I"$rel_top_srcdir"/vendor -c "$f"
|
||||
done
|
||||
# echo "#==== link UPX ====="
|
||||
if test "x$AR" = "x"; then
|
||||
# link without using $AR
|
||||
run "CXX upx" $CXX -o upx *.o */*.o
|
||||
else
|
||||
run "AR libupx" $AR rcs libupx_submodules.a */*.o
|
||||
run "CXX upx" $CXX -o upx *.o -L. -lupx_submodules
|
||||
fi
|
||||
echo "# current directory: '$(pwd)'"
|
||||
ls -l upx*
|
||||
|
||||
echo "# All done."
|
||||
@@ -11,14 +11,18 @@ find . \
|
||||
-type d -name '.hg' -prune -o \
|
||||
-type d -name 'build*' -prune -o \
|
||||
-type d -name 'tmp*' -prune -o \
|
||||
-type d -name 'vendor' -prune -o \
|
||||
-type f -iname '*.bat' -prune -o \
|
||||
-type f -iname '*.exe' -prune -o \
|
||||
-type f -iname '*.o' -prune -o \
|
||||
-type f -iname '*.obj' -prune -o \
|
||||
-type f -iname '*.out' -prune -o \
|
||||
-type f -iname '*.pdf' -prune -o \
|
||||
-type f -iname '*.swp' -prune -o \
|
||||
-type f -print0 | \
|
||||
LC_ALL=C sort -z | xargs -0r perl -n -e '
|
||||
#print("$ARGV\n");
|
||||
if (m,[\x00\x01\x02\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
|
||||
if (m,[\x00\x01\x02\x7f\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
|
||||
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
|
||||
if (m,([ \t]+)$,) {
|
||||
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
|
||||
@@ -27,9 +31,10 @@ LC_ALL=C sort -z | xargs -0r perl -n -e '
|
||||
}
|
||||
}
|
||||
if (m,\t,) {
|
||||
if ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
|
||||
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
|
||||
elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { }
|
||||
else { print "ERROR: hard TAB detected $ARGV: $_"; exit(1); }
|
||||
if ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
|
||||
elsif ($ARGV =~ m,\.mk$,) { }
|
||||
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
|
||||
elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { }
|
||||
else { print "ERROR: hard TAB detected $ARGV: $_"; exit(1); }
|
||||
}
|
||||
' || exit 1
|
||||
@@ -10,12 +10,13 @@ set -e; set -o pipefail
|
||||
git ls-files --full-name -z | perl -0 -n -e '
|
||||
s,^,./,;
|
||||
if (m,^\./src/lzma-sdk(\0|$),) { }
|
||||
elsif (m,^\./vendor/,) { }
|
||||
elsif (m,\.bat(\0|$),) { }
|
||||
elsif (m,\.exe(\0|$),) { }
|
||||
else { print; }
|
||||
' | LC_ALL=C sort -z | xargs -0r perl -n -e '
|
||||
#print("$ARGV\n");
|
||||
if (m,[\x00\x01\x02\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
|
||||
if (m,[\x00\x01\x02\x7f\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
|
||||
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
|
||||
if (m,([ \t]+)$,) {
|
||||
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
|
||||
@@ -24,9 +25,10 @@ git ls-files --full-name -z | perl -0 -n -e '
|
||||
}
|
||||
}
|
||||
if (m,\t,) {
|
||||
if ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
|
||||
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
|
||||
elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { }
|
||||
else { print "ERROR: hard TAB detected $ARGV: $_"; exit(1); }
|
||||
if ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
|
||||
elsif ($ARGV =~ m,\.mk$,) { }
|
||||
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
|
||||
elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { }
|
||||
else { print "ERROR: hard TAB detected $ARGV: $_"; exit(1); }
|
||||
}
|
||||
' || exit 1
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
|
||||
# "Gofmt's style is nobody's favourite, but gofmt is everybody's favourite." --Rob Pike
|
||||
|
||||
# NOTE: we are using clang-format-15.0.6 from upx-stubtools
|
||||
# see https://github.com/upx/upx-stubtools/releases
|
||||
|
||||
# NOTE: we use .clang-format config from upx.git/.clang-format
|
||||
|
||||
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
|
||||
UPX_CLANG_FORMAT="$HOME/local/bin/bin-upx/clang-format-15.0.6"
|
||||
fi
|
||||
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
|
||||
UPX_CLANG_FORMAT="$HOME/.local/bin/bin-upx/clang-format-15.0.6"
|
||||
fi
|
||||
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
|
||||
UPX_CLANG_FORMAT="$HOME/bin/bin-upx/clang-format-15.0.6"
|
||||
fi
|
||||
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
|
||||
echo "ERROR: $0: cannot find clang-format-15.0.6"
|
||||
echo "ERROR: $0: please visit https://github.com/upx/upx-stubtools"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# limit memory usage to 1 GiB (in case of clang-format problems with invalid files)
|
||||
ulimit -v 1048576 || true
|
||||
|
||||
#echo $UPX_CLANG_FORMAT
|
||||
exec "$UPX_CLANG_FORMAT" -style=file "$@"
|
||||
exit 1
|
||||
Executable
+394
@@ -0,0 +1,394 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs")
|
||||
|
||||
# disable on macOS for now, see https://github.com/upx/upx/issues/612
|
||||
if [[ "$(uname)" == Darwin ]]; then
|
||||
echo "$0: SKIPPED"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# IMPORTANT NOTE: do NOT run as user root!!
|
||||
# IMPORTANT NOTE: this script only works on Unix!!
|
||||
umask 0022
|
||||
|
||||
id || true
|
||||
echo "PWD='$PWD'"
|
||||
if [[ $UID == 0 || $EUID == 0 ]]; then
|
||||
echo "ERROR: do not run as root: UID=$UID EUID=$EUID"
|
||||
exit 91
|
||||
fi
|
||||
|
||||
# test file system behaviour with symlinks; requires:
|
||||
# $upx_exe (required, but with convenience fallback "./upx")
|
||||
# optional settings:
|
||||
# $upx_exe_runner (e.g. "qemu-x86_64 -cpu Westmere" or "valgrind")
|
||||
|
||||
#***********************************************************************
|
||||
# init & checks
|
||||
#***********************************************************************
|
||||
|
||||
# upx_exe
|
||||
[[ -z $upx_exe && -f ./upx && -x ./upx ]] && upx_exe=./upx # convenience fallback
|
||||
if [[ -z $upx_exe ]]; then echo "UPX-ERROR: please set \$upx_exe"; exit 1; fi
|
||||
if [[ ! -f $upx_exe ]]; then echo "UPX-ERROR: file '$upx_exe' does not exist"; exit 1; fi
|
||||
upx_exe=$(readlink -fn "$upx_exe") # make absolute
|
||||
[[ -f $upx_exe ]] || exit 1
|
||||
upx_run=()
|
||||
if [[ -n $upx_exe_runner ]]; then
|
||||
# usage examples:
|
||||
# export upx_exe_runner="qemu-x86_64 -cpu Westmere"
|
||||
# export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet"
|
||||
# export upx_exe_runner="wine"
|
||||
IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array
|
||||
fi
|
||||
upx_run+=( "$upx_exe" )
|
||||
echo "upx_run='${upx_run[*]}'"
|
||||
|
||||
# upx_run check
|
||||
if ! "${upx_run[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
|
||||
if ! "${upx_run[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! "${upx_run[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
|
||||
#***********************************************************************
|
||||
# util
|
||||
#***********************************************************************
|
||||
|
||||
exit_code=0
|
||||
num_errors=0
|
||||
all_errors=
|
||||
|
||||
failed() {
|
||||
####exit $1
|
||||
# log error and keep going
|
||||
exit_code=1
|
||||
local a="$(basename "$(dirname "$PWD")")"
|
||||
local b="$(basename "$PWD")"
|
||||
let num_errors+=1 || true
|
||||
all_errors="${all_errors} $a/$b/$1"
|
||||
echo " FAILED $b/$1"
|
||||
}
|
||||
|
||||
assert_file() {
|
||||
local f
|
||||
for f in "$@"; do
|
||||
[[ ! -L "$f" && -f "$f" ]] && continue
|
||||
echo "failed '$f': not a regular file"
|
||||
failed 21
|
||||
done
|
||||
}
|
||||
|
||||
assert_symlink_to_file() {
|
||||
local f
|
||||
for f in "$@"; do
|
||||
[[ -L "$f" && -f "$f" ]] && continue
|
||||
echo "failed '$f': not a symlink to file"
|
||||
failed 22
|
||||
done
|
||||
}
|
||||
|
||||
assert_symlink_to_dir() {
|
||||
local f
|
||||
for f in "$@"; do
|
||||
[[ -L "$f" && -d "$f" ]] && continue
|
||||
echo "failed '$f': not a symlink to dir"
|
||||
failed 23
|
||||
done
|
||||
}
|
||||
|
||||
assert_symlink_dangling() {
|
||||
local f
|
||||
for f in "$@"; do
|
||||
[[ -L "$f" && ! -e "$f" ]] && continue
|
||||
echo "failed '$f': not a dangling symlink"
|
||||
failed 24
|
||||
done
|
||||
}
|
||||
|
||||
copy_directory() {
|
||||
if command -v rsync >/dev/null; then
|
||||
rsync -aH "$1/" "$2"
|
||||
else
|
||||
cp -ai "$1" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
create_files() {
|
||||
# clean
|
||||
local d
|
||||
for d in z_dir_1 z_dir_2 z_dir_3 z_dir_4; do
|
||||
if [[ -d $d ]]; then
|
||||
chmod -R +rwx "./$d"
|
||||
rm -rf "./$d"
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir z_dir_1
|
||||
cd z_dir_1
|
||||
: > z_file
|
||||
ln -s z_file z_symlink_file
|
||||
: > z_file_link_1
|
||||
ln z_file_link_1 z_file_link_2
|
||||
ln -s z_file_link_1 z_symlink_file_link
|
||||
mkdir z_dir
|
||||
ln -s z_dir z_symlink_dir
|
||||
ln -s z_file_missing z_symlink_dangling
|
||||
assert_file z_file*
|
||||
assert_symlink_to_file z_symlink_file
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
cd ..
|
||||
|
||||
# write-protect z_dir_2/z_file*
|
||||
copy_directory z_dir_1 z_dir_2
|
||||
chmod a-w z_dir_2/z_file*
|
||||
|
||||
# write-protect z_dir_3 itself
|
||||
copy_directory z_dir_1 z_dir_3
|
||||
chmod a-w z_dir_3
|
||||
|
||||
# write-protect everything in z_dir_4
|
||||
copy_directory z_dir_1 z_dir_4
|
||||
chmod -R a-w z_dir_4
|
||||
}
|
||||
|
||||
#***********************************************************************
|
||||
#
|
||||
#***********************************************************************
|
||||
|
||||
#set -x # debug
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_VERBOSE=0
|
||||
export NO_COLOR=1
|
||||
|
||||
testsuite_header() {
|
||||
local x='==========='; x="$x$x$x$x$x$x$x"
|
||||
echo -e "\n${x}\n${1}\n${x}\n"
|
||||
}
|
||||
|
||||
enter_dir() {
|
||||
cd "$1" || exit 1
|
||||
echo "===== $(basename "$PWD")"
|
||||
}
|
||||
leave_dir() {
|
||||
echo "===== $(basename "$PWD") files"
|
||||
ls -lA
|
||||
cd ..
|
||||
}
|
||||
|
||||
# create a tmpdir in current directory
|
||||
tmpdir="$(mktemp -d tmp-upx-test-XXXXXX)"
|
||||
cd "./$tmpdir" || exit 1
|
||||
|
||||
if [[ -f /bin/ls ]]; then
|
||||
test_file="$(readlink -fn /bin/ls)"
|
||||
else
|
||||
test_file="$(readlink -fn /usr/bin/env)"
|
||||
fi
|
||||
|
||||
testsuite_header "default"
|
||||
flags="-qq -1 --no-filter"
|
||||
mkdir default
|
||||
cd default
|
||||
create_files
|
||||
enter_dir z_dir_1
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_2
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_3
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_4
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
cd ..
|
||||
|
||||
testsuite_header "force-overwrite"
|
||||
flags="-qq -1 --no-filter --force-overwrite"
|
||||
mkdir force-overwrite
|
||||
cd force-overwrite
|
||||
create_files
|
||||
enter_dir z_dir_1
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
assert_file z_symlink_file z_symlink_file_link
|
||||
assert_file z_symlink_dir
|
||||
assert_file z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_2
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
assert_file z_symlink_file z_symlink_file_link
|
||||
assert_file z_symlink_dir
|
||||
assert_file z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_3
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_4
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
cd ..
|
||||
|
||||
if [[ 1 == 1 ]]; then
|
||||
testsuite_header "link"
|
||||
flags="-qq -1 --no-filter --link"
|
||||
mkdir link
|
||||
cd link
|
||||
create_files
|
||||
enter_dir z_dir_1
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
assert_file z_symlink_file z_symlink_file_link
|
||||
assert_file z_symlink_dir
|
||||
assert_file z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_2
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
assert_file z_symlink_file z_symlink_file_link
|
||||
assert_file z_symlink_dir
|
||||
assert_file z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_3
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_4
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# clean up
|
||||
cd ..
|
||||
chmod -R +rwx "./$tmpdir"
|
||||
rm -rf "./$tmpdir"
|
||||
|
||||
if [[ $exit_code == 0 ]]; then
|
||||
echo "UPX testsuite passed. All done."
|
||||
else
|
||||
echo "UPX-ERROR: UPX testsuite FAILED:${all_errors}"
|
||||
echo "UPX-ERROR: UPX testsuite FAILED with $num_errors error(s). See log file."
|
||||
fi
|
||||
exit $exit_code
|
||||
@@ -0,0 +1,209 @@
|
||||
########## begin .sha256sums.recreate
|
||||
expected_sha256sums__t010_decompressed="\
|
||||
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
|
||||
24808d572483f4cd713d66894b3da406755038737007a78b076528e6407e3132 *amd64-linux.elf/upx-3.95
|
||||
d88eaad0528bcecec9f51cbe015a117c8cf350a3f6d8308f2b0517d4fd19d189 *amd64-win64.pe/upx-3.95.exe
|
||||
f7279729eb975e4238f8b8ee56fefa41ccbeb35ef0ffe4c34f8047baab78fff5 *arm-linux.elf/upx-3.95
|
||||
e09df2a69f88c692138447f274ba7f99cdd11f8696c71ac8d3761606c95ab5c5 *arm-wince.pe/upx-3.91.exe
|
||||
ce81113f8a4ff1cd806811cb80ab8bea5c9c6fbced47451c7f07e50700f9817b *arm64-linux.elf/upx-3.95
|
||||
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
|
||||
84b90eb0d617571fe4885639925b35ca6a61060cb2616bb5bf729b4d701653e4 *armeb-linux.elf/upx-3.95
|
||||
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
7d331e508449497f64cd47abdd3f00f70307f508ad3fd692d333feb97beccead *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
|
||||
a1f3e5ffa7b2cfebe1e475ac1f4c7683b1b8b4e292aa0d04386cc0314dd162c9 *i386-linux.elf/upx-3.95
|
||||
e90fb09a808334c2674996760d42c82f8352e3f671f6b66c11481e772785c4d2 *i386-win32.pe/upx-3.91.exe
|
||||
07bd50c1d80f6ff651228e6fc0ba3a583a472915772244f232696b34156a9d27 *i386-win32.pe/upx-3.95.exe
|
||||
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
|
||||
8902f38ec3d95d8e077e3ab5fdbb5bad408859913a35deb87041f4f053cd6605 *mips-linux.elf/upx-3.95
|
||||
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
|
||||
dd1496bc4e9c32a5d5dd47e3eaabf7b134ca001d48807eebfd3d5e28c8a2ab58 *mipsel-linux.elf/upx-3.95
|
||||
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
|
||||
2bc00a51daa0bada19a8fa1bd2c227a8596844fa1b0aa3611087f195072700e2 *powerpc-linux.elf/upx-3.95
|
||||
a0950546dc17fca9437219431d8ddb0249ce5b08e899e0c799a87ac982adee70 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t020_canonicalized="\
|
||||
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
|
||||
24808d572483f4cd713d66894b3da406755038737007a78b076528e6407e3132 *amd64-linux.elf/upx-3.95
|
||||
d88eaad0528bcecec9f51cbe015a117c8cf350a3f6d8308f2b0517d4fd19d189 *amd64-win64.pe/upx-3.95.exe
|
||||
f7279729eb975e4238f8b8ee56fefa41ccbeb35ef0ffe4c34f8047baab78fff5 *arm-linux.elf/upx-3.95
|
||||
e09df2a69f88c692138447f274ba7f99cdd11f8696c71ac8d3761606c95ab5c5 *arm-wince.pe/upx-3.91.exe
|
||||
ce81113f8a4ff1cd806811cb80ab8bea5c9c6fbced47451c7f07e50700f9817b *arm64-linux.elf/upx-3.95
|
||||
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
|
||||
84b90eb0d617571fe4885639925b35ca6a61060cb2616bb5bf729b4d701653e4 *armeb-linux.elf/upx-3.95
|
||||
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
7d331e508449497f64cd47abdd3f00f70307f508ad3fd692d333feb97beccead *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
|
||||
a1f3e5ffa7b2cfebe1e475ac1f4c7683b1b8b4e292aa0d04386cc0314dd162c9 *i386-linux.elf/upx-3.95
|
||||
e90fb09a808334c2674996760d42c82f8352e3f671f6b66c11481e772785c4d2 *i386-win32.pe/upx-3.91.exe
|
||||
07bd50c1d80f6ff651228e6fc0ba3a583a472915772244f232696b34156a9d27 *i386-win32.pe/upx-3.95.exe
|
||||
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
|
||||
8902f38ec3d95d8e077e3ab5fdbb5bad408859913a35deb87041f4f053cd6605 *mips-linux.elf/upx-3.95
|
||||
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
|
||||
dd1496bc4e9c32a5d5dd47e3eaabf7b134ca001d48807eebfd3d5e28c8a2ab58 *mipsel-linux.elf/upx-3.95
|
||||
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
|
||||
2bc00a51daa0bada19a8fa1bd2c227a8596844fa1b0aa3611087f195072700e2 *powerpc-linux.elf/upx-3.95
|
||||
a0950546dc17fca9437219431d8ddb0249ce5b08e899e0c799a87ac982adee70 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t110_compress_ucl_nrv2b_3_no_filter="\
|
||||
def838b0032333bf3f525944ccafe362e8921b828936fcd6f3fb397c74432795 *amd64-linux.elf/upx-3.91
|
||||
aae4ab6795a826cee7a3f3d56acb613c17c1b1ab8c52e9830848bd8380ca395c *amd64-linux.elf/upx-3.95
|
||||
4faf76c6f509b5ced9349065d94da7ef4e2ff7356f050d429ae6ba37a66f7069 *amd64-win64.pe/upx-3.95.exe
|
||||
29da363abd195475090b86e9be0aff13bab7eded09575dd67bf0fc90013c00e9 *arm-linux.elf/upx-3.95
|
||||
0049eb0e899fc07f8f4cbe44d57b8e9558a70c34337b9f47e06a7ffdc21ad256 *arm-wince.pe/upx-3.91.exe
|
||||
4cc6c4a1808a9a6502c92510137c28aeceb1dbd4c5a31b44ef781a02a47163d3 *arm64-linux.elf/upx-3.95
|
||||
a9311d80c688a188f29f98284887fa8dca54a98c6a1693098f0bd23efadb59f4 *armeb-linux.elf/upx-3.91
|
||||
638103772ef45ea4ce182f784609b269b8d77974d408a74752d677c0c619ee44 *armeb-linux.elf/upx-3.95
|
||||
e8256dfde7bb3da63eb62f70bf8cef9abc6fdf9d52fd89963039bbe01e3aa10e *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
1acd381ebcb396cd1affd59ad2708a538fda1e49be8992b908680ff3a9de0648 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
0f806dae28529256ea89ed5c44b7f8daf8ad0f614a7433dc8b8fc9f99b1dd164 *i386-linux.elf/upx-3.91
|
||||
2b6b2e106ff23305f0713cab0f8d9509a53e82fb550cdbc8378ff52f4f5df19c *i386-linux.elf/upx-3.95
|
||||
695d27ebcefe8f4a6fccba050f0f82641e575233a83ea944fd35573c62c58538 *i386-win32.pe/upx-3.91.exe
|
||||
2cff918961f8e7eee395a8d2018cb94f91ecdcac1a01988437087d2c32c78d25 *i386-win32.pe/upx-3.95.exe
|
||||
17a754921048185871bb83c92788e1bec8b6a86b5a8f1b6be5077894759b3edc *m68k-atari.tos/upx-3.91.ttp
|
||||
f0ff4d442c1ac39411be6c8077be60476281f5a04e2736c9fbad0d950cfebe52 *mips-linux.elf/upx-3.95
|
||||
3175422f8cccffaa1f7b0cda5a6f273977642652f2f618e7ef554aa74b3deae0 *mipsel-linux.elf/upx-3.91
|
||||
db78052d467edb695d31a7540c2ff07c5d5157171824e55be1c0bf830d755f9e *mipsel-linux.elf/upx-3.95
|
||||
8cfb74cc5a592857167ae511c48f6ca126016b41e459846ac9376eb753e5ed2b *powerpc-linux.elf/upx-3.91
|
||||
8aaf2b9c4fbd7274f841b183b3bf799d673c77444e62b2d93cf49ecaf4eb82d8 *powerpc-linux.elf/upx-3.95
|
||||
be81fe407b90afce31898085bc23b5f47b5e899347817ec85a866d10ee8f4ca9 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\
|
||||
07828062ffc59e911b115d0f4f576a996bd6c732672646cdcec9cb9f28b1e1fd *amd64-linux.elf/upx-3.91
|
||||
fa36932d3b862ffa9142025440c02b5d4b604b5bb74a680e24f00c05c415590b *amd64-linux.elf/upx-3.95
|
||||
4377c48118aac9eb2d93853e7a8f26d7aeb0b09dd98b76685418424670c18d38 *amd64-win64.pe/upx-3.95.exe
|
||||
2b07d4aacbf14b188d18c814709435ff861cdd9af1cab8579604d6b64d554f18 *arm-linux.elf/upx-3.95
|
||||
f1abde57de44ea314d8b5a6ae1fbaadc539f004c1eed3153557dff0d36d86e9c *arm-wince.pe/upx-3.91.exe
|
||||
3d71827807812c85271d26ad241b88ede4731e5d23abb49daa3141941911668a *arm64-linux.elf/upx-3.95
|
||||
a6f100ddd3bc9a0b20c2225395aeead23038bcbcd7c2855fa8bf4b0389bded5f *armeb-linux.elf/upx-3.91
|
||||
7961d15d103ffabacf74f5be77e584eb2b382807f127ec658b62a79865cd8d7b *armeb-linux.elf/upx-3.95
|
||||
b6e7e212ec1b839cd0fb5f0ba2676af500f12222f76eeb4961966f3efde82d59 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
63b8c444e413534f9f57b7777635a21ed41eee5441707a61884ed504408fcf10 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
6e5e55eaeae0861e3340d863c7ac272b5e82abf7e74805ab6c2c91406cb6d80e *i386-linux.elf/upx-3.91
|
||||
3fb3dbc4de5d6a6587f179f121d3bf2b43dd35c87bb02737e08ae19659bd63b0 *i386-linux.elf/upx-3.95
|
||||
93dd8e25e4a4f9d73859ef82b565deadf06cf645c017f871803ec9a65e3a1f2e *i386-win32.pe/upx-3.91.exe
|
||||
c9fd12f5bd7fd7fd9b224387a19db65132829f057927b523d307986588862778 *i386-win32.pe/upx-3.95.exe
|
||||
72eabcdf8483677d4e6a34fd9292d0acc6afb977b9c11c04cb9d8701ed70a514 *m68k-atari.tos/upx-3.91.ttp
|
||||
8405b6f62a9da0fb1ed48e39b835787f44e0007df25fbb5addf62e537bea5b8d *mips-linux.elf/upx-3.95
|
||||
e1399cdbd927de11ee2e190870072c20ae4b0457293ed095e216ec07aaef63be *mipsel-linux.elf/upx-3.91
|
||||
e3ee3305d7eb8a087347563cb918826c0020f9425517dd2379d35b81f7558523 *mipsel-linux.elf/upx-3.95
|
||||
9359c529192c47170f54724d5552a9c7aea525fbe48bcb65cadf649d2a1a61bc *powerpc-linux.elf/upx-3.91
|
||||
ebfde9974eb2f5f0d84cb1d94b68bb3839f337cc19cd49f7a5bf05f5f06d0104 *powerpc-linux.elf/upx-3.95
|
||||
fe0d0e08f3f52a09b3ef266dc8ef20f8ca1b101a84697e1336aa7100be5c20bd *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\
|
||||
2767214e38bef8040a2ffcc49ed566110d4017c584ef8d70a19150123db70b07 *amd64-linux.elf/upx-3.91
|
||||
977d6d3ea341af39113df6194981b219b03752e5690371dbe26da2e95cc3cfe0 *amd64-linux.elf/upx-3.95
|
||||
0b69830516796f9018614270e0f07050c09c479495c753fab9c1f0029f3e8f33 *amd64-win64.pe/upx-3.95.exe
|
||||
b6c169e5ac4e1d84202d4ca885d66c50d10a8fc0754cd11fd5b10030e02bfebb *arm-linux.elf/upx-3.95
|
||||
bea5d7bace3c48d53c3e32c1cd21660ec38f1e5181d032e338ed01df0d2127fc *arm-wince.pe/upx-3.91.exe
|
||||
61397d56c882183181996024120c1ff6693eaad1d94b25ad589ca3f3f13f20f2 *arm64-linux.elf/upx-3.95
|
||||
50a9129df007f66036d6c975ec65f01d40d647816495b37de22c68fcfb78029d *armeb-linux.elf/upx-3.91
|
||||
2d60dd807a5b6e751a03bc27422e18370f33a84a400fe9764bb457df2cd71462 *armeb-linux.elf/upx-3.95
|
||||
0fc777c5ce9357496422b14f426aadbd0430f862cd7d3c6a441bfab861ff7e22 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
0152a5c3587016f5eaac20637b6ed05df7a73de2a270a8384d6026c3c4196967 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
38a9525611849ea6ef99a4b9203f664c23f3f970d8057d21ebb6679674d4f1db *i386-linux.elf/upx-3.91
|
||||
c692d7890d9b853303374cadfea9eb53eee603acb7d483c359d40e1500dd1f78 *i386-linux.elf/upx-3.95
|
||||
9dbc382f2c7bdc808183a81fd338b8089596695128edd2def6ce39b7b4328d68 *i386-win32.pe/upx-3.91.exe
|
||||
98a657dd4b718c973e88003b13ad338d1375dfa3355dc5cfc9bbb661aae158ed *i386-win32.pe/upx-3.95.exe
|
||||
4f69c4101b169a5b77ae387f6e58413a8f0b75edfef418e48a85d4fa208f622c *m68k-atari.tos/upx-3.91.ttp
|
||||
b5795fce568d81b0d3962f022983f2c9ccc9873ab1c92c8ae2d5c2df08ba05cc *mips-linux.elf/upx-3.95
|
||||
29ece4f791c731eb3f17ae3ea67cc31477260050591852a12612be2d8b5f1cc2 *mipsel-linux.elf/upx-3.91
|
||||
00350a2493106d353c17230902ddfbd375b0b5be92c8746514a32fb5b4f20531 *mipsel-linux.elf/upx-3.95
|
||||
7bb5a8d7b9f563557eb3bc970e5a92f0e5583b43151f75ac48e2360cd3d53c87 *powerpc-linux.elf/upx-3.91
|
||||
ce49efdc960a78078277c3dc746db0d9eb409d45bc6f91863e49a862bc65c966 *powerpc-linux.elf/upx-3.95
|
||||
9a800c16d1d7db5e8c6b8140c9aecc253d65717e1dfba5ac65de7804f487efee *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t140_compress_lzma_2_no_filter="\
|
||||
0069bd038cddcd0b87b2f56471c7fe223eaa1186c29648c5505103e813d841c3 *amd64-linux.elf/upx-3.91
|
||||
82ae15c72fddba6a569c7a3c3c9dbcb9021f5de8dcaf20ef304a6255475dc076 *amd64-linux.elf/upx-3.95
|
||||
616c7bfe28cbf059d23036fab3931f1a77d8383287102e0f4533ac8bba2ed3f1 *amd64-win64.pe/upx-3.95.exe
|
||||
24110285d7f44c2caf53f8e8a4cd83e07d7650964d0d0f1adff9411731918bb2 *arm-linux.elf/upx-3.95
|
||||
4f5a9de1efe24c8ba5acd4b858f38da0f5a05fac2eb6582960d999341c6b5a7b *arm-wince.pe/upx-3.91.exe
|
||||
6fe5e2a043e84e376a66a22a3cdc0cf30f04ca5fe404129e3d6ff8746a597cfd *arm64-linux.elf/upx-3.95
|
||||
fd1d2050a4e414db32375d9400dd583462d21ddc625bf48318525c4cef750194 *armeb-linux.elf/upx-3.91
|
||||
db077c6fd75e81e889ae7cfccd7fb2eb604ada3d8f68ddced1c283c8d65ec5c5 *armeb-linux.elf/upx-3.95
|
||||
68d307bdbb6dbd721cc62ca2029879c7e505e889d322176c894b5451d1975563 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
3a2619475906f20e9aca7eb31167c6ab502de7c496c54167f0589d0c52ab060b *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
3b64a7279552c9754b9fbe9760ce94df698d5c72e0e722013a4c8992854da97a *i386-linux.elf/upx-3.91
|
||||
3da0a1c028d6b9a325d7beef6399379fcb2c1f6654b1be8548654c0451ff92cb *i386-linux.elf/upx-3.95
|
||||
366c066909663c9b19f9211a444ae08e228cc78a9f2cc32af6c07a5be02fcb19 *i386-win32.pe/upx-3.91.exe
|
||||
615a77ca6df08458e34c4a67ff657bab9dcc3cebf2da3d675fec623eb7dcd631 *i386-win32.pe/upx-3.95.exe
|
||||
cd612528df6180c7a72e80dcd779729a082d9b5b5312b930032f1425f0ee6525 *m68k-atari.tos/upx-3.91.ttp
|
||||
18371b44212bb75de8ab435ad0302d5a69b9fdeb2d0e3241a860e57c8c7ae684 *mips-linux.elf/upx-3.95
|
||||
ec3b847217121ee5b7de02f1d81c44b149af9676c59d1a20eb71bd00cc200a96 *mipsel-linux.elf/upx-3.91
|
||||
70febd6b0460cf481681d0d2c3062d7dbfe4031a94dc0a60527b8ac236a61464 *mipsel-linux.elf/upx-3.95
|
||||
7901f9f8c87e0e6adc91e4cb1f3013f8e48ac484c7f1ec93712a54bb4054b86a *powerpc-linux.elf/upx-3.91
|
||||
3233502fc41d22fb5d6708a4b4a8c8bbb1a469baa818de2313d3eb682e2bcabf *powerpc-linux.elf/upx-3.95
|
||||
240f68868436b71c258b3941d497506ae7aa908c47a6e8d860b315f31747ae8f *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t150_compress_ucl_2_all_filters="\
|
||||
44782eb9d4612c0da2349a85ff203434be9fec95a7de831d5c9dddf86b4bcca6 *amd64-linux.elf/upx-3.91
|
||||
f2a9302c55856518941e15e5e27396b09b0a6436f3fd285a72233e70307cd84f *amd64-linux.elf/upx-3.95
|
||||
cea35c25e4417fa815f383195bf2bef77631e5a594943dd830228e7efb2fceaf *amd64-win64.pe/upx-3.95.exe
|
||||
e3a22eea074646a74221a2f77719711cbd7dd773dc4118d1e20e7f4b4243ab7c *arm-linux.elf/upx-3.95
|
||||
44be9300e7a196715ec98757058bd033d54f60d9b472a9bb44574bcf13ad6872 *arm-wince.pe/upx-3.91.exe
|
||||
e59d29a593ec04952ebb9d8739104eeb191c84bf179232bfd5f4cf3d93d9c300 *arm64-linux.elf/upx-3.95
|
||||
af99b4f754a2d69788ecd802c23b2073acb6a2c255205b1f48ee5bf858b4e0ec *armeb-linux.elf/upx-3.91
|
||||
6222c23490376a8b639c887e4a74329563c887745e23e2805b2747ce4592afea *armeb-linux.elf/upx-3.95
|
||||
27d0e4525aab2f136cd9711f7f49971eeac3916c1c020b3ae96012d63d259bfa *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
36825cb489b31be59873a2d7b7b70d73f5693384b4d07b43ef824c39781ba2f2 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
b8f50569863c7ddc62678a83e64db1f92d52f208dab82bd0f682f2e94e9893b6 *i386-linux.elf/upx-3.91
|
||||
21b192de6430e534e408dd84438f3df41e0c9e2f4874d404a48fa0f6c8ef420c *i386-linux.elf/upx-3.95
|
||||
0f563975edf33eda453a3ff6c29c6d4cb4986b411fd1e08ac3335a7e0efecbf0 *i386-win32.pe/upx-3.91.exe
|
||||
01192c4c7ab197ec9f94e1d759bf5375a759d258719999e30b9252598d5ba3fd *i386-win32.pe/upx-3.95.exe
|
||||
e9da1f7bbac24026b3d0e102e3428b5408521140a72421be9133b3e4383f7ae8 *m68k-atari.tos/upx-3.91.ttp
|
||||
2ca89ba1d0fa58a6741e1f59b313e95501385c003628a6f54f4314a81e3bf003 *mips-linux.elf/upx-3.95
|
||||
987d193c228b498cb0096783e0dad3f3f1a5964f0ecd8d88373be5619bf365e6 *mipsel-linux.elf/upx-3.91
|
||||
b90ac46b8d1ad5e89c3aef00317de48de343a8789d08beba8ce73ea3d3389e0c *mipsel-linux.elf/upx-3.95
|
||||
643e83b549b120d4b95ab9776aceb1bce00b5bcd092f8e797c6de569b7319d60 *powerpc-linux.elf/upx-3.91
|
||||
835e1e6100c9538feae120fc49b2d279bbd47bc06d121e068b20120c1d723370 *powerpc-linux.elf/upx-3.95
|
||||
adde61c5841ee5774c58828e199410c288b1b820eb1c2a541937208c4571d6e0 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t160_compress_all_methods_1_no_filter="\
|
||||
30d2d0daad443d6510ca98211cbb252eb7e34fb8e64dcff9f488b80efe16ae11 *amd64-linux.elf/upx-3.91
|
||||
d0d739ddf40049b1aa47adf4d223b93423b24e4b3d0b90c6784984eaf543a6a0 *amd64-linux.elf/upx-3.95
|
||||
83aed8c5af108230c8e1a65978ceb0284f9aba3a2d322751a835fc00b44977e3 *amd64-win64.pe/upx-3.95.exe
|
||||
c52fc32e70518dbb4a018bb13cae96189d6829e022a66a290ae22bdc2002ddda *arm-linux.elf/upx-3.95
|
||||
9f3bbd889e8ae5e84c9642b469e7572d33ee907cded259cce0cc06313694da94 *arm-wince.pe/upx-3.91.exe
|
||||
4cc27218d283568ea3d291e7e81823582dadf6aad171e5e1a3cf5ed498f7e42d *arm64-linux.elf/upx-3.95
|
||||
22b15aec122fff9af6b165be15202e2b37a9040e29d8134b36a2f1b6089b4d31 *armeb-linux.elf/upx-3.91
|
||||
aafc89fe42ad632bf97611f0fa883ea2bad3fa8acc8609bf3fafb9e3eb7e836b *armeb-linux.elf/upx-3.95
|
||||
a60b7ac4aa974e777f53010d2e67b9f1797f264303a6520f6a5091c74d3ee2d5 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
40dd6e828e194af6c7ba556bb0b3f871b4359678aaa8774e4ebd2f3d2f0f8a8b *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
f5060a90ccdeace91e6ad7b76cea9b91782726e1ec87006a479623014c0f9a15 *i386-linux.elf/upx-3.91
|
||||
313401757dbac85507981b32a0a1b91b8dae69341df8b883a8c9503fdc853a5e *i386-linux.elf/upx-3.95
|
||||
b3ca631c6ef394cb1c6128a9fe80ae15046f08d6117f34b3b50f9038d9abd040 *i386-win32.pe/upx-3.91.exe
|
||||
2abd77c25d1b127df71b2ca907b886698fe366325d13fc79d42d3bad9bc80c9a *i386-win32.pe/upx-3.95.exe
|
||||
c7cb10370e0b1fc829751e454b8c31db71f374b4242a495193dd1a3095353030 *m68k-atari.tos/upx-3.91.ttp
|
||||
3ad999051b105774b6156216196afceca832e23ed182f23068b3fd72cb405776 *mips-linux.elf/upx-3.95
|
||||
22bd048307eb9c72537558e6f50f971a3d083639849fcbdba7f2ae465985f6be *mipsel-linux.elf/upx-3.91
|
||||
7d85fd4fac91e65ec7c480f56dcf66fabe6597123b93e9a5d8ac09739ffb1a0c *mipsel-linux.elf/upx-3.95
|
||||
91f2cf4275d14d60ff086b6eb79eaea3b5bac5ea182cb678339a4cf70b4e46a7 *powerpc-linux.elf/upx-3.91
|
||||
51c8366e143061412e9e9e92846ae9d6ed78dc687dd8ac3ee944c6cc55ad2b95 *powerpc-linux.elf/upx-3.95
|
||||
1d88a2605b6a12966b26b9d0fdd9b3f8b4ac2ebfacb022d539e52fa2ea1be0cf *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\
|
||||
687cd0d51188481265c6253757a87a94378b307caa88ca95f159a9cfeb6cfa66 *amd64-linux.elf/upx-3.91
|
||||
794e33f457d112b0380ccbcbfced16cf2569f15a36a974a4b009fa1ffb2e8949 *amd64-linux.elf/upx-3.95
|
||||
9ae9462455f1f8b5eb3e8950f7626a984597bb025659314acce71534e35cee88 *amd64-win64.pe/upx-3.95.exe
|
||||
e62442fc7c0b9f4a6b54780d0cd279b59cf127b6c5f09b7d641cf07e1fd567c2 *arm-linux.elf/upx-3.95
|
||||
19ed6d80777a365175602a24a5207c861f79e356fdacb17623522f8b427d4233 *arm-wince.pe/upx-3.91.exe
|
||||
66f4e3b6e14d3a38ee603708cf60896e05203fbe22f5212ae388bd807471ceef *arm64-linux.elf/upx-3.95
|
||||
dc5e78ab3d0b501223e9bc43a941117c2aa5a95ebeb901cef895c40b6a61d589 *armeb-linux.elf/upx-3.91
|
||||
78b345cbd58873a179b300519b2207ed8b419fd8aa594196522dbe53a6ab46e9 *armeb-linux.elf/upx-3.95
|
||||
7e74eac05b02b3032ae86946a4cf9e6d3c0c9af65da38bc018fcff6cb028f952 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
21136df18a98ffe3cd02cca2b28afe7680af22c36673b074d7428ae7cdb997de *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
f49473440ae7ab009fabc7ef010d63abbcbffd997a9765eded2d7aee987410a6 *i386-linux.elf/upx-3.91
|
||||
a900c4100b29ef2cbddaa3fafb8ad0c036a78643c673bc95f752c804132fac82 *i386-linux.elf/upx-3.95
|
||||
f30af1a399ee567e48a6421bde100c185c2adc2c4f511082de3b5269560b27f3 *i386-win32.pe/upx-3.91.exe
|
||||
675e2ee5c4bf3cb238df206342a89b66781b2805028d637a175b6f0c9f4f2334 *i386-win32.pe/upx-3.95.exe
|
||||
cbd080edafac3eff5d1d2942a5b1084f088bf681ceaed099b40daec8c67a6a5c *m68k-atari.tos/upx-3.91.ttp
|
||||
a4dbaf71ead4ca4f4ffaa0061ceb25f531f81532fb37845cffdd2fd9750e9d12 *mips-linux.elf/upx-3.95
|
||||
2894ae7f01ed6bc44d1a1da580ba6b2a9c5a69fc18d8105f1d7afae5ef5e5769 *mipsel-linux.elf/upx-3.91
|
||||
27447c78485ac0421138594bf3b80e7ea0745537437e8915ee665509e89a80fe *mipsel-linux.elf/upx-3.95
|
||||
9cc94dc937a895d07cbaf50ef116a6b45e6127a10e23bc47e993d838bf1e398a *powerpc-linux.elf/upx-3.91
|
||||
b2ad0b8dcfb788ba344b3700f31946c9b1d8b9fda6f29665b3c9f71f2dbcdf9b *powerpc-linux.elf/upx-3.95
|
||||
10785a5ef331592f2135964f3e46b29f1591708bf3c09fef079ded145eb9e0e4 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
########## end .sha256sums.recreate
|
||||
Executable
+329
@@ -0,0 +1,329 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs")
|
||||
|
||||
# very first version of the upx-testsuite; requires:
|
||||
# $upx_exe (required, but with convenience fallback "./upx")
|
||||
# $upx_testsuite_SRCDIR (required, but with convenience fallback)
|
||||
# $upx_testsuite_BUILDDIR (optional)
|
||||
#
|
||||
# optional settings:
|
||||
# $upx_exe_runner (e.g. "qemu-x86_64 -cpu Westmere" or "valgrind")
|
||||
# $UPX_TESTSUITE_VERBOSE
|
||||
# $UPX_TESTSUITE_LEVEL
|
||||
#
|
||||
# see https://github.com/upx/upx-testsuite.git
|
||||
|
||||
#***********************************************************************
|
||||
# init & checks
|
||||
#***********************************************************************
|
||||
|
||||
# upx_exe
|
||||
[[ -z $upx_exe && -f ./upx && -x ./upx ]] && upx_exe=./upx # convenience fallback
|
||||
if [[ -z $upx_exe ]]; then echo "UPX-ERROR: please set \$upx_exe"; exit 1; fi
|
||||
if [[ ! -f $upx_exe ]]; then echo "UPX-ERROR: file '$upx_exe' does not exist"; exit 1; fi
|
||||
upx_exe=$(readlink -fn "$upx_exe") # make absolute
|
||||
[[ -f $upx_exe ]] || exit 1
|
||||
upx_run=()
|
||||
if [[ -n $upx_exe_runner ]]; then
|
||||
# usage examples:
|
||||
# export upx_exe_runner="qemu-x86_64 -cpu Westmere"
|
||||
# export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet"
|
||||
# export upx_exe_runner="wine"
|
||||
IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array
|
||||
fi
|
||||
upx_run+=( "$upx_exe" )
|
||||
echo "upx_run='${upx_run[*]}'"
|
||||
|
||||
# upx_run check, part1
|
||||
if ! "${upx_run[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
|
||||
if ! "${upx_run[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! "${upx_run[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
|
||||
# upx_testsuite_SRCDIR
|
||||
if [[ -z $upx_testsuite_SRCDIR ]]; then
|
||||
# convenience fallback: search standard locations below upx top-level directory
|
||||
if [[ -d "$argv0dir/../../../upx--upx-testsuite.git/files/packed" ]]; then
|
||||
upx_testsuite_SRCDIR="$argv0dir/../../../upx--upx-testsuite.git"
|
||||
elif [[ -d "$argv0dir/../../../upx-testsuite.git/files/packed" ]]; then
|
||||
upx_testsuite_SRCDIR="$argv0dir/../../../upx-testsuite.git"
|
||||
elif [[ -d "$argv0dir/../../../upx-testsuite/files/packed" ]]; then
|
||||
upx_testsuite_SRCDIR="$argv0dir/../../../upx-testsuite"
|
||||
fi
|
||||
fi
|
||||
if [[ ! -d "$upx_testsuite_SRCDIR/files/packed" ]]; then
|
||||
echo "invalid or missing \$upx_testsuite_SRCDIR:"
|
||||
echo " please git clone https://github.com/upx/upx-testsuite.git"
|
||||
echo " and set (export) the envvar upx_testsuite_SRCDIR to the local file path"
|
||||
exit 1
|
||||
fi
|
||||
upx_testsuite_SRCDIR=$(readlink -fn "$upx_testsuite_SRCDIR") # make absolute
|
||||
[[ -d $upx_testsuite_SRCDIR ]] || exit 1
|
||||
|
||||
# upx_testsuite_BUILDDIR
|
||||
if [[ -z $upx_testsuite_BUILDDIR ]]; then
|
||||
upx_testsuite_BUILDDIR="./tmp-upx-testsuite"
|
||||
fi
|
||||
mkdir -p "$upx_testsuite_BUILDDIR" || exit 1
|
||||
upx_testsuite_BUILDDIR=$(readlink -fn "$upx_testsuite_BUILDDIR") # make absolute
|
||||
[[ -d $upx_testsuite_BUILDDIR ]] || exit 1
|
||||
|
||||
cd / && cd "$upx_testsuite_BUILDDIR" || exit 1
|
||||
: > ./.mfxnobackup
|
||||
|
||||
# upx_run check, part2
|
||||
if ! "${upx_run[@]}" --version-short >/dev/null; then
|
||||
echo "UPX-ERROR: FATAL: upx --version-short FAILED"
|
||||
echo "please make sure that \$upx_exe contains ABSOLUTE file paths and can be run from any directory"
|
||||
echo "INFO: upx_run='${upx_run[*]}'"
|
||||
exit 1
|
||||
fi
|
||||
if ! "${upx_run[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! "${upx_run[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
|
||||
case $UPX_TESTSUITE_LEVEL in
|
||||
[0-8]) ;;
|
||||
*) UPX_TESTSUITE_LEVEL=999 ;;
|
||||
esac
|
||||
if [[ $UPX_TESTSUITE_LEVEL == 0 ]]; then
|
||||
echo "UPX testsuite SKIPPED."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#***********************************************************************
|
||||
# setup
|
||||
#***********************************************************************
|
||||
|
||||
#set -x # debug
|
||||
exit_code=0
|
||||
num_errors=0
|
||||
all_errors=
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_VERBOSE=0
|
||||
|
||||
rm -rf ./testsuite_1
|
||||
mkdir testsuite_1 || exit 1
|
||||
cd testsuite_1 || exit 1
|
||||
|
||||
#***********************************************************************
|
||||
# support functions
|
||||
#***********************************************************************
|
||||
|
||||
run_upx() {
|
||||
local ec=0
|
||||
if [[ $UPX_TESTSUITE_VERBOSE == 1 ]]; then
|
||||
echo "LOG: '${upx_run[*]}' $*"
|
||||
fi
|
||||
"${upx_run[@]}" "$@" || ec=$?
|
||||
if [[ $ec != 0 ]]; then
|
||||
echo "FATAL: '${upx_run[*]}' $*"
|
||||
echo " (exit code was $ec)"
|
||||
exit 42
|
||||
fi
|
||||
}
|
||||
|
||||
testsuite_header() {
|
||||
local x='==========='; x="$x$x$x$x$x$x$x"
|
||||
echo -e "\n${x}\n${1}\n${x}\n"
|
||||
}
|
||||
|
||||
testsuite_split_f() {
|
||||
fd=$(dirname "$1")
|
||||
fb=$(basename "$1")
|
||||
fsubdir=$(basename "$fd")
|
||||
# sanity checks
|
||||
if [[ ! -f $1 || -z $fsubdir || -z $fb ]]; then
|
||||
fd=''; fb=''; fsubdir=''
|
||||
fi
|
||||
}
|
||||
|
||||
testsuite_check_sha() {
|
||||
(cd "$1" && sha256sum -b [0-9a-zA-Z]*/* | LC_ALL=C sort -k2) > $1/.sha256sums.current
|
||||
echo
|
||||
cat $1/.sha256sums.current
|
||||
if ! cmp -s $1/.sha256sums.expected $1/.sha256sums.current; then
|
||||
echo "UPX-ERROR: $1 FAILED: checksum mismatch"
|
||||
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
|
||||
exit_code=99
|
||||
let num_errors+=1 || true
|
||||
all_errors="${all_errors} $1"
|
||||
#exit 99
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
testsuite_check_sha_decompressed() {
|
||||
(cd "$1" && sha256sum -b [0-9a-zA-Z]*/* | LC_ALL=C sort -k2) > $1/.sha256sums.current
|
||||
if ! cmp -s $1/.sha256sums.expected $1/.sha256sums.current; then
|
||||
cat $1/.sha256sums.current
|
||||
echo "UPX-ERROR: FATAL: $1 FAILED: decompressed checksum mismatch"
|
||||
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
|
||||
exit 98
|
||||
fi
|
||||
}
|
||||
|
||||
testsuite_use_canonicalized=1
|
||||
testsuite_run_compress() {
|
||||
testsuite_header $testdir
|
||||
local files f
|
||||
if [[ $testsuite_use_canonicalized == 1 ]]; then
|
||||
files='t020_canonicalized/*/*'
|
||||
else
|
||||
files='t010_decompressed/*/*'
|
||||
fi
|
||||
for f in $files; do
|
||||
testsuite_split_f "$f"
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p "$testdir/$fsubdir" "$testdir/.decompressed/$fsubdir"
|
||||
run_upx -qq --prefer-ucl "$@" "$f" -o "$testdir/$fsubdir/$fb"
|
||||
run_upx -qq -d "$testdir/$fsubdir/$fb" -o "$testdir/.decompressed/$fsubdir/$fb"
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
run_upx -qq -l "$testdir"/*/*
|
||||
run_upx -qq --file-info "$testdir"/*/*
|
||||
run_upx -q -t "$testdir"/*/*
|
||||
if [[ $testsuite_use_canonicalized == 1 ]]; then
|
||||
# check that after decompression the file matches the canonicalized version
|
||||
cp t020_canonicalized/.sha256sums.expected $testdir/.decompressed/
|
||||
testsuite_check_sha_decompressed $testdir/.decompressed
|
||||
rm -rf "./$testdir/.decompressed"
|
||||
fi
|
||||
}
|
||||
|
||||
#***********************************************************************
|
||||
# expected checksums
|
||||
#
|
||||
# To ease maintenance of this script in case of updates this section
|
||||
# can be automatically re-created from the current checksums -
|
||||
# see call of function recreate_expected_sha256sums below.
|
||||
#***********************************************************************
|
||||
|
||||
recreate_expected_sha256sums() {
|
||||
local o="$1"
|
||||
local files f d
|
||||
echo "########## begin .sha256sums.recreate" > "$o"
|
||||
files='*/.sha256sums.current'
|
||||
for f in $files; do
|
||||
d=$(dirname "$f")
|
||||
echo "expected_sha256sums__${d}="'"\' >> "$o"
|
||||
cat "$f" >> "$o"
|
||||
echo '"' >> "$o"
|
||||
done
|
||||
echo "########## end .sha256sums.recreate" >> "$o"
|
||||
}
|
||||
|
||||
source "$argv0dir/upx_testsuite_1-expected_sha256sums.sh" || exit 1
|
||||
|
||||
#***********************************************************************
|
||||
# decompression tests
|
||||
#***********************************************************************
|
||||
|
||||
testdir=t010_decompressed
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
|
||||
testsuite_header $testdir
|
||||
for f in "$upx_testsuite_SRCDIR"/files/packed/*/upx-3.9[15]*; do
|
||||
testsuite_split_f "$f"
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p "$testdir/$fsubdir"
|
||||
run_upx -qq -d "$f" -o "$testdir/$fsubdir/$fb"
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
|
||||
# run one pack+unpack step to canonicalize the files
|
||||
testdir=t020_canonicalized
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
|
||||
testsuite_header $testdir
|
||||
for f in t010_decompressed/*/*; do
|
||||
testsuite_split_f "$f"
|
||||
[[ -z $fb ]] && continue
|
||||
echo "# $f"
|
||||
mkdir -p "$testdir/$fsubdir/.packed"
|
||||
run_upx -qq --prefer-ucl -1 "$f" -o "$testdir/$fsubdir/.packed/$fb"
|
||||
run_upx -qq -d "$testdir/$fsubdir/.packed/$fb" -o "$testdir/$fsubdir/$fb"
|
||||
done
|
||||
testsuite_check_sha $testdir
|
||||
|
||||
#***********************************************************************
|
||||
# compression tests
|
||||
# info: we use fast compression levels because we want to
|
||||
# test UPX and not the compression libraries
|
||||
#***********************************************************************
|
||||
|
||||
if [[ $UPX_TESTSUITE_LEVEL -ge 2 ]]; then
|
||||
testdir=t110_compress_ucl_nrv2b_3_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --nrv2b -3 --no-filter
|
||||
fi
|
||||
|
||||
if [[ $UPX_TESTSUITE_LEVEL -ge 3 ]]; then
|
||||
testdir=t120_compress_ucl_nrv2d_3_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --nrv2d -3 --no-filter
|
||||
fi
|
||||
|
||||
if [[ $UPX_TESTSUITE_LEVEL -ge 4 ]]; then
|
||||
testdir=t130_compress_ucl_nrv2e_3_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --nrv2e -3 --no-filter
|
||||
fi
|
||||
|
||||
if [[ $UPX_TESTSUITE_LEVEL -ge 5 ]]; then
|
||||
testdir=t140_compress_lzma_2_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --lzma -2 --no-filter
|
||||
fi
|
||||
|
||||
if [[ $UPX_TESTSUITE_LEVEL -ge 6 ]]; then
|
||||
testdir=t150_compress_ucl_2_all_filters
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress -2 --all-filters
|
||||
fi
|
||||
|
||||
if [[ $UPX_TESTSUITE_LEVEL -ge 7 ]]; then
|
||||
testdir=t160_compress_all_methods_1_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --all-methods -1 --no-filter
|
||||
fi
|
||||
|
||||
if [[ $UPX_TESTSUITE_LEVEL -ge 8 ]]; then
|
||||
testdir=t170_compress_all_methods_no_lzma_5_no_filter
|
||||
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
|
||||
time testsuite_run_compress --all-methods --no-lzma -5 --no-filter
|
||||
fi
|
||||
|
||||
#***********************************************************************
|
||||
# summary
|
||||
#***********************************************************************
|
||||
|
||||
# recreate checksums from current version for an easy update in case of changes
|
||||
recreate_expected_sha256sums .sha256sums.recreate
|
||||
|
||||
testsuite_header "UPX testsuite summary: level $UPX_TESTSUITE_LEVEL"
|
||||
run_upx --version-short
|
||||
echo
|
||||
echo "upx_exe='$upx_exe'"
|
||||
ls -l "$upx_exe"
|
||||
if command -v file >/dev/null; then
|
||||
file "$upx_exe" || true
|
||||
fi
|
||||
echo "upx_run='${upx_run[*]}'"
|
||||
echo "upx_testsuite_SRCDIR='$upx_testsuite_SRCDIR'"
|
||||
echo "upx_testsuite_BUILDDIR='$upx_testsuite_BUILDDIR'"
|
||||
echo ".sha256sums.{expected,current} counts:"
|
||||
cat ./*/.sha256sums.expected | LC_ALL=C sort | wc
|
||||
cat ./*/.sha256sums.current | LC_ALL=C sort | wc
|
||||
echo
|
||||
if [[ $exit_code == 0 ]]; then
|
||||
echo "UPX testsuite passed. All done."
|
||||
else
|
||||
echo "UPX-ERROR: UPX testsuite FAILED:${all_errors}"
|
||||
echo "UPX-ERROR: UPX testsuite FAILED with $num_errors error(s). See log file."
|
||||
fi
|
||||
exit $exit_code
|
||||
+71
-139
@@ -1,174 +1,106 @@
|
||||
#
|
||||
# UPX Makefile - needs GNU make 3.81 or better
|
||||
#
|
||||
# Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
# UPX src Makefile - needs GNU make and CMake >= 3.13
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
# build configuration options for this Makefile
|
||||
BUILD_TYPE_DEBUG ?= 0
|
||||
BUILD_TYPE_SANITIZE ?= 0
|
||||
BUILD_USE_DEPEND ?= 1
|
||||
|
||||
MAKEFLAGS += -r
|
||||
.SUFFIXES:
|
||||
export SHELL = /bin/sh
|
||||
override ee = $($1) $(EXTRA_$1) $(upx_$1) $(upx_EXTRA_$1) $($(basename $(notdir $@)).$1)
|
||||
# NOTE: this Makefile is deprecated - please directly use the CMake build
|
||||
# instead. And see the top-level Makefile for some pre-defined CMake
|
||||
# build configurations.
|
||||
|
||||
ifndef srcdir
|
||||
srcdir := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
srcdir := $(shell echo '$(srcdir)' | sed 's,/*$$,,' || echo 'ERROR')
|
||||
srcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
|
||||
endif
|
||||
ifndef top_srcdir
|
||||
top_srcdir := $(srcdir)/..
|
||||
endif
|
||||
include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
|
||||
ifneq ($(srcdir),.)
|
||||
vpath %.cpp .:$(srcdir)
|
||||
vpath %.h .:$(srcdir)
|
||||
top_srcdir := $(srcdir)/..
|
||||
endif
|
||||
|
||||
# toolchain
|
||||
CXX ?= g++
|
||||
CXXLD = $(CXX)
|
||||
exeext ?= .out
|
||||
libext ?= .a
|
||||
objext ?= .o
|
||||
#
|
||||
# redirect to top-level CMake build
|
||||
#
|
||||
|
||||
upx_SOURCES := $(sort $(wildcard $(srcdir)/*.cpp))
|
||||
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
|
||||
# NOTE that top-level Makefile .DEFAULT_GOAL is build/release
|
||||
.DEFAULT_GOAL = build/debug
|
||||
|
||||
ifneq ($(wildcard $(top_srcdir)/.git/.),)
|
||||
UPX_VERSION_GITREV := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=12 HEAD || echo 'ERROR'))
|
||||
ifneq ($(UPX_VERSION_GITREV),)
|
||||
GITREV_PLUS := $(strip $(shell cd '$(top_srcdir)' && git diff --exit-code HEAD >/dev/null && echo '' || echo '+'))
|
||||
DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)$(GITREV_PLUS)"'
|
||||
endif
|
||||
endif
|
||||
build/debug: $(top_srcdir)/build/debug/upx
|
||||
build/release: $(top_srcdir)/build/release/upx
|
||||
|
||||
# we need UCL and zlib - you can set envvar UPX_UCLDIR
|
||||
ifneq ($(wildcard $(UPX_UCLDIR)/include/ucl/ucl.h),)
|
||||
INCLUDES += -I$(UPX_UCLDIR)/include
|
||||
LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
|
||||
endif
|
||||
LIBS += -lucl -lz
|
||||
# LZMA from https://github.com/upx/upx-lzma-sdk
|
||||
include $(top_srcdir)/src/stub/src/c/Makevars.lzma
|
||||
.NOTPARALLEL: # because the actual builds use "cmake --parallel"
|
||||
.PHONY: PHONY
|
||||
.SECONDEXPANSION:
|
||||
.SUFFIXES:
|
||||
|
||||
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
|
||||
ifeq ($(BUILD_TYPE_DEBUG),1)
|
||||
CXXFLAGS_OPTIMIZE ?= -O0 -g
|
||||
else
|
||||
CXXFLAGS_OPTIMIZE ?= -O2
|
||||
endif
|
||||
CXXFLAGS += $(CXXFLAGS_OPTIMIZE)
|
||||
# protect against security threats caused by misguided C++ compiler "optimizations"
|
||||
ifeq ($(findstring clang,$(CXX)),)
|
||||
CXXFLAGS += -fno-delete-null-pointer-checks
|
||||
endif
|
||||
CXXFLAGS += -fno-strict-aliasing -fwrapv
|
||||
CXXFLAGS += -funsigned-char
|
||||
CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wshadow -Wvla -Wwrite-strings
|
||||
CXXFLAGS_WERROR ?= -Werror
|
||||
CXXFLAGS += $(CXXFLAGS_WERROR)
|
||||
# shortcuts (all => debug + release)
|
||||
debug: build/debug
|
||||
release: build/release
|
||||
all build/all: build/debug build/release
|
||||
|
||||
ifeq ($(BUILD_TYPE_SANITIZE),1)
|
||||
CXXFLAGS_SANITIZE ?= -fsanitize=address,undefined -fno-omit-frame-pointer -DACC_CFG_NO_UNALIGNED
|
||||
CXXFLAGS += $(CXXFLAGS_SANITIZE)
|
||||
# these are the only 2 objects that are actually speed-sensitive
|
||||
compress_lzma$(objext) filteri$(objext) : override CXXFLAGS_SANITIZE =
|
||||
endif
|
||||
|
||||
# rules
|
||||
all: upx$(exeext) | ./.depend
|
||||
.DELETE_ON_ERROR: upx$(exeext) $(upx_OBJECTS) ./.depend
|
||||
|
||||
upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
|
||||
$($(notdir $@).PRE_LINK_STEP)
|
||||
$(strip $(CXXLD) $(call ee,CXXFLAGS) $(call ee,LDFLAGS) -o $@ $(upx_OBJECTS) $(call ee,LDADD) $(call ee,LIBS))
|
||||
$($(notdir $@).POST_LINK_STEP)
|
||||
$(CHECK_WHITESPACE)
|
||||
|
||||
%.o : %.cpp | ./.depend
|
||||
$(strip $(CXX) $(call ee,CPPFLAGS) $(call ee,CXXFLAGS) -o $@ -c $<)
|
||||
%.cpp.ii : %.cpp
|
||||
$(strip $(CXX) $(call ee,CPPFLAGS) $(call ee,CXXFLAGS) -o $@ -E $<)
|
||||
|
||||
ifeq ($(BUILD_USE_DEPEND),1)
|
||||
./.depend: $(sort $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h)) $(MAKEFILE_LIST)
|
||||
@rm -f $@
|
||||
@echo "Updating $@"
|
||||
@$(strip $(CXX) $(call ee,CPPFLAGS) $(call ee,CXXFLAGS) -MM) $(filter %.cpp,$^) > $@
|
||||
else
|
||||
./.depend:
|
||||
.PHONY: ./.depend
|
||||
endif
|
||||
|
||||
CHECK_WHITESPACE =
|
||||
ifeq ($(shell uname),Linux)
|
||||
CHECK_WHITESPACE = $(top_srcdir)/src/stub/scripts/check_whitespace.sh $(top_srcdir)
|
||||
ifneq ($(wildcard $(top_srcdir)/.git/.),)
|
||||
CHECK_WHITESPACE = $(top_srcdir)/src/stub/scripts/check_whitespace_git.sh $(top_srcdir)
|
||||
endif
|
||||
check-whitespace : ; $(CHECK_WHITESPACE)
|
||||
endif
|
||||
.PHONY: check-whitespace
|
||||
|
||||
mostlyclean clean distclean maintainer-clean:
|
||||
rm -f *.d *.ii *.map *.o *.obj *.res ./.depend upx.exe upx.out upx.ttp upx$(exeext)
|
||||
|
||||
./.depend compress_lzma$(objext) : INCLUDES += -I$(UPX_LZMADIR)
|
||||
|
||||
compress_lzma$(objext) : CXXFLAGS += -Wno-shadow
|
||||
p_mach$(objext) : CXXFLAGS += -Wno-cast-align
|
||||
|
||||
.PHONY: all mostlyclean clean distclean maintainer-clean
|
||||
|
||||
ifeq ($(MAKECMDGOALS),mostlyclean)
|
||||
else ifeq ($(MAKECMDGOALS),clean)
|
||||
else ifeq ($(MAKECMDGOALS),distclean)
|
||||
else ifeq ($(MAKECMDGOALS),maintainer-clean)
|
||||
else ifeq ($(MAKECMDGOALS),clang-format)
|
||||
else ifeq ($(MAKECMDGOALS),check-whitespace)
|
||||
else
|
||||
ifeq ($(BUILD_USE_DEPEND),1)
|
||||
-include ./.depend
|
||||
endif
|
||||
help$(objext): $(MAKEFILE_LIST)
|
||||
endif
|
||||
$(top_srcdir)/build/debug/upx: PHONY
|
||||
$(MAKE) -C $(top_srcdir) build/debug
|
||||
$(top_srcdir)/build/release/upx: PHONY
|
||||
$(MAKE) -C $(top_srcdir) build/release
|
||||
|
||||
#
|
||||
# "make run-testsuite"
|
||||
# see https://github.com/upx/upx-testsuite.git
|
||||
#
|
||||
|
||||
# search for the UPX testsuite -- git clone https://github.com/upx/upx-testsuite.git
|
||||
# you also can override upx_testsuite_SRCDIR
|
||||
ifndef upx_testsuite_SRCDIR
|
||||
# search standard locations below $(top_srcdir)
|
||||
ifneq ($(wildcard $(top_srcdir)/../upx-testsuite.git/files/packed/.),)
|
||||
ifneq ($(wildcard $(top_srcdir)/../upx--upx-testsuite.git/files/packed/.),)
|
||||
upx_testsuite_SRCDIR := $(top_srcdir)/../upx--upx-testsuite.git
|
||||
else ifneq ($(wildcard $(top_srcdir)/../upx-testsuite.git/files/packed/.),)
|
||||
upx_testsuite_SRCDIR := $(top_srcdir)/../upx-testsuite.git
|
||||
else ifneq ($(wildcard $(top_srcdir)/../upx-testsuite/files/packed/.),)
|
||||
upx_testsuite_SRCDIR := $(top_srcdir)/../upx-testsuite
|
||||
endif
|
||||
endif
|
||||
|
||||
# run the UPX testsuite
|
||||
# The expected (old) checksums are in $(top_srcdir)/misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
|
||||
# The actual (new) checksums are in ./tmp-upx-testsuite/testsuite_1/.sha256sums.recreate
|
||||
ifneq ($(wildcard $(upx_testsuite_SRCDIR)/files/packed/.),)
|
||||
ifneq ($(wildcard $(top_srcdir)/.github/travis_testsuite_1.sh),)
|
||||
run-testsuite: export upx_exe := ./upx$(exeext)
|
||||
run-testsuite: export upx_testsuite_SRCDIR := $(upx_testsuite_SRCDIR)
|
||||
run-testsuite: export upx_testsuite_BUILDDIR := ./tmp-testsuite
|
||||
run-testsuite: ./upx$(exeext)
|
||||
time -p bash $(top_srcdir)/.github/travis_testsuite_1.sh
|
||||
.PHONY: run-testsuite
|
||||
ifneq ($(wildcard $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh),)
|
||||
run-testsuite: run-testsuite-release
|
||||
run-testsuite-%: export upx_testsuite_SRCDIR := $(upx_testsuite_SRCDIR)
|
||||
run-testsuite-%: export upx_testsuite_BUILDDIR := ./tmp-upx-testsuite
|
||||
run-testsuite-debug: export upx_exe := $(top_srcdir)/build/debug/upx
|
||||
run-testsuite-debug: PHONY $(top_srcdir)/build/debug/upx
|
||||
time -p bash $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh
|
||||
run-testsuite-release: export upx_exe := $(top_srcdir)/build/release/upx
|
||||
run-testsuite-release: PHONY $(top_srcdir)/build/release/upx
|
||||
time -p bash $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# "make check-whitespace"
|
||||
#
|
||||
|
||||
ifneq ($(wildcard /usr/bin/env),) # needs bash, perl, xargs, etc.
|
||||
CHECK_WHITESPACE = $(top_srcdir)/misc/scripts/check_whitespace.sh $(top_srcdir)
|
||||
ifneq ($(wildcard $(top_srcdir)/.git/.),)
|
||||
CHECK_WHITESPACE = $(top_srcdir)/misc/scripts/check_whitespace_git.sh $(top_srcdir)
|
||||
endif
|
||||
check-whitespace: PHONY; $(CHECK_WHITESPACE)
|
||||
endif
|
||||
|
||||
#
|
||||
# "make clang-format"
|
||||
#
|
||||
|
||||
# automatically format some C++ source code files
|
||||
ifeq ($(shell uname),Linux)
|
||||
CLANG_FORMAT_FILES += linker.cpp linker.h packhead.cpp
|
||||
CLANG_FORMAT_FILES += s_djgpp2.cpp s_object.cpp s_vcsa.cpp s_win32.cpp screen.h
|
||||
CLANG_FORMAT_FILES += snprintf.cpp
|
||||
CLANG_FORMAT_FILES += stdcxx.cpp stdcxx.h
|
||||
CLANG_FORMAT_FILES += ui.cpp ui.h util.h
|
||||
clang-format:
|
||||
$(top_srcdir)/src/stub/scripts/upx-clang-format -i $(addprefix $(top_srcdir)/src/,$(CLANG_FORMAT_FILES))
|
||||
.PHONY: clang-format
|
||||
# Markus loves clang-format, but John hates it; find a compromise
|
||||
CLANG_FORMAT_EXCLUDE_FILES += miniacc.h stub/%.h
|
||||
CLANG_FORMAT_EXCLUDE_FILES += p_elf.h p_elf_enum.h p_lx_% p_mach% p_unix% p_vmlin%
|
||||
CLANG_FORMAT_FILES := $(sort $(wildcard *.[ch]* ../maint/src/*.[ch]* */*.[ch]*))
|
||||
CLANG_FORMAT_FILES += $(sort $(wildcard stub/tools/*/*.[ch]*))
|
||||
CLANG_FORMAT_FILES := $(filter-out $(CLANG_FORMAT_EXCLUDE_FILES),$(CLANG_FORMAT_FILES))
|
||||
clang-format: PHONY $(CLANG_FORMAT_FILES)
|
||||
@echo "running upx-clang-format"
|
||||
@$(top_srcdir)/misc/scripts/upx-clang-format.sh -i $(CLANG_FORMAT_FILES)
|
||||
endif
|
||||
|
||||
# vim:set ts=8 sw=8 noet:
|
||||
|
||||
+665
-373
File diff suppressed because it is too large
Load Diff
+92
-136
@@ -2,8 +2,8 @@
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2017 Laszlo Molnar
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2023 Laszlo Molnar
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
@@ -25,36 +25,30 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __UPX_BELE_H
|
||||
# error "this is an internal include file"
|
||||
#endif
|
||||
|
||||
// this is an internal include file private to bele.h
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
#if defined(BELE_CTP)
|
||||
// CTP - Compile-Time Polymorphism (templates)
|
||||
# define V static inline
|
||||
# define S static int __acc_cdecl_qsort
|
||||
# define C /*empty*/
|
||||
// CTP - Compile-Time Polymorphism (templates)
|
||||
#define V static inline
|
||||
#define S static int __acc_cdecl_qsort
|
||||
#define C noexcept
|
||||
#elif defined(BELE_RTP)
|
||||
// RTP - Run-Time Polymorphism (virtual functions)
|
||||
# define V virtual
|
||||
# define S virtual int
|
||||
# define C const
|
||||
// RTP - Run-Time Polymorphism (virtual functions)
|
||||
#define V virtual
|
||||
#define S virtual int
|
||||
#define C const noexcept
|
||||
#else
|
||||
# error
|
||||
#error
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BELE_RTP)
|
||||
struct AbstractPolicy
|
||||
{
|
||||
inline AbstractPolicy() { }
|
||||
virtual inline ~AbstractPolicy() { }
|
||||
struct AbstractPolicy {
|
||||
explicit inline AbstractPolicy() noexcept {}
|
||||
virtual inline ~AbstractPolicy() noexcept {}
|
||||
V bool isBE() C = 0;
|
||||
V bool isLE() C = 0;
|
||||
|
||||
@@ -68,10 +62,10 @@ struct AbstractPolicy
|
||||
V void set32(void *p, unsigned v) C = 0;
|
||||
V void set64(void *p, upx_uint64_t v) C = 0;
|
||||
|
||||
V unsigned get16_signed(const void *p) C = 0;
|
||||
V unsigned get24_signed(const void *p) C = 0;
|
||||
V unsigned get32_signed(const void *p) C = 0;
|
||||
V upx_uint64_t get64_signed(const void *p) C = 0;
|
||||
V int get16_signed(const void *p) C = 0;
|
||||
V int get24_signed(const void *p) C = 0;
|
||||
V int get32_signed(const void *p) C = 0;
|
||||
V upx_int64_t get64_signed(const void *p) C = 0;
|
||||
|
||||
S u16_compare(const void *a, const void *b) C = 0;
|
||||
S u24_compare(const void *a, const void *b) C = 0;
|
||||
@@ -83,18 +77,28 @@ struct AbstractPolicy
|
||||
S u32_compare_signed(const void *a, const void *b) C = 0;
|
||||
S u64_compare_signed(const void *a, const void *b) C = 0;
|
||||
|
||||
private:
|
||||
// disable copy and move
|
||||
AbstractPolicy(const AbstractPolicy &) DELETED_FUNCTION;
|
||||
AbstractPolicy &operator=(const AbstractPolicy &) DELETED_FUNCTION;
|
||||
AbstractPolicy(AbstractPolicy &&) noexcept DELETED_FUNCTION;
|
||||
AbstractPolicy &operator=(AbstractPolicy &&) noexcept DELETED_FUNCTION;
|
||||
// disable dynamic allocation
|
||||
DISABLE_NEW_DELETE
|
||||
ACC_CXX_DISABLE_NEW_DELETE
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BELE_RTP)
|
||||
#undef C
|
||||
#define C const noexcept override
|
||||
#endif
|
||||
|
||||
struct BEPolicy
|
||||
#if defined(BELE_RTP)
|
||||
: public AbstractPolicy
|
||||
final : public AbstractPolicy
|
||||
#endif
|
||||
{
|
||||
inline BEPolicy() { }
|
||||
explicit inline BEPolicy() noexcept {}
|
||||
#if defined(BELE_CTP)
|
||||
typedef N_BELE_RTP::BEPolicy RTP_Policy;
|
||||
#elif defined(BELE_RTP)
|
||||
@@ -107,50 +111,30 @@ struct BEPolicy
|
||||
typedef BE32 U32;
|
||||
typedef BE64 U64;
|
||||
|
||||
V unsigned get16(const void *p) C
|
||||
{ return get_be16(p); }
|
||||
V unsigned get24(const void *p) C
|
||||
{ return get_be24(p); }
|
||||
V unsigned get32(const void *p) C
|
||||
{ return get_be32(p); }
|
||||
V upx_uint64_t get64(const void *p) C
|
||||
{ return get_be64(p); }
|
||||
V unsigned get16(const void *p) C { return get_be16(p); }
|
||||
V unsigned get24(const void *p) C { return get_be24(p); }
|
||||
V unsigned get32(const void *p) C { return get_be32(p); }
|
||||
V upx_uint64_t get64(const void *p) C { return get_be64(p); }
|
||||
|
||||
V void set16(void *p, unsigned v) C
|
||||
{ set_be16(p, v); }
|
||||
V void set24(void *p, unsigned v) C
|
||||
{ set_be24(p, v); }
|
||||
V void set32(void *p, unsigned v) C
|
||||
{ set_be32(p, v); }
|
||||
V void set64(void *p, upx_uint64_t v) C
|
||||
{ set_be64(p, v); }
|
||||
V void set16(void *p, unsigned v) C { set_be16(p, v); }
|
||||
V void set24(void *p, unsigned v) C { set_be24(p, v); }
|
||||
V void set32(void *p, unsigned v) C { set_be32(p, v); }
|
||||
V void set64(void *p, upx_uint64_t v) C { set_be64(p, v); }
|
||||
|
||||
V unsigned get16_signed(const void *p) C
|
||||
{ return get_be16_signed(p); }
|
||||
V unsigned get24_signed(const void *p) C
|
||||
{ return get_be24_signed(p); }
|
||||
V unsigned get32_signed(const void *p) C
|
||||
{ return get_be32_signed(p); }
|
||||
V upx_uint64_t get64_signed(const void *p) C
|
||||
{ return get_be64_signed(p); }
|
||||
V int get16_signed(const void *p) C { return get_be16_signed(p); }
|
||||
V int get24_signed(const void *p) C { return get_be24_signed(p); }
|
||||
V int get32_signed(const void *p) C { return get_be32_signed(p); }
|
||||
V upx_int64_t get64_signed(const void *p) C { return get_be64_signed(p); }
|
||||
|
||||
S u16_compare(const void *a, const void *b) C
|
||||
{ return be16_compare(a, b); }
|
||||
S u24_compare(const void *a, const void *b) C
|
||||
{ return be24_compare(a, b); }
|
||||
S u32_compare(const void *a, const void *b) C
|
||||
{ return be32_compare(a, b); }
|
||||
S u64_compare(const void *a, const void *b) C
|
||||
{ return be64_compare(a, b); }
|
||||
S u16_compare(const void *a, const void *b) C { return be16_compare(a, b); }
|
||||
S u24_compare(const void *a, const void *b) C { return be24_compare(a, b); }
|
||||
S u32_compare(const void *a, const void *b) C { return be32_compare(a, b); }
|
||||
S u64_compare(const void *a, const void *b) C { return be64_compare(a, b); }
|
||||
|
||||
S u16_compare_signed(const void *a, const void *b) C
|
||||
{ return be16_compare_signed(a, b); }
|
||||
S u24_compare_signed(const void *a, const void *b) C
|
||||
{ return be24_compare_signed(a, b); }
|
||||
S u32_compare_signed(const void *a, const void *b) C
|
||||
{ return be32_compare_signed(a, b); }
|
||||
S u64_compare_signed(const void *a, const void *b) C
|
||||
{ return be64_compare_signed(a, b); }
|
||||
S u16_compare_signed(const void *a, const void *b) C { return be16_compare_signed(a, b); }
|
||||
S u24_compare_signed(const void *a, const void *b) C { return be24_compare_signed(a, b); }
|
||||
S u32_compare_signed(const void *a, const void *b) C { return be32_compare_signed(a, b); }
|
||||
S u64_compare_signed(const void *a, const void *b) C { return be64_compare_signed(a, b); }
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
@@ -161,17 +145,22 @@ struct BEPolicy
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(U64)
|
||||
}
|
||||
|
||||
private:
|
||||
// disable copy and move
|
||||
BEPolicy(const BEPolicy &) DELETED_FUNCTION;
|
||||
BEPolicy &operator=(const BEPolicy &) DELETED_FUNCTION;
|
||||
BEPolicy(BEPolicy &&) noexcept DELETED_FUNCTION;
|
||||
BEPolicy &operator=(BEPolicy &&) noexcept DELETED_FUNCTION;
|
||||
// disable dynamic allocation
|
||||
DISABLE_NEW_DELETE
|
||||
ACC_CXX_DISABLE_NEW_DELETE
|
||||
};
|
||||
|
||||
|
||||
struct LEPolicy
|
||||
#if defined(BELE_RTP)
|
||||
: public AbstractPolicy
|
||||
final : public AbstractPolicy
|
||||
#endif
|
||||
{
|
||||
inline LEPolicy() { }
|
||||
explicit inline LEPolicy() noexcept {}
|
||||
#if defined(BELE_CTP)
|
||||
typedef N_BELE_RTP::LEPolicy RTP_Policy;
|
||||
#elif defined(BELE_RTP)
|
||||
@@ -184,50 +173,30 @@ struct LEPolicy
|
||||
typedef LE32 U32;
|
||||
typedef LE64 U64;
|
||||
|
||||
V unsigned get16(const void *p) C
|
||||
{ return get_le16(p); }
|
||||
V unsigned get24(const void *p) C
|
||||
{ return get_le24(p); }
|
||||
V unsigned get32(const void *p) C
|
||||
{ return get_le32(p); }
|
||||
V upx_uint64_t get64(const void *p) C
|
||||
{ return get_le64(p); }
|
||||
V unsigned get16(const void *p) C { return get_le16(p); }
|
||||
V unsigned get24(const void *p) C { return get_le24(p); }
|
||||
V unsigned get32(const void *p) C { return get_le32(p); }
|
||||
V upx_uint64_t get64(const void *p) C { return get_le64(p); }
|
||||
|
||||
V void set16(void *p, unsigned v) C
|
||||
{ set_le16(p, v); }
|
||||
V void set24(void *p, unsigned v) C
|
||||
{ set_le24(p, v); }
|
||||
V void set32(void *p, unsigned v) C
|
||||
{ set_le32(p, v); }
|
||||
V void set64(void *p, upx_uint64_t v) C
|
||||
{ set_le64(p, v); }
|
||||
V void set16(void *p, unsigned v) C { set_le16(p, v); }
|
||||
V void set24(void *p, unsigned v) C { set_le24(p, v); }
|
||||
V void set32(void *p, unsigned v) C { set_le32(p, v); }
|
||||
V void set64(void *p, upx_uint64_t v) C { set_le64(p, v); }
|
||||
|
||||
V unsigned get16_signed(const void *p) C
|
||||
{ return get_le16_signed(p); }
|
||||
V unsigned get24_signed(const void *p) C
|
||||
{ return get_le24_signed(p); }
|
||||
V unsigned get32_signed(const void *p) C
|
||||
{ return get_le32_signed(p); }
|
||||
V upx_uint64_t get64_signed(const void *p) C
|
||||
{ return get_le64_signed(p); }
|
||||
V int get16_signed(const void *p) C { return get_le16_signed(p); }
|
||||
V int get24_signed(const void *p) C { return get_le24_signed(p); }
|
||||
V int get32_signed(const void *p) C { return get_le32_signed(p); }
|
||||
V upx_int64_t get64_signed(const void *p) C { return get_le64_signed(p); }
|
||||
|
||||
S u16_compare(const void *a, const void *b) C
|
||||
{ return le16_compare(a, b); }
|
||||
S u24_compare(const void *a, const void *b) C
|
||||
{ return le24_compare(a, b); }
|
||||
S u32_compare(const void *a, const void *b) C
|
||||
{ return le32_compare(a, b); }
|
||||
S u64_compare(const void *a, const void *b) C
|
||||
{ return le64_compare(a, b); }
|
||||
S u16_compare(const void *a, const void *b) C { return le16_compare(a, b); }
|
||||
S u24_compare(const void *a, const void *b) C { return le24_compare(a, b); }
|
||||
S u32_compare(const void *a, const void *b) C { return le32_compare(a, b); }
|
||||
S u64_compare(const void *a, const void *b) C { return le64_compare(a, b); }
|
||||
|
||||
S u16_compare_signed(const void *a, const void *b) C
|
||||
{ return le16_compare_signed(a, b); }
|
||||
S u24_compare_signed(const void *a, const void *b) C
|
||||
{ return le24_compare_signed(a, b); }
|
||||
S u32_compare_signed(const void *a, const void *b) C
|
||||
{ return le32_compare_signed(a, b); }
|
||||
S u64_compare_signed(const void *a, const void *b) C
|
||||
{ return le64_compare_signed(a, b); }
|
||||
S u16_compare_signed(const void *a, const void *b) C { return le16_compare_signed(a, b); }
|
||||
S u24_compare_signed(const void *a, const void *b) C { return le24_compare_signed(a, b); }
|
||||
S u32_compare_signed(const void *a, const void *b) C { return le32_compare_signed(a, b); }
|
||||
S u64_compare_signed(const void *a, const void *b) C { return le64_compare_signed(a, b); }
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
@@ -238,40 +207,27 @@ struct LEPolicy
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(U64)
|
||||
}
|
||||
|
||||
private:
|
||||
// disable copy and move
|
||||
LEPolicy(const LEPolicy &) DELETED_FUNCTION;
|
||||
LEPolicy &operator=(const LEPolicy &) DELETED_FUNCTION;
|
||||
LEPolicy(LEPolicy &&) noexcept DELETED_FUNCTION;
|
||||
LEPolicy &operator=(LEPolicy &&) noexcept DELETED_FUNCTION;
|
||||
// disable dynamic allocation
|
||||
DISABLE_NEW_DELETE
|
||||
ACC_CXX_DISABLE_NEW_DELETE
|
||||
};
|
||||
|
||||
|
||||
// Native Endianness policy (aka host policy)
|
||||
#if (ACC_ABI_BIG_ENDIAN)
|
||||
typedef BEPolicy NEPolicy;
|
||||
typedef BEPolicy HostPolicy;
|
||||
#elif (ACC_ABI_LITTLE_ENDIAN)
|
||||
typedef LEPolicy NEPolicy;
|
||||
typedef LEPolicy HostPolicy;
|
||||
#else
|
||||
# error "ACC_ABI_ENDIAN"
|
||||
#error "ACC_ABI_ENDIAN"
|
||||
#endif
|
||||
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
struct HostAlignedPolicy
|
||||
{
|
||||
#if defined(BELE_CTP)
|
||||
enum { isBE = HostPolicy::isBE, isLE = HostPolicy::isLE };
|
||||
#endif
|
||||
|
||||
typedef upx_uint16_t U16;
|
||||
typedef upx_uint32_t U32;
|
||||
typedef upx_uint64_t U64;
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#undef V
|
||||
#undef S
|
||||
#undef C
|
||||
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
/* bptr.h --
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2017 Laszlo Molnar
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __UPX_BPTR_H
|
||||
#define __UPX_BPTR_H 1
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// BoundedPtr
|
||||
**************************************************************************/
|
||||
|
||||
template <class T>
|
||||
class BoundedPtr
|
||||
{
|
||||
public:
|
||||
//typedef T* StoredType;
|
||||
//typedef T* PointerType;
|
||||
//typedef T& ReferenceType;
|
||||
|
||||
~BoundedPtr() { }
|
||||
|
||||
explicit BoundedPtr(void* base, size_t size_in_bytes, T* ptr=0)
|
||||
: ptr_(ptr), base_(base), size_in_bytes_(0)
|
||||
{
|
||||
assert(base_ != NULL);
|
||||
size_in_bytes_ = mem_size(1, size_in_bytes);
|
||||
check();
|
||||
}
|
||||
|
||||
// assignment
|
||||
BoundedPtr& operator= (const BoundedPtr& other) {
|
||||
assert(base_ == other.base_);
|
||||
assert(size_in_bytes_ == other.size_in_bytes_);
|
||||
ptr_ = other.ptr_; check(); return *this;
|
||||
}
|
||||
BoundedPtr& operator= (T* other) {
|
||||
ptr_ = other; check(); return *this;
|
||||
}
|
||||
|
||||
operator T* () { return ptr_; }
|
||||
operator const T* () const { return ptr_; }
|
||||
|
||||
BoundedPtr& operator += (size_t n) {
|
||||
checkNULL(); ptr_ += n; checkRange(); return *this;
|
||||
}
|
||||
BoundedPtr& operator -= (size_t n) {
|
||||
checkNULL(); ptr_ -= n; checkRange(); return *this;
|
||||
}
|
||||
BoundedPtr& operator ++ (void) {
|
||||
checkNULL(); ptr_ += 1; checkRange(); return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void checkNULL() const {
|
||||
if __acc_very_unlikely(!ptr_)
|
||||
throwCantUnpack("unexpected NULL pointer; take care!");
|
||||
}
|
||||
void checkRange() const {
|
||||
size_t off = (const char *) ptr_ - (const char *) base_;
|
||||
if __acc_very_unlikely(off > size_in_bytes_)
|
||||
throwCantUnpack("pointer out of range; take care!");
|
||||
}
|
||||
void check() const { // check ptr_ invariant: either NULL or valid checkRange()
|
||||
if (ptr_ != NULL)
|
||||
checkRange();
|
||||
}
|
||||
|
||||
T* ptr_;
|
||||
void* base_;
|
||||
size_t size_in_bytes_;
|
||||
|
||||
// disable copy
|
||||
BoundedPtr(const BoundedPtr&); // {}
|
||||
// disable dynamic allocation
|
||||
DISABLE_NEW_DELETE
|
||||
};
|
||||
|
||||
|
||||
#endif /* already included */
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -0,0 +1,674 @@
|
||||
/* dt_check.cpp -- doctest check
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#include "../conf.h"
|
||||
|
||||
/*************************************************************************
|
||||
// upx_doctest_check()
|
||||
//
|
||||
// honors environment variables:
|
||||
// UPX_DEBUG_DOCTEST_DISABLE
|
||||
// UPX_DEBUG_DOCTEST_VERBOSE
|
||||
//
|
||||
// HINT: set "UPX_DEBUG_DOCTEST_DISABLE=1" for improved debugging experience
|
||||
**************************************************************************/
|
||||
|
||||
int upx_doctest_check(int argc, char **argv) {
|
||||
#if defined(DOCTEST_CONFIG_DISABLE)
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
return 0;
|
||||
#else
|
||||
const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE");
|
||||
if (!e)
|
||||
e = getenv("UPX_DEBUG_DISABLE_DOCTEST"); // allow alternate spelling
|
||||
if (e && e[0] && strcmp(e, "0") != 0)
|
||||
return 0;
|
||||
bool minimal = true; // don't show summary
|
||||
bool duration = false; // don't show timings
|
||||
bool success = false; // don't show all succeeding tests
|
||||
#if DEBUG
|
||||
// default for debug builds: do show the [doctest] summary
|
||||
minimal = false;
|
||||
#endif
|
||||
e = getenv("UPX_DEBUG_DOCTEST_VERBOSE");
|
||||
if (e && e[0]) {
|
||||
if (strcmp(e, "0") == 0) {
|
||||
minimal = true;
|
||||
} else if (strcmp(e, "1") == 0) {
|
||||
minimal = false;
|
||||
} else if (strcmp(e, "2") == 0) {
|
||||
minimal = false;
|
||||
duration = true;
|
||||
} else if (strcmp(e, "3") == 0) {
|
||||
minimal = false;
|
||||
duration = true;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
doctest::Context context;
|
||||
if (minimal)
|
||||
context.setOption("dt-minimal", true);
|
||||
if (duration)
|
||||
context.setOption("dt-duration", true);
|
||||
if (success)
|
||||
context.setOption("dt-success", true);
|
||||
// this requires that main_get_options() understands "--dt-XXX" options
|
||||
if (argc > 0 && argv != nullptr)
|
||||
context.applyCommandLine(argc, argv);
|
||||
int r = context.run();
|
||||
if (r != 0)
|
||||
return 1;
|
||||
if (context.shouldExit())
|
||||
return 2;
|
||||
return 0;
|
||||
#endif // DOCTEST_CONFIG_DISABLE
|
||||
}
|
||||
|
||||
int upx_doctest_check() { return upx_doctest_check(0, nullptr); }
|
||||
|
||||
/*************************************************************************
|
||||
// compile-time checks
|
||||
**************************************************************************/
|
||||
|
||||
// need extra parenthesis because the C preprocessor does not understand C++ templates
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same<short, upx_int16_t>::value))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same<unsigned short, upx_uint16_t>::value))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same<int, upx_int32_t>::value))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same<unsigned, upx_uint32_t>::value))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same<long long, upx_int64_t>::value))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same<unsigned long long, upx_uint64_t>::value))
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(no_bswap16(0x04030201) == 0x0201)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(no_bswap32(0x04030201) == 0x04030201)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(no_bswap64(0x0807060504030201ull) == 0x0807060504030201ull)
|
||||
#if !(ACC_CC_MSC) // unfortunately *not* constexpr with current MSVC
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(bswap16(0x04030201) == 0x0102)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(bswap32(0x04030201) == 0x01020304)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(bswap64(0x0807060504030201ull) == 0x0102030405060708ull)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(bswap16(bswap16(0xf4f3f2f1)) == no_bswap16(0xf4f3f2f1))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(bswap32(bswap32(0xf4f3f2f1)) == no_bswap32(0xf4f3f2f1))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(bswap64(bswap64(0xf8f7f6f5f4f3f2f1ull)) ==
|
||||
no_bswap64(0xf8f7f6f5f4f3f2f1ull))
|
||||
#endif
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 0, 8) == 0)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 1, 8) == 1)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 127, 8) == 127)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 128, 8) == -128)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u - 1, 8) == -1)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 256, 8) == 0)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 257, 8) == 1)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 383, 8) == 127)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 384, 8) == -128)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 511, 8) == -1)
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_BIT == 8)
|
||||
#if 0 // does not work with MSVC
|
||||
#if '\0' - 1 < 0
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 127)
|
||||
#else
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255)
|
||||
#endif
|
||||
#if L'\0' - 1 < 0
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((wchar_t) -1 < 0)
|
||||
#else
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((wchar_t) -1 > 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
// upx_compiler_sanity_check()
|
||||
// assert a sane architecture and compiler
|
||||
// (modern compilers will optimize away most of this code)
|
||||
**************************************************************************/
|
||||
|
||||
namespace {
|
||||
|
||||
template <class T>
|
||||
struct CheckIntegral {
|
||||
struct TestT {
|
||||
T a;
|
||||
T x[2];
|
||||
};
|
||||
template <class U>
|
||||
struct TestU {
|
||||
U a = {};
|
||||
const U b = {};
|
||||
static constexpr U c = {};
|
||||
U x[2] = {};
|
||||
const U y[2] = {};
|
||||
static constexpr U z[2] = {};
|
||||
};
|
||||
template <class U>
|
||||
static void checkU(void) noexcept {
|
||||
{
|
||||
U a = {};
|
||||
const U b = {};
|
||||
constexpr U c = {};
|
||||
U x[2] = {};
|
||||
const U y[2] = {};
|
||||
constexpr U z[2] = {};
|
||||
assert_noexcept(a == 0);
|
||||
assert_noexcept(b == 0);
|
||||
assert_noexcept(c == 0);
|
||||
assert_noexcept(x[0] == 0 && x[1] == 0);
|
||||
assert_noexcept(y[0] == 0 && y[1] == 0);
|
||||
assert_noexcept(z[0] == 0 && z[1] == 0);
|
||||
}
|
||||
{
|
||||
TestU<U> t;
|
||||
assert_noexcept(t.a == 0);
|
||||
assert_noexcept(t.b == 0);
|
||||
assert_noexcept(t.c == 0);
|
||||
assert_noexcept(t.x[0] == 0 && t.x[1] == 0);
|
||||
assert_noexcept(t.y[0] == 0 && t.y[1] == 0);
|
||||
assert_noexcept(t.z[0] == 0 && t.z[1] == 0);
|
||||
}
|
||||
#if __cplusplus <= 201703L
|
||||
COMPILE_TIME_ASSERT(std::is_pod<U>::value) // std::is_pod is deprecated in C++20
|
||||
#endif
|
||||
COMPILE_TIME_ASSERT(std::is_standard_layout<U>::value)
|
||||
COMPILE_TIME_ASSERT(std::is_trivial<U>::value)
|
||||
// more checks, these are probably implied by std::is_trivial
|
||||
COMPILE_TIME_ASSERT(std::is_nothrow_default_constructible<U>::value)
|
||||
COMPILE_TIME_ASSERT(std::is_nothrow_destructible<U>::value)
|
||||
COMPILE_TIME_ASSERT(std::is_trivially_copyable<U>::value)
|
||||
COMPILE_TIME_ASSERT(std::is_trivially_default_constructible<U>::value)
|
||||
// UPX extras
|
||||
COMPILE_TIME_ASSERT(upx_is_integral<U>::value)
|
||||
COMPILE_TIME_ASSERT(upx_is_integral_v<U>)
|
||||
}
|
||||
static void check(void) noexcept {
|
||||
{
|
||||
TestT t = {};
|
||||
assert_noexcept(t.a == 0);
|
||||
assert_noexcept(t.x[0] == 0 && t.x[1] == 0);
|
||||
}
|
||||
{
|
||||
const TestT t = {};
|
||||
assert_noexcept(t.a == 0);
|
||||
assert_noexcept(t.x[0] == 0 && t.x[1] == 0);
|
||||
}
|
||||
{
|
||||
constexpr TestT t = {};
|
||||
assert_noexcept(t.a == 0);
|
||||
assert_noexcept(t.x[0] == 0 && t.x[1] == 0);
|
||||
}
|
||||
{
|
||||
TestT t;
|
||||
mem_clear(&t);
|
||||
assert_noexcept(t.a == 0);
|
||||
assert_noexcept(t.x[0] == 0 && t.x[1] == 0);
|
||||
}
|
||||
checkU<T>();
|
||||
checkU<typename std::add_const<T>::type>();
|
||||
}
|
||||
};
|
||||
template <class T>
|
||||
struct CheckAlignment {
|
||||
static void check(void) noexcept {
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(T)
|
||||
struct alignas(1) Test1 {
|
||||
char a;
|
||||
T b;
|
||||
};
|
||||
struct alignas(1) Test2 {
|
||||
char a;
|
||||
T b[3];
|
||||
};
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(Test1)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(Test2)
|
||||
Test1 t1[7];
|
||||
Test2 t2[7];
|
||||
COMPILE_TIME_ASSERT(sizeof(Test1) == 1 + sizeof(T))
|
||||
COMPILE_TIME_ASSERT(sizeof(t1) == 7 + 7 * sizeof(T))
|
||||
COMPILE_TIME_ASSERT(sizeof(Test2) == 1 + 3 * sizeof(T))
|
||||
COMPILE_TIME_ASSERT(sizeof(t2) == 7 + 21 * sizeof(T))
|
||||
UNUSED(t1);
|
||||
UNUSED(t2);
|
||||
}
|
||||
};
|
||||
template <class T>
|
||||
struct TestBELE {
|
||||
static noinline bool test(void) noexcept {
|
||||
CheckIntegral<T>::check();
|
||||
CheckAlignment<T>::check();
|
||||
// arithmetic checks
|
||||
T allbits = {};
|
||||
assert_noexcept(allbits == 0);
|
||||
allbits += 1;
|
||||
allbits -= 2;
|
||||
T v1;
|
||||
v1 = 1;
|
||||
v1 *= 4;
|
||||
v1 /= 2;
|
||||
v1 -= 1;
|
||||
T v2;
|
||||
v2 = 1;
|
||||
assert_noexcept((v1 == v2));
|
||||
assert_noexcept(!(v1 != v2));
|
||||
assert_noexcept((v1 <= v2));
|
||||
assert_noexcept((v1 >= v2));
|
||||
assert_noexcept(!(v1 < v2));
|
||||
assert_noexcept(!(v1 > v2));
|
||||
v2 ^= allbits;
|
||||
assert_noexcept(!(v1 == v2));
|
||||
assert_noexcept((v1 != v2));
|
||||
assert_noexcept((v1 <= v2));
|
||||
assert_noexcept(!(v1 >= v2));
|
||||
assert_noexcept((v1 < v2));
|
||||
assert_noexcept(!(v1 > v2));
|
||||
v2 += 2;
|
||||
assert_noexcept(v1 == 1);
|
||||
assert_noexcept(v2 == 0);
|
||||
v1 <<= 1;
|
||||
v1 |= v2;
|
||||
v1 >>= 1;
|
||||
v2 &= v1;
|
||||
v2 /= v1;
|
||||
v2 *= v1;
|
||||
v1 += v2;
|
||||
v1 -= v2;
|
||||
assert_noexcept(v1 == 1);
|
||||
assert_noexcept(v2 == 0);
|
||||
if ((v1 ^ v2) != 1)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
struct TestNoAliasingStruct {
|
||||
static noinline bool test(A *a, B *b) noexcept {
|
||||
*a = 0;
|
||||
*b = 0;
|
||||
*b -= 3;
|
||||
return *a != 0;
|
||||
}
|
||||
};
|
||||
template <class A, class B>
|
||||
static forceinline bool testNoAliasing(A *a, B *b) noexcept {
|
||||
return TestNoAliasingStruct<A, B>::test(a, b);
|
||||
}
|
||||
template <class T>
|
||||
struct TestIntegerWrap {
|
||||
static inline bool inc_gt(const T x) noexcept { return x + 1 > x; }
|
||||
static inline bool dec_lt(const T x) noexcept { return x - 1 < x; }
|
||||
static inline bool neg_eq(const T x) noexcept { return T(0) - x == x; }
|
||||
};
|
||||
|
||||
static noinline void throwSomeValue(int x) may_throw {
|
||||
if (x < 0)
|
||||
throw int(x);
|
||||
else
|
||||
throw size_t(x);
|
||||
}
|
||||
|
||||
static noinline void check_basic_cxx_exception_handling(void (*func)(int)) noexcept {
|
||||
bool cxx_exception_handling_works = false;
|
||||
try {
|
||||
func(42);
|
||||
} catch (const size_t &e) {
|
||||
if (e == 42)
|
||||
cxx_exception_handling_works = true;
|
||||
} catch (...) {
|
||||
}
|
||||
assert_noexcept(cxx_exception_handling_works);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#define ACC_WANT_ACC_CHK_CH 1
|
||||
#undef ACCCHK_ASSERT
|
||||
#include "../miniacc.h"
|
||||
|
||||
void upx_compiler_sanity_check(void) noexcept {
|
||||
const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE");
|
||||
if (!e)
|
||||
e = getenv("UPX_DEBUG_DISABLE_DOCTEST"); // allow alternate spelling
|
||||
if (e && e[0] && strcmp(e, "0") != 0) {
|
||||
// If UPX_DEBUG_DOCTEST_DISABLE is set then we don't want to throw any
|
||||
// exceptions in order to improve debugging experience.
|
||||
} else {
|
||||
// check working C++ exception handling to catch toolchain/qemu/wine/etc problems
|
||||
check_basic_cxx_exception_handling(throwSomeValue);
|
||||
}
|
||||
|
||||
#define ACC_WANT_ACC_CHK_CH 1
|
||||
#undef ACCCHK_ASSERT
|
||||
#define ACCCHK_ASSERT(expr) ACC_COMPILE_TIME_ASSERT(expr)
|
||||
#include "../miniacc.h"
|
||||
#undef ACCCHK_ASSERT
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(char) == 1)
|
||||
COMPILE_TIME_ASSERT(sizeof(short) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(int) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(long) >= 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(void *) >= 4)
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(BE16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(BE32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(BE64) == 8)
|
||||
COMPILE_TIME_ASSERT(sizeof(LE16) == 2)
|
||||
COMPILE_TIME_ASSERT(sizeof(LE32) == 4)
|
||||
COMPILE_TIME_ASSERT(sizeof(LE64) == 8)
|
||||
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(BE16)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(BE32)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(BE64)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(LE16)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(LE32)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(LE64)
|
||||
|
||||
CheckIntegral<char>::check();
|
||||
CheckIntegral<signed char>::check();
|
||||
CheckIntegral<unsigned char>::check();
|
||||
CheckIntegral<short>::check();
|
||||
CheckIntegral<int>::check();
|
||||
CheckIntegral<long>::check();
|
||||
CheckIntegral<long long>::check();
|
||||
CheckIntegral<ptrdiff_t>::check();
|
||||
CheckIntegral<size_t>::check();
|
||||
CheckIntegral<upx_off_t>::check();
|
||||
CheckIntegral<upx_uintptr_t>::check();
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(upx_charptr_unit_type) == 1)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(upx_charptr_unit_type)
|
||||
COMPILE_TIME_ASSERT(sizeof(*((charptr) nullptr)) == 1)
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_STRING4) == 4 + 1)
|
||||
assert_noexcept(strlen(UPX_VERSION_STRING4) == 4);
|
||||
COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_YEAR) == 4 + 1)
|
||||
assert_noexcept(strlen(UPX_VERSION_YEAR) == 4);
|
||||
assert_noexcept(memcmp(UPX_VERSION_DATE_ISO, UPX_VERSION_YEAR, 4) == 0);
|
||||
assert_noexcept(
|
||||
memcmp(&UPX_VERSION_DATE[sizeof(UPX_VERSION_DATE) - 1 - 4], UPX_VERSION_YEAR, 4) == 0);
|
||||
if (gitrev[0]) {
|
||||
size_t revlen = strlen(gitrev);
|
||||
if (strncmp(gitrev, "ERROR", 5) == 0) {
|
||||
assert_noexcept(revlen == 5 || revlen == 6);
|
||||
} else {
|
||||
assert_noexcept(revlen == 12 || revlen == 13);
|
||||
}
|
||||
if (revlen == 6 || revlen == 13) {
|
||||
assert_noexcept(gitrev[revlen - 1] == '+');
|
||||
}
|
||||
}
|
||||
assert_noexcept(UPX_RSIZE_MAX_MEM == 805306368);
|
||||
|
||||
#if DEBUG || 1
|
||||
assert_noexcept(TestBELE<LE16>::test());
|
||||
assert_noexcept(TestBELE<LE32>::test());
|
||||
assert_noexcept(TestBELE<LE64>::test());
|
||||
assert_noexcept(TestBELE<BE16>::test());
|
||||
assert_noexcept(TestBELE<BE32>::test());
|
||||
assert_noexcept(TestBELE<BE64>::test());
|
||||
{
|
||||
alignas(16) static const byte dd[32] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0,
|
||||
0, 0, 0, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0, 0, 0, 0, 0};
|
||||
const byte *d;
|
||||
const N_BELE_RTP::AbstractPolicy *bele;
|
||||
d = dd + 7;
|
||||
assert_noexcept(upx_adler32(d, 4) == 0x09f003f7);
|
||||
assert_noexcept(upx_adler32(d, 4, 0) == 0x09ec03f6);
|
||||
assert_noexcept(upx_adler32(d, 4, 1) == 0x09f003f7);
|
||||
bele = &N_BELE_RTP::be_policy;
|
||||
assert_noexcept(get_be16(d) == 0xfffe);
|
||||
assert_noexcept(bele->get16(d) == 0xfffe);
|
||||
assert_noexcept(get_be16_signed(d) == -2);
|
||||
assert_noexcept(get_be24(d) == 0xfffefd);
|
||||
assert_noexcept(bele->get24(d) == 0xfffefd);
|
||||
assert_noexcept(get_be24_signed(d) == -259);
|
||||
assert_noexcept(get_be32(d) == 0xfffefdfc);
|
||||
assert_noexcept(bele->get32(d) == 0xfffefdfc);
|
||||
assert_noexcept(get_be32_signed(d) == -66052);
|
||||
bele = &N_BELE_RTP::le_policy;
|
||||
assert_noexcept(get_le16(d) == 0xfeff);
|
||||
assert_noexcept(bele->get16(d) == 0xfeff);
|
||||
assert_noexcept(get_le16_signed(d) == -257);
|
||||
assert_noexcept(get_le24(d) == 0xfdfeff);
|
||||
assert_noexcept(bele->get24(d) == 0xfdfeff);
|
||||
assert_noexcept(get_le24_signed(d) == -131329);
|
||||
assert_noexcept(get_le32(d) == 0xfcfdfeff);
|
||||
assert_noexcept(bele->get32(d) == 0xfcfdfeff);
|
||||
assert_noexcept(get_le32_signed(d) == -50462977);
|
||||
assert_noexcept(get_le64_signed(d) == -506097522914230529LL);
|
||||
assert_noexcept(find_be16(d, 2, 0xfffe) == 0);
|
||||
assert_noexcept(find_le16(d, 2, 0xfeff) == 0);
|
||||
assert_noexcept(find_be32(d, 4, 0xfffefdfc) == 0);
|
||||
assert_noexcept(find_le32(d, 4, 0xfcfdfeff) == 0);
|
||||
d += 12;
|
||||
assert_noexcept(get_be16_signed(d) == 32638);
|
||||
assert_noexcept(get_be24_signed(d) == 8355453);
|
||||
assert_noexcept(get_be32_signed(d) == 2138996092);
|
||||
assert_noexcept(get_be64_signed(d) == 9186918263483431288LL);
|
||||
}
|
||||
{
|
||||
unsigned dd;
|
||||
void *const d = ⅆ
|
||||
dd = ne32_to_le32(0xf7f6f5f4);
|
||||
assert_noexcept(get_le26(d) == 0x03f6f5f4);
|
||||
set_le26(d, 0);
|
||||
assert_noexcept(get_le26(d) == 0);
|
||||
assert_noexcept(dd == ne32_to_le32(0xf4000000));
|
||||
set_le26(d, 0xff020304);
|
||||
assert_noexcept(get_le26(d) == 0x03020304);
|
||||
assert_noexcept(dd == ne32_to_le32(0xf7020304));
|
||||
}
|
||||
{
|
||||
upx_uint16_t a = 0;
|
||||
upx_uint32_t b = 0;
|
||||
upx_uint64_t c = 0;
|
||||
set_ne16(&a, 0x04030201); // ignore upper bits
|
||||
set_ne32(&b, 0x04030201);
|
||||
set_ne64(&c, 0x0807060504030201ull);
|
||||
assert_noexcept(a == 0x0201);
|
||||
assert_noexcept(b == 0x04030201);
|
||||
assert_noexcept(c == 0x0807060504030201ull);
|
||||
assert_noexcept(get_ne16(&a) == 0x0201);
|
||||
assert_noexcept(get_ne32(&b) == 0x04030201);
|
||||
assert_noexcept(get_ne64(&c) == 0x0807060504030201ull);
|
||||
}
|
||||
#endif // DEBUG
|
||||
union {
|
||||
short v_short;
|
||||
int v_int;
|
||||
long v_long;
|
||||
long long v_llong;
|
||||
BE16 b16;
|
||||
BE32 b32;
|
||||
BE64 b64;
|
||||
LE16 l16;
|
||||
LE32 l32;
|
||||
LE64 l64;
|
||||
} u;
|
||||
assert_noexcept(testNoAliasing(&u.v_short, &u.b32));
|
||||
assert_noexcept(testNoAliasing(&u.v_short, &u.l32));
|
||||
assert_noexcept(testNoAliasing(&u.v_int, &u.b64));
|
||||
assert_noexcept(testNoAliasing(&u.v_int, &u.l64));
|
||||
// check working -fno-strict-aliasing
|
||||
assert_noexcept(testNoAliasing(&u.v_short, &u.v_int));
|
||||
assert_noexcept(testNoAliasing(&u.v_int, &u.v_long));
|
||||
assert_noexcept(testNoAliasing(&u.v_int, &u.v_llong));
|
||||
assert_noexcept(testNoAliasing(&u.v_long, &u.v_llong));
|
||||
|
||||
assert_noexcept(TestIntegerWrap<unsigned>::inc_gt(0));
|
||||
assert_noexcept(!TestIntegerWrap<unsigned>::inc_gt(UINT_MAX));
|
||||
assert_noexcept(TestIntegerWrap<unsigned>::dec_lt(1));
|
||||
assert_noexcept(!TestIntegerWrap<unsigned>::dec_lt(0));
|
||||
assert_noexcept(TestIntegerWrap<unsigned>::neg_eq(0));
|
||||
assert_noexcept(!TestIntegerWrap<unsigned>::neg_eq(1));
|
||||
assert_noexcept(!TestIntegerWrap<unsigned>::neg_eq(UINT_MAX));
|
||||
// check working -fno-strict-overflow
|
||||
assert_noexcept(TestIntegerWrap<int>::inc_gt(0));
|
||||
assert_noexcept(!TestIntegerWrap<int>::inc_gt(INT_MAX));
|
||||
assert_noexcept(TestIntegerWrap<int>::dec_lt(0));
|
||||
assert_noexcept(!TestIntegerWrap<int>::dec_lt(INT_MIN));
|
||||
assert_noexcept(TestIntegerWrap<int>::neg_eq(0));
|
||||
assert_noexcept(!TestIntegerWrap<int>::neg_eq(1));
|
||||
assert_noexcept(!TestIntegerWrap<int>::neg_eq(INT_MAX));
|
||||
assert_noexcept(TestIntegerWrap<int>::neg_eq(INT_MIN)); // special case
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// some doctest test cases
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("assert_noexcept") {
|
||||
// just to make sure that our own assert() macros don't generate any warnings
|
||||
byte dummy = 0;
|
||||
byte *ptr1 = &dummy;
|
||||
const byte *const ptr2 = &dummy;
|
||||
void *ptr3 = nullptr;
|
||||
assert(true);
|
||||
assert(1);
|
||||
assert(ptr1);
|
||||
assert(ptr2);
|
||||
assert(!ptr3);
|
||||
assert_noexcept(true);
|
||||
assert_noexcept(1);
|
||||
assert_noexcept(ptr1);
|
||||
assert_noexcept(ptr2);
|
||||
assert_noexcept(!ptr3);
|
||||
}
|
||||
|
||||
TEST_CASE("acc_vget") {
|
||||
CHECK_EQ(acc_vget_int(0, 0), 0);
|
||||
CHECK_EQ(acc_vget_long(1, -1), 1);
|
||||
CHECK_EQ(acc_vget_acc_int64l_t(2, 1), 2);
|
||||
CHECK_EQ(acc_vget_acc_hvoid_p(nullptr, 0), nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("working -fno-strict-aliasing") {
|
||||
bool ok;
|
||||
long v = 0;
|
||||
short *ps = ACC_STATIC_CAST(short *, acc_vget_acc_hvoid_p(&v, 0));
|
||||
int *pi = ACC_STATIC_CAST(int *, acc_vget_acc_hvoid_p(&v, 0));
|
||||
long *pl = ACC_STATIC_CAST(long *, acc_vget_acc_hvoid_p(&v, 0));
|
||||
*ps = 0;
|
||||
*pl = -1;
|
||||
ok = *ps == -1;
|
||||
CHECK(ok);
|
||||
*pi = 0;
|
||||
*pl = -1;
|
||||
ok = *pi == -1;
|
||||
CHECK(ok);
|
||||
*pl = 0;
|
||||
*ps = -1;
|
||||
ok = *pl != 0;
|
||||
CHECK(ok);
|
||||
*pl = 0;
|
||||
*pi = -1;
|
||||
ok = *pl != 0;
|
||||
CHECK(ok);
|
||||
UNUSED(ok);
|
||||
}
|
||||
|
||||
TEST_CASE("working -fno-strict-overflow") {
|
||||
CHECK_EQ(acc_vget_int(INT_MAX, 0) + 1, INT_MIN);
|
||||
CHECK_EQ(acc_vget_int(INT_MIN, 0) - 1, INT_MAX);
|
||||
CHECK_EQ(acc_vget_long(LONG_MAX, 0) + 1, LONG_MIN);
|
||||
CHECK_EQ(acc_vget_long(LONG_MIN, 0) - 1, LONG_MAX);
|
||||
bool ok;
|
||||
int i;
|
||||
i = INT_MAX;
|
||||
i += 1;
|
||||
ok = i == INT_MIN;
|
||||
CHECK(ok);
|
||||
i = INT_MIN;
|
||||
i -= 1;
|
||||
ok = i == INT_MAX;
|
||||
CHECK(ok);
|
||||
UNUSED(ok);
|
||||
}
|
||||
|
||||
TEST_CASE("libc snprintf") {
|
||||
// runtime check that Windows/MinGW <stdio.h> works as expected
|
||||
char buf[64];
|
||||
long long ll = acc_vget_int(-1, 0);
|
||||
unsigned long long llu = (unsigned long long) ll;
|
||||
snprintf(buf, sizeof(buf), "%d.%ld.%lld.%u.%lu.%llu", -3, -2L, ll, 3U, 2LU, llu);
|
||||
CHECK_EQ(strcmp(buf, "-3.-2.-1.3.2.18446744073709551615"), 0);
|
||||
intmax_t im = ll;
|
||||
uintmax_t um = llu;
|
||||
snprintf(buf, sizeof(buf), "%d.%d.%d.%d.%d.%d.%d.%d.%d.%jd", -4, 0, 0, 0, 0, 0, 0, 0, 4, im);
|
||||
CHECK_EQ(strcmp(buf, "-4.0.0.0.0.0.0.0.4.-1"), 0);
|
||||
snprintf(buf, sizeof(buf), "%d.%d.%d.%d.%d.%d.%d.%d.%d.%ju", -5, 0, 0, 0, 0, 0, 0, 0, 5, um);
|
||||
CHECK_EQ(strcmp(buf, "-5.0.0.0.0.0.0.0.5.18446744073709551615"), 0);
|
||||
snprintf(buf, sizeof(buf), "%d.%d.%d.%d.%d.%d.%d.%d.%d.%jx", -6, 0, 0, 0, 0, 0, 0, 0, 6, um);
|
||||
CHECK_EQ(strcmp(buf, "-6.0.0.0.0.0.0.0.6.ffffffffffffffff"), 0);
|
||||
snprintf(buf, sizeof(buf), "%d.%d.%d.%d.%d.%d.%d.%d.%d.%#jx", -7, 0, 0, 0, 0, 0, 0, 0, 7, um);
|
||||
CHECK_EQ(strcmp(buf, "-7.0.0.0.0.0.0.0.7.0xffffffffffffffff"), 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST_CASE("libc qsort") {
|
||||
// runtime check that libc qsort() never compares identical objects
|
||||
// UPDATE: while only poor implementations of qsort() would actually do
|
||||
// this, it is probably allowed by the standard; so skip this test case
|
||||
struct Elem {
|
||||
upx_uint16_t id;
|
||||
upx_uint16_t value;
|
||||
static int __acc_cdecl_qsort compare(const void *aa, const void *bb) noexcept {
|
||||
const Elem *a = (const Elem *) aa;
|
||||
const Elem *b = (const Elem *) bb;
|
||||
assert_noexcept(a->id != b->id); // check not IDENTICAL
|
||||
return a->value < b->value ? -1 : (a->value == b->value ? 0 : 1);
|
||||
}
|
||||
static bool check_sort(upx_sort_func_t sort, Elem *e, size_t n) {
|
||||
upx_uint32_t x = 5381 + n + ((upx_uintptr_t) e & 0xff);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
e[i].id = (upx_uint16_t) i;
|
||||
x = x * 33 + 1 + (i & 255);
|
||||
e[i].value = (upx_uint16_t) x;
|
||||
}
|
||||
sort(e, n, sizeof(Elem), Elem::compare);
|
||||
for (size_t i = 1; i < n; i++)
|
||||
if very_unlikely (e[i - 1].value > e[i].value)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
constexpr size_t N = 4096;
|
||||
Elem e[N];
|
||||
for (size_t n = 0; n <= N; n = 2 * n + 1) {
|
||||
// CHECK(Elem::check_sort(qsort, e, n)); // libc qsort()
|
||||
CHECK(Elem::check_sort(upx_gnomesort, e, n));
|
||||
CHECK(Elem::check_sort(upx_shellsort_memswap, e, n));
|
||||
CHECK(Elem::check_sort(upx_shellsort_memcpy, e, n));
|
||||
#if UPX_CONFIG_USE_STABLE_SORT
|
||||
upx_sort_func_t wrap_stable_sort = [](void *aa, size_t nn, size_t, upx_compare_func_t cc) {
|
||||
upx_std_stable_sort<sizeof(Elem)>(aa, nn, cc);
|
||||
};
|
||||
CHECK(Elem::check_sort(wrap_stable_sort, e, n));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -0,0 +1,283 @@
|
||||
/* dt_cxxlib.cpp -- doctest check
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
// lots of tests (and probably quite a number of redundant tests)
|
||||
// modern compilers will optimize away much of this code
|
||||
|
||||
#include "../conf.h"
|
||||
|
||||
/*************************************************************************
|
||||
// compile-time checks
|
||||
**************************************************************************/
|
||||
|
||||
// need extra parenthesis because the C preprocessor does not understand C++ templates
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_all_v<int>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_all_v<int, int>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_all_v<int, int, int>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_all_v<int, char>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_all_v<int, char, int>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_all_v<int, int, char>) )
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_any_v<int, int>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_any_v<int, char, int>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_any_v<int, int, char>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char, char>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char, long>) )
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(int) == sizeof(int))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof('a') == sizeof(char))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("") == 1)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("a") == 2)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0) == sizeof(int))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0L) == sizeof(long))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0LL) == sizeof(long long))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(nullptr) == sizeof(void *))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(sizeof(0)) == sizeof(size_t))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(usizeof(0)) == sizeof(unsigned))
|
||||
|
||||
namespace compile_time = upx::compile_time;
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("") == 0)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("a") == 1)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("ab") == 2)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("abc") == 3)
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_eq("", ""))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("a", ""))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("", "a"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_eq("abc", "abc"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("ab", "abc"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("abc", "ab"))
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("", ""))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("a", ""))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_lt("", "a"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("abc", "abc"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_lt("ab", "abc"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("abc", "ab"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("abc", "aba"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_lt("abc", "abz"))
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_ne("abc", "abz"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_gt("abc", "abz"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_ge("abc", "abz"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_le("abc", "abz"))
|
||||
|
||||
/*************************************************************************
|
||||
// util
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("ptr_reinterpret_cast") {
|
||||
// check that we don't trigger any -Wcast-align warnings
|
||||
using upx::ptr_reinterpret_cast;
|
||||
void *vp = nullptr;
|
||||
byte *bp = nullptr;
|
||||
int *ip = nullptr;
|
||||
double *dp = nullptr;
|
||||
|
||||
assert((vp == ptr_reinterpret_cast<void *>(vp)));
|
||||
assert((vp == ptr_reinterpret_cast<void *>(bp)));
|
||||
assert((vp == ptr_reinterpret_cast<void *>(ip)));
|
||||
assert((vp == ptr_reinterpret_cast<void *>(dp)));
|
||||
|
||||
assert((bp == ptr_reinterpret_cast<byte *>(vp)));
|
||||
assert((bp == ptr_reinterpret_cast<byte *>(bp)));
|
||||
assert((bp == ptr_reinterpret_cast<byte *>(ip)));
|
||||
assert((bp == ptr_reinterpret_cast<byte *>(dp)));
|
||||
|
||||
assert((ip == ptr_reinterpret_cast<int *>(vp)));
|
||||
assert((ip == ptr_reinterpret_cast<int *>(bp)));
|
||||
assert((ip == ptr_reinterpret_cast<int *>(ip)));
|
||||
assert((ip == ptr_reinterpret_cast<int *>(dp)));
|
||||
|
||||
assert((dp == ptr_reinterpret_cast<double *>(vp)));
|
||||
assert((dp == ptr_reinterpret_cast<double *>(bp)));
|
||||
assert((dp == ptr_reinterpret_cast<double *>(ip)));
|
||||
assert((dp == ptr_reinterpret_cast<double *>(dp)));
|
||||
|
||||
const byte *bc = nullptr;
|
||||
const int *ic = nullptr;
|
||||
assert((bc == ptr_reinterpret_cast<byte *>(bp)));
|
||||
assert((bc == ptr_reinterpret_cast<const byte *>(bc)));
|
||||
assert((bc == ptr_reinterpret_cast<byte *>(ip)));
|
||||
assert((bc == ptr_reinterpret_cast<const byte *>(ic)));
|
||||
assert((ic == ptr_reinterpret_cast<int *>(bp)));
|
||||
assert((ic == ptr_reinterpret_cast<const int *>(bc)));
|
||||
assert((ic == ptr_reinterpret_cast<int *>(ip)));
|
||||
assert((ic == ptr_reinterpret_cast<const int *>(ic)));
|
||||
}
|
||||
|
||||
TEST_CASE("noncopyable") {
|
||||
struct Test : private upx::noncopyable {
|
||||
int v = 1;
|
||||
};
|
||||
Test t = {};
|
||||
CHECK(t.v == 1);
|
||||
#if (ACC_CC_MSC) // MSVC thinks that Test is not std::is_trivially_copyable; true or compiler bug?
|
||||
// @COMPILER_BUG @MSVC_BUG
|
||||
t.v = 0;
|
||||
#else
|
||||
mem_clear(&t);
|
||||
#endif
|
||||
CHECK(t.v == 0);
|
||||
constexpr Test x = {};
|
||||
static_assert(x.v == 1);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// TriBool checks
|
||||
**************************************************************************/
|
||||
|
||||
namespace {
|
||||
template <class T>
|
||||
struct TestTriBool {
|
||||
static void test(bool expect_true) {
|
||||
static_assert(std::is_class<T>::value);
|
||||
static_assert(std::is_nothrow_default_constructible<T>::value);
|
||||
static_assert(std::is_nothrow_destructible<T>::value);
|
||||
static_assert(std::is_standard_layout<T>::value);
|
||||
static_assert(std::is_trivially_copyable<T>::value);
|
||||
static_assert(sizeof(typename T::value_type) == sizeof(typename T::underlying_type));
|
||||
static_assert(alignof(typename T::value_type) == alignof(typename T::underlying_type));
|
||||
#if (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__)
|
||||
// broken compiler or broken ABI
|
||||
#else
|
||||
static_assert(sizeof(T) == sizeof(typename T::underlying_type));
|
||||
static_assert(alignof(T) == alignof(typename T::underlying_type));
|
||||
#endif
|
||||
static_assert(!bool(T(false)));
|
||||
static_assert(bool(T(true)));
|
||||
static_assert(bool(T(T::Third)) == T::is_third_true);
|
||||
static_assert(T(false) == T::False);
|
||||
static_assert(T(true) == T::True);
|
||||
static_assert(T(T::False) == T::False);
|
||||
static_assert(T(T::True) == T::True);
|
||||
static_assert(T(T::Third) == T::Third);
|
||||
static_assert(T(T::Third) == T(9));
|
||||
static_assert(T(8) == T(9));
|
||||
static_assert(!(T(0) == T(9)));
|
||||
static_assert(!(T(1) == T(9)));
|
||||
static_assert(T(T::Third) == 9);
|
||||
static_assert(T(8) == 9);
|
||||
static_assert(!(T(0) == 9));
|
||||
static_assert(!(T(1) == 9));
|
||||
constexpr T array[] = {false, true, T::Third};
|
||||
static_assert(array[0].isStrictFalse());
|
||||
static_assert(array[1].isStrictTrue());
|
||||
static_assert(array[2].isThird());
|
||||
static_assert(sizeof(array) == 3 * sizeof(T));
|
||||
T a;
|
||||
assert(a.getValue() == T::False);
|
||||
assert(!a);
|
||||
assert(!bool(a));
|
||||
assert((!a ? true : false));
|
||||
assert(a.isStrictFalse());
|
||||
assert(!a.isStrictTrue());
|
||||
assert(a.isStrictBool());
|
||||
assert(!a.isThird());
|
||||
a = false;
|
||||
assert(a.getValue() == T::False);
|
||||
assert(!a);
|
||||
assert(!bool(a));
|
||||
assert((!a ? true : false));
|
||||
assert(a.isStrictFalse());
|
||||
assert(!a.isStrictTrue());
|
||||
assert(a.isStrictBool());
|
||||
assert(!a.isThird());
|
||||
a = true;
|
||||
assert(a.getValue() == T::True);
|
||||
assert(a);
|
||||
assert(bool(a));
|
||||
assert((a ? true : false));
|
||||
assert(!a.isStrictFalse());
|
||||
assert(a.isStrictTrue());
|
||||
assert(a.isStrictBool());
|
||||
assert(!a.isThird());
|
||||
a = T::Third;
|
||||
assert(a.getValue() == T::Third);
|
||||
assert(T::is_third_true == expect_true);
|
||||
if (expect_true) {
|
||||
assert(a);
|
||||
assert(bool(a));
|
||||
assert((a ? true : false));
|
||||
} else {
|
||||
assert(!a);
|
||||
assert(!bool(a));
|
||||
assert((!a ? true : false));
|
||||
}
|
||||
assert(!a.isStrictFalse());
|
||||
assert(!a.isStrictTrue());
|
||||
assert(!a.isStrictBool());
|
||||
assert(a.isThird());
|
||||
a = 99;
|
||||
assert(a.getValue() == T::Third);
|
||||
if (expect_true) {
|
||||
assert(a);
|
||||
assert(bool(a));
|
||||
assert((a ? true : false));
|
||||
} else {
|
||||
assert(!a);
|
||||
assert(!bool(a));
|
||||
assert((!a ? true : false));
|
||||
}
|
||||
assert(!a.isStrictFalse());
|
||||
assert(!a.isStrictTrue());
|
||||
assert(!a.isStrictBool());
|
||||
assert(a.isThird());
|
||||
mem_clear(&a);
|
||||
assert(a.isStrictFalse());
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("TriBool") {
|
||||
using upx::TriBool, upx::tribool;
|
||||
static_assert(!tribool(false));
|
||||
static_assert(tribool(true));
|
||||
static_assert(!tribool(tribool::Third));
|
||||
TestTriBool<tribool>::test(false);
|
||||
#if DEBUG || 1
|
||||
TestTriBool<TriBool<upx_int8_t> >::test(false);
|
||||
TestTriBool<TriBool<upx_uint8_t> >::test(false);
|
||||
TestTriBool<TriBool<upx_int16_t> >::test(false);
|
||||
TestTriBool<TriBool<upx_uint16_t> >::test(false);
|
||||
TestTriBool<TriBool<upx_int32_t> >::test(false);
|
||||
TestTriBool<TriBool<upx_uint32_t> >::test(false);
|
||||
TestTriBool<TriBool<upx_int64_t> >::test(false);
|
||||
TestTriBool<TriBool<upx_uint64_t> >::test(false);
|
||||
TestTriBool<TriBool<upx_int8_t, true> >::test(true);
|
||||
TestTriBool<TriBool<upx_uint8_t, true> >::test(true);
|
||||
TestTriBool<TriBool<upx_int16_t, true> >::test(true);
|
||||
TestTriBool<TriBool<upx_uint16_t, true> >::test(true);
|
||||
TestTriBool<TriBool<upx_int32_t, true> >::test(true);
|
||||
TestTriBool<TriBool<upx_uint32_t, true> >::test(true);
|
||||
TestTriBool<TriBool<upx_int64_t, true> >::test(true);
|
||||
TestTriBool<TriBool<upx_uint64_t, true> >::test(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -0,0 +1,59 @@
|
||||
/* dt_impl.cpp -- doctest support code implementation
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
/*************************************************************************
|
||||
// doctest support code implementation
|
||||
**************************************************************************/
|
||||
|
||||
#define DOCTEST_CONFIG_IMPLEMENT
|
||||
#define DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
|
||||
|
||||
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||
|
||||
#if defined(__i386__) && defined(__MSDOS__) && defined(__DJGPP__) && defined(__GNUC__)
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_NO_POSIX_SIGNALS
|
||||
#elif defined(__m68k__) && defined(__atarist__) && defined(__GNUC__)
|
||||
#define DOCTEST_CONFIG_COLORS_NONE
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_NO_POSIX_SIGNALS
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#endif
|
||||
|
||||
#if !defined(UPX_DOCTEST_CONFIG_MULTITHREADING)
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__FAST_MATH__) && defined(__INTEL_LLVM_COMPILER)
|
||||
// warning: comparison with NaN always evaluates to false in fast floating point modes
|
||||
#pragma clang diagnostic ignored "-Wtautological-constant-compare"
|
||||
#endif
|
||||
|
||||
#include <doctest/doctest/parts/doctest.cpp>
|
||||
|
||||
#endif // DOCTEST_CONFIG_DISABLE
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -0,0 +1,978 @@
|
||||
/* xspan -- a minimally invasive checked memory smart pointer
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
// lots of tests (and probably quite a number of redundant tests)
|
||||
|
||||
#include "../conf.h"
|
||||
|
||||
/*************************************************************************
|
||||
// raw_bytes
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("raw_bytes ptr") {
|
||||
upx_uint16_t *ptr = nullptr;
|
||||
CHECK_NOTHROW(raw_bytes(ptr, 0));
|
||||
CHECK_THROWS(raw_bytes(ptr, 1));
|
||||
CHECK_THROWS(raw_index_bytes(ptr, 0, 0));
|
||||
CHECK_THROWS(raw_index_bytes(ptr, 1, 0));
|
||||
CHECK_THROWS(raw_index_bytes(ptr, 0, 1));
|
||||
upx_uint16_t buf[4];
|
||||
ptr = buf;
|
||||
CHECK(ptr_udiff_bytes(raw_index_bytes(ptr, 1, 1), ptr) == 2u);
|
||||
CHECK(ptr_udiff_bytes(raw_index_bytes(ptr, 4, 0), ptr) == 8u);
|
||||
UNUSED(ptr);
|
||||
}
|
||||
|
||||
TEST_CASE("raw_bytes bounded array") {
|
||||
upx_uint16_t buf[4];
|
||||
CHECK_NOTHROW(raw_bytes(buf, 8));
|
||||
CHECK_THROWS(raw_bytes(buf, 9));
|
||||
CHECK_NOTHROW(raw_index_bytes(buf, 4, 0));
|
||||
CHECK_THROWS(raw_index_bytes(buf, 4, 1));
|
||||
CHECK_NOTHROW(raw_index_bytes(buf, 3, 2));
|
||||
CHECK_THROWS(raw_index_bytes(buf, 3, 3));
|
||||
CHECK(ptr_udiff_bytes(raw_index_bytes(buf, 1, 1), buf) == 2u);
|
||||
CHECK(ptr_udiff_bytes(raw_index_bytes(buf, 4, 0), buf) == 8u);
|
||||
UNUSED(buf);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// basic xspan
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("basic xspan usage") {
|
||||
alignas(4) char buf[4] = {0, 1, 2, 3};
|
||||
|
||||
SUBCASE("XSPAN_x") {
|
||||
XSPAN_0(char) a0 = nullptr;
|
||||
|
||||
XSPAN_0(char) b0 = buf;
|
||||
XSPAN_P(char) bp = buf;
|
||||
|
||||
XSPAN_0(char) c0 = XSPAN_0_MAKE(char, buf);
|
||||
XSPAN_P(char) cp = XSPAN_P_MAKE(char, buf);
|
||||
XSPAN_S(char) cs = XSPAN_S_MAKE(char, buf, sizeof(buf));
|
||||
|
||||
XSPAN_0(const char) const x0 = XSPAN_0_MAKE(const char, buf);
|
||||
XSPAN_P(const char) const xp = XSPAN_P_MAKE(const char, buf);
|
||||
XSPAN_S(const char) const xs = XSPAN_S_MAKE(const char, buf, sizeof(buf));
|
||||
XSPAN_P(const char) const yp = xs;
|
||||
XSPAN_0(const char) const z0p = yp;
|
||||
XSPAN_0(const char) const z0s = xs;
|
||||
|
||||
CHECK((a0 == nullptr));
|
||||
CHECK(c0 == b0);
|
||||
CHECK(cp == bp);
|
||||
CHECK(cs == bp);
|
||||
CHECK(x0 == z0p);
|
||||
CHECK(xp == z0s);
|
||||
|
||||
CHECK_NOTHROW(raw_bytes(a0, 0));
|
||||
CHECK_THROWS(raw_bytes(a0, 1));
|
||||
CHECK_THROWS(raw_index_bytes(a0, 0, 0));
|
||||
|
||||
CHECK(raw_bytes(b0, 0) == buf);
|
||||
CHECK(raw_bytes(bp, 0) == buf);
|
||||
// info: these will fail if we ever add an overload for bounded-arrays
|
||||
#if WITH_XSPAN >= 2
|
||||
CHECK(b0.raw_size_in_bytes() == 0u);
|
||||
CHECK(bp.raw_size_in_bytes() == 0u);
|
||||
#endif
|
||||
CHECK(raw_bytes(b0, 999999) == buf);
|
||||
CHECK(raw_bytes(bp, 999999) == buf);
|
||||
|
||||
CHECK(raw_bytes(c0, 4) == buf);
|
||||
CHECK(raw_index_bytes(c0, 1, 3) == buf + 1);
|
||||
CHECK(raw_bytes(cp, 4) == buf);
|
||||
CHECK(raw_index_bytes(cp, 1, 3) == buf + 1);
|
||||
CHECK(raw_bytes(cs, 4) == buf);
|
||||
CHECK(raw_index_bytes(cs, 1, 3) == buf + 1);
|
||||
#if WITH_XSPAN >= 2
|
||||
CHECK_THROWS(raw_bytes(cs, 5));
|
||||
CHECK_THROWS(raw_index_bytes(cs, 1, 4));
|
||||
#endif
|
||||
|
||||
XSPAN_0(upx_uint16_t) c0_2 = XSPAN_TYPE_CAST(upx_uint16_t, c0 + 2);
|
||||
XSPAN_P(upx_uint16_t) cp_2 = XSPAN_TYPE_CAST(upx_uint16_t, cp + 2);
|
||||
XSPAN_S(upx_uint16_t) cs_2 = XSPAN_TYPE_CAST(upx_uint16_t, cs + 2);
|
||||
CHECK(ptr_udiff_bytes(c0_2, c0) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cp_2, c0) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cs_2, c0) == 2u);
|
||||
CHECK(ptr_udiff_bytes(c0_2, cp) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cp_2, cp) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cs_2, cp) == 2u);
|
||||
CHECK(ptr_udiff_bytes(c0_2, cs) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cp_2, cs) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cs_2, cs) == 2u);
|
||||
XSPAN_0(upx_uint16_t) c0_2b = XSPAN_TYPE_CAST(upx_uint16_t, c0) + 1;
|
||||
XSPAN_P(upx_uint16_t) cp_2b = XSPAN_TYPE_CAST(upx_uint16_t, cp) + 1;
|
||||
XSPAN_S(upx_uint16_t) cs_2b = XSPAN_TYPE_CAST(upx_uint16_t, cs) + 1;
|
||||
CHECK(c0_2 == c0_2b);
|
||||
CHECK(cp_2 == cp_2b);
|
||||
CHECK(cs_2 == cs_2b);
|
||||
|
||||
CHECK(sizeof(*c0) == 1u);
|
||||
CHECK(sizeof(*c0_2) == 2u);
|
||||
}
|
||||
|
||||
SUBCASE("XSPAN_x_VAR") {
|
||||
XSPAN_0_VAR(char, b0, buf);
|
||||
XSPAN_P_VAR(char, bp, buf);
|
||||
|
||||
XSPAN_0_VAR(char, c0, buf, sizeof(buf));
|
||||
XSPAN_P_VAR(char, cp, buf, sizeof(buf));
|
||||
XSPAN_S_VAR(char, cs, buf, sizeof(buf));
|
||||
|
||||
XSPAN_0_VAR(char, d0, buf + 1, sizeof(buf), buf);
|
||||
XSPAN_P_VAR(char, dp, buf + 1, sizeof(buf), buf);
|
||||
XSPAN_S_VAR(char, ds, buf + 1, sizeof(buf), buf);
|
||||
|
||||
XSPAN_0_VAR(const char, const x0, buf, sizeof(buf));
|
||||
XSPAN_P_VAR(const char, const xp, buf, sizeof(buf));
|
||||
XSPAN_S_VAR(const char, const xs, buf, sizeof(buf));
|
||||
XSPAN_P_VAR(const char, const yp, xs);
|
||||
XSPAN_0_VAR(const char, const z0p, yp);
|
||||
XSPAN_0_VAR(const char, const z0s, xs);
|
||||
|
||||
CHECK(c0 == b0);
|
||||
CHECK(cp == bp);
|
||||
CHECK(cs == bp);
|
||||
CHECK(d0 == dp);
|
||||
CHECK(d0 == ds);
|
||||
CHECK(x0 == z0p);
|
||||
CHECK(xp == z0s);
|
||||
|
||||
#if WITH_XSPAN >= 1 || __cplusplus >= 201103L
|
||||
XSPAN_0_VAR(char, a0, nullptr);
|
||||
CHECK((a0 == nullptr));
|
||||
CHECK_NOTHROW(raw_bytes(a0, 0));
|
||||
CHECK_THROWS(raw_bytes(a0, 1));
|
||||
CHECK_THROWS(raw_index_bytes(a0, 0, 0));
|
||||
#endif
|
||||
|
||||
CHECK(raw_bytes(b0, 0) == buf);
|
||||
CHECK(raw_bytes(bp, 0) == buf);
|
||||
// info: these will fail if we ever add an overload for bounded-arrays
|
||||
#if WITH_XSPAN >= 2
|
||||
CHECK(b0.raw_size_in_bytes() == 0u);
|
||||
CHECK(bp.raw_size_in_bytes() == 0u);
|
||||
#endif
|
||||
CHECK(raw_bytes(b0, 999999) == buf);
|
||||
CHECK(raw_bytes(bp, 999999) == buf);
|
||||
|
||||
CHECK(raw_bytes(c0, 4) == buf);
|
||||
CHECK(raw_index_bytes(c0, 1, 3) == buf + 1);
|
||||
CHECK(raw_bytes(cp, 4) == buf);
|
||||
CHECK(raw_index_bytes(cp, 1, 3) == buf + 1);
|
||||
CHECK(raw_bytes(cs, 4) == buf);
|
||||
CHECK(raw_index_bytes(cs, 1, 3) == buf + 1);
|
||||
#if WITH_XSPAN >= 2
|
||||
CHECK_THROWS(raw_bytes(cs, 5));
|
||||
CHECK_THROWS(raw_index_bytes(cs, 1, 4));
|
||||
#endif
|
||||
|
||||
XSPAN_0_VAR(upx_uint16_t, c0_2, XSPAN_TYPE_CAST(upx_uint16_t, c0 + 2));
|
||||
XSPAN_P_VAR(upx_uint16_t, cp_2, XSPAN_TYPE_CAST(upx_uint16_t, cp + 2));
|
||||
XSPAN_S_VAR(upx_uint16_t, cs_2, XSPAN_TYPE_CAST(upx_uint16_t, cs + 2));
|
||||
CHECK(ptr_udiff_bytes(c0_2, c0) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cp_2, c0) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cs_2, c0) == 2u);
|
||||
CHECK(ptr_udiff_bytes(c0_2, cp) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cp_2, cp) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cs_2, cp) == 2u);
|
||||
CHECK(ptr_udiff_bytes(c0_2, cs) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cp_2, cs) == 2u);
|
||||
CHECK(ptr_udiff_bytes(cs_2, cs) == 2u);
|
||||
XSPAN_0_VAR(upx_uint16_t, c0_2b, XSPAN_TYPE_CAST(upx_uint16_t, c0) + 1);
|
||||
XSPAN_P_VAR(upx_uint16_t, cp_2b, XSPAN_TYPE_CAST(upx_uint16_t, cp) + 1);
|
||||
XSPAN_S_VAR(upx_uint16_t, cs_2b, XSPAN_TYPE_CAST(upx_uint16_t, cs) + 1);
|
||||
CHECK(c0_2 == c0_2b);
|
||||
CHECK(cp_2 == cp_2b);
|
||||
CHECK(cs_2 == cs_2b);
|
||||
|
||||
CHECK(sizeof(*c0) == 1u);
|
||||
CHECK(sizeof(*c0_2) == 2u);
|
||||
}
|
||||
|
||||
SUBCASE("xspan in class") {
|
||||
struct MyType {
|
||||
XSPAN_0(char) s0;
|
||||
XSPAN_P(char) sp;
|
||||
XSPAN_S(char) ss;
|
||||
#if __cplusplus >= 201103L
|
||||
XSPAN_0(char) x0 = nullptr;
|
||||
#endif
|
||||
#if WITH_XSPAN >= 2
|
||||
// much nicer syntax when using fully checked xspan:
|
||||
MyType(char *b, size_t n, bool) : s0(b, n), sp(b, n), ss(b, n) {}
|
||||
#endif
|
||||
MyType(char *b, size_t n)
|
||||
: s0(XSPAN_0_MAKE(char, b, n)), sp(XSPAN_P_MAKE(char, b, n)),
|
||||
ss(XSPAN_S_MAKE(char, b, n)) {
|
||||
UNUSED(n);
|
||||
}
|
||||
};
|
||||
MyType x(buf, sizeof(buf));
|
||||
MyType y = MyType(buf, sizeof(buf));
|
||||
CHECK(x.s0 == y.sp);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
#if (WITH_XSPAN >= 2) && DEBUG
|
||||
|
||||
TEST_CASE("PtrOrSpanOrNull") {
|
||||
char real_buf[2 + 6 + 2] = {126, 127, 0, 1, 2, 3, 4, 5, 124, 125};
|
||||
char *base_buf = real_buf + 2;
|
||||
char *const my_null = nullptr;
|
||||
typedef PtrOrSpanOrNull<char> Span0;
|
||||
|
||||
// basic nullptr
|
||||
CHECK_NOTHROW(Span0(base_buf, 4, base_buf) = my_null);
|
||||
CHECK_NOTHROW(Span0(base_buf, 4, base_buf).assign(my_null));
|
||||
// basic range checking
|
||||
CHECK_NOTHROW(Span0(base_buf, 4, base_buf));
|
||||
CHECK_NOTHROW(Span0(base_buf, 0, base_buf));
|
||||
CHECK_NOTHROW(Span0(base_buf, 0, base_buf) - 0);
|
||||
CHECK_THROWS(Span0(base_buf, 0, base_buf) + 1);
|
||||
CHECK_THROWS(Span0(base_buf, 0, base_buf) - 1);
|
||||
CHECK_NOTHROW(Span0(base_buf, 4, base_buf) + 4);
|
||||
CHECK_THROWS(Span0(base_buf, 4, base_buf) + 5);
|
||||
CHECK_THROWS(Span0(base_buf - 1, 4, base_buf));
|
||||
CHECK_THROWS(Span0(base_buf + 1, 0, base_buf));
|
||||
// basic same base
|
||||
CHECK_NOTHROW(Span0(base_buf, 4, base_buf) = Span0(base_buf + 1, 3, base_buf));
|
||||
CHECK_NOTHROW(Span0(base_buf, 4, base_buf) = Span0(base_buf + 1, 1, base_buf));
|
||||
CHECK_NOTHROW(Span0(base_buf, 4, base_buf) = Span0(base_buf + 1, 5, base_buf));
|
||||
CHECK_THROWS(Span0(base_buf, 4, base_buf) = Span0(base_buf + 1, 3, base_buf + 1));
|
||||
|
||||
Span0 a1(nullptr);
|
||||
assert(a1 == nullptr);
|
||||
assert(a1.raw_ptr() == nullptr);
|
||||
assert(a1.raw_base() == nullptr);
|
||||
assert(a1.raw_size_in_bytes() == 0u);
|
||||
CHECK_THROWS(*a1);
|
||||
CHECK_THROWS(a1[0]);
|
||||
|
||||
Span0 a2 = nullptr;
|
||||
assert(a2 == nullptr);
|
||||
assert(a2.raw_ptr() == nullptr);
|
||||
assert(a2.raw_base() == nullptr);
|
||||
assert(a2.raw_size_in_bytes() == 0u);
|
||||
CHECK_THROWS(*a2);
|
||||
CHECK_THROWS(a2[0]);
|
||||
|
||||
Span0 base0(nullptr, 4, base_buf);
|
||||
assert(base0.raw_ptr() == nullptr);
|
||||
assert(base0.raw_base() == base_buf);
|
||||
assert(base0.raw_size_in_bytes() == 4u);
|
||||
CHECK_THROWS(*base0); // nullptr
|
||||
CHECK_THROWS(base0[0]); // nullptr
|
||||
CHECK_THROWS(base0 + 1); // nullptr
|
||||
|
||||
Span0 base4(base_buf, 4);
|
||||
assert(base4.raw_ptr() == base_buf);
|
||||
assert(base4.raw_base() == base_buf);
|
||||
assert(base4.raw_size_in_bytes() == 4u);
|
||||
|
||||
a1 = base_buf;
|
||||
a1 = base0;
|
||||
assert(a1 == nullptr);
|
||||
assert(a1.raw_ptr() == nullptr);
|
||||
assert(a1.raw_base() == base_buf);
|
||||
assert(a1.raw_size_in_bytes() == 4u);
|
||||
a1 = base4;
|
||||
assert(a1 == base_buf);
|
||||
assert(a1.raw_ptr() == base_buf);
|
||||
assert(a1.raw_base() == base_buf);
|
||||
assert(a1.raw_size_in_bytes() == 4u);
|
||||
|
||||
a1 = base_buf;
|
||||
assert(a1 != nullptr);
|
||||
a1 = base_buf + 1;
|
||||
CHECK(*a1++ == 1);
|
||||
CHECK(*++a1 == 3);
|
||||
CHECK(*a1 == 3);
|
||||
a1 = base_buf + 4; // at the end of buffer
|
||||
CHECK_THROWS(*a1);
|
||||
CHECK_THROWS(a1 = base_buf + 5); // range error
|
||||
assert(a1 == base_buf + 4);
|
||||
CHECK(a1[-4] == 0);
|
||||
CHECK_THROWS(a1[-5]); // range error
|
||||
a1 = base_buf;
|
||||
CHECK(*a1 == 0);
|
||||
|
||||
Span0 new_base4(base_buf + 2, 4);
|
||||
CHECK_THROWS(a1 = new_base4); // not same base
|
||||
a2 = new_base4;
|
||||
CHECK_THROWS(a2 = base4); // not same base
|
||||
|
||||
Span0 s0_no_base(nullptr);
|
||||
Span0 s0_with_base(nullptr, 4, base_buf);
|
||||
s0_no_base = nullptr;
|
||||
s0_with_base = nullptr;
|
||||
s0_with_base = s0_no_base;
|
||||
assert(s0_no_base.raw_base() == nullptr);
|
||||
assert(s0_with_base.raw_base() == base_buf);
|
||||
s0_no_base = s0_with_base;
|
||||
assert(s0_no_base.raw_base() == base_buf);
|
||||
assert(s0_no_base.raw_ptr() == nullptr);
|
||||
assert(s0_with_base.raw_ptr() == nullptr);
|
||||
s0_no_base = my_null;
|
||||
s0_with_base = my_null;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("PtrOrSpan") {
|
||||
char real_buf[2 + 6 + 2] = {126, 127, 0, 1, 2, 3, 4, 5, 124, 125};
|
||||
char *base_buf = real_buf + 2;
|
||||
char *const my_null = nullptr;
|
||||
typedef PtrOrSpan<char> SpanP;
|
||||
|
||||
// basic nullptr
|
||||
CHECK_THROWS(SpanP(base_buf, 4, base_buf) = my_null);
|
||||
CHECK_THROWS(SpanP(base_buf, 4, base_buf).assign(my_null));
|
||||
// basic range checking
|
||||
CHECK_NOTHROW(SpanP(base_buf, 4, base_buf));
|
||||
CHECK_NOTHROW(SpanP(base_buf, 0, base_buf));
|
||||
CHECK_NOTHROW(SpanP(base_buf, 0, base_buf) - 0);
|
||||
CHECK_THROWS(SpanP(base_buf, 0, base_buf) + 1);
|
||||
CHECK_THROWS(SpanP(base_buf, 0, base_buf) - 1);
|
||||
CHECK_NOTHROW(SpanP(base_buf, 4, base_buf) + 4);
|
||||
CHECK_THROWS(SpanP(base_buf, 4, base_buf) + 5);
|
||||
CHECK_THROWS(SpanP(base_buf - 1, 4, base_buf));
|
||||
CHECK_THROWS(SpanP(base_buf + 1, 0, base_buf));
|
||||
// basic same base
|
||||
CHECK_NOTHROW(SpanP(base_buf, 4, base_buf) = SpanP(base_buf + 1, 3, base_buf));
|
||||
CHECK_NOTHROW(SpanP(base_buf, 4, base_buf) = SpanP(base_buf + 1, 1, base_buf));
|
||||
CHECK_NOTHROW(SpanP(base_buf, 4, base_buf) = SpanP(base_buf + 1, 5, base_buf));
|
||||
CHECK_THROWS(SpanP(base_buf, 4, base_buf) = SpanP(base_buf + 1, 3, base_buf + 1));
|
||||
|
||||
SpanP x1(base_buf, 0);
|
||||
assert(x1 != nullptr);
|
||||
assert(x1.raw_ptr() == base_buf);
|
||||
assert(x1.raw_base() == base_buf);
|
||||
assert(x1.raw_size_in_bytes() == 0u);
|
||||
CHECK_THROWS(*x1);
|
||||
CHECK_THROWS(x1[0]);
|
||||
|
||||
SpanP a2 = base_buf;
|
||||
assert(a2 != nullptr);
|
||||
assert(a2.raw_ptr() == base_buf);
|
||||
assert(a2.raw_base() == nullptr);
|
||||
assert(a2.raw_size_in_bytes() == 0u);
|
||||
CHECK(*a2 == 0);
|
||||
CHECK(a2[1] == 1);
|
||||
|
||||
SpanP base0(base_buf, 4, base_buf);
|
||||
assert(base0.raw_ptr() == base_buf);
|
||||
assert(base0.raw_base() == base_buf);
|
||||
assert(base0.raw_size_in_bytes() == 4u);
|
||||
|
||||
SpanP base4(base_buf, 4);
|
||||
assert(base4.raw_ptr() == base_buf);
|
||||
assert(base4.raw_base() == base_buf);
|
||||
assert(base4.raw_size_in_bytes() == 4u);
|
||||
|
||||
SpanP a1(base_buf, 4);
|
||||
a1 = base_buf;
|
||||
a1 = base0;
|
||||
assert(a1 == base0);
|
||||
assert(a1 != nullptr);
|
||||
assert(a1.raw_ptr() == base0.raw_ptr());
|
||||
assert(a1.raw_base() == base_buf);
|
||||
assert(a1.raw_size_in_bytes() == 4u);
|
||||
a1 = base4;
|
||||
assert(a1 == base_buf);
|
||||
assert(a1.raw_ptr() == base_buf);
|
||||
assert(a1.raw_base() == base_buf);
|
||||
assert(a1.raw_size_in_bytes() == 4u);
|
||||
|
||||
a1 = base_buf;
|
||||
a1 = base_buf + 1;
|
||||
CHECK(*a1++ == 1);
|
||||
CHECK(*++a1 == 3);
|
||||
CHECK(*a1 == 3);
|
||||
a1 = base_buf + 4; // at the end of buffer
|
||||
CHECK_THROWS(*a1);
|
||||
CHECK_THROWS(a1 = base_buf + 5); // range error
|
||||
assert(a1 == base_buf + 4);
|
||||
CHECK(a1[-4] == 0);
|
||||
CHECK_THROWS(a1[-5]); // range error
|
||||
a1 = base_buf;
|
||||
CHECK(*a1 == 0);
|
||||
|
||||
SpanP new_base4(base_buf + 2, 4);
|
||||
CHECK_THROWS(a1 = new_base4); // not same base
|
||||
a2 = new_base4;
|
||||
CHECK_THROWS(a2 = base4); // not same base
|
||||
|
||||
SpanP sp_no_base(base_buf);
|
||||
SpanP sp_with_base(base_buf, 4, base_buf);
|
||||
assert(sp_no_base.raw_base() == nullptr);
|
||||
assert(sp_with_base.raw_base() == base_buf);
|
||||
CHECK_THROWS(sp_no_base = my_null); // nullptr assignment
|
||||
CHECK_THROWS(sp_with_base = my_null); // nullptr assignment
|
||||
#if XSPAN_CONFIG_ENABLE_SPAN_CONVERSION
|
||||
typedef PtrOrSpanOrNull<char> Span0;
|
||||
Span0 s0_no_base(nullptr);
|
||||
Span0 s0_with_base(nullptr, 4, base_buf);
|
||||
CHECK_THROWS(sp_no_base = s0_no_base); // nullptr assignment
|
||||
CHECK_THROWS(sp_no_base = s0_with_base); // nullptr assignment
|
||||
CHECK_THROWS(sp_with_base = s0_no_base); // nullptr assignment
|
||||
CHECK_THROWS(sp_with_base = s0_with_base); // nullptr assignment
|
||||
#endif
|
||||
UNUSED(my_null);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("Span") {
|
||||
char real_buf[2 + 6 + 2] = {126, 127, 0, 1, 2, 3, 4, 5, 124, 125};
|
||||
char *base_buf = real_buf + 2;
|
||||
char *const my_null = nullptr;
|
||||
typedef Span<char> SpanS;
|
||||
|
||||
// basic nullptr
|
||||
CHECK_THROWS(SpanS(base_buf, 4, base_buf) = my_null);
|
||||
CHECK_THROWS(SpanS(base_buf, 4, base_buf).assign(my_null));
|
||||
// basic range checking
|
||||
CHECK_NOTHROW(SpanS(base_buf, 4, base_buf));
|
||||
CHECK_NOTHROW(SpanS(base_buf, 0, base_buf));
|
||||
CHECK_NOTHROW(SpanS(base_buf, 0, base_buf) - 0);
|
||||
CHECK_THROWS(SpanS(base_buf, 0, base_buf) + 1);
|
||||
CHECK_THROWS(SpanS(base_buf, 0, base_buf) - 1);
|
||||
CHECK_NOTHROW(SpanS(base_buf, 4, base_buf) + 4);
|
||||
CHECK_THROWS(SpanS(base_buf, 4, base_buf) + 5);
|
||||
CHECK_THROWS(SpanS(base_buf - 1, 4, base_buf));
|
||||
CHECK_THROWS(SpanS(base_buf + 1, 0, base_buf));
|
||||
// basic same base
|
||||
CHECK_NOTHROW(SpanS(base_buf, 4, base_buf) = SpanS(base_buf + 1, 3, base_buf));
|
||||
CHECK_NOTHROW(SpanS(base_buf, 4, base_buf) = SpanS(base_buf + 1, 1, base_buf));
|
||||
CHECK_NOTHROW(SpanS(base_buf, 4, base_buf) = SpanS(base_buf + 1, 5, base_buf));
|
||||
CHECK_THROWS(SpanS(base_buf, 4, base_buf) = SpanS(base_buf + 1, 3, base_buf + 1));
|
||||
|
||||
SpanS x1(base_buf, 0);
|
||||
assert(x1 != nullptr);
|
||||
assert(x1.raw_ptr() == base_buf);
|
||||
assert(x1.raw_base() == base_buf);
|
||||
assert(x1.raw_size_in_bytes() == 0u);
|
||||
CHECK_THROWS(*x1);
|
||||
CHECK_THROWS(x1[0]);
|
||||
|
||||
SpanS a2(base_buf, 4);
|
||||
assert(a2 != nullptr);
|
||||
assert(a2.raw_ptr() == base_buf);
|
||||
assert(a2.raw_base() == base_buf);
|
||||
assert(a2.raw_size_in_bytes() == 4u);
|
||||
CHECK(*a2 == 0);
|
||||
CHECK(a2[1] == 1);
|
||||
|
||||
SpanS base0(base_buf, 4, base_buf);
|
||||
assert(base0.raw_ptr() == base_buf);
|
||||
assert(base0.raw_base() == base_buf);
|
||||
assert(base0.raw_size_in_bytes() == 4u);
|
||||
|
||||
SpanS base4(base_buf, 4);
|
||||
assert(base4.raw_ptr() == base_buf);
|
||||
assert(base4.raw_base() == base_buf);
|
||||
assert(base4.raw_size_in_bytes() == 4u);
|
||||
|
||||
SpanS a1(base_buf, 4);
|
||||
a1 = base_buf;
|
||||
a1 = base0;
|
||||
assert(a1 == base0);
|
||||
assert(a1 != nullptr);
|
||||
assert(a1.raw_ptr() == base0.raw_ptr());
|
||||
assert(a1.raw_base() == base_buf);
|
||||
assert(a1.raw_size_in_bytes() == 4u);
|
||||
a1 = base4;
|
||||
assert(a1 == base_buf);
|
||||
assert(a1.raw_ptr() == base_buf);
|
||||
assert(a1.raw_base() == base_buf);
|
||||
assert(a1.raw_size_in_bytes() == 4u);
|
||||
|
||||
a1 = base_buf;
|
||||
a1 = base_buf + 1;
|
||||
CHECK(*a1++ == 1);
|
||||
CHECK(*++a1 == 3);
|
||||
CHECK(*a1 == 3);
|
||||
a1 = base_buf + 4; // at the end of buffer
|
||||
CHECK_THROWS(*a1);
|
||||
CHECK_THROWS(a1 = base_buf + 5); // range error
|
||||
assert(a1 == base_buf + 4);
|
||||
CHECK(a1[-4] == 0);
|
||||
CHECK_THROWS(a1[-5]); // range error
|
||||
a1 = base_buf;
|
||||
CHECK(*a1 == 0);
|
||||
|
||||
SpanS new_base4(base_buf + 2, 4);
|
||||
CHECK_THROWS(a1 = new_base4); // not same base
|
||||
CHECK_THROWS(a2 = new_base4); // not same base
|
||||
|
||||
SpanS ss_with_base(base_buf, 4, base_buf);
|
||||
assert(ss_with_base.raw_base() == base_buf);
|
||||
CHECK_THROWS(ss_with_base = my_null); // nullptr assignment
|
||||
#if XSPAN_CONFIG_ENABLE_SPAN_CONVERSION
|
||||
{
|
||||
typedef PtrOrSpanOrNull<char> Span0;
|
||||
// v0 nullptr, b0 base, b1 base + 1
|
||||
const Span0 v0_v0(nullptr);
|
||||
const Span0 v0_b0(nullptr, 4, base_buf);
|
||||
const Span0 v0_b1(nullptr, 3, base_buf + 1);
|
||||
const Span0 b0_v0(base_buf);
|
||||
const Span0 b0_b0(base_buf, 4, base_buf);
|
||||
CHECK_THROWS(XSPAN_0_MAKE(char, base_buf, 3, base_buf + 1)); // b0_b1
|
||||
const Span0 b1_v0(base_buf + 1);
|
||||
const Span0 b1_b0(base_buf + 1, 4, base_buf);
|
||||
const Span0 b1_b1(base_buf + 1, 3, base_buf + 1);
|
||||
CHECK_THROWS(ss_with_base = v0_v0); // nullptr assignment
|
||||
CHECK_THROWS(ss_with_base = v0_b0); // nullptr assignment
|
||||
CHECK_THROWS(ss_with_base = v0_b1); // nullptr assignment
|
||||
CHECK_NOTHROW(ss_with_base = b0_v0);
|
||||
CHECK_NOTHROW(ss_with_base = b0_b0);
|
||||
CHECK_NOTHROW(ss_with_base = b1_v0);
|
||||
CHECK_NOTHROW(ss_with_base = b1_b0);
|
||||
CHECK_THROWS(ss_with_base = b1_b1); // different base
|
||||
CHECK_THROWS(XSPAN_S_MAKE(char, v0_v0));
|
||||
CHECK_THROWS(XSPAN_S_MAKE(char, v0_b0));
|
||||
CHECK_THROWS(XSPAN_S_MAKE(char, v0_b1));
|
||||
CHECK_THROWS(XSPAN_S_MAKE(char, b0_v0));
|
||||
CHECK_NOTHROW(XSPAN_S_MAKE(char, b0_b0));
|
||||
CHECK_THROWS(XSPAN_S_MAKE(char, b1_v0));
|
||||
CHECK_NOTHROW(XSPAN_S_MAKE(char, b1_b0));
|
||||
CHECK_NOTHROW(XSPAN_S_MAKE(char, b1_b1));
|
||||
//
|
||||
CHECK((XSPAN_S_MAKE(char, b0_b0).raw_base() == base_buf));
|
||||
CHECK((XSPAN_S_MAKE(char, b1_b0).raw_base() == base_buf));
|
||||
CHECK((XSPAN_S_MAKE(char, b1_b1).raw_base() == base_buf + 1));
|
||||
}
|
||||
{
|
||||
typedef PtrOrSpan<char> SpanP;
|
||||
// v0 nullptr, b0 base, b1 base + 1
|
||||
const SpanP b0_v0(base_buf);
|
||||
const SpanP b0_b0(base_buf, 4, base_buf);
|
||||
CHECK_THROWS(XSPAN_P_MAKE(char, base_buf, 3, base_buf + 1)); // b0_b1
|
||||
const SpanP b1_v0(base_buf + 1);
|
||||
const SpanP b1_b0(base_buf + 1, 4, base_buf);
|
||||
const SpanP b1_b1(base_buf + 1, 3, base_buf + 1);
|
||||
CHECK_NOTHROW(ss_with_base = b0_v0);
|
||||
CHECK_NOTHROW(ss_with_base = b0_b0);
|
||||
CHECK_NOTHROW(ss_with_base = b1_v0);
|
||||
CHECK_NOTHROW(ss_with_base = b1_b0);
|
||||
CHECK_THROWS(ss_with_base = b1_b1); // different base
|
||||
CHECK_THROWS(XSPAN_S_MAKE(char, b0_v0));
|
||||
CHECK_NOTHROW(XSPAN_S_MAKE(char, b0_b0));
|
||||
CHECK_THROWS(XSPAN_S_MAKE(char, b1_v0));
|
||||
CHECK_NOTHROW(XSPAN_S_MAKE(char, b1_b0));
|
||||
CHECK_NOTHROW(XSPAN_S_MAKE(char, b1_b1));
|
||||
//
|
||||
CHECK((XSPAN_S_MAKE(char, b0_b0).raw_base() == base_buf));
|
||||
CHECK((XSPAN_S_MAKE(char, b1_b0).raw_base() == base_buf));
|
||||
CHECK((XSPAN_S_MAKE(char, b1_b1).raw_base() == base_buf + 1));
|
||||
}
|
||||
#endif
|
||||
UNUSED(my_null);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("Span void ptr") {
|
||||
static char a[4] = {0, 1, 2, 3};
|
||||
XSPAN_0(void) a0(a, 4);
|
||||
XSPAN_P(void) ap(a, 4);
|
||||
XSPAN_S(void) as(a, 4);
|
||||
XSPAN_0(const void) c0(a, 4);
|
||||
XSPAN_P(const void) cp(a, 4);
|
||||
XSPAN_S(const void) cs(a, 4);
|
||||
static const char b[4] = {0, 1, 2, 3};
|
||||
XSPAN_0(const void) b0(b, 4);
|
||||
XSPAN_P(const void) bp(b, 4);
|
||||
XSPAN_S(const void) bs(b, 4);
|
||||
}
|
||||
|
||||
TEST_CASE("Span deref/array/arrow") {
|
||||
static char real_a[2 + 4 + 2] = {126, 127, 0, 1, 2, 3, 124, 125};
|
||||
static char *a = real_a + 2;
|
||||
XSPAN_0(char) a0(a, 4);
|
||||
XSPAN_P(char) ap(a, 4);
|
||||
XSPAN_S(char) as(a, 4);
|
||||
CHECK_THROWS(a0[4]);
|
||||
CHECK_THROWS(a0[-1]);
|
||||
CHECK_THROWS(a0[-2]);
|
||||
a0 += 2;
|
||||
CHECK(*a0 == 2);
|
||||
CHECK(a0[-1] == 1);
|
||||
CHECK(a0[0] == 2);
|
||||
CHECK(a0[1] == 3);
|
||||
ap += 2;
|
||||
CHECK(*ap == 2);
|
||||
CHECK(ap[-1] == 1);
|
||||
CHECK(ap[0] == 2);
|
||||
CHECK(ap[1] == 3);
|
||||
as += 2;
|
||||
CHECK(*as == 2);
|
||||
CHECK(as[-1] == 1);
|
||||
CHECK(as[0] == 2);
|
||||
CHECK(as[1] == 3);
|
||||
}
|
||||
|
||||
TEST_CASE("Span subspan") {
|
||||
static char buf[4] = {0, 1, 2, 3};
|
||||
XSPAN_S(char) as(buf, 4);
|
||||
CHECK(as.subspan(1, 1)[0] == 1);
|
||||
CHECK((as + 1).subspan(1, 1)[0] == 2);
|
||||
CHECK((as + 2).subspan(0, -2)[0] == 0);
|
||||
CHECK_THROWS(as.subspan(1, 0)[0]);
|
||||
CHECK_THROWS(as.subspan(1, 1)[-1]);
|
||||
}
|
||||
|
||||
TEST_CASE("Span constness") {
|
||||
static char buf[4] = {0, 1, 2, 3};
|
||||
|
||||
// NOLINTBEGIN(performance-unnecessary-copy-initialization)
|
||||
|
||||
XSPAN_0(char) b0(buf, 4);
|
||||
XSPAN_P(char) bp(buf, 4);
|
||||
XSPAN_S(char) bs(buf, 4);
|
||||
|
||||
XSPAN_0(char) s0(b0);
|
||||
XSPAN_P(char) sp(bp);
|
||||
XSPAN_S(char) ss(bs);
|
||||
|
||||
XSPAN_0(const char) b0c(buf, 4);
|
||||
XSPAN_P(const char) bpc(buf, 4);
|
||||
XSPAN_S(const char) bsc(buf, 4);
|
||||
|
||||
XSPAN_0(const char) s0c(b0c);
|
||||
XSPAN_P(const char) spc(bpc);
|
||||
XSPAN_S(const char) ssc(bsc);
|
||||
|
||||
XSPAN_0(const char) x0c(b0);
|
||||
XSPAN_P(const char) xpc(bp);
|
||||
XSPAN_S(const char) xsc(bs);
|
||||
|
||||
// NOLINTEND(performance-unnecessary-copy-initialization)
|
||||
|
||||
CHECK(ptr_diff_bytes(b0, buf) == 0);
|
||||
CHECK(ptr_diff_bytes(bp, buf) == 0);
|
||||
CHECK(ptr_diff_bytes(bs, buf) == 0);
|
||||
CHECK(ptr_diff_bytes(s0, buf) == 0);
|
||||
CHECK(ptr_diff_bytes(sp, buf) == 0);
|
||||
CHECK(ptr_diff_bytes(bs, buf) == 0);
|
||||
//
|
||||
CHECK(ptr_diff_bytes(s0, bp) == 0);
|
||||
CHECK(ptr_diff_bytes(s0, sp) == 0);
|
||||
CHECK(ptr_diff_bytes(s0, ss) == 0);
|
||||
//
|
||||
CHECK(ptr_diff_bytes(s0c, b0c) == 0);
|
||||
CHECK(ptr_diff_bytes(spc, bpc) == 0);
|
||||
CHECK(ptr_diff_bytes(ssc, bsc) == 0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||
namespace {
|
||||
int my_memcmp_v1(XSPAN_P(const void) a, XSPAN_0(const void) b, size_t n) {
|
||||
if (b == nullptr)
|
||||
return -2;
|
||||
XSPAN_0(const void) x(a);
|
||||
return memcmp(x, b, n);
|
||||
}
|
||||
int my_memcmp_v2(XSPAN_P(const char) a, XSPAN_0(const char) b, size_t n) {
|
||||
if (a == b)
|
||||
return 0;
|
||||
if (b == nullptr)
|
||||
return -2;
|
||||
a += 1;
|
||||
b -= 1;
|
||||
XSPAN_0(const char) x(a);
|
||||
XSPAN_0(const char) y = b;
|
||||
return memcmp(x, y, n);
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
TEST_CASE("PtrOrSpan") {
|
||||
static const char buf[4] = {0, 1, 2, 3};
|
||||
CHECK(my_memcmp_v1(buf, nullptr, 4) == -2);
|
||||
CHECK(my_memcmp_v2(buf + 4, buf + 4, 999) == 0);
|
||||
CHECK(my_memcmp_v2(buf, buf + 2, 3) == 0);
|
||||
UNUSED(buf);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("PtrOrSpan char") {
|
||||
char real_buf[2 + 8 + 2] = {126, 127, 0, 1, 2, 3, 4, 5, 6, 7, 124, 125};
|
||||
char *buf = real_buf + 2;
|
||||
XSPAN_P(char) a(buf, XSpanSizeInBytes(8));
|
||||
XSPAN_P(char) b = a.subspan(0, 7);
|
||||
XSPAN_P(char) c = (b + 1).subspan(0, 6);
|
||||
a += 1;
|
||||
CHECK(*a == 1);
|
||||
*a++ += 1;
|
||||
*b++ = 1;
|
||||
CHECK(a == buf + 2);
|
||||
CHECK(b == buf + 1);
|
||||
CHECK(c == buf + 1);
|
||||
CHECK(*b == 2);
|
||||
CHECK(*c == 2);
|
||||
CHECK(a.raw_size_in_bytes() == 8u);
|
||||
CHECK(b.raw_size_in_bytes() == 7u);
|
||||
CHECK(c.raw_size_in_bytes() == 6u);
|
||||
CHECK(a.raw_base() == buf);
|
||||
CHECK(b.raw_base() == buf);
|
||||
CHECK(c.raw_base() == buf + 1);
|
||||
#ifdef UPX_VERSION_HEX
|
||||
CHECK(get_le32(a) != 0);
|
||||
#endif
|
||||
++c;
|
||||
c++;
|
||||
#ifdef UPX_VERSION_HEX
|
||||
CHECK(get_le32(c) != 0);
|
||||
#endif
|
||||
++c;
|
||||
#ifdef UPX_VERSION_HEX
|
||||
CHECK_THROWS(get_le32(c));
|
||||
#endif
|
||||
++b;
|
||||
b++;
|
||||
b += 4;
|
||||
CHECK(b.raw_ptr() == buf + 7);
|
||||
CHECK_THROWS(*b);
|
||||
CHECK(a.raw_size_in_bytes() == 8u);
|
||||
a = b;
|
||||
CHECK(a.raw_size_in_bytes() == 8u);
|
||||
CHECK(a.raw_ptr() == buf + 7);
|
||||
a++;
|
||||
CHECK_THROWS(*a);
|
||||
CHECK_THROWS(raw_bytes(a, 1));
|
||||
a = b;
|
||||
CHECK_THROWS(a = c);
|
||||
*a = 0;
|
||||
a = buf;
|
||||
#ifdef UPX_VERSION_HEX
|
||||
CHECK(upx_safe_strlen(a) == 7u);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("PtrOrSpan int") {
|
||||
int buf[8] = {0, 11, 22, 33, 44, 55, 66, 77};
|
||||
XSPAN_P(const int) a(buf, XSpanCount(8));
|
||||
CHECK(a.raw_size_in_bytes() == 8 * sizeof(int));
|
||||
XSPAN_P(const int) b = a.subspan(0, 7);
|
||||
CHECK(b.raw_size_in_bytes() == 7 * sizeof(int));
|
||||
XSPAN_P(const int) c = (b + 1).subspan(0, 6);
|
||||
CHECK(c.raw_size_in_bytes() == 6 * sizeof(int));
|
||||
a += 1;
|
||||
CHECK(a == buf + 1);
|
||||
CHECK(*a == 11);
|
||||
CHECK(*a++ == 11);
|
||||
CHECK(a == buf + 2);
|
||||
CHECK(*a == 22);
|
||||
CHECK(*++a == 33);
|
||||
CHECK(a == buf + 3);
|
||||
CHECK(*a == 33);
|
||||
CHECK(*--a == 22);
|
||||
CHECK(a == buf + 2);
|
||||
CHECK(*a == 22);
|
||||
CHECK(*a-- == 22);
|
||||
CHECK(a == buf + 1);
|
||||
CHECK(*a == 11);
|
||||
CHECK(*b == 0);
|
||||
CHECK(*c == 11);
|
||||
a -= 1;
|
||||
a += 7;
|
||||
#ifdef UPX_VERSION_HEX
|
||||
CHECK(get_le32(a) == ne32_to_le32(77));
|
||||
#endif
|
||||
a++;
|
||||
#ifdef UPX_VERSION_HEX
|
||||
CHECK_THROWS(get_le32(a));
|
||||
#endif
|
||||
CHECK_THROWS(raw_bytes(a, 1));
|
||||
CHECK_THROWS(a++);
|
||||
CHECK_THROWS(++a);
|
||||
CHECK_THROWS(a += 1);
|
||||
CHECK(a == buf + 8);
|
||||
a = buf;
|
||||
CHECK_THROWS(a--);
|
||||
CHECK_THROWS(--a);
|
||||
CHECK_THROWS(a -= 1);
|
||||
CHECK_THROWS(a += 9);
|
||||
CHECK(a == buf);
|
||||
a += 8;
|
||||
CHECK(a == buf + 8);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// codegen
|
||||
**************************************************************************/
|
||||
|
||||
namespace {
|
||||
template <class T>
|
||||
static noinline int foo(T p) {
|
||||
unsigned r = 0;
|
||||
r += *p++;
|
||||
r += *++p;
|
||||
p += 3;
|
||||
r += *p;
|
||||
r += *--p;
|
||||
r += *p--;
|
||||
r += *p;
|
||||
return r;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
XSPAN_0(T)
|
||||
make_span_0(T *ptr, size_t count) {
|
||||
return PtrOrSpanOrNull<T>(ptr, count);
|
||||
}
|
||||
template <class T>
|
||||
XSPAN_P(T)
|
||||
make_span_p(T *ptr, size_t count) {
|
||||
return PtrOrSpan<T>(ptr, count);
|
||||
}
|
||||
template <class T>
|
||||
XSPAN_S(T)
|
||||
make_span_s(T *ptr, size_t count) {
|
||||
return Span<T>(ptr, count);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("Span codegen") {
|
||||
upx_uint8_t buf[8] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
CHECK(foo(buf) == 0 + 2 + 5 + 4 + 4 + 3);
|
||||
CHECK(foo(make_span_0(buf, 8)) == 0 + 2 + 5 + 4 + 4 + 3);
|
||||
CHECK(foo(make_span_p(buf, 8)) == 0 + 2 + 5 + 4 + 4 + 3);
|
||||
CHECK(foo(make_span_s(buf, 8)) == 0 + 2 + 5 + 4 + 4 + 3);
|
||||
CHECK(foo(XSPAN_0_MAKE(upx_uint8_t, buf, 8)) == 0 + 2 + 5 + 4 + 4 + 3);
|
||||
CHECK(foo(XSPAN_P_MAKE(upx_uint8_t, buf, 8)) == 0 + 2 + 5 + 4 + 4 + 3);
|
||||
CHECK(foo(XSPAN_S_MAKE(upx_uint8_t, buf, 8)) == 0 + 2 + 5 + 4 + 4 + 3);
|
||||
UNUSED(buf);
|
||||
}
|
||||
|
||||
#endif // WITH_XSPAN >= 2
|
||||
|
||||
/*************************************************************************
|
||||
// misc
|
||||
**************************************************************************/
|
||||
|
||||
namespace {
|
||||
template <class T>
|
||||
struct PointerTraits {
|
||||
typedef typename std::add_lvalue_reference<T>::type reference;
|
||||
typedef
|
||||
typename std::add_lvalue_reference<typename std::add_const<T>::type>::type const_reference;
|
||||
typedef typename std::add_pointer<T>::type pointer;
|
||||
typedef typename std::add_pointer<typename std::add_const<T>::type>::type const_pointer;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
|
||||
TEST_CASE("decltype integral constants") {
|
||||
static_assert((std::is_same<decltype(0), int>::value), "");
|
||||
static_assert((std::is_same<decltype(0u), unsigned>::value), "");
|
||||
static_assert((std::is_same<decltype(0l), long>::value), "");
|
||||
static_assert((std::is_same<decltype(0ul), unsigned long>::value), "");
|
||||
static_assert((std::is_same<decltype(0ll), long long>::value), "");
|
||||
static_assert((std::is_same<decltype(0ull), unsigned long long>::value), "");
|
||||
static_assert((std::is_same<decltype((char) 0), char>::value), "");
|
||||
static_assert((std::is_same<decltype((short) 0), short>::value), "");
|
||||
static_assert((std::is_same<decltype((long) 0), long>::value), "");
|
||||
static_assert((std::is_same<decltype((long long) 0), long long>::value), "");
|
||||
static_assert((std::is_same<decltype(char(0)), char>::value), "");
|
||||
static_assert((std::is_same<decltype(short(0)), short>::value), "");
|
||||
static_assert((std::is_same<decltype(long(0)), long>::value), "");
|
||||
}
|
||||
|
||||
TEST_CASE("decltype pointer") {
|
||||
int dummy = 0;
|
||||
int *p = &dummy;
|
||||
const int *c = &dummy;
|
||||
static_assert((std::is_same<decltype(p - p), std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<decltype(c - c), std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<decltype(p - c), std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<decltype(c - p), std::ptrdiff_t>::value), "");
|
||||
typedef PointerTraits<int> TInt;
|
||||
typedef PointerTraits<const int> TConstInt;
|
||||
static_assert((std::is_same<int *, TInt::pointer>::value), "");
|
||||
static_assert((std::is_same<const int *, TInt::const_pointer>::value), "");
|
||||
static_assert((std::is_same<const int *, TConstInt::pointer>::value), "");
|
||||
static_assert((std::is_same<const int *, TConstInt::const_pointer>::value), "");
|
||||
//
|
||||
static_assert((std::is_same<decltype(p), TInt::pointer>::value), "");
|
||||
static_assert((std::is_same<decltype(c), TInt::const_pointer>::value), "");
|
||||
static_assert((std::is_same<decltype(c), TConstInt::pointer>::value), "");
|
||||
static_assert((std::is_same<decltype(p + 1), TInt::pointer>::value), "");
|
||||
static_assert((std::is_same<decltype(c + 1), TInt::const_pointer>::value), "");
|
||||
static_assert((std::is_same<decltype(c + 1), TConstInt::pointer>::value), "");
|
||||
static_assert((std::is_same<decltype(c + 1), TConstInt::const_pointer>::value), "");
|
||||
static_assert((std::is_same<decltype(c + 1), const int *>::value), "");
|
||||
// dereference
|
||||
static_assert((std::is_same<decltype(*p), TInt::reference>::value), "");
|
||||
static_assert((std::is_same<decltype(*c), TInt::const_reference>::value), "");
|
||||
#if 0
|
||||
// this works, but avoid clang warnings:
|
||||
// "Expression with side effects has no effect in an unevaluated context"
|
||||
static_assert((std::is_same<decltype(*p++), TInt::reference>::value), "");
|
||||
static_assert((std::is_same<decltype(*++p), TInt::reference>::value), "");
|
||||
static_assert((std::is_same<decltype(*c++), TInt::const_reference>::value), "");
|
||||
static_assert((std::is_same<decltype(*c++), TConstInt::reference>::value), "");
|
||||
static_assert((std::is_same<decltype(*c++), TConstInt::const_reference>::value), "");
|
||||
static_assert((std::is_same<decltype(*++c), TInt::const_reference>::value), "");
|
||||
static_assert((std::is_same<decltype(*++c), TConstInt::reference>::value), "");
|
||||
static_assert((std::is_same<decltype(*++c), TConstInt::const_reference>::value), "");
|
||||
#endif
|
||||
// array access
|
||||
static_assert((std::is_same<decltype(p[0]), TInt::reference>::value), "");
|
||||
static_assert((std::is_same<decltype(c[0]), TInt::const_reference>::value), "");
|
||||
static_assert((std::is_same<decltype(c[0]), TConstInt::reference>::value), "");
|
||||
static_assert((std::is_same<decltype(c[0]), TConstInt::const_reference>::value), "");
|
||||
UNUSED(p);
|
||||
UNUSED(c);
|
||||
}
|
||||
|
||||
#endif // __cplusplus >= 201103L
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2017 Laszlo Molnar
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
@@ -21,25 +20,22 @@
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "conf.h"
|
||||
#include "../conf.h"
|
||||
#include "compress.h"
|
||||
#include "mem.h"
|
||||
|
||||
#include "../util/membuffer.h"
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
|
||||
{
|
||||
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler) {
|
||||
if (len == 0)
|
||||
return adler;
|
||||
assert(buf != NULL);
|
||||
assert(buf != nullptr);
|
||||
#if 1
|
||||
return upx_ucl_adler32(buf, len, adler);
|
||||
#else
|
||||
@@ -47,37 +43,32 @@ unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
#if 0 // UNUSED
|
||||
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
|
||||
{
|
||||
if (len == 0)
|
||||
return crc;
|
||||
assert(buf != NULL);
|
||||
assert(buf != nullptr);
|
||||
#if 1
|
||||
return upx_ucl_crc32(buf, len, crc);
|
||||
#else
|
||||
return upx_zlib_crc32(buf, len, crc);
|
||||
#endif
|
||||
}
|
||||
#endif /* UNUSED */
|
||||
|
||||
#endif // UNUSED
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_compress ( const upx_bytep src, unsigned src_len,
|
||||
upx_bytep dst, unsigned* dst_len,
|
||||
upx_callback_p cb,
|
||||
int method, int level,
|
||||
const upx_compress_config_t *cconf,
|
||||
upx_compress_result_t *cresult )
|
||||
{
|
||||
int upx_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
upx_callback_p cb, int method, int level, const upx_compress_config_t *cconf,
|
||||
upx_compress_result_t *cresult) {
|
||||
int r = UPX_E_ERROR;
|
||||
upx_compress_result_t cresult_buffer;
|
||||
|
||||
assert(method > 0); assert(level > 0);
|
||||
assert(method > 0);
|
||||
assert(level > 0);
|
||||
|
||||
#if 1
|
||||
// set available bytes in dst
|
||||
@@ -87,67 +78,67 @@ int upx_compress ( const upx_bytep src, unsigned src_len,
|
||||
// force users to provide *dst_len
|
||||
assert(*dst_len != 0);
|
||||
#endif
|
||||
// for UPX, we always require a reasonably sized outbut buffer
|
||||
// for UPX, we always require a reasonably sized output buffer
|
||||
assert(*dst_len >= MemBuffer::getSizeForCompression(src_len));
|
||||
|
||||
if (!cresult)
|
||||
cresult = &cresult_buffer;
|
||||
memset(cresult, 0, sizeof(*cresult));
|
||||
cresult->reset();
|
||||
#if 1
|
||||
// debug
|
||||
cresult->method = method;
|
||||
cresult->level = level;
|
||||
cresult->u_len = src_len;
|
||||
cresult->c_len = 0;
|
||||
// debugging aid
|
||||
cresult->debug.method = method;
|
||||
cresult->debug.level = level;
|
||||
cresult->debug.u_len = src_len;
|
||||
cresult->debug.c_len = 0;
|
||||
#endif
|
||||
|
||||
if __acc_cte(0) {
|
||||
const unsigned orig_dst_len = *dst_len;
|
||||
if (__acc_cte(false)) {
|
||||
}
|
||||
#if (WITH_LZMA)
|
||||
else if (M_IS_LZMA(method))
|
||||
r = upx_lzma_compress(src, src_len, dst, dst_len,
|
||||
cb, method, level, cconf, cresult);
|
||||
r = upx_lzma_compress(src, src_len, dst, dst_len, cb, method, level, cconf, cresult);
|
||||
#endif
|
||||
#if (WITH_NRV)
|
||||
else if ((M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method)) && !opt->prefer_ucl)
|
||||
r = upx_nrv_compress(src, src_len, dst, dst_len,
|
||||
cb, method, level, cconf, cresult);
|
||||
r = upx_nrv_compress(src, src_len, dst, dst_len, cb, method, level, cconf, cresult);
|
||||
#endif
|
||||
#if (WITH_UCL)
|
||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||
r = upx_ucl_compress(src, src_len, dst, dst_len,
|
||||
cb, method, level, cconf, cresult);
|
||||
r = upx_ucl_compress(src, src_len, dst, dst_len, cb, method, level, cconf, cresult);
|
||||
#endif
|
||||
#if (WITH_ZSTD)
|
||||
else if (M_IS_ZSTD(method))
|
||||
r = upx_zstd_compress(src, src_len, dst, dst_len, cb, method, level, cconf, cresult);
|
||||
#endif
|
||||
else {
|
||||
throwInternalError("unknown compression method");
|
||||
}
|
||||
|
||||
#if 1
|
||||
// debug
|
||||
cresult->c_len = *dst_len;
|
||||
// debugging aid
|
||||
cresult->debug.c_len = *dst_len;
|
||||
#endif
|
||||
assert_noexcept(*dst_len <= orig_dst_len);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_decompress ( const upx_bytep src, unsigned src_len,
|
||||
upx_bytep dst, unsigned* dst_len,
|
||||
int method,
|
||||
const upx_compress_result_t *cresult )
|
||||
{
|
||||
int upx_decompress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
int method, const upx_compress_result_t *cresult) {
|
||||
int r = UPX_E_ERROR;
|
||||
|
||||
assert(*dst_len > 0);
|
||||
assert(src_len < *dst_len); // must be compressed
|
||||
|
||||
if (cresult && cresult->method == 0)
|
||||
cresult = NULL;
|
||||
if (cresult && cresult->debug.method == 0)
|
||||
cresult = nullptr;
|
||||
|
||||
if __acc_cte(0) {
|
||||
const unsigned orig_dst_len = *dst_len;
|
||||
if (__acc_cte(false)) {
|
||||
}
|
||||
#if (WITH_LZMA)
|
||||
else if (M_IS_LZMA(method))
|
||||
@@ -164,37 +155,37 @@ int upx_decompress ( const upx_bytep src, unsigned src_len,
|
||||
#if (WITH_ZLIB)
|
||||
else if (M_IS_DEFLATE(method))
|
||||
r = upx_zlib_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||
#endif
|
||||
#if (WITH_ZSTD)
|
||||
else if (M_IS_ZSTD(method))
|
||||
r = upx_zstd_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||
#endif
|
||||
else {
|
||||
throwInternalError("unknown decompression method");
|
||||
}
|
||||
|
||||
assert_noexcept(*dst_len <= orig_dst_len);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_test_overlap ( const upx_bytep buf,
|
||||
const upx_bytep tbuf,
|
||||
unsigned src_off, unsigned src_len,
|
||||
unsigned* dst_len,
|
||||
int method,
|
||||
const upx_compress_result_t *cresult )
|
||||
{
|
||||
int upx_test_overlap(const upx_bytep buf, const upx_bytep tbuf, unsigned src_off, unsigned src_len,
|
||||
unsigned *dst_len, int method, const upx_compress_result_t *cresult) {
|
||||
int r = UPX_E_ERROR;
|
||||
|
||||
if (cresult && cresult->method == 0)
|
||||
cresult = NULL;
|
||||
if (cresult && cresult->debug.method == 0)
|
||||
cresult = nullptr;
|
||||
|
||||
assert(*dst_len > 0);
|
||||
assert(src_len < *dst_len); // must be compressed
|
||||
unsigned overlap_overhead = src_off + src_len - *dst_len;
|
||||
assert((int)overlap_overhead > 0);
|
||||
assert((int) overlap_overhead > 0);
|
||||
|
||||
if __acc_cte(0) {
|
||||
const unsigned orig_dst_len = *dst_len;
|
||||
if (__acc_cte(false)) {
|
||||
}
|
||||
#if (WITH_LZMA)
|
||||
else if (M_IS_LZMA(method))
|
||||
@@ -207,11 +198,16 @@ int upx_test_overlap ( const upx_bytep buf,
|
||||
#if (WITH_UCL)
|
||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||
r = upx_ucl_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||
#endif
|
||||
#if (WITH_ZSTD)
|
||||
else if (M_IS_ZSTD(method))
|
||||
r = upx_zstd_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||
#endif
|
||||
else {
|
||||
throwInternalError("unknown decompression method");
|
||||
}
|
||||
|
||||
assert_noexcept(*dst_len <= orig_dst_len);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2017 Laszlo Molnar
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
@@ -21,19 +20,39 @@
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __UPX_COMPRESS_H
|
||||
#define __UPX_COMPRESS_H 1
|
||||
|
||||
// clang-format off
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
#if (WITH_BZIP2)
|
||||
int upx_bzip2_init(void);
|
||||
const char *upx_bzip2_version_string(void);
|
||||
int upx_bzip2_compress ( const upx_bytep src, unsigned src_len,
|
||||
upx_bytep dst, unsigned* dst_len,
|
||||
upx_callback_p cb,
|
||||
int method, int level,
|
||||
const upx_compress_config_t *cconf,
|
||||
upx_compress_result_t *cresult );
|
||||
int upx_bzip2_decompress ( const upx_bytep src, unsigned src_len,
|
||||
upx_bytep dst, unsigned* dst_len,
|
||||
int method,
|
||||
const upx_compress_result_t *cresult );
|
||||
int upx_bzip2_test_overlap ( const upx_bytep buf,
|
||||
const upx_bytep tbuf,
|
||||
unsigned src_off, unsigned src_len,
|
||||
unsigned* dst_len,
|
||||
int method,
|
||||
const upx_compress_result_t *cresult );
|
||||
#endif
|
||||
|
||||
#if (WITH_LZMA)
|
||||
int upx_lzma_init(void);
|
||||
const char *upx_lzma_version_string(void);
|
||||
@@ -55,7 +74,6 @@ int upx_lzma_test_overlap ( const upx_bytep buf,
|
||||
const upx_compress_result_t *cresult );
|
||||
#endif
|
||||
|
||||
|
||||
#if (WITH_NRV)
|
||||
int upx_nrv_init(void);
|
||||
const char *upx_nrv_version_string(void);
|
||||
@@ -77,7 +95,6 @@ int upx_nrv_test_overlap ( const upx_bytep buf,
|
||||
const upx_compress_result_t *cresult );
|
||||
#endif
|
||||
|
||||
|
||||
#if (WITH_UCL)
|
||||
int upx_ucl_init(void);
|
||||
const char *upx_ucl_version_string(void);
|
||||
@@ -101,7 +118,6 @@ unsigned upx_ucl_adler32(const void *buf, unsigned len, unsigned adler);
|
||||
unsigned upx_ucl_crc32 (const void *buf, unsigned len, unsigned crc);
|
||||
#endif
|
||||
|
||||
|
||||
#if (WITH_ZLIB)
|
||||
int upx_zlib_init(void);
|
||||
const char *upx_zlib_version_string(void);
|
||||
@@ -125,7 +141,25 @@ unsigned upx_zlib_adler32(const void *buf, unsigned len, unsigned adler);
|
||||
unsigned upx_zlib_crc32 (const void *buf, unsigned len, unsigned crc);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* already included */
|
||||
#if (WITH_ZSTD)
|
||||
int upx_zstd_init(void);
|
||||
const char *upx_zstd_version_string(void);
|
||||
int upx_zstd_compress ( const upx_bytep src, unsigned src_len,
|
||||
upx_bytep dst, unsigned* dst_len,
|
||||
upx_callback_p cb,
|
||||
int method, int level,
|
||||
const upx_compress_config_t *cconf,
|
||||
upx_compress_result_t *cresult );
|
||||
int upx_zstd_decompress ( const upx_bytep src, unsigned src_len,
|
||||
upx_bytep dst, unsigned* dst_len,
|
||||
int method,
|
||||
const upx_compress_result_t *cresult );
|
||||
int upx_zstd_test_overlap ( const upx_bytep buf,
|
||||
const upx_bytep tbuf,
|
||||
unsigned src_off, unsigned src_len,
|
||||
unsigned* dst_len,
|
||||
int method,
|
||||
const upx_compress_result_t *cresult );
|
||||
#endif
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -0,0 +1,553 @@
|
||||
/* compress_lzma.cpp --
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#include "../conf.h"
|
||||
#include "compress.h"
|
||||
#include "../util/membuffer.h"
|
||||
|
||||
#if (ACC_CC_CLANG)
|
||||
#pragma clang diagnostic ignored "-Wshadow"
|
||||
#endif
|
||||
#if (ACC_CC_GNUC >= 0x040200)
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#endif
|
||||
#if (ACC_CC_MSC)
|
||||
#pragma warning(disable : 4456) // -Wno-shadow
|
||||
#endif
|
||||
#if (ACC_CC_MSC && (_MSC_VER < 1900))
|
||||
#pragma warning(disable : 4127) // warning C4127: conditional expression is constant
|
||||
#endif
|
||||
|
||||
void lzma_compress_config_t::reset() noexcept {
|
||||
pos_bits.reset();
|
||||
lit_pos_bits.reset();
|
||||
lit_context_bits.reset();
|
||||
dict_size.reset();
|
||||
fast_mode = 2;
|
||||
num_fast_bytes.reset();
|
||||
match_finder_cycles = 0;
|
||||
|
||||
max_num_probs = 0;
|
||||
}
|
||||
|
||||
// INFO: the LZMA SDK is covered by a permissive license which allows
|
||||
// using unmodified LZMA source code in UPX and the UPX stubs.
|
||||
// See SPECIAL EXCEPTION below.
|
||||
//
|
||||
// Quoting from lzma-4.43/lzma.txt:
|
||||
//
|
||||
// LICENSE
|
||||
// -------
|
||||
//
|
||||
// LZMA SDK is available under any of the following licenses:
|
||||
//
|
||||
// 1) GNU Lesser General Public License (GNU LGPL)
|
||||
// 2) Common Public License (CPL)
|
||||
// 3) Simplified license for unmodified code (read SPECIAL EXCEPTION)
|
||||
// 4) Proprietary license
|
||||
//
|
||||
// It means that you can select one of these four options and follow rules
|
||||
// of that license.
|
||||
//
|
||||
// 1,2) GNU LGPL and CPL licenses are pretty similar and both these
|
||||
// licenses are classified as
|
||||
// - "Free software licenses" at http://www.gnu.org/
|
||||
// - "OSI-approved" at http://www.opensource.org/
|
||||
//
|
||||
// 3) SPECIAL EXCEPTION
|
||||
//
|
||||
// Igor Pavlov, as the author of this code, expressly permits you
|
||||
// to statically or dynamically link your code (or bind by name)
|
||||
// to the files from LZMA SDK without subjecting your linked
|
||||
// code to the terms of the CPL or GNU LGPL.
|
||||
// Any modifications or additions to files from LZMA SDK, however,
|
||||
// are subject to the GNU LGPL or CPL terms.
|
||||
//
|
||||
// SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code,
|
||||
// while you keep LZMA SDK code unmodified.
|
||||
|
||||
/*************************************************************************
|
||||
// compress defaults
|
||||
**************************************************************************/
|
||||
|
||||
static bool prepare_result(lzma_compress_result_t *res, unsigned src_len, int method, int level,
|
||||
const lzma_compress_config_t *lcconf) {
|
||||
// setup defaults
|
||||
res->pos_bits = 2; // 0 .. 4
|
||||
res->lit_pos_bits = 0; // 0 .. 4
|
||||
res->lit_context_bits = 3; // 0 .. 8
|
||||
res->dict_size = 4 * 1024 * 1024; // 1 .. 2**30
|
||||
res->fast_mode = 2; // 0 .. 2
|
||||
res->num_fast_bytes = 64; // 5 .. 273
|
||||
res->match_finder_cycles = 0;
|
||||
// UPX overrides
|
||||
res->pos_bits = lzma_compress_config_t::pos_bits_t::default_value;
|
||||
res->lit_pos_bits = lzma_compress_config_t::lit_pos_bits_t::default_value;
|
||||
res->lit_context_bits = lzma_compress_config_t::lit_context_bits_t::default_value;
|
||||
res->dict_size = lzma_compress_config_t::dict_size_t::default_value;
|
||||
res->num_fast_bytes = lzma_compress_config_t::num_fast_bytes_t::default_value;
|
||||
// method overrides
|
||||
if (method >= 0x100) {
|
||||
res->pos_bits = (method >> 16) & 15;
|
||||
res->lit_pos_bits = (method >> 12) & 15;
|
||||
res->lit_context_bits = (method >> 8) & 15;
|
||||
}
|
||||
#if 0
|
||||
// DEBUG - set sizes so that we use a maximum amount of stack.
|
||||
// These settings cause res->num_probs == 3147574, i.e. we will
|
||||
// need about 6 MiB of stack during runtime decompression.
|
||||
res->lit_pos_bits = 4;
|
||||
res->lit_context_bits = 8;
|
||||
#endif
|
||||
|
||||
// TODO: tune these settings according to level
|
||||
switch (level) {
|
||||
case 1:
|
||||
res->dict_size = 256 * 1024;
|
||||
res->fast_mode = 0;
|
||||
res->num_fast_bytes = 8;
|
||||
break;
|
||||
case 2:
|
||||
res->dict_size = 256 * 1024;
|
||||
res->fast_mode = 0;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
break;
|
||||
case 9:
|
||||
res->dict_size = 8 * 1024 * 1024;
|
||||
break;
|
||||
case 10:
|
||||
res->dict_size = src_len;
|
||||
break;
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
|
||||
// cconf overrides
|
||||
if (lcconf) {
|
||||
oassign(res->pos_bits, lcconf->pos_bits);
|
||||
oassign(res->lit_pos_bits, lcconf->lit_pos_bits);
|
||||
oassign(res->lit_context_bits, lcconf->lit_context_bits);
|
||||
oassign(res->dict_size, lcconf->dict_size);
|
||||
oassign(res->num_fast_bytes, lcconf->num_fast_bytes);
|
||||
}
|
||||
|
||||
// limit dictionary size
|
||||
if (res->dict_size > src_len)
|
||||
res->dict_size = src_len;
|
||||
|
||||
// limit num_probs
|
||||
if (lcconf && lcconf->max_num_probs) {
|
||||
for (;;) {
|
||||
unsigned n = 1846 + (768u << (res->lit_context_bits + res->lit_pos_bits));
|
||||
if (n <= lcconf->max_num_probs)
|
||||
break;
|
||||
if (res->lit_pos_bits > res->lit_context_bits) {
|
||||
if (res->lit_pos_bits == 0)
|
||||
goto error;
|
||||
res->lit_pos_bits -= 1;
|
||||
} else {
|
||||
if (res->lit_context_bits == 0)
|
||||
goto error;
|
||||
res->lit_context_bits -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lzma_compress_config_t::pos_bits_t::assertValue(res->pos_bits);
|
||||
lzma_compress_config_t::lit_pos_bits_t::assertValue(res->lit_pos_bits);
|
||||
lzma_compress_config_t::lit_context_bits_t::assertValue(res->lit_context_bits);
|
||||
lzma_compress_config_t::dict_size_t::assertValue(res->dict_size);
|
||||
lzma_compress_config_t::num_fast_bytes_t::assertValue(res->num_fast_bytes);
|
||||
|
||||
res->num_probs = 1846 + (768u << (res->lit_context_bits + res->lit_pos_bits));
|
||||
NO_printf("\nlzma_compress config: %u %u %u %u %u\n", res->pos_bits, res->lit_pos_bits,
|
||||
res->lit_context_bits, res->dict_size, res->num_probs);
|
||||
return true;
|
||||
|
||||
error:
|
||||
return false;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// compress - cruft because of pseudo-COM layer
|
||||
**************************************************************************/
|
||||
|
||||
// ensure proper nullptr usage
|
||||
// TODO later: examine why we need this in the first place
|
||||
#undef NULL
|
||||
// NOLINTBEGIN(clang-analyzer-optin.cplusplus.*)
|
||||
#define NULL nullptr
|
||||
// NOLINTEND(clang-analyzer-optin.cplusplus.*)
|
||||
#if defined(__GNUC__)
|
||||
#undef __null
|
||||
#define __null nullptr
|
||||
#endif
|
||||
|
||||
#undef MSDOS
|
||||
#undef OS2
|
||||
#undef _WIN32
|
||||
#undef _WIN32_WCE
|
||||
#undef COMPRESS_MF_MT
|
||||
#undef _NO_EXCEPTIONS
|
||||
#include <lzma-sdk/C/Common/MyInitGuid.h>
|
||||
// #include <lzma-sdk/C/7zip/Compress/LZMA/LZMADecoder.h>
|
||||
#include <lzma-sdk/C/7zip/Compress/LZMA/LZMAEncoder.h>
|
||||
|
||||
namespace MyLzma {
|
||||
|
||||
struct InStream final : public ISequentialInStream, public CMyUnknownImp {
|
||||
virtual ~InStream() {}
|
||||
MY_UNKNOWN_IMP
|
||||
const Byte *b_buf = nullptr;
|
||||
size_t b_size;
|
||||
size_t b_pos;
|
||||
void Init(const Byte *data, size_t size) {
|
||||
b_buf = data;
|
||||
b_size = size;
|
||||
b_pos = 0;
|
||||
}
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) override;
|
||||
};
|
||||
|
||||
STDMETHODIMP InStream::Read(void *data, UInt32 size, UInt32 *processedSize) {
|
||||
size_t remain = b_size - b_pos;
|
||||
if (size > remain)
|
||||
size = (UInt32) remain;
|
||||
memmove(data, b_buf + b_pos, size);
|
||||
b_pos += size;
|
||||
if (processedSize != nullptr)
|
||||
*processedSize = size;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
struct OutStream final : public ISequentialOutStream, public CMyUnknownImp {
|
||||
virtual ~OutStream() {}
|
||||
MY_UNKNOWN_IMP
|
||||
Byte *b_buf = nullptr;
|
||||
size_t b_size;
|
||||
size_t b_pos;
|
||||
bool overflow;
|
||||
void Init(Byte *data, size_t size) {
|
||||
b_buf = data;
|
||||
b_size = size;
|
||||
b_pos = 0;
|
||||
overflow = false;
|
||||
}
|
||||
HRESULT WriteByte(Byte c) {
|
||||
if (b_pos >= b_size) {
|
||||
overflow = true;
|
||||
return E_FAIL;
|
||||
}
|
||||
b_buf[b_pos++] = c;
|
||||
return S_OK;
|
||||
}
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) override;
|
||||
};
|
||||
|
||||
STDMETHODIMP OutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) {
|
||||
size_t remain = b_size - b_pos;
|
||||
if (size > remain)
|
||||
size = (UInt32) remain, overflow = true;
|
||||
memmove(b_buf + b_pos, data, size);
|
||||
b_pos += size;
|
||||
if (processedSize != nullptr)
|
||||
*processedSize = size;
|
||||
return overflow ? E_FAIL : S_OK;
|
||||
}
|
||||
|
||||
struct ProgressInfo final : public ICompressProgressInfo, public CMyUnknownImp {
|
||||
virtual ~ProgressInfo() {}
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize) override;
|
||||
upx_callback_p cb = nullptr;
|
||||
};
|
||||
|
||||
STDMETHODIMP ProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) {
|
||||
if (cb && cb->nprogress)
|
||||
cb->nprogress(cb, (unsigned) *inSize, (unsigned) *outSize);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
} // namespace MyLzma
|
||||
|
||||
#include <lzma-sdk/C/Common/Alloc.cpp>
|
||||
#include <lzma-sdk/C/Common/CRC.cpp>
|
||||
// #include <lzma-sdk/C/7zip/Common/InBuffer.cpp>
|
||||
#include <lzma-sdk/C/7zip/Common/OutBuffer.cpp>
|
||||
#include <lzma-sdk/C/7zip/Common/StreamUtils.cpp>
|
||||
#include <lzma-sdk/C/7zip/Compress/LZ/LZInWindow.cpp>
|
||||
// #include <lzma-sdk/C/7zip/Compress/LZ/LZOutWindow.cpp>
|
||||
// #include <lzma-sdk/C/7zip/Compress/LZMA/LZMADecoder.cpp>
|
||||
#include <lzma-sdk/C/7zip/Compress/LZMA/LZMAEncoder.cpp>
|
||||
#include <lzma-sdk/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp>
|
||||
#undef RC_NORMALIZE
|
||||
|
||||
int upx_lzma_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
upx_callback_p cb, int method, int level,
|
||||
const upx_compress_config_t *cconf_parm, upx_compress_result_t *cresult) {
|
||||
assert(M_IS_LZMA(method));
|
||||
assert(level > 0);
|
||||
assert(cresult != nullptr);
|
||||
|
||||
int r = UPX_E_ERROR;
|
||||
HRESULT rh;
|
||||
const lzma_compress_config_t *const lcconf = cconf_parm ? &cconf_parm->conf_lzma : nullptr;
|
||||
lzma_compress_result_t *const res = &cresult->result_lzma;
|
||||
|
||||
MyLzma::InStream is;
|
||||
is.AddRef();
|
||||
is.Init(src, src_len);
|
||||
MyLzma::OutStream os;
|
||||
os.AddRef();
|
||||
os.Init(dst, *dst_len);
|
||||
MyLzma::ProgressInfo progress;
|
||||
progress.AddRef();
|
||||
progress.cb = cb; // progress.Init()
|
||||
|
||||
NCompress::NLZMA::CEncoder enc;
|
||||
const PROPID propIDs[8] = {
|
||||
NCoderPropID::kPosStateBits, // 0 pb _posStateBits(2)
|
||||
NCoderPropID::kLitPosBits, // 1 lp _numLiteralPosStateBits(0)
|
||||
NCoderPropID::kLitContextBits, // 2 lc _numLiteralContextBits(3)
|
||||
NCoderPropID::kDictionarySize, // 3 ds
|
||||
NCoderPropID::kAlgorithm, // 4 fm _fastmode
|
||||
NCoderPropID::kNumFastBytes, // 5 fb
|
||||
NCoderPropID::kMatchFinderCycles, // 6 mfc _matchFinderCycles, _cutValue
|
||||
NCoderPropID::kMatchFinder // 7 mf
|
||||
};
|
||||
PROPVARIANT pr[8];
|
||||
const unsigned nprops = 8;
|
||||
if (!prepare_result(res, src_len, method, level, lcconf))
|
||||
goto error;
|
||||
pr[0].vt = pr[1].vt = pr[2].vt = pr[3].vt = pr[4].vt = pr[5].vt = pr[6].vt = VT_UI4;
|
||||
pr[7].vt = VT_BSTR;
|
||||
pr[0].uintVal = res->pos_bits;
|
||||
pr[1].uintVal = res->lit_pos_bits;
|
||||
pr[2].uintVal = res->lit_context_bits;
|
||||
pr[3].uintVal = res->dict_size;
|
||||
pr[4].uintVal = res->fast_mode;
|
||||
pr[5].uintVal = res->num_fast_bytes;
|
||||
pr[6].uintVal = res->match_finder_cycles;
|
||||
static const wchar_t matchfinder[] = L"BT4";
|
||||
assert(NCompress::NLZMA::FindMatchFinder(matchfinder) >= 0);
|
||||
pr[7].bstrVal = ACC_PCAST(BSTR, ACC_UNCONST_CAST(wchar_t *, matchfinder));
|
||||
|
||||
try {
|
||||
if (enc.SetCoderProperties(propIDs, pr, nprops) != S_OK)
|
||||
goto error;
|
||||
// encode properties in LZMA-style (5 bytes)
|
||||
if (enc.WriteCoderProperties(&os) != S_OK)
|
||||
goto error;
|
||||
if (os.overflow) {
|
||||
// r = UPX_E_OUTPUT_OVERRUN;
|
||||
r = UPX_E_NOT_COMPRESSIBLE;
|
||||
goto error;
|
||||
}
|
||||
assert(os.b_pos == 5);
|
||||
|
||||
// reset and encode properties in UPX-style (2 bytes)
|
||||
os.b_pos = 0;
|
||||
// UPX extra stuff in first byte: 5 high bits convenience for stub decompressor
|
||||
unsigned t = res->lit_context_bits + res->lit_pos_bits;
|
||||
os.WriteByte(Byte((t << 3) | res->pos_bits));
|
||||
os.WriteByte(Byte((res->lit_pos_bits << 4) | res->lit_context_bits));
|
||||
|
||||
// compress
|
||||
rh = enc.Code(&is, &os, nullptr, nullptr, &progress);
|
||||
|
||||
} catch (...) {
|
||||
rh = E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
assert(is.b_pos <= src_len);
|
||||
assert(os.b_pos <= *dst_len);
|
||||
if (rh == E_OUTOFMEMORY)
|
||||
r = UPX_E_OUT_OF_MEMORY;
|
||||
else if (os.overflow) {
|
||||
assert(os.b_pos == *dst_len);
|
||||
// r = UPX_E_OUTPUT_OVERRUN;
|
||||
r = UPX_E_NOT_COMPRESSIBLE;
|
||||
} else if (rh == S_OK) {
|
||||
assert(is.b_pos == src_len);
|
||||
r = UPX_E_OK;
|
||||
}
|
||||
|
||||
error:
|
||||
*dst_len = (unsigned) os.b_pos;
|
||||
NO_printf("\nlzma_compress: %d: %u %u %u %u %u, %u - > %u\n", r, res->pos_bits,
|
||||
res->lit_pos_bits, res->lit_context_bits, res->dict_size, res->num_probs, src_len,
|
||||
*dst_len);
|
||||
NO_printf("%u %u %u\n", is.__m_RefCount, os.__m_RefCount, progress.__m_RefCount);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// decompress
|
||||
**************************************************************************/
|
||||
|
||||
#undef _LZMA_IN_CB
|
||||
#undef _LZMA_OUT_READ
|
||||
#undef _LZMA_PROB32
|
||||
#undef _LZMA_LOC_OPT
|
||||
#include <lzma-sdk/C/7zip/Compress/LZMA_C/LzmaDecode.h>
|
||||
#include <lzma-sdk/C/7zip/Compress/LZMA_C/LzmaDecode.c>
|
||||
|
||||
int upx_lzma_decompress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
int method, const upx_compress_result_t *cresult) {
|
||||
assert(M_IS_LZMA(method));
|
||||
// see res->num_probs above
|
||||
COMPILE_TIME_ASSERT(sizeof(CProb) == 2)
|
||||
COMPILE_TIME_ASSERT(LZMA_BASE_SIZE == 1846)
|
||||
COMPILE_TIME_ASSERT(LZMA_LIT_SIZE == 768)
|
||||
|
||||
CLzmaDecoderState s;
|
||||
mem_clear(&s);
|
||||
SizeT src_out = 0, dst_out = 0;
|
||||
int r = UPX_E_ERROR;
|
||||
int rh;
|
||||
|
||||
// decode UPX-style properties (2 bytes)
|
||||
if (src_len < 3) {
|
||||
r = UPX_E_INPUT_OVERRUN;
|
||||
goto error;
|
||||
}
|
||||
s.Properties.pb = src[0] & 7;
|
||||
s.Properties.lp = (src[1] >> 4);
|
||||
s.Properties.lc = src[1] & 15;
|
||||
if (s.Properties.pb >= 5)
|
||||
goto error;
|
||||
if (s.Properties.lp >= 5)
|
||||
goto error;
|
||||
if (s.Properties.lc >= 9)
|
||||
goto error;
|
||||
// UPX extra stuff in first byte: 5 high bits convenience for stub decompressor
|
||||
if ((src[0] >> 3) != s.Properties.lc + s.Properties.lp)
|
||||
goto error;
|
||||
src += 2;
|
||||
src_len -= 2;
|
||||
|
||||
if (cresult) {
|
||||
assert(cresult->debug.method == method);
|
||||
assert(cresult->result_lzma.pos_bits == (unsigned) s.Properties.pb);
|
||||
assert(cresult->result_lzma.lit_pos_bits == (unsigned) s.Properties.lp);
|
||||
assert(cresult->result_lzma.lit_context_bits == (unsigned) s.Properties.lc);
|
||||
assert(cresult->result_lzma.num_probs == (unsigned) LzmaGetNumProbs(&s.Properties));
|
||||
const lzma_compress_result_t *res = &cresult->result_lzma;
|
||||
NO_printf("\nlzma_decompress config: %u %u %u %u %u\n", res->pos_bits, res->lit_pos_bits,
|
||||
res->lit_context_bits, res->dict_size, res->num_probs);
|
||||
UNUSED(res);
|
||||
}
|
||||
s.Probs = (CProb *) malloc(sizeof(CProb) * LzmaGetNumProbs(&s.Properties));
|
||||
if (!s.Probs) {
|
||||
r = UPX_E_OUT_OF_MEMORY;
|
||||
goto error;
|
||||
}
|
||||
rh = LzmaDecode(&s, src, src_len, &src_out, dst, *dst_len, &dst_out);
|
||||
assert(src_out <= src_len);
|
||||
assert(dst_out <= *dst_len);
|
||||
if (rh == 0) {
|
||||
r = UPX_E_OK;
|
||||
if (src_out != src_len)
|
||||
r = UPX_E_INPUT_NOT_CONSUMED;
|
||||
} else if (rh == LZMA_RESULT_INPUT_OVERRUN)
|
||||
r = UPX_E_INPUT_OVERRUN;
|
||||
else if (rh == LZMA_RESULT_OUTPUT_OVERRUN)
|
||||
r = UPX_E_OUTPUT_OVERRUN;
|
||||
|
||||
error:
|
||||
*dst_len = dst_out;
|
||||
free(s.Probs);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// test_overlap - see <ucl/ucl.h> for semantics
|
||||
**************************************************************************/
|
||||
|
||||
int upx_lzma_test_overlap(const upx_bytep buf, const upx_bytep tbuf, unsigned src_off,
|
||||
unsigned src_len, unsigned *dst_len, int method,
|
||||
const upx_compress_result_t *cresult) {
|
||||
assert(M_IS_LZMA(method));
|
||||
|
||||
MemBuffer b(src_off + src_len);
|
||||
memcpy(b + src_off, buf + src_off, src_len);
|
||||
unsigned saved_dst_len = *dst_len;
|
||||
int r = upx_lzma_decompress(raw_index_bytes(b, src_off, src_len), src_len,
|
||||
raw_bytes(b, *dst_len), dst_len, method, cresult);
|
||||
if (r != UPX_E_OK)
|
||||
return r;
|
||||
if (*dst_len != saved_dst_len)
|
||||
return UPX_E_ERROR;
|
||||
// NOTE: there is a very tiny possibility that decompression has
|
||||
// succeeded but the data is not restored correctly because of
|
||||
// in-place buffer overlapping, so we use an extra memcmp().
|
||||
if (tbuf != nullptr && memcmp(tbuf, b, *dst_len) != 0)
|
||||
return UPX_E_ERROR;
|
||||
return UPX_E_OK;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// misc
|
||||
**************************************************************************/
|
||||
|
||||
int upx_lzma_init(void) { return 0; }
|
||||
|
||||
const char *upx_lzma_version_string(void) { return "4.43"; }
|
||||
|
||||
/*************************************************************************
|
||||
// doctest checks
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("upx_lzma_decompress") {
|
||||
const byte *c_data;
|
||||
byte d_buf[16];
|
||||
unsigned d_len;
|
||||
int r;
|
||||
|
||||
c_data = (const byte *) "\x1a\x03\x00\x7f\xed\x3c\x00\x00\x00";
|
||||
d_len = 16;
|
||||
r = upx_lzma_decompress(c_data, 9, d_buf, &d_len, M_LZMA, nullptr);
|
||||
CHECK((r == 0 && d_len == 16));
|
||||
r = upx_lzma_decompress(c_data, 8, d_buf, &d_len, M_LZMA, nullptr);
|
||||
CHECK(r == UPX_E_INPUT_OVERRUN);
|
||||
d_len = 15;
|
||||
r = upx_lzma_decompress(c_data, 9, d_buf, &d_len, M_LZMA, nullptr);
|
||||
CHECK(r == UPX_E_OUTPUT_OVERRUN);
|
||||
UNUSED(r);
|
||||
}
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -0,0 +1,369 @@
|
||||
/* compress_ucl.cpp --
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#include "../conf.h"
|
||||
#include "compress.h"
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
static int convert_errno_from_ucl(int r) {
|
||||
switch (r) {
|
||||
case UCL_E_OK:
|
||||
return UPX_E_OK;
|
||||
case UCL_E_ERROR:
|
||||
return UPX_E_ERROR;
|
||||
case UCL_E_OUT_OF_MEMORY:
|
||||
return UPX_E_OUT_OF_MEMORY;
|
||||
case UCL_E_NOT_COMPRESSIBLE:
|
||||
return UPX_E_NOT_COMPRESSIBLE;
|
||||
case UCL_E_INPUT_OVERRUN:
|
||||
return UPX_E_INPUT_OVERRUN;
|
||||
case UCL_E_OUTPUT_OVERRUN:
|
||||
return UPX_E_OUTPUT_OVERRUN;
|
||||
case UCL_E_LOOKBEHIND_OVERRUN:
|
||||
return UPX_E_LOOKBEHIND_OVERRUN;
|
||||
case UCL_E_EOF_NOT_FOUND:
|
||||
return UPX_E_EOF_NOT_FOUND;
|
||||
case UCL_E_INPUT_NOT_CONSUMED:
|
||||
return UPX_E_INPUT_NOT_CONSUMED;
|
||||
case UCL_E_INVALID_ARGUMENT:
|
||||
return UPX_E_INVALID_ARGUMENT;
|
||||
// UCL extra:
|
||||
case UCL_E_OVERLAP_OVERRUN:
|
||||
return UPX_E_ERROR;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return UPX_E_ERROR;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
static void __UCL_CDECL wrap_nprogress_ucl(ucl_uint a, ucl_uint b, int state, ucl_voidp user) {
|
||||
if (state != -1 && state != 3)
|
||||
return;
|
||||
upx_callback_p cb = (upx_callback_p) user;
|
||||
if (cb && cb->nprogress)
|
||||
cb->nprogress(cb, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_ucl_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
upx_callback_p cb_parm, int method, int level,
|
||||
const upx_compress_config_t *cconf_parm, upx_compress_result_t *cresult) {
|
||||
int r;
|
||||
assert(level > 0);
|
||||
assert(cresult != nullptr);
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(ucl_compress_config_t) == sizeof(REAL_ucl_compress_config_t))
|
||||
|
||||
ucl_progress_callback_t cb;
|
||||
cb.callback = nullptr;
|
||||
cb.user = nullptr;
|
||||
if (cb_parm && cb_parm->nprogress) {
|
||||
cb.callback = wrap_nprogress_ucl;
|
||||
cb.user = cb_parm;
|
||||
}
|
||||
|
||||
ucl_compress_config_t cconf;
|
||||
cconf.reset();
|
||||
if (cconf_parm) {
|
||||
// cconf = cconf_parm->conf_ucl; // struct copy
|
||||
memcpy(&cconf, &cconf_parm->conf_ucl, sizeof(cconf));
|
||||
}
|
||||
|
||||
ucl_uint *const res = cresult->result_ucl.result;
|
||||
// assume no info available - fill in worst case results
|
||||
// res[0] = 1; // min_offset_found - NOT USED
|
||||
res[1] = src_len - 1; // max_offset_found
|
||||
// res[2] = 2; // min_match_found - NOT USED
|
||||
res[3] = src_len - 1; // max_match_found
|
||||
// res[4] = 1; // min_run_found - NOT USED
|
||||
res[5] = src_len; // max_run_found
|
||||
res[6] = 1; // first_offset_found
|
||||
// res[7] = 999999; // same_match_offsets_found - NOT USED
|
||||
|
||||
// prepare bit-buffer settings
|
||||
cconf.bb_endian = 0;
|
||||
cconf.bb_size = 0;
|
||||
if (method >= M_NRV2B_LE32 && method <= M_NRV2E_LE16) {
|
||||
static const upx_uint8_t sizes[3] = {32, 8, 16};
|
||||
cconf.bb_size = sizes[(method - M_NRV2B_LE32) % 3];
|
||||
} else {
|
||||
throwInternalError("unknown compression method");
|
||||
return UPX_E_ERROR;
|
||||
}
|
||||
|
||||
// optimize compression params
|
||||
if (level <= 3 && cconf.max_offset == UCL_UINT_MAX)
|
||||
cconf.max_offset = 8 * 1024 - 1;
|
||||
else if (level == 4 && cconf.max_offset == UCL_UINT_MAX)
|
||||
cconf.max_offset = 32 * 1024 - 1;
|
||||
|
||||
if M_IS_NRV2B (method)
|
||||
r = ucl_nrv2b_99_compress(src, src_len, dst, dst_len, &cb, level, &cconf, res);
|
||||
else if M_IS_NRV2D (method)
|
||||
r = ucl_nrv2d_99_compress(src, src_len, dst, dst_len, &cb, level, &cconf, res);
|
||||
else if M_IS_NRV2E (method)
|
||||
r = ucl_nrv2e_99_compress(src, src_len, dst, dst_len, &cb, level, &cconf, res);
|
||||
else {
|
||||
throwInternalError("unknown compression method");
|
||||
return UPX_E_ERROR;
|
||||
}
|
||||
|
||||
// make sure first_offset_found is set
|
||||
if (res[6] == 0)
|
||||
res[6] = 1;
|
||||
|
||||
return convert_errno_from_ucl(r);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_ucl_decompress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
int method, const upx_compress_result_t *cresult) {
|
||||
int r;
|
||||
|
||||
switch (method) {
|
||||
case M_NRV2B_8:
|
||||
r = ucl_nrv2b_decompress_safe_8(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2B_LE16:
|
||||
r = ucl_nrv2b_decompress_safe_le16(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2B_LE32:
|
||||
r = ucl_nrv2b_decompress_safe_le32(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2D_8:
|
||||
r = ucl_nrv2d_decompress_safe_8(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2D_LE16:
|
||||
r = ucl_nrv2d_decompress_safe_le16(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2D_LE32:
|
||||
r = ucl_nrv2d_decompress_safe_le32(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2E_8:
|
||||
r = ucl_nrv2e_decompress_safe_8(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2E_LE16:
|
||||
r = ucl_nrv2e_decompress_safe_le16(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2E_LE32:
|
||||
r = ucl_nrv2e_decompress_safe_le32(src, src_len, dst, dst_len, nullptr);
|
||||
break;
|
||||
default:
|
||||
throwInternalError("unknown decompression method");
|
||||
return UPX_E_ERROR;
|
||||
}
|
||||
|
||||
UNUSED(cresult);
|
||||
return convert_errno_from_ucl(r);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_ucl_test_overlap(const upx_bytep buf, const upx_bytep tbuf, unsigned src_off,
|
||||
unsigned src_len, unsigned *dst_len, int method,
|
||||
const upx_compress_result_t *cresult) {
|
||||
int r;
|
||||
UNUSED(tbuf); // not needed for UCL
|
||||
|
||||
switch (method) {
|
||||
case M_NRV2B_8:
|
||||
r = ucl_nrv2b_test_overlap_8(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2B_LE16:
|
||||
r = ucl_nrv2b_test_overlap_le16(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2B_LE32:
|
||||
r = ucl_nrv2b_test_overlap_le32(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2D_8:
|
||||
r = ucl_nrv2d_test_overlap_8(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2D_LE16:
|
||||
r = ucl_nrv2d_test_overlap_le16(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2D_LE32:
|
||||
r = ucl_nrv2d_test_overlap_le32(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2E_8:
|
||||
r = ucl_nrv2e_test_overlap_8(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2E_LE16:
|
||||
r = ucl_nrv2e_test_overlap_le16(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
case M_NRV2E_LE32:
|
||||
r = ucl_nrv2e_test_overlap_le32(buf, src_off, src_len, dst_len, nullptr);
|
||||
break;
|
||||
default:
|
||||
throwInternalError("unknown decompression method");
|
||||
return UPX_E_ERROR;
|
||||
}
|
||||
|
||||
UNUSED(cresult);
|
||||
return convert_errno_from_ucl(r);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// misc
|
||||
**************************************************************************/
|
||||
|
||||
extern "C" {
|
||||
static ucl_voidp __UCL_CDECL my_malloc(ucl_uint n) { return upx_calloc(n, 1); }
|
||||
static void __UCL_CDECL my_free(ucl_voidp p) { free(p); }
|
||||
} // extern "C"
|
||||
|
||||
int upx_ucl_init(void) {
|
||||
if (ucl_init() != UCL_E_OK)
|
||||
return -1;
|
||||
if (UCL_VERSION != ucl_version() || strcmp(UCL_VERSION_STRING, ucl_version_string()) != 0)
|
||||
return -2;
|
||||
ucl_set_malloc_hooks(my_malloc, my_free);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *upx_ucl_version_string(void) { return ucl_version_string(); }
|
||||
|
||||
unsigned upx_ucl_adler32(const void *buf, unsigned len, unsigned adler) {
|
||||
return ucl_adler32(adler, (const ucl_bytep) buf, len);
|
||||
}
|
||||
|
||||
#if 0 // UNUSED
|
||||
unsigned upx_ucl_crc32(const void *buf, unsigned len, unsigned crc) {
|
||||
return ucl_crc32(crc, (const ucl_bytep) buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
// doctest checks
|
||||
**************************************************************************/
|
||||
|
||||
#if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1
|
||||
|
||||
#include "../util/membuffer.h"
|
||||
|
||||
static bool check_ucl(const int method, const unsigned expected_c_len) {
|
||||
const unsigned u_len = 16384;
|
||||
const unsigned c_extra = 4096;
|
||||
MemBuffer u_buf, c_buf, d_buf;
|
||||
unsigned c_len, d_len;
|
||||
upx_compress_result_t cresult;
|
||||
int r;
|
||||
const int level = 3; // don't waste time
|
||||
|
||||
u_buf.alloc(u_len);
|
||||
memset(u_buf, 0, u_len);
|
||||
c_buf.allocForCompression(u_len, c_extra);
|
||||
d_buf.allocForDecompression(u_len);
|
||||
|
||||
c_len = c_buf.getSize() - c_extra;
|
||||
r = upx_ucl_compress(raw_bytes(u_buf, u_len), u_len, raw_index_bytes(c_buf, c_extra, c_len),
|
||||
&c_len, nullptr, method, level, NULL_cconf, &cresult);
|
||||
if (r != 0 || c_len != expected_c_len)
|
||||
return false;
|
||||
|
||||
d_len = d_buf.getSize();
|
||||
r = upx_ucl_decompress(raw_index_bytes(c_buf, c_extra, c_len), c_len, raw_bytes(d_buf, d_len),
|
||||
&d_len, method, nullptr);
|
||||
if (r != 0 || d_len != u_len || memcmp(u_buf, d_buf, u_len) != 0)
|
||||
return false;
|
||||
|
||||
d_len = u_len - 1;
|
||||
r = upx_ucl_decompress(raw_index_bytes(c_buf, c_extra, c_len), c_len, raw_bytes(d_buf, d_len),
|
||||
&d_len, method, nullptr);
|
||||
if (r == 0)
|
||||
return false;
|
||||
|
||||
// TODO: rewrite Packer::findOverlapOverhead() so that we can test it here
|
||||
// unsigned x_len = d_len;
|
||||
// r = upx_ucl_test_overlap(c_buf, u_buf, c_extra, c_len, &x_len, method, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_CASE("compress_ucl") {
|
||||
CHECK(check_ucl(M_NRV2B_8, 34));
|
||||
CHECK(check_ucl(M_NRV2B_LE16, 34));
|
||||
CHECK(check_ucl(M_NRV2B_LE32, 34));
|
||||
CHECK(check_ucl(M_NRV2D_8, 32));
|
||||
CHECK(check_ucl(M_NRV2D_LE16, 32));
|
||||
CHECK(check_ucl(M_NRV2D_LE32, 34));
|
||||
CHECK(check_ucl(M_NRV2E_8, 32));
|
||||
CHECK(check_ucl(M_NRV2E_LE16, 32));
|
||||
CHECK(check_ucl(M_NRV2E_LE32, 34));
|
||||
}
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
TEST_CASE("upx_ucl_decompress") {
|
||||
const byte *c_data;
|
||||
byte d_buf[16];
|
||||
unsigned d_len;
|
||||
int r;
|
||||
|
||||
c_data = (const byte *) "\x92\xff\x10\x00\x00\x00\x00\x00\x48\xff";
|
||||
d_len = 16;
|
||||
r = upx_ucl_decompress(c_data, 10, d_buf, &d_len, M_NRV2B_8, nullptr);
|
||||
CHECK((r == 0 && d_len == 16));
|
||||
r = upx_ucl_decompress(c_data, 9, d_buf, &d_len, M_NRV2B_8, nullptr);
|
||||
CHECK(r == UPX_E_INPUT_OVERRUN);
|
||||
d_len = 15;
|
||||
r = upx_ucl_decompress(c_data, 10, d_buf, &d_len, M_NRV2B_8, nullptr);
|
||||
CHECK(r == UPX_E_OUTPUT_OVERRUN);
|
||||
|
||||
c_data = (const byte *) "\x92\xff\x10\x92\x49\x24\x92\xa0\xff";
|
||||
d_len = 16;
|
||||
r = upx_ucl_decompress(c_data, 9, d_buf, &d_len, M_NRV2D_8, nullptr);
|
||||
CHECK((r == 0 && d_len == 16));
|
||||
r = upx_ucl_decompress(c_data, 8, d_buf, &d_len, M_NRV2D_8, nullptr);
|
||||
CHECK(r == UPX_E_INPUT_OVERRUN);
|
||||
d_len = 15;
|
||||
r = upx_ucl_decompress(c_data, 9, d_buf, &d_len, M_NRV2D_8, nullptr);
|
||||
CHECK(r == UPX_E_OUTPUT_OVERRUN);
|
||||
|
||||
c_data = (const byte *) "\x90\xff\xb0\x92\x49\x24\x92\xa0\xff";
|
||||
d_len = 16;
|
||||
r = upx_ucl_decompress(c_data, 9, d_buf, &d_len, M_NRV2E_8, nullptr);
|
||||
CHECK((r == 0 && d_len == 16));
|
||||
r = upx_ucl_decompress(c_data, 8, d_buf, &d_len, M_NRV2E_8, nullptr);
|
||||
CHECK(r == UPX_E_INPUT_OVERRUN);
|
||||
d_len = 15;
|
||||
r = upx_ucl_decompress(c_data, 9, d_buf, &d_len, M_NRV2E_8, nullptr);
|
||||
CHECK(r == UPX_E_OUTPUT_OVERRUN);
|
||||
UNUSED(r);
|
||||
}
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -0,0 +1,311 @@
|
||||
/* compress_zlib.cpp --
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#include "../conf.h"
|
||||
#include "compress.h"
|
||||
#include "../util/membuffer.h"
|
||||
// NOLINTBEGIN(clang-analyzer-optin.performance.Padding)
|
||||
#define ZLIB_CONST 1
|
||||
#include <zlib/zlib.h>
|
||||
#include <zlib/deflate.h>
|
||||
// NOLINTEND(clang-analyzer-optin.performance.Padding)
|
||||
|
||||
void zlib_compress_config_t::reset() noexcept {
|
||||
mem_clear(this);
|
||||
mem_level.reset();
|
||||
window_bits.reset();
|
||||
strategy.reset();
|
||||
}
|
||||
|
||||
static int convert_errno_from_zlib(int zr) {
|
||||
switch (zr) {
|
||||
case Z_OK:
|
||||
return UPX_E_OK;
|
||||
// positive values
|
||||
case Z_STREAM_END:
|
||||
return UPX_E_ERROR;
|
||||
case Z_NEED_DICT:
|
||||
return UPX_E_ERROR;
|
||||
// negative values
|
||||
case Z_ERRNO:
|
||||
return UPX_E_ERROR;
|
||||
case Z_STREAM_ERROR:
|
||||
return UPX_E_ERROR;
|
||||
case Z_DATA_ERROR:
|
||||
return UPX_E_ERROR;
|
||||
case Z_MEM_ERROR:
|
||||
return UPX_E_OUT_OF_MEMORY;
|
||||
case Z_BUF_ERROR:
|
||||
return UPX_E_OUTPUT_OVERRUN;
|
||||
case Z_VERSION_ERROR:
|
||||
return UPX_E_ERROR;
|
||||
case -7: // UPX extra
|
||||
return UPX_E_INPUT_OVERRUN;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return UPX_E_ERROR;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_zlib_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
upx_callback_p cb_parm, int method, int level,
|
||||
const upx_compress_config_t *cconf_parm, upx_compress_result_t *cresult) {
|
||||
assert(method == M_DEFLATE);
|
||||
assert(level > 0);
|
||||
assert(cresult != nullptr);
|
||||
UNUSED(cb_parm);
|
||||
int r = UPX_E_ERROR;
|
||||
int zr;
|
||||
const zlib_compress_config_t *const lcconf = cconf_parm ? &cconf_parm->conf_zlib : nullptr;
|
||||
zlib_compress_result_t *const res = &cresult->result_zlib;
|
||||
|
||||
if (level == 10)
|
||||
level = 9;
|
||||
|
||||
zlib_compress_config_t::mem_level_t mem_level;
|
||||
zlib_compress_config_t::window_bits_t window_bits;
|
||||
zlib_compress_config_t::strategy_t strategy;
|
||||
// cconf overrides
|
||||
if (lcconf) {
|
||||
oassign(mem_level, lcconf->mem_level);
|
||||
oassign(window_bits, lcconf->window_bits);
|
||||
oassign(strategy, lcconf->strategy);
|
||||
}
|
||||
|
||||
res->dummy = 0;
|
||||
|
||||
z_stream s;
|
||||
s.zalloc = (alloc_func) nullptr;
|
||||
s.zfree = (free_func) nullptr;
|
||||
s.next_in = src;
|
||||
s.avail_in = src_len;
|
||||
s.next_out = dst;
|
||||
s.avail_out = *dst_len;
|
||||
s.total_in = s.total_out = 0;
|
||||
|
||||
zr = (int) deflateInit2(&s, level, Z_DEFLATED, 0 - (int) window_bits, mem_level, strategy);
|
||||
if (zr != Z_OK)
|
||||
goto error;
|
||||
assert(s.state->level == level);
|
||||
zr = deflate(&s, Z_FINISH);
|
||||
if (zr != Z_STREAM_END)
|
||||
goto error;
|
||||
zr = deflateEnd(&s);
|
||||
if (zr != Z_OK)
|
||||
goto error;
|
||||
r = UPX_E_OK;
|
||||
goto done;
|
||||
error:
|
||||
(void) deflateEnd(&s);
|
||||
r = convert_errno_from_zlib(zr);
|
||||
if (r == UPX_E_OK)
|
||||
r = UPX_E_ERROR;
|
||||
done:
|
||||
if (r == UPX_E_OK) {
|
||||
if (s.avail_in != 0 || s.total_in != src_len)
|
||||
r = UPX_E_ERROR;
|
||||
}
|
||||
assert(s.total_in <= src_len);
|
||||
assert(s.total_out <= *dst_len);
|
||||
*dst_len = s.total_out;
|
||||
return r;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_zlib_decompress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
int method, const upx_compress_result_t *cresult) {
|
||||
assert(method == M_DEFLATE);
|
||||
UNUSED(method);
|
||||
UNUSED(cresult);
|
||||
int r = UPX_E_ERROR;
|
||||
int zr;
|
||||
|
||||
z_stream s;
|
||||
s.zalloc = (alloc_func) nullptr;
|
||||
s.zfree = (free_func) nullptr;
|
||||
s.next_in = src;
|
||||
s.avail_in = src_len;
|
||||
s.next_out = dst;
|
||||
s.avail_out = *dst_len;
|
||||
s.total_in = s.total_out = 0;
|
||||
|
||||
zr = inflateInit2(&s, -15);
|
||||
if (zr != Z_OK)
|
||||
goto error;
|
||||
zr = inflate(&s, Z_FINISH);
|
||||
if (zr != Z_STREAM_END) {
|
||||
if (zr == Z_BUF_ERROR && s.avail_in == 0)
|
||||
zr = -7; // UPX extra
|
||||
goto error;
|
||||
}
|
||||
zr = inflateEnd(&s);
|
||||
if (zr != Z_OK)
|
||||
goto error;
|
||||
r = UPX_E_OK;
|
||||
goto done;
|
||||
error:
|
||||
(void) inflateEnd(&s);
|
||||
r = convert_errno_from_zlib(zr);
|
||||
if (r == UPX_E_OK)
|
||||
r = UPX_E_ERROR;
|
||||
done:
|
||||
if (r == UPX_E_OK) {
|
||||
if (s.avail_in != 0 || s.total_in != src_len)
|
||||
r = UPX_E_INPUT_NOT_CONSUMED;
|
||||
}
|
||||
assert(s.total_in <= src_len);
|
||||
assert(s.total_out <= *dst_len);
|
||||
*dst_len = s.total_out;
|
||||
return r;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// test_overlap - see <ucl/ucl.h> for semantics
|
||||
**************************************************************************/
|
||||
|
||||
int upx_zlib_test_overlap(const upx_bytep buf, const upx_bytep tbuf, unsigned src_off,
|
||||
unsigned src_len, unsigned *dst_len, int method,
|
||||
const upx_compress_result_t *cresult) {
|
||||
assert(method == M_DEFLATE);
|
||||
|
||||
MemBuffer b(src_off + src_len);
|
||||
memcpy(b + src_off, buf + src_off, src_len);
|
||||
unsigned saved_dst_len = *dst_len;
|
||||
int r = upx_zlib_decompress(raw_index_bytes(b, src_off, src_len), src_len,
|
||||
raw_bytes(b, *dst_len), dst_len, method, cresult);
|
||||
if (r != UPX_E_OK)
|
||||
return r;
|
||||
if (*dst_len != saved_dst_len)
|
||||
return UPX_E_ERROR;
|
||||
// NOTE: there is a very tiny possibility that decompression has
|
||||
// succeeded but the data is not restored correctly because of
|
||||
// in-place buffer overlapping, so we use an extra memcmp().
|
||||
if (tbuf != nullptr && memcmp(tbuf, b, *dst_len) != 0)
|
||||
return UPX_E_ERROR;
|
||||
return UPX_E_OK;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// misc
|
||||
**************************************************************************/
|
||||
|
||||
int upx_zlib_init(void) {
|
||||
if (strcmp(ZLIB_VERSION, zlibVersion()) != 0)
|
||||
return -2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *upx_zlib_version_string(void) { return zlibVersion(); }
|
||||
|
||||
#if 0 // UNUSED
|
||||
unsigned upx_zlib_adler32(const void *buf, unsigned len, unsigned adler) {
|
||||
return adler32(adler, (const Bytef *) buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 // UNUSED
|
||||
unsigned upx_zlib_crc32(const void *buf, unsigned len, unsigned crc) {
|
||||
return crc32(crc, (const Bytef *) buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
// doctest checks
|
||||
**************************************************************************/
|
||||
|
||||
#if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1
|
||||
|
||||
static bool check_zlib(const int method, const int level, const unsigned expected_c_len) {
|
||||
const unsigned u_len = 16384;
|
||||
const unsigned c_extra = 4096;
|
||||
MemBuffer u_buf, c_buf, d_buf;
|
||||
unsigned c_len, d_len;
|
||||
upx_compress_result_t cresult;
|
||||
int r;
|
||||
|
||||
u_buf.alloc(u_len);
|
||||
memset(u_buf, 0, u_len);
|
||||
c_buf.allocForCompression(u_len, c_extra);
|
||||
d_buf.allocForDecompression(u_len);
|
||||
|
||||
c_len = c_buf.getSize() - c_extra;
|
||||
r = upx_zlib_compress(raw_bytes(u_buf, u_len), u_len, raw_index_bytes(c_buf, c_extra, c_len),
|
||||
&c_len, nullptr, method, level, NULL_cconf, &cresult);
|
||||
if (r != 0 || c_len != expected_c_len)
|
||||
return false;
|
||||
|
||||
d_len = d_buf.getSize();
|
||||
r = upx_zlib_decompress(raw_index_bytes(c_buf, c_extra, c_len), c_len, raw_bytes(d_buf, d_len),
|
||||
&d_len, method, nullptr);
|
||||
if (r != 0 || d_len != u_len || memcmp(u_buf, d_buf, u_len) != 0)
|
||||
return false;
|
||||
|
||||
d_len = u_len - 1;
|
||||
r = upx_zlib_decompress(raw_index_bytes(c_buf, c_extra, c_len), c_len, raw_bytes(d_buf, d_len),
|
||||
&d_len, method, nullptr);
|
||||
if (r == 0)
|
||||
return false;
|
||||
|
||||
// TODO: rewrite Packer::findOverlapOverhead() so that we can test it here
|
||||
// unsigned x_len = d_len;
|
||||
// r = upx_zlib_test_overlap(c_buf, u_buf, c_extra, c_len, &x_len, method, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_CASE("compress_zlib") {
|
||||
CHECK(check_zlib(M_DEFLATE, 1, 89));
|
||||
CHECK(check_zlib(M_DEFLATE, 3, 89));
|
||||
CHECK(check_zlib(M_DEFLATE, 5, 33));
|
||||
}
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
TEST_CASE("upx_zlib_decompress") {
|
||||
const byte *c_data;
|
||||
byte d_buf[16];
|
||||
unsigned d_len;
|
||||
int r;
|
||||
|
||||
c_data = (const byte *) "\xfb\xff\x1f\x15\x00\x00";
|
||||
d_len = 16;
|
||||
r = upx_zlib_decompress(c_data, 6, d_buf, &d_len, M_DEFLATE, nullptr);
|
||||
CHECK((r == 0 && d_len == 16));
|
||||
r = upx_zlib_decompress(c_data, 5, d_buf, &d_len, M_DEFLATE, nullptr);
|
||||
CHECK(r == UPX_E_INPUT_OVERRUN);
|
||||
d_len = 15;
|
||||
r = upx_zlib_decompress(c_data, 6, d_buf, &d_len, M_DEFLATE, nullptr);
|
||||
CHECK(r == UPX_E_OUTPUT_OVERRUN);
|
||||
UNUSED(r);
|
||||
}
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -0,0 +1,228 @@
|
||||
/* compress_zstd.cpp --
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#include "../conf.h"
|
||||
|
||||
void zstd_compress_config_t::reset() noexcept { mem_clear(this); }
|
||||
|
||||
#if WITH_ZSTD
|
||||
#include "compress.h"
|
||||
#include "../util/membuffer.h"
|
||||
#include <zstd/lib/zstd.h>
|
||||
#include <zstd/lib/zstd_errors.h>
|
||||
#include <zstd/lib/compress/hist.h>
|
||||
|
||||
static int convert_errno_from_zstd(size_t zr) {
|
||||
const ZSTD_ErrorCode ze = ZSTD_getErrorCode(zr);
|
||||
switch (ze) {
|
||||
case ZSTD_error_memory_allocation:
|
||||
return UPX_E_OUT_OF_MEMORY;
|
||||
case ZSTD_error_srcSize_wrong:
|
||||
return UPX_E_INPUT_OVERRUN;
|
||||
case ZSTD_error_dstSize_tooSmall:
|
||||
return UPX_E_OUTPUT_OVERRUN;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return UPX_E_ERROR;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// TODO later: use advanced compression API for compression finetuning
|
||||
**************************************************************************/
|
||||
|
||||
int upx_zstd_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
upx_callback_p cb_parm, int method, int level,
|
||||
const upx_compress_config_t *cconf_parm, upx_compress_result_t *cresult) {
|
||||
assert(method == M_ZSTD);
|
||||
assert(level > 0);
|
||||
assert(cresult != nullptr);
|
||||
UNUSED(cb_parm);
|
||||
int r = UPX_E_ERROR;
|
||||
size_t zr;
|
||||
const zstd_compress_config_t *const lcconf = cconf_parm ? &cconf_parm->conf_zstd : nullptr;
|
||||
zstd_compress_result_t *const res = &cresult->result_zstd;
|
||||
|
||||
// TODO later: map level 1..10 to zstd-level 1..22
|
||||
if (level == 10)
|
||||
level = 22;
|
||||
|
||||
// cconf overrides
|
||||
if (lcconf) {
|
||||
UNUSED(lcconf);
|
||||
}
|
||||
|
||||
res->dummy = 0;
|
||||
|
||||
zr = ZSTD_compress(dst, *dst_len, src, src_len, level);
|
||||
if (ZSTD_isError(zr)) {
|
||||
*dst_len = 0; // TODO ???
|
||||
r = convert_errno_from_zstd(zr);
|
||||
assert(r != UPX_E_OK);
|
||||
} else {
|
||||
assert(zr <= *dst_len);
|
||||
*dst_len = (unsigned) zr;
|
||||
r = UPX_E_OK;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
int upx_zstd_decompress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
int method, const upx_compress_result_t *cresult) {
|
||||
assert(method == M_ZSTD);
|
||||
UNUSED(method);
|
||||
UNUSED(cresult);
|
||||
int r = UPX_E_ERROR;
|
||||
size_t zr;
|
||||
|
||||
zr = ZSTD_decompress(dst, *dst_len, src, src_len);
|
||||
if (ZSTD_isError(zr)) {
|
||||
*dst_len = 0; // TODO ???
|
||||
r = convert_errno_from_zstd(zr);
|
||||
assert(r != UPX_E_OK);
|
||||
} else {
|
||||
assert(zr <= *dst_len);
|
||||
*dst_len = (unsigned) zr;
|
||||
r = UPX_E_OK;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// test_overlap - see <ucl/ucl.h> for semantics
|
||||
**************************************************************************/
|
||||
|
||||
int upx_zstd_test_overlap(const upx_bytep buf, const upx_bytep tbuf, unsigned src_off,
|
||||
unsigned src_len, unsigned *dst_len, int method,
|
||||
const upx_compress_result_t *cresult) {
|
||||
assert(method == M_ZSTD);
|
||||
|
||||
MemBuffer b(src_off + src_len);
|
||||
memcpy(b + src_off, buf + src_off, src_len);
|
||||
unsigned saved_dst_len = *dst_len;
|
||||
int r = upx_zstd_decompress(raw_index_bytes(b, src_off, src_len), src_len,
|
||||
raw_bytes(b, *dst_len), dst_len, method, cresult);
|
||||
if (r != UPX_E_OK)
|
||||
return r;
|
||||
if (*dst_len != saved_dst_len)
|
||||
return UPX_E_ERROR;
|
||||
// NOTE: there is a very tiny possibility that decompression has
|
||||
// succeeded but the data is not restored correctly because of
|
||||
// in-place buffer overlapping, so we use an extra memcmp().
|
||||
if (tbuf != nullptr && memcmp(tbuf, b, *dst_len) != 0)
|
||||
return UPX_E_ERROR;
|
||||
return UPX_E_OK;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// misc
|
||||
**************************************************************************/
|
||||
|
||||
int upx_zstd_init(void) {
|
||||
if (strcmp(ZSTD_VERSION_STRING, ZSTD_versionString()) != 0)
|
||||
return -2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *upx_zstd_version_string(void) { return ZSTD_VERSION_STRING; }
|
||||
|
||||
/*************************************************************************
|
||||
// doctest checks
|
||||
**************************************************************************/
|
||||
|
||||
#if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1
|
||||
|
||||
static bool check_zstd(const int method, const int level, const unsigned expected_c_len) {
|
||||
const unsigned u_len = 16384;
|
||||
const unsigned c_extra = 4096;
|
||||
MemBuffer u_buf, c_buf, d_buf;
|
||||
unsigned c_len, d_len;
|
||||
upx_compress_result_t cresult;
|
||||
int r;
|
||||
|
||||
u_buf.alloc(u_len);
|
||||
memset(u_buf, 0, u_len);
|
||||
c_buf.allocForCompression(u_len, c_extra);
|
||||
d_buf.allocForDecompression(u_len);
|
||||
|
||||
c_len = c_buf.getSize() - c_extra;
|
||||
r = upx_zstd_compress(raw_bytes(u_buf, u_len), u_len, raw_index_bytes(c_buf, c_extra, c_len),
|
||||
&c_len, nullptr, method, level, NULL_cconf, &cresult);
|
||||
if (r != 0 || c_len != expected_c_len)
|
||||
return false;
|
||||
|
||||
d_len = d_buf.getSize();
|
||||
r = upx_zstd_decompress(raw_index_bytes(c_buf, c_extra, c_len), c_len, raw_bytes(d_buf, d_len),
|
||||
&d_len, method, nullptr);
|
||||
if (r != 0 || d_len != u_len || memcmp(u_buf, d_buf, u_len) != 0)
|
||||
return false;
|
||||
|
||||
d_len = u_len - 1;
|
||||
r = upx_zstd_decompress(raw_index_bytes(c_buf, c_extra, c_len), c_len, raw_bytes(d_buf, d_len),
|
||||
&d_len, method, nullptr);
|
||||
if (r == 0)
|
||||
return false;
|
||||
|
||||
// TODO: rewrite Packer::findOverlapOverhead() so that we can test it here
|
||||
// unsigned x_len = d_len;
|
||||
// r = upx_zstd_test_overlap(c_buf, u_buf, c_extra, c_len, &x_len, method, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_CASE("compress_zstd") {
|
||||
CHECK(check_zstd(M_ZSTD, 1, 19));
|
||||
CHECK(check_zstd(M_ZSTD, 3, 19));
|
||||
CHECK(check_zstd(M_ZSTD, 5, 19));
|
||||
}
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
TEST_CASE("upx_zstd_decompress") {
|
||||
const byte *c_data;
|
||||
byte d_buf[32];
|
||||
unsigned d_len;
|
||||
int r;
|
||||
|
||||
c_data = (const byte *) "\x28\xb5\x2f\xfd\x20\x20\x3d\x00\x00\x08\xff\x01\x00\x34\x4e\x08";
|
||||
d_len = 32;
|
||||
r = upx_zstd_decompress(c_data, 16, d_buf, &d_len, M_ZSTD, nullptr);
|
||||
CHECK((r == 0 && d_len == 32));
|
||||
r = upx_zstd_decompress(c_data, 15, d_buf, &d_len, M_ZSTD, nullptr);
|
||||
CHECK(r == UPX_E_INPUT_OVERRUN);
|
||||
d_len = 31;
|
||||
r = upx_zstd_decompress(c_data, 16, d_buf, &d_len, M_ZSTD, nullptr);
|
||||
CHECK(r == UPX_E_OUTPUT_OVERRUN);
|
||||
}
|
||||
|
||||
#endif // WITH_ZSTD
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
@@ -1,528 +0,0 @@
|
||||
/* compress_lzma.cpp --
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2017 Laszlo Molnar
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "conf.h"
|
||||
#include "compress.h"
|
||||
#include "mem.h"
|
||||
|
||||
#if (ACC_CC_MSC)
|
||||
# pragma warning(disable: 4456) // -Wno-shadow
|
||||
#endif
|
||||
#if (ACC_CC_MSC && (_MSC_VER < 1900))
|
||||
# pragma warning(disable: 4127) // warning C4127: conditional expression is constant
|
||||
#endif
|
||||
#if (ACC_CC_INTELC_GNUC)
|
||||
# pragma warning(error: 424) // #424: extra ";" ignored
|
||||
#endif
|
||||
|
||||
|
||||
void lzma_compress_config_t::reset()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
|
||||
pos_bits.reset();
|
||||
lit_pos_bits.reset();
|
||||
lit_context_bits.reset();
|
||||
dict_size.reset();
|
||||
fast_mode = 2;
|
||||
num_fast_bytes.reset();
|
||||
match_finder_cycles = 0;
|
||||
|
||||
max_num_probs = 0;
|
||||
}
|
||||
|
||||
|
||||
// INFO: the LZMA SDK is covered by a permissive license which allows
|
||||
// using unmodified LZMA source code in UPX and the UPX stubs.
|
||||
// See SPECIAL EXCEPTION below.
|
||||
//
|
||||
// Quoting from lzma-4.43/lzma.txt:
|
||||
//
|
||||
// LICENSE
|
||||
// -------
|
||||
//
|
||||
// LZMA SDK is available under any of the following licenses:
|
||||
//
|
||||
// 1) GNU Lesser General Public License (GNU LGPL)
|
||||
// 2) Common Public License (CPL)
|
||||
// 3) Simplified license for unmodified code (read SPECIAL EXCEPTION)
|
||||
// 4) Proprietary license
|
||||
//
|
||||
// It means that you can select one of these four options and follow rules
|
||||
// of that license.
|
||||
//
|
||||
// 1,2) GNU LGPL and CPL licenses are pretty similar and both these
|
||||
// licenses are classified as
|
||||
// - "Free software licenses" at http://www.gnu.org/
|
||||
// - "OSI-approved" at http://www.opensource.org/
|
||||
//
|
||||
// 3) SPECIAL EXCEPTION
|
||||
//
|
||||
// Igor Pavlov, as the author of this code, expressly permits you
|
||||
// to statically or dynamically link your code (or bind by name)
|
||||
// to the files from LZMA SDK without subjecting your linked
|
||||
// code to the terms of the CPL or GNU LGPL.
|
||||
// Any modifications or additions to files from LZMA SDK, however,
|
||||
// are subject to the GNU LGPL or CPL terms.
|
||||
//
|
||||
// SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code,
|
||||
// while you keep LZMA SDK code unmodified.
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// compress defaults
|
||||
**************************************************************************/
|
||||
|
||||
static int prepare(lzma_compress_result_t *res,
|
||||
unsigned src_len, int method, int level,
|
||||
const lzma_compress_config_t *lcconf)
|
||||
{
|
||||
// setup defaults
|
||||
res->pos_bits = 2; // 0 .. 4
|
||||
res->lit_pos_bits = 0; // 0 .. 4
|
||||
res->lit_context_bits = 3; // 0 .. 8
|
||||
res->dict_size = 4 * 1024 * 1024; // 1 .. 2**30
|
||||
res->fast_mode = 2;
|
||||
res->num_fast_bytes = 64; // 5 .. 273
|
||||
res->match_finder_cycles = 0;
|
||||
// UPX overrides
|
||||
res->pos_bits = lzma_compress_config_t::pos_bits_t::default_value_c;
|
||||
res->lit_pos_bits = lzma_compress_config_t::lit_pos_bits_t::default_value_c;
|
||||
res->lit_context_bits = lzma_compress_config_t::lit_context_bits_t::default_value_c;
|
||||
res->dict_size = lzma_compress_config_t::dict_size_t::default_value_c;
|
||||
res->num_fast_bytes = lzma_compress_config_t::num_fast_bytes_t::default_value_c;
|
||||
// method overrides
|
||||
if (method >= 0x100) {
|
||||
res->pos_bits = (method >> 16) & 15;
|
||||
res->lit_pos_bits = (method >> 12) & 15;
|
||||
res->lit_context_bits = (method >> 8) & 15;
|
||||
}
|
||||
#if 0
|
||||
// DEBUG - set sizes so that we use a maxmimum amount of stack.
|
||||
// These settings cause res->num_probs == 3147574, i.e. we will
|
||||
// need about 6 MiB of stack during runtime decompression.
|
||||
res->lit_pos_bits = 4;
|
||||
res->lit_context_bits = 8;
|
||||
#endif
|
||||
|
||||
// TODO: tune these settings according to level
|
||||
switch (level)
|
||||
{
|
||||
case 1:
|
||||
res->dict_size = 256 * 1024;
|
||||
res->fast_mode = 0;
|
||||
res->num_fast_bytes = 8;
|
||||
break;
|
||||
case 2:
|
||||
res->dict_size = 256 * 1024;
|
||||
res->fast_mode = 0;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
case 7:
|
||||
break;
|
||||
case 8:
|
||||
break;
|
||||
case 9:
|
||||
res->dict_size = 8 * 1024 * 1024;
|
||||
break;
|
||||
case 10:
|
||||
res->dict_size = src_len;
|
||||
break;
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
|
||||
// cconf overrides
|
||||
if (lcconf)
|
||||
{
|
||||
oassign(res->pos_bits, lcconf->pos_bits);
|
||||
oassign(res->lit_pos_bits, lcconf->lit_pos_bits);
|
||||
oassign(res->lit_context_bits, lcconf->lit_context_bits);
|
||||
oassign(res->dict_size, lcconf->dict_size);
|
||||
oassign(res->num_fast_bytes, lcconf->num_fast_bytes);
|
||||
}
|
||||
|
||||
// limit dictionary size
|
||||
if (res->dict_size > src_len)
|
||||
res->dict_size = src_len;
|
||||
|
||||
// limit num_probs
|
||||
if (lcconf && lcconf->max_num_probs)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
unsigned n = 1846 + (768 << (res->lit_context_bits + res->lit_pos_bits));
|
||||
if (n <= lcconf->max_num_probs)
|
||||
break;
|
||||
if (res->lit_pos_bits > res->lit_context_bits)
|
||||
{
|
||||
if (res->lit_pos_bits == 0)
|
||||
goto error;
|
||||
res->lit_pos_bits -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (res->lit_context_bits == 0)
|
||||
goto error;
|
||||
res->lit_context_bits -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res->num_probs = 1846 + (768 << (res->lit_context_bits + res->lit_pos_bits));
|
||||
//printf("\nlzma_compress config: %u %u %u %u %u\n", res->pos_bits, res->lit_pos_bits, res->lit_context_bits, res->dict_size, res->num_probs);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// compress - cruft because of pseudo-COM layer
|
||||
**************************************************************************/
|
||||
|
||||
#undef MSDOS
|
||||
#undef OS2
|
||||
#undef _WIN32
|
||||
#undef _WIN32_WCE
|
||||
#undef COMPRESS_MF_MT
|
||||
#undef _NO_EXCEPTIONS
|
||||
#include "C/Common/MyInitGuid.h"
|
||||
//#include "C/7zip/Compress/LZMA/LZMADecoder.h"
|
||||
#include "C/7zip/Compress/LZMA/LZMAEncoder.h"
|
||||
|
||||
namespace MyLzma {
|
||||
|
||||
struct InStream: public ISequentialInStream, public CMyUnknownImp
|
||||
{
|
||||
virtual ~InStream() { }
|
||||
MY_UNKNOWN_IMP
|
||||
const Byte *b_buf; size_t b_size; size_t b_pos;
|
||||
void Init(const Byte *data, size_t size) {
|
||||
b_buf = data; b_size = size; b_pos = 0;
|
||||
}
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
STDMETHODIMP InStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
size_t remain = b_size - b_pos;
|
||||
if (size > remain) size = (UInt32) remain;
|
||||
memmove(data, b_buf + b_pos, size);
|
||||
b_pos += size;
|
||||
if (processedSize != NULL) *processedSize = size;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
struct OutStream : public ISequentialOutStream, public CMyUnknownImp
|
||||
{
|
||||
virtual ~OutStream() { }
|
||||
MY_UNKNOWN_IMP
|
||||
Byte *b_buf; size_t b_size; size_t b_pos; bool overflow;
|
||||
void Init(Byte *data, size_t size) {
|
||||
b_buf = data; b_size = size; b_pos = 0; overflow = false;
|
||||
}
|
||||
HRESULT WriteByte(Byte c) {
|
||||
if (b_pos >= b_size) { overflow = true; return E_FAIL; }
|
||||
b_buf[b_pos++] = c;
|
||||
return S_OK;
|
||||
}
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
STDMETHODIMP OutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
size_t remain = b_size - b_pos;
|
||||
if (size > remain) size = (UInt32) remain, overflow = true;
|
||||
memmove(b_buf + b_pos, data, size);
|
||||
b_pos += size;
|
||||
if (processedSize != NULL) *processedSize = size;
|
||||
return overflow ? E_FAIL : S_OK;
|
||||
}
|
||||
|
||||
struct ProgressInfo : public ICompressProgressInfo, public CMyUnknownImp
|
||||
{
|
||||
virtual ~ProgressInfo() { }
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
upx_callback_p cb;
|
||||
};
|
||||
|
||||
STDMETHODIMP ProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
|
||||
{
|
||||
if (cb && cb->nprogress)
|
||||
cb->nprogress(cb, (unsigned) *inSize, (unsigned) *outSize);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "C/Common/Alloc.cpp"
|
||||
#include "C/Common/CRC.cpp"
|
||||
//#include "C/7zip/Common/InBuffer.cpp"
|
||||
#include "C/7zip/Common/OutBuffer.cpp"
|
||||
#include "C/7zip/Common/StreamUtils.cpp"
|
||||
#include "C/7zip/Compress/LZ/LZInWindow.cpp"
|
||||
//#include "C/7zip/Compress/LZ/LZOutWindow.cpp"
|
||||
//#include "C/7zip/Compress/LZMA/LZMADecoder.cpp"
|
||||
#include "C/7zip/Compress/LZMA/LZMAEncoder.cpp"
|
||||
#include "C/7zip/Compress/RangeCoder/RangeCoderBit.cpp"
|
||||
#undef RC_NORMALIZE
|
||||
|
||||
|
||||
int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
||||
upx_bytep dst, unsigned* dst_len,
|
||||
upx_callback_p cb,
|
||||
int method, int level,
|
||||
const upx_compress_config_t *cconf_parm,
|
||||
upx_compress_result_t *cresult )
|
||||
{
|
||||
assert(M_IS_LZMA(method));
|
||||
assert(level > 0); assert(cresult != NULL);
|
||||
|
||||
int r = UPX_E_ERROR;
|
||||
HRESULT rh;
|
||||
const lzma_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_lzma : NULL;
|
||||
lzma_compress_result_t *res = &cresult->result_lzma;
|
||||
|
||||
MyLzma::InStream is; is.AddRef();
|
||||
MyLzma::OutStream os; os.AddRef();
|
||||
is.Init(src, src_len);
|
||||
os.Init(dst, *dst_len);
|
||||
|
||||
MyLzma::ProgressInfo progress; progress.AddRef();
|
||||
progress.cb = cb;
|
||||
|
||||
NCompress::NLZMA::CEncoder enc;
|
||||
const PROPID propIDs[8] = {
|
||||
NCoderPropID::kPosStateBits, // 0 pb _posStateBits(2)
|
||||
NCoderPropID::kLitPosBits, // 1 lp _numLiteralPosStateBits(0)
|
||||
NCoderPropID::kLitContextBits, // 2 lc _numLiteralContextBits(3)
|
||||
NCoderPropID::kDictionarySize, // 3 ds
|
||||
NCoderPropID::kAlgorithm, // 4 fm _fastmode
|
||||
NCoderPropID::kNumFastBytes, // 5 fb
|
||||
NCoderPropID::kMatchFinderCycles, // 6 mfc _matchFinderCycles, _cutValue
|
||||
NCoderPropID::kMatchFinder // 7 mf
|
||||
};
|
||||
PROPVARIANT pr[8];
|
||||
const unsigned nprops = 8;
|
||||
static const wchar_t matchfinder[] = L"BT4";
|
||||
assert(NCompress::NLZMA::FindMatchFinder(matchfinder) >= 0);
|
||||
pr[7].vt = VT_BSTR; pr[7].bstrVal = ACC_PCAST(BSTR, ACC_UNCONST_CAST(wchar_t *, matchfinder));
|
||||
pr[0].vt = pr[1].vt = pr[2].vt = pr[3].vt = VT_UI4;
|
||||
pr[4].vt = pr[5].vt = pr[6].vt = VT_UI4;
|
||||
if (prepare(res, src_len, method, level, lcconf) != 0)
|
||||
goto error;
|
||||
pr[0].uintVal = res->pos_bits;
|
||||
pr[1].uintVal = res->lit_pos_bits;
|
||||
pr[2].uintVal = res->lit_context_bits;
|
||||
pr[3].uintVal = res->dict_size;
|
||||
pr[4].uintVal = res->fast_mode;
|
||||
pr[5].uintVal = res->num_fast_bytes;
|
||||
pr[6].uintVal = res->match_finder_cycles;
|
||||
|
||||
try {
|
||||
|
||||
if (enc.SetCoderProperties(propIDs, pr, nprops) != S_OK)
|
||||
goto error;
|
||||
if (enc.WriteCoderProperties(&os) != S_OK)
|
||||
goto error;
|
||||
if (os.overflow) {
|
||||
//r = UPX_E_OUTPUT_OVERRUN;
|
||||
r = UPX_E_NOT_COMPRESSIBLE;
|
||||
goto error;
|
||||
}
|
||||
assert(os.b_pos == 5);
|
||||
os.b_pos = 0;
|
||||
// extra stuff in first byte: 5 high bits convenience for stub decompressor
|
||||
unsigned t = res->lit_context_bits + res->lit_pos_bits;
|
||||
os.WriteByte(Byte((t << 3) | res->pos_bits));
|
||||
os.WriteByte(Byte((res->lit_pos_bits << 4) | (res->lit_context_bits)));
|
||||
|
||||
rh = enc.Code(&is, &os, NULL, NULL, &progress);
|
||||
|
||||
} catch (...) {
|
||||
rh = E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
assert(is.b_pos <= src_len);
|
||||
assert(os.b_pos <= *dst_len);
|
||||
if (rh == E_OUTOFMEMORY)
|
||||
r = UPX_E_OUT_OF_MEMORY;
|
||||
else if (os.overflow)
|
||||
{
|
||||
assert(os.b_pos == *dst_len);
|
||||
//r = UPX_E_OUTPUT_OVERRUN;
|
||||
r = UPX_E_NOT_COMPRESSIBLE;
|
||||
}
|
||||
else if (rh == S_OK)
|
||||
{
|
||||
assert(is.b_pos == src_len);
|
||||
r = UPX_E_OK;
|
||||
}
|
||||
|
||||
error:
|
||||
*dst_len = (unsigned) os.b_pos;
|
||||
//printf("\nlzma_compress: %d: %u %u %u %u %u, %u - > %u\n", r, res->pos_bits, res->lit_pos_bits, res->lit_context_bits, res->dict_size, res->num_probs, src_len, *dst_len);
|
||||
//printf("%u %u %u\n", is.__m_RefCount, os.__m_RefCount, progress.__m_RefCount);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// decompress
|
||||
**************************************************************************/
|
||||
|
||||
#undef _LZMA_IN_CB
|
||||
#undef _LZMA_OUT_READ
|
||||
#undef _LZMA_PROB32
|
||||
#undef _LZMA_LOC_OPT
|
||||
#include "C/7zip/Compress/LZMA_C/LzmaDecode.h"
|
||||
#include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
|
||||
|
||||
int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
|
||||
upx_bytep dst, unsigned* dst_len,
|
||||
int method,
|
||||
const upx_compress_result_t *cresult )
|
||||
{
|
||||
assert(M_IS_LZMA(method));
|
||||
// see res->num_probs above
|
||||
COMPILE_TIME_ASSERT(sizeof(CProb) == 2)
|
||||
COMPILE_TIME_ASSERT(LZMA_BASE_SIZE == 1846)
|
||||
COMPILE_TIME_ASSERT(LZMA_LIT_SIZE == 768)
|
||||
|
||||
CLzmaDecoderState s; memset(&s, 0, sizeof(s));
|
||||
SizeT src_out = 0, dst_out = 0;
|
||||
int r = UPX_E_ERROR;
|
||||
int rh;
|
||||
|
||||
if (src_len < 3)
|
||||
goto error;
|
||||
s.Properties.pb = src[0] & 7;
|
||||
s.Properties.lp = (src[1] >> 4);
|
||||
s.Properties.lc = src[1] & 15;
|
||||
if (s.Properties.pb >= 5) goto error;
|
||||
if (s.Properties.lp >= 5) goto error;
|
||||
if (s.Properties.lc >= 9) goto error;
|
||||
// extra
|
||||
if ((src[0] >> 3) != s.Properties.lc + s.Properties.lp) goto error;
|
||||
src += 2; src_len -= 2;
|
||||
|
||||
if (cresult)
|
||||
{
|
||||
assert(cresult->method == method);
|
||||
assert(cresult->result_lzma.pos_bits == (unsigned) s.Properties.pb);
|
||||
assert(cresult->result_lzma.lit_pos_bits == (unsigned) s.Properties.lp);
|
||||
assert(cresult->result_lzma.lit_context_bits == (unsigned) s.Properties.lc);
|
||||
assert(cresult->result_lzma.num_probs == (unsigned) LzmaGetNumProbs(&s.Properties));
|
||||
const lzma_compress_result_t *res = &cresult->result_lzma;
|
||||
UNUSED(res);
|
||||
//printf("\nlzma_decompress config: %u %u %u %u %u\n", res->pos_bits, res->lit_pos_bits, res->lit_context_bits, res->dict_size, res->num_probs);
|
||||
}
|
||||
s.Probs = (CProb *) malloc(sizeof(CProb) * LzmaGetNumProbs(&s.Properties));
|
||||
if (!s.Probs)
|
||||
{
|
||||
r = UPX_E_OUT_OF_MEMORY;
|
||||
goto error;
|
||||
}
|
||||
rh = LzmaDecode(&s, src, src_len, &src_out, dst, *dst_len, &dst_out);
|
||||
assert(src_out <= src_len);
|
||||
assert(dst_out <= *dst_len);
|
||||
if (rh == 0)
|
||||
{
|
||||
r = UPX_E_OK;
|
||||
if (src_out != src_len)
|
||||
r = UPX_E_INPUT_NOT_CONSUMED;
|
||||
}
|
||||
|
||||
error:
|
||||
*dst_len = dst_out;
|
||||
free(s.Probs);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// test_overlap - see <ucl/ucl.h> for semantics
|
||||
**************************************************************************/
|
||||
|
||||
int upx_lzma_test_overlap ( const upx_bytep buf,
|
||||
const upx_bytep tbuf,
|
||||
unsigned src_off, unsigned src_len,
|
||||
unsigned* dst_len,
|
||||
int method,
|
||||
const upx_compress_result_t *cresult )
|
||||
{
|
||||
assert(M_IS_LZMA(method));
|
||||
|
||||
MemBuffer b(src_off + src_len);
|
||||
memcpy(b + src_off, buf + src_off, src_len);
|
||||
unsigned saved_dst_len = *dst_len;
|
||||
int r = upx_lzma_decompress(b + src_off, src_len, b, dst_len, method, cresult);
|
||||
if (r != UPX_E_OK)
|
||||
return r;
|
||||
if (*dst_len != saved_dst_len)
|
||||
return UPX_E_ERROR;
|
||||
// NOTE: there is a very tiny possibility that decompression has
|
||||
// succeeded but the data is not restored correctly because of
|
||||
// in-place buffer overlapping, so we use an extra memcmp().
|
||||
if (tbuf != NULL && memcmp(tbuf, b, *dst_len) != 0)
|
||||
return UPX_E_ERROR;
|
||||
return UPX_E_OK;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// misc
|
||||
**************************************************************************/
|
||||
|
||||
int upx_lzma_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *upx_lzma_version_string(void)
|
||||
{
|
||||
#if (WITH_LZMA == 0x443)
|
||||
return "4.43";
|
||||
#else
|
||||
# error "unknown WITH_LZMA version"
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user