Compare commits
2384 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| fdce705e55 | |||
| 81268e7064 | |||
| f502f41359 | |||
| 34c9cfb6b0 | |||
| 6da1790c46 | |||
| d333c940da | |||
| c940d2906f | |||
| ac4b51ba85 | |||
| ea7a1ad2c7 | |||
| 45ddd6a68d | |||
| acd99364e0 | |||
| 14710dea55 | |||
| 5d3be8da1d | |||
| 3026821f9f | |||
| fba51dabd0 | |||
| c4da5e81fa | |||
| bc80d81432 | |||
| 67797efead | |||
| c7cb036536 | |||
| 0ccbc5f139 | |||
| 2a6bbcaf8f | |||
| d46a8438ba | |||
| cc9d19da19 | |||
| 6e6aa6fd6d | |||
| 61652a2989 | |||
| edd7503607 | |||
| c9d6dab401 | |||
| d303038bcb | |||
| 0a0e7c3b7c | |||
| 0b4ac35bc9 | |||
| c51864ca39 | |||
| a1cabd5a68 | |||
| 9c1bc99d7a | |||
| c05fedcb76 | |||
| e11beeae4b | |||
| 4749e0d71e | |||
| 1c01b77a71 | |||
| 1dd8ad3685 | |||
| d6f6350b54 | |||
| 4f3b85e604 | |||
| efd5bc24b0 | |||
| a1d5dfa1ac | |||
| 597c2ba180 | |||
| 2c2fb1b70b | |||
| fc1287659a | |||
| 1a76630594 | |||
| 322f682d32 | |||
| 0e329336fc | |||
| b33bdabbb6 | |||
| 27d30121ab | |||
| 345278f309 | |||
| 4953e77161 | |||
| 8d61e037f9 | |||
| 33a51e69bf | |||
| d5dd9bbf24 | |||
| 8772e52513 | |||
| 9e1631ad4f | |||
| 134b829d59 | |||
| 3df7d26101 | |||
| cf56086f06 | |||
| a72aca4379 | |||
| edb0b7519a | |||
| 3a3248c88c | |||
| 3f14b9dab7 | |||
| b1c07c22ce | |||
| 3b2c411274 | |||
| e418af1ccd | |||
| 7dc004acb3 | |||
| 2635472896 | |||
| 5c0340f9ae | |||
| c2c970ee33 | |||
| b52dabe091 | |||
| 3fa2db8d6f | |||
| 1e7950f671 | |||
| 8fde05191a | |||
| 2557de6c4e | |||
| 44328aee76 | |||
| f606b5879b | |||
| 83607119df | |||
| 9b86e68268 | |||
| d688a05ac7 | |||
| 97e975b4f6 | |||
| 9dd0e3ce4f | |||
| ca2293f6d3 | |||
| 0cd1ef0c7a | |||
| b0207ce524 | |||
| fab0c3b09d | |||
| 8b35dd3358 | |||
| cadcbb27eb | |||
| 297d44c614 | |||
| 22178f2224 | |||
| 554f8a376c | |||
| 4157affbd7 | |||
| 4b991203df | |||
| 38a265741c | |||
| 56eb02280f | |||
| ed900b0476 | |||
| 42206364e5 | |||
| 82d9bb8f51 | |||
| 923a9d3f9b | |||
| ae7660068b | |||
| f466c1d764 | |||
| 6e76f8ef3a | |||
| b3a8d02caf | |||
| 022ba32c1a | |||
| 8f5e89c900 | |||
| d335d7bafd | |||
| 1f51ef7df6 | |||
| ec082ee023 | |||
| a6bc271e0d | |||
| 791fd9199e | |||
| 9e8baf1914 | |||
| 64b7080532 | |||
| 8fd5479f32 | |||
| 04eb9c02c3 | |||
| 07b41b9bc3 | |||
| 8ebadfafe9 | |||
| 3283896e4b | |||
| b444bcf418 | |||
| 13034577fc | |||
| 9feefc2e7f | |||
| a5393e985d | |||
| e3fe0dc89b | |||
| 42d49e9d50 | |||
| 06eb244800 | |||
| 870cdfa51f | |||
| 93787c74ee | |||
| 945323fe15 | |||
| 5e41e69b27 | |||
| 9d14185f7d | |||
| 0f74162551 | |||
| 00b1ff1ff6 | |||
| 977024ea94 | |||
| 3534ed21d7 | |||
| ee093e5232 | |||
| 807ab8d19f | |||
| 81f3ff098f | |||
| 85a5759afb | |||
| 490e7a56a5 | |||
| e41c475671 | |||
| b0841268bd | |||
| b9b3b67b95 | |||
| 0d57d2cfe3 | |||
| 32de5d0d7f | |||
| 51eab2a4b7 | |||
| 93cf170253 | |||
| f7554374ab | |||
| b4870f62c9 | |||
| f1d713ebf6 | |||
| 4134a512b9 | |||
| cf998f945c | |||
| a7386238dd | |||
| 6b39d122a6 | |||
| a0582c5380 | |||
| 1f37112969 | |||
| 361958db76 | |||
| 8bc7880b19 | |||
| ceddf29586 | |||
| 3fc78e21bc | |||
| 48e00b371c | |||
| aee52d3880 | |||
| bd54499537 | |||
| e6da9e8d1a | |||
| 156ca03b67 | |||
| 3f4419b177 | |||
| 676f860d7d | |||
| 5ce93ae0c7 | |||
| 43231826b9 | |||
| 899b393fcc | |||
| 5c3e02d2f0 | |||
| a29064107e | |||
| 4cdc969801 | |||
| 68159d457e | |||
| daafc29d2b | |||
| 3c786acf2b | |||
| 53c3817d4d | |||
| 9109254488 | |||
| df19f0d5ec | |||
| 093362e479 | |||
| 7826a3652b | |||
| c27b7e52e1 | |||
| 6f79cbb2a6 | |||
| 6f33929f91 | |||
| 2e8b649195 | |||
| 3841be7e20 | |||
| 2c28521283 | |||
| 1c735cc204 | |||
| f0b13ae8e4 | |||
| b1a2f8fec0 | |||
| 83828aa8a3 | |||
| 4eb81b4d66 | |||
| 96d9968db5 | |||
| 2781e37ec0 | |||
| 6d61e773b5 | |||
| c5171114d1 | |||
| 0ca0a832de | |||
| aef54a4bfd | |||
| 4c473acfec | |||
| 0de41e97ac | |||
| 0e52ab3f90 | |||
| 797679b42c | |||
| 1bc8b6f46e | |||
| f322b580ff | |||
| 2b2f33e3f5 | |||
| ce29cd2fad | |||
| 0d5843f44e | |||
| e36e8e3b33 | |||
| e251a1ca19 | |||
| 4aedb00e43 | |||
| 10a0469221 | |||
| d3419acada | |||
| 65ea4117ca | |||
| 8b0101dcab | |||
| 188f67cfca | |||
| a89f4bd4b8 | |||
| 053c9dc0e1 | |||
| 493d9f1b9d | |||
| e28793f128 | |||
| ea2bddf245 | |||
| 763b3c05af | |||
| 473cfb54be | |||
| a7fd742c17 | |||
| b66ba140cb | |||
| 242f606a29 | |||
| 60a1214d7e | |||
| 189ab8c8e8 | |||
| 3765ca4e92 | |||
| df87d76070 | |||
| 8fbf0b406b | |||
| 633073803f | |||
| 104da198d3 | |||
| b3121e4534 | |||
| 3bb654cc85 | |||
| d2830db94d | |||
| ad6914b938 | |||
| 57ba965b93 | |||
| 544ec21fc2 | |||
| 1bb0fa1809 | |||
| ffa0efc898 | |||
| af6b4b8c27 | |||
| 3f7c1f966b | |||
| 535515f296 | |||
| 7af6c4b10e | |||
| 2076bef95b | |||
| 48ce1f1814 | |||
| 5151c8a505 | |||
| 44248f19b5 | |||
| 8d433f2580 | |||
| 272fe5488c | |||
| c97765de14 | |||
| 7acf150ac5 | |||
| 077bbdfc78 | |||
| 2fb38ce13a | |||
| 22dc183f25 | |||
| 3c492c3fc7 | |||
| d71db2978e | |||
| e4723e0bad | |||
| dc56c4e530 | |||
| 9579a51a8b | |||
| 71f897ebf5 | |||
| 09d9f71ae9 | |||
| c678ccdfb1 | |||
| bbbebe343b | |||
| 033cb4f0c2 | |||
| d750034b79 | |||
| a2063f0628 | |||
| acf2f2ffc4 | |||
| d14f484c4b | |||
| 695e515a65 | |||
| 61089feee7 | |||
| ddc9b10cd3 | |||
| f95c92b431 | |||
| eba65a94e6 | |||
| c28a0c6bb8 | |||
| d6bacd9b47 | |||
| 70b1657323 | |||
| 1ef08bd169 | |||
| da68cc6a78 | |||
| 45c75d42ad | |||
| d4e55af2c2 | |||
| 48791a329d | |||
| 9b26ebed75 | |||
| e2160fb6c9 | |||
| 345a1c64f9 | |||
| 7ad1e7756b | |||
| 90caf19e9e | |||
| 8d0b3b7d44 | |||
| 4c253d68d4 | |||
| 73d1b331f1 | |||
| af2fddfd6d | |||
| 3e065ead65 | |||
| 3774704326 | |||
| 4a1100b6a4 | |||
| 63dec77ed6 | |||
| 1d3a66f890 | |||
| c1da92ca22 | |||
| 13475002d7 | |||
| 5bb6f246ed | |||
| 89df7451ef | |||
| 1334d544f7 | |||
| 3fefaa7362 | |||
| 15d62f7b96 | |||
| 83e0aaa511 | |||
| ee06ce1148 | |||
| 16d6124bb4 | |||
| 1197beaa13 | |||
| 98b428a8be | |||
| 17f47d3c0a | |||
| a9cc3b2a89 | |||
| 199102c106 | |||
| c7d76fb7ab | |||
| ba9b86c0dc | |||
| 5de83a606e | |||
| 01a0c8672d | |||
| fa522c0ffc | |||
| 16241d010f | |||
| 9cb8fbf178 | |||
| bd7ef27628 | |||
| 42e520e841 | |||
| d8f9cd237f | |||
| 33065ecf04 | |||
| 718a1da262 | |||
| b89c3ebb42 | |||
| 9d7e44feff | |||
| e48a60a4f0 | |||
| 163e1907a4 | |||
| ac1ccaa246 | |||
| 53b45279ad | |||
| f80daf5de1 | |||
| 298ea1f0d3 | |||
| 1d13d8c4a0 | |||
| 2238c99b61 | |||
| 7d4dfbef2b | |||
| 759827b404 | |||
| fca627d1b0 | |||
| 404da18aed | |||
| 330fca722a | |||
| 8939cd120b | |||
| 63afeb7373 | |||
| 6ba68a6455 | |||
| 1579c74302 | |||
| 373ca15c71 | |||
| a8a3caed1c | |||
| cb35ba4543 | |||
| cdd152d015 | |||
| 83ce7dc62f | |||
| b182b50f24 | |||
| 71a9941b84 | |||
| c777da263e | |||
| 2cb7b56a41 | |||
| 52f9ef14b9 | |||
| 8d6c594240 | |||
| 7ad77ff540 | |||
| acede72e9b | |||
| 771fd732d1 | |||
| 2a79a69f59 | |||
| 8c0321697f | |||
| 0151b3f9b3 | |||
| 82a51f35ea | |||
| 35944cbfc1 | |||
| f0aef9b28b | |||
| ae37c3902c | |||
| d612585582 | |||
| 7ca14d209c | |||
| c37f582c10 | |||
| 6272fb3822 | |||
| 2582fbac59 | |||
| 5abb578e47 | |||
| 015ebf89a5 | |||
| c6724968f1 | |||
| 9fa1772ae4 | |||
| 4551937812 | |||
| 51ee664cae | |||
| fb611a98f9 | |||
| a3d5face38 | |||
| 424cd497d3 | |||
| d46eeffaaf | |||
| 6520f2061e | |||
| 5d93f86b4b | |||
| b3f63ce7ae | |||
| 56de770682 | |||
| 940341bc9d | |||
| 804a0ce601 | |||
| 41054a4c56 | |||
| 7b8e5d4180 | |||
| ca2369f1c1 | |||
| 129cb0b3cd | |||
| 632b2ae1ba | |||
| 18e55061e1 | |||
| e49b65723f | |||
| 8e52894763 | |||
| 07cba6c774 | |||
| 9cb639b505 | |||
| 4cf6eeeee2 | |||
| c0f692792f | |||
| bd77e0945b | |||
| f0eb171b2a | |||
| fb93662b5c | |||
| a26c982e93 | |||
| 7db3e98944 | |||
| 4a87834e04 | |||
| bf6ecaeeb9 | |||
| f70ef86dfa | |||
| cd3132667a | |||
| 1c459a7bea | |||
| 4f0bfeab4c | |||
| c5c9921b59 | |||
| 6b63aba1fc | |||
| 382331fb11 | |||
| caf9af7ae4 | |||
| 45d2adeb9c | |||
| 96708d7592 | |||
| 13090d1219 | |||
| 8ab229cca9 | |||
| 583cd078dc | |||
| aa2ac1bbb8 | |||
| 928b426672 | |||
| 6766b14415 | |||
| 9d0f9e967f | |||
| d7609088e5 | |||
| b2643b6926 | |||
| 07b65ca069 | |||
| 25727f7f99 | |||
| 880ae89307 | |||
| 1496df1989 | |||
| 7d8ae6b4b1 | |||
| 312d4cccaf | |||
| ce5f9f95ea | |||
| d9bf8a76d9 | |||
| f7a35fb9fe | |||
| 3ba691ded5 | |||
| 7a7277d56f | |||
| 76be5dd1d3 | |||
| 53dc63f3bc | |||
| 80da0bc9d5 | |||
| bce7af4e11 | |||
| 9da09b51ed | |||
| 86392f197f | |||
| 1c13046297 | |||
| fbc756b531 | |||
| 6c64b06453 | |||
| 241834029a | |||
| 5b8a9c0b47 | |||
| 037c29d24a | |||
| 893f26ac9a | |||
| d43f8e3100 | |||
| 2b42acf7b8 | |||
| f65b80ed42 | |||
| e84abbdc82 | |||
| 66269eabe9 | |||
| 36c0928483 | |||
| 9237e15adc | |||
| 0d3a2072b2 | |||
| aa2ee5dfc2 | |||
| b515fa39ec | |||
| 76e3f4eb92 | |||
| 4959e5c6c2 | |||
| 7082594bbc | |||
| 36dd35f238 | |||
| 9c9fb6a485 | |||
| 5438a4837b | |||
| 84996e8cb6 | |||
| 87a368a857 | |||
| 21412d93dd | |||
| 0b11ff22b4 | |||
| 8fafa78796 | |||
| c43158f8a2 | |||
| 92ad524947 | |||
| b362a61863 | |||
| 468fec38d7 | |||
| 89830a5ae0 | |||
| 5977c296bd | |||
| 47d5792d97 | |||
| 25d706a913 | |||
| 048236aaaa | |||
| d442c58fd1 | |||
| f890f6bb09 | |||
| 036d466790 | |||
| dee47ba2d8 | |||
| be96c28b77 | |||
| ad1c0f578e | |||
| c8f7b1b72c | |||
| c89702ae84 | |||
| 2d29a82250 | |||
| b36c65e654 | |||
| 09b072b908 | |||
| 0ae9fee350 | |||
| 1579182ed9 | |||
| 074671aa71 | |||
| 36b7c47247 | |||
| 424d5b3025 | |||
| 8a5d352733 | |||
| f383629282 | |||
| a6d717cb04 | |||
| 84a5753301 | |||
| 5d2d9c7e81 | |||
| 82801d1411 | |||
| 340c3963d8 | |||
| ef15cf9847 | |||
| 4d613ccfa7 | |||
| 43ce34d547 | |||
| eda074cd80 | |||
| a2396d82f6 | |||
| a38721db93 | |||
| a06e811717 | |||
| 86e534ff75 | |||
| 640d5b2dec | |||
| 57e9b27085 | |||
| c56eefc739 | |||
| cf28306997 | |||
| 10acf3ddd1 | |||
| fed3ed9f9a | |||
| 260138ba11 | |||
| 67f7e0089c | |||
| d4a22c7851 | |||
| 06cf986490 | |||
| adf9aa04ce | |||
| 69f66fbe52 | |||
| d061005c89 | |||
| f6ee8b9f04 | |||
| 31af22c2ff | |||
| c421e3f243 | |||
| 6e92902407 | |||
| 6256381dc3 | |||
| b247b051ea | |||
| afbd553622 | |||
| 36bc14e884 | |||
| 9c5d0ff2ff | |||
| cfa6c8ddf6 | |||
| 21924bf022 | |||
| eea33f6019 | |||
| 66d48ae808 | |||
| de9b9fd0b1 | |||
| ece7384be4 | |||
| 0c052e4506 | |||
| 1996a0a3d6 | |||
| 679ad9b8c6 | |||
| d4983731e7 | |||
| 4fec3c8f34 | |||
| 836fd2565f | |||
| 54618064a1 | |||
| 519e3e01ae | |||
| aec8f81358 | |||
| c1d6bf4366 | |||
| 9bf2b79d9e | |||
| 4d98408995 | |||
| 7b466388f9 | |||
| b926fb3c66 | |||
| 6c8d5c0d0e | |||
| 5a1d234260 | |||
| fd6d42c297 | |||
| 7310ad6e92 | |||
| 7e47b1348d | |||
| 1e3555a6b7 | |||
| 9a67ce5968 | |||
| 279d7955f8 | |||
| db977c0bf5 | |||
| ba6bc59818 | |||
| 6e8be0578c | |||
| 92f7d16b5e | |||
| 40bb3c2f5e | |||
| 56a6096221 | |||
| ee37b42a91 | |||
| 0806e61df4 | |||
| 279ffeeefa | |||
| 80c5ee2479 | |||
| 16208544e5 | |||
| 6afeb24fdb | |||
| e6357b81eb | |||
| dfc2efe8a6 | |||
| f28b96f431 | |||
| a10293f8f7 | |||
| b1f02f91d7 | |||
| e76fa45d86 | |||
| 06f43892a5 | |||
| a094332b0d | |||
| 7b8779f534 | |||
| 371bf20d19 | |||
| 0f633ddd15 | |||
| 7886ca7f5f | |||
| 9b4c11954d | |||
| a1b724f30a | |||
| 7c3b2fb9cc | |||
| acef68d67e | |||
| 7e393d5f1e | |||
| 955c31b165 | |||
| e307cd48ad | |||
| 25f8b9e451 | |||
| e8ba14a2c1 | |||
| 9670d3341c | |||
| cec9778fd5 | |||
| 7451db4a68 | |||
| e31777ec53 | |||
| 7aa0b3dc7a | |||
| e7b2d5dc01 | |||
| 47d728667d | |||
| e1f8989d54 | |||
| 1d8cb47830 | |||
| faaa7c37a9 | |||
| 0aff9d8df4 | |||
| 30c3f8c1ac | |||
| bcd2469e01 | |||
| 983c6ae73d | |||
| 6d8e1fe776 | |||
| 99b4921309 | |||
| 3c231c3c9e | |||
| 175c0a6236 | |||
| 0031ceb06c | |||
| e3cc5a63df | |||
| 3cb61402c2 | |||
| 5336c51199 | |||
| 52aa658aaa | |||
| d08a51d7e4 | |||
| d97a557ac3 | |||
| 8a68d9cded | |||
| b031f7e902 | |||
| 963ffecb96 | |||
| 8f8aaca818 | |||
| 801f92b7e7 | |||
| 44db45700e | |||
| 25902005f6 | |||
| ffec71e0d8 | |||
| 99a208110b | |||
| e56799c993 | |||
| 957eb300f8 | |||
| 626025d539 | |||
| 9e8a0a020f | |||
| 40f592eade | |||
| 5e899f0be4 | |||
| f2748284b1 | |||
| a15ce00934 | |||
| 9e3e80261b | |||
| c72c685434 | |||
| 0177a8d277 | |||
| b6a9b0a4c9 | |||
| f4f8bd8d42 | |||
| 6e4aeffc0c | |||
| dba256d384 | |||
| 910008e9e7 | |||
| 8cb9545c41 | |||
| 59c16da6fb | |||
| 630df5bbd2 | |||
| f550111400 | |||
| 77377195aa | |||
| 7e2e72bd40 | |||
| aa7a13bd02 | |||
| 5895058a17 | |||
| ffb60d5149 | |||
| 1e2cb279b0 | |||
| e7f766f5ba | |||
| 8de5aa9409 | |||
| bf28a4df49 | |||
| fe1a0ab371 | |||
| 01daccfaf7 | |||
| 94e861e298 | |||
| d36af2ed5c | |||
| 7104b33214 | |||
| 32998e5377 | |||
| af0c9ef092 | |||
| 3bc3b3d10e | |||
| f03f42ca4d | |||
| 79783abeb1 | |||
| 895b0bd602 | |||
| 2ee5ee92f8 | |||
| 3e619423b1 | |||
| b524e18bdf | |||
| 6aa4579db8 | |||
| 17fb86c0f1 | |||
| 62ecfe4873 | |||
| 04e55e6b9a | |||
| f432aa1090 | |||
| 7add104313 | |||
| 36de249066 | |||
| b7a54dcffd | |||
| 6bb28deab2 | |||
| 7f88d15c86 | |||
| 94c5014e23 | |||
| c5a8256500 | |||
| 5f39884bf7 | |||
| d96825a242 | |||
| 443a938091 | |||
| 6bc3197721 | |||
| 269cc91fd5 | |||
| c1ddea479d | |||
| 5f3a95962c | |||
| ee1a8e6a32 | |||
| eeae73296e | |||
| 4ca8357af4 | |||
| 8a5b8c87fb | |||
| 6ab04d7bbc | |||
| a5a1380636 | |||
| eeab1aef64 | |||
| 4e1c342e55 | |||
| d8ed259bce | |||
| 9f6cb5de4c | |||
| ba634118d7 | |||
| 63da091d36 | |||
| ad0dc88a33 | |||
| 147acf4b57 | |||
| 5085f3a15e | |||
| 22a95ad8ea | |||
| df4bd6a60c | |||
| 813e7b05e4 | |||
| ab8b486b4a | |||
| 590f666ec9 | |||
| 9adaee915b | |||
| bce0f06fe9 | |||
| 856ecb84a0 | |||
| 90ddc06c98 | |||
| 405abc4e95 | |||
| 549c59ecf5 | |||
| 0a485eafcb | |||
| e0c11956a6 | |||
| da6a9bf3eb | |||
| dacd11e1cc | |||
| fc854b4c77 | |||
| 4dcc1f0374 | |||
| fc57390242 | |||
| bd15ef0a0c | |||
| 967ecafc33 | |||
| 29576da985 | |||
| 200a2556ef | |||
| ae0ab5025e | |||
| aa74276b25 | |||
| b03112a5dd | |||
| a3f49df62d | |||
| aa2af3f6dd | |||
| 20dcbc593c | |||
| 472ba8c1fd | |||
| d8345a44a4 | |||
| a187cb6c9c | |||
| b89c0b35d1 | |||
| 7ffcc0a5e7 | |||
| bde43fbdfb | |||
| 3728b2208f | |||
| dc52a756ee | |||
| 98dc886841 | |||
| d0cf104e43 | |||
| d7ed2412f6 | |||
| 7d38f0e234 | |||
| 3e8d072d24 | |||
| 84ac771893 | |||
| 3a9e0b5be6 | |||
| 9694ff433f | |||
| 2e82e78b98 | |||
| aaef4bee27 | |||
| 4ca8569488 | |||
| 8377ada3e0 | |||
| 8a034d59ed | |||
| 8e492d8798 | |||
| 7974ef80d7 | |||
| 3664d86430 | |||
| 9adef80d6b | |||
| be57adaee7 | |||
| d117e442a4 | |||
| 8820bc0796 | |||
| 57a64de023 | |||
| 5ed689ceb0 | |||
| 25f1765f36 | |||
| 063bd58802 | |||
| 901c6b34fa | |||
| 5b2d6488a2 | |||
| f6f35415d1 | |||
| 6c6069e963 | |||
| 6219d82560 | |||
| 1dcd7a16ab | |||
| b60caeb9dd | |||
| 4c4768aaf3 | |||
| 2f4ac0a663 | |||
| 23a446f852 | |||
| ec48334a1a | |||
| f4c061d412 | |||
| 31a076d7b3 | |||
| 6bd43d986c | |||
| dd32a2f15a | |||
| c88c20820f | |||
| 86de510731 | |||
| 0b31fbf827 | |||
| 34ad1450eb | |||
| e6ba71390d | |||
| f0c8dbe0ec | |||
| bf046a8ccb | |||
| b05ba7683e | |||
| aedf8dad15 | |||
| 74ebb7c722 | |||
| 1307f66494 | |||
| 448a24cb36 | |||
| 7266f23450 | |||
| c0ad31acfc | |||
| 25d3a0de27 | |||
| 1e38bbfbc1 | |||
| 1c62e95812 | |||
| d453cc27a3 | |||
| 2c3e841d8a | |||
| 50668c462f | |||
| 8d1192e832 | |||
| 4a8e2e9ed4 | |||
| 12fc45220a | |||
| 6bce68fbe7 | |||
| d54f947c98 | |||
| 6c8bb3a22e | |||
| ed29ce5183 | |||
| a51d269b7c | |||
| 8283e4e6d6 | |||
| 23ce91eb55 | |||
| 545ac7fcfa | |||
| 3926ccccad | |||
| f431307ef2 | |||
| ca368e0f9b | |||
| 8afeb56c11 | |||
| 2a6f90c5f3 | |||
| 271031128e | |||
| b991f954d0 | |||
| f12bb3f80d | |||
| 6dc978e8d8 | |||
| 9f05a873bc | |||
| 703d498772 | |||
| ed3b9543bb | |||
| fc7efba7d8 | |||
| b3178fe8f4 | |||
| e36798a993 | |||
| a143605465 | |||
| d3ad35b21e | |||
| 68134941bf | |||
| 54d0fef559 | |||
| 7f9c47176a | |||
| 9060ac7897 | |||
| d9073e4a17 | |||
| de1c1d7cc2 | |||
| 6ff1bd5917 | |||
| a6b04f426e | |||
| fa49dbe2cb | |||
| 682eb04a52 | |||
| 77064fb09e | |||
| be8d93563a | |||
| d4a6a5216d | |||
| 1cb1427050 | |||
| e4f4eace1c | |||
| 30a98b7e8c | |||
| d36c8d95ad | |||
| 506bd0abcf | |||
| 8dd810c41d | |||
| d9d0dc5201 | |||
| 72880d9e03 | |||
| 6c7ec6eb1b | |||
| 705fc5d116 | |||
| d20b575b9b | |||
| c949beab9c | |||
| 3fb857c435 | |||
| 0a4f999ade | |||
| f0b7147881 | |||
| b36a42cd0a | |||
| 000309b47f | |||
| 5cb12988f0 | |||
| 50c4b749ec | |||
| 5db2734e6f | |||
| e9e5507483 | |||
| d63dc7adfb | |||
| 27db44a8db | |||
| 1a035e2866 | |||
| 887aa20116 | |||
| 5e03d86695 | |||
| 95075aa28e | |||
| 0260f0790a | |||
| 34d65ba292 | |||
| 27a77a15ed | |||
| 76025bfae1 | |||
| 4957faf482 | |||
| 0d8e16d5c8 | |||
| 07baed1581 | |||
| eab5da075a | |||
| 0d1bbb19ce | |||
| 58d6cbc6ac | |||
| 4d3b627839 | |||
| 49455c99ad | |||
| 31bb6bedbd | |||
| 8d54678ea1 | |||
| 590767c299 | |||
| ec1bd342b8 | |||
| b031c9e7f6 | |||
| ea0dfe83b7 | |||
| bdd90f2c57 | |||
| 288dac5d70 | |||
| 9d22e1c35e | |||
| ace2359e7b | |||
| 617e6510a5 | |||
| 26024770b8 | |||
| d556f58e34 | |||
| b6f302dfc0 | |||
| 8e9b5f14af | |||
| 3635c00143 | |||
| abc71baaa6 | |||
| 959aaebede | |||
| d17f8c5049 | |||
| 42a7201a70 | |||
| 1f1744a49a | |||
| fd7dbe5bd9 | |||
| 984549400d | |||
| cf0c49277e | |||
| 16c3f9fa9c | |||
| 2f2539cf34 | |||
| e66823d017 | |||
| 881c32a3df | |||
| ea0a361c35 | |||
| dc60f8bb7b | |||
| 9e92c9ea12 | |||
| a503a54240 | |||
| 265957712a | |||
| c26962bb71 | |||
| a428eddf93 | |||
| dc4f7eb2f9 | |||
| d54ac1ba91 | |||
| a3d46b18ac | |||
| e81dd05666 | |||
| 29394935e3 | |||
| df8acc4ed7 | |||
| 81928d4ab1 | |||
| 3ebf93e03d | |||
| 59e4032f1f | |||
| 8f15777427 | |||
| 748c4bf780 | |||
| befcf6d2b3 | |||
| 48236ecd3c | |||
| f340f84de7 | |||
| 40e19293f9 | |||
| f252f824a4 | |||
| 1d7e5a8130 | |||
| cb2ff92c2f | |||
| ef373ab54f | |||
| 9141a78c29 | |||
| 10a6370738 | |||
| 573009eeb6 | |||
| c3363712d9 | |||
| faa33d89a2 | |||
| f347458c53 | |||
| 530e6d9196 | |||
| b398e18e12 | |||
| 747e8370e0 | |||
| 2c67875781 | |||
| c96e8a8c19 | |||
| 5f203fc082 | |||
| b943c9b471 | |||
| 1a90a1daa8 | |||
| 72dfc743fd | |||
| 465307655b | |||
| 6ce71e6694 | |||
| 7f01b3b92a | |||
| 76950d56b9 | |||
| c11e0d02b3 | |||
| 4c798c1718 | |||
| 450d7e9ad4 | |||
| b8ab79c83e | |||
| 6934bdd533 | |||
| 84dedb73a5 | |||
| 8964aa5221 | |||
| 3481ae236c | |||
| 46adc5f8a4 | |||
| 5296df5899 | |||
| 13dad4be16 | |||
| b5d0c343b4 | |||
| b00b945264 | |||
| 3bda09e105 | |||
| 32d32c4e4a | |||
| 497441b54e | |||
| 9c564fd4c7 | |||
| 0c2263d0e9 | |||
| 3d4d30766d | |||
| 99d84d44fc | |||
| 41ba7077ad | |||
| 8a929a91c3 | |||
| 0604f06841 | |||
| 229924adf9 | |||
| df988b7c69 | |||
| e8106e2e34 | |||
| c21d3e24f8 | |||
| 2d87aa0753 | |||
| b2ad4dc9a0 | |||
| 370f2ea98f | |||
| a05ca565ff | |||
| 52255637f2 | |||
| 0fcaa3a2f5 | |||
| 0e2fa6eb9d | |||
| 1aac462c83 | |||
| 2a0edfd8f7 | |||
| 1f59a9f846 | |||
| 80c20a90ea | |||
| 56a35649fe | |||
| f07cea0b79 | |||
| 4c1b08a281 | |||
| 117f9eddcd | |||
| 7bbbfce482 | |||
| f37a7811f9 | |||
| 9173c10239 | |||
| 318b31550d | |||
| c18ebc63a6 | |||
| d704694272 | |||
| 1cfec3bdf7 | |||
| fe6ea6bc10 | |||
| d29c8df45e | |||
| 71f996af95 | |||
| d9722ad6b3 | |||
| 398fd8028c | |||
| 1345a3cfd3 | |||
| 7eb0b195b8 | |||
| 009caee82d | |||
| 3bdc805a22 | |||
| ac457792b4 | |||
| 1377b54b9e | |||
| 66418ffc8c | |||
| b4c4b1fb70 | |||
| ffe4a4b047 | |||
| 753ce45310 | |||
| fece0d73e7 | |||
| edce076e68 | |||
| 675d0a009a | |||
| 5d41b5a4db | |||
| fe53b135eb | |||
| 5b1c154ee2 | |||
| 816d882611 | |||
| 12bcb09051 | |||
| c59c69a85f | |||
| bdd0daaf6f | |||
| cfad7c8356 | |||
| b2b8a128d0 | |||
| 1cfad80ca2 | |||
| a5a80e41b8 | |||
| 152f8e92bf | |||
| 0323560b49 | |||
| d3bc84a2f7 | |||
| 8a82c259bd | |||
| 46009c7658 | |||
| 6f760308bd | |||
| c346f8f17d | |||
| af1d059fff | |||
| 5562b21a20 | |||
| 8f68f31877 | |||
| ce7e94030c | |||
| ccf5a1b972 | |||
| 0d5ae77efc | |||
| 1695096d18 | |||
| 6db0b7cf18 | |||
| 575b43b0d4 | |||
| 7b39b05894 | |||
| 8bea9e0a5e | |||
| 2255b32e45 | |||
| b62573ae8f | |||
| 44ed84f5cf | |||
| d008c834be | |||
| 2d3a914aee | |||
| 7324f4c3d1 | |||
| 50c8860a50 | |||
| 6456de7188 | |||
| 23c629f2aa | |||
| 2bf154f74f | |||
| b598ad1bc0 | |||
| ace24ad68e | |||
| 750c1a0f27 | |||
| 52d89bd66b | |||
| 8cfb9d35e9 | |||
| 2f529158a0 | |||
| 6e68ab6d9e | |||
| 7a3c55af35 | |||
| fb39d6304a | |||
| 4cb57d9059 | |||
| 42d69bd0e5 | |||
| f27b399f81 | |||
| a545a3938f | |||
| d1e352c9ee | |||
| 99be1e798b | |||
| 2132a28a17 | |||
| 8b1cc28783 | |||
| 78364ac830 | |||
| 6e5f5732b5 | |||
| 87844254d1 | |||
| 08ef9f69fb | |||
| 5fbd1b78e7 | |||
| 39f5eb753f | |||
| f4cbe3f300 | |||
| 70632e5541 | |||
| 0bba700105 | |||
| b71aaccff3 | |||
| 7271ae9611 | |||
| 6e32dff2ad | |||
| 8f7c898c08 | |||
| f4a9815f48 | |||
| 0f8d5c7e98 | |||
| 5e83596a1b | |||
| 6361213e07 | |||
| 9c59a5d9b6 | |||
| bb04844bd5 | |||
| 0b988176fa | |||
| a354f18a2d | |||
| a7ca0fec88 | |||
| 06eec508df | |||
| 10dc580a3a | |||
| 2f6ae3ef01 | |||
| 392e803905 | |||
| 83a5fb585b | |||
| c6205ffbe0 | |||
| c04737ce20 | |||
| 11b92172fe | |||
| 3a6c574376 | |||
| b21ce925fb | |||
| de9dcc4ed6 | |||
| 9e77dbfe20 | |||
| 4cee0676a4 | |||
| 8ad9d21db3 | |||
| 8ba8317eea | |||
| d221187f24 | |||
| db54ec294f | |||
| 1d39796e3f | |||
| cd6a318903 | |||
| 73090b98ab | |||
| 745de1abab | |||
| 961031efc1 | |||
| 2487595778 | |||
| 5c4863d504 | |||
| 5e3a658932 | |||
| cb4704c821 | |||
| cc0b7d1492 | |||
| f8ebbf8b08 | |||
| 8795f60bf1 | |||
| f00c0a9436 | |||
| 767bc71870 | |||
| 4c068e3e00 | |||
| 277d862172 | |||
| dbed6a47bb | |||
| 94f3749784 | |||
| 728e6d851e | |||
| 11e863545f | |||
| dde49f0bb4 | |||
| a37a75aecc | |||
| e43e3aeb1c | |||
| a8fe529814 | |||
| d9f5e2bb08 | |||
| dfa83b0ac8 | |||
| bd5cef1411 | |||
| cd70b48831 | |||
| 50ebf8088a | |||
| c5cfb7eb40 | |||
| bccaafda6d | |||
| bf0086d7b5 | |||
| 7e65938ca6 | |||
| 112eff2509 | |||
| d7837d9179 | |||
| 6cdd057f80 | |||
| 5a03b213fb | |||
| f270213246 | |||
| 2e1795c5ba | |||
| 732d6710d3 | |||
| edf384d2ee | |||
| c307640826 | |||
| a77b598f82 | |||
| 217420cfa5 | |||
| f2b9dff596 | |||
| ae945ed315 | |||
| 770c153c76 | |||
| 29c4a7e606 | |||
| 8875470b37 | |||
| 6e52364bcb | |||
| 7015d616b4 | |||
| 92e6da3260 | |||
| 9220b6f1d5 | |||
| 1d0d538d0c | |||
| 83052eafae | |||
| fa95c3c4a2 | |||
| 665dcf221b | |||
| 8f73dbd253 | |||
| 826312cbad | |||
| 72a18f2b3f | |||
| a6b5e3d0ae | |||
| 1b321f4fa3 | |||
| fbde0b9f35 | |||
| 0e5f5e54cc | |||
| cbb5902066 | |||
| 92ec1b0598 | |||
| a62fc3abff | |||
| 08f8e55446 | |||
| 68f54a3247 | |||
| 29c099fe56 | |||
| 76b81c7b35 | |||
| d6b33ffd6b | |||
| 16b9873fa8 | |||
| ba4a686d1c | |||
| 4be3d79e12 | |||
| 2569b09dbe | |||
| 5d71e69941 | |||
| 16163bf20b | |||
| f1a97fecbd | |||
| a050f82f0e | |||
| ef7beea334 | |||
| 3f4acb33f9 | |||
| 14822e6395 | |||
| e82db4ed38 | |||
| 87b7ea9cf3 | |||
| 787b1fceff | |||
| 140d6ad839 | |||
| 46e8e22236 | |||
| c386db2b33 | |||
| 8dad091c6b | |||
| 3365ccbb9c | |||
| 2ced230965 | |||
| 989d10a3e1 | |||
| 62d8c69774 | |||
| cf704257b0 | |||
| a6cb6f57d3 | |||
| 141c703ed5 | |||
| 796d58867b | |||
| 2f483ec8e8 | |||
| e338918773 | |||
| d9effc58cf | |||
| 05d03f97fc | |||
| 03e891c0e8 | |||
| 4dfe9d52e9 | |||
| 9e65692b69 | |||
| 0687c9a57a | |||
| ffe1287016 | |||
| 75b7e7260f | |||
| d631e081bc | |||
| db5843d904 | |||
| 5ec16153f7 | |||
| 8c873ccdc8 | |||
| c95088f8d5 | |||
| 519fa55df7 | |||
| b8dda033ed | |||
| 0359e9c5c7 | |||
| d822b4a62a | |||
| d9e8c953b1 | |||
| 9eca502026 | |||
| cd0efe3edb | |||
| 8146e9cbcd | |||
| 5d95275024 | |||
| 49a97eea4b | |||
| 36e9c27e9c | |||
| 6e5153cd07 | |||
| c73da864c8 | |||
| 071bb75700 | |||
| 99374de340 | |||
| db7ae4ed5d | |||
| e61f481881 | |||
| 396a3ad2fc | |||
| be235ddc38 | |||
| 9e72ecd93d | |||
| 8e0bd936eb | |||
| 9d0270dcd6 | |||
| 713415c354 | |||
| 786550572e | |||
| 46caeddc81 | |||
| 71bfde2bfe | |||
| 76771b845a | |||
| a74e239e28 | |||
| 6e763b0b42 | |||
| 2f41ece017 | |||
| 01cd5fe0d5 | |||
| ed12ff7bb3 | |||
| f1386bb60d | |||
| 417bd06e76 | |||
| 91e46e3cf8 | |||
| deb5139c4d | |||
| 862ac5d014 | |||
| 028235d421 | |||
| 143d399849 | |||
| 375f171e47 | |||
| 387edcf4b2 | |||
| 011cd37cfb | |||
| 0d4254f319 | |||
| 4c407c2850 | |||
| 829e2d6c5d | |||
| a31c4bd474 | |||
| 17f24dc377 | |||
| de3e9f2809 | |||
| 4442a282e1 | |||
| 261010f23d | |||
| ede44ca6ee | |||
| 452a953234 | |||
| 2b122562ad | |||
| 6891bc3da3 | |||
| b31b8cd7f0 | |||
| e1379ac5ce | |||
| 0ef3f75d7a | |||
| 407a9e5be0 | |||
| 892bb9bf30 | |||
| 47ac871a12 | |||
| a38c3e7f6d | |||
| 08818355d1 | |||
| 0a68afef00 | |||
| 2c0783e327 | |||
| c2e5e45c84 | |||
| 014236c861 | |||
| 610fd7561b | |||
| d6f4480a4f | |||
| 28a6ac09ad | |||
| 86e4d24476 | |||
| 913a697ab2 | |||
| ebef2b1e44 | |||
| a61457b422 | |||
| 8f7f1135df | |||
| 89612c10c9 | |||
| d55bfb32f1 | |||
| d2b72cf496 | |||
| 8d90fffd46 | |||
| b84af27a86 | |||
| b45f28f3e9 | |||
| bfa1b5656a | |||
| 47f946cd65 | |||
| 970e7bfcda | |||
| a81c7a7cd6 | |||
| b0e1bd239f | |||
| 53ca41717a | |||
| 6a5bee0cdd | |||
| fd3ae51f83 | |||
| 5e5954a808 | |||
| add8540909 | |||
| 06a302aed0 | |||
| 147432d38d | |||
| 2a003ff72b | |||
| 8660d3324d | |||
| 6c59b73ae5 | |||
| 80218c1eca | |||
| f24d96d59f | |||
| d14bd49f46 | |||
| 1a692a0873 | |||
| 631a1a4ddc | |||
| 57df7601d9 | |||
| f7650000aa | |||
| 6f93c2d9b2 | |||
| 1654764968 | |||
| 1a1b8416e2 | |||
| 36c66d52a6 | |||
| 68fe43d488 | |||
| 877b9ee23b | |||
| 80ff93beeb | |||
| b9ddd2812b | |||
| ba54b56de4 | |||
| 85be67bc2d | |||
| ae20e01d2c | |||
| d094e8c3fc | |||
| f009fe1f63 | |||
| 2007fe5f49 | |||
| 84989ffa04 | |||
| 31b629a19c | |||
| e762d9e274 | |||
| 6833267b19 | |||
| 05f2833388 | |||
| 0d026ef18d | |||
| b756d93891 | |||
| f54513586d | |||
| 6c519c237e | |||
| 4ffde4db98 | |||
| 41847d31e7 | |||
| 24ce25bb5c | |||
| e051b69e80 | |||
| 59283d1164 | |||
| 0de32a5edc | |||
| 4f80066dcb | |||
| 04ddc8003f | |||
| 3213f98d66 | |||
| 1f16f85c51 | |||
| c03cb3a11c | |||
| 62e29a6546 | |||
| 3574b065d6 | |||
| c0c47f41be | |||
| 37761d580f | |||
| e075c8e691 | |||
| 0c61ca1a6b | |||
| 1846fa1f54 | |||
| 579ce20cad | |||
| 12e4bcba5d | |||
| b4f57dee3b | |||
| f11673ae3f | |||
| a27af7dd7e | |||
| 2b26a3cc14 | |||
| 47c4849694 | |||
| 30a4adf331 | |||
| 117a721166 | |||
| 1a219e62ba | |||
| c8d54b324b | |||
| 0ac2971fc1 | |||
| 348a40201b | |||
| 9f20ddc800 | |||
| 6f1cc2c1e5 | |||
| 601cd95277 | |||
| 8e9ce59ef2 | |||
| d76ef8e3cf | |||
| c19ffafd8d | |||
| 996a99ad75 | |||
| affb926d44 | |||
| c506e534aa | |||
| 9994315070 | |||
| 4f0d89ef8b | |||
| aab984618d | |||
| 8b662bc6b5 | |||
| 03ce7a8db3 | |||
| 033e7928b5 | |||
| b095f2a158 | |||
| 196c0e0ebc | |||
| 8ab309630b | |||
| 42bac47a71 | |||
| 3bc4de2236 | |||
| a6e4b45a38 | |||
| 28e97ccaf2 | |||
| 255781c029 | |||
| 7f5635ea8c | |||
| 4f18ec726c | |||
| 263622d628 | |||
| 1dfd2443ac | |||
| 881bd53f60 | |||
| ec4404b1ba | |||
| badaeac81f | |||
| 618d5ddaff | |||
| 4ed74af868 | |||
| 123d9af7d0 | |||
| 4f17b30915 | |||
| 1fc265b0aa | |||
| afae9b8d17 | |||
| 481be44879 | |||
| b8530b0f0b | |||
| 69de79684f | |||
| 6e6fd057b5 | |||
| 4b0ebf2b80 | |||
| ee82c32119 | |||
| 3fe6731035 | |||
| 1c3f3b5705 | |||
| def1ccffc4 | |||
| fa2e531343 | |||
| 814ddbc6cc | |||
| 267e8dcfb6 | |||
| 49ec1561f8 | |||
| e2dc612153 | |||
| 8f225431fe | |||
| 194be5e0b7 | |||
| 6788a05dd1 | |||
| 6a7066ac2f | |||
| ec5ff4e973 | |||
| fe6d460531 | |||
| 9cb97af10f | |||
| 1c784eea3d | |||
| 59dd33a461 | |||
| 97ebd912dc | |||
| 742fcc060c | |||
| 3ad5cb8a23 | |||
| 0d1f12e31a | |||
| a8ddf8f66d | |||
| f7a9c0a248 | |||
| 190badb395 | |||
| 3d91ab6c31 | |||
| c15b8d71bc | |||
| 5a707dba8a | |||
| ffd2fcde6b | |||
| 8e4056c1e4 | |||
| 1554e2b135 | |||
| 4715cbb70d | |||
| fd1611079a | |||
| 8edc03df64 | |||
| 9f5c0af5b8 | |||
| 6d6eeba5d5 | |||
| 5dfb64ef71 | |||
| e5bda7add7 | |||
| 77f9b336bd | |||
| cf930d0dde | |||
| f01c94e8bc | |||
| 0d774527b4 | |||
| 58ba9496d0 | |||
| 1993e94e53 | |||
| 3bcc06ed09 | |||
| 2f6ce88e28 | |||
| cd1dec9fc7 | |||
| 05872d7650 | |||
| 1dcee2ffa2 | |||
| 5f622efb77 | |||
| 52e8326d54 | |||
| 436532bed7 | |||
| d15e789200 | |||
| 98942f5528 | |||
| c7c21dc122 | |||
| 4500c1d1a4 | |||
| b8b983dded | |||
| d6a6673971 | |||
| 0580fe8db8 | |||
| c727e24138 | |||
| b83698ebf5 | |||
| 3fbbaa5130 | |||
| 2f48b840ae | |||
| efdee11d5a | |||
| 4c87e11aeb | |||
| e881e008b8 | |||
| 1b2837915d | |||
| d076a6724f | |||
| 386af71c39 | |||
| 49f277192c | |||
| 5974a6276b | |||
| e06a390771 | |||
| b34e204676 | |||
| 755d990dfd | |||
| 7185358b98 | |||
| 3843ec1e02 | |||
| cfc5631d5d | |||
| e64555aca0 | |||
| ef52ebb529 | |||
| c98136ca4f | |||
| 65f44d24ca | |||
| 44f20782fd | |||
| 9b1d76a5d0 | |||
| 21b5074ce8 | |||
| 0b8825fecb | |||
| 3d3c20e507 | |||
| 67a282f19f | |||
| 92023b533a | |||
| c1d14c150e | |||
| aa656c74d5 | |||
| e39b7ffe30 | |||
| 1897148abc | |||
| b76118802a | |||
| 8266aa3343 | |||
| ab0c349261 | |||
| d5e0e66426 | |||
| c5b3107f83 | |||
| 1a0a64e4de | |||
| 6bd9805bcc | |||
| f74c2af65c | |||
| 9531bdf674 | |||
| 76e705e7ee | |||
| d35211328e | |||
| b7bbd81dda | |||
| 9836dd5d10 | |||
| 2109ad320d | |||
| c026121c0e | |||
| ee0c87f7b1 | |||
| 709fb93a22 | |||
| b38cd0a48d | |||
| 264435c32d | |||
| c285929ad3 | |||
| 1cbea8157d | |||
| 0a10334f1b | |||
| f0d5a6ebac | |||
| db7086b5e6 | |||
| 0e92280b33 | |||
| 0d7255158a | |||
| 33564b68dd | |||
| ba942b952a | |||
| bd7f28896e | |||
| 18fe124696 | |||
| ea3a3b6e1c | |||
| e6c06aacff | |||
| 1aee92cd5c | |||
| 40c4cad491 | |||
| 013d46fb02 | |||
| f0f465411f | |||
| 32ce83475d | |||
| ec0d3f5b5d | |||
| 75294b9146 | |||
| 26a0eb68ef | |||
| b983e29fb0 | |||
| 68dadabc29 | |||
| ed9fd3f0e0 | |||
| fa9573436a | |||
| 6d2058c3b7 | |||
| 0d7f93b877 | |||
| f022c9d510 | |||
| 5964a06386 | |||
| f14dc4a4e9 | |||
| fd56e2534c | |||
| 08962a74ab | |||
| f850d36c52 | |||
| c5fb161477 | |||
| bfc2fab33f | |||
| ec9d6c4fd2 | |||
| 6135d61e3d | |||
| a677242a2c | |||
| 6602f30112 | |||
| a4b8dc18c1 | |||
| c0d4741f88 | |||
| b33718180c | |||
| 3872393b29 | |||
| 1d72a7df99 | |||
| 5455908772 | |||
| 8882192fac | |||
| 7b77491c06 | |||
| 20bf214d6e | |||
| 8ab3e63aeb | |||
| 0dc03214c5 | |||
| 362e98b43d | |||
| 193e085cf0 | |||
| e0df2a342b | |||
| ba19ccac43 | |||
| d7261b7a78 | |||
| 0d80173efd | |||
| 930f07d15e | |||
| 66df7389d2 | |||
| c7bf0b6ddd | |||
| 0bc361adeb | |||
| 4fff523a6d | |||
| 67e09fb342 | |||
| c360806f47 | |||
| 7b74b73b08 | |||
| e9a851c0d4 | |||
| b13b169149 | |||
| 455329a745 | |||
| a68b76c8b4 | |||
| 96e3899216 | |||
| 771ab5ea9a | |||
| 3c87e6b270 | |||
| 6d8afec510 | |||
| 89e25657d8 | |||
| 29387f1fcf | |||
| 58e885c052 | |||
| 984dfcd7e1 | |||
| 3785479086 | |||
| 8ed280907c | |||
| d742671205 | |||
| 87e72c28a4 | |||
| 4dee357362 | |||
| 431f4b9b0d | |||
| dd5b7825d5 | |||
| 02bc48925a | |||
| 4eb505755e | |||
| 83e94a70ea | |||
| 8a150b27c3 | |||
| 1a51451ec2 | |||
| 41e51bfb77 | |||
| 7e1d9bc768 | |||
| ba065ec1d8 | |||
| fe057a91c8 | |||
| d2c36eefc9 | |||
| 28d56bab04 | |||
| 2500eff90d | |||
| 153446b3a1 | |||
| 391f5caaa2 | |||
| cc0df92444 | |||
| 03910d67c3 | |||
| fec5cc864e | |||
| cb78362713 | |||
| 4c5b1a6ff4 | |||
| 83c5727698 | |||
| 80838ff1e9 | |||
| 29e8d072b7 | |||
| d7592f01e1 | |||
| 392f283d9e | |||
| bcd738ebbb | |||
| 8020c52c48 | |||
| 3f566e541d | |||
| be4a631dc8 | |||
| 0bfdf908c1 | |||
| 6f2fc23f77 | |||
| f3a47c7e70 | |||
| 36349ffabb | |||
| b13f7366cf | |||
| 9181bcd9a7 | |||
| 7dbc1d894b | |||
| 5720445d15 | |||
| a90027521d | |||
| e02d400bf6 | |||
| efadb8fd31 | |||
| a19d06561b | |||
| 0b685d11c9 | |||
| 28f019d672 | |||
| bf5cbfffc2 | |||
| fe021e7c51 | |||
| c42fb54bc6 | |||
| 9382b68781 | |||
| 178198a417 | |||
| 7068e90771 | |||
| 1c762f23d0 | |||
| fd2b9a6e21 | |||
| db43910288 | |||
| f248c0460e | |||
| b8e3c0ceb4 | |||
| b5053d889e | |||
| 12ba7776b3 | |||
| 7817e88d03 | |||
| 8dec65853d | |||
| 88e3cb3be1 | |||
| fa702b48e3 | |||
| 299dcf6686 | |||
| 27f9ae5bbb | |||
| 9cb3a853f1 | |||
| 95c8ef4148 | |||
| a41bb52014 | |||
| 914cd7221e | |||
| 2dfc0a58ab | |||
| 0c9f3c638a | |||
| a966d6acf1 | |||
| 1e0c38b5f9 | |||
| d3323d6550 | |||
| ebed0b9f20 | |||
| f654a453dc | |||
| 10decf94cc | |||
| 96dd4817f1 | |||
| 72906cdc6a | |||
| fba4375be0 | |||
| 75120676ad | |||
| 7daf63fd3f | |||
| 014de25f6f | |||
| 3fc6535012 | |||
| 4fc0a32572 | |||
| dcc704a357 | |||
| bd8acbde97 | |||
| 112b10c19d | |||
| d89e561a85 | |||
| 49c1da79c8 | |||
| 0a72f00175 | |||
| 1af5820db0 | |||
| c117491549 | |||
| d8748f4270 | |||
| c0ba6e13e4 | |||
| c34daf1a35 | |||
| d461b53235 | |||
| c3ee14eb67 | |||
| 869fb8e327 | |||
| fbbc3024d6 | |||
| f1ba0c0aa7 | |||
| 54340ab4bf | |||
| 39732eee5e | |||
| a9e4526a6d | |||
| 57a6d2abf9 | |||
| d6246941ac | |||
| 2eb91f9b91 | |||
| 34ae413607 | |||
| ee9f8c184b | |||
| 7a84afcbdb | |||
| b8a16ea99d | |||
| 095466d5c7 | |||
| 89cfa22c3f | |||
| 1f18050930 | |||
| 537b78d564 | |||
| 717fd57ce1 | |||
| 3fb7786868 | |||
| 17ecfc9765 | |||
| 5326260a76 | |||
| e7522f4bdf | |||
| 504deeff42 | |||
| b7785b64cf | |||
| f914cb6858 | |||
| 91051d2521 | |||
| 51536a7acd | |||
| 263ccab6e3 | |||
| 9f87755dcb | |||
| 60b4cca5e5 | |||
| d2718e99a4 | |||
| 69a00c0ab3 | |||
| 3272d23917 | |||
| 7f0545cae7 | |||
| 68f35deb86 | |||
| c4f4035072 | |||
| a7d8845952 | |||
| a3378393b0 | |||
| 3dfe0ad478 | |||
| 9a3b7a4f3f | |||
| 78579b1103 | |||
| 7d50344512 | |||
| 7a00c12065 | |||
| af71e67681 | |||
| b3e20fc324 | |||
| bd1014abb6 | |||
| 7f76664a5d | |||
| 0a5a80b05d | |||
| 2d63da0660 | |||
| 8387527d2e | |||
| 5d03ba7d63 | |||
| 0ece50c122 | |||
| f2ac297252 | |||
| 0ca8ae17d4 | |||
| 88ca87cf9e | |||
| 0d69d228e4 | |||
| a3afe95306 | |||
| 9fb4af8658 | |||
| 9bb6ba9311 | |||
| faa42ba341 | |||
| 596827a912 | |||
| 89b4292445 | |||
| dd88737414 | |||
| 5456cfc304 | |||
| 1e66096ea7 | |||
| 2b6ae3908c | |||
| 1924612479 | |||
| 2af5bdeaab | |||
| b28565b38d | |||
| fec602362b | |||
| 6753c5f45a | |||
| 2f3c108d42 | |||
| ce6d99bdb4 | |||
| 86d4125893 | |||
| 3a18f00379 | |||
| e6274904a7 | |||
| 3677395444 | |||
| 22ba35b3b5 | |||
| 9c1ab9979b | |||
| eaa463e1c9 | |||
| 6984be48c3 | |||
| b739bd3d79 | |||
| 23f3e4396c | |||
| c264750924 | |||
| c155f0a5d5 | |||
| 76734f086d | |||
| 4f2d1172dd | |||
| 75caf4e297 | |||
| 509ab8261f | |||
| 1e05b40d4f | |||
| 451390f835 | |||
| 58cce9d2f8 | |||
| 2eb6e3b0ea | |||
| fb1181ed26 | |||
| 6d5e1d529d | |||
| 0e0ca08924 | |||
| 5d948a67a8 | |||
| 6a4db2ecab | |||
| f700273624 | |||
| 0c198e0ccc | |||
| 71ffbbc420 | |||
| 4fd09b889d | |||
| 4cb2a3eebe | |||
| c25186b1f6 | |||
| 779033d0bc | |||
| 3e31560e7d | |||
| d23d7e8775 | |||
| f6fdf5cb7f | |||
| 1879ccd27d | |||
| 08c0796719 | |||
| edc7994ce5 | |||
| bcfcfbd064 | |||
| 9e79b3258d | |||
| 243873cd2d | |||
| c7b8a4b0c1 | |||
| e39e0c7140 | |||
| d4a3f11dbb | |||
| 0962f266b3 | |||
| 69e4d3fdad | |||
| c0908f463a | |||
| b00a61a17b | |||
| 553c2f886a | |||
| 4fd9c5772a | |||
| 04e0e06d85 | |||
| 4d7829d72b | |||
| 6b751aac57 | |||
| 813349fd23 | |||
| 16a2744782 | |||
| 7b6870db22 | |||
| 3e38e7d52c | |||
| 8142d3474d | |||
| 8773649de6 | |||
| c117920ff9 | |||
| c8dd2a3eb8 | |||
| 90b1817e92 | |||
| d6c3ff5997 | |||
| 984ec25132 | |||
| a7bff34784 | |||
| a6e7afbc91 | |||
| 33f1d63b64 | |||
| f95e171e11 | |||
| c82b50b212 | |||
| 2b402b77f1 | |||
| adcb551020 | |||
| 2680aabe06 | |||
| d5c0533b74 | |||
| 609307668b | |||
| cdaf36572a | |||
| 033c8d5d51 | |||
| 6216ec1d6a | |||
| 6c9c67f6c5 | |||
| 5bd32b5521 | |||
| 549336f75b | |||
| f0e75f30b3 | |||
| 144c09f175 | |||
| ee50c0f97c | |||
| ade921bf02 | |||
| 676cacff04 | |||
| a3097d5e25 | |||
| fd78148558 | |||
| a4d79d7375 | |||
| df04e8183d | |||
| c43c484a62 | |||
| 0608c35669 | |||
| 7dd4d06e26 | |||
| 1ee0310b86 | |||
| cc0a52038f | |||
| 6aed1fe231 | |||
| 680608fe18 | |||
| ec6acbc602 | |||
| cb7ee4c5d2 | |||
| 88d5798f45 |
+111
@@ -0,0 +1,111 @@
|
|||||||
|
# Support for AppVeyor CI -- https://www.appveyor.com/
|
||||||
|
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||||
|
|
||||||
|
os: Visual Studio 2015
|
||||||
|
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- /^gitlab.*/
|
||||||
|
- /^travis.*/
|
||||||
|
|
||||||
|
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: msvc-14.1-x86, CL_VERSION: 19.16, VS_VERSION: 2017, APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 }
|
||||||
|
- { C: msvc-14.1-x64, CL_VERSION: 19.16, VS_VERSION: 2017, APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 }
|
||||||
|
- { C: msvc-14.2-x86, CL_VERSION: 19.24, VS_VERSION: 2019, APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 }
|
||||||
|
- { C: msvc-14.2-x64, CL_VERSION: 19.24, VS_VERSION: 2019, APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 }
|
||||||
|
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 cmp & 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 & where touch
|
||||||
|
# - 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 )
|
||||||
|
- if "%C%"=="msvc-14.1-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 )
|
||||||
|
- if "%C%"=="msvc-14.1-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 )
|
||||||
|
- if "%C%"=="msvc-14.2-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 )
|
||||||
|
- if "%C%"=="msvc-14.2-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 )
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- cd c:\projects\upx
|
||||||
|
# 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 -WX -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -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
|
||||||
|
# info: it seems that ssh is not properly installed/started on the 2019 worker image
|
||||||
|
- if NOT "%VS_VERSION%"=="2019" ( bash ./.github/travis_deploy.sh )
|
||||||
|
|
||||||
|
# vim:set ts=2 sw=2 et:
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
.bzr*
|
|
||||||
.darcs*
|
|
||||||
.git*
|
|
||||||
.hg*
|
|
||||||
_darcs
|
|
||||||
B
|
|
||||||
build*
|
|
||||||
doxygen
|
|
||||||
maint
|
|
||||||
ChangeLog.cvs*
|
|
||||||
GNUmakefile
|
|
||||||
MMakefile
|
|
||||||
TODO.*
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# see https://editorconfig.org/
|
||||||
|
#
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[{GNUmakefile*,MMakefile*,Makefile*,Makevars*,*.mk}]
|
||||||
|
indent_size = 8
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
[*.S]
|
||||||
|
indent_size = 8
|
||||||
|
|
||||||
|
[*.yml]
|
||||||
|
indent_size = 2
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<!---
|
||||||
|
|
||||||
|
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,170 @@
|
|||||||
|
#! /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
|
||||||
|
if [[ -f "$HOME/local/bin/bin-upx/upx-stubtools-check-version" ]]; then
|
||||||
|
bin_upx=$(readlink -en -- "$HOME/local/bin/bin-upx")
|
||||||
|
elif [[ -f "$HOME/.local/bin/bin-upx/upx-stubtools-check-version" ]]; then
|
||||||
|
bin_upx=$(readlink -en -- "$HOME/.local/bin/bin-upx")
|
||||||
|
else
|
||||||
|
bin_upx=$(readlink -en -- "$upx_SRCDIR/../deps/bin-upx-20160918")
|
||||||
|
fi
|
||||||
|
cd / && cd $upx_SRCDIR || exit 1
|
||||||
|
extra_subdirs=()
|
||||||
|
extra_subdirs+=( src/stub/src/arch/amd64 )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/arm/v4a )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/arm/v4t )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/arm64/v8 )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/i386 )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/m68k/m68000 )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/m68k/m68020 )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/mips/r3000 )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/powerpc/32 )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/powerpc/64 )
|
||||||
|
extra_subdirs+=( src/stub/src/arch/powerpc/64le )
|
||||||
|
make -C src/stub maintainer-clean
|
||||||
|
for d in ${extra_subdirs[@]}; do
|
||||||
|
make -C $d -f Makefile.extra maintainer-clean
|
||||||
|
git status $d || true
|
||||||
|
done
|
||||||
|
git status src/stub/src || true
|
||||||
|
git status || true
|
||||||
|
failed=0
|
||||||
|
for d in ${extra_subdirs[@]}; do
|
||||||
|
PATH="$bin_upx:$PATH" make -C $d -f Makefile.extra || failed=1
|
||||||
|
done
|
||||||
|
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
|
||||||
|
git status
|
||||||
|
if [[ $BM_X == rebuild-stubs ]]; then
|
||||||
|
echo "X=rebuild-stubs done. Exiting."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
unset bin_upx extra_subdirs d failed
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# build UCL
|
||||||
|
#
|
||||||
|
|
||||||
|
cd / && cd $ucl_BUILDDIR || exit 1
|
||||||
|
# patch UCL
|
||||||
|
sed 's/^#elif (ACC_ARCH_AMD64 || ACC_ARCH_IA64)$/& \&\& !defined(__ILP32__)/' $ucl_SRCDIR/acc/acc_chk.ch > a.tmp
|
||||||
|
if cmp -s a.tmp $ucl_SRCDIR/acc/acc_chk.ch; then rm a.tmp; else mv a.tmp $ucl_SRCDIR/acc/acc_chk.ch; fi
|
||||||
|
if [[ $BUILD_LOCAL_UCL == 1 ]]; 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
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
#! /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 and do not deploy debug builds
|
||||||
|
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
|
||||||
|
appveyor*) ;;
|
||||||
|
devel*) ;;
|
||||||
|
gitlab*) ;;
|
||||||
|
master*) ;;
|
||||||
|
travis*) ;;
|
||||||
|
*) exit 0;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# get $rev, $branch and $git_user
|
||||||
|
cd / && cd $upx_SRCDIR || exit 1
|
||||||
|
rev=$(git rev-parse --verify HEAD)
|
||||||
|
if [[ "$branch" == gitlab* ]]; then
|
||||||
|
if git fetch -v origin devel; then
|
||||||
|
git branch -a -v
|
||||||
|
rev=$(git merge-base origin/devel $rev || echo $rev)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
timestamp=$(git log -n1 --format='%at' $rev)
|
||||||
|
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
|
||||||
|
unset cpu os
|
||||||
|
fi
|
||||||
|
d=$d-$BM_C-$BM_B
|
||||||
|
|
||||||
|
# remove redundant -m32/-m64/-x86/-x64 from directory name
|
||||||
|
if [[ $d =~ ^((i386-darwin|i386-linux|i386-win32).*)(-m32|-x86)(-.+)?$ ]]; then
|
||||||
|
d="${BASH_REMATCH[1]}${BASH_REMATCH[4]}"
|
||||||
|
fi
|
||||||
|
if [[ $d =~ ^((amd64-darwin|amd64-linux|amd64-win64).*)(-m64|-x64)(-.+)?$ ]]; then
|
||||||
|
d="${BASH_REMATCH[1]}${BASH_REMATCH[4]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n $subdir ]]; then
|
||||||
|
print_header "DEPLOY $subdir/$d"
|
||||||
|
else
|
||||||
|
print_header "DEPLOY $d"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
unset f
|
||||||
|
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 || true
|
||||||
|
fi
|
||||||
|
git ls-files -v
|
||||||
|
|
||||||
|
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 -v
|
||||||
|
#git log --pretty=fuller
|
||||||
|
|
||||||
|
umask 077
|
||||||
|
[[ -d ~/.ssh ]] || mkdir ~/.ssh
|
||||||
|
fix_home_ssh_perms
|
||||||
|
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
|
||||||
|
fix_home_ssh_perms
|
||||||
|
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
|
||||||
|
fix_home_ssh_perms
|
||||||
|
|
||||||
|
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 branch -a -v
|
||||||
|
git fetch -v origin "$branch"
|
||||||
|
git branch -a -v
|
||||||
|
git rebase FETCH_HEAD
|
||||||
|
git branch -a -v
|
||||||
|
sleep $((RANDOM % 5 + 1))
|
||||||
|
let i+=1
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,268 @@
|
|||||||
|
## 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")
|
||||||
|
chmod() {
|
||||||
|
gchmod "$@"
|
||||||
|
}
|
||||||
|
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_UCL=1
|
||||||
|
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_UCL=1
|
||||||
|
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
|
||||||
|
if [[ $TRAVIS_OS_NAME == osx ]]; then
|
||||||
|
case $BM_C in
|
||||||
|
clang | clang-m?? | clang-[6789][0-9][0-9]-m?? | clang-1[0-1][0-9][0-9]-m??)
|
||||||
|
CC="clang"; CXX="clang++" ;; # standard system compiler
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
case $BM_C in
|
||||||
|
clang | clang-m?? | clang-3.4-m??)
|
||||||
|
CC="clang"; CXX="clang++" ;; # standard system compiler
|
||||||
|
clang-[3456].[0-9]-m??)
|
||||||
|
v=${BM_C:6:3}; CC="clang-$v"; CXX="clang++-$v"; SCAN_BUILD="scan-build-$v" ;;
|
||||||
|
clang-[789]-m??)
|
||||||
|
v=${BM_C:6:1}; 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-[56789]-m?? | gcc-[56789]-mx32)
|
||||||
|
v=${BM_C:4:1}; CC="gcc-$v"; CXX="g++-$v" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
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"; BUILD_LOCAL_UCL=1; BUILD_LOCAL_ZLIB=1 ;;
|
||||||
|
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_header() {
|
||||||
|
local x="==========="; x="$x$x$x$x$x$x$x"
|
||||||
|
echo -e "\n${x}\n${1}\n${x}\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
fix_home_ssh_perms() {
|
||||||
|
if [[ -d ~/.ssh ]]; then
|
||||||
|
if [[ -x /usr/sbin/restorecon ]]; then
|
||||||
|
/usr/sbin/restorecon -v -R ~/.ssh || true
|
||||||
|
fi
|
||||||
|
chmod -c -R go-rwx ~/.ssh || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
@@ -0,0 +1,210 @@
|
|||||||
|
########## begin .sha256sums.recreate
|
||||||
|
expected_sha256sums__t010_decompressed="\
|
||||||
|
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
|
||||||
|
24808d572483f4cd713d66894b3da406755038737007a78b076528e6407e3132 *amd64-linux.elf/upx-3.95
|
||||||
|
c5007328ffcec842bb808329470afd71c9f7bf6416f5f5c978be1f942fe72618 *amd64-win64.pe/upx-3.95.exe
|
||||||
|
f7279729eb975e4238f8b8ee56fefa41ccbeb35ef0ffe4c34f8047baab78fff5 *arm-linux.elf/upx-3.95
|
||||||
|
28d7ca8f0dfca8159e637eaf2057230b6e6719e07751aca1d19a45b5efed817c *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
|
||||||
|
0dbc3c267ca8cd35ee3ea138b59c8b1ae35872c918be6d17df1a892b75710f9b *i386-win32.pe/upx-3.91.exe
|
||||||
|
e0dfcb440bb43d53cf68f0178429a5136f8f7f13544499ad17699a98a6f8ffc0 *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
|
||||||
|
c5007328ffcec842bb808329470afd71c9f7bf6416f5f5c978be1f942fe72618 *amd64-win64.pe/upx-3.95.exe
|
||||||
|
f7279729eb975e4238f8b8ee56fefa41ccbeb35ef0ffe4c34f8047baab78fff5 *arm-linux.elf/upx-3.95
|
||||||
|
28d7ca8f0dfca8159e637eaf2057230b6e6719e07751aca1d19a45b5efed817c *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
|
||||||
|
0dbc3c267ca8cd35ee3ea138b59c8b1ae35872c918be6d17df1a892b75710f9b *i386-win32.pe/upx-3.91.exe
|
||||||
|
e0dfcb440bb43d53cf68f0178429a5136f8f7f13544499ad17699a98a6f8ffc0 *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="\
|
||||||
|
82a3c42af2aae745b6b233fb4c0d3b60c3a2b224ada7af4b81d062d913503bac *amd64-linux.elf/upx-3.91
|
||||||
|
8959e46212b736476f517f911b7740038da882b30788efebf71d0108a01cecf8 *amd64-linux.elf/upx-3.95
|
||||||
|
099a690a01bb8e08bb88a09919241c499aae1fa282f3fa49588f1240b1fdd3e8 *amd64-win64.pe/upx-3.95.exe
|
||||||
|
39f86a05b5a7065e13e028638d324d9ddbf72fc537f0a62ad4637364722249f2 *arm-linux.elf/upx-3.95
|
||||||
|
a6d50d99a37ed7d52ea6b53be1d2ce57550139276d450be0ccfc0c61eac99498 *arm-wince.pe/upx-3.91.exe
|
||||||
|
7cfb366a6ed04c6a2706a7cc28411c6f190dfde56403fc52eb1677130dd4307f *arm64-linux.elf/upx-3.95
|
||||||
|
9532ef921b3bfb02deaeb59cb33aaa499132af689fa1df51499790f26e99a790 *armeb-linux.elf/upx-3.91
|
||||||
|
b076ac9531bee0fbcf44824c2baf83284e747bb381325076c0a1466b9002581c *armeb-linux.elf/upx-3.95
|
||||||
|
5c365ab8f4c5811a55cceab8d6bfa59ee56c89a966d423e1f734cd27745e7191 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||||
|
70c13950a28362bf4d5f49b496f683e2ed2d28875891cff283e11f2916163956 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||||
|
32649cd041f5bee83d02b065c486ac8f26dd29d28a05c36503d42edd62ce7767 *i386-linux.elf/upx-3.91
|
||||||
|
f8dc23edc677f99075746f5f722ceb1642a82e3f38e5041fa1bf232016bdfc6e *i386-linux.elf/upx-3.95
|
||||||
|
1ab486ab59e331a811b7b16880b0673443a378442d875067377d4427075e124c *i386-win32.pe/upx-3.91.exe
|
||||||
|
f0416ec4793a0eed79858feaec6e5f9e04e8cdd7f7fe8bdef9c25fffbef6d358 *i386-win32.pe/upx-3.95.exe
|
||||||
|
2139848afeae725b6d7d95786a7ac5f07bf7116a76dfee169f99b3444cfca277 *m68k-atari.tos/upx-3.91.ttp
|
||||||
|
45c6f581807c0382462911899d30957d10ff58e6f2c4fde15d2187a0affa7785 *mips-linux.elf/upx-3.95
|
||||||
|
bc1ab2df1985aec60f78b1ee7adf52c6bc30d207dc4aca5f7f3b2cc187cc98ed *mipsel-linux.elf/upx-3.91
|
||||||
|
29d67983278a5149d122eb98b2f73f8abb648bc88cfcaae7ad468d69d5dbe3c4 *mipsel-linux.elf/upx-3.95
|
||||||
|
0a652f004aac31d2baa4610561ecd8210841f366b2f210953212a9e0750c301f *powerpc-linux.elf/upx-3.91
|
||||||
|
2bfc2e143736f378904f0f1322aaaf4086877fb37fd783ab4d0789825d59e6d5 *powerpc-linux.elf/upx-3.95
|
||||||
|
2c8657627f2247963d0187d6e5cf02fbe3bd84f2475908c234ecc1ae081b9ba7 *powerpc64le-linux.elf/upx-3.95
|
||||||
|
"
|
||||||
|
expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\
|
||||||
|
fcbe8cf92e76268950bd09e1285ce4cd9756d5505784e1e495a54623a88de8c5 *amd64-linux.elf/upx-3.91
|
||||||
|
272dbd7aa6eba2202008b9d5853fe8e24e894e7df66bf988690d96f428aeb93d *amd64-linux.elf/upx-3.95
|
||||||
|
7b7bd8e5c0d4e29ef9f3b97eb76dfe0afbe711172e25ee9c3079d656c5d036dd *amd64-win64.pe/upx-3.95.exe
|
||||||
|
21af84a819e789fad98534cb973c4ad3806cf7676caf546c9e4ace33d559e7e0 *arm-linux.elf/upx-3.95
|
||||||
|
74060375496ef1450252c9b30547ef3235b79e2b57666500dd44c61fedc0539e *arm-wince.pe/upx-3.91.exe
|
||||||
|
efb6240ce6a2be00906a4a3ba7652160e5aee43ed968961c1bc55ea370f6cd93 *arm64-linux.elf/upx-3.95
|
||||||
|
dc24337091e85595bf9ce259a702c52e9cc10e31d759df8f1ad26e65c148ed04 *armeb-linux.elf/upx-3.91
|
||||||
|
cde5cc6967cbee06c260a25eef3d7cdaf430bf8a63db5a6dfc8a9079ec895c52 *armeb-linux.elf/upx-3.95
|
||||||
|
217f050aecd01f04ef9eba37fed518c4380f170d3cdb483ae019312fad827490 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||||
|
5a909066dd5aac865e36a26f7d002a8ddf6ae57e93a1dc1f6582b922388e9489 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||||
|
909650339b3a93360b622a4ab2c9a2e489206ddbd4af2556101ff68a1082cf0f *i386-linux.elf/upx-3.91
|
||||||
|
d778256d361ab72ea9629a45a8c8ea501007978f64df6a003024f7a07efaf8e4 *i386-linux.elf/upx-3.95
|
||||||
|
8217b20bac36090189a7415196e96df93e0110f5d716d15ed84d0c1ac4b001e5 *i386-win32.pe/upx-3.91.exe
|
||||||
|
eb6a8c4e3652c75f4b054cc36933a4c9853ca23e4f2790ad6505368dc1ba82b7 *i386-win32.pe/upx-3.95.exe
|
||||||
|
29bf5c38da5cf33aecf6c48c55acdb0d73a3878790786f48815cbd8ad1819037 *m68k-atari.tos/upx-3.91.ttp
|
||||||
|
5163bf81989cf96127e833eacafa605248b3139ade256512122a8d56a00d8475 *mips-linux.elf/upx-3.95
|
||||||
|
6da6103fb68113c930f59455a504a5fbb1b982971d488f6cb34e6e19154eb812 *mipsel-linux.elf/upx-3.91
|
||||||
|
98c5ea01aeabb9d3d54b47dbce13b5884e3ff2b856598d191fe50eb026da48b4 *mipsel-linux.elf/upx-3.95
|
||||||
|
35458012d9e90013c6ff6442b9a5b2a5dc90ea1451c7653b0d144ea8be9b8fd5 *powerpc-linux.elf/upx-3.91
|
||||||
|
a61669951a13a530fa06d9e0286c4c9ff18e47be836ccdde4c24acc5d0e7dda0 *powerpc-linux.elf/upx-3.95
|
||||||
|
852844b06078a5c820936e31cd52f4edc44b42ee9aa0edca9a21ee41b4442af5 *powerpc64le-linux.elf/upx-3.95
|
||||||
|
"
|
||||||
|
expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\
|
||||||
|
24d0578ee2a83d40de7740c7141c1b102961c505a04155ca3b66c73c493eee64 *amd64-linux.elf/upx-3.91
|
||||||
|
4253f580fa8bb00db0a093c3826350f759f096098fcb43195eb71f4213479d85 *amd64-linux.elf/upx-3.95
|
||||||
|
626ac9e02a60c25ab26bfd96120ef728abd3c7ed56b23b81cf22f439a8673e5f *amd64-win64.pe/upx-3.95.exe
|
||||||
|
40d1f54eb707b51223a36e939caabd7a4df81c87edd12f36c40f525bcf59f919 *arm-linux.elf/upx-3.95
|
||||||
|
8f29c06b3eb3770eae267e6adad6bbaf3c03e12a1649e085d044d7ea03638d3b *arm-wince.pe/upx-3.91.exe
|
||||||
|
bebb9c6327d88eb92bad9b1182d4f8f732caaed4e6aff169057ad108016a6f72 *arm64-linux.elf/upx-3.95
|
||||||
|
94010dc973ce886131b6ecd9775e0a3e9ed421503bfc74954f31a154e4a60d39 *armeb-linux.elf/upx-3.91
|
||||||
|
49b3c157b56c2cf2b206447b981d7e74561fde02569ccb73814a187163a1e05a *armeb-linux.elf/upx-3.95
|
||||||
|
12fd7e4e4e5c4067880e7e3db0526601f67d1456e7fa2c77e46beb3c10234bb1 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||||
|
3771f947c9ce27221c3c647aa6814cc990734cd4f5ec8b4a1e4fb890e8352130 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||||
|
27141ee7a92c81461233e0f7ef2dd22bf9d086c6b006af9a7a63906ea998a8b3 *i386-linux.elf/upx-3.91
|
||||||
|
bdeda6183b13f14b389829be4c23e8aeb202ff16b9b5f6644ec98ef448529780 *i386-linux.elf/upx-3.95
|
||||||
|
37871a1a85954ced4211b3930d4f27acd51f77e999ea8801c01667f221ccde4a *i386-win32.pe/upx-3.91.exe
|
||||||
|
27a77ed9d8243e1f1ccf2051f80977c8727790823dcdfd33d788b97ee32482eb *i386-win32.pe/upx-3.95.exe
|
||||||
|
bd45c11476def67a48cd8c8b79fde0bcc10da4a4811fd1cd87acb4b8cb317f7c *m68k-atari.tos/upx-3.91.ttp
|
||||||
|
b2d63e1a494f9ad8296f7c5b90c22d67c4e554c6bd2d0a9685c8d45bf2b4cba4 *mips-linux.elf/upx-3.95
|
||||||
|
48772c5cc502e503978da73d6f72eea2cafa55c06726c3b61f8b80e17f523b18 *mipsel-linux.elf/upx-3.91
|
||||||
|
e7499fb50da2a7000e5ccb9d8b0d022c71ec449c81e2edf27e48e413f0258c1e *mipsel-linux.elf/upx-3.95
|
||||||
|
fdf8a7484ca0771d11509183639610fa0dcdb36d195013a8f4f754094545a259 *powerpc-linux.elf/upx-3.91
|
||||||
|
839de35bcc7e7beb185055c60ad8728731a0456c7a32bb69e30faee5646dfdbc *powerpc-linux.elf/upx-3.95
|
||||||
|
dccd1b5296c1a70533332e9eec2788f74abcebf223fb6e44642148bdcc63b195 *powerpc64le-linux.elf/upx-3.95
|
||||||
|
"
|
||||||
|
expected_sha256sums__t140_compress_lzma_2_no_filter="\
|
||||||
|
8bdcd33cb7073de57e3b72fcdfd52693d80e063c8f18c146fcbcb93feaa57438 *amd64-linux.elf/upx-3.91
|
||||||
|
c0cc9f01d4c74c003df410070f19181275650c96d6267b5af6d2029f72ecc2d5 *amd64-linux.elf/upx-3.95
|
||||||
|
32df633b40027b08da5a0cb4845294c971c2e133ee2506684979a3532c5fc685 *amd64-win64.pe/upx-3.95.exe
|
||||||
|
91474e9a68d5225916b2582ffbcae23d2644ece6f823686b1692edba0d909066 *arm-linux.elf/upx-3.95
|
||||||
|
19455d55f642e610df5f9071d59cde24d5db013ae8215a9946b3a995c6cb123a *arm-wince.pe/upx-3.91.exe
|
||||||
|
abd540824d65696fbb0aa45e1935f286435fc9c53049ac66d916cf53c39278b5 *arm64-linux.elf/upx-3.95
|
||||||
|
832db37f9c05d6e80e44d26974bc8368dcc02eadeeb37f4f79513855dc5e8ffb *armeb-linux.elf/upx-3.91
|
||||||
|
339086e40ae660fec688995a1fdb3b89487859891521a8dd03b44aaba9372331 *armeb-linux.elf/upx-3.95
|
||||||
|
3b4466fb3defcff86d7679b7c35929f959eba2e8d64f08099e3fbc5e7fd5aab9 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||||
|
6a722037156b5b75e6622f4ac8187d163a73f7e090c0b6374d0c745f84ba197c *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||||
|
b67cc7eaee651c5ee41b02ae1894c3740274a1dd258e734c7933c48edf81ed06 *i386-linux.elf/upx-3.91
|
||||||
|
68eb9861137a5d0c05367f671343556f145d40aac49c6f7455d081b263d3e1ff *i386-linux.elf/upx-3.95
|
||||||
|
906fbf9f6c1e3483f6e9f003c602f20c584b013cf89c51cd17c8095c514a1d1d *i386-win32.pe/upx-3.91.exe
|
||||||
|
ca1e4f751677eab4e24d73d04e69c4c7f645798fa6bb416468bddde9c5dda61c *i386-win32.pe/upx-3.95.exe
|
||||||
|
11fbc05a27d6e2468baa64efc58bf23693e90d3a374b267d4a72a866af56e284 *m68k-atari.tos/upx-3.91.ttp
|
||||||
|
a81d82d7606f1735889dbfa1a5de1c6d35209c31e6e56c48cc40c9470d07da54 *mips-linux.elf/upx-3.95
|
||||||
|
3ce5b8a9b36a71c33a644a8cd4fc9e5cb1009f5133d1df181c18c175b94143e4 *mipsel-linux.elf/upx-3.91
|
||||||
|
f2e03dad0165c3adb683c3bd8f26117dca53a577c8603441abeda911af07204f *mipsel-linux.elf/upx-3.95
|
||||||
|
174eb63cf809b0a105fccfa5318a754da6685610c3ffa3d81ba41ced4a040984 *powerpc-linux.elf/upx-3.91
|
||||||
|
01d6aa378efda299ade377d1bcd04611a467cb903efb82545205ed439c566c26 *powerpc-linux.elf/upx-3.95
|
||||||
|
e9b32f705ea249cfafcd3e6181f7632f38b304dcba0ab39690e8a5ffbcc2504f *powerpc64le-linux.elf/upx-3.95
|
||||||
|
"
|
||||||
|
expected_sha256sums__t150_compress_ucl_2_all_filters="\
|
||||||
|
9d2d9449ff3cd62389337d76d419306b18be18c48dc23c89b9048ab13856999d *amd64-linux.elf/upx-3.91
|
||||||
|
f221da0c79fa1a59de5becf341126b1a41f19c9860ce66676e927b0546956d16 *amd64-linux.elf/upx-3.95
|
||||||
|
a0c35f620eb4f5c49cc7c0ae591c9bc1ff39fe3b5a084a7038c37ac4242172be *amd64-win64.pe/upx-3.95.exe
|
||||||
|
a09b27147773e2288dc0a7075097bd76d86d0fdd6fb9d0726c4b928bc8b74b1b *arm-linux.elf/upx-3.95
|
||||||
|
ff5abf994119a68584d752f5d3ab120ec9f28b2a719efede55e6c71cb4d82b57 *arm-wince.pe/upx-3.91.exe
|
||||||
|
6801a06892b7d1a3534410bfb4a03aed6195dbc5012801a987f0a635f6b3af7a *arm64-linux.elf/upx-3.95
|
||||||
|
69587df298a09ccf3a1c147cec28942fb0419478163f75f61cf7b72538abeefe *armeb-linux.elf/upx-3.91
|
||||||
|
985f238569e6aa2c3973a281bfcfd13cfc9e638c10ebb5a3ff07c4051c97c488 *armeb-linux.elf/upx-3.95
|
||||||
|
fe14d316c0dc98bc49e6c0f5888a83b1fa8e58caea6d211301726fee0cdd020e *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||||
|
e4dd0a9565f7a501520997a48227d027e37fa3becf3b84e839c5f96aa169e601 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||||
|
301a0b90694809ad0be9d354a7a9d6baa3fa9b4ccd62264166c95d86142df164 *i386-linux.elf/upx-3.91
|
||||||
|
3a6c56ba29940b4ac3b42d23cdfd21d0331036b082e50f4d2d87e1508567591f *i386-linux.elf/upx-3.95
|
||||||
|
91d816d5ecee3ffa48bc624283a600758776790fe928c2dc1846a72cd4d9d14d *i386-win32.pe/upx-3.91.exe
|
||||||
|
1930f3a09c0ec1a12056be6469f12d048a572bcdd7a62dc2c006a1c46f09fcf6 *i386-win32.pe/upx-3.95.exe
|
||||||
|
9024f8d52cf40726f27c0782fe63eb15b6aa33789c97a343fb80b901df8a7468 *m68k-atari.tos/upx-3.91.ttp
|
||||||
|
4dbfb026a0e10ffb43b8053c1f32b20c1632f8963c93a3170230c0a7dbc3e805 *mips-linux.elf/upx-3.95
|
||||||
|
aaca5c6fdadb4f735b1f5ff99e1394ba711db28b1e22f1df9119ee2693c419b3 *mipsel-linux.elf/upx-3.91
|
||||||
|
9edd1d514102ed0955f9a333b1de41ca3550ec34d075dbd69dc09a7f6325b68e *mipsel-linux.elf/upx-3.95
|
||||||
|
1ffcbc5041300c223ef03dbbed131560f942033d3df55b317099d1a8ad2ced69 *powerpc-linux.elf/upx-3.91
|
||||||
|
9884be7a7d0a459e8d90ecdb663d2dfb166199e3ae614ef2478aa8d7dab215ef *powerpc-linux.elf/upx-3.95
|
||||||
|
7847d39cc94308d7509b1515eef2daee0fcca48678ec2540570a05d6d461e76c *powerpc64le-linux.elf/upx-3.95
|
||||||
|
"
|
||||||
|
expected_sha256sums__t160_compress_all_methods_1_no_filter="\
|
||||||
|
5f9e96872c68df382efb48502d5d81b8afe3240d4eba9f81643863b0c4db4c56 *amd64-linux.elf/upx-3.91
|
||||||
|
e9eeb7710b3e2d54c7cbabf7cb4de2c40c30efdf1dccbe5324bb58cfd665fbc8 *amd64-linux.elf/upx-3.95
|
||||||
|
46043947b045c1e7bb5a1e29b369a61609c5a7e7b5c89e029d3606e38703da4f *amd64-win64.pe/upx-3.95.exe
|
||||||
|
2b801d5b4f61ed2c90fd54648b1aad3f346f7539f4f8047c6d6585eafa443800 *arm-linux.elf/upx-3.95
|
||||||
|
6b5f6961874812665512518792cb5a21a7c013e5fb6e2da30e72591625983a13 *arm-wince.pe/upx-3.91.exe
|
||||||
|
444850947143d981137eb825225c2a09e9a67da186812d0c0b25304b9cefcca5 *arm64-linux.elf/upx-3.95
|
||||||
|
950e6cbae17f14cb53da024d814790aa006c019060cbc0a11a277eb5e0722cbb *armeb-linux.elf/upx-3.91
|
||||||
|
2a0e7f240ee8cabfa026a58aae0e9763eb4d21bb0ce59c538cb4a8bd0734c422 *armeb-linux.elf/upx-3.95
|
||||||
|
3094ac645a70cd5316e777208eb2af00116cab03b0924fed9f6f2f4d1335d975 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||||
|
97e1f9535799fb58b7814d20fc18ce78fabef669b7467da4ec0da952dc003597 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||||
|
6614ffb7d8f742a9407a99515608399e370732bcdf041b13280de5ecb83d6e35 *i386-linux.elf/upx-3.91
|
||||||
|
323c3943a677fe84d526da7707d865e57d28d9e24b5d7055e71bf3e9ffc924a8 *i386-linux.elf/upx-3.95
|
||||||
|
7a2deccab37f364e650df63ed3719433b38ee53193e29e7737bc352998a27281 *i386-win32.pe/upx-3.91.exe
|
||||||
|
0accf03fe46774a170710f5477f6e7095ba9ace0850bb3a1c697c1b1ec570be3 *i386-win32.pe/upx-3.95.exe
|
||||||
|
efb22c80605d58fb96a302c58fcc5c1bdf143f90a6874004fae6549df2a224c8 *m68k-atari.tos/upx-3.91.ttp
|
||||||
|
754295165a9c08364e9754322868c6f4df7c2772746d844a04fda3287907f362 *mips-linux.elf/upx-3.95
|
||||||
|
bf63ab0df4b2d45f3f156ebf9fd7e60e6cb175f688f68bd14b5e699e6b95872b *mipsel-linux.elf/upx-3.91
|
||||||
|
4a2894fb946d684d370f7d252abc43afcff0a339ef2aeaeaa23767ff3e6b15fd *mipsel-linux.elf/upx-3.95
|
||||||
|
fcb40e252de5e3a7f495d338ad6bf6dc73aee7d10513e06b07a270161fe449d8 *powerpc-linux.elf/upx-3.91
|
||||||
|
e282ca41f508ae63defc249aa2e4318540362ae8b3c40f31bf46946a6a1bf5f6 *powerpc-linux.elf/upx-3.95
|
||||||
|
8b67e3e700f6d5afb99bc561e5d2e5850b2eea4b5a854cab0c84766e6df2a4a6 *powerpc64le-linux.elf/upx-3.95
|
||||||
|
"
|
||||||
|
expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\
|
||||||
|
42c2358cc7a6a1252c1fb8bb29562e3047d839a506720ef0dff098cbd6cd08c3 *amd64-linux.elf/upx-3.91
|
||||||
|
e11f33fa80dda7e2b547cc375c1802f5f075a80f12033c123c97b2d572ad8757 *amd64-linux.elf/upx-3.95
|
||||||
|
77230816a4ebc51a430e8304ea331399491c548d182aa001b8d653e2d7b6ea9a *amd64-win64.pe/upx-3.95.exe
|
||||||
|
54cb369bf7b8e1e55380a2a97bd7e644cb0da79982d1678eea7a668362d93610 *arm-linux.elf/upx-3.95
|
||||||
|
7818cd3cbc877d3781ae1ce0abbaf4a19186af55cb675229f406943d552694dd *arm-wince.pe/upx-3.91.exe
|
||||||
|
3186b21f336cae305bbcadcddc5691969752b4a97094f27344361d49037a9b48 *arm64-linux.elf/upx-3.95
|
||||||
|
1ff49ccf438feefb7a8c9467c6fa3d6ad218cf9abdf12870522a1b24fd26f0c6 *armeb-linux.elf/upx-3.91
|
||||||
|
b43bb20b5e372dd877015e0fffd18e908ed3d53ffa057624ab4242f07515e11a *armeb-linux.elf/upx-3.95
|
||||||
|
ce60084e86b17798e34e59c21b6cea28702d850f786f9e35e41a2bc873178f53 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||||
|
aa3f9f5742e5f7aa87a7578d92b54425da6eb4b173200408f3e30384c4089370 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||||
|
d63d34bffb7864f1af6c76edb85820b01f3ccb053528b075b81b1425feabe797 *i386-linux.elf/upx-3.91
|
||||||
|
e42f1febc0ca7f54adf7b2fd721aac2f9e72680e0e010ed2368f669f8d341071 *i386-linux.elf/upx-3.95
|
||||||
|
21d932deff36167a2f030773e8f68f952fc4fb67bf1864c515f3930f572fb624 *i386-win32.pe/upx-3.91.exe
|
||||||
|
7665c75c47fc3b7913e0849187070e8ddf73f584f1e2495f51d3ebb32cf0ad21 *i386-win32.pe/upx-3.95.exe
|
||||||
|
17420ed467a4f326c79c13d0b89b6d3a4dd6a2d3b96f199d7e9dd31528439f2f *m68k-atari.tos/upx-3.91.ttp
|
||||||
|
d93f08394e03b17044be5f22ff496913aeaf0a6927d2b926452aadc32af2a479 *mips-linux.elf/upx-3.95
|
||||||
|
b0d689013481cc7f668a2559a7d696356ab7adafe68ae49f9e7e68ced1d6a8ff *mipsel-linux.elf/upx-3.91
|
||||||
|
2593ca7f7609a44ae87c22a2d72e0470737253967eb82f9a8ceda9496b195503 *mipsel-linux.elf/upx-3.95
|
||||||
|
236f784979481ed09b875fb7302bb31beb151140752ea62ef9ad4aa0ec073a4f *powerpc-linux.elf/upx-3.91
|
||||||
|
70d0da07e4ac2e249864644fdf29935352452416f70b7362d0e62ab87ec05653 *powerpc-linux.elf/upx-3.95
|
||||||
|
f98e35412b9fda2aaa58c6f84b843b3d9493781b6510ac4ec0af9ccb9327a141 *powerpc64le-linux.elf/upx-3.95
|
||||||
|
"
|
||||||
|
########## end .sha256sums.recreate
|
||||||
|
|
||||||
@@ -0,0 +1,281 @@
|
|||||||
|
#! /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() {
|
||||||
|
print_header "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
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 */* | 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"
|
||||||
|
}
|
||||||
|
|
||||||
|
source "$argv0dir/travis_testsuite_1-expected_sha256sums.sh" || exit 1
|
||||||
|
|
||||||
|
# /***********************************************************************
|
||||||
|
# // 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"
|
||||||
|
export UPX_DISABLE_GITREV_WARNING=1
|
||||||
|
|
||||||
|
# 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.9[15]*; 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,68 @@
|
|||||||
|
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=
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
/.bzr*
|
||||||
|
/.hg*
|
||||||
|
/.vscode*
|
||||||
|
/Makevars.global*
|
||||||
|
/build*
|
||||||
|
/maint*
|
||||||
|
|
||||||
|
.depend
|
||||||
|
GNUmakefile
|
||||||
|
MMakefile
|
||||||
|
Makevars.local*
|
||||||
|
tmp-testsuite*
|
||||||
|
|
||||||
|
*.a
|
||||||
|
*.dll
|
||||||
|
*.lib
|
||||||
|
*.py[cdo]
|
||||||
|
*.so
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
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*/*.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
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[submodule "src/lzma-sdk"]
|
||||||
|
path = src/lzma-sdk
|
||||||
|
url = https://github.com/upx/upx-lzma-sdk.git
|
||||||
|
branch = master
|
||||||
+559
@@ -0,0 +1,559 @@
|
|||||||
|
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
|
||||||
|
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
language: cpp
|
||||||
|
|
||||||
|
notifications: { email: { on_success: never, on_failure: change } }
|
||||||
|
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- /^appveyor.*/
|
||||||
|
- /^gitlab.*/
|
||||||
|
|
||||||
|
# Ubuntu 12.04 LTS "Precise"
|
||||||
|
# also see TB_OS_linux_precise_llvm below
|
||||||
|
.ubuntu_precise_toolchain_sources: &PS
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-precise-3.5
|
||||||
|
- llvm-toolchain-precise-3.6
|
||||||
|
- llvm-toolchain-precise-3.7
|
||||||
|
- llvm-toolchain-precise-3.8
|
||||||
|
- llvm-toolchain-precise-3.9
|
||||||
|
|
||||||
|
# Ubuntu 14.04 LTS "Trusty"
|
||||||
|
.ubuntu_trusty_toolchain_sources: &TS
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-trusty-3.9
|
||||||
|
- llvm-toolchain-trusty-4.0
|
||||||
|
- llvm-toolchain-trusty-5.0
|
||||||
|
- llvm-toolchain-trusty-6.0
|
||||||
|
- llvm-toolchain-trusty-7
|
||||||
|
- llvm-toolchain-trusty-8
|
||||||
|
|
||||||
|
# Ubuntu 16.04 LTS "Xenial"
|
||||||
|
.ubuntu_xenial_toolchain_sources: &XS
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-xenial-6.0
|
||||||
|
- llvm-toolchain-xenial-7
|
||||||
|
- llvm-toolchain-xenial-8
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
# TB_LEVEL >= 1: gcc-7, gcc-8, gcc-9, clang-8, xcode11
|
||||||
|
# TB_LEVEL >= 2: gcc-4.4, gcc-4.8, gcc-6, clang-3.4, clang-7
|
||||||
|
# TB_LEVEL >= 3: gcc-4.6, gcc-5, clang-3.9, clang-6, xcode9, xcode10
|
||||||
|
# TB_LEVEL >= 4: include sanitize/scan-build/valgrind builds
|
||||||
|
# TB_LEVEL >= 5: cross-compilers running testsuite under qemu/wine
|
||||||
|
# TB_LEVEL >= 6: all other compilers & builds
|
||||||
|
- TB_LEVEL=5
|
||||||
|
- TB_OS_linux=1 TB_OS_osx=1
|
||||||
|
- TB_OS_linux_precise_llvm=1
|
||||||
|
- 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:
|
||||||
|
fast_finish: true
|
||||||
|
include:
|
||||||
|
- if: 1 = 1
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: gcc
|
||||||
|
env: X=rebuild-stubs
|
||||||
|
addons: { apt: { packages: [ "g++-multilib", "lib32z1" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.4-m32
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "g++-4.4-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.4-m64
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "g++-4.4" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.5-m32
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "g++-4.5-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.5-m64
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "g++-4.5" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.6-m32
|
||||||
|
addons: { apt: { packages: [ "g++-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.6-m64
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.7-m32
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "g++-4.7-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.7-m64
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "g++-4.7" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.8-m32
|
||||||
|
addons: { apt: { packages: [ "g++-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.8-m64
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.8-mx32
|
||||||
|
addons: { apt: { packages: [ "g++-multilib", "libx32stdc++-4.8-dev" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.9-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-4.9-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-4.9-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-4.9" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-5-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-5-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-5-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-5" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-6-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-6-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-6" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-7-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-7-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-7-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-7" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-8-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-8-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-8-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-8" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-8-m32 B=debug
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-8-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-8-m64 B=debug
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-8" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[4-9]$/
|
||||||
|
# must use sudo CAP_SYS_PTRACE for sanitize - see https://github.com/travis-ci/travis-ci/issues/9033
|
||||||
|
sudo: true
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-8-m64 B=debug+sanitize
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-8" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[4-9]$/
|
||||||
|
# must use sudo CAP_SYS_PTRACE for sanitize - see https://github.com/travis-ci/travis-ci/issues/9033
|
||||||
|
sudo: true
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-8-m64 B=sanitize
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-8" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[4-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-8-m64 B=valgrind T=valgrind
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "g++-8", valgrind ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-9-m32
|
||||||
|
addons: { apt: { sources: *XS, packages: [ "g++-9-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: gcc
|
||||||
|
env: C=gcc-9-m64
|
||||||
|
addons: { apt: { sources: *XS, packages: [ "g++-9" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.4-m32
|
||||||
|
addons: { apt: { packages: [ "g++-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.4-m64
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/ AND env(TB_OS_linux_precise_llvm) = 1
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.5-m32
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "clang-3.5", "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/ AND env(TB_OS_linux_precise_llvm) = 1
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.5-m64
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "clang-3.5" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/ AND env(TB_OS_linux_precise_llvm) = 1
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.6-m32
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "clang-3.6", "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/ AND env(TB_OS_linux_precise_llvm) = 1
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.6-m64
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "clang-3.6" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/ AND env(TB_OS_linux_precise_llvm) = 1
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.7-m32
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "clang-3.7", "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/ AND env(TB_OS_linux_precise_llvm) = 1
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.7-m64
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "clang-3.7" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/ AND env(TB_OS_linux_precise_llvm) = 1
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.8-m32
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "clang-3.8", "g++-6-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/ AND env(TB_OS_linux_precise_llvm) = 1
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.8-m64
|
||||||
|
addons: { apt: { sources: *PS, packages: [ "clang-3.8" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.9-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-3.9", "g++-7-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-3.9-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-3.9" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-4.0-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-4.0", "g++-7-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-4.0-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-4.0" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-5.0-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-5.0", "g++-7-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-5.0-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-5.0" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-6.0-m32
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-6.0", "g++-7-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-6.0-m64
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-6.0" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[4-9]$/
|
||||||
|
# must use sudo CAP_SYS_PTRACE for sanitize - see https://github.com/travis-ci/travis-ci/issues/9033
|
||||||
|
sudo: true
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-6.0-m64 B=debug+sanitize
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-6.0" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[4-9]$/
|
||||||
|
# must use sudo CAP_SYS_PTRACE for sanitize - see https://github.com/travis-ci/travis-ci/issues/9033
|
||||||
|
sudo: true
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-6.0-m64 B=sanitize
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-6.0" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[4-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-6.0-m64 B=debug+scan-build
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-6.0", "clang-tools-6.0" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[4-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-6.0-m64 B=scan-build
|
||||||
|
addons: { apt: { sources: *TS, packages: [ "clang-6.0", "clang-tools-6.0" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-7-m32
|
||||||
|
addons: { apt: { sources: *XS, packages: [ "clang-7", "g++-9-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[2-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-7-m64
|
||||||
|
addons: { apt: { sources: *XS, packages: [ "clang-7" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-8-m32
|
||||||
|
addons: { apt: { sources: *XS, packages: [ "clang-8", "g++-9-multilib", "zlib1g-dev:i386" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-8-m64
|
||||||
|
addons: { apt: { sources: *XS, packages: [ "clang-8" ] } }
|
||||||
|
|
||||||
|
# Ubuntu 12.04 cross compilers
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[5-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: CROSS=arm-linux-gnueabi C=gcc-4.6 T=qemu
|
||||||
|
addons: { apt: { packages: [ "g++-arm-linux-gnueabi", "qemu-user" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[5-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
compiler: gcc
|
||||||
|
env: CROSS=arm-linux-gnueabihf C=gcc-4.6 T=qemu
|
||||||
|
addons: { apt: { packages: [ "g++-arm-linux-gnueabihf", "qemu-user" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[5-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
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" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[5-9]$/
|
||||||
|
os: linux
|
||||||
|
dist: precise
|
||||||
|
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" ] } }
|
||||||
|
|
||||||
|
# Ubuntu 16.04 cross compilers
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[5-90]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: gcc
|
||||||
|
env: CROSS=mips-linux-gnu C=gcc-5 T=qemu
|
||||||
|
addons: { apt: { packages: [ "g++-5-mips-linux-gnu", "qemu-user" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[5-90]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: gcc
|
||||||
|
env: CROSS=mipsel-linux-gnu C=gcc-5 T=qemu
|
||||||
|
addons: { apt: { packages: [ "g++-5-mipsel-linux-gnu", "qemu-user" ] } }
|
||||||
|
- if: env(TB_OS_linux) = 1 AND env(TB_LEVEL) =~ /^[5-90]$/
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: gcc
|
||||||
|
env: CROSS=powerpc-linux-gnu C=gcc-5 T=qemu
|
||||||
|
addons: { apt: { packages: [ "g++-5-powerpc-linux-gnu", "qemu-user" ] } }
|
||||||
|
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
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
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
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
|
||||||
|
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode7.3
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-703-m32
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode7.3
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-703-m64
|
||||||
|
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode8.3
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-802-m32
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[6-9]$/
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode8.3
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-802-m64
|
||||||
|
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode9.4
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-902-m32
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode9.4
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-902-m64
|
||||||
|
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[3-9]$/
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode10.3
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-1001-m64
|
||||||
|
|
||||||
|
- if: env(TB_OS_osx) = 1 AND env(TB_LEVEL) =~ /^[1-9]$/
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode11.3
|
||||||
|
compiler: clang
|
||||||
|
env: C=clang-1100-m64
|
||||||
|
addons: { homebrew: { packages: [ "coreutils" ] } }
|
||||||
|
|
||||||
|
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:
|
||||||
|
- success=1
|
||||||
|
- cd $TRAVIS_BUILD_DIR || success=0
|
||||||
|
- test $success = 0 || bash ./.github/travis_build.sh || success=0
|
||||||
|
- test $success = 0 || bash ./.github/travis_testsuite_1.sh || success=0
|
||||||
|
- test $success = 0 || bash ./.github/travis_deploy.sh || success=0
|
||||||
|
- test $success = 1
|
||||||
|
|
||||||
|
# vim:set ts=2 sw=2 et:
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2006 Markus Oberhumer & Laszlo Molnar
|
Copyright (c) 1996-2020 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
https://upx.github.io
|
||||||
|
|
||||||
|
|
||||||
Limitations and other things which are not (yet) supported:
|
Limitations and other things which are not (yet) supported:
|
||||||
@@ -28,7 +28,7 @@ dos/exe
|
|||||||
watcom/le
|
watcom/le
|
||||||
---------
|
---------
|
||||||
* 16-bit selector alias fixups
|
* 16-bit selector alias fixups
|
||||||
* 16-bit offset relocation for objects larger than 4 kB
|
* 16-bit offset relocation for objects larger than 4 KiB
|
||||||
* 16:16 fixups
|
* 16:16 fixups
|
||||||
|
|
||||||
If you need any of the above (they're very rare), send us an URL of a
|
If you need any of the above (they're very rare), send us an URL of a
|
||||||
@@ -44,7 +44,7 @@ test file.
|
|||||||
|
|
||||||
win32/pe
|
win32/pe
|
||||||
--------
|
--------
|
||||||
* writeable shared sections (`--force' *may* work)
|
* writable shared sections (`--force' *may* work)
|
||||||
* certificates in the image
|
* certificates in the image
|
||||||
* compressing files which contain a big BSS requires lots of memory
|
* compressing files which contain a big BSS requires lots of memory
|
||||||
during compression
|
during compression
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
|
|||||||
General Public License applies to most of the Free Software
|
General Public License applies to most of the Free Software
|
||||||
Foundation's software and to any other program whose authors commit to
|
Foundation's software and to any other program whose authors commit to
|
||||||
using it. (Some other Free Software Foundation software is covered by
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
the GNU Library General Public License instead.) You can apply it to
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
your programs, too.
|
your programs, too.
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
@@ -55,7 +55,7 @@ patent must be licensed for everyone's free use or not licensed at all.
|
|||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
|
|||||||
License. (Exception: if the Program itself is interactive but
|
License. (Exception: if the Program itself is interactive but
|
||||||
does not normally print such an announcement, your work based on
|
does not normally print such an announcement, your work based on
|
||||||
the Program is not required to print an announcement.)
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
These requirements apply to the modified work as a whole. If
|
||||||
identifiable sections of that work are not derived from the Program,
|
identifiable sections of that work are not derived from the Program,
|
||||||
and can be reasonably considered independent and separate works in
|
and can be reasonably considered independent and separate works in
|
||||||
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
|
|||||||
access to copy the source code from the same place counts as
|
access to copy the source code from the same place counts as
|
||||||
distribution of the source code, even though third parties are not
|
distribution of the source code, even though third parties are not
|
||||||
compelled to copy the source along with the object code.
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
except as expressly provided under this License. Any attempt
|
except as expressly provided under this License. Any attempt
|
||||||
otherwise to copy, modify, sublicense or distribute the Program is
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
@@ -225,7 +225,7 @@ impose that choice.
|
|||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
This section is intended to make thoroughly clear what is believed to
|
||||||
be a consequence of the rest of this License.
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
8. If the distribution and/or use of the Program is restricted in
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
original copyright holder who places the Program under this License
|
original copyright holder who places the Program under this License
|
||||||
@@ -278,7 +278,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|||||||
POSSIBILITY OF SUCH DAMAGES.
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
@@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least
|
|||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
Copyright (C) 19yy <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License along
|
||||||
along with this program; if not, write to the Free Software
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program is interactive, make it output a short notice like this
|
If the program is interactive, make it output a short notice like this
|
||||||
when it starts in an interactive mode:
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names:
|
|||||||
This General Public License does not permit incorporating your program into
|
This General Public License does not permit incorporating your program into
|
||||||
proprietary programs. If your program is a subroutine library, you may
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
consider it more useful to permit linking proprietary applications with the
|
consider it more useful to permit linking proprietary applications with the
|
||||||
library. If this is what you want to do, use the GNU Library General
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
Public License instead of this License.
|
Public License instead of this License.
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
# Toplevel Makefile for UPX
|
#
|
||||||
|
# UPX toplevel Makefile - needs GNU make 3.81 or better
|
||||||
|
#
|
||||||
|
# Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
#
|
||||||
|
|
||||||
MAKEFLAGS += -rR
|
MAKEFLAGS += -rR
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
@@ -6,38 +10,27 @@ export SHELL = /bin/sh
|
|||||||
|
|
||||||
srcdir = .
|
srcdir = .
|
||||||
top_srcdir = .
|
top_srcdir = .
|
||||||
|
include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@echo "UPX info: please choose a target for 'make'"
|
@echo "UPX info: please choose a target for 'make'"
|
||||||
|
|
||||||
all mostlyclean clean distclean maintainer-clean:
|
all mostlyclean clean distclean maintainer-clean:
|
||||||
$(MAKE) -C src/stub/util/sstrip $@
|
ifeq ($(BUILD_STUB),1)
|
||||||
$(MAKE) -C src/stub $@
|
$(MAKE) -C src/stub $@
|
||||||
|
endif
|
||||||
$(MAKE) -C src $@
|
$(MAKE) -C src $@
|
||||||
$(MAKE) -C doc $@
|
$(MAKE) -C doc $@
|
||||||
|
|
||||||
dist: distclean
|
.PHONY: default all mostlyclean clean distclean maintainer-clean
|
||||||
false
|
|
||||||
|
|
||||||
|
|
||||||
ifneq ($(wildcard CVS/R*),)
|
|
||||||
CVS_ROOT := $(shell cat CVS/Root)
|
|
||||||
CVS_REPO := $(shell cat CVS/Repository)
|
|
||||||
endif
|
|
||||||
|
|
||||||
cvs-info:
|
|
||||||
@echo 'CVS info: $(CVS_ROOT) $(CVS_REPO)'
|
|
||||||
|
|
||||||
cvs-admin-ko:
|
|
||||||
cvs admin -ko .
|
|
||||||
cvs -q -z6 update -P -d
|
|
||||||
|
|
||||||
# automatically generate ChangeLog from CVS
|
|
||||||
ChangeLog ChangeLog.cvs:
|
|
||||||
perl $(srcdir)/scripts/cvs2cl.pl --utc -f ChangeLog.cvs
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all mostlyclean clean distclean maintainer-clean
|
|
||||||
.PHONY: dist cvs-info cvs-admin-ko ChangeLog ChangeLog.cvs
|
|
||||||
|
|
||||||
|
# vim:set ts=8 sw=8 noet:
|
||||||
|
|||||||
@@ -2,10 +2,190 @@
|
|||||||
User visible changes for UPX
|
User visible changes for UPX
|
||||||
==================================================================
|
==================================================================
|
||||||
|
|
||||||
[ UNSTABLE BETA VERSION - please see README.1ST for some more info ]
|
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):
|
||||||
|
* 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):
|
||||||
|
* 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.
|
||||||
|
* Support Apple MacOS 10.12 "Sierra", including more-robust de-compression.
|
||||||
|
* Explicitly diagnose Go-language bad PT_LOAD; recommend hemfix.c.
|
||||||
|
https://sourceforge.net/p/upx/bugs/195/ https://github.com/pwaller/goupx
|
||||||
|
* Fix CERT-FI Case 829767 UPX command line tools segfaults.
|
||||||
|
Received by UPX Team on 2015-May-08; originally reported
|
||||||
|
by Codenomicon to NCSC-FI on 2015-01-08.
|
||||||
|
The vulnerabilities were discovered by Joonas Kuorilehto and
|
||||||
|
Antti Häyrynen from Codenomicon.
|
||||||
|
* 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
|
||||||
|
work by Stefan Widmann. Please use for testing only!
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
==================================================================
|
||||||
|
|
||||||
|
Changes in 3.09 (18 Feb 2013):
|
||||||
|
* New option --preserve-build-id for GNU ELF.
|
||||||
|
* Allow for code signing and LC_UUID on Mac OS X executables.
|
||||||
|
* Allow non-contiguous LC_SEGMENTs and 0==.vmsize for Mach-O.
|
||||||
|
* Allow zero-filled final page in PackUnix::canUnpack().
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.08 (12 Dec 2011):
|
||||||
|
* Fix allocation in runtime stub for darwin.macho-entry (i386 and amd64).
|
||||||
|
* 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.
|
||||||
|
* Preserve more ELF .e_flags on ARM.
|
||||||
|
* Minor code improvements for ELF stubs.
|
||||||
|
* Defend against another flavor of corrupt PE header.
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.07 (08 Sep 2010):
|
||||||
|
* win32/pe: fixed relocation handling for files with *no* TLS callbacks
|
||||||
|
[severe bug introduced in 3.06]
|
||||||
|
|
||||||
|
Changes in 3.06 (04 Sep 2010):
|
||||||
|
* win32/pe: TLS callback support contributed by Stefan Widmann. Thanks!
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.05 (27 Apr 2010):
|
||||||
|
* i386-linux and amd64-linux support shared libraries (DT_INIT must
|
||||||
|
exist, all info needed by runtime loader must be first in .text, etc.)
|
||||||
|
* Linux /proc/self/exe now is preserved by default, by leaving behind
|
||||||
|
one page. New compress-time option --unmap-all-pages is available.
|
||||||
|
* Withdraw support for shared libraries on Darwin (Apple Mac OS X)
|
||||||
|
because upx does not understand enough about .dylib.
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.04 (27 Sep 2009):
|
||||||
|
* new format Mach/AMD64 supports 64-bit programs on Apple Macintosh.
|
||||||
|
* new formats Dylib/i386 and Dylib/ppc32 support shared libraries
|
||||||
|
[such as browser plugins] on Darwin (Apple Macintosh). An existing
|
||||||
|
-init function (LC_ROUTINES command) is required.
|
||||||
|
* new format vmlinuz/armel for Debian NSLU2 (etc.) linux kernel
|
||||||
|
* bvmlinuz boot protocol 2.08 for 386 Linux kernel
|
||||||
|
* Extended ABI version 4 for armel-eabi ARM Linux ELF
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.03 (27 Apr 2008):
|
||||||
|
* implement cache flushing for PowerPC (esp. model 440)
|
||||||
|
* fix cache flushing on MIPS (>3 MiB compressed, or with holes)
|
||||||
|
* fix MIPS big-endian
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.02 (16 Dec 2007):
|
||||||
|
* fix unmapping on arm-linux.elf
|
||||||
|
* fix error checking in mmap for i386-linux.elf [triggered by -fPIE]
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.01 (31 Jul 2007):
|
||||||
|
* new options --no-mode, --no-owner and --no-time to disable preservation
|
||||||
|
of mode (file permissions), file ownership and timestamps.
|
||||||
|
* dos/exe: fixed an incorrect error message caused by a bug in
|
||||||
|
relocation handling
|
||||||
|
* new format linux/mipsel supports ELF on [32-bit] R3000
|
||||||
|
* fix argv[0] on PowerPC with --lzma
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 3.00 (27 Apr 2007):
|
||||||
|
* watcom/le & tmt/adam: fixed a problem when using certain filters
|
||||||
|
|
||||||
|
Changes in 2.93 beta (08 Mar 2007):
|
||||||
|
* new formats Mach/i386 and Mach/fat support Mac OS X i686 and
|
||||||
|
Universal binaries [i686 and PowerPC only]
|
||||||
|
* dos/exe: LZMA is now also supported for 16-bit dos/exe. Please note that
|
||||||
|
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 occurring bug in relocation handling
|
||||||
|
* win32/pe & arm/pe: better icon compression handling
|
||||||
|
|
||||||
|
Changes in 2.92 beta (23 Jan 2007):
|
||||||
|
* new option '--ultra-brute' which tries even more variants
|
||||||
|
* slightly improved compression ratio for some files when
|
||||||
|
using '--brute' or '--ultra-brute'
|
||||||
|
* bug fixes
|
||||||
|
|
||||||
|
Changes in 2.91 beta (29 Nov 2006):
|
||||||
|
* assorted bug fixes
|
||||||
|
* arm/pe: 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):
|
||||||
|
* LZMA algorithm support for most of the 32-bit and 64-bit file formats;
|
||||||
|
use new option '--lzma' to enable
|
||||||
|
* new format: BSD/elf386 supporting FreeBSD, NetBSD and OpenBSD
|
||||||
|
via auto-detection of PT_NOTE or EI_OSABI
|
||||||
|
* arm/pe: all the NRV compression methods are now supported
|
||||||
|
(only NRV2D is missing in thumb mode)
|
||||||
|
* linux/elf386, linux/ElfAMD: remember /proc/self/exe in environment
|
||||||
|
* major source code changes: the runtime decompression stubs are now
|
||||||
|
built from internal ELF objects
|
||||||
|
|
||||||
|
==================================================================
|
||||||
|
|
||||||
|
Changes in 2.03 (07 Nov 2006):
|
||||||
|
* bvmlinuz/386: fix for kernels not at 0x100000; also allow x86_64
|
||||||
|
* linux/elf386: work around Linux kernel bug (0-length .bss needs PF_W)
|
||||||
|
|
||||||
|
Changes in 2.02 (13 Aug 2006):
|
||||||
|
* linux/386: work around Linux kernel bug (".bss" requires PF_W)
|
||||||
|
* linux/ppc32, mach/ppc32: compressed programs now work on a 405 CPU
|
||||||
|
* vmlinuz/386: fixed zlib uncompression problem on DOS
|
||||||
|
|
||||||
|
Changes in 2.01 (06 Jun 2006):
|
||||||
|
* arm/pe: better DLL support
|
||||||
|
* dos/exe: device driver support added
|
||||||
|
* linux/386: Fix --force-execve for PaX, grSecurity, and strict SELinux.
|
||||||
|
/tmp must support execve(); therefore /tmp cannot be mounted 'noexec'.
|
||||||
|
* win32/pe & arm/pe: added new option '--keep-resource=' for
|
||||||
|
excluding selected resources from compression
|
||||||
|
|
||||||
|
Changes in 2.00 (27 Apr 2006):
|
||||||
|
* linux/386: the stub now prints an error message if some strict
|
||||||
|
SELinux mode does prevent runtime decompression and execution
|
||||||
|
(for a fully SELinux-compatible but otherwise inferior compression
|
||||||
|
format you can use the '--force-execve' option)
|
||||||
|
* linux/386: worked around a problem where certain Linux kernels
|
||||||
|
clobber the %ebx register during a syscall
|
||||||
|
* win32/pe: disable filters for files with broken PE headers
|
||||||
|
|
||||||
|
Changes in 1.96 beta (13 Apr 2006):
|
||||||
|
* arm/pe: added filter support
|
||||||
|
* win32/pe: removed an unnecessary check so that Delphi 2006 and
|
||||||
|
Digital Mars C++ programs finally are supported
|
||||||
|
|
||||||
|
Changes in 1.95 beta (09 Apr 2006):
|
||||||
|
* arm/pe: added DLL support
|
||||||
|
* arm/pe: added thumb mode stub support
|
||||||
|
* arm/pe: added unpacking support
|
||||||
|
* win32/pe: really worked around R6002 runtime errors
|
||||||
|
|
||||||
Changes in 1.94 beta (11 Mar 2006):
|
Changes in 1.94 beta (11 Mar 2006):
|
||||||
* UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING
|
|
||||||
* new format: added support for arm/pe (ARM executables running on WinCE)
|
* new format: added support for arm/pe (ARM executables running on WinCE)
|
||||||
* new format: added support for linux elf/amd64
|
* new format: added support for linux elf/amd64
|
||||||
* new format: added support for linux elf/ppc32
|
* new format: added support for linux elf/ppc32
|
||||||
@@ -18,8 +198,8 @@ Changes in 1.93 beta (07 Feb 2005):
|
|||||||
* vmlinuz/386: fixes to support more kernels
|
* vmlinuz/386: fixes to support more kernels
|
||||||
|
|
||||||
Changes in 1.92 beta (20 Jul 2004):
|
Changes in 1.92 beta (20 Jul 2004):
|
||||||
* win32/pe: added option `--strip-loadconf' to strip the SEH
|
* win32/pe: added option '--strip-loadconf' to strip the SEH load
|
||||||
load config section
|
config section [NOTE: this option is obsolete since UPX 1.94]
|
||||||
* win32/pe: try to detect .NET (win32/net) files [not yet supported by UPX]
|
* win32/pe: try to detect .NET (win32/net) files [not yet supported by UPX]
|
||||||
* vmlinux/386: new format that directly supports building Linux kernels
|
* vmlinux/386: new format that directly supports building Linux kernels
|
||||||
* source code: now compiles cleanly under Win64
|
* source code: now compiles cleanly under Win64
|
||||||
@@ -30,7 +210,7 @@ Changes in 1.91 beta (30 Jun 2004):
|
|||||||
* vmlinuz/386: added support for recent kernels
|
* vmlinuz/386: added support for recent kernels
|
||||||
* watcom/le: don't crash on files without relocations
|
* watcom/le: don't crash on files without relocations
|
||||||
* win32/pe: stricter checks of some PE values
|
* win32/pe: stricter checks of some PE values
|
||||||
* option `--brute' now implies `--crp-ms=999999'.
|
* option '--brute' now implies '--crp-ms=999999'.
|
||||||
* source code: much improved portability using ACC, the
|
* source code: much improved portability using ACC, the
|
||||||
Automatic Compiler Configuration
|
Automatic Compiler Configuration
|
||||||
* source code: compile fixes for strict ISO C++ compilers
|
* source code: compile fixes for strict ISO C++ compilers
|
||||||
@@ -39,9 +219,9 @@ Changes in 1.91 beta (30 Jun 2004):
|
|||||||
|
|
||||||
Changes in 1.90 beta (11 Nov 2002):
|
Changes in 1.90 beta (11 Nov 2002):
|
||||||
* implemented several new options for finer compression control:
|
* implemented several new options for finer compression control:
|
||||||
`--all-methods', `--all-filters' and `--brute'
|
'--all-methods', '--all-filters' and '--brute'
|
||||||
* ps1/exe: new format - UPX now supports PlayStation One programs
|
* ps1/exe: new format - UPX now supports PlayStation One programs
|
||||||
* linux/386: added the option `--force-execve'
|
* linux/386: added the option '--force-execve'
|
||||||
* vmlinuz/386: better kernel detection and sanity checks
|
* vmlinuz/386: better kernel detection and sanity checks
|
||||||
* re-synced with upx 1.24 branch
|
* re-synced with upx 1.24 branch
|
||||||
* documentation updates
|
* documentation updates
|
||||||
@@ -86,9 +266,9 @@ Changes in 1.22 (27 Jun 2002)
|
|||||||
Digital Mars C++ and Watcom C++
|
Digital Mars C++ and Watcom C++
|
||||||
|
|
||||||
Changes in 1.21 (01 Jun 2002)
|
Changes in 1.21 (01 Jun 2002)
|
||||||
* New option `--crp-ms=' for slightly better compression at the cost
|
* New option '--crp-ms=' for slightly better compression at the cost
|
||||||
of higher memory requirements during compression.
|
of higher memory requirements during compression.
|
||||||
Try `upx --best --crp-ms=100000'. See the docs for more info.
|
Try 'upx --best --crp-ms=100000'. See the docs for more info.
|
||||||
* source code: portability fixes
|
* source code: portability fixes
|
||||||
* source code: compile fixes for g++ 3.0 and g++ 3.1
|
* source code: compile fixes for g++ 3.0 and g++ 3.1
|
||||||
|
|
||||||
@@ -126,7 +306,7 @@ Changes in 1.05 (24 Jan 2001)
|
|||||||
at the unstable UPX 1.1x beta versions for that)
|
at the unstable UPX 1.1x beta versions for that)
|
||||||
|
|
||||||
Changes in 1.04 (19 Dec 2000)
|
Changes in 1.04 (19 Dec 2000)
|
||||||
* dos/exe: fixed an internal error when using `--no-reloc'
|
* dos/exe: fixed an internal error when using '--no-reloc'
|
||||||
* win32/pe: fixed a rare bug in the relocation handling code
|
* win32/pe: fixed a rare bug in the relocation handling code
|
||||||
* some tunings for the default compression level
|
* some tunings for the default compression level
|
||||||
|
|
||||||
@@ -134,7 +314,7 @@ Changes in 1.03 (30 Nov 2000)
|
|||||||
* linked with a new version of the NRV compression library:
|
* linked with a new version of the NRV compression library:
|
||||||
- improved compression ratio a little bit
|
- improved compression ratio a little bit
|
||||||
- overall significantly faster compression
|
- overall significantly faster compression
|
||||||
- much faster when using high compression levels like `-9' or `--best'
|
- much faster when using high compression levels like '-9' or '--best'
|
||||||
- much faster with large files
|
- much faster with large files
|
||||||
* atari/tos: added support for FreeMiNT
|
* atari/tos: added support for FreeMiNT
|
||||||
* the 32-bit DOS version now uses the new CWSDSTUB extender
|
* the 32-bit DOS version now uses the new CWSDSTUB extender
|
||||||
@@ -142,7 +322,7 @@ Changes in 1.03 (30 Nov 2000)
|
|||||||
Changes in 1.02 (13 Sep 2000)
|
Changes in 1.02 (13 Sep 2000)
|
||||||
* watcom/le: fixed a problem with the Causeway extender
|
* watcom/le: fixed a problem with the Causeway extender
|
||||||
* win32/pe: don't automatically strip relocs if they seem needed
|
* win32/pe: don't automatically strip relocs if they seem needed
|
||||||
* support multiple backup generations when using `-k'
|
* support multiple backup generations when using '-k'
|
||||||
* updated the console screen driver
|
* updated the console screen driver
|
||||||
|
|
||||||
Changes in 1.01 (09 Apr 2000)
|
Changes in 1.01 (09 Apr 2000)
|
||||||
@@ -170,7 +350,7 @@ Changes in 0.99.1 (29 Feb 2000)
|
|||||||
|
|
||||||
Changes in 0.99 (25 Feb 2000)
|
Changes in 0.99 (25 Feb 2000)
|
||||||
* FULL SOURCE CODE RELEASED UNDER THE TERMS OF THE GNU GPL
|
* FULL SOURCE CODE RELEASED UNDER THE TERMS OF THE GNU GPL
|
||||||
* win32/pe: changed default to `--strip-relocs=1'
|
* win32/pe: changed default to '--strip-relocs=1'
|
||||||
* dos/com and dos/sys: fixed a bad decompressor problem
|
* dos/com and dos/sys: fixed a bad decompressor problem
|
||||||
* linux/386: the counter for the progress indicator was off by one
|
* linux/386: the counter for the progress indicator was off by one
|
||||||
|
|
||||||
@@ -193,7 +373,7 @@ Changes in 0.91 (13 Nov 1999)
|
|||||||
* dos/exe: correctly restore cs when uncompressing
|
* dos/exe: correctly restore cs when uncompressing
|
||||||
|
|
||||||
Changes in 0.90 (10 Nov 1999)
|
Changes in 0.90 (10 Nov 1999)
|
||||||
* all formats: `--overlay=copy' now is the default overlay mode
|
* all formats: '--overlay=copy' now is the default overlay mode
|
||||||
* improved compression ratio for most files
|
* improved compression ratio for most files
|
||||||
* win32/pe: uncompression is finally supported
|
* win32/pe: uncompression is finally supported
|
||||||
* win32/pe: never compress REGISTRY resources
|
* win32/pe: never compress REGISTRY resources
|
||||||
@@ -203,7 +383,7 @@ Changes in 0.90 (10 Nov 1999)
|
|||||||
* win32/pe: somewhat less memory is required during compression
|
* win32/pe: somewhat less memory is required during compression
|
||||||
* linux/386: fixed compression of scripts which was broken since 0.71
|
* linux/386: fixed compression of scripts which was broken since 0.71
|
||||||
* linux/386: more FreeBSD compatibility issues
|
* linux/386: more FreeBSD compatibility issues
|
||||||
* changed option: `-i' now prints some more details during compression
|
* changed option: '-i' now prints some more details during compression
|
||||||
(not finished yet)
|
(not finished yet)
|
||||||
|
|
||||||
Changes in 0.84 (04 Oct 1999)
|
Changes in 0.84 (04 Oct 1999)
|
||||||
@@ -219,7 +399,7 @@ Changes in 0.83 (17 Sep 1999)
|
|||||||
Changes in 0.82 (16 Aug 1999)
|
Changes in 0.82 (16 Aug 1999)
|
||||||
* dos/exe: fixed a decompressor bug which could cause crash on some files
|
* dos/exe: fixed a decompressor bug which could cause crash on some files
|
||||||
* linux/386: section headers are now stripped from the stub so that
|
* linux/386: section headers are now stripped from the stub so that
|
||||||
`strip' won't ruin a compressed file any longer
|
'strip' won't ruin a compressed file any longer
|
||||||
* wc/le: support for stack not in the last object disabled again
|
* wc/le: support for stack not in the last object disabled again
|
||||||
* win32/pe: removed some unneeded data
|
* win32/pe: removed some unneeded data
|
||||||
|
|
||||||
@@ -228,32 +408,32 @@ Changes in 0.81 (04 Aug 1999)
|
|||||||
* dos/com: fixed an internal error that could happen with very small files
|
* dos/com: fixed an internal error that could happen with very small files
|
||||||
|
|
||||||
Changes in 0.80 (03 Aug 1999)
|
Changes in 0.80 (03 Aug 1999)
|
||||||
* you can set some default options in the environment var `UPX'
|
* you can set some default options in the environment var 'UPX'
|
||||||
* dos/com: the decompressor stub now checks for enough free memory
|
* dos/com: the decompressor stub now checks for enough free memory
|
||||||
* dos/exe: decompressor rewritten, some bugs are fixed
|
* dos/exe: decompressor rewritten, some bugs are fixed
|
||||||
* dos/exe: new option `--no-reloc': no relocation data is put into
|
* dos/exe: new option '--no-reloc': no relocation data is put into
|
||||||
the DOS header
|
the DOS header
|
||||||
* tmt/adam: added support for more stubs, detect already packed files
|
* tmt/adam: added support for more stubs, detect already packed files
|
||||||
* tmt/adam: new option `--copy-overlay'
|
* tmt/adam: new option '--copy-overlay'
|
||||||
* wc/le: reduced memory requirement during uncompression
|
* wc/le: reduced memory requirement during uncompression
|
||||||
* wc/le: support files which do not contain their stack in the last object
|
* wc/le: support files which do not contain their stack in the last object
|
||||||
* wc/le: fixed a bug which could cause a crash, improved relocation
|
* wc/le: fixed a bug which could cause a crash, improved relocation
|
||||||
handling
|
handling
|
||||||
* wc/le: new option `--copy-overlay'
|
* wc/le: new option '--copy-overlay'
|
||||||
* win32/pe: `--compress-icons=2' is now the default
|
* win32/pe: '--compress-icons=2' is now the default
|
||||||
* win32/pe: even better TLS support
|
* win32/pe: even better TLS support
|
||||||
* win32/pe: versioninfo works on NT
|
* win32/pe: versioninfo works on NT
|
||||||
* win32/pe: import by ordinal from kernel32.dll works
|
* win32/pe: import by ordinal from kernel32.dll works
|
||||||
* win32/pe: other import improvements: importing a nonexistant DLL
|
* win32/pe: other import improvements: importing a nonexistent DLL
|
||||||
results in a usual Windows message, importing a nonexistant function
|
results in a usual Windows message, importing a nonexistent function
|
||||||
results in program exit (instead of crash ;-)
|
results in program exit (instead of crash ;-)
|
||||||
* win32/pe: new option: `--compress-resources=0'
|
* win32/pe: new option: '--compress-resources=0'
|
||||||
* win32/pe: reduced memory requirement during uncompression, some
|
* win32/pe: reduced memory requirement during uncompression, some
|
||||||
files might even require LESS memory when they're compressed
|
files might even require LESS memory when they're compressed
|
||||||
* win32/pe: TYPELIBs should work now
|
* win32/pe: TYPELIBs should work now
|
||||||
* win32/pe: improved relocation handling, 16-bit relocations should work
|
* win32/pe: improved relocation handling, 16-bit relocations should work
|
||||||
* win32/pe: new option `--strip-relocs' (only if you know what you are doing)
|
* win32/pe: new option '--strip-relocs' (only if you know what you are doing)
|
||||||
* win32/pe: new option `--copy-overlay'
|
* win32/pe: new option '--copy-overlay'
|
||||||
* important internal changes: now the stubs are built at runtime
|
* important internal changes: now the stubs are built at runtime
|
||||||
|
|
||||||
Changes in 0.72 (12 May 1999)
|
Changes in 0.72 (12 May 1999)
|
||||||
@@ -267,20 +447,20 @@ Changes in 0.72 (12 May 1999)
|
|||||||
* linux/386: minor decompressor stub updates, nicer progress bar
|
* linux/386: minor decompressor stub updates, nicer progress bar
|
||||||
|
|
||||||
Changes in 0.71 (19 Apr 1999)
|
Changes in 0.71 (19 Apr 1999)
|
||||||
* dos/exe: added option `--no-overlay'
|
* dos/exe: added option '--no-overlay'
|
||||||
* linux/386: various improvements in the stub, most notably the
|
* linux/386: various improvements in the stub, most notably the
|
||||||
overhead for an extra cleanup process has been removed
|
overhead for an extra cleanup process has been removed
|
||||||
* win32/pe: added support for export forwarders
|
* win32/pe: added support for export forwarders
|
||||||
* win32/pe: added support for DLLs without entry point or imports
|
* win32/pe: added support for DLLs without entry point or imports
|
||||||
* win32/pe: yet another .bss fix
|
* win32/pe: yet another .bss fix
|
||||||
* win32/pe: new option `--compress-icons=2': compress all icons
|
* win32/pe: new option '--compress-icons=2': compress all icons
|
||||||
which are not in the first icon directory
|
which are not in the first icon directory
|
||||||
* win32/pe: rearranged stub to avoid false alerts from some virus scanners
|
* win32/pe: rearranged stub to avoid false alerts from some virus scanners
|
||||||
|
|
||||||
Changes in 0.70 (30 Mar 1999)
|
Changes in 0.70 (30 Mar 1999)
|
||||||
* added support for linux/386 executables
|
* added support for linux/386 executables
|
||||||
* improved compression ratio quite a bit
|
* improved compression ratio quite a bit
|
||||||
* added new compression level `--best' to squeeze out even some more bytes
|
* added new compression level '--best' to squeeze out even some more bytes
|
||||||
* win32/pe: TLS support is much better now
|
* win32/pe: TLS support is much better now
|
||||||
* win32/pe: --compress-icons=0 should now work as well
|
* win32/pe: --compress-icons=0 should now work as well
|
||||||
* the usual minor fixes for win32/pe
|
* the usual minor fixes for win32/pe
|
||||||
@@ -297,7 +477,7 @@ Changes in 0.60 (06 Mar 1999)
|
|||||||
* win32/pe: fixed file corruption when the size of the export data is invalid
|
* win32/pe: fixed file corruption when the size of the export data is invalid
|
||||||
* win32/pe: fixed a problem with empty resource data
|
* win32/pe: fixed a problem with empty resource data
|
||||||
* win32/pe: compressed file alignment set to minimum value
|
* win32/pe: compressed file alignment set to minimum value
|
||||||
* win32/pe: made all compressed sections writeable
|
* win32/pe: made all compressed sections writable
|
||||||
* fixed some other win32/pe bugs
|
* fixed some other win32/pe bugs
|
||||||
* fixed an address optimization problem for some not Watcom LE files
|
* fixed an address optimization problem for some not Watcom LE files
|
||||||
* fixed a bug which could make UPX hang when an exe header contained
|
* fixed a bug which could make UPX hang when an exe header contained
|
||||||
@@ -338,3 +518,5 @@ Changes in 0.20 (05 Jul 1998)
|
|||||||
Changes in 0.05 (26 May 1998)
|
Changes in 0.05 (26 May 1998)
|
||||||
* first public beta release
|
* first public beta release
|
||||||
|
|
||||||
|
|
||||||
|
# vim:set syntax=off tw=0 ts=4 sw=4 et: -*- coding: utf-8 -*-
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2006 Markus Oberhumer & Laszlo Molnar
|
Copyright (c) 1996-2020 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
https://upx.github.io
|
||||||
|
|
||||||
|
|
||||||
Here are some possible projects from which you can choose if you'd like to
|
Here are some possible projects from which you can choose if you'd like to
|
||||||
@@ -56,8 +56,6 @@ Existing formats:
|
|||||||
|
|
||||||
- dos/exe: implement filter support
|
- dos/exe: implement filter support
|
||||||
|
|
||||||
- dos/sys: add support for sys/exe combos
|
|
||||||
|
|
||||||
- linux/i386:
|
- linux/i386:
|
||||||
- use the new assembly preprocessor stuff (ie. process the file
|
- use the new assembly preprocessor stuff (ie. process the file
|
||||||
headers internally)
|
headers internally)
|
||||||
@@ -68,8 +66,7 @@ Existing formats:
|
|||||||
|
|
||||||
- win32/pe: display a nice dialog box in the stub in case
|
- win32/pe: display a nice dialog box in the stub in case
|
||||||
of problems (like importing a DLL or function fails)
|
of problems (like importing a DLL or function fails)
|
||||||
- win32/pe: finer control over resource compression, per section
|
- win32/pe: per section compression
|
||||||
compression
|
|
||||||
|
|
||||||
|
|
||||||
Compression ratio:
|
Compression ratio:
|
||||||
|
|||||||
@@ -8,36 +8,11 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2006 Markus Oberhumer & Laszlo Molnar
|
Copyright (c) 1996-2020 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
https://upx.github.io
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WARNING - UNSTABLE BETA VERSION
|
|
||||||
===============================
|
|
||||||
|
|
||||||
All versions 1.9x are unstable beta releases - use them only for testing,
|
|
||||||
and never distribute a program that is packed with them !
|
|
||||||
There will be hidden bugs. Really.
|
|
||||||
|
|
||||||
The current stable release is 1.25, and the next stable release
|
|
||||||
will be called version 2.00.
|
|
||||||
|
|
||||||
The main news since 1.25 are:
|
|
||||||
- slightly better compression using the new NRV2E algorithm
|
|
||||||
- new options for compression tuning (e.g. `--brute')
|
|
||||||
- support for bootable Linux kernels ("vmlinuz/386")
|
|
||||||
- support for Linux kernel building ("vmlinux/386")
|
|
||||||
- direct Linux ELF-to-memory decompression ("linux/elf386") and
|
|
||||||
shell-to-memory decompression ("linux/sh386")
|
|
||||||
- support for arm/WinCE ("arm/pe") exes
|
|
||||||
- support for mach/ppc32
|
|
||||||
- support for Linux elf/ppc32
|
|
||||||
- support for Linux elf/amd64
|
|
||||||
- support for playstation exes ("ps1/exe")
|
|
||||||
- lots of new bugs ;-) take care
|
|
||||||
|
|
||||||
|
|
||||||
WELCOME
|
WELCOME
|
||||||
=======
|
=======
|
||||||
|
|
||||||
@@ -62,7 +37,7 @@ and run exactly as before, with no runtime or memory penalty for most
|
|||||||
of the supported formats.
|
of the supported formats.
|
||||||
|
|
||||||
UPX supports a number of different executable formats, including
|
UPX supports a number of different executable formats, including
|
||||||
Windows 95/98/ME/NT/2000/XP programs and DLLs, DOS programs,
|
Windows 95/98/ME/NT/2000/XP/CE programs and DLLs, DOS programs,
|
||||||
and Linux executables and kernels.
|
and Linux executables and kernels.
|
||||||
|
|
||||||
UPX is free software distributed under the term of the GNU General
|
UPX is free software distributed under the term of the GNU General
|
||||||
@@ -80,8 +55,8 @@ UPX aims to be Commercial Quality Freeware.
|
|||||||
SHORT DOCUMENTATION
|
SHORT DOCUMENTATION
|
||||||
===================
|
===================
|
||||||
|
|
||||||
`upx program.exe' will compress a program or DLL. For best compression
|
'upx program.exe' will compress a program or DLL. For best compression
|
||||||
results try `upx --best program.exe'.
|
results try 'upx --brute program.exe'.
|
||||||
|
|
||||||
Please see the file UPX.DOC for the full documentation. The files
|
Please see the file UPX.DOC for the full documentation. The files
|
||||||
NEWS and BUGS also contain various tidbits of information.
|
NEWS and BUGS also contain various tidbits of information.
|
||||||
@@ -95,7 +70,7 @@ 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
|
Having said that, we think that UPX is quite stable now. Indeed we
|
||||||
have compressed lots of files without any problems. Also, the
|
have compressed lots of files without any problems. Also, the
|
||||||
current version has undergone several months of beta testing -
|
current version has undergone several months of beta testing -
|
||||||
actually it's more than 4 years since our first public beta.
|
actually it's almost 8 years since our first public beta.
|
||||||
|
|
||||||
This is the first production quality release, and we plan that future
|
This is the first production quality release, and we plan that future
|
||||||
releases will be backward compatible with this version.
|
releases will be backward compatible with this version.
|
||||||
@@ -106,12 +81,7 @@ Please report all problems or suggestions to the authors. Thanks.
|
|||||||
THE FUTURE
|
THE FUTURE
|
||||||
==========
|
==========
|
||||||
|
|
||||||
- We'd really love to support handheld systems like the PalmPilot because
|
- AArch64 (64-bit ARM) for Linux and iOS.
|
||||||
compression makes a lot of sense here. And - because of the atari/tos
|
|
||||||
format - we already have a working decompressor in 68000 assembly.
|
|
||||||
Unfortunately we know next to nothing about the operating system
|
|
||||||
architecture of such handhelds, so we need some information from
|
|
||||||
an expert. Please contact us if you think you can help.
|
|
||||||
|
|
||||||
- The Linux approach could probably get ported to a lot of other Unix
|
- 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
|
variants, at least for other i386 architectures it shouldn't be too
|
||||||
@@ -121,7 +91,7 @@ THE FUTURE
|
|||||||
- We will *NOT* add any sort of protection and/or encryption.
|
- We will *NOT* add any sort of protection and/or encryption.
|
||||||
This only gives people a false feeling of security because
|
This only gives people a false feeling of security because
|
||||||
by definition all protectors/compressors can be broken.
|
by definition all protectors/compressors can be broken.
|
||||||
And don't trust any advertisment of authors of other executable
|
And don't trust any advertisement of authors of other executable
|
||||||
compressors about this topic - just do a websearch on "unpackers"...
|
compressors about this topic - just do a websearch on "unpackers"...
|
||||||
|
|
||||||
- Fix all remaining bugs - keep your reports coming ;-)
|
- Fix all remaining bugs - keep your reports coming ;-)
|
||||||
@@ -133,8 +103,9 @@ THE FUTURE
|
|||||||
COPYRIGHT
|
COPYRIGHT
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2006 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
|
Copyright (C) 2000-2020 John F. Reiser
|
||||||
|
|
||||||
This program may be used freely, and you are welcome to
|
This program may be used freely, and you are welcome to
|
||||||
redistribute it under certain conditions.
|
redistribute it under certain conditions.
|
||||||
@@ -149,12 +120,14 @@ with this program; see the file LICENSE. If not, visit the UPX home page.
|
|||||||
|
|
||||||
|
|
||||||
Share and enjoy,
|
Share and enjoy,
|
||||||
Markus & Laszlo
|
Markus & Laszlo & John
|
||||||
|
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@users.sourceforge.net
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
|
John F. Reiser
|
||||||
|
<jreiser@BitWagon.com>
|
||||||
|
|
||||||
|
|
||||||
[ The term UPX is a shorthand for the Ultimate Packer for eXecutables
|
[ The term UPX is a shorthand for the Ultimate Packer for eXecutables
|
||||||
|
|||||||
+8
-22
@@ -8,31 +8,17 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2006 Markus Oberhumer & Laszlo Molnar
|
Copyright (c) 1996-2020 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
https://upx.github.io
|
||||||
|
|
||||||
|
|
||||||
|
MAJOR NEWS IN UPX 3
|
||||||
|
===================
|
||||||
|
|
||||||
WARNING - UNSTABLE BETA VERSION
|
The main news since UPX 2 are:
|
||||||
===============================
|
|
||||||
|
|
||||||
All versions 1.9x are unstable beta releases - use them only for testing,
|
* new format: added support for linux elf/arm
|
||||||
and never distribute a program that is packed with them !
|
|
||||||
There will be hidden bugs. Really.
|
|
||||||
|
|
||||||
The current stable release is 1.25, and the next stable release
|
* better compression using the LZMA algorithm (option '--lzma')
|
||||||
will be called version 2.00.
|
|
||||||
|
|
||||||
The main news since 1.25 are:
|
* better support for MacOS
|
||||||
- slightly better compression using the new NRV2E algorithm
|
|
||||||
- new options for compression tuning (e.g. `--brute')
|
|
||||||
- support for bootable Linux kernels ("vmlinuz/386")
|
|
||||||
- support for Linux kernel building ("vmlinux/386")
|
|
||||||
- direct Linux ELF-to-memory decompression ("linux/elf386") and
|
|
||||||
shell-to-memory decompression ("linux/sh386")
|
|
||||||
- support for arm/WinCE ("arm/pe") exes
|
|
||||||
- support for mach/ppc32
|
|
||||||
- support for Linux elf/ppc32
|
|
||||||
- support for Linux elf/amd64
|
|
||||||
- support for playstation exes ("ps1/exe")
|
|
||||||
- lots of new bugs ;-) take care
|
|
||||||
|
|||||||
+23
-36
@@ -61,61 +61,49 @@ Prerequisites
|
|||||||
|
|
||||||
- first of all you need to build the UCL compression library
|
- first of all you need to build the UCL compression library
|
||||||
http://www.oberhumer.com/opensource/ucl/
|
http://www.oberhumer.com/opensource/ucl/
|
||||||
|
Use "CC=gcc -std=gnu89" especially with gcc-6.3 and gcc-7.1.
|
||||||
|
To build for native aarch64 (64-bit ARM) the files config.guess
|
||||||
|
and config.sub must be updated according to the recipe at
|
||||||
|
https://www.gnu.org/software/gettext/manual/html_node/config_002eguess.html
|
||||||
|
|
||||||
|
|
||||||
Tools needed to build/modify the UPX sources
|
Tools needed to build/modify the UPX sources
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
|
||||||
- A C++ compiler supporting inner classes, templates, exceptions
|
- A C++ compiler: gcc >= 3.3 or clang.
|
||||||
and RTTI.
|
|
||||||
|
|
||||||
- GNU make 3.80 for Win32
|
- GNU make 3.81 or better
|
||||||
http://www.cygwin.com/
|
|
||||||
|
|
||||||
- GNU make 3.80 for DOS
|
- zlib and zlib-devel [or zlib-dev] software packages for your
|
||||||
http://www.delorie.com/djgpp/
|
host environment
|
||||||
|
|
||||||
|
- LZMA SDK from https://github.com/upx/upx-lzma-sdk
|
||||||
|
When using git run 'git submodule update --init --recursive'.
|
||||||
|
|
||||||
|
|
||||||
To compile the packer sources
|
To compile the packer sources
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
set the environment variable UCLDIR to point to your UCL installation, e.g.
|
Set the environment variable UPX_UCLDIR to point to your
|
||||||
|
UCL build directory, e.g.
|
||||||
|
|
||||||
set UCLDIR=c:\src\ucl-1.03 (DOS / Windows)
|
set UPX_UCLDIR=c:\src\ucl-1.03 (DOS / Windows)
|
||||||
export UCLDIR=$HOME/local/src/ucl-1.03 (Unix)
|
export UPX_UCLDIR=$HOME/local/src/ucl-1.03 (Unix)
|
||||||
|
|
||||||
then type
|
Finally type
|
||||||
|
|
||||||
make target=linux # linux
|
make
|
||||||
make target=djgpp2 # dos32 - djgpp2
|
|
||||||
make target=cygwin # win32 - cygwin 1.3.x
|
|
||||||
make target=mingw32 # win32 - mingw32
|
|
||||||
make target=no-cygwin # win32 - mingw32 as included in cygwin
|
|
||||||
|
|
||||||
|
|
||||||
If you want to modify the stub sources you'll also need
|
If you want to modify the stub sources you'll also need
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
|
|
||||||
- Nasm 0.98.38 - the Netwide Assembler
|
- Perl & Python
|
||||||
http://upx.sourceforge.net/download/tools/
|
|
||||||
http://sourceforge.net/projects/nasm/
|
|
||||||
|
|
||||||
- A68K - a 68000 macro assembler
|
- upx-stubtools - a number of cross-assemblers and cross-compilers.
|
||||||
http://upx.sourceforge.net/download/tools/
|
Precompiled binaries for i386-linux hosts are available from
|
||||||
|
https://github.com/upx/upx-stubtools/releases
|
||||||
|
|
||||||
- djasm - an assembler for the djgpp stub
|
|
||||||
http://upx.sourceforge.net/download/tools/
|
|
||||||
|
|
||||||
- Perl 5.6 or better
|
|
||||||
|
|
||||||
- Linux (for the linux/386 stubs)
|
|
||||||
|
|
||||||
- Other cross compilers targeted at the following architectures:
|
|
||||||
- powerpc-750-linux-gnu
|
|
||||||
- x86_64-unknown-linux-gnu
|
|
||||||
- arm-wince-pe
|
|
||||||
|
|
||||||
- ASM5900 - a MIPS R3000 assembler
|
|
||||||
|
|
||||||
Misc. notes
|
Misc. notes
|
||||||
-----------
|
-----------
|
||||||
@@ -129,9 +117,6 @@ Misc. notes
|
|||||||
stream.
|
stream.
|
||||||
- Use gcc extensions and other compiler specific stuff only through
|
- Use gcc extensions and other compiler specific stuff only through
|
||||||
macros.
|
macros.
|
||||||
- Keep in mind that it should be possible to build UPX on braindead
|
|
||||||
file systems (FAT). Don't use long file names or other things
|
|
||||||
that break building under plain DOS.
|
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
@@ -156,3 +141,5 @@ Patches/Contributions
|
|||||||
|
|
||||||
diff -uNr olddirectory newdirectory
|
diff -uNr olddirectory newdirectory
|
||||||
|
|
||||||
|
|
||||||
|
# vim:set ts=4 sw=4 et:
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2006 Markus Oberhumer & Laszlo Molnar
|
Copyright (c) 1996-2020 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
https://upx.github.io
|
||||||
|
|
||||||
|
|
||||||
.___.. .
|
.___.. .
|
||||||
@@ -39,12 +39,12 @@ Ice
|
|||||||
for debugging the PE headersize problem down
|
for debugging the PE headersize problem down
|
||||||
Joergen Ibsen <jibz@hotmail.com> and d'b
|
Joergen Ibsen <jibz@hotmail.com> and d'b
|
||||||
for the relocation & address optimization ideas
|
for the relocation & address optimization ideas
|
||||||
John F. Reiser <jreiser@BitWagon.com>
|
|
||||||
for the new Linux executable formats
|
|
||||||
John S. Fine <johnfine@erols.com>
|
John S. Fine <johnfine@erols.com>
|
||||||
for the new version of the dos/exe decompressor
|
for the new version of the dos/exe decompressor
|
||||||
Lukundoo <Lukundoo@softhome.net>
|
Lukundoo <Lukundoo@softhome.net>
|
||||||
for beta testing
|
for beta testing
|
||||||
|
Michael Devore
|
||||||
|
for initial dos/exe device driver support
|
||||||
Oleg V. Volkov <rover@lglobus.ru>
|
Oleg V. Volkov <rover@lglobus.ru>
|
||||||
for various FreeBSD specific informations
|
for various FreeBSD specific informations
|
||||||
The Owl & G-RoM
|
The Owl & G-RoM
|
||||||
@@ -53,6 +53,8 @@ Ralph Roth <RalphRoth@gmx.net>
|
|||||||
for reporting several bugs
|
for reporting several bugs
|
||||||
Salvador Eduardo Tropea
|
Salvador Eduardo Tropea
|
||||||
for beta testing
|
for beta testing
|
||||||
|
Stefan Widmann
|
||||||
|
for the win32/pe TLS callback support
|
||||||
The WINE project (http://www.winehq.com/)
|
The WINE project (http://www.winehq.com/)
|
||||||
for lots of useful information found in their PE loader sources
|
for lots of useful information found in their PE loader sources
|
||||||
Natascha
|
Natascha
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
UPX TODO list. Last updated 2006-03-11.
|
|
||||||
|
|
||||||
|
|
||||||
IMPORTANT PROBLEMS THAT SHOULD BE FIXED SOON:
|
|
||||||
|
|
||||||
- [None]
|
|
||||||
|
|
||||||
|
|
||||||
OTHER:
|
|
||||||
|
|
||||||
- docs: convert docs from upx.pod to use AsciiDoc
|
|
||||||
|
|
||||||
- check all <const_cast> to make sure they are not invalid
|
|
||||||
|
|
||||||
- throwNotCompressible() is not a real error, so make the output nicer
|
|
||||||
(info: bla bla). Also ui.cpp (total_*).
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
IMPROVED COMPRESSION RATIO
|
|
||||||
==========================
|
|
||||||
|
|
||||||
- experiment with new filters
|
|
||||||
|
|
||||||
- implement filters for dos/exe
|
|
||||||
|
|
||||||
- filters: could we exploit a f->firstcall info field ?
|
|
||||||
|
|
||||||
- for small programs (e.g. < 64k), try an additional algorithm
|
|
||||||
to see if it gives better compression
|
|
||||||
|
|
||||||
|
|
||||||
ALL FORMATS
|
|
||||||
===========
|
|
||||||
|
|
||||||
- more thoroughly test the exe-header in canPack()
|
|
||||||
and throw exceptions when encountering bad values.
|
|
||||||
|
|
||||||
- implement `--cpu=486' option to use bswap on the 32-bit formats
|
|
||||||
(if cpu >= 486)
|
|
||||||
|
|
||||||
- consider removing "or ebp,-1" when not needed
|
|
||||||
|
|
||||||
|
|
||||||
FORMAT DJGPP2/COFF
|
|
||||||
==================
|
|
||||||
|
|
||||||
- handle overlays
|
|
||||||
|
|
||||||
- fix default file extension handling when the --coff option is set
|
|
||||||
|
|
||||||
|
|
||||||
FORMAT DOS/EXE
|
|
||||||
==============
|
|
||||||
|
|
||||||
- implement filters
|
|
||||||
|
|
||||||
- add a check so that we don't pack djgpp1 binaries
|
|
||||||
|
|
||||||
|
|
||||||
FORMAT LINUX/386
|
|
||||||
================
|
|
||||||
|
|
||||||
- don't mmap() the temporary output file - this seems to improve
|
|
||||||
file io speed
|
|
||||||
|
|
||||||
|
|
||||||
FORMAT TMT/ADAM
|
|
||||||
===============
|
|
||||||
|
|
||||||
- the decompressors are already aligned, no need for an
|
|
||||||
extra alignment
|
|
||||||
|
|
||||||
|
|
||||||
FORMAT WATCOM/LE
|
|
||||||
================
|
|
||||||
|
|
||||||
- handle files without relocations
|
|
||||||
|
|
||||||
- the decompressors are already aligned, no need for an
|
|
||||||
extra alignment
|
|
||||||
|
|
||||||
- fix default file extension handling when the --le option is set
|
|
||||||
|
|
||||||
- handle holes in the file
|
|
||||||
|
|
||||||
- implement compressWithFilters()
|
|
||||||
|
|
||||||
- add a call to verifyOverlappingDecompression()
|
|
||||||
|
|
||||||
|
|
||||||
FORMAT WIN16/NE
|
|
||||||
===============
|
|
||||||
|
|
||||||
- implement readFileHeader() to correctly identify a win16/ne
|
|
||||||
executable, so that the call for contribution will get thrown
|
|
||||||
|
|
||||||
|
|
||||||
FORMAT WIN32/PE
|
|
||||||
===============
|
|
||||||
|
|
||||||
- fix the section alignment with the Intel compiler
|
|
||||||
|
|
||||||
- decrease runtime memory overhead
|
|
||||||
|
|
||||||
2 - easy - mfx + ml) new switch(es) : do not compress resource types x,y,z
|
|
||||||
or resource names a,b,c
|
|
||||||
|
|
||||||
3 - difficult) don't compress the BSS section and other holes.
|
|
||||||
|
|
||||||
4 - medium - ml) fix when objectalign < 0x1000
|
|
||||||
|
|
||||||
4 - easy - ml) put the original offset of moved resources somewhere into
|
|
||||||
the res.dir. (if it's safe to do)
|
|
||||||
|
|
||||||
4 - ??? - ml) fix FIXMEs
|
|
||||||
|
|
||||||
5 - medium - ml) try to put the preprocessed imports & relocs back to their
|
|
||||||
original section if possible. this could save some virtual memory
|
|
||||||
address space.
|
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
upx.1
|
|
||||||
upx.doc
|
|
||||||
upx.html
|
|
||||||
upx.man
|
|
||||||
upx.ps
|
|
||||||
upx.tex
|
|
||||||
+49
-34
@@ -1,34 +1,43 @@
|
|||||||
|
#
|
||||||
|
# UPX doc Makefile - needs GNU make 3.81 or better
|
||||||
|
#
|
||||||
|
|
||||||
|
MAKEFLAGS += -rR
|
||||||
|
.SUFFIXES:
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
top_srcdir = ..
|
# internal make variables
|
||||||
|
comma := ,
|
||||||
|
empty :=
|
||||||
|
space := $(empty) $(empty)
|
||||||
|
tab := $(empty) $(empty)
|
||||||
|
|
||||||
|
|
||||||
|
# /***********************************************************************
|
||||||
|
# //
|
||||||
|
# ************************************************************************/
|
||||||
|
|
||||||
|
top_srcdir ?= ..
|
||||||
|
|
||||||
PACKAGE = upx
|
PACKAGE = upx
|
||||||
VERSION_DATE = 11 Mar 2006
|
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)
|
VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
|
||||||
|
|
||||||
TRIMSPACE = cat
|
RTRIM := sed -e 's/[ $(tab)]*$$//'
|
||||||
TRIMSPACE = sed -e 's/ *$$//'
|
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 upx.man upx.ps upx.tex
|
||||||
BUILT_SOURCES = upx.1 upx.doc upx.html
|
BUILT_SOURCES = upx.1 upx.doc upx.html
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
###
|
### targets
|
||||||
###
|
###
|
||||||
|
|
||||||
all: $(BUILT_SOURCES)
|
all: $(BUILT_SOURCES)
|
||||||
|
|
||||||
mostlyclean:
|
mostlyclean clean distclean maintainer-clean:
|
||||||
-rm -f $(BUILT_SOURCES) pod2htm*
|
rm -f $(BUILT_SOURCES) pod2htm*
|
||||||
|
|
||||||
clean: mostlyclean
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
|
|
||||||
maintainer-clean: distclean
|
|
||||||
|
|
||||||
.SUFFIXES: .1 .doc .html .man .pod .ps .tex .texi
|
|
||||||
|
|
||||||
.PHONY: all mostlyclean clean distclean maintainer-clean
|
.PHONY: all mostlyclean clean distclean maintainer-clean
|
||||||
|
|
||||||
@@ -37,32 +46,38 @@ maintainer-clean: distclean
|
|||||||
### rules
|
### rules
|
||||||
###
|
###
|
||||||
|
|
||||||
.pod.1:
|
.SUFFIXES: .1 .doc .html .man .pod .ps .tex
|
||||||
pod2man --center=" " --release="$(PACKAGE) $(VERSION)" --date="$(VERSION_DATE)" $< | $(TRIMSPACE) > $@
|
|
||||||
|
|
||||||
.pod.html:
|
%.1 : %.pod
|
||||||
### pod2html $< | $(TRIMSPACE) > $@
|
pod2man --center=" " --release="$(PACKAGE) $(VERSION)" --date="$(VERSION_DATE)" $< | $(RTRIM) > $@
|
||||||
pod2html --noindex $< | $(TRIMSPACE) > $@
|
test -s $@
|
||||||
@-rm -f pod2htm*
|
|
||||||
|
|
||||||
.pod.tex:
|
%.doc : %.pod
|
||||||
|
pod2text < $< | $(RTRIM) > $@
|
||||||
|
test -s $@
|
||||||
|
|
||||||
|
%.html : %.pod
|
||||||
|
pod2html --noindex $< | $(RTRIM) | $(DETAB2) > $@
|
||||||
|
@rm -f pod2htm*
|
||||||
|
test -s $@
|
||||||
|
|
||||||
|
%.man : %.1
|
||||||
|
nroff -man $< | $(RTRIM) > $@
|
||||||
|
test -s $@
|
||||||
|
|
||||||
|
%.ps : %.1
|
||||||
|
groff -man $< | $(RTRIM) > $@
|
||||||
|
test -s $@
|
||||||
|
|
||||||
|
%.tex : %.pod
|
||||||
pod2latex $<
|
pod2latex $<
|
||||||
|
test -s $@
|
||||||
.pod.doc:
|
|
||||||
pod2text < $< | $(TRIMSPACE) > $@
|
|
||||||
|
|
||||||
.1.man:
|
|
||||||
nroff -man $< | $(TRIMSPACE) > $@
|
|
||||||
|
|
||||||
.1.ps:
|
|
||||||
groff -man $< | $(TRIMSPACE) > $@
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
### dependencies
|
### dependencies
|
||||||
###
|
###
|
||||||
|
|
||||||
$(BUILT_SOURCES): $(top_srcdir)/src/version.h Makefile
|
$(BUILT_SOURCES): $(top_srcdir)/src/version.h $(MAKEFILE_LIST)
|
||||||
|
.DELETE_ON_ERROR: $(BUILT_SOURCES)
|
||||||
.NOEXPORT:
|
|
||||||
|
|
||||||
|
|||||||
+47
-5
@@ -1,5 +1,5 @@
|
|||||||
Decompressing ELF Directly to Memory on Linux/x86
|
Decompressing ELF Directly to Memory on Linux/x86
|
||||||
Copyright 2000 John F. Reiser jreiser@BitWagon.com
|
Copyright (C) 2000-2020 John F. Reiser jreiser@BitWagon.com
|
||||||
|
|
||||||
References:
|
References:
|
||||||
<elf.h> definitions for the ELF file format
|
<elf.h> definitions for the ELF file format
|
||||||
@@ -17,7 +17,7 @@ program itself. So, the decompressor program (which contains the
|
|||||||
compressed version of the original executable) must have the same
|
compressed version of the original executable) must have the same
|
||||||
brk() as the original executable. So, the second PT_LOAD
|
brk() as the original executable. So, the second PT_LOAD
|
||||||
ELF "segment" of the compressed program is used only to set the brk(0).
|
ELF "segment" of the compressed program is used only to set the brk(0).
|
||||||
See src/p_lx_elf.cpp, function PackLinuxI386elf::patchLoader().
|
See src/p_lx_elf.cpp, function PackLinuxElf32::generateElfHdr.
|
||||||
All of the decompressor's code, and all of the compressed image
|
All of the decompressor's code, and all of the compressed image
|
||||||
of the original executable, reside in the first PT_LOAD of the
|
of the original executable, reside in the first PT_LOAD of the
|
||||||
decompressor program.
|
decompressor program.
|
||||||
@@ -46,8 +46,8 @@ may not be used to take the address of a function.
|
|||||||
|
|
||||||
The address 0x00400000 was chosen to be out of the way of the usual
|
The address 0x00400000 was chosen to be out of the way of the usual
|
||||||
load address 0x08048000, and to minimize fragmentation in kernel
|
load address 0x08048000, and to minimize fragmentation in kernel
|
||||||
page tables; one page of page tables covers 4MB. The address
|
page tables; one page of page tables covers 4 MiB. The address
|
||||||
0x00401000 was chosen as 1 page up from a 64KB boundary, to
|
0x00401000 was chosen as 1 page up from a 64 KiB boundary, to
|
||||||
make the startup code and its constants smaller.
|
make the startup code and its constants smaller.
|
||||||
|
|
||||||
Decompression of the executable begins by decompressing the Elf32_Ehdr
|
Decompression of the executable begins by decompressing the Elf32_Ehdr
|
||||||
@@ -57,9 +57,51 @@ Subroutine do_xmap() of src/stub/l_lx_elf.c performs the
|
|||||||
"virtual execve()" using the compressed data as source, and stores
|
"virtual execve()" using the compressed data as source, and stores
|
||||||
the decompressed bytes directly into the appropriate virtual addresses.
|
the decompressed bytes directly into the appropriate virtual addresses.
|
||||||
|
|
||||||
Before transfering control to the PT_INTERP "program interpreter",
|
Before transferring control to the PT_INTERP "program interpreter",
|
||||||
minor tricks are required to setup the Elf32_auxv_t entries,
|
minor tricks are required to setup the Elf32_auxv_t entries,
|
||||||
clear the free portion of the stack (to compensate for ld-linux.so.2
|
clear the free portion of the stack (to compensate for ld-linux.so.2
|
||||||
assuming that its automatic stack variables are initialized to zero),
|
assuming that its automatic stack variables are initialized to zero),
|
||||||
and remove (all but 4 bytes of) the decompression program (and
|
and remove (all but 4 bytes of) the decompression program (and
|
||||||
compressed executable) from the address space.
|
compressed executable) from the address space.
|
||||||
|
|
||||||
|
As of upx-3.05, by default on Linux, upon decompression then one page
|
||||||
|
of the compressed executable remains mapped into the address space
|
||||||
|
of the process. If all of the pages of the compressed executable are
|
||||||
|
unmapped, then the Linux kernel erases the symlink /proc/self/exe,
|
||||||
|
and this can cause trouble for the runtime shared library loader
|
||||||
|
expanding $ORIGIN in -rpath, or for application code that relies on
|
||||||
|
/proc/self/exe. Use the compress-time command-line option
|
||||||
|
--unmap-all-pages to achieve that effect at run time. Upx-3.04
|
||||||
|
and previous versions did this by default with no option. However,
|
||||||
|
too much other software erroneously assumes that /proc/self/exe
|
||||||
|
always exists.
|
||||||
|
|
||||||
|
On arm*-linux-elf there is no good address at which to retain one
|
||||||
|
page of the compressed executable. Pages below the usual .p_vaddr
|
||||||
|
0x8000 (32KiB) are rejected by the kernel. Using a page above the
|
||||||
|
original uncompressed brk(0) would require placing the entire initial
|
||||||
|
compressed program above uncompressed brk(0), which would significantly
|
||||||
|
increase the running brk(0); but too many programs break if brk(0)
|
||||||
|
moves. Thus on arm*-linux-elf the compressed executable begins
|
||||||
|
with 0x8000==.p_vaddr, all pages mapped by execve() that are also
|
||||||
|
occupied by decompressed bytes are removed before overwriting, and
|
||||||
|
/proc/self/exe becomes a "(deleted)" symlink. It might be possible
|
||||||
|
to preserve /proc/self/exe if the original uncompressed executable
|
||||||
|
were created with 0x9000==.p_vaddr (one page higher than the usual
|
||||||
|
0x8000) so that the compressed page mapped at 0x8000 would linger.
|
||||||
|
[This has not been tested.]
|
||||||
|
|
||||||
|
Linux stores the pathname argument that was specified to execve()
|
||||||
|
immediately after the '\0' which terminates the character string of the
|
||||||
|
last environment variable [as of execve()]. This is true for at least
|
||||||
|
all Linux 2.6, 2.4, and 2.2 kernels. Linux kernel 2.6.29 and later
|
||||||
|
records a pointer to that character string in Elf32_auxv[AT_EXECFN].
|
||||||
|
The pathname is not "bound" to the file as strongly as /proc/self/exe
|
||||||
|
(the file may be changed without affecting the pathname), but the
|
||||||
|
pathname does provide some information. The pathname may be relative
|
||||||
|
to the working directory, so look before any chdir().
|
||||||
|
|
||||||
|
The Elf formats for Linux add an environment variable named " " [three
|
||||||
|
spaces] which saves the results of readlink("/proc/self/exe",,) before
|
||||||
|
the runtime stub unmaps all its pages. As of 2006-10-03 this works
|
||||||
|
for linux/elf386 and linux/ElfAMD.
|
||||||
|
|||||||
+2
-2
@@ -108,14 +108,14 @@ then skip another one - the unfiltering process needs some information
|
|||||||
to be able to reverse the filtering.
|
to be able to reverse the filtering.
|
||||||
|
|
||||||
UPX uses the following idea, which works nicely. First we assume that
|
UPX uses the following idea, which works nicely. First we assume that
|
||||||
the size of the area that should be filtered is less than 16MB. Then
|
the size of the area that should be filtered is less than 16 MiB. Then
|
||||||
UPX scans over this area and keeps a record of the bytes that are
|
UPX scans over this area and keeps a record of the bytes that are
|
||||||
following the 0xE8 bytes. If we are lucky, there will be bytes that
|
following the 0xE8 bytes. If we are lucky, there will be bytes that
|
||||||
were not found following 0xE8. These bytes are our candidates to be
|
were not found following 0xE8. These bytes are our candidates to be
|
||||||
used as markers.
|
used as markers.
|
||||||
|
|
||||||
Do you still remember that we assumed that the size of scanned area is
|
Do you still remember that we assumed that the size of scanned area is
|
||||||
less than 16MB? Well, this means that when we process a real call, the
|
less than 16 MiB? Well, this means that when we process a real call, the
|
||||||
resulting offset will be less than 0x00FFFFFF too. So the MSB is always
|
resulting offset will be less than 0x00FFFFFF too. So the MSB is always
|
||||||
0x00. Which is a nice place to store our marker. Of course we should
|
0x00. Which is a nice place to store our marker. Of course we should
|
||||||
reverse the byte order in the resulting offset - so this marker will
|
reverse the byte order in the resulting offset - so this marker will
|
||||||
|
|||||||
+27
-66
@@ -2,16 +2,8 @@ This documentation is written for those brave souls who want to
|
|||||||
understand and/or modify the UPX assembly stubs - the small snippets
|
understand and/or modify the UPX assembly stubs - the small snippets
|
||||||
that do the runtime decompression when a compressed program is started.
|
that do the runtime decompression when a compressed program is started.
|
||||||
|
|
||||||
So, how the runtime stub/loader generation works?
|
If you look at the C++ source files, you can find code fragments like
|
||||||
|
this:
|
||||||
You might have already noticed that for some file formats the loaders
|
|
||||||
are quite simple (linux/i386 & tos) while in the other cases the
|
|
||||||
loaders look very suspicious: they're full of `%ifdef's and contain
|
|
||||||
loads of cryptic comments like `__PERELOC2__'.
|
|
||||||
|
|
||||||
If you look at the C++ source files, however you can notice that these
|
|
||||||
comment strings (without the leading and trailing underscores) are used
|
|
||||||
in the following way:
|
|
||||||
|
|
||||||
addLoader("PEMAIN20",
|
addLoader("PEMAIN20",
|
||||||
ih.entry ? "PEDOJUMP" : "PERETURN",
|
ih.entry ? "PEDOJUMP" : "PERETURN",
|
||||||
@@ -19,71 +11,40 @@ in the following way:
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
Basically that's all you have to know: when you want to add a section
|
linker->defineSymbol("original_entry", ih.entry);
|
||||||
of assembly code to the runtime loader, you just write
|
|
||||||
|
|
||||||
l_foo.asm
|
and in the assembly files fragments like this:
|
||||||
---------
|
|
||||||
;__FOOBAR00__
|
|
||||||
|
|
||||||
|
section PEISDLL1
|
||||||
|
cmpb [esp + 8], 1
|
||||||
|
jnz reloc_end_jmp
|
||||||
|
|
||||||
|
section PEMAIN21
|
||||||
|
reloc_end_jmp:
|
||||||
|
|
||||||
|
section PERETURN
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
label1:
|
inc eax
|
||||||
jmps label1
|
ret 0x0C
|
||||||
|
section PEDOJUMP
|
||||||
|
jmp original_entry
|
||||||
|
|
||||||
;__FOOBARZZ__
|
Everything works as you would expect. If you want to add the code
|
||||||
|
fragment which is in `section PERETURN' to the runtime stub, then
|
||||||
p_foo.cpp
|
simply use `addLoader("PERETURN")' in the C++ source.
|
||||||
---------
|
|
||||||
|
|
||||||
addLoader("FOOBAR00", NULL);
|
|
||||||
|
|
||||||
This will add the assembly section starting from __FOOBAR00__ and ending
|
|
||||||
before __FOOBARZZ__ to the loader. You can add an %ifdef - %endif pair
|
|
||||||
before these comments if you wish - but these conditionals will NOT be
|
|
||||||
seen by the assembler, they are just syntactic sugar to make the code a
|
|
||||||
little bit more readable and understandable. (Note however, that only
|
|
||||||
%ifdefs which are started on the 1st column are removed by the upx
|
|
||||||
assembly preprocessor program, so you can still use preprocessor
|
|
||||||
conditionals if you wish - just write them starting from the 2nd
|
|
||||||
column.)
|
|
||||||
|
|
||||||
That's nice, you could say, but how cross section jumps and calls are
|
That's nice, you could say, but how cross section jumps and calls are
|
||||||
handled? Well, that is the nicest part of this stuff - they are handled
|
handled? Well, that is the nicest part of this stuff - they are handled
|
||||||
automatically. All you have to do is to add the required sections to the
|
automatically. All you have to do is to add the required sections to the
|
||||||
loader using `addLoader()' and the rest is done by upx. It will resolve
|
loader using `addLoader()' and the rest is done by upx. It will resolve
|
||||||
every conditional or unconditional jumps or subrutine calls for you.
|
every conditional or unconditional jumps or subroutine calls for you.
|
||||||
|
|
||||||
This functionality (we could say it's a simple linker) is achived by the
|
You can also use (undefined) symbols in the assembly for values that
|
||||||
assembly preprocessor (src/stub/scripts/app.pl) and a little C++ module
|
can only be computed during compression time (like `original_entry').
|
||||||
(src/linker.cpp). And of course NASM - the Netwide Assembler. You can
|
These symbols can be defined later in C++ using
|
||||||
see what's going on behind the scenes - just do:
|
|
||||||
|
|
||||||
cd src/stubs
|
linker->defineSymbol("xx", yy)
|
||||||
make maintainer-clean
|
|
||||||
make all
|
|
||||||
|
|
||||||
This will rebuild all the loaders - and keep the temporary files (*.as[xy])
|
This functionality (we could say it's a simple linker) is achieved by
|
||||||
which are seen by the assembler.
|
compiling the assembly into an ELF object file which a little C++
|
||||||
|
module (src/linker.cpp) can interpret and work with.
|
||||||
Currently this loader/stub building method only works with ix86
|
|
||||||
assembly - both app.pl and linker.cpp heavily rely on this when dealing
|
|
||||||
with cross section references.
|
|
||||||
|
|
||||||
And finally some important features/requirements you should be aware of:
|
|
||||||
|
|
||||||
- as previously stated - preprocessor conditionals starting on the 1st
|
|
||||||
column are removed by app.pl
|
|
||||||
- sections are separated by comments in the form `;__X1234567__'
|
|
||||||
- jumps are recognized by searching for a word which starts with `j'
|
|
||||||
and followed by a label - this also means that `jmp short label1'
|
|
||||||
will NOT be recognized (but you can use a macro called `jmps' for it
|
|
||||||
by adding `%define jmps jmp short' to the beginning of the file)
|
|
||||||
- at the end of the file you need something like this
|
|
||||||
|
|
||||||
eof:
|
|
||||||
; __XTHEENDX__
|
|
||||||
section .data
|
|
||||||
dd -1
|
|
||||||
dw eof
|
|
||||||
|
|
||||||
That's all for now.
|
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ code 127, and a record will be added to the history file
|
|||||||
|
|
||||||
In "targeted enforcing" mode, SELinux pays close attention mostly to
|
In "targeted enforcing" mode, SELinux pays close attention mostly to
|
||||||
designated processes that run with elevated privileges: web server,
|
designated processes that run with elevated privileges: web server,
|
||||||
print server, login server, etc. Ordinary user excutables receive
|
print server, login server, etc. Ordinary user executables receive
|
||||||
much less scrutiny. However, one of the eventual goals of SELinux is to
|
much less scrutiny. However, one of the eventual goals of SELinux is to
|
||||||
eradicate runtime generation of instructions because of the possibility
|
eradicate runtime generation of instructions because of the possibility
|
||||||
for exploitation by malware (virus, trojan, key logger, privilege
|
for exploitation by malware (virus, trojan, key logger, privilege
|
||||||
|
|||||||
+78
-65
@@ -13,8 +13,8 @@ B<upx> S<[ I<command> ]> S<[ I<options> ]> I<filename>...
|
|||||||
=head1 ABSTRACT
|
=head1 ABSTRACT
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (c) 1996-2006 Markus Oberhumer & Laszlo Molnar
|
Copyright (c) 1996-2020 Markus Oberhumer, Laszlo Molnar & John Reiser
|
||||||
http://upx.sourceforge.net
|
https://upx.github.io
|
||||||
|
|
||||||
|
|
||||||
B<UPX> is a portable, extendable, high-performance executable packer for
|
B<UPX> is a portable, extendable, high-performance executable packer for
|
||||||
@@ -51,8 +51,8 @@ B<UPX> is a versatile executable packer with the following features:
|
|||||||
- excellent compression ratio: compresses better than zip/gzip,
|
- excellent compression ratio: compresses better than zip/gzip,
|
||||||
use UPX to decrease the size of your distribution !
|
use UPX to decrease the size of your distribution !
|
||||||
|
|
||||||
- very fast decompression: about 10 MB/sec on an ancient Pentium 133,
|
- very fast decompression: about 10 MiB/sec on an ancient Pentium 133,
|
||||||
about 200 MB/sec on an Athlon XP 2000+.
|
about 200 MiB/sec on an Athlon XP 2000+.
|
||||||
|
|
||||||
- no memory overhead for your compressed executables for most of the
|
- no memory overhead for your compressed executables for most of the
|
||||||
supported formats
|
supported formats
|
||||||
@@ -75,9 +75,11 @@ B<UPX> is a versatile executable packer with the following features:
|
|||||||
* rtm32/pe
|
* rtm32/pe
|
||||||
* tmt/adam
|
* tmt/adam
|
||||||
* vmlinuz/386 [bootable Linux kernel]
|
* vmlinuz/386 [bootable Linux kernel]
|
||||||
|
* vmlinux/386
|
||||||
* watcom/le (supporting DOS4G, PMODE/W, DOS32a and CauseWay)
|
* watcom/le (supporting DOS4G, PMODE/W, DOS32a and CauseWay)
|
||||||
* win32/pe
|
* win32/pe (exe and dll)
|
||||||
* arm/pe
|
* win64/pe (exe and dll)
|
||||||
|
* arm/pe (exe and dll)
|
||||||
* linux/elfamd64
|
* linux/elfamd64
|
||||||
* linux/elfppc32
|
* linux/elfppc32
|
||||||
* mach/elfppc32
|
* mach/elfppc32
|
||||||
@@ -137,6 +139,13 @@ B<--help>: prints the help
|
|||||||
|
|
||||||
B<--version>: print the version of B<UPX>
|
B<--version>: print the version of B<UPX>
|
||||||
|
|
||||||
|
B<--exact>: when compressing, require to be able to get a byte-identical file
|
||||||
|
after decompression with option B<-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.]
|
||||||
|
|
||||||
[ ...to be written... - type `B<upx --help>' for now ]
|
[ ...to be written... - type `B<upx --help>' for now ]
|
||||||
|
|
||||||
|
|
||||||
@@ -145,7 +154,7 @@ B<--version>: print the version of B<UPX>
|
|||||||
|
|
||||||
B<UPX> offers ten different compression levels from B<-1> to B<-9>,
|
B<UPX> offers ten different compression levels from B<-1> to B<-9>,
|
||||||
and B<--best>. The default compression level is B<-8> for files
|
and B<--best>. The default compression level is B<-8> for files
|
||||||
smaller than 512 kB, and B<-7> otherwise.
|
smaller than 512 KiB, and B<-7> otherwise.
|
||||||
|
|
||||||
=over 4
|
=over 4
|
||||||
|
|
||||||
@@ -171,38 +180,13 @@ Note that compression level B<--best> can be somewhat slow for large
|
|||||||
files, but you definitely should use it when releasing a final version
|
files, but you definitely should use it when releasing a final version
|
||||||
of your program.
|
of your program.
|
||||||
|
|
||||||
Quick start for achieving the best compression ratio:
|
Quick info for achieving the best compression ratio:
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
Try B<upx --brute myfile.exe>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
Details for achieving the best compression ratio:
|
|
||||||
|
|
||||||
=over 4
|
=over 4
|
||||||
|
|
||||||
=item *
|
=item *
|
||||||
|
|
||||||
Use the compression level B<--best>.
|
Try B<upx --brute myfile.exe> or even B<upx --ultra-brute myfile.exe>.
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Try one or both of the options B<--all-methods> and B<--all-filters>.
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Try the option B<--crp-ms=NUMBER>. This uses more memory during compression
|
|
||||||
to achieve a (slightly) better compression ratio.
|
|
||||||
|
|
||||||
NUMBER must be a decimal value from 10000 to 999999, inclusive.
|
|
||||||
The default value is 10000 (ten thousand).
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Info: the option B<--brute> is an abbrevation for the options
|
|
||||||
B<S<--best> S<--all-methods> S<--all-filters> S<--crp-ms=999999>>.
|
|
||||||
|
|
||||||
=item *
|
=item *
|
||||||
|
|
||||||
@@ -218,7 +202,7 @@ For win32/pe programs there's B<--strip-relocs=0>. See notes below.
|
|||||||
|
|
||||||
=head1 OVERLAY HANDLING OPTIONS
|
=head1 OVERLAY HANDLING OPTIONS
|
||||||
|
|
||||||
Info: An "overlay" means auxillary data atached after the logical end of
|
Info: An "overlay" means auxiliary data attached after the logical end of
|
||||||
an executable, and it often contains application specific data
|
an executable, and it often contains application specific data
|
||||||
(this is a common practice to avoid an extra data file, though
|
(this is a common practice to avoid an extra data file, though
|
||||||
it would be better to use resource sections).
|
it would be better to use resource sections).
|
||||||
@@ -339,9 +323,6 @@ Extra options available for this executable format:
|
|||||||
|
|
||||||
=head2 NOTES FOR DOS/SYS
|
=head2 NOTES FOR DOS/SYS
|
||||||
|
|
||||||
You can only compress plain sys files, sys/exe (two in one)
|
|
||||||
combos are not supported.
|
|
||||||
|
|
||||||
Compressed programs only work on a 286+.
|
Compressed programs only work on a 286+.
|
||||||
|
|
||||||
Packed programs will be byte-identical to the original after uncompression.
|
Packed programs will be byte-identical to the original after uncompression.
|
||||||
@@ -369,7 +350,7 @@ Extra options available for this executable format:
|
|||||||
First of all, it is recommended to use B<UPX> *instead* of B<strip>. strip has
|
First of all, it is recommended to use B<UPX> *instead* of B<strip>. strip has
|
||||||
the very bad habit of replacing your stub with its own (outdated) version.
|
the very bad habit of replacing your stub with its own (outdated) version.
|
||||||
Additionally B<UPX> corrects a bug/feature in strip v2.8.x: it
|
Additionally B<UPX> corrects a bug/feature in strip v2.8.x: it
|
||||||
will fix the 4 KByte aligment of the stub.
|
will fix the 4 KiB alignment of the stub.
|
||||||
|
|
||||||
B<UPX> includes the full functionality of stubify. This means it will
|
B<UPX> includes the full functionality of stubify. This means it will
|
||||||
automatically stubify your COFF files. Use the option B<--coff> to
|
automatically stubify your COFF files. Use the option B<--coff> to
|
||||||
@@ -404,7 +385,7 @@ Extra options available for this executable format:
|
|||||||
Introduction
|
Introduction
|
||||||
|
|
||||||
Linux/386 support in UPX consists of 3 different executable formats,
|
Linux/386 support in UPX consists of 3 different executable formats,
|
||||||
one optimized for ELF excutables ("linux/elf386"), one optimized
|
one optimized for ELF executables ("linux/elf386"), one optimized
|
||||||
for shell scripts ("linux/sh386"), and one generic format
|
for shell scripts ("linux/sh386"), and one generic format
|
||||||
("linux/386").
|
("linux/386").
|
||||||
|
|
||||||
@@ -435,11 +416,11 @@ General user's overview
|
|||||||
speeds of CPU, RAM, swap space, /tmp, and file system storage, then
|
speeds of CPU, RAM, swap space, /tmp, and file system storage, then
|
||||||
invoking and running a compressed executable can be faster than
|
invoking and running a compressed executable can be faster than
|
||||||
directly running the corresponding uncompressed program.
|
directly running the corresponding uncompressed program.
|
||||||
The operating system might perfrom fewer expensive I/O operations
|
The operating system might perform fewer expensive I/O operations
|
||||||
to invoke the compressed program. Paging to or from swap space
|
to invoke the compressed program. Paging to or from swap space
|
||||||
or /tmp might be faster than paging from the general file system.
|
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
|
``Medium-sized'' programs which access about 1/3 to 1/2 of their
|
||||||
stored program bytes can do particulary well with compression.
|
stored program bytes can do particularly well with compression.
|
||||||
Small programs tend not to benefit as much because the absolute
|
Small programs tend not to benefit as much because the absolute
|
||||||
savings is less. Big programs tend not to benefit proportionally
|
savings is less. Big programs tend not to benefit proportionally
|
||||||
because each invocation may use only a small fraction of the program,
|
because each invocation may use only a small fraction of the program,
|
||||||
@@ -537,7 +518,7 @@ The linux/elf386 format decompresses directly into RAM,
|
|||||||
uses only one exec, does not use space in /tmp,
|
uses only one exec, does not use space in /tmp,
|
||||||
and does not use /proc.
|
and does not use /proc.
|
||||||
|
|
||||||
Linux/elf386 is automatically selected for Linux ELF exectuables.
|
Linux/elf386 is automatically selected for Linux ELF executables.
|
||||||
|
|
||||||
Packed programs will be byte-identical to the original after uncompression.
|
Packed programs will be byte-identical to the original after uncompression.
|
||||||
|
|
||||||
@@ -640,7 +621,7 @@ How it works:
|
|||||||
UPX uses kernel execve(), which first requires decompressing to a
|
UPX uses kernel execve(), which first requires decompressing to a
|
||||||
temporary file in the file system. Interestingly -
|
temporary file in the file system. Interestingly -
|
||||||
because of the good memory management of the Linux kernel - this
|
because of the good memory management of the Linux kernel - this
|
||||||
often does not introduce a noticable delay, and in fact there
|
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
|
will be no disk access at all if you have enough free memory as
|
||||||
the entire process takes places within the file system buffers.
|
the entire process takes places within the file system buffers.
|
||||||
|
|
||||||
@@ -680,8 +661,8 @@ Specific drawbacks:
|
|||||||
|
|
||||||
- Because of temporary decompression to disk the decompression speed
|
- Because of temporary decompression to disk the decompression speed
|
||||||
is not as fast as with the other executable formats. Still, I can see
|
is not as fast as with the other executable formats. Still, I can see
|
||||||
no noticable delay when starting programs like my ~3 MB emacs (which
|
no noticeable delay when starting programs like my ~3 MiB emacs (which
|
||||||
is less than 1 MB when compressed :-).
|
is less than 1 MiB when compressed :-).
|
||||||
|
|
||||||
Extra options available for this executable format:
|
Extra options available for this executable format:
|
||||||
|
|
||||||
@@ -701,19 +682,23 @@ nostalgic feelings of one of the authors.
|
|||||||
Packed programs will be byte-identical to the original after uncompression,
|
Packed programs will be byte-identical to the original after uncompression,
|
||||||
until further notice.
|
until further notice.
|
||||||
|
|
||||||
Maximum uncompressed size: ~1998848 bytes.
|
Maximum uncompressed size: ~1.89 / ~7.60 MiB.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
- UPX creates as default a 'CD-Rom only' PS1/PS2 compatible executable.
|
- UPX creates as default a suitable executable for CD-Mastering
|
||||||
For transfer between client/target use options below.
|
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
|
- Normally the packed files use the same memory areas like the uncompressed
|
||||||
versions, so they will not override other memory areas while unpacking.
|
versions, so they will not override other memory areas while unpacking.
|
||||||
If this isn't possible UPX will abort showing a 'packed data overlap'
|
If this isn't possible UPX will abort showing a 'packed data overlap'
|
||||||
error. With the "--force" option UPX will set a few 'bytes higher' loading
|
error. With the "--force" option UPX will relocate the loading address
|
||||||
offset for the packed file, but this isn't a real problem if it is a
|
for the packed file, but this isn't a real problem if it is a single or
|
||||||
single or boot-only executable.
|
the main executable.
|
||||||
|
|
||||||
Extra options available for this executable format:
|
Extra options available for this executable format:
|
||||||
|
|
||||||
@@ -722,15 +707,19 @@ Extra options available for this executable format:
|
|||||||
the compression ratio in some cases, but usually
|
the compression ratio in some cases, but usually
|
||||||
the default method gives the best results anyway.
|
the default method gives the best results anyway.
|
||||||
|
|
||||||
--boot-only The format will only run from a CD and may slightly
|
--8-bit Uses 8 bit size compression [default: 32 bit]
|
||||||
improves the compression ratio. The decompression
|
|
||||||
routines are faster than default ones.
|
--8mib-ram PSone has 8 MiB ram available [default: 2 MiB]
|
||||||
But it cannot be used for host/client transfer !
|
|
||||||
|
--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
|
--no-align This option disables CD mode 2 data sector format
|
||||||
alignment. May slightly improves the compression ratio,
|
alignment. May slightly improves the compression ratio,
|
||||||
but the compressed executable will not boot from a CD.
|
but the compressed executable will not boot from a CD.
|
||||||
Use it for client/target transfer only !
|
Use it for console transfer only !
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -825,13 +814,13 @@ Extra options available for this executable format:
|
|||||||
=head2 NOTES FOR WIN32/PE
|
=head2 NOTES FOR WIN32/PE
|
||||||
|
|
||||||
The PE support in B<UPX> is quite stable now, but probably there are
|
The PE support in B<UPX> is quite stable now, but probably there are
|
||||||
still some incompabilities with some files.
|
still some incompatibilities with some files.
|
||||||
|
|
||||||
Because of the way B<UPX> (and other packers for this format) works, you
|
Because of the way B<UPX> (and other packers for this format) works, you
|
||||||
can see increased memory usage of your compressed files because the whole
|
can see increased memory usage of your compressed files because the whole
|
||||||
program is loaded into memory at startup.
|
program is loaded into memory at startup.
|
||||||
If you start several instances of huge compressed programs you're
|
If you start several instances of huge compressed programs you're
|
||||||
wasting memory because the common segements of the program won't
|
wasting memory because the common segments of the program won't
|
||||||
get shared across the instances.
|
get shared across the instances.
|
||||||
On the other hand if you're compressing only smaller programs, or
|
On the other hand if you're compressing only smaller programs, or
|
||||||
running only one instance of larger programs, then this penalty is
|
running only one instance of larger programs, then this penalty is
|
||||||
@@ -840,12 +829,19 @@ smaller, but it's still there.
|
|||||||
If you're running executables from network, then compressed programs
|
If you're running executables from network, then compressed programs
|
||||||
will load faster, and require less bandwidth during execution.
|
will load faster, and require less bandwidth during execution.
|
||||||
|
|
||||||
DLLs are supported.
|
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
|
Screensavers are supported, with the restriction that the filename
|
||||||
must end with ".scr" (as screensavers are handled slightly different
|
must end with ".scr" (as screensavers are handled slightly different
|
||||||
than normal exe files).
|
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:
|
Extra options available for this executable format:
|
||||||
|
|
||||||
--compress-exports=0 Don't compress the export section.
|
--compress-exports=0 Don't compress the export section.
|
||||||
@@ -862,9 +858,26 @@ Extra options available for this executable format:
|
|||||||
--compress-icons=1 Compress all but the first icon.
|
--compress-icons=1 Compress all but the first icon.
|
||||||
--compress-icons=2 Compress all icons which are not in the
|
--compress-icons=2 Compress all icons which are not in the
|
||||||
first icon directory. [DEFAULT]
|
first icon directory. [DEFAULT]
|
||||||
|
--compress-icons=3 Compress all icons.
|
||||||
|
|
||||||
--compress-resources=0 Don't compress any resources at all.
|
--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
|
--force Force compression even when there is an
|
||||||
unexpected value in a header field.
|
unexpected value in a header field.
|
||||||
Use with care.
|
Use with care.
|
||||||
@@ -911,7 +924,7 @@ Please report all bugs immediately to the authors.
|
|||||||
Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||||
http://www.oberhumer.com
|
http://www.oberhumer.com
|
||||||
|
|
||||||
Laszlo Molnar <ml1050@users.sourceforge.net>
|
Laszlo Molnar <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
John F. Reiser <jreiser@BitWagon.com>
|
John F. Reiser <jreiser@BitWagon.com>
|
||||||
|
|
||||||
@@ -921,13 +934,13 @@ Please report all bugs immediately to the authors.
|
|||||||
|
|
||||||
=head1 COPYRIGHT
|
=head1 COPYRIGHT
|
||||||
|
|
||||||
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
|
||||||
Copyright (C) 1996-2006 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
|
|
||||||
Copyright (C) 2000-2006 John F. Reiser
|
Copyright (C) 2000-2020 John F. Reiser
|
||||||
|
|
||||||
Copyright (C) 2002-2006 Jens Medoch
|
Copyright (C) 2002-2020 Jens Medoch
|
||||||
|
|
||||||
This program may be used freely, and you are welcome to
|
This program may be used freely, and you are welcome to
|
||||||
redistribute it under certain conditions.
|
redistribute it under certain conditions.
|
||||||
|
|||||||
-3220
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
|||||||
*.0??
|
|
||||||
*.d
|
|
||||||
*.dat
|
|
||||||
*.idb
|
|
||||||
*.img
|
|
||||||
*.map
|
|
||||||
*.raw
|
|
||||||
*.rc
|
|
||||||
*.rel
|
|
||||||
*.res
|
|
||||||
*.pdb
|
|
||||||
*.out
|
|
||||||
*.upx
|
|
||||||
.gdbinit
|
|
||||||
GNUmakefile
|
|
||||||
MMakefile
|
|
||||||
compress_nrv.*
|
|
||||||
upx
|
|
||||||
version1*.h
|
|
||||||
+153
-32
@@ -1,55 +1,176 @@
|
|||||||
#
|
#
|
||||||
# UPX Makefile - needs GNU make 3.80 or better
|
# UPX Makefile - needs GNU make 3.81 or better
|
||||||
|
#
|
||||||
|
# Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
#
|
#
|
||||||
|
|
||||||
MAKEFLAGS += -rR
|
# build configuration options for this Makefile
|
||||||
|
BUILD_TYPE_DEBUG ?= 0
|
||||||
|
BUILD_TYPE_SANITIZE ?= 0
|
||||||
|
BUILD_USE_DEPEND ?= 1
|
||||||
|
|
||||||
|
MAKEFLAGS += -r
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
export SHELL = /bin/sh
|
export SHELL = /bin/sh
|
||||||
override e = $($1) $(EXTRA_$1) $(upx_$1) $($(basename $(notdir $@)).$1)
|
override ee = $($1) $(EXTRA_$1) $(upx_$1) $(upx_EXTRA_$1) $($(basename $(notdir $@)).$1)
|
||||||
|
|
||||||
srcdir ?= $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
|
ifndef srcdir
|
||||||
ifneq ($(srcdir),./)
|
srcdir := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||||
srcdir := $(shell echo '$(srcdir)' | sed 's,/*$$,,')
|
srcdir := $(shell echo '$(srcdir)' | sed 's,/*$$,,' || echo 'ERROR')
|
||||||
##$(info Info: using VPATH . $(srcdir))
|
endif
|
||||||
VPATH := . $(srcdir)
|
ifndef top_srcdir
|
||||||
|
top_srcdir := $(srcdir)/..
|
||||||
|
endif
|
||||||
|
include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
|
||||||
|
ifneq ($(srcdir),.)
|
||||||
|
vpath %.cpp .:$(srcdir)
|
||||||
|
vpath %.h .:$(srcdir)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CXX),)
|
# toolchain
|
||||||
CXX = g++
|
CXX ?= g++
|
||||||
endif
|
CXXLD = $(CXX)
|
||||||
ifeq ($(CXX),g++)
|
|
||||||
CXXFLAGS += -O2 -MMD
|
|
||||||
CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wpointer-arith -Wwrite-strings -Werror
|
|
||||||
endif
|
|
||||||
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
|
|
||||||
CXXLD ?= $(CXX)
|
|
||||||
|
|
||||||
exeext ?= .out
|
exeext ?= .out
|
||||||
libext ?= .a
|
libext ?= .a
|
||||||
objext ?= .o
|
objext ?= .o
|
||||||
|
|
||||||
# we need UCL and zlib - you can set envvar UCLDIR
|
upx_SOURCES := $(sort $(wildcard $(srcdir)/*.cpp))
|
||||||
ifneq ($(wildcard $(UCLDIR)/include/ucl/ucl.h),)
|
|
||||||
INCLUDES += -I$(UCLDIR)/include
|
|
||||||
LIBS += $(addprefix -L,$(dir $(wildcard $(UCLDIR)/libucl$(libext) $(UCLDIR)/src/.libs/libucl$(libext))))
|
|
||||||
endif
|
|
||||||
LIBS += -lucl -lz
|
|
||||||
|
|
||||||
upx_SOURCES := $(wildcard $(srcdir)/*.cpp)
|
|
||||||
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
|
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
|
||||||
|
|
||||||
all: upx$(exeext)
|
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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
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)
|
upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
|
||||||
$($(notdir $@).PRE_LINK_STEP)
|
$($(notdir $@).PRE_LINK_STEP)
|
||||||
$(strip $(CXXLD) $(call e,CPPFLAGS) $(call e,CXXFLAGS) $(call e,LDFLAGS) -o $@ $(upx_OBJECTS) $(call e,LDADD) $(call e,LIBS))
|
$(strip $(CXXLD) $(call ee,CXXFLAGS) $(call ee,LDFLAGS) -o $@ $(upx_OBJECTS) $(call ee,LDADD) $(call ee,LIBS))
|
||||||
$($(notdir $@).POST_LINK_STEP)
|
$($(notdir $@).POST_LINK_STEP)
|
||||||
|
$(CHECK_WHITESPACE)
|
||||||
|
|
||||||
%.o : %.cpp
|
%.o : %.cpp | ./.depend
|
||||||
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<)
|
$(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:
|
mostlyclean clean distclean maintainer-clean:
|
||||||
rm -f *.d *.map *.o *.obj *.res upx.exe upx.out upx.ttp upx$(exeext)
|
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
|
||||||
|
|
||||||
-include *.d
|
|
||||||
.PHONY: all mostlyclean clean distclean maintainer-clean
|
.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
|
||||||
|
|
||||||
|
# "make run-testsuite"
|
||||||
|
# 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/.),)
|
||||||
|
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)/.github/travis_testsuite_1-expected_sha256sums.sh
|
||||||
|
# The actual (new) checksums are in tmp-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
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# automatically format some C++ source code files
|
||||||
|
ifeq ($(shell uname),Linux)
|
||||||
|
CLANG_FORMAT_FILES += linker.cpp linker.h packhead.cpp packmast.cpp packmast.h
|
||||||
|
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.cpp util.h work.cpp
|
||||||
|
clang-format:
|
||||||
|
$(top_srcdir)/src/stub/scripts/upx-clang-format -i $(addprefix $(top_srcdir)/src/,$(CLANG_FORMAT_FILES))
|
||||||
|
.PHONY: clang-format
|
||||||
|
endif
|
||||||
|
|
||||||
|
# vim:set ts=8 sw=8 noet:
|
||||||
|
|||||||
+222
-104
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2005 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2005 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_BELE_H
|
#ifndef __UPX_BELE_H
|
||||||
#define __UPX_BELE_H
|
#define __UPX_BELE_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -88,7 +88,7 @@ inline void set_be32(void *p, unsigned v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_uint64l_t get_be64(const void *p)
|
inline upx_uint64_t get_be64(const void *p)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_GET_BE64)
|
#if defined(ACC_UA_GET_BE64)
|
||||||
return ACC_UA_GET_BE64(p);
|
return ACC_UA_GET_BE64(p);
|
||||||
@@ -97,7 +97,7 @@ inline acc_uint64l_t get_be64(const void *p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set_be64(void *p, acc_uint64l_t v)
|
inline void set_be64(void *p, upx_uint64_t v)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_SET_BE64)
|
#if defined(ACC_UA_SET_BE64)
|
||||||
ACC_UA_SET_BE64(p, v);
|
ACC_UA_SET_BE64(p, v);
|
||||||
@@ -142,6 +142,22 @@ inline void set_le24(void *p, unsigned v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline unsigned get_le26(const void *p)
|
||||||
|
{
|
||||||
|
const acc_hbyte_p b = ACC_CCAST(const acc_hbyte_p, p);
|
||||||
|
return ACC_ICONV(acc_uint32l_t, b[0] ) | ( ACC_ICONV(acc_uint32l_t, b[1]) << 8) |
|
||||||
|
(ACC_ICONV(acc_uint32l_t, b[2]) << 16) | (((ACC_ICONV(acc_uint32l_t, b[3]) & 3)<< 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_le26(void *p, unsigned v)
|
||||||
|
{
|
||||||
|
acc_hbyte_p b = ACC_PCAST(acc_hbyte_p, p);
|
||||||
|
b[0] = ACC_ICONV(unsigned char, (v >> 0) & 0xff);
|
||||||
|
b[1] = ACC_ICONV(unsigned char, (v >> 8) & 0xff);
|
||||||
|
b[2] = ACC_ICONV(unsigned char, (v >> 16) & 0xff);
|
||||||
|
b[3] = ACC_ICONV(unsigned char, (v >> 24) & 0x03) | (0xFC & b[3]);
|
||||||
|
}
|
||||||
|
|
||||||
inline unsigned get_le32(const void *p)
|
inline unsigned get_le32(const void *p)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_GET_LE32)
|
#if defined(ACC_UA_GET_LE32)
|
||||||
@@ -160,7 +176,7 @@ inline void set_le32(void *p, unsigned v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_uint64l_t get_le64(const void *p)
|
inline upx_uint64_t get_le64(const void *p)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_GET_LE64)
|
#if defined(ACC_UA_GET_LE64)
|
||||||
return ACC_UA_GET_LE64(p);
|
return ACC_UA_GET_LE64(p);
|
||||||
@@ -169,7 +185,7 @@ inline acc_uint64l_t get_le64(const void *p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set_le64(void *p, acc_uint64l_t v)
|
inline void set_le64(void *p, upx_uint64_t v)
|
||||||
{
|
{
|
||||||
#if defined(ACC_UA_SET_LE64)
|
#if defined(ACC_UA_SET_LE64)
|
||||||
ACC_UA_SET_LE64(p, v);
|
ACC_UA_SET_LE64(p, v);
|
||||||
@@ -183,177 +199,240 @@ inline void set_le64(void *p, acc_uint64l_t v)
|
|||||||
// get signed values, i.e. sign-extend
|
// get signed values, i.e. sign-extend
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
inline int sign_extend(int v, int bits)
|
inline int sign_extend(unsigned v, unsigned bits)
|
||||||
{
|
{
|
||||||
const unsigned sign_bit = 1u << (bits - 1);
|
const unsigned sign_bit = 1u << (bits - 1);
|
||||||
v |= 0u - (v & sign_bit);
|
v &= sign_bit | (sign_bit - 1);
|
||||||
return v;
|
v |= 0 - (v & sign_bit);
|
||||||
|
return ACC_ICAST(int, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_int64l_t sign_extend(acc_int64l_t v, int bits)
|
inline upx_int64_t sign_extend(upx_uint64_t v, unsigned bits)
|
||||||
{
|
{
|
||||||
const acc_uint64l_t sign_bit = ACC_UINT64_C(1) << (bits - 1);
|
const upx_uint64_t sign_bit = UPX_UINT64_C(1) << (bits - 1);
|
||||||
v |= ACC_UINT64_C(0) - (v & sign_bit);
|
v &= sign_bit | (sign_bit - 1);
|
||||||
return v;
|
v |= 0 - (v & sign_bit);
|
||||||
|
return ACC_ICAST(upx_int64_t, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_be16_signed(const void *p)
|
inline int get_be16_signed(const void *p)
|
||||||
{
|
{
|
||||||
int v = get_be16(p);
|
unsigned v = get_be16(p);
|
||||||
return sign_extend(v, 16);
|
return sign_extend(v, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_be24_signed(const void *p)
|
inline int get_be24_signed(const void *p)
|
||||||
{
|
{
|
||||||
int v = get_be24(p);
|
unsigned v = get_be24(p);
|
||||||
return sign_extend(v, 24);
|
return sign_extend(v, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_be32_signed(const void *p)
|
inline int get_be32_signed(const void *p)
|
||||||
{
|
{
|
||||||
int v = get_be32(p);
|
unsigned v = get_be32(p);
|
||||||
return sign_extend(v, 32);
|
return sign_extend(v, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline acc_int64l_t get_be64_signed(const void *p)
|
inline upx_int64_t get_be64_signed(const void *p)
|
||||||
{
|
{
|
||||||
acc_int64l_t v = get_be64(p);
|
upx_uint64_t v = get_be64(p);
|
||||||
return sign_extend(v, 64);
|
return sign_extend(v, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_le16_signed(const void *p)
|
inline int get_le16_signed(const void *p)
|
||||||
{
|
{
|
||||||
int v = get_le16(p);
|
unsigned v = get_le16(p);
|
||||||
return sign_extend(v, 16);
|
return sign_extend(v, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_le24_signed(const void *p)
|
inline int get_le24_signed(const void *p)
|
||||||
{
|
{
|
||||||
int v = get_le24(p);
|
unsigned v = get_le24(p);
|
||||||
return sign_extend(v, 24);
|
return sign_extend(v, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_le32_signed(const void *p)
|
inline int get_le32_signed(const void *p)
|
||||||
{
|
{
|
||||||
int v = get_le32(p);
|
unsigned v = get_le32(p);
|
||||||
return sign_extend(v, 32);
|
return sign_extend(v, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_le64_signed(const void *p)
|
inline upx_int64_t get_le64_signed(const void *p)
|
||||||
{
|
{
|
||||||
acc_int64l_t v = get_le64(p);
|
upx_uint64_t v = get_le64(p);
|
||||||
return sign_extend(v, 64);
|
return sign_extend(v, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// swab (bswap)
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
inline unsigned acc_swab16(unsigned v)
|
||||||
|
{
|
||||||
|
return ((v & 0x00ff) << 8) |
|
||||||
|
((v & 0xff00) >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned acc_swab32(unsigned v)
|
||||||
|
{
|
||||||
|
return ((v & 0x000000ff) << 24) |
|
||||||
|
((v & 0x0000ff00) << 8) |
|
||||||
|
((v & 0x00ff0000) >> 8) |
|
||||||
|
((v & 0xff000000) >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline unsigned acc_swab16p(const upx_uint16_t *p)
|
||||||
|
{
|
||||||
|
return acc_swab16(*p);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned acc_swap32p(const upx_uint32_t *p)
|
||||||
|
{
|
||||||
|
return acc_swab32(*p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void acc_swab16s(upx_uint16_t *p)
|
||||||
|
{
|
||||||
|
*p = ACC_ICONV(upx_uint16_t, acc_swab16(*p));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void acc_swab32s(upx_uint32_t *p)
|
||||||
|
{
|
||||||
|
*p = ACC_ICONV(upx_uint32_t, acc_swab32(*p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void acc_ua_swab16s(void *p)
|
||||||
|
{
|
||||||
|
set_be16(p, get_le16(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void acc_ua_swab32s(void *p)
|
||||||
|
{
|
||||||
|
set_be32(p, get_le32(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// classes for portable unaligned access
|
// classes for portable unaligned access
|
||||||
//
|
//
|
||||||
// Important: these classes must be PODs (Plain Old Data), i.e. no
|
// Important: these classes must be PODs (Plain Old Data), i.e. no
|
||||||
// constructor, no destructor, no virtual functions and no default
|
// constructor, no destructor, no virtual functions and no default
|
||||||
// assignment operator, and all fields must be public(!).
|
// assignment operator, and all fields must be public(!).
|
||||||
|
//
|
||||||
|
// [Actually we _can_ use a safe non-POD subset, but for this we need
|
||||||
|
// to have gcc bug 17519 fixed - see http://gcc.gnu.org/PR17519 ]
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
struct BE16
|
__packed_struct(BE16)
|
||||||
{
|
|
||||||
unsigned char d[2];
|
unsigned char d[2];
|
||||||
|
|
||||||
BE16& operator = (unsigned v) { set_be16(d, v); return *this; }
|
BE16& operator = (unsigned v) { set_be16(d, v); return *this; }
|
||||||
BE16& operator += (unsigned v) { set_be16(d, get_be16(d) + v); return *this; }
|
BE16& operator += (unsigned v) { set_be16(d, get_be16(d) + v); return *this; }
|
||||||
BE16& operator -= (unsigned v) { set_be16(d, get_be16(d) - v); return *this; }
|
BE16& operator -= (unsigned v) { set_be16(d, get_be16(d) - v); return *this; }
|
||||||
BE16& operator *= (unsigned v) { set_be16(d, get_be16(d) * v); return *this; }
|
BE16& operator *= (unsigned v) { set_be16(d, get_be16(d) * v); return *this; }
|
||||||
|
BE16& operator /= (unsigned v) { set_be16(d, get_be16(d) / v); return *this; }
|
||||||
BE16& operator &= (unsigned v) { set_be16(d, get_be16(d) & v); return *this; }
|
BE16& operator &= (unsigned v) { set_be16(d, get_be16(d) & v); return *this; }
|
||||||
BE16& operator |= (unsigned v) { set_be16(d, get_be16(d) | v); return *this; }
|
BE16& operator |= (unsigned v) { set_be16(d, get_be16(d) | v); return *this; }
|
||||||
BE16& operator ^= (unsigned v) { set_be16(d, get_be16(d) ^ v); return *this; }
|
BE16& operator ^= (unsigned v) { set_be16(d, get_be16(d) ^ v); return *this; }
|
||||||
|
BE16& operator <<= (unsigned v) { set_be16(d, get_be16(d) << v); return *this; }
|
||||||
|
BE16& operator >>= (unsigned v) { set_be16(d, get_be16(d) >> v); return *this; }
|
||||||
|
|
||||||
operator unsigned () const { return get_be16(d); }
|
operator unsigned () const { return get_be16(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct BE32
|
__packed_struct(BE32)
|
||||||
{
|
|
||||||
unsigned char d[4];
|
unsigned char d[4];
|
||||||
|
|
||||||
BE32& operator = (unsigned v) { set_be32(d, v); return *this; }
|
BE32& operator = (unsigned v) { set_be32(d, v); return *this; }
|
||||||
BE32& operator += (unsigned v) { set_be32(d, get_be32(d) + v); return *this; }
|
BE32& operator += (unsigned v) { set_be32(d, get_be32(d) + v); return *this; }
|
||||||
BE32& operator -= (unsigned v) { set_be32(d, get_be32(d) - v); return *this; }
|
BE32& operator -= (unsigned v) { set_be32(d, get_be32(d) - v); return *this; }
|
||||||
BE32& operator *= (unsigned v) { set_be32(d, get_be32(d) * v); return *this; }
|
BE32& operator *= (unsigned v) { set_be32(d, get_be32(d) * v); return *this; }
|
||||||
|
BE32& operator /= (unsigned v) { set_be32(d, get_be32(d) / v); return *this; }
|
||||||
BE32& operator &= (unsigned v) { set_be32(d, get_be32(d) & v); return *this; }
|
BE32& operator &= (unsigned v) { set_be32(d, get_be32(d) & v); return *this; }
|
||||||
BE32& operator |= (unsigned v) { set_be32(d, get_be32(d) | v); return *this; }
|
BE32& operator |= (unsigned v) { set_be32(d, get_be32(d) | v); return *this; }
|
||||||
BE32& operator ^= (unsigned v) { set_be32(d, get_be32(d) ^ v); return *this; }
|
BE32& operator ^= (unsigned v) { set_be32(d, get_be32(d) ^ v); return *this; }
|
||||||
|
BE32& operator <<= (unsigned v) { set_be32(d, get_be32(d) << v); return *this; }
|
||||||
|
BE32& operator >>= (unsigned v) { set_be32(d, get_be32(d) >> v); return *this; }
|
||||||
|
|
||||||
operator unsigned () const { return get_be32(d); }
|
operator unsigned () const { return get_be32(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct BE64
|
__packed_struct(BE64)
|
||||||
{
|
|
||||||
unsigned char d[8];
|
unsigned char d[8];
|
||||||
|
|
||||||
BE64& operator = (acc_uint64l_t v) { set_be64(d, v); return *this; }
|
BE64& operator = (upx_uint64_t v) { set_be64(d, v); return *this; }
|
||||||
BE64& operator += (acc_uint64l_t v) { set_be64(d, get_be64(d) + v); return *this; }
|
BE64& operator += (upx_uint64_t v) { set_be64(d, get_be64(d) + v); return *this; }
|
||||||
BE64& operator -= (acc_uint64l_t v) { set_be64(d, get_be64(d) - v); return *this; }
|
BE64& operator -= (upx_uint64_t v) { set_be64(d, get_be64(d) - v); return *this; }
|
||||||
BE64& operator *= (acc_uint64l_t v) { set_be64(d, get_be64(d) * v); return *this; }
|
BE64& operator *= (upx_uint64_t v) { set_be64(d, get_be64(d) * v); return *this; }
|
||||||
BE64& operator &= (acc_uint64l_t v) { set_be64(d, get_be64(d) & v); return *this; }
|
BE64& operator /= (upx_uint64_t v) { set_be64(d, get_be64(d) / v); return *this; }
|
||||||
BE64& operator |= (acc_uint64l_t v) { set_be64(d, get_be64(d) | v); return *this; }
|
BE64& operator &= (upx_uint64_t v) { set_be64(d, get_be64(d) & v); return *this; }
|
||||||
BE64& operator ^= (acc_uint64l_t v) { set_be64(d, get_be64(d) ^ v); return *this; }
|
BE64& operator |= (upx_uint64_t v) { set_be64(d, get_be64(d) | v); return *this; }
|
||||||
|
BE64& operator ^= (upx_uint64_t v) { set_be64(d, get_be64(d) ^ v); return *this; }
|
||||||
|
BE64& operator <<= (unsigned v) { set_be64(d, get_be64(d) << v); return *this; }
|
||||||
|
BE64& operator >>= (unsigned v) { set_be64(d, get_be64(d) >> v); return *this; }
|
||||||
|
|
||||||
operator acc_uint64l_t () const { return get_be64(d); }
|
operator upx_uint64_t () const { return get_be64(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct LE16
|
__packed_struct(LE16)
|
||||||
{
|
|
||||||
unsigned char d[2];
|
unsigned char d[2];
|
||||||
|
|
||||||
LE16& operator = (unsigned v) { set_le16(d, v); return *this; }
|
LE16& operator = (unsigned v) { set_le16(d, v); return *this; }
|
||||||
LE16& operator += (unsigned v) { set_le16(d, get_le16(d) + v); return *this; }
|
LE16& operator += (unsigned v) { set_le16(d, get_le16(d) + v); return *this; }
|
||||||
LE16& operator -= (unsigned v) { set_le16(d, get_le16(d) - v); return *this; }
|
LE16& operator -= (unsigned v) { set_le16(d, get_le16(d) - v); return *this; }
|
||||||
LE16& operator *= (unsigned v) { set_le16(d, get_le16(d) * v); return *this; }
|
LE16& operator *= (unsigned v) { set_le16(d, get_le16(d) * v); return *this; }
|
||||||
|
LE16& operator /= (unsigned v) { set_le16(d, get_le16(d) / v); return *this; }
|
||||||
LE16& operator &= (unsigned v) { set_le16(d, get_le16(d) & v); return *this; }
|
LE16& operator &= (unsigned v) { set_le16(d, get_le16(d) & v); return *this; }
|
||||||
LE16& operator |= (unsigned v) { set_le16(d, get_le16(d) | v); return *this; }
|
LE16& operator |= (unsigned v) { set_le16(d, get_le16(d) | v); return *this; }
|
||||||
LE16& operator ^= (unsigned v) { set_le16(d, get_le16(d) ^ v); return *this; }
|
LE16& operator ^= (unsigned v) { set_le16(d, get_le16(d) ^ v); return *this; }
|
||||||
|
LE16& operator <<= (unsigned v) { set_le16(d, get_le16(d) << v); return *this; }
|
||||||
|
LE16& operator >>= (unsigned v) { set_le16(d, get_le16(d) >> v); return *this; }
|
||||||
|
|
||||||
operator unsigned () const { return get_le16(d); }
|
operator unsigned () const { return get_le16(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct LE32
|
__packed_struct(LE32)
|
||||||
{
|
|
||||||
unsigned char d[4];
|
unsigned char d[4];
|
||||||
|
|
||||||
LE32& operator = (unsigned v) { set_le32(d, v); return *this; }
|
LE32& operator = (unsigned v) { set_le32(d, v); return *this; }
|
||||||
LE32& operator += (unsigned v) { set_le32(d, get_le32(d) + v); return *this; }
|
LE32& operator += (unsigned v) { set_le32(d, get_le32(d) + v); return *this; }
|
||||||
LE32& operator -= (unsigned v) { set_le32(d, get_le32(d) - v); return *this; }
|
LE32& operator -= (unsigned v) { set_le32(d, get_le32(d) - v); return *this; }
|
||||||
LE32& operator *= (unsigned v) { set_le32(d, get_le32(d) * v); return *this; }
|
LE32& operator *= (unsigned v) { set_le32(d, get_le32(d) * v); return *this; }
|
||||||
|
LE32& operator /= (unsigned v) { set_le32(d, get_le32(d) / v); return *this; }
|
||||||
LE32& operator &= (unsigned v) { set_le32(d, get_le32(d) & v); return *this; }
|
LE32& operator &= (unsigned v) { set_le32(d, get_le32(d) & v); return *this; }
|
||||||
LE32& operator |= (unsigned v) { set_le32(d, get_le32(d) | v); return *this; }
|
LE32& operator |= (unsigned v) { set_le32(d, get_le32(d) | v); return *this; }
|
||||||
LE32& operator ^= (unsigned v) { set_le32(d, get_le32(d) ^ v); return *this; }
|
LE32& operator ^= (unsigned v) { set_le32(d, get_le32(d) ^ v); return *this; }
|
||||||
|
LE32& operator <<= (unsigned v) { set_le32(d, get_le32(d) << v); return *this; }
|
||||||
|
LE32& operator >>= (unsigned v) { set_le32(d, get_le32(d) >> v); return *this; }
|
||||||
|
|
||||||
operator unsigned () const { return get_le32(d); }
|
operator unsigned () const { return get_le32(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
struct LE64
|
__packed_struct(LE64)
|
||||||
{
|
|
||||||
unsigned char d[8];
|
unsigned char d[8];
|
||||||
|
|
||||||
LE64& operator = (acc_uint64l_t v) { set_le64(d, v); return *this; }
|
LE64& operator = (upx_uint64_t v) { set_le64(d, v); return *this; }
|
||||||
LE64& operator += (acc_uint64l_t v) { set_le64(d, get_le64(d) + v); return *this; }
|
LE64& operator += (upx_uint64_t v) { set_le64(d, get_le64(d) + v); return *this; }
|
||||||
LE64& operator -= (acc_uint64l_t v) { set_le64(d, get_le64(d) - v); return *this; }
|
LE64& operator -= (upx_uint64_t v) { set_le64(d, get_le64(d) - v); return *this; }
|
||||||
LE64& operator *= (acc_uint64l_t v) { set_le64(d, get_le64(d) * v); return *this; }
|
LE64& operator *= (upx_uint64_t v) { set_le64(d, get_le64(d) * v); return *this; }
|
||||||
LE64& operator &= (acc_uint64l_t v) { set_le64(d, get_le64(d) & v); return *this; }
|
LE64& operator /= (upx_uint64_t v) { set_le64(d, get_le64(d) / v); return *this; }
|
||||||
LE64& operator |= (acc_uint64l_t v) { set_le64(d, get_le64(d) | v); return *this; }
|
LE64& operator &= (upx_uint64_t v) { set_le64(d, get_le64(d) & v); return *this; }
|
||||||
LE64& operator ^= (acc_uint64l_t v) { set_le64(d, get_le64(d) ^ v); return *this; }
|
LE64& operator |= (upx_uint64_t v) { set_le64(d, get_le64(d) | v); return *this; }
|
||||||
|
LE64& operator ^= (upx_uint64_t v) { set_le64(d, get_le64(d) ^ v); return *this; }
|
||||||
|
LE64& operator <<= (unsigned v) { set_le64(d, get_le64(d) << v); return *this; }
|
||||||
|
LE64& operator >>= (unsigned v) { set_le64(d, get_le64(d) >> v); return *this; }
|
||||||
|
|
||||||
operator acc_uint64l_t () const { return get_le64(d); }
|
operator upx_uint64_t () const { return get_le64(d); }
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -399,11 +478,47 @@ template <class T> T* operator + (const LE64& v, T* ptr);
|
|||||||
template <class T> T* operator - (T* ptr, const LE64& v);
|
template <class T> T* operator - (T* ptr, const LE64& v);
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// global overloads
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
inline unsigned ALIGN_DOWN(unsigned a, const BE32& b) { return ALIGN_DOWN(a, (unsigned) b); }
|
||||||
|
inline unsigned ALIGN_DOWN(const BE32& a, unsigned b) { return ALIGN_DOWN((unsigned) a, b); }
|
||||||
|
inline unsigned ALIGN_UP (unsigned a, const BE32& b) { return ALIGN_UP (a, (unsigned) b); }
|
||||||
|
inline unsigned ALIGN_UP (const BE32& a, unsigned b) { return ALIGN_UP ((unsigned) a, b); }
|
||||||
|
|
||||||
|
inline unsigned ALIGN_DOWN(unsigned a, const LE32& b) { return ALIGN_DOWN(a, (unsigned) b); }
|
||||||
|
inline unsigned ALIGN_DOWN(const LE32& a, unsigned b) { return ALIGN_DOWN((unsigned) a, b); }
|
||||||
|
inline unsigned ALIGN_UP (unsigned a, const LE32& b) { return ALIGN_UP (a, (unsigned) b); }
|
||||||
|
inline unsigned ALIGN_UP (const LE32& a, unsigned b) { return ALIGN_UP ((unsigned) a, b); }
|
||||||
|
|
||||||
|
inline unsigned UPX_MAX(unsigned a, const BE16& b) { return UPX_MAX(a, (unsigned) b); }
|
||||||
|
inline unsigned UPX_MAX(const BE16& a, unsigned b) { return UPX_MAX((unsigned) a, b); }
|
||||||
|
inline unsigned UPX_MIN(unsigned a, const BE16& b) { return UPX_MIN(a, (unsigned) b); }
|
||||||
|
inline unsigned UPX_MIN(const BE16& a, unsigned b) { return UPX_MIN((unsigned) a, b); }
|
||||||
|
|
||||||
|
inline unsigned UPX_MAX(unsigned a, const BE32& b) { return UPX_MAX(a, (unsigned) b); }
|
||||||
|
inline unsigned UPX_MAX(const BE32& a, unsigned b) { return UPX_MAX((unsigned) a, b); }
|
||||||
|
inline unsigned UPX_MIN(unsigned a, const BE32& b) { return UPX_MIN(a, (unsigned) b); }
|
||||||
|
inline unsigned UPX_MIN(const BE32& a, unsigned b) { return UPX_MIN((unsigned) a, b); }
|
||||||
|
|
||||||
|
inline unsigned UPX_MAX(unsigned a, const LE16& b) { return UPX_MAX(a, (unsigned) b); }
|
||||||
|
inline unsigned UPX_MAX(const LE16& a, unsigned b) { return UPX_MAX((unsigned) a, b); }
|
||||||
|
inline unsigned UPX_MIN(unsigned a, const LE16& b) { return UPX_MIN(a, (unsigned) b); }
|
||||||
|
inline unsigned UPX_MIN(const LE16& a, unsigned b) { return UPX_MIN((unsigned) a, b); }
|
||||||
|
|
||||||
|
inline unsigned UPX_MAX(unsigned a, const LE32& b) { return UPX_MAX(a, (unsigned) b); }
|
||||||
|
inline unsigned UPX_MAX(const LE32& a, unsigned b) { return UPX_MAX((unsigned) a, b); }
|
||||||
|
inline unsigned UPX_MIN(unsigned a, const LE32& b) { return UPX_MIN(a, (unsigned) b); }
|
||||||
|
inline unsigned UPX_MIN(const LE32& a, unsigned b) { return UPX_MIN((unsigned) a, b); }
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// misc
|
// misc
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
// for use with qsort()
|
// for use with qsort()
|
||||||
|
extern "C" {
|
||||||
int __acc_cdecl_qsort be16_compare(const void *, const void *);
|
int __acc_cdecl_qsort be16_compare(const void *, const void *);
|
||||||
int __acc_cdecl_qsort be24_compare(const void *, const void *);
|
int __acc_cdecl_qsort be24_compare(const void *, const void *);
|
||||||
int __acc_cdecl_qsort be32_compare(const void *, const void *);
|
int __acc_cdecl_qsort be32_compare(const void *, const void *);
|
||||||
@@ -420,48 +535,51 @@ int __acc_cdecl_qsort le16_compare_signed(const void *, const void *);
|
|||||||
int __acc_cdecl_qsort le24_compare_signed(const void *, const void *);
|
int __acc_cdecl_qsort le24_compare_signed(const void *, const void *);
|
||||||
int __acc_cdecl_qsort le32_compare_signed(const void *, const void *);
|
int __acc_cdecl_qsort le32_compare_signed(const void *, const void *);
|
||||||
int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
||||||
|
} // extern "C"
|
||||||
|
|
||||||
|
|
||||||
// just for testing...
|
/*************************************************************************
|
||||||
#if !defined(ACC_CFG_NO_UNALIGNED)
|
// Provide namespaces and classes to abstract endianness policies.
|
||||||
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x030200)
|
//
|
||||||
typedef acc_uint16e_t LE16_unaligned __attribute__((__aligned__(1)));
|
// CTP - Compile-Time Polymorphism (templates)
|
||||||
typedef acc_uint32e_t LE32_unaligned __attribute__((__aligned__(1)));
|
// RTP - Run-Time Polymorphism (virtual functions)
|
||||||
# ifndef LE16
|
**************************************************************************/
|
||||||
# define LE16 LE16_unaligned
|
|
||||||
# endif
|
// forward declarations
|
||||||
# ifndef LE16
|
namespace N_BELE_CTP {
|
||||||
# define LE32 LE32_unaligned
|
struct BEPolicy;
|
||||||
# endif
|
struct LEPolicy;
|
||||||
#endif
|
extern const BEPolicy be_policy;
|
||||||
#if 0 && (ACC_ARCH_I386) && (ACC_CC_INTELC)
|
extern const LEPolicy le_policy;
|
||||||
typedef __declspec(align(1)) acc_uint16e_t LE16_unaligned;
|
}
|
||||||
typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned;
|
namespace N_BELE_RTP {
|
||||||
# ifndef LE16
|
struct AbstractPolicy;
|
||||||
# define LE16 LE16_unaligned
|
struct BEPolicy;
|
||||||
# endif
|
struct LEPolicy;
|
||||||
# ifndef LE16
|
extern const BEPolicy be_policy;
|
||||||
# define LE32 LE32_unaligned
|
extern const LEPolicy le_policy;
|
||||||
# endif
|
}
|
||||||
#endif
|
|
||||||
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_MSC) && (_MSC_VER >= 1200)
|
namespace N_BELE_CTP {
|
||||||
typedef __declspec(align(1)) acc_uint16e_t LE16_unaligned;
|
#define BELE_CTP 1
|
||||||
typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned;
|
#include "bele_policy.h"
|
||||||
# ifndef LE16
|
#undef BELE_CTP
|
||||||
# define LE16 LE16_unaligned
|
}
|
||||||
# endif
|
|
||||||
# ifndef LE16
|
namespace N_BELE_RTP {
|
||||||
# define LE32 LE32_unaligned
|
#define BELE_RTP 1
|
||||||
# endif
|
#include "bele_policy.h"
|
||||||
# pragma warning(disable: 4244) // Wx: conversion, possible loss of data
|
#undef BELE_RTP
|
||||||
#endif
|
}
|
||||||
#endif
|
|
||||||
|
namespace N_BELE_CTP {
|
||||||
|
inline const N_BELE_RTP::AbstractPolicy* getRTP(const BEPolicy*)
|
||||||
|
{ return &N_BELE_RTP::be_policy; }
|
||||||
|
inline const N_BELE_RTP::AbstractPolicy* getRTP(const LEPolicy*)
|
||||||
|
{ return &N_BELE_RTP::le_policy; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,279 @@
|
|||||||
|
/* bele_policy.h -- access memory in BigEndian and LittleEndian byte order
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2020 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_BELE_H
|
||||||
|
# error "this is an internal include file"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#if defined(BELE_CTP)
|
||||||
|
// CTP - Compile-Time Polymorphism (templates)
|
||||||
|
# define V static inline
|
||||||
|
# define S static int __acc_cdecl_qsort
|
||||||
|
# define C /*empty*/
|
||||||
|
#elif defined(BELE_RTP)
|
||||||
|
// RTP - Run-Time Polymorphism (virtual functions)
|
||||||
|
# define V virtual
|
||||||
|
# define S virtual int
|
||||||
|
# define C const
|
||||||
|
#else
|
||||||
|
# error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(BELE_RTP)
|
||||||
|
struct AbstractPolicy
|
||||||
|
{
|
||||||
|
inline AbstractPolicy() { }
|
||||||
|
virtual inline ~AbstractPolicy() { }
|
||||||
|
V bool isBE() C = 0;
|
||||||
|
V bool isLE() C = 0;
|
||||||
|
|
||||||
|
V unsigned get16(const void *p) C = 0;
|
||||||
|
V unsigned get24(const void *p) C = 0;
|
||||||
|
V unsigned get32(const void *p) C = 0;
|
||||||
|
V upx_uint64_t get64(const void *p) C = 0;
|
||||||
|
|
||||||
|
V void set16(void *p, unsigned v) C = 0;
|
||||||
|
V void set24(void *p, unsigned v) C = 0;
|
||||||
|
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;
|
||||||
|
|
||||||
|
S u16_compare(const void *a, const void *b) C = 0;
|
||||||
|
S u24_compare(const void *a, const void *b) C = 0;
|
||||||
|
S u32_compare(const void *a, const void *b) C = 0;
|
||||||
|
S u64_compare(const void *a, const void *b) C = 0;
|
||||||
|
|
||||||
|
S u16_compare_signed(const void *a, const void *b) C = 0;
|
||||||
|
S u24_compare_signed(const void *a, const void *b) C = 0;
|
||||||
|
S u32_compare_signed(const void *a, const void *b) C = 0;
|
||||||
|
S u64_compare_signed(const void *a, const void *b) C = 0;
|
||||||
|
|
||||||
|
// disable dynamic allocation
|
||||||
|
DISABLE_NEW_DELETE
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
struct BEPolicy
|
||||||
|
#if defined(BELE_RTP)
|
||||||
|
: public AbstractPolicy
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
inline BEPolicy() { }
|
||||||
|
#if defined(BELE_CTP)
|
||||||
|
typedef N_BELE_RTP::BEPolicy RTP_Policy;
|
||||||
|
#elif defined(BELE_RTP)
|
||||||
|
typedef N_BELE_CTP::BEPolicy CTP_Policy;
|
||||||
|
#endif
|
||||||
|
V bool isBE() C { return true; }
|
||||||
|
V bool isLE() C { return false; }
|
||||||
|
|
||||||
|
typedef BE16 U16;
|
||||||
|
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 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); }
|
||||||
|
|
||||||
|
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); }
|
||||||
|
|
||||||
|
static void compileTimeAssertions() {
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(U16)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(U32)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(U64)
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable dynamic allocation
|
||||||
|
DISABLE_NEW_DELETE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct LEPolicy
|
||||||
|
#if defined(BELE_RTP)
|
||||||
|
: public AbstractPolicy
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
inline LEPolicy() { }
|
||||||
|
#if defined(BELE_CTP)
|
||||||
|
typedef N_BELE_RTP::LEPolicy RTP_Policy;
|
||||||
|
#elif defined(BELE_RTP)
|
||||||
|
typedef N_BELE_CTP::LEPolicy CTP_Policy;
|
||||||
|
#endif
|
||||||
|
V bool isBE() C { return false; }
|
||||||
|
V bool isLE() C { return true; }
|
||||||
|
|
||||||
|
typedef LE16 U16;
|
||||||
|
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 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); }
|
||||||
|
|
||||||
|
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); }
|
||||||
|
|
||||||
|
static void compileTimeAssertions() {
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(U32) == 4)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(U64) == 8)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(U16)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(U32)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(U64)
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable dynamic allocation
|
||||||
|
DISABLE_NEW_DELETE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if (ACC_ABI_BIG_ENDIAN)
|
||||||
|
typedef BEPolicy HostPolicy;
|
||||||
|
#elif (ACC_ABI_LITTLE_ENDIAN)
|
||||||
|
typedef LEPolicy HostPolicy;
|
||||||
|
#else
|
||||||
|
# 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
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
+31
-40
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_BPTR_H
|
#ifndef __UPX_BPTR_H
|
||||||
#define __UPX_BPTR_H
|
#define __UPX_BPTR_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -37,70 +37,65 @@
|
|||||||
template <class T>
|
template <class T>
|
||||||
class BoundedPtr
|
class BoundedPtr
|
||||||
{
|
{
|
||||||
// typedef BoundedPtr<T> Self;
|
|
||||||
public:
|
public:
|
||||||
typedef T* StoredType;
|
//typedef T* StoredType;
|
||||||
typedef T* PointerType;
|
//typedef T* PointerType;
|
||||||
typedef T& ReferenceType;
|
//typedef T& ReferenceType;
|
||||||
|
|
||||||
~BoundedPtr() { }
|
~BoundedPtr() { }
|
||||||
|
|
||||||
explicit BoundedPtr(void* base, unsigned size, T* ptr=0)
|
explicit BoundedPtr(void* base, size_t size_in_bytes, T* ptr=0)
|
||||||
: ptr_(ptr), base_(base), size_(size) { check(); }
|
: 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) {
|
BoundedPtr& operator= (const BoundedPtr& other) {
|
||||||
assert(base_ == other.base_); assert(size_ == other.size_);
|
assert(base_ == other.base_);
|
||||||
|
assert(size_in_bytes_ == other.size_in_bytes_);
|
||||||
ptr_ = other.ptr_; check(); return *this;
|
ptr_ = other.ptr_; check(); return *this;
|
||||||
}
|
}
|
||||||
BoundedPtr& operator= (T* other) {
|
BoundedPtr& operator= (T* other) {
|
||||||
ptr_ = other; check(); return *this;
|
ptr_ = other; check(); return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator T* () { check(); return ptr_; }
|
operator T* () { return ptr_; }
|
||||||
operator const T* () const { check(); return ptr_; }
|
operator const T* () const { return ptr_; }
|
||||||
|
|
||||||
BoundedPtr& operator += (size_t n) {
|
BoundedPtr& operator += (size_t n) {
|
||||||
checkStrict(); ptr_ += n; checkStrict(); return *this;
|
checkNULL(); ptr_ += n; checkRange(); return *this;
|
||||||
}
|
}
|
||||||
BoundedPtr& operator -= (size_t n) {
|
BoundedPtr& operator -= (size_t n) {
|
||||||
checkStrict(); ptr_ -= n; checkStrict(); return *this;
|
checkNULL(); ptr_ -= n; checkRange(); return *this;
|
||||||
}
|
}
|
||||||
BoundedPtr& operator ++ (void) {
|
BoundedPtr& operator ++ (void) {
|
||||||
checkStrict(); ptr_ += 1; checkStrict(); return *this;
|
checkNULL(); ptr_ += 1; checkRange(); return *this;
|
||||||
}
|
}
|
||||||
// T* operator ++ (int) {
|
|
||||||
// T* p = ptr_; checkStrict(); ptr_ += 1; checkStrict(); return p;
|
|
||||||
// }
|
|
||||||
// BoundedPtr& operator -- (void) {
|
|
||||||
// checkStrict(); ptr_ -= 1; checkStrict(); return *this;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkNULL() const {
|
void checkNULL() const {
|
||||||
if (!ptr_)
|
if __acc_very_unlikely(!ptr_)
|
||||||
throwCantUnpack("unexpected NULL pointer; take care!");
|
throwCantUnpack("unexpected NULL pointer; take care!");
|
||||||
}
|
}
|
||||||
void checkRange(size_t extra=0) const {
|
void checkRange() const {
|
||||||
size_t off = (const char *) ptr_ - (const char *) base_;
|
size_t off = (const char *) ptr_ - (const char *) base_;
|
||||||
if (off > size_ || off + extra > size_)
|
if __acc_very_unlikely(off > size_in_bytes_)
|
||||||
throwCantUnpack("pointer out of range; take care!");
|
throwCantUnpack("pointer out of range; take care!");
|
||||||
}
|
}
|
||||||
void checkStrict(size_t extra=0) const {
|
void check() const { // check ptr_ invariant: either NULL or valid checkRange()
|
||||||
checkNULL();
|
if (ptr_ != NULL)
|
||||||
checkRange(extra);
|
checkRange();
|
||||||
}
|
|
||||||
void check(size_t extra=0) const {
|
|
||||||
if (ptr_) checkRange(extra);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
T* ptr_;
|
T* ptr_;
|
||||||
void* base_;
|
void* base_;
|
||||||
size_t size_;
|
size_t size_in_bytes_;
|
||||||
|
|
||||||
// disable copy
|
// disable copy
|
||||||
BoundedPtr(const BoundedPtr&); // {}
|
BoundedPtr(const BoundedPtr&); // {}
|
||||||
// BoundedPtr& operator= (const BoundedPtr&); // { return *this; }
|
|
||||||
|
|
||||||
// disable dynamic allocation
|
// disable dynamic allocation
|
||||||
DISABLE_NEW_DELETE
|
DISABLE_NEW_DELETE
|
||||||
};
|
};
|
||||||
@@ -108,8 +103,4 @@ private:
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+6
-10
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,13 +22,13 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
@@ -72,7 +72,7 @@ static void print0(FILE *f, const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static upx_bool intro(FILE *f)
|
static bool intro(FILE *f)
|
||||||
{
|
{
|
||||||
UNUSED(f);
|
UNUSED(f);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -89,8 +89,4 @@ console_t console_file =
|
|||||||
|
|
||||||
#endif /* USE_CONSOLE */
|
#endif /* USE_CONSOLE */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+9
-13
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
FILE *con_term = NULL;
|
FILE *con_term = NULL;
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
@@ -84,14 +84,14 @@ static int do_init(FILE *f)
|
|||||||
if (!acc_isatty(STDIN_FILENO) || !acc_isatty(STDOUT_FILENO) || !acc_isatty(STDERR_FILENO))
|
if (!acc_isatty(STDIN_FILENO) || !acc_isatty(STDOUT_FILENO) || !acc_isatty(STDERR_FILENO))
|
||||||
return con_mode;
|
return con_mode;
|
||||||
|
|
||||||
#if defined(USE_ANSI)
|
#if (USE_ANSI)
|
||||||
try_init(&console_ansi_mono,f);
|
try_init(&console_ansi_mono,f);
|
||||||
try_init(&console_ansi_color,f);
|
try_init(&console_ansi_color,f);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SCREEN)
|
#if (USE_SCREEN)
|
||||||
try_init(&console_screen,f);
|
try_init(&console_screen,f);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_AALIB)
|
#if (USE_AALIB)
|
||||||
try_init(&console_aalib,f);
|
try_init(&console_aalib,f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ static int set_fg(FILE *f, int fg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static upx_bool intro(FILE *f)
|
static bool intro(FILE *f)
|
||||||
{
|
{
|
||||||
if (con == me)
|
if (con == me)
|
||||||
init(f,-1,-1);
|
init(f,-1,-1);
|
||||||
@@ -159,8 +159,4 @@ void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
|
|||||||
|
|
||||||
#endif /* USE_CONSOLE */
|
#endif /* USE_CONSOLE */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+6
-10
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,13 +22,13 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
@@ -58,7 +58,7 @@ static void print0(FILE *f, const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static upx_bool intro(FILE *f)
|
static bool intro(FILE *f)
|
||||||
{
|
{
|
||||||
UNUSED(f);
|
UNUSED(f);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -75,8 +75,4 @@ console_t console_none =
|
|||||||
|
|
||||||
#endif /* USE_CONSOLE */
|
#endif /* USE_CONSOLE */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+11
-15
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,13 +22,13 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
#if defined(USE_SCREEN)
|
#if (USE_SCREEN)
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
@@ -126,19 +126,19 @@ static int init(FILE *f, int o, int now)
|
|||||||
else
|
else
|
||||||
return CON_INIT;
|
return CON_INIT;
|
||||||
|
|
||||||
#if defined(__DJGPP__)
|
#if (ACC_OS_DOS32) && defined(__DJGPP__)
|
||||||
if (!screen)
|
if (!screen)
|
||||||
screen = do_construct(screen_djgpp2_construct(),fd);
|
screen = do_construct(screen_djgpp2_construct(),fd);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SCREEN_WIN32)
|
#if (USE_SCREEN_WIN32)
|
||||||
if (!screen)
|
if (!screen)
|
||||||
screen = do_construct(screen_win32_construct(),fd);
|
screen = do_construct(screen_win32_construct(),fd);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SCREEN_VCSA)
|
#if (USE_SCREEN_VCSA)
|
||||||
if (!screen)
|
if (!screen)
|
||||||
screen = do_construct(screen_vcsa_construct(),fd);
|
screen = do_construct(screen_vcsa_construct(),fd);
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SCREEN_CURSES)
|
#if (USE_SCREEN_CURSES)
|
||||||
if (!screen && o == CON_SCREEN)
|
if (!screen && o == CON_SCREEN)
|
||||||
screen = do_construct(screen_curses_construct(),fd);
|
screen = do_construct(screen_curses_construct(),fd);
|
||||||
#endif
|
#endif
|
||||||
@@ -295,10 +295,10 @@ static void print0(FILE *f, const char *ss)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static upx_bool intro(FILE *f)
|
static bool intro(FILE *f)
|
||||||
{
|
{
|
||||||
UNUSED(f);
|
UNUSED(f);
|
||||||
#if defined(USE_FRAMES)
|
#if (USE_FRAMES)
|
||||||
if (screen->intro)
|
if (screen->intro)
|
||||||
return screen->intro(screen,screen_show_frames);
|
return screen->intro(screen,screen_show_frames);
|
||||||
#endif
|
#endif
|
||||||
@@ -317,8 +317,4 @@ console_t console_screen =
|
|||||||
|
|
||||||
#endif /* USE_SCREEN */
|
#endif /* USE_SCREEN */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
-278
@@ -1,278 +0,0 @@
|
|||||||
/* compress.ch --
|
|
||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
|
||||||
Copyright (C) 1996-2004 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
|
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#if 1 && defined(UCL_USE_ASM)
|
|
||||||
# include <ucl/ucl_asm.h>
|
|
||||||
# define ucl_nrv2b_decompress_safe_8 ucl_nrv2b_decompress_asm_safe_8
|
|
||||||
# define ucl_nrv2b_decompress_safe_le16 ucl_nrv2b_decompress_asm_safe_le16
|
|
||||||
# define ucl_nrv2b_decompress_safe_le32 ucl_nrv2b_decompress_asm_safe_le32
|
|
||||||
# define ucl_nrv2d_decompress_safe_8 ucl_nrv2d_decompress_asm_safe_8
|
|
||||||
# define ucl_nrv2d_decompress_safe_le16 ucl_nrv2d_decompress_asm_safe_le16
|
|
||||||
# define ucl_nrv2d_decompress_safe_le32 ucl_nrv2d_decompress_asm_safe_le32
|
|
||||||
# define ucl_nrv2e_decompress_safe_8 ucl_nrv2e_decompress_asm_safe_8
|
|
||||||
# define ucl_nrv2e_decompress_safe_le16 ucl_nrv2e_decompress_asm_safe_le16
|
|
||||||
# define ucl_nrv2e_decompress_safe_le32 ucl_nrv2e_decompress_asm_safe_le32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#if defined(upx_adler32)
|
|
||||||
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
|
|
||||||
{
|
|
||||||
if (len == 0)
|
|
||||||
return adler;
|
|
||||||
assert(buf != NULL);
|
|
||||||
return ucl_adler32(adler, (const ucl_bytep)buf, len);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(upx_crc32)
|
|
||||||
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
|
|
||||||
{
|
|
||||||
if (len == 0)
|
|
||||||
return crc;
|
|
||||||
assert(buf != NULL);
|
|
||||||
return ucl_crc32(crc, (const ucl_bytep)buf, len);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#if defined(upx_compress)
|
|
||||||
|
|
||||||
int upx_compress ( const upx_bytep src, upx_uint src_len,
|
|
||||||
upx_bytep dst, upx_uintp dst_len,
|
|
||||||
upx_progress_callback_t *cb,
|
|
||||||
int method, int level,
|
|
||||||
const struct upx_compress_config_t *conf_parm,
|
|
||||||
upx_uintp result )
|
|
||||||
{
|
|
||||||
struct upx_compress_config_t conf;
|
|
||||||
upx_uint result_buffer[16];
|
|
||||||
int r = UPX_E_ERROR;
|
|
||||||
|
|
||||||
assert(level > 0);
|
|
||||||
memset(&conf, 0xff, sizeof(conf));
|
|
||||||
if (conf_parm)
|
|
||||||
conf = *conf_parm; // struct copy
|
|
||||||
if (!result)
|
|
||||||
result = result_buffer;
|
|
||||||
|
|
||||||
// assume no info available - fill in worst case results
|
|
||||||
//result[0] = 1; // min_offset_found - NOT USED
|
|
||||||
result[1] = src_len - 1; // max_offset_found
|
|
||||||
//result[2] = 2; // min_match_found - NOT USED
|
|
||||||
result[3] = src_len - 1; // max_match_found
|
|
||||||
//result[4] = 1; // min_run_found - NOT USED
|
|
||||||
result[5] = src_len; // max_run_found
|
|
||||||
result[6] = 1; // first_offset_found
|
|
||||||
//result[7] = 999999; // same_match_offsets_found - NOT USED
|
|
||||||
|
|
||||||
// prepare bit-buffer settings
|
|
||||||
conf.bb_endian = 0;
|
|
||||||
conf.bb_size = 0;
|
|
||||||
if (method >= M_NRV2B_LE32 && method <= M_CL1B_LE16)
|
|
||||||
{
|
|
||||||
static const unsigned char sizes[3]={32,8,16};
|
|
||||||
conf.bb_size = sizes[(method - M_NRV2B_LE32) % 3];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throwInternalError("unknown compression method");
|
|
||||||
|
|
||||||
// optimize compression parms
|
|
||||||
if (level <= 3 && conf.max_offset == UPX_UINT_MAX)
|
|
||||||
conf.max_offset = 8*1024-1;
|
|
||||||
else if (level == 4 && conf.max_offset == UPX_UINT_MAX)
|
|
||||||
conf.max_offset = 32*1024-1;
|
|
||||||
|
|
||||||
if M_IS_NRV2B(method)
|
|
||||||
r = ucl_nrv2b_99_compress(src, src_len, dst, dst_len,
|
|
||||||
cb, level, &conf, result);
|
|
||||||
else if M_IS_NRV2D(method)
|
|
||||||
r = ucl_nrv2d_99_compress(src, src_len, dst, dst_len,
|
|
||||||
cb, level, &conf, result);
|
|
||||||
#if defined(ALG_NRV2E)
|
|
||||||
else if M_IS_NRV2E(method)
|
|
||||||
r = ucl_nrv2e_99_compress(src, src_len, dst, dst_len,
|
|
||||||
cb, level, &conf, result);
|
|
||||||
#endif
|
|
||||||
#if 0 /*{*/
|
|
||||||
else if M_IS_CL1B(method)
|
|
||||||
r = cl1b_compress(src, src_len, dst, dst_len,
|
|
||||||
cb, level, &conf, result);
|
|
||||||
#endif /*}*/
|
|
||||||
else
|
|
||||||
throwInternalError("unknown compression method");
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* upx_compress */
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#if defined(upx_decompress)
|
|
||||||
|
|
||||||
int upx_decompress ( const upx_bytep src, upx_uint src_len,
|
|
||||||
upx_bytep dst, upx_uintp dst_len,
|
|
||||||
int method )
|
|
||||||
{
|
|
||||||
int r = UPX_E_ERROR;
|
|
||||||
|
|
||||||
switch (method)
|
|
||||||
{
|
|
||||||
case M_NRV2B_8:
|
|
||||||
r = ucl_nrv2b_decompress_safe_8(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2B_LE16:
|
|
||||||
r = ucl_nrv2b_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2B_LE32:
|
|
||||||
r = ucl_nrv2b_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2D_8:
|
|
||||||
r = ucl_nrv2d_decompress_safe_8(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2D_LE16:
|
|
||||||
r = ucl_nrv2d_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2D_LE32:
|
|
||||||
r = ucl_nrv2d_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
#if defined(ALG_NRV2E)
|
|
||||||
case M_NRV2E_8:
|
|
||||||
r = ucl_nrv2e_decompress_safe_8(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2E_LE16:
|
|
||||||
r = ucl_nrv2e_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2E_LE32:
|
|
||||||
r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#if 0 /*{*/
|
|
||||||
case M_CL1B_8:
|
|
||||||
r = cl1b_decompress_safe_8(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_CL1B_LE16:
|
|
||||||
r = cl1b_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_CL1B_LE32:
|
|
||||||
r = cl1b_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
#endif /*}*/
|
|
||||||
default:
|
|
||||||
throwInternalError("unknown decompression method");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* upx_decompress */
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#if defined(upx_test_overlap)
|
|
||||||
|
|
||||||
int upx_test_overlap ( const upx_bytep buf, upx_uint src_off,
|
|
||||||
upx_uint src_len, upx_uintp dst_len,
|
|
||||||
int method )
|
|
||||||
{
|
|
||||||
int r = UPX_E_ERROR;
|
|
||||||
|
|
||||||
switch (method)
|
|
||||||
{
|
|
||||||
case M_NRV2B_8:
|
|
||||||
r = ucl_nrv2b_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2B_LE16:
|
|
||||||
r = ucl_nrv2b_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2B_LE32:
|
|
||||||
r = ucl_nrv2b_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2D_8:
|
|
||||||
r = ucl_nrv2d_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2D_LE16:
|
|
||||||
r = ucl_nrv2d_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2D_LE32:
|
|
||||||
r = ucl_nrv2d_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
#if defined(ALG_NRV2E)
|
|
||||||
case M_NRV2E_8:
|
|
||||||
r = ucl_nrv2e_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2E_LE16:
|
|
||||||
r = ucl_nrv2e_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_NRV2E_LE32:
|
|
||||||
r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#if 0 /*{*/
|
|
||||||
case M_CL1B_8:
|
|
||||||
r = cl1b_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_CL1B_LE16:
|
|
||||||
r = cl1b_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
case M_CL1B_LE32:
|
|
||||||
r = cl1b_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
|
|
||||||
break;
|
|
||||||
#endif /*}*/
|
|
||||||
default:
|
|
||||||
throwInternalError("unknown decompression method");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* upx_test_overlap */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
+185
-17
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,29 +22,197 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
#include "compress.h"
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(WITH_NRV)
|
/*************************************************************************
|
||||||
# include "compress_nrv.ch"
|
//
|
||||||
#elif defined(WITH_UCL)
|
**************************************************************************/
|
||||||
# define ALG_NRV2E
|
|
||||||
# define upx_adler32 upx_adler32
|
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
|
||||||
//# define upx_crc32 upx_crc32
|
{
|
||||||
# define upx_compress upx_compress
|
if (len == 0)
|
||||||
# define upx_decompress upx_decompress
|
return adler;
|
||||||
# define upx_test_overlap upx_test_overlap
|
assert(buf != NULL);
|
||||||
# include "compress.ch"
|
#if 1
|
||||||
|
return upx_ucl_adler32(buf, len, adler);
|
||||||
#else
|
#else
|
||||||
# error
|
return upx_zlib_adler32(buf, len, adler);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0 /* UNUSED */
|
||||||
|
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
|
||||||
|
{
|
||||||
|
if (len == 0)
|
||||||
|
return crc;
|
||||||
|
assert(buf != NULL);
|
||||||
|
#if 1
|
||||||
|
return upx_ucl_crc32(buf, len, crc);
|
||||||
|
#else
|
||||||
|
return upx_zlib_crc32(buf, len, crc);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#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 r = UPX_E_ERROR;
|
||||||
|
upx_compress_result_t cresult_buffer;
|
||||||
|
|
||||||
|
assert(method > 0); assert(level > 0);
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
// set available bytes in dst
|
||||||
|
if (*dst_len == 0)
|
||||||
|
*dst_len = MemBuffer::getSizeForCompression(src_len);
|
||||||
|
#else
|
||||||
|
// force users to provide *dst_len
|
||||||
|
assert(*dst_len != 0);
|
||||||
|
#endif
|
||||||
|
// for UPX, we always require a reasonably sized outbut buffer
|
||||||
|
assert(*dst_len >= MemBuffer::getSizeForCompression(src_len));
|
||||||
|
|
||||||
|
if (!cresult)
|
||||||
|
cresult = &cresult_buffer;
|
||||||
|
memset(cresult, 0, sizeof(*cresult));
|
||||||
|
#if 1
|
||||||
|
// debug
|
||||||
|
cresult->method = method;
|
||||||
|
cresult->level = level;
|
||||||
|
cresult->u_len = src_len;
|
||||||
|
cresult->c_len = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if __acc_cte(0) {
|
||||||
|
}
|
||||||
|
#if (WITH_LZMA)
|
||||||
|
else if (M_IS_LZMA(method))
|
||||||
|
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);
|
||||||
|
#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);
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
throwInternalError("unknown compression method");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
#if 1
|
||||||
vi:ts=4:et:nowrap
|
// debug
|
||||||
*/
|
cresult->c_len = *dst_len;
|
||||||
|
#endif
|
||||||
|
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 r = UPX_E_ERROR;
|
||||||
|
|
||||||
|
assert(*dst_len > 0);
|
||||||
|
assert(src_len < *dst_len); // must be compressed
|
||||||
|
|
||||||
|
if (cresult && cresult->method == 0)
|
||||||
|
cresult = NULL;
|
||||||
|
|
||||||
|
if __acc_cte(0) {
|
||||||
|
}
|
||||||
|
#if (WITH_LZMA)
|
||||||
|
else if (M_IS_LZMA(method))
|
||||||
|
r = upx_lzma_decompress(src, src_len, dst, dst_len, method, 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_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||||
|
#endif
|
||||||
|
#if (WITH_UCL)
|
||||||
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
|
r = upx_ucl_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||||
|
#endif
|
||||||
|
#if (WITH_ZLIB)
|
||||||
|
else if (M_IS_DEFLATE(method))
|
||||||
|
r = upx_zlib_decompress(src, src_len, dst, dst_len, method, cresult);
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
throwInternalError("unknown decompression method");
|
||||||
|
}
|
||||||
|
|
||||||
|
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 r = UPX_E_ERROR;
|
||||||
|
|
||||||
|
if (cresult && cresult->method == 0)
|
||||||
|
cresult = NULL;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if __acc_cte(0) {
|
||||||
|
}
|
||||||
|
#if (WITH_LZMA)
|
||||||
|
else if (M_IS_LZMA(method))
|
||||||
|
r = upx_lzma_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, 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_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||||
|
#endif
|
||||||
|
#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
|
||||||
|
else {
|
||||||
|
throwInternalError("unknown decompression method");
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
|
|||||||
+131
@@ -0,0 +1,131 @@
|
|||||||
|
/* compress.h --
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2020 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_COMPRESS_H
|
||||||
|
#define __UPX_COMPRESS_H 1
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#if (WITH_LZMA)
|
||||||
|
int upx_lzma_init(void);
|
||||||
|
const char *upx_lzma_version_string(void);
|
||||||
|
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,
|
||||||
|
upx_compress_result_t *cresult );
|
||||||
|
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 );
|
||||||
|
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 );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if (WITH_NRV)
|
||||||
|
int upx_nrv_init(void);
|
||||||
|
const char *upx_nrv_version_string(void);
|
||||||
|
int upx_nrv_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_nrv_decompress ( const upx_bytep src, unsigned src_len,
|
||||||
|
upx_bytep dst, unsigned* dst_len,
|
||||||
|
int method,
|
||||||
|
const upx_compress_result_t *cresult );
|
||||||
|
int upx_nrv_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_UCL)
|
||||||
|
int upx_ucl_init(void);
|
||||||
|
const char *upx_ucl_version_string(void);
|
||||||
|
int upx_ucl_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_ucl_decompress ( const upx_bytep src, unsigned src_len,
|
||||||
|
upx_bytep dst, unsigned* dst_len,
|
||||||
|
int method,
|
||||||
|
const upx_compress_result_t *cresult );
|
||||||
|
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 );
|
||||||
|
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);
|
||||||
|
int upx_zlib_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_zlib_decompress ( const upx_bytep src, unsigned src_len,
|
||||||
|
upx_bytep dst, unsigned* dst_len,
|
||||||
|
int method,
|
||||||
|
const upx_compress_result_t *cresult );
|
||||||
|
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 );
|
||||||
|
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 */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
@@ -0,0 +1,538 @@
|
|||||||
|
/* compress_lzma.cpp --
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2020 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_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
|
||||||
|
#if (ACC_CC_INTELC_GNUC)
|
||||||
|
# pragma warning(error: 424) // #424: extra ";" ignored
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void lzma_compress_config_t::reset()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
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 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 + (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: */
|
||||||
@@ -0,0 +1,320 @@
|
|||||||
|
/* compress_ucl.cpp --
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2020 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"
|
||||||
|
#if !(WITH_UCL)
|
||||||
|
extern int compress_ucl_dummy;
|
||||||
|
int compress_ucl_dummy = 0;
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if 1 && !(UCL_USE_ASM) && (ACC_ARCH_I386)
|
||||||
|
# if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_WATCOMC)
|
||||||
|
# define UCL_USE_ASM 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if (UCL_NO_ASM)
|
||||||
|
# undef UCL_USE_ASM
|
||||||
|
#endif
|
||||||
|
#if (ACC_CFG_NO_UNALIGNED)
|
||||||
|
# undef UCL_USE_ASM
|
||||||
|
#endif
|
||||||
|
#if 1 && (UCL_USE_ASM)
|
||||||
|
# include <ucl/ucl_asm.h>
|
||||||
|
# define ucl_nrv2b_decompress_safe_8 ucl_nrv2b_decompress_asm_safe_8
|
||||||
|
# define ucl_nrv2b_decompress_safe_le16 ucl_nrv2b_decompress_asm_safe_le16
|
||||||
|
# define ucl_nrv2b_decompress_safe_le32 ucl_nrv2b_decompress_asm_safe_le32
|
||||||
|
# define ucl_nrv2d_decompress_safe_8 ucl_nrv2d_decompress_asm_safe_8
|
||||||
|
# define ucl_nrv2d_decompress_safe_le16 ucl_nrv2d_decompress_asm_safe_le16
|
||||||
|
# define ucl_nrv2d_decompress_safe_le32 ucl_nrv2d_decompress_asm_safe_le32
|
||||||
|
# define ucl_nrv2e_decompress_safe_8 ucl_nrv2e_decompress_asm_safe_8
|
||||||
|
# define ucl_nrv2e_decompress_safe_le16 ucl_nrv2e_decompress_asm_safe_le16
|
||||||
|
# define ucl_nrv2e_decompress_safe_le32 ucl_nrv2e_decompress_asm_safe_le32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
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_NOT_YET_IMPLEMENTED: return UPX_E_NOT_YET_IMPLEMENTED;
|
||||||
|
case UCL_E_INVALID_ARGUMENT: return UPX_E_INVALID_ARGUMENT;
|
||||||
|
// UCL extra:
|
||||||
|
case UCL_E_OVERLAP_OVERRUN: return UPX_E_ERROR;
|
||||||
|
}
|
||||||
|
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 != NULL);
|
||||||
|
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(ucl_compress_config_t) == sizeof(REAL_ucl_compress_config_t))
|
||||||
|
|
||||||
|
ucl_progress_callback_t cb;
|
||||||
|
cb.callback = 0;
|
||||||
|
cb.user = NULL;
|
||||||
|
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)
|
||||||
|
memcpy(&cconf, &cconf_parm->conf_ucl, sizeof(cconf)); // cconf = cconf_parm->conf_ucl; // struct copy
|
||||||
|
|
||||||
|
ucl_uint *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 unsigned char 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 parms
|
||||||
|
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,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2B_LE16:
|
||||||
|
r = ucl_nrv2b_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2B_LE32:
|
||||||
|
r = ucl_nrv2b_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2D_8:
|
||||||
|
r = ucl_nrv2d_decompress_safe_8(src,src_len,dst,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2D_LE16:
|
||||||
|
r = ucl_nrv2d_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2D_LE32:
|
||||||
|
r = ucl_nrv2d_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2E_8:
|
||||||
|
r = ucl_nrv2e_decompress_safe_8(src,src_len,dst,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2E_LE16:
|
||||||
|
r = ucl_nrv2e_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2E_LE32:
|
||||||
|
r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
|
||||||
|
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,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2B_LE16:
|
||||||
|
r = ucl_nrv2b_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2B_LE32:
|
||||||
|
r = ucl_nrv2b_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2D_8:
|
||||||
|
r = ucl_nrv2d_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2D_LE16:
|
||||||
|
r = ucl_nrv2d_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2D_LE32:
|
||||||
|
r = ucl_nrv2d_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2E_8:
|
||||||
|
r = ucl_nrv2e_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2E_LE16:
|
||||||
|
r = ucl_nrv2e_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
|
||||||
|
break;
|
||||||
|
case M_NRV2E_LE32:
|
||||||
|
r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
|
||||||
|
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 calloc(1, n); }
|
||||||
|
static void __UCL_CDECL my_free(ucl_voidp p) { free(p); }
|
||||||
|
}
|
||||||
|
|
||||||
|
int upx_ucl_init(void)
|
||||||
|
{
|
||||||
|
if (ucl_init() != UCL_E_OK)
|
||||||
|
return -1;
|
||||||
|
#if defined(UPX_OFFICIAL_BUILD)
|
||||||
|
if (UCL_VERSION != ucl_version())
|
||||||
|
return -2;
|
||||||
|
#endif
|
||||||
|
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
|
||||||
|
|
||||||
|
#endif /* WITH_UCL */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
/* compress_zlib.cpp --
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2020 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"
|
||||||
|
|
||||||
|
|
||||||
|
void zlib_compress_config_t::reset()
|
||||||
|
{
|
||||||
|
mem_clear(this, sizeof(*this));
|
||||||
|
|
||||||
|
mem_level.reset();
|
||||||
|
window_bits.reset();
|
||||||
|
strategy.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !(WITH_ZLIB)
|
||||||
|
extern int compress_zlib_dummy;
|
||||||
|
int compress_zlib_dummy = 0;
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
static int convert_errno_from_zlib(int zr)
|
||||||
|
{
|
||||||
|
switch (zr)
|
||||||
|
{
|
||||||
|
case Z_OK: return UPX_E_OK;
|
||||||
|
case Z_DATA_ERROR: return UPX_E_ERROR;
|
||||||
|
case Z_NEED_DICT: return UPX_E_ERROR;
|
||||||
|
}
|
||||||
|
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 != NULL);
|
||||||
|
UNUSED(cb_parm);
|
||||||
|
int r = UPX_E_ERROR;
|
||||||
|
int zr;
|
||||||
|
const zlib_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_zlib : NULL;
|
||||||
|
zlib_compress_result_t *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) 0;
|
||||||
|
s.zfree = (free_func) 0;
|
||||||
|
s.next_in = ACC_UNCONST_CAST(upx_bytep, src);
|
||||||
|
s.avail_in = src_len;
|
||||||
|
s.next_out = dst;
|
||||||
|
s.avail_out = *dst_len;
|
||||||
|
s.total_in = s.total_out = 0;
|
||||||
|
|
||||||
|
zr = deflateInit2(&s, level, Z_DEFLATED, 0 - (int)window_bits,
|
||||||
|
mem_level, strategy);
|
||||||
|
if (zr != Z_OK)
|
||||||
|
goto error;
|
||||||
|
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) 0;
|
||||||
|
s.zfree = (free_func) 0;
|
||||||
|
s.next_in = ACC_UNCONST_CAST(upx_bytep, 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)
|
||||||
|
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(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_zlib_init(void)
|
||||||
|
{
|
||||||
|
#if defined(UPX_OFFICIAL_BUILD)
|
||||||
|
if (strcmp(ZLIB_VERSION, zlibVersion()) != 0)
|
||||||
|
return -2;
|
||||||
|
#endif
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* WITH_ZLIB */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
+437
-276
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,100 +22,88 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_CONF_H
|
#ifndef __UPX_CONF_H
|
||||||
#define __UPX_CONF_H
|
#define __UPX_CONF_H 1
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
#if !defined(_FILE_OFFSET_BITS)
|
||||||
|
# define _FILE_OFFSET_BITS 64
|
||||||
|
#endif
|
||||||
|
#undef NDEBUG
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// ACC
|
// ACC
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ACC_CFG_USE_NEW_STYLE_CASTS
|
||||||
|
#define ACC_CFG_USE_NEW_STYLE_CASTS 1
|
||||||
|
#endif
|
||||||
|
#define ACC_CFG_PREFER_TYPEOF_ACC_INT32E_T ACC_TYPEOF_INT
|
||||||
|
#define ACC_CFG_PREFER_TYPEOF_ACC_INT64E_T ACC_TYPEOF_LONG_LONG
|
||||||
#include "miniacc.h"
|
#include "miniacc.h"
|
||||||
#if ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MWERKS) && defined(__MSL__)
|
#if !(ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_MSC)
|
||||||
# undef HAVE_UTIME_H /* this pulls in <windows.h> */
|
// other compilers may work, but we're NOT interested into supporting them
|
||||||
|
# error "only clang and gcc are officially supported"
|
||||||
|
#endif
|
||||||
|
// UPX sanity checks for a sane compiler
|
||||||
|
#if !defined(UINT_MAX) || (UINT_MAX != 0xffffffffL)
|
||||||
|
# error "UINT_MAX"
|
||||||
|
#endif
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4)
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER((1u << 31) << 1 == 0)
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER(((int)(1u << 31)) >> 31 == -1) // arithmetic right shift
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255) // -funsigned-char
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char
|
||||||
|
|
||||||
|
#if (ACC_CC_MSC)
|
||||||
|
# pragma warning(error: 4127)
|
||||||
|
# pragma warning(error: 4146)
|
||||||
|
# pragma warning(error: 4319)
|
||||||
|
# pragma warning(error: 4805)
|
||||||
|
# pragma warning(disable: 4244) // -Wconversion
|
||||||
|
# pragma warning(disable: 4267) // -Wconversion
|
||||||
|
# pragma warning(disable: 4820) // padding added after data member
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// FIXME - quick hack for arm-wince-gcc-3.4 (Debian pocketpc-*.deb packages)
|
||||||
#if (ACC_CC_BORLANDC)
|
#if 1 && (ACC_ARCH_ARM) && defined(__pe__) && !defined(__CEGCC__) && !defined(_WIN32)
|
||||||
# if (__BORLANDC__ < 0x0500)
|
# undef HAVE_CHMOD
|
||||||
# error "need Borland C++ 5.0 or newer"
|
# undef HAVE_CHOWN
|
||||||
|
# undef HAVE_LSTAT
|
||||||
|
# undef HAVE_UTIME
|
||||||
#endif
|
#endif
|
||||||
# pragma warn -aus // 8004: 'x' is assigned a value that is never used
|
|
||||||
# pragma warn -inl // 8026+8027: Function not expanded inline
|
|
||||||
// Borland compilers typically produce a number of bogus warnings, and
|
|
||||||
// the actual diagnostics vary from version to version...
|
|
||||||
# if (__BORLANDC__ < 0x0530)
|
|
||||||
# pragma warn -csu // 8012: Comparing signed and unsigned values
|
|
||||||
# endif
|
|
||||||
# if (__BORLANDC__ >= 0x0530 && __BORLANDC__ < 0x0560)
|
|
||||||
# pragma warn -osh // 8055: Possible overflow in shift operation
|
|
||||||
# endif
|
|
||||||
# if (__BORLANDC__ >= 0x0560)
|
|
||||||
# pragma warn -use // 8080: 'x' is declared but never used
|
|
||||||
# endif
|
|
||||||
#elif (ACC_CC_DMC)
|
|
||||||
# if (__DMC__ < 0x829)
|
|
||||||
# error "need Digital Mars C++ 8.29 or newer"
|
|
||||||
# endif
|
|
||||||
#elif (ACC_CC_INTELC)
|
|
||||||
# if (__INTEL_COMPILER < 450)
|
|
||||||
# error "need Intel C++ 4.5 or newer"
|
|
||||||
# endif
|
|
||||||
# if (ACC_OS_WIN32 || ACC_OS_WIN64)
|
|
||||||
# elif defined(__linux__)
|
|
||||||
# pragma warning(error: 424) // #424: extra ";" ignored
|
|
||||||
# pragma warning(disable: 193) // #193: zero used for undefined preprocessing identifier
|
|
||||||
# pragma warning(disable: 810) // #810: conversion from "A" to "B" may lose significant bits
|
|
||||||
# pragma warning(disable: 981) // #981: operands are evaluated in unspecified order
|
|
||||||
# pragma warning(disable: 1418) // #1418: external definition with no prior declaration
|
|
||||||
# else
|
|
||||||
# error "untested platform"
|
|
||||||
# endif
|
|
||||||
#elif (ACC_CC_MSC)
|
|
||||||
# if (_MSC_VER < 1100)
|
|
||||||
# error "need Visual C++ 5.0 or newer"
|
|
||||||
# endif
|
|
||||||
# pragma warning(error: 4096) // W2: '__cdecl' must be used with '...'
|
|
||||||
# pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B'
|
|
||||||
# pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated
|
|
||||||
# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated
|
|
||||||
# pragma warning(disable: 4514) // W4: 'function': unreferenced inline function has been removed
|
|
||||||
# pragma warning(disable: 4710) // W4: 'function': function not inlined
|
|
||||||
# if (_MSC_VER >= 1300)
|
|
||||||
# pragma warning(disable: 4625) // W4: 'class' : copy constructor could not be generated because a base class copy constructor is inaccessible
|
|
||||||
# pragma warning(disable: 4626) // W4: 'class' : assignment operator could not be generated because a base class assignment operator is inaccessible
|
|
||||||
# pragma warning(disable: 4711) // W4: 'function' selected for automatic inline expansion
|
|
||||||
# pragma warning(disable: 4820) // W4: 'struct' : 'x' bytes padding added after member 'member'
|
|
||||||
# endif
|
|
||||||
# if (_MSC_VER >= 1400)
|
|
||||||
# pragma warning(disable: 4996) // W1: 'function': was declared deprecated
|
|
||||||
# endif
|
|
||||||
#elif (ACC_CC_WATCOMC)
|
|
||||||
# if (__WATCOMC__ < 1100)
|
|
||||||
# error "need Watcom C++ 11.0c or newer"
|
|
||||||
# endif
|
|
||||||
# if defined(__cplusplus)
|
|
||||||
# pragma warning 656 9 // w5: define this function inside its class definition (may improve code quality)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define ACC_WANT_ACC_INCD_H 1
|
#define ACC_WANT_ACC_INCD_H 1
|
||||||
#define ACC_WANT_ACC_INCE_H 1
|
#define ACC_WANT_ACC_INCE_H 1
|
||||||
#define ACC_WANT_ACC_LIB_H 1
|
#define ACC_WANT_ACC_LIB_H 1
|
||||||
#define ACC_WANT_ACC_CXX_H 1
|
#define ACC_WANT_ACC_CXX_H 1
|
||||||
#include "miniacc.h"
|
#include "miniacc.h"
|
||||||
#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
|
||||||
# if defined(INVALID_HANDLE_VALUE) || defined(MAKEWORD) || defined(RT_CURSOR)
|
/* intergral types */
|
||||||
# error "something pulled in <windows.h>"
|
typedef acc_int8_t upx_int8_t;
|
||||||
# endif
|
typedef acc_uint8_t upx_uint8_t;
|
||||||
#endif
|
typedef acc_int16_t upx_int16_t;
|
||||||
|
typedef acc_uint16_t upx_uint16_t;
|
||||||
|
typedef acc_int32_t upx_int32_t;
|
||||||
|
typedef acc_uint32_t upx_uint32_t;
|
||||||
|
typedef acc_int64_t upx_int64_t;
|
||||||
|
typedef acc_uint64_t upx_uint64_t;
|
||||||
|
typedef acc_uintptr_t upx_uintptr_t;
|
||||||
|
#define UPX_INT16_C ACC_INT16_C
|
||||||
|
#define UPX_UINT16_C ACC_UINT16_C
|
||||||
|
#define UPX_INT32_C ACC_INT32_C
|
||||||
|
#define UPX_UINT32_C ACC_UINT32_C
|
||||||
|
#define UPX_INT64_C ACC_INT64_C
|
||||||
|
#define UPX_UINT64_C ACC_UINT64_C
|
||||||
|
|
||||||
|
typedef unsigned char upx_byte;
|
||||||
|
#define upx_bytep upx_byte *
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -127,101 +115,59 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// just in case
|
// just in case
|
||||||
#undef NDEBUG
|
#undef _
|
||||||
|
#undef __
|
||||||
|
#undef ___
|
||||||
#undef dos
|
#undef dos
|
||||||
#undef linux
|
#undef linux
|
||||||
#undef small
|
#undef small
|
||||||
#undef tos
|
#undef tos
|
||||||
#if defined(ACC_CC_DMC)
|
|
||||||
# undef tell
|
|
||||||
#endif
|
|
||||||
#if !defined(ACC_CC_PGI)
|
|
||||||
#undef unix
|
#undef unix
|
||||||
#endif
|
#if (ACC_OS_DOS32) && defined(__DJGPP__)
|
||||||
#if defined(__DJGPP__)
|
|
||||||
# undef sopen
|
# undef sopen
|
||||||
# undef __unix__
|
# undef __unix__
|
||||||
# undef __unix
|
# undef __unix
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define WITH_LZMA 0x443
|
||||||
#if !defined(WITH_UCL)
|
|
||||||
#define WITH_UCL 1
|
#define WITH_UCL 1
|
||||||
#endif
|
#define WITH_ZLIB 1
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
|
# define ucl_compress_config_t REAL_ucl_compress_config_t
|
||||||
# include <ucl/uclconf.h>
|
# include <ucl/uclconf.h>
|
||||||
# include <ucl/ucl.h>
|
# include <ucl/ucl.h>
|
||||||
# if !defined(UCL_VERSION) || (UCL_VERSION < 0x010200L)
|
# if !defined(UCL_VERSION) || (UCL_VERSION < 0x010300L)
|
||||||
# error "please upgrade your UCL installation"
|
# error "please upgrade your UCL installation"
|
||||||
# endif
|
# endif
|
||||||
# if !defined(UPX_UINT_MAX)
|
# undef ucl_compress_config_t
|
||||||
# define UPX_UINT_MAX UCL_UINT_MAX
|
# undef ucl_compress_config_p
|
||||||
# define upx_uint ucl_uint
|
|
||||||
# define upx_voidp ucl_voidp
|
|
||||||
# define upx_uintp ucl_uintp
|
|
||||||
# define upx_byte ucl_byte
|
|
||||||
# define upx_bytep ucl_bytep
|
|
||||||
# define upx_bool ucl_bool
|
|
||||||
# define upx_compress_config_t ucl_compress_config_t
|
|
||||||
# define upx_progress_callback_t ucl_progress_callback_t
|
|
||||||
# define UPX_E_OK UCL_E_OK
|
|
||||||
# define UPX_E_ERROR UCL_E_ERROR
|
|
||||||
# define UPX_E_OUT_OF_MEMORY UCL_E_OUT_OF_MEMORY
|
|
||||||
# define __UPX_CDECL __UCL_CDECL
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if defined(WITH_NRV)
|
|
||||||
# include <nrv/nrvconf.h>
|
|
||||||
#endif
|
|
||||||
#if !defined(__UPX_CHECKER)
|
|
||||||
# if defined(__UCL_CHECKER) || defined(__NRV_CHECKER)
|
|
||||||
# define __UPX_CHECKER
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(UINT_MAX) || (UINT_MAX < 0xffffffffL)
|
|
||||||
# error "UINT_MAX"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
// system includes
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
// malloc debuggers
|
// malloc debuggers
|
||||||
#if defined(WITH_VALGRIND)
|
#if (WITH_VALGRIND)
|
||||||
# include <valgrind/memcheck.h>
|
# include <valgrind/memcheck.h>
|
||||||
#elif defined(WITH_DMALLOC)
|
#endif
|
||||||
# define DMALLOC_FUNC_CHECK
|
#if !defined(VALGRIND_MAKE_MEM_DEFINED)
|
||||||
# include <dmalloc.h>
|
# define VALGRIND_MAKE_MEM_DEFINED(addr,len) 0
|
||||||
#elif defined(WITH_GC)
|
#endif
|
||||||
# define GC_DEBUG
|
#if !defined(VALGRIND_MAKE_MEM_NOACCESS)
|
||||||
# include <gc/gc.h>
|
# define VALGRIND_MAKE_MEM_NOACCESS(addr,len) 0
|
||||||
# undef malloc
|
#endif
|
||||||
# undef realloc
|
#if !defined(VALGRIND_MAKE_MEM_UNDEFINED)
|
||||||
# undef free
|
# define VALGRIND_MAKE_MEM_UNDEFINED(addr,len) 0
|
||||||
# define malloc GC_MALLOC
|
|
||||||
# define realloc GC_REALLOC
|
|
||||||
# define free GC_FREE
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(VALGRIND_MAKE_WRITABLE)
|
// IMPORTANT: unconditionally enable assertions
|
||||||
# define VALGRIND_MAKE_WRITABLE(addr,len) 0
|
|
||||||
#endif
|
|
||||||
#if !defined(VALGRIND_MAKE_READABLE)
|
|
||||||
# if 0
|
|
||||||
# define VALGRIND_MAKE_READABLE(addr,len) (memset(addr,0,len), 0)
|
|
||||||
# else
|
|
||||||
# define VALGRIND_MAKE_READABLE(addr,len) 0
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(VALGRIND_DISCARD)
|
|
||||||
# define VALGRIND_DISCARD(handle) ((void)(&handle))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#undef NDEBUG
|
#undef NDEBUG
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
// protect against integer overflows and malicious header fields
|
||||||
|
// see C 11 standard, Annex K
|
||||||
|
typedef size_t upx_rsize_t;
|
||||||
|
#define UPX_RSIZE_MAX UPX_RSIZE_MAX_MEM
|
||||||
|
#define UPX_RSIZE_MAX_MEM (768 * 1024 * 1024) // DO NOT CHANGE
|
||||||
|
#define UPX_RSIZE_MAX_STR (1024 * 1024)
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// portab
|
// portab
|
||||||
@@ -237,15 +183,13 @@
|
|||||||
# define STDERR_FILENO (fileno(stderr))
|
# define STDERR_FILENO (fileno(stderr))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !(HAVE_STRCASECMP) && (HAVE_STRICMP)
|
||||||
#if !defined(HAVE_STRCASECMP) && defined(HAVE_STRICMP)
|
|
||||||
# define strcasecmp stricmp
|
# define strcasecmp stricmp
|
||||||
#endif
|
#endif
|
||||||
#if !defined(HAVE_STRNCASECMP) && defined(HAVE_STRNICMP)
|
#if !(HAVE_STRNCASECMP) && (HAVE_STRNICMP)
|
||||||
# define strncasecmp strnicmp
|
# define strncasecmp strnicmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(S_IWUSR) && defined(_S_IWUSR)
|
#if !defined(S_IWUSR) && defined(_S_IWUSR)
|
||||||
# define S_IWUSR _S_IWUSR
|
# define S_IWUSR _S_IWUSR
|
||||||
#elif !defined(S_IWUSR) && defined(_S_IWRITE)
|
#elif !defined(S_IWUSR) && defined(_S_IWRITE)
|
||||||
@@ -285,25 +229,22 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// avoid warnings about shadowing global functions
|
// avoid warnings about shadowing global functions
|
||||||
|
#undef basename
|
||||||
#undef index
|
#undef index
|
||||||
|
#undef outp
|
||||||
#define basename upx_basename
|
#define basename upx_basename
|
||||||
#define index upx_index
|
#define index upx_index
|
||||||
#define outp upx_outp
|
#define outp upx_outp
|
||||||
|
|
||||||
|
#undef PAGE_MASK
|
||||||
|
#undef PAGE_SIZE
|
||||||
|
|
||||||
#undef __attribute_packed
|
#if !defined(O_BINARY) || (O_BINARY+0 == 0)
|
||||||
#if (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE)
|
# if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||||
# if (1 && (ACC_ARCH_I386))
|
# error "missing O_BINARY"
|
||||||
# define __attribute_packed
|
|
||||||
# else
|
|
||||||
# define __attribute_packed __attribute__((__packed__,__aligned__(1)))
|
|
||||||
# endif
|
# endif
|
||||||
#else
|
|
||||||
# define __attribute_packed
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(O_BINARY)
|
#if !defined(O_BINARY)
|
||||||
# define O_BINARY 0
|
# define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
@@ -317,83 +258,67 @@
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
#if (ACC_CC_MSC)
|
||||||
|
#define __packed_struct(s) struct s {
|
||||||
|
#define __packed_struct_end() };
|
||||||
|
#else
|
||||||
|
#define __packed_struct(s) __acc_struct_packed(s)
|
||||||
|
#define __packed_struct_end() __acc_struct_packed_end()
|
||||||
|
#endif
|
||||||
|
|
||||||
#define UNUSED(var) ACC_UNUSED(var)
|
#define UNUSED(var) ACC_UNUSED(var)
|
||||||
#define COMPILE_TIME_ASSERT(e) ACC_COMPILE_TIME_ASSERT(e)
|
#define COMPILE_TIME_ASSERT(e) ACC_COMPILE_TIME_ASSERT(e)
|
||||||
|
|
||||||
#if 1
|
|
||||||
#define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \
|
#define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \
|
||||||
typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \
|
typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \
|
||||||
struct acc_tmp_t { acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z[7]; } __attribute_packed; \
|
__packed_struct(acc_tmp_t) acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z; __packed_struct_end() \
|
||||||
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 8*sizeof(b)+sizeof(a)) \
|
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 2*sizeof(b)+sizeof(a)) \
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(((acc_tmp_t*)0)->x)+sizeof(((acc_tmp_t*)0)->y)+sizeof(((acc_tmp_t*)0)->z) == 2*sizeof(b)+sizeof(a)) \
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \
|
|
||||||
struct acc_tmp_t { b x; a y; b z[7]; } __attribute_packed; \
|
|
||||||
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 8*sizeof(b)+sizeof(a)) \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__acc_alignof)
|
#if defined(__acc_alignof)
|
||||||
# define COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
|
# define __COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
|
||||||
__COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) \
|
__COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) \
|
||||||
COMPILE_TIME_ASSERT(__acc_alignof(a) == sizeof(b))
|
COMPILE_TIME_ASSERT(__acc_alignof(a) == sizeof(b))
|
||||||
#else
|
#else
|
||||||
# define COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
|
# define __COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
|
||||||
__COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b)
|
__COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b)
|
||||||
#endif
|
#endif
|
||||||
|
#define COMPILE_TIME_ASSERT_ALIGNED1(a) __COMPILE_TIME_ASSERT_ALIGNOF(a,char)
|
||||||
|
|
||||||
#define TABLESIZE(table) ((sizeof(table)/sizeof((table)[0])))
|
#define TABLESIZE(table) ((sizeof(table)/sizeof((table)[0])))
|
||||||
|
|
||||||
#define ALIGN_DOWN(a,b) (((a) / (b)) * (b))
|
|
||||||
#define ALIGN_UP(a,b) ALIGN_DOWN((a) + ((b) - 1), b)
|
|
||||||
#define ALIGN_GAP(a,b) (ALIGN_UP(a,b) - (a))
|
|
||||||
|
|
||||||
#define UPX_MAX(a,b) ((a) >= (b) ? (a) : (b))
|
template <class T>
|
||||||
#define UPX_MIN(a,b) ((a) <= (b) ? (a) : (b))
|
inline T ALIGN_DOWN(const T& a, const T& b) { T r; r = (a / b) * b; return r; }
|
||||||
#define UPX_MAX3(a,b,c) ((a) >= (b) ? UPX_MAX(a,c) : UPX_MAX(b,c))
|
template <class T>
|
||||||
#define UPX_MIN3(a,b,c) ((a) <= (b) ? UPX_MIN(a,c) : UPX_MIN(b,c))
|
inline T ALIGN_UP (const T& a, const T& b) { T r; r = ((a + b - 1) / b) * b; return r; }
|
||||||
|
template <class T>
|
||||||
|
inline T ALIGN_GAP (const T& a, const T& b) { T r; r = ALIGN_UP(a, b) - a; return r; }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
#if 0 && defined(__cplusplus) && !defined(new) && !defined(delete)
|
inline const T& UPX_MAX(const T& a, const T& b) { if (a < b) return b; return a; }
|
||||||
// global operators - debug
|
template <class T>
|
||||||
inline void *operator new(size_t l)
|
inline const T& UPX_MIN(const T& a, const T& b) { if (a < b) return a; return b; }
|
||||||
{
|
|
||||||
void *p = malloc(l);
|
|
||||||
printf("new %6ld %p\n",(long)l,p);
|
|
||||||
fflush(stdout);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
inline void *operator new[](size_t l)
|
|
||||||
{
|
|
||||||
void *p = malloc(l);
|
|
||||||
printf("new[] %6ld %p\n",(long)l,p);
|
|
||||||
fflush(stdout);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
inline void operator delete(void *p)
|
|
||||||
{
|
|
||||||
printf("delete %p\n",p);
|
|
||||||
fflush(stdout);
|
|
||||||
if (p) free(p);
|
|
||||||
}
|
|
||||||
inline void operator delete[](void *p)
|
|
||||||
{
|
|
||||||
printf("delete[] %p\n",p);
|
|
||||||
fflush(stdout);
|
|
||||||
if (p) free(p);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// An Array allocates memory on the heap, but automatically
|
// An Array allocates memory on the heap, but automatically
|
||||||
// gets destructed when leaving scope or on exceptions.
|
// gets destructed when leaving scope or on exceptions.
|
||||||
#define Array(type, var, size) \
|
#define Array(type, var, size) \
|
||||||
assert((int)(size) > 0); \
|
MemBuffer var ## _membuf(mem_size(sizeof(type), size)); \
|
||||||
MemBuffer var ## _membuf((size)*(sizeof(type))); \
|
type * const var = ACC_STATIC_CAST(type *, var ## _membuf.getVoidPtr())
|
||||||
type * const var = ((type *) var ## _membuf.getVoidPtr())
|
|
||||||
|
|
||||||
#define ByteArray(var, size) Array(unsigned char, var, size)
|
#define ByteArray(var, size) Array(unsigned char, var, size)
|
||||||
|
|
||||||
|
class noncopyable
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
inline noncopyable() {}
|
||||||
|
inline ~noncopyable() {}
|
||||||
|
private:
|
||||||
|
noncopyable(const noncopyable &); // undefined
|
||||||
|
const noncopyable& operator=(const noncopyable &); // undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// constants
|
// constants
|
||||||
@@ -413,6 +338,97 @@ inline void operator delete[](void *p)
|
|||||||
#define EXIT_INTERNAL 1
|
#define EXIT_INTERNAL 1
|
||||||
|
|
||||||
|
|
||||||
|
// magic constants for patching
|
||||||
|
#define UPX_MAGIC_LE32 0x21585055 /* "UPX!" */
|
||||||
|
#define UPX_MAGIC2_LE32 0xD5D0D8A1
|
||||||
|
|
||||||
|
|
||||||
|
// upx_compress() error codes
|
||||||
|
#define UPX_E_OK (0)
|
||||||
|
#define UPX_E_ERROR (-1)
|
||||||
|
#define UPX_E_OUT_OF_MEMORY (-2)
|
||||||
|
#define UPX_E_NOT_COMPRESSIBLE (-3)
|
||||||
|
#define UPX_E_INPUT_OVERRUN (-4)
|
||||||
|
#define UPX_E_OUTPUT_OVERRUN (-5)
|
||||||
|
#define UPX_E_LOOKBEHIND_OVERRUN (-6)
|
||||||
|
#define UPX_E_EOF_NOT_FOUND (-7)
|
||||||
|
#define UPX_E_INPUT_NOT_CONSUMED (-8)
|
||||||
|
#define UPX_E_NOT_YET_IMPLEMENTED (-9)
|
||||||
|
#define UPX_E_INVALID_ARGUMENT (-10)
|
||||||
|
|
||||||
|
|
||||||
|
// Executable formats. Note: big endian types are >= 128.
|
||||||
|
#define UPX_F_DOS_COM 1
|
||||||
|
#define UPX_F_DOS_SYS 2
|
||||||
|
#define UPX_F_DOS_EXE 3
|
||||||
|
#define UPX_F_DJGPP2_COFF 4
|
||||||
|
#define UPX_F_WATCOM_LE 5
|
||||||
|
#define UPX_F_VXD_LE 6 // NOT IMPLEMENTED
|
||||||
|
#define UPX_F_DOS_EXEH 7 // OBSOLETE
|
||||||
|
#define UPX_F_TMT_ADAM 8
|
||||||
|
#define UPX_F_WIN32_PE 9
|
||||||
|
#define UPX_F_LINUX_i386 10
|
||||||
|
#define UPX_F_WIN16_NE 11 // NOT IMPLEMENTED
|
||||||
|
#define UPX_F_LINUX_ELF_i386 12
|
||||||
|
#define UPX_F_LINUX_SEP_i386 13 // NOT IMPLEMENTED
|
||||||
|
#define UPX_F_LINUX_SH_i386 14
|
||||||
|
#define UPX_F_VMLINUZ_i386 15
|
||||||
|
#define UPX_F_BVMLINUZ_i386 16
|
||||||
|
#define UPX_F_ELKS_8086 17 // NOT IMPLEMENTED
|
||||||
|
#define UPX_F_PS1_EXE 18
|
||||||
|
#define UPX_F_VMLINUX_i386 19
|
||||||
|
#define UPX_F_LINUX_ELFI_i386 20
|
||||||
|
#define UPX_F_WINCE_ARM_PE 21
|
||||||
|
#define UPX_F_LINUX_ELF64_AMD 22
|
||||||
|
#define UPX_F_LINUX_ELF32_ARMEL 23
|
||||||
|
#define UPX_F_BSD_i386 24
|
||||||
|
#define UPX_F_BSD_ELF_i386 25
|
||||||
|
#define UPX_F_BSD_SH_i386 26
|
||||||
|
|
||||||
|
#define UPX_F_VMLINUX_AMD64 27
|
||||||
|
#define UPX_F_VMLINUX_ARMEL 28
|
||||||
|
#define UPX_F_MACH_i386 29
|
||||||
|
#define UPX_F_LINUX_ELF32_MIPSEL 30
|
||||||
|
#define UPX_F_VMLINUZ_ARMEL 31
|
||||||
|
#define UPX_F_MACH_ARMEL 32
|
||||||
|
|
||||||
|
#define UPX_F_DYLIB_i386 33
|
||||||
|
#define UPX_F_MACH_AMD64 34
|
||||||
|
#define UPX_F_DYLIB_AMD64 35
|
||||||
|
|
||||||
|
#define UPX_F_WIN64_PEP 36
|
||||||
|
|
||||||
|
#define UPX_F_MACH_ARM64EL 37
|
||||||
|
|
||||||
|
#define UPX_F_MACH_PPC64LE 38
|
||||||
|
#define UPX_F_LINUX_ELFPPC64LE 39
|
||||||
|
#define UPX_F_VMLINUX_PPC64LE 40
|
||||||
|
#define UPX_F_DYLIB_PPC64LE 41
|
||||||
|
|
||||||
|
#define UPX_F_LINUX_ELF64_ARM 42
|
||||||
|
|
||||||
|
#define UPX_F_ATARI_TOS 129
|
||||||
|
#define UPX_F_SOLARIS_SPARC 130 // NOT IMPLEMENTED
|
||||||
|
#define UPX_F_MACH_PPC32 131
|
||||||
|
#define UPX_F_LINUX_ELFPPC32 132
|
||||||
|
#define UPX_F_LINUX_ELF32_ARMEB 133
|
||||||
|
#define UPX_F_MACH_FAT 134
|
||||||
|
#define UPX_F_VMLINUX_ARMEB 135
|
||||||
|
#define UPX_F_VMLINUX_PPC32 136
|
||||||
|
#define UPX_F_LINUX_ELF32_MIPSEB 137
|
||||||
|
#define UPX_F_DYLIB_PPC32 138
|
||||||
|
|
||||||
|
#define UPX_F_MACH_PPC64 139
|
||||||
|
#define UPX_F_LINUX_ELFPPC64 140
|
||||||
|
#define UPX_F_VMLINUX_PPC64 141
|
||||||
|
#define UPX_F_DYLIB_PPC64 142
|
||||||
|
|
||||||
|
// compression methods
|
||||||
|
#define M_ALL (-1)
|
||||||
|
#define M_END (-2)
|
||||||
|
#define M_NONE (-3)
|
||||||
|
#define M_SKIP (-4)
|
||||||
|
#define M_ULTRA_BRUTE (-5)
|
||||||
// compression methods - DO NOT CHANGE
|
// compression methods - DO NOT CHANGE
|
||||||
#define M_NRV2B_LE32 2
|
#define M_NRV2B_LE32 2
|
||||||
#define M_NRV2B_8 3
|
#define M_NRV2B_8 3
|
||||||
@@ -423,60 +439,203 @@ inline void operator delete[](void *p)
|
|||||||
#define M_NRV2E_LE32 8
|
#define M_NRV2E_LE32 8
|
||||||
#define M_NRV2E_8 9
|
#define M_NRV2E_8 9
|
||||||
#define M_NRV2E_LE16 10
|
#define M_NRV2E_LE16 10
|
||||||
#define M_CL1B_LE32 11
|
//#define M_CL1B_LE32 11
|
||||||
#define M_CL1B_8 12
|
//#define M_CL1B_8 12
|
||||||
#define M_CL1B_LE16 13
|
//#define M_CL1B_LE16 13
|
||||||
|
#define M_LZMA 14
|
||||||
|
#define M_DEFLATE 15 /* zlib */
|
||||||
|
|
||||||
#define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16)
|
#define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16)
|
||||||
#define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16)
|
#define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16)
|
||||||
#define M_IS_NRV2E(x) ((x) >= M_NRV2E_LE32 && (x) <= M_NRV2E_LE16)
|
#define M_IS_NRV2E(x) ((x) >= M_NRV2E_LE32 && (x) <= M_NRV2E_LE16)
|
||||||
#define M_IS_CL1B(x) ((x) >= M_CL1B_LE32 && (x) <= M_CL1B_LE16)
|
//#define M_IS_CL1B(x) ((x) >= M_CL1B_LE32 && (x) <= M_CL1B_LE16)
|
||||||
|
#define M_IS_LZMA(x) (((x) & 255) == M_LZMA)
|
||||||
|
#define M_IS_DEFLATE(x) ((x) == M_DEFLATE)
|
||||||
|
|
||||||
|
|
||||||
// Executable formats. Note: big endian types are >= 128.
|
// filters
|
||||||
#define UPX_F_DOS_COM 1
|
#define FT_END (-1)
|
||||||
#define UPX_F_DOS_SYS 2
|
#define FT_NONE (-2)
|
||||||
#define UPX_F_DOS_EXE 3
|
#define FT_SKIP (-3)
|
||||||
#define UPX_F_DJGPP2_COFF 4
|
#define FT_ULTRA_BRUTE (-4)
|
||||||
#define UPX_F_WATCOM_LE 5
|
|
||||||
#define UPX_F_VXD_LE 6
|
|
||||||
#define UPX_F_DOS_EXEH 7 /* OBSOLETE */
|
|
||||||
#define UPX_F_TMT_ADAM 8
|
|
||||||
#define UPX_F_WIN32_PE 9
|
|
||||||
#define UPX_F_LINUX_i386 10
|
|
||||||
#define UPX_F_WIN16_NE 11
|
|
||||||
#define UPX_F_LINUX_ELF_i386 12
|
|
||||||
#define UPX_F_LINUX_SEP_i386 13
|
|
||||||
#define UPX_F_LINUX_SH_i386 14
|
|
||||||
#define UPX_F_VMLINUZ_i386 15
|
|
||||||
#define UPX_F_BVMLINUZ_i386 16
|
|
||||||
#define UPX_F_ELKS_8086 17
|
|
||||||
#define UPX_F_PS1_EXE 18
|
|
||||||
#define UPX_F_VMLINUX_i386 19
|
|
||||||
#define UPX_F_LINUX_ELFI_i386 20
|
|
||||||
#define UPX_F_WINCE_ARM_PE 21
|
|
||||||
#define UPX_F_LINUX_ELF64_AMD 22
|
|
||||||
|
|
||||||
#define UPX_F_PLAIN_TEXT 127
|
|
||||||
|
|
||||||
#define UPX_F_ATARI_TOS 129
|
|
||||||
#define UPX_F_SOLARIS_SPARC 130
|
|
||||||
#define UPX_F_MACH_PPC32 131
|
|
||||||
#define UPX_F_LINUX_ELFPPC32 132
|
|
||||||
|
|
||||||
|
|
||||||
#define UPX_MAGIC_LE32 0x21585055 /* "UPX!" */
|
/*************************************************************************
|
||||||
#define UPX_MAGIC2_LE32 0xD5D0D8A1
|
// compression - callback_t
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
struct upx_callback_t;
|
||||||
|
typedef upx_callback_t *upx_callback_p;
|
||||||
|
typedef void (__acc_cdecl *upx_progress_func_t)
|
||||||
|
(upx_callback_p, unsigned, unsigned);
|
||||||
|
|
||||||
|
struct upx_callback_t
|
||||||
|
{
|
||||||
|
upx_progress_func_t nprogress;
|
||||||
|
void *user;
|
||||||
|
|
||||||
|
void reset() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// compression - config_t
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
template <class T, T default_value_, T min_value_, T max_value_>
|
||||||
|
struct OptVar
|
||||||
|
{
|
||||||
|
typedef T value_type;
|
||||||
|
static const T default_value = default_value_;
|
||||||
|
static const T min_value = min_value_;
|
||||||
|
static const T max_value = max_value_;
|
||||||
|
|
||||||
|
static void assertValue(const T &v) {
|
||||||
|
// info: this generates annoying warnings "unsigned >= 0 is always true"
|
||||||
|
//assert(v >= min_value);
|
||||||
|
assert(v == min_value || v >= min_value + 1);
|
||||||
|
assert(v <= max_value);
|
||||||
|
}
|
||||||
|
void assertValue() const {
|
||||||
|
assertValue(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
OptVar() : v(default_value), is_set(0) { }
|
||||||
|
OptVar& operator= (const T &other) {
|
||||||
|
v = other; is_set = 1;
|
||||||
|
assertValue();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() { v = default_value; is_set = 0; }
|
||||||
|
operator T () const { return v; }
|
||||||
|
|
||||||
|
T v;
|
||||||
|
unsigned is_set;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// optional assignments
|
||||||
|
template <class T, T a, T b, T c>
|
||||||
|
inline void oassign(OptVar<T,a,b,c> &self, const OptVar<T,a,b,c> &other) {
|
||||||
|
if (other.is_set) { self.v = other.v; self.is_set = 1; }
|
||||||
|
}
|
||||||
|
template <class T, T a, T b, T c>
|
||||||
|
inline void oassign(T &v, const OptVar<T,a,b,c> &other) {
|
||||||
|
if (other.is_set) { v = other.v; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct lzma_compress_config_t
|
||||||
|
{
|
||||||
|
typedef OptVar<unsigned, 2u, 0u, 4u> pos_bits_t; // pb
|
||||||
|
typedef OptVar<unsigned, 0u, 0u, 4u> lit_pos_bits_t; // lp
|
||||||
|
typedef OptVar<unsigned, 3u, 0u, 8u> lit_context_bits_t; // lc
|
||||||
|
typedef OptVar<unsigned, (1u<<22), 1u, (1u<<30) > dict_size_t;
|
||||||
|
typedef OptVar<unsigned, 64u, 5u, 273u> num_fast_bytes_t;
|
||||||
|
|
||||||
|
pos_bits_t pos_bits; // pb
|
||||||
|
lit_pos_bits_t lit_pos_bits; // lp
|
||||||
|
lit_context_bits_t lit_context_bits; // lc
|
||||||
|
dict_size_t dict_size;
|
||||||
|
unsigned fast_mode;
|
||||||
|
num_fast_bytes_t num_fast_bytes;
|
||||||
|
unsigned match_finder_cycles;
|
||||||
|
|
||||||
|
unsigned max_num_probs;
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct ucl_compress_config_t : public REAL_ucl_compress_config_t
|
||||||
|
{
|
||||||
|
void reset() { memset(this, 0xff, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct zlib_compress_config_t
|
||||||
|
{
|
||||||
|
typedef OptVar<unsigned, 8u, 1u, 9u> mem_level_t; // ml
|
||||||
|
typedef OptVar<unsigned, 15u, 9u, 15u> window_bits_t; // wb
|
||||||
|
typedef OptVar<unsigned, 0u, 0u, 4u> strategy_t; // st
|
||||||
|
|
||||||
|
mem_level_t mem_level; // ml
|
||||||
|
window_bits_t window_bits; // wb
|
||||||
|
strategy_t strategy; // st
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct upx_compress_config_t
|
||||||
|
{
|
||||||
|
lzma_compress_config_t conf_lzma;
|
||||||
|
ucl_compress_config_t conf_ucl;
|
||||||
|
zlib_compress_config_t conf_zlib;
|
||||||
|
void reset() { conf_lzma.reset(); conf_ucl.reset(); conf_zlib.reset(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NULL_cconf ((upx_compress_config_t *) NULL)
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// compression - result_t
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
struct lzma_compress_result_t
|
||||||
|
{
|
||||||
|
unsigned pos_bits; // pb
|
||||||
|
unsigned lit_pos_bits; // lp
|
||||||
|
unsigned lit_context_bits; // lc
|
||||||
|
unsigned dict_size;
|
||||||
|
unsigned fast_mode;
|
||||||
|
unsigned num_fast_bytes;
|
||||||
|
unsigned match_finder_cycles;
|
||||||
|
unsigned num_probs; // (computed result)
|
||||||
|
|
||||||
|
void reset() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct ucl_compress_result_t
|
||||||
|
{
|
||||||
|
ucl_uint result[16];
|
||||||
|
|
||||||
|
void reset() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct zlib_compress_result_t
|
||||||
|
{
|
||||||
|
unsigned dummy;
|
||||||
|
|
||||||
|
void reset() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct upx_compress_result_t
|
||||||
|
{
|
||||||
|
// debug
|
||||||
|
int method, level;
|
||||||
|
unsigned u_len, c_len;
|
||||||
|
|
||||||
|
lzma_compress_result_t result_lzma;
|
||||||
|
ucl_compress_result_t result_ucl;
|
||||||
|
zlib_compress_result_t result_zlib;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
memset(this, 0, sizeof(*this));
|
||||||
|
result_lzma.reset(); result_ucl.reset(); result_zlib.reset();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// globals
|
// globals
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "snprintf.h"
|
#include "snprintf.h" // must get included first!
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
|
|
||||||
#include "stdcxx.h"
|
#include "stdcxx.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "except.h"
|
#include "except.h"
|
||||||
@@ -485,11 +644,15 @@ inline void operator delete[](void *p)
|
|||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
||||||
|
|
||||||
|
// classes
|
||||||
|
class ElfLinker;
|
||||||
|
typedef ElfLinker Linker;
|
||||||
|
|
||||||
|
|
||||||
// main.cpp
|
// main.cpp
|
||||||
extern const char *progname;
|
extern const char *progname;
|
||||||
void init_options(struct options_t *o);
|
bool set_exit_code(int ec);
|
||||||
bool set_ec(int ec);
|
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
#if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
|
||||||
void e_exit(int ec) __attribute__((__noreturn__));
|
void e_exit(int ec) __attribute__((__noreturn__));
|
||||||
#else
|
#else
|
||||||
void e_exit(int ec);
|
void e_exit(int ec);
|
||||||
@@ -501,7 +664,7 @@ void printSetNl(int need_nl);
|
|||||||
void printClearLine(FILE *f = NULL);
|
void printClearLine(FILE *f = NULL);
|
||||||
void printErr(const char *iname, const Throwable *e);
|
void printErr(const char *iname, const Throwable *e);
|
||||||
void printUnhandledException(const char *iname, const std::exception *e);
|
void printUnhandledException(const char *iname, const std::exception *e);
|
||||||
#if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
|
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
|
||||||
__attribute__((__format__(__printf__,2,3)));
|
__attribute__((__format__(__printf__,2,3)));
|
||||||
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
|
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
|
||||||
@@ -511,7 +674,7 @@ void __acc_cdecl_va printErr(const char *iname, const char *format, ...);
|
|||||||
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...);
|
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
|
||||||
void __acc_cdecl_va infoWarning(const char *format, ...)
|
void __acc_cdecl_va infoWarning(const char *format, ...)
|
||||||
__attribute__((__format__(__printf__,1,2)));
|
__attribute__((__format__(__printf__,1,2)));
|
||||||
void __acc_cdecl_va infoHeader(const char *format, ...)
|
void __acc_cdecl_va infoHeader(const char *format, ...)
|
||||||
@@ -533,8 +696,9 @@ void do_files(int i, int argc, char *argv[]);
|
|||||||
|
|
||||||
|
|
||||||
// help.cpp
|
// help.cpp
|
||||||
|
extern const char gitrev[];
|
||||||
void show_head(void);
|
void show_head(void);
|
||||||
void show_help(int x = 0);
|
void show_help(int verbose=0);
|
||||||
void show_license(void);
|
void show_license(void);
|
||||||
void show_usage(void);
|
void show_usage(void);
|
||||||
void show_version(int);
|
void show_version(int);
|
||||||
@@ -544,21 +708,22 @@ void show_version(int);
|
|||||||
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler=1);
|
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler=1);
|
||||||
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc=0);
|
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc=0);
|
||||||
|
|
||||||
int upx_compress ( const upx_bytep src, upx_uint src_len,
|
int upx_compress ( const upx_bytep src, unsigned src_len,
|
||||||
upx_bytep dst, upx_uintp dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
upx_progress_callback_t *cb,
|
upx_callback_p cb,
|
||||||
int method, int level,
|
int method, int level,
|
||||||
const struct upx_compress_config_t *conf,
|
const upx_compress_config_t *cconf,
|
||||||
upx_uintp result );
|
upx_compress_result_t *cresult );
|
||||||
int upx_decompress ( const upx_bytep src, upx_uint src_len,
|
int upx_decompress ( const upx_bytep src, unsigned src_len,
|
||||||
upx_bytep dst, upx_uintp dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
int method );
|
int method,
|
||||||
int upx_test_overlap ( const upx_bytep buf, upx_uint src_off,
|
const upx_compress_result_t *cresult );
|
||||||
upx_uint src_len, upx_uintp dst_len,
|
int upx_test_overlap ( const upx_bytep buf,
|
||||||
int method );
|
const upx_bytep tbuf,
|
||||||
|
unsigned src_off, unsigned src_len,
|
||||||
|
unsigned* dst_len,
|
||||||
#endif /* __cplusplus */
|
int method,
|
||||||
|
const upx_compress_result_t *cresult );
|
||||||
|
|
||||||
|
|
||||||
#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||||
@@ -570,8 +735,4 @@ int upx_test_overlap ( const upx_bytep buf, upx_uint src_off,
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+25
-29
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -39,41 +39,41 @@
|
|||||||
#undef USE_SCREEN_WIN32
|
#undef USE_SCREEN_WIN32
|
||||||
#undef USE_FRAMES
|
#undef USE_FRAMES
|
||||||
|
|
||||||
#if defined(WITH_GUI) && !defined(NO_CONSOLE)
|
#if 1 && (WITH_GUI) && !defined(NO_CONSOLE)
|
||||||
# define NO_CONSOLE
|
# define NO_CONSOLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1 && defined(__linux__)
|
#if 1 && defined(__linux__)
|
||||||
# define USE_SCREEN
|
# define USE_SCREEN 1
|
||||||
# define USE_SCREEN_VCSA
|
# define USE_SCREEN_VCSA 1
|
||||||
# if !defined(HAVE_LINUX_KD_H)
|
# if !(HAVE_LINUX_KD_H)
|
||||||
# undef USE_SCREEN
|
# undef USE_SCREEN
|
||||||
# undef USE_SCREEN_VCSA
|
# undef USE_SCREEN_VCSA
|
||||||
# endif
|
# endif
|
||||||
# if !defined(HAVE_LINUX_KDEV_T_H) || !defined(HAVE_LINUX_MAJOR_H)
|
# if !(HAVE_LINUX_KDEV_T_H) || !(HAVE_LINUX_MAJOR_H)
|
||||||
# undef USE_SCREEN
|
# undef USE_SCREEN
|
||||||
# undef USE_SCREEN_VCSA
|
# undef USE_SCREEN_VCSA
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1 && defined(__DJGPP__)
|
#if 1 && (ACC_OS_DOS32) && defined(__DJGPP__)
|
||||||
# define USE_SCREEN
|
# define USE_SCREEN 1
|
||||||
#elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
|
#elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||||
# define USE_SCREEN
|
# define USE_SCREEN 1
|
||||||
# define USE_SCREEN_WIN32
|
# define USE_SCREEN_WIN32 1
|
||||||
#elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
|
#elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
|
||||||
# define USE_SCREEN
|
# define USE_SCREEN 1
|
||||||
# define USE_SCREEN_WIN32
|
# define USE_SCREEN_WIN32 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 0 || defined(NO_ANSI)
|
#if 0 || (NO_ANSI)
|
||||||
# undef USE_ANSI
|
# undef USE_ANSI
|
||||||
#endif
|
#endif
|
||||||
#if 0 || defined(NO_SCREEN)
|
#if 0 || (NO_SCREEN)
|
||||||
# undef USE_SCREEN
|
# undef USE_SCREEN
|
||||||
#endif
|
#endif
|
||||||
#if 0 || defined(NO_FRAMES) || !defined(USE_SCREEN)
|
#if 0 || (NO_FRAMES) || !(USE_SCREEN)
|
||||||
# undef USE_FRAMES
|
# undef USE_FRAMES
|
||||||
#endif
|
#endif
|
||||||
#if 1
|
#if 1
|
||||||
@@ -81,11 +81,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 0 || defined(USE_ANSI) || defined(USE_SCREEN)
|
#if 0 || (USE_ANSI) || (USE_SCREEN)
|
||||||
# define USE_CONSOLE
|
# define USE_CONSOLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 || defined(NO_CONSOLE) || !defined(USE_CONSOLE)
|
#if 0 || (NO_CONSOLE) || !(USE_CONSOLE)
|
||||||
# undef USE_CONSOLE
|
# undef USE_CONSOLE
|
||||||
# undef USE_ANSI
|
# undef USE_ANSI
|
||||||
# undef USE_SCREEN
|
# undef USE_SCREEN
|
||||||
@@ -110,14 +110,14 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int (*init)(FILE *f, int, int);
|
int (*init)(FILE *f, int, int);
|
||||||
int (*set_fg)(FILE *f, int fg);
|
int (*set_fg)(FILE *f, int fg);
|
||||||
void (*print0)(FILE *f, const char *s);
|
void (*print0)(FILE *f, const char *s);
|
||||||
upx_bool (*intro)(FILE *f);
|
bool (*intro)(FILE *f);
|
||||||
}
|
}
|
||||||
console_t;
|
console_t;
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...);
|
|||||||
|
|
||||||
extern FILE *con_term;
|
extern FILE *con_term;
|
||||||
|
|
||||||
#if defined(USE_CONSOLE)
|
#if (USE_CONSOLE)
|
||||||
|
|
||||||
extern int con_mode;
|
extern int con_mode;
|
||||||
extern console_t *con;
|
extern console_t *con;
|
||||||
@@ -187,8 +187,4 @@ extern console_t console_screen;
|
|||||||
|
|
||||||
#endif /* USE_CONSOLE */
|
#endif /* USE_CONSOLE */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+21
-12
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
long Throwable::counter = 0;
|
unsigned long Throwable::counter = 0;
|
||||||
|
|
||||||
Throwable::Throwable(const char *m, int e, bool w) NOTHROW
|
Throwable::Throwable(const char *m, int e, bool w) NOTHROW
|
||||||
: super(), msg(NULL), err(e), is_warning(w)
|
: super(), msg(NULL), err(e), is_warning(w)
|
||||||
@@ -41,7 +41,7 @@ Throwable::Throwable(const char *m, int e, bool w) NOTHROW
|
|||||||
if (m)
|
if (m)
|
||||||
msg = strdup(m);
|
msg = strdup(m);
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "construct exception: %s %ld\n", msg, counter);
|
fprintf(stderr, "construct exception: %s %lu\n", msg, counter);
|
||||||
counter++;
|
counter++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ Throwable::Throwable(const Throwable &other) NOTHROW
|
|||||||
if (other.msg)
|
if (other.msg)
|
||||||
msg = strdup(other.msg);
|
msg = strdup(other.msg);
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "copy exception: %s %ld\n", msg, counter);
|
fprintf(stderr, "copy exception: %s %lu\n", msg, counter);
|
||||||
counter++;
|
counter++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ Throwable::~Throwable() NOTHROW
|
|||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
counter--;
|
counter--;
|
||||||
fprintf(stderr, "destruct exception: %s %ld\n", msg, counter);
|
fprintf(stderr, "destruct exception: %s %lu\n", msg, counter);
|
||||||
#endif
|
#endif
|
||||||
if (msg)
|
if (msg)
|
||||||
free(msg);
|
free(msg);
|
||||||
@@ -85,6 +85,11 @@ void throwCantPack(const char *msg)
|
|||||||
throw CantUnpackException(msg);
|
throw CantUnpackException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void throwCantPackExact()
|
||||||
|
{
|
||||||
|
throwCantPack("option '--exact' does not work with this file");
|
||||||
|
}
|
||||||
|
|
||||||
void throwFilterException()
|
void throwFilterException()
|
||||||
{
|
{
|
||||||
throwCantPack("filter problem");
|
throwCantPack("filter problem");
|
||||||
@@ -156,6 +161,14 @@ void throwBadLoader()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void throwOutOfMemoryException(const char *msg)
|
||||||
|
{
|
||||||
|
if (msg == NULL)
|
||||||
|
msg = "out of memory";
|
||||||
|
throw OutOfMemoryException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void throwIOException(const char *msg, int e)
|
void throwIOException(const char *msg, int e)
|
||||||
{
|
{
|
||||||
throw IOException(msg, e);
|
throw IOException(msg, e);
|
||||||
@@ -192,8 +205,4 @@ const char *prettyName(const char *n) NOTHROW
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+11
-14
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_EXCEPT_H
|
#ifndef __UPX_EXCEPT_H
|
||||||
#define __UPX_EXCEPT_H
|
#define __UPX_EXCEPT_H 1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ private:
|
|||||||
DISABLE_NEW_DELETE
|
DISABLE_NEW_DELETE
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static long counter; // for debugging
|
static unsigned long counter; // for debugging
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// application execptions
|
// application exceptions
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
class OverlayException : public Exception
|
class OverlayException : public Exception
|
||||||
@@ -200,14 +200,14 @@ public:
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#undef NORET
|
#undef NORET
|
||||||
#if 0 && defined(__GNUC__)
|
#if 1 && defined(__GNUC__)
|
||||||
// (noreturn) is probably not the correct semantics for throwing exceptions
|
|
||||||
#define NORET __attribute__((__noreturn__))
|
#define NORET __attribute__((__noreturn__))
|
||||||
#else
|
#else
|
||||||
#define NORET
|
#define NORET /*empty*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void throwCantPack(const char *msg) NORET;
|
void throwCantPack(const char *msg) NORET;
|
||||||
|
void throwCantPackExact() NORET;
|
||||||
void throwUnknownExecutableFormat(const char *msg = NULL, bool warn = false) NORET;
|
void throwUnknownExecutableFormat(const char *msg = NULL, bool warn = false) NORET;
|
||||||
void throwNotCompressible(const char *msg = NULL) NORET;
|
void throwNotCompressible(const char *msg = NULL) NORET;
|
||||||
void throwAlreadyPacked(const char *msg = NULL) NORET;
|
void throwAlreadyPacked(const char *msg = NULL) NORET;
|
||||||
@@ -219,6 +219,7 @@ void throwBadLoader() NORET;
|
|||||||
void throwChecksumError() NORET;
|
void throwChecksumError() NORET;
|
||||||
void throwCompressedDataViolation() NORET;
|
void throwCompressedDataViolation() NORET;
|
||||||
void throwInternalError(const char *msg) NORET;
|
void throwInternalError(const char *msg) NORET;
|
||||||
|
void throwOutOfMemoryException(const char *msg = NULL) NORET;
|
||||||
void throwIOException(const char *msg = NULL, int e = 0) NORET;
|
void throwIOException(const char *msg = NULL, int e = 0) NORET;
|
||||||
void throwEOFException(const char *msg = NULL, int e = 0) NORET;
|
void throwEOFException(const char *msg = NULL, int e = 0) NORET;
|
||||||
|
|
||||||
@@ -229,8 +230,4 @@ void throwEOFException(const char *msg = NULL, int e = 0) NORET;
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+136
-26
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
void File::chmod(const char *name, int mode)
|
void File::chmod(const char *name, int mode)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_CHMOD)
|
#if (HAVE_CHMOD)
|
||||||
if (::chmod(name,mode) != 0)
|
if (::chmod(name,mode) != 0)
|
||||||
throwIOException(name,errno);
|
throwIOException(name,errno);
|
||||||
#else
|
#else
|
||||||
@@ -48,7 +48,7 @@ void File::chmod(const char *name, int mode)
|
|||||||
|
|
||||||
void File::rename(const char *old_, const char *new_)
|
void File::rename(const char *old_, const char *new_)
|
||||||
{
|
{
|
||||||
#if defined(__DJGPP__)
|
#if (ACC_OS_DOS32) && defined(__DJGPP__)
|
||||||
if (::_rename(old_,new_) != 0)
|
if (::_rename(old_,new_) != 0)
|
||||||
#else
|
#else
|
||||||
if (::rename(old_,new_) != 0)
|
if (::rename(old_,new_) != 0)
|
||||||
@@ -69,7 +69,7 @@ void File::unlink(const char *name)
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
FileBase::FileBase() :
|
FileBase::FileBase() :
|
||||||
_fd(-1), _flags(0), _shflags(0), _mode(0), _name(NULL)
|
_fd(-1), _flags(0), _shflags(0), _mode(0), _name(NULL), _offset(0), _length(0)
|
||||||
{
|
{
|
||||||
memset(&st,0,sizeof(st));
|
memset(&st,0,sizeof(st));
|
||||||
}
|
}
|
||||||
@@ -88,22 +88,28 @@ FileBase::~FileBase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FileBase::sopen()
|
bool FileBase::do_sopen()
|
||||||
{
|
{
|
||||||
if (_shflags < 0)
|
if (_shflags < 0)
|
||||||
_fd = ::open(_name, _flags, _mode);
|
_fd = ::open(_name, _flags, _mode);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(__DJGPP__)
|
#if (ACC_OS_DOS32) && defined(__DJGPP__)
|
||||||
_fd = ::open(_name,_flags | _shflags, _mode);
|
_fd = ::open(_name,_flags | _shflags, _mode);
|
||||||
#elif defined(__MINT__)
|
#elif defined(__MINT__)
|
||||||
_fd = ::open(_name,_flags | (_shflags & O_SHMODE), _mode);
|
_fd = ::open(_name,_flags | (_shflags & O_SHMODE), _mode);
|
||||||
#elif defined(SH_DENYRW)
|
#elif defined(SH_DENYRW)
|
||||||
_fd = ::sopen(_name, _flags, _shflags, _mode);
|
_fd = ::sopen(_name, _flags, _shflags, _mode);
|
||||||
#else
|
#else
|
||||||
assert(0);
|
throwInternalError("bad usage of do_sopen()");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if (_fd < 0)
|
||||||
|
return false;
|
||||||
|
if (::fstat(_fd, &st) != 0)
|
||||||
|
throwIOException(_name, errno);
|
||||||
|
_length = st.st_size;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,6 +123,8 @@ bool FileBase::close()
|
|||||||
_flags = 0;
|
_flags = 0;
|
||||||
_mode = 0;
|
_mode = 0;
|
||||||
_name = NULL;
|
_name = NULL;
|
||||||
|
_offset = 0;
|
||||||
|
_length = 0;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +140,7 @@ int FileBase::read(void *buf, int len)
|
|||||||
{
|
{
|
||||||
if (!isOpen() || len < 0)
|
if (!isOpen() || len < 0)
|
||||||
throwIOException("bad read");
|
throwIOException("bad read");
|
||||||
|
mem_size_assert(1, len); // sanity check
|
||||||
errno = 0;
|
errno = 0;
|
||||||
long l = acc_safe_hread(_fd, buf, len);
|
long l = acc_safe_hread(_fd, buf, len);
|
||||||
if (errno)
|
if (errno)
|
||||||
@@ -153,6 +162,7 @@ void FileBase::write(const void *buf, int len)
|
|||||||
{
|
{
|
||||||
if (!isOpen() || len < 0)
|
if (!isOpen() || len < 0)
|
||||||
throwIOException("bad write");
|
throwIOException("bad write");
|
||||||
|
mem_size_assert(1, len); // sanity check
|
||||||
errno = 0;
|
errno = 0;
|
||||||
long l = acc_safe_hwrite(_fd, buf, len);
|
long l = acc_safe_hwrite(_fd, buf, len);
|
||||||
if (l != len)
|
if (l != len)
|
||||||
@@ -160,16 +170,26 @@ void FileBase::write(const void *buf, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FileBase::seek(off_t off, int whence)
|
off_t FileBase::seek(upx_int64_t off64, int whence)
|
||||||
{
|
{
|
||||||
|
mem_size_assert(1, off64 >= 0 ? off64 : -off64); // sanity check
|
||||||
|
off_t off = ACC_ICONV(off_t, off64);
|
||||||
if (!isOpen())
|
if (!isOpen())
|
||||||
throwIOException("bad seek 1");
|
throwIOException("bad seek 1");
|
||||||
if (whence == SEEK_SET && off < 0)
|
if (whence == SEEK_SET) {
|
||||||
|
if (off < 0)
|
||||||
throwIOException("bad seek 2");
|
throwIOException("bad seek 2");
|
||||||
if (whence == SEEK_END && off > 0)
|
off += _offset;
|
||||||
|
}
|
||||||
|
if (whence == SEEK_END) {
|
||||||
|
if (off > 0)
|
||||||
throwIOException("bad seek 3");
|
throwIOException("bad seek 3");
|
||||||
|
off += _offset + _length;
|
||||||
|
whence = SEEK_SET;
|
||||||
|
}
|
||||||
if (::lseek(_fd,off,whence) < 0)
|
if (::lseek(_fd,off,whence) < 0)
|
||||||
throwIOException("seek error",errno);
|
throwIOException("seek error",errno);
|
||||||
|
return off - _offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -180,7 +200,19 @@ off_t FileBase::tell() const
|
|||||||
off_t l = ::lseek(_fd, 0, SEEK_CUR);
|
off_t l = ::lseek(_fd, 0, SEEK_CUR);
|
||||||
if (l < 0)
|
if (l < 0)
|
||||||
throwIOException("tell error",errno);
|
throwIOException("tell error",errno);
|
||||||
return l;
|
return l - _offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FileBase::set_extent(off_t offset, off_t length)
|
||||||
|
{
|
||||||
|
_offset = offset;
|
||||||
|
_length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
off_t FileBase::st_size() const
|
||||||
|
{
|
||||||
|
return _length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -205,8 +237,9 @@ void InputFile::sopen(const char *name, int flags, int shflags)
|
|||||||
_flags = flags;
|
_flags = flags;
|
||||||
_shflags = shflags;
|
_shflags = shflags;
|
||||||
_mode = 0;
|
_mode = 0;
|
||||||
FileBase::sopen();
|
_offset = 0;
|
||||||
if (!isOpen())
|
_length = 0;
|
||||||
|
if (!FileBase::do_sopen())
|
||||||
{
|
{
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
throw FileNotFoundException(_name, errno);
|
throw FileNotFoundException(_name, errno);
|
||||||
@@ -215,6 +248,7 @@ void InputFile::sopen(const char *name, int flags, int shflags)
|
|||||||
else
|
else
|
||||||
throwIOException(_name, errno);
|
throwIOException(_name, errno);
|
||||||
}
|
}
|
||||||
|
_length_orig = _length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -255,9 +289,12 @@ int InputFile::readx(MemBuffer &buf, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InputFile::seek(off_t off, int whence)
|
off_t InputFile::seek(upx_int64_t off64, int whence)
|
||||||
{
|
{
|
||||||
super::seek(off,whence);
|
off_t pos = super::seek(off64, whence);
|
||||||
|
if (_length < pos)
|
||||||
|
throwIOException("bad seek 4");
|
||||||
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -266,6 +303,10 @@ off_t InputFile::tell() const
|
|||||||
return super::tell();
|
return super::tell();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
off_t InputFile::st_size_orig() const
|
||||||
|
{
|
||||||
|
return _length_orig;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
@@ -289,8 +330,9 @@ void OutputFile::sopen(const char *name, int flags, int shflags, int mode)
|
|||||||
_flags = flags;
|
_flags = flags;
|
||||||
_shflags = shflags;
|
_shflags = shflags;
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
FileBase::sopen();
|
_offset = 0;
|
||||||
if (!isOpen())
|
_length = 0;
|
||||||
|
if (!FileBase::do_sopen())
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
// don't throw FileNotFound here -- this is confusing
|
// don't throw FileNotFound here -- this is confusing
|
||||||
@@ -316,6 +358,8 @@ bool OutputFile::openStdout(int flags, bool force)
|
|||||||
_flags = flags;
|
_flags = flags;
|
||||||
_shflags = -1;
|
_shflags = -1;
|
||||||
_mode = 0;
|
_mode = 0;
|
||||||
|
_offset = 0;
|
||||||
|
_length = 0;
|
||||||
if (flags && acc_set_binmode(fd, 1) == -1)
|
if (flags && acc_set_binmode(fd, 1) == -1)
|
||||||
throwIOException(_name, errno);
|
throwIOException(_name, errno);
|
||||||
_fd = fd;
|
_fd = fd;
|
||||||
@@ -329,6 +373,18 @@ void OutputFile::write(const void *buf, int len)
|
|||||||
bytes_written += len;
|
bytes_written += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
off_t OutputFile::st_size() const
|
||||||
|
{
|
||||||
|
if (opt->to_stdout) { // might be a pipe ==> .st_size is invalid
|
||||||
|
return bytes_written; // too big if seek()+write() instead of rewrite()
|
||||||
|
}
|
||||||
|
struct stat my_st;
|
||||||
|
my_st.st_size = 0;
|
||||||
|
if (::fstat(_fd, &my_st) != 0)
|
||||||
|
throwIOException(_name, errno);
|
||||||
|
return my_st.st_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void OutputFile::write(const MemBuffer *buf, int len)
|
void OutputFile::write(const MemBuffer *buf, int len)
|
||||||
{
|
{
|
||||||
@@ -343,12 +399,70 @@ void OutputFile::write(const MemBuffer &buf, int len)
|
|||||||
write(&buf, len);
|
write(&buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OutputFile::rewrite(const void *buf, int len)
|
||||||
|
{
|
||||||
|
assert(!opt->to_stdout);
|
||||||
|
write(buf, len);
|
||||||
|
bytes_written -= len; // restore
|
||||||
|
}
|
||||||
|
|
||||||
|
off_t OutputFile::seek(upx_int64_t off64, int whence)
|
||||||
|
{
|
||||||
|
mem_size_assert(1, off64 >= 0 ? off64 : -off64); // sanity check
|
||||||
|
off_t off = ACC_ICONV(off_t, off64);
|
||||||
|
assert(!opt->to_stdout);
|
||||||
|
switch (whence) {
|
||||||
|
case SEEK_SET: {
|
||||||
|
if (bytes_written < off) {
|
||||||
|
bytes_written = off;
|
||||||
|
}
|
||||||
|
_length = bytes_written; // cheap, lazy update; needed?
|
||||||
|
} break;
|
||||||
|
case SEEK_END: {
|
||||||
|
_length = bytes_written; // necessary
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return super::seek(off,whence);
|
||||||
|
}
|
||||||
|
|
||||||
|
// WARNING: fsync() does not exist in some Windows environments.
|
||||||
|
// This trick works only on UNIX-like systems.
|
||||||
|
//int OutputFile::read(void *buf, int len)
|
||||||
|
//{
|
||||||
|
// fsync(_fd);
|
||||||
|
// InputFile infile;
|
||||||
|
// infile.open(this->getName(), O_RDONLY | O_BINARY);
|
||||||
|
// infile.seek(this->tell(), SEEK_SET);
|
||||||
|
// return infile.read(buf, len);
|
||||||
|
//}
|
||||||
|
|
||||||
|
void OutputFile::set_extent(off_t offset, off_t length)
|
||||||
|
{
|
||||||
|
super::set_extent(offset, length);
|
||||||
|
bytes_written = 0;
|
||||||
|
if (0==offset && (off_t)~0u==length) {
|
||||||
|
if (::fstat(_fd, &st) != 0)
|
||||||
|
throwIOException(_name, errno);
|
||||||
|
_length = st.st_size - offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
off_t OutputFile::unset_extent()
|
||||||
|
{
|
||||||
|
off_t l = ::lseek(_fd, 0, SEEK_END);
|
||||||
|
if (l < 0)
|
||||||
|
throwIOException("lseek error", errno);
|
||||||
|
_offset = 0;
|
||||||
|
_length = l;
|
||||||
|
bytes_written = _length;
|
||||||
|
return _length;
|
||||||
|
}
|
||||||
|
|
||||||
void OutputFile::dump(const char *name, const void *buf, int len, int flags)
|
void OutputFile::dump(const char *name, const void *buf, int len, int flags)
|
||||||
{
|
{
|
||||||
if (flags < 0)
|
if (flags < 0)
|
||||||
flags = O_CREAT | O_BINARY | O_TRUNC;
|
flags = O_CREAT | O_TRUNC;
|
||||||
flags |= O_WRONLY;
|
flags |= O_WRONLY | O_BINARY;
|
||||||
OutputFile f;
|
OutputFile f;
|
||||||
f.open(name, flags, 0600);
|
f.open(name, flags, 0600);
|
||||||
f.write(buf, len);
|
f.write(buf, len);
|
||||||
@@ -384,8 +498,4 @@ void MemoryOutputFile::write(const void *buf, int len)
|
|||||||
|
|
||||||
#endif /* if 0 */
|
#endif /* if 0 */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+21
-24
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_FILE_H
|
#ifndef __UPX_FILE_H
|
||||||
#define __UPX_FILE_H
|
#define __UPX_FILE_H 1
|
||||||
|
|
||||||
class MemBuffer;
|
class MemBuffer;
|
||||||
|
|
||||||
@@ -59,13 +59,15 @@ public:
|
|||||||
virtual bool isOpen() const { return _fd >= 0; }
|
virtual bool isOpen() const { return _fd >= 0; }
|
||||||
int getFd() const { return _fd; }
|
int getFd() const { return _fd; }
|
||||||
const char *getName() const { return _name; }
|
const char *getName() const { return _name; }
|
||||||
|
virtual off_t st_size() const; // { return _length; }
|
||||||
|
virtual void set_extent(off_t offset, off_t length);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void sopen();
|
bool do_sopen();
|
||||||
virtual int read(void *buf, int len);
|
virtual int read(void *buf, int len);
|
||||||
virtual int readx(void *buf, int len);
|
virtual int readx(void *buf, int len);
|
||||||
virtual void write(const void *buf, int len);
|
virtual void write(const void *buf, int len);
|
||||||
virtual void seek(off_t off, int whence);
|
virtual off_t seek(upx_int64_t off, int whence);
|
||||||
virtual off_t tell() const;
|
virtual off_t tell() const;
|
||||||
|
|
||||||
int _fd;
|
int _fd;
|
||||||
@@ -73,6 +75,8 @@ protected:
|
|||||||
int _shflags;
|
int _shflags;
|
||||||
int _mode;
|
int _mode;
|
||||||
const char *_name;
|
const char *_name;
|
||||||
|
off_t _offset;
|
||||||
|
off_t _length;
|
||||||
public:
|
public:
|
||||||
struct stat st;
|
struct stat st;
|
||||||
};
|
};
|
||||||
@@ -102,8 +106,11 @@ public:
|
|||||||
virtual int read(MemBuffer &buf, int len);
|
virtual int read(MemBuffer &buf, int len);
|
||||||
virtual int readx(MemBuffer &buf, int len);
|
virtual int readx(MemBuffer &buf, int len);
|
||||||
|
|
||||||
virtual void seek(off_t off, int whence);
|
virtual off_t seek(upx_int64_t off, int whence);
|
||||||
virtual off_t tell() const;
|
virtual off_t tell() const;
|
||||||
|
virtual off_t st_size_orig() const;
|
||||||
|
protected:
|
||||||
|
off_t _length_orig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -128,21 +135,15 @@ public:
|
|||||||
virtual void write(const void *buf, int len);
|
virtual void write(const void *buf, int len);
|
||||||
virtual void write(const MemBuffer *buf, int len);
|
virtual void write(const MemBuffer *buf, int len);
|
||||||
virtual void write(const MemBuffer &buf, int len);
|
virtual void write(const MemBuffer &buf, int len);
|
||||||
|
virtual void set_extent(off_t offset, off_t length);
|
||||||
|
virtual off_t unset_extent(); // returns actual length
|
||||||
|
|
||||||
off_t getBytesWritten() const { return bytes_written; }
|
off_t getBytesWritten() const { return bytes_written; }
|
||||||
|
virtual off_t st_size() const; // { return _length; }
|
||||||
|
|
||||||
// FIXME - these won't work when using the `--stdout' option
|
// FIXME - these won't work when using the '--stdout' option
|
||||||
virtual void seek(off_t off, int whence)
|
virtual off_t seek(upx_int64_t off, int whence);
|
||||||
{
|
virtual void rewrite(const void *buf, int len);
|
||||||
assert(!opt->to_stdout);
|
|
||||||
super::seek(off,whence);
|
|
||||||
}
|
|
||||||
virtual void rewrite(const void *buf, int len)
|
|
||||||
{
|
|
||||||
assert(!opt->to_stdout);
|
|
||||||
write(buf, len);
|
|
||||||
bytes_written -= len; // restore
|
|
||||||
}
|
|
||||||
|
|
||||||
// util
|
// util
|
||||||
static void dump(const char *name, const void *buf, int len, int flags=-1);
|
static void dump(const char *name, const void *buf, int len, int flags=-1);
|
||||||
@@ -184,8 +185,4 @@ protected:
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+22
-12
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -61,10 +61,10 @@ const FilterImp::FilterEntry *FilterImp::getFilter(int id)
|
|||||||
memset(filter_map, 0xff, sizeof(filter_map));
|
memset(filter_map, 0xff, sizeof(filter_map));
|
||||||
for (int i = 0; i < n_filters; i++)
|
for (int i = 0; i < n_filters; i++)
|
||||||
{
|
{
|
||||||
int fid = filters[i].id;
|
int filter_id = filters[i].id;
|
||||||
assert(fid >= 0 && fid <= 255);
|
assert(filter_id >= 0 && filter_id <= 255);
|
||||||
assert(filter_map[fid] == 0xff);
|
assert(filter_map[filter_id] == 0xff);
|
||||||
filter_map[fid] = (unsigned char) i;
|
filter_map[filter_id] = (unsigned char) i;
|
||||||
}
|
}
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
@@ -85,6 +85,20 @@ bool Filter::isValidFilter(int filter_id)
|
|||||||
return fe != NULL;
|
return fe != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Filter::isValidFilter(int filter_id, const int *allowed_filters)
|
||||||
|
{
|
||||||
|
if (!isValidFilter(filter_id))
|
||||||
|
return false;
|
||||||
|
if (filter_id == 0)
|
||||||
|
return true;
|
||||||
|
if (allowed_filters == NULL)
|
||||||
|
return false;
|
||||||
|
while (*allowed_filters != FT_END)
|
||||||
|
if (*allowed_filters++ == filter_id)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// high level API
|
// high level API
|
||||||
@@ -214,8 +228,4 @@ bool Filter::scan(const upx_byte *buf_, unsigned buf_len_)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+6
-9
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_FILTER_H
|
#ifndef __UPX_FILTER_H
|
||||||
#define __UPX_FILTER_H
|
#define __UPX_FILTER_H 1
|
||||||
|
|
||||||
class Filter;
|
class Filter;
|
||||||
class FilterImp;
|
class FilterImp;
|
||||||
@@ -62,6 +62,7 @@ public:
|
|||||||
bool scan(const upx_byte *buf, unsigned buf_len);
|
bool scan(const upx_byte *buf, unsigned buf_len);
|
||||||
|
|
||||||
static bool isValidFilter(int filter_id);
|
static bool isValidFilter(int filter_id);
|
||||||
|
static bool isValidFilter(int filter_id, const int *allowed_filters);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Will be set by each call to filter()/unfilter().
|
// Will be set by each call to filter()/unfilter().
|
||||||
@@ -130,8 +131,4 @@ private:
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+119
-6
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -383,8 +383,121 @@ static int s_ct32_e8e9_bswap_be(Filter *f)
|
|||||||
|
|
||||||
#undef CT32
|
#undef CT32
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// 24-bit ARM calltrick ("naive")
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
/*
|
#define CT24ARM_LE(f, cond, addvalue, get, set) \
|
||||||
vi:ts=4:et:nowrap
|
upx_byte *b = f->buf; \
|
||||||
*/
|
upx_byte *b_end = b + f->buf_len - 4; \
|
||||||
|
do { \
|
||||||
|
if (cond) \
|
||||||
|
{ \
|
||||||
|
unsigned a = (unsigned) (b - f->buf); \
|
||||||
|
f->lastcall = a; \
|
||||||
|
set(b, get(b) + (addvalue)); \
|
||||||
|
f->calls++; \
|
||||||
|
} \
|
||||||
|
b += 4; \
|
||||||
|
} while (b < b_end); \
|
||||||
|
if (f->lastcall) f->lastcall += 4; \
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
#define ARMCT_COND_le (((b[3] & 0x0f) == 0x0b))
|
||||||
|
|
||||||
|
static int f_ct24arm_le(Filter *f)
|
||||||
|
{
|
||||||
|
CT24ARM_LE(f, ARMCT_COND_le, a / 4 + f->addvalue, get_le24, set_le24)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_ct24arm_le(Filter *f)
|
||||||
|
{
|
||||||
|
CT24ARM_LE(f, ARMCT_COND_le, 0 - a / 4 - f->addvalue, get_le24, set_le24)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_ct24arm_le(Filter *f)
|
||||||
|
{
|
||||||
|
CT24ARM_LE(f, ARMCT_COND_le, a + f->addvalue, get_le24, set_dummy)
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef CT24ARM_LE
|
||||||
|
|
||||||
|
#define CT24ARM_BE(f, cond, addvalue, get, set) \
|
||||||
|
upx_byte *b = f->buf; \
|
||||||
|
upx_byte *b_end = b + f->buf_len - 4; \
|
||||||
|
do { \
|
||||||
|
if (cond) \
|
||||||
|
{ \
|
||||||
|
unsigned a = (unsigned) (b - f->buf); \
|
||||||
|
f->lastcall = a; \
|
||||||
|
set(1+b, get(1+b) + (addvalue)); \
|
||||||
|
f->calls++; \
|
||||||
|
} \
|
||||||
|
b += 4; \
|
||||||
|
} while (b < b_end); \
|
||||||
|
if (f->lastcall) f->lastcall += 4; \
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#define ARMCT_COND_be (((b[0] & 0x0f) == 0x0b))
|
||||||
|
|
||||||
|
static int f_ct24arm_be(Filter *f)
|
||||||
|
{
|
||||||
|
CT24ARM_BE(f, ARMCT_COND_be, a / 4 + f->addvalue, get_be24, set_be24)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_ct24arm_be(Filter *f)
|
||||||
|
{
|
||||||
|
CT24ARM_BE(f, ARMCT_COND_be, 0 - a / 4 - f->addvalue, get_be24, set_be24)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_ct24arm_be(Filter *f)
|
||||||
|
{
|
||||||
|
CT24ARM_BE(f, ARMCT_COND_be, a + f->addvalue, get_be24, set_dummy)
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef CT24ARM_BE
|
||||||
|
#undef ARMCT_COND
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// 26-bit ARM calltrick ("naive")
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#define CT26ARM_LE(f, cond, addvalue, get, set) \
|
||||||
|
upx_byte *b = f->buf; \
|
||||||
|
upx_byte *b_end = b + f->buf_len - 4; \
|
||||||
|
do { \
|
||||||
|
if (cond) \
|
||||||
|
{ \
|
||||||
|
unsigned a = (unsigned) (b - f->buf); \
|
||||||
|
f->lastcall = a; \
|
||||||
|
set(b, get(b) + (addvalue)); \
|
||||||
|
f->calls++; \
|
||||||
|
} \
|
||||||
|
b += 4; \
|
||||||
|
} while (b < b_end); \
|
||||||
|
if (f->lastcall) f->lastcall += 4; \
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
#define ARMCT_COND (((b[3] & 0x7C) == 0x14))
|
||||||
|
|
||||||
|
static int f_ct26arm_le(Filter *f)
|
||||||
|
{
|
||||||
|
CT26ARM_LE(f, ARMCT_COND, a / 4 + f->addvalue, get_le26, set_le26)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_ct26arm_le(Filter *f)
|
||||||
|
{
|
||||||
|
CT26ARM_LE(f, ARMCT_COND, 0 - a / 4 - f->addvalue, get_le26, set_le26)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_ct26arm_le(Filter *f)
|
||||||
|
{
|
||||||
|
CT26ARM_LE(f, ARMCT_COND, a + f->addvalue, get_le26, set_dummy)
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef CT26ARM_LE
|
||||||
|
#undef ARMCT_COND
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
|
|||||||
+16
-13
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ static int F(Filter *f)
|
|||||||
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
||||||
unsigned lastnoncall = size, lastcall = 0;
|
unsigned lastnoncall = size, lastcall = 0;
|
||||||
|
|
||||||
// find a 16MB large empty address space
|
// find a 16 MiB large empty address space
|
||||||
{
|
{
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
memset(buf,0,256);
|
memset(buf,0,256);
|
||||||
@@ -58,8 +58,16 @@ static int F(Filter *f)
|
|||||||
// must not conflict with the mark.
|
// must not conflict with the mark.
|
||||||
// Note that unsigned comparison checks both edges of buffer.
|
// Note that unsigned comparison checks both edges of buffer.
|
||||||
for (ic = 0; ic < size - 5; ic++)
|
for (ic = 0; ic < size - 5; ic++)
|
||||||
if (COND(b,ic) && get_le32(b+ic+1)+ic+1 >= size)
|
|
||||||
{
|
{
|
||||||
|
if (!COND(b,ic))
|
||||||
|
continue;
|
||||||
|
jc = get_le32(b+ic+1)+ic+1;
|
||||||
|
if (jc < size)
|
||||||
|
{
|
||||||
|
if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
buf[b[ic+1]] |= 1;
|
buf[b[ic+1]] |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,8 +87,7 @@ static int F(Filter *f)
|
|||||||
// try to detect 'real' calls only
|
// try to detect 'real' calls only
|
||||||
if (jc < size)
|
if (jc < size)
|
||||||
{
|
{
|
||||||
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
|
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
|
||||||
return 1; // fail - buffer not restored
|
|
||||||
#ifdef U
|
#ifdef U
|
||||||
set_be32(b+ic+1,jc+addvalue+cto);
|
set_be32(b+ic+1,jc+addvalue+cto);
|
||||||
#endif
|
#endif
|
||||||
@@ -119,7 +126,7 @@ static int F(Filter *f)
|
|||||||
f->noncalls = noncalls;
|
f->noncalls = noncalls;
|
||||||
f->lastcall = lastcall;
|
f->lastcall = lastcall;
|
||||||
|
|
||||||
#ifdef TESTING
|
#if 0 || defined(TESTING)
|
||||||
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
|
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@@ -162,8 +169,4 @@ static int U(Filter *f)
|
|||||||
#undef F
|
#undef F
|
||||||
#undef U
|
#undef U
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+17
-14
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
Copyright (C) 2000-2004 John F. Reiser
|
Copyright (C) 2000-2020 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
John F. Reiser
|
John F. Reiser
|
||||||
<jreiser@users.sourceforge.net>
|
<jreiser@users.sourceforge.net>
|
||||||
@@ -51,14 +51,22 @@ static int F(Filter *f)
|
|||||||
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
||||||
unsigned lastnoncall = size, lastcall = 0;
|
unsigned lastnoncall = size, lastcall = 0;
|
||||||
|
|
||||||
// find a 16MB large empty address space
|
// find a 16 MiB large empty address space
|
||||||
{
|
{
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
memset(buf,0,256);
|
memset(buf,0,256);
|
||||||
|
|
||||||
for (ic = 0; ic < size - 5; ic++)
|
for (ic = 0; ic < size - 5; ic++)
|
||||||
if (COND(b,ic,lastcall) && get_le32(b+ic+1)+ic+1 >= size)
|
|
||||||
{
|
{
|
||||||
|
if (!COND(b,ic,lastcall))
|
||||||
|
continue;
|
||||||
|
jc = get_le32(b+ic+1)+ic+1;
|
||||||
|
if (jc < size)
|
||||||
|
{
|
||||||
|
if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
buf[b[ic+1]] |= 1;
|
buf[b[ic+1]] |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +86,7 @@ static int F(Filter *f)
|
|||||||
// try to detect 'real' calls only
|
// try to detect 'real' calls only
|
||||||
if (jc < size)
|
if (jc < size)
|
||||||
{
|
{
|
||||||
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
|
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
|
||||||
return 1; // fail - buffer not restored
|
|
||||||
#ifdef U
|
#ifdef U
|
||||||
set_be32(b+ic+1,jc+addvalue+cto);
|
set_be32(b+ic+1,jc+addvalue+cto);
|
||||||
#endif
|
#endif
|
||||||
@@ -118,7 +125,7 @@ static int F(Filter *f)
|
|||||||
f->noncalls = noncalls;
|
f->noncalls = noncalls;
|
||||||
f->lastcall = lastcall;
|
f->lastcall = lastcall;
|
||||||
|
|
||||||
#ifdef TESTING
|
#if 0 || defined(TESTING)
|
||||||
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
|
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@@ -161,8 +168,4 @@ static int U(Filter *f)
|
|||||||
#undef F
|
#undef F
|
||||||
#undef U
|
#undef U
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+14
-15
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
Copyright (C) 2000-2004 John F. Reiser
|
Copyright (C) 2000-2020 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
John F. Reiser
|
John F. Reiser
|
||||||
<jreiser@users.sourceforge.net>
|
<jreiser@users.sourceforge.net>
|
||||||
@@ -62,7 +62,7 @@ f80_jcc2(Filter const *f)
|
|||||||
return f80_jmp1(f);
|
return f80_jmp1(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int const N_MRU = 32; // does not have to be a power of 2
|
#define N_MRU 32 // does not have to be a power of 2
|
||||||
|
|
||||||
// Adaptively remember recent destinations.
|
// Adaptively remember recent destinations.
|
||||||
static void
|
static void
|
||||||
@@ -123,8 +123,8 @@ static int F(Filter *f)
|
|||||||
N_MRU : 0;
|
N_MRU : 0;
|
||||||
#endif //}
|
#endif //}
|
||||||
|
|
||||||
// FIXME: We must fit into 8MB because we steal one bit.
|
// FIXME: We must fit into 8 MiB because we steal one bit.
|
||||||
// find a 16MB large empty address space
|
// find a 16 MiB large empty address space
|
||||||
{
|
{
|
||||||
int which;
|
int which;
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
@@ -249,11 +249,11 @@ static int F(Filter *f)
|
|||||||
f->noncalls = noncalls;
|
f->noncalls = noncalls;
|
||||||
f->lastcall = lastcall;
|
f->lastcall = lastcall;
|
||||||
|
|
||||||
/*#ifdef TESTING*/
|
#if 0 || defined(TESTING)
|
||||||
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",
|
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",
|
||||||
calls,noncalls,noncalls2,size,cto8);
|
calls,noncalls,noncalls2,size,cto8);
|
||||||
printf("CALL/JMP/JCC %d %d %d\n",wtally[0],wtally[1],wtally[2]);
|
printf("CALL/JMP/JCC %d %d %d\n",wtally[0],wtally[1],wtally[2]);
|
||||||
/*#endif*/
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,6 +300,9 @@ static int U(Filter *f)
|
|||||||
}
|
}
|
||||||
else { // not 1st time at this destination
|
else { // not 1st time at this destination
|
||||||
jc >>= 1;
|
jc >>= 1;
|
||||||
|
if (N_MRU <= jc) {
|
||||||
|
throwCompressedDataViolation();
|
||||||
|
}
|
||||||
int kh = jc + hand;
|
int kh = jc + hand;
|
||||||
if (N_MRU <= kh) {
|
if (N_MRU <= kh) {
|
||||||
kh -= N_MRU;
|
kh -= N_MRU;
|
||||||
@@ -337,12 +340,8 @@ static int U(Filter *f)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef N_MRU
|
||||||
#undef F
|
#undef F
|
||||||
#undef U
|
#undef U
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+17
-14
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
Copyright (C) 2000-2004 John F. Reiser
|
Copyright (C) 2000-2020 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
John F. Reiser
|
John F. Reiser
|
||||||
<jreiser@users.sourceforge.net>
|
<jreiser@users.sourceforge.net>
|
||||||
@@ -52,14 +52,22 @@ static int F(Filter *f)
|
|||||||
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
unsigned calls = 0, noncalls = 0, noncalls2 = 0;
|
||||||
unsigned lastnoncall = size, lastcall = 0;
|
unsigned lastnoncall = size, lastcall = 0;
|
||||||
|
|
||||||
// find a 16MB large empty address space
|
// find a 16 MiB large empty address space
|
||||||
{
|
{
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
memset(buf,0,256);
|
memset(buf,0,256);
|
||||||
|
|
||||||
for (ic = 0; ic < size - 5; ic++)
|
for (ic = 0; ic < size - 5; ic++)
|
||||||
if (COND(b,ic,lastcall,id) && get_le32(b+ic+1)+ic+1 >= size)
|
|
||||||
{
|
{
|
||||||
|
if (!COND(b,ic,lastcall,id))
|
||||||
|
continue;
|
||||||
|
jc = get_le32(b+ic+1)+ic+1;
|
||||||
|
if (jc < size)
|
||||||
|
{
|
||||||
|
if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
buf[b[ic+1]] |= 1;
|
buf[b[ic+1]] |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,8 +87,7 @@ static int F(Filter *f)
|
|||||||
// try to detect 'real' calls only
|
// try to detect 'real' calls only
|
||||||
if (jc < size)
|
if (jc < size)
|
||||||
{
|
{
|
||||||
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
|
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
|
||||||
return 1; // fail - buffer not restored
|
|
||||||
#ifdef U
|
#ifdef U
|
||||||
set_be32(b+ic+1,jc+addvalue+cto);
|
set_be32(b+ic+1,jc+addvalue+cto);
|
||||||
#endif
|
#endif
|
||||||
@@ -119,7 +126,7 @@ static int F(Filter *f)
|
|||||||
f->noncalls = noncalls;
|
f->noncalls = noncalls;
|
||||||
f->lastcall = lastcall;
|
f->lastcall = lastcall;
|
||||||
|
|
||||||
#ifdef TESTING
|
#if 0 || defined(TESTING)
|
||||||
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
|
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@@ -164,8 +171,4 @@ static int U(Filter *f)
|
|||||||
#undef F
|
#undef F
|
||||||
#undef U
|
#undef U
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -166,8 +166,4 @@ static int s_ctsw32_e9_e8(Filter *f)
|
|||||||
|
|
||||||
#undef CTSW32
|
#undef CTSW32
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+4
-9
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -67,9 +67,4 @@ static int getcto(Filter *f, const unsigned char *buf, const int n=256)
|
|||||||
return ic;
|
return ic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+17
-16
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
Copyright (C) 2004-2005 John F. Reiser
|
Copyright (C) 2004-2020 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
John F. Reiser
|
John F. Reiser
|
||||||
<jreiser@users.sourceforge.net>
|
<jreiser@users.sourceforge.net>
|
||||||
@@ -47,7 +47,7 @@ static int F(Filter *f)
|
|||||||
// scan
|
// scan
|
||||||
const upx_byte *b = f->buf;
|
const upx_byte *b = f->buf;
|
||||||
#endif
|
#endif
|
||||||
const unsigned size = umin(f->buf_len, -(~0u<<(32 - (6+ W_CTO))));
|
const unsigned size = umin(f->buf_len, 0u - (~0u<<(32 - (6+ W_CTO))));
|
||||||
const unsigned size4 = size -4;
|
const unsigned size4 = size -4;
|
||||||
|
|
||||||
unsigned ic;
|
unsigned ic;
|
||||||
@@ -58,7 +58,7 @@ static int F(Filter *f)
|
|||||||
{
|
{
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
unsigned short wbuf[256];
|
unsigned short wbuf[256];
|
||||||
const size_t WW = (size_t)0 - (~(size_t)0) << W_CTO; // ???
|
const size_t WW = (size_t)0 - ((~(size_t)0) << W_CTO); // ???
|
||||||
memset(wbuf, 0, sizeof(wbuf));
|
memset(wbuf, 0, sizeof(wbuf));
|
||||||
memset(buf , 0, WW);
|
memset(buf , 0, WW);
|
||||||
memset(buf + WW, 1, 256 - WW);
|
memset(buf + WW, 1, 256 - WW);
|
||||||
@@ -72,9 +72,11 @@ static int F(Filter *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getcto(f, buf) < 0) {
|
if (getcto(f, buf) < 0) {
|
||||||
if (0!=W_CTO) // FIXME: what is this ???
|
#if (W_CTO != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
#else
|
||||||
f->cto = 0;
|
f->cto = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const unsigned char cto8 = f->cto;
|
const unsigned char cto8 = f->cto;
|
||||||
@@ -95,8 +97,9 @@ static int F(Filter *f)
|
|||||||
lastcall = ic;
|
lastcall = ic;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(0==W_CTO // FIXME: what is this ???
|
#if (W_CTO != 0)
|
||||||
|| (~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != cto8); // this should not happen
|
assert((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != (unsigned) cto8); // this should not happen
|
||||||
|
#endif
|
||||||
lastnoncall = ic;
|
lastnoncall = ic;
|
||||||
noncalls++;
|
noncalls++;
|
||||||
}
|
}
|
||||||
@@ -105,8 +108,9 @@ static int F(Filter *f)
|
|||||||
f->calls = calls;
|
f->calls = calls;
|
||||||
f->noncalls = noncalls;
|
f->noncalls = noncalls;
|
||||||
f->lastcall = lastcall;
|
f->lastcall = lastcall;
|
||||||
|
ACC_UNUSED(lastnoncall);
|
||||||
|
|
||||||
#if 0
|
#if 0 || defined(TESTING)
|
||||||
printf("\ncalls=%d noncalls=%d text_size=%x calltrickoffset=%x\n",
|
printf("\ncalls=%d noncalls=%d text_size=%x calltrickoffset=%x\n",
|
||||||
calls,noncalls,size,cto8);
|
calls,noncalls,size,cto8);
|
||||||
#endif
|
#endif
|
||||||
@@ -122,14 +126,14 @@ static int F(Filter *f)
|
|||||||
static int U(Filter *f)
|
static int U(Filter *f)
|
||||||
{
|
{
|
||||||
upx_byte *b = f->buf;
|
upx_byte *b = f->buf;
|
||||||
const unsigned size4 = umin(f->buf_len - 4, -(~0u<<(32 - (6+ W_CTO))));
|
const unsigned size4 = umin(f->buf_len - 4, 0u - (~0u<<(32 - (6+ W_CTO))));
|
||||||
const unsigned addvalue = f->addvalue;
|
const unsigned addvalue = f->addvalue;
|
||||||
|
|
||||||
unsigned ic;
|
unsigned ic;
|
||||||
|
|
||||||
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
|
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
|
||||||
unsigned const word = get_be32(b+ic);
|
unsigned const word = get_be32(b+ic);
|
||||||
if ((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) == f->cto) {
|
if ((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) == (unsigned) f->cto) {
|
||||||
unsigned const jc = word & (~(~0u<<(26 - W_CTO)) & (~0u<<2));
|
unsigned const jc = word & (~(~0u<<(26 - W_CTO)) & (~0u<<2));
|
||||||
set_be32(b+ic, (0xfc000003&word)|(0x03fffffc&(jc-ic-addvalue)));
|
set_be32(b+ic, (0xfc000003&word)|(0x03fffffc&(jc-ic-addvalue)));
|
||||||
f->calls++;
|
f->calls++;
|
||||||
@@ -149,7 +153,4 @@ static int U(Filter *f)
|
|||||||
|
|
||||||
#undef W_CTO
|
#undef W_CTO
|
||||||
|
|
||||||
/*
|
/* vim:set ts=4 sw=4 et: */
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+4
-9
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -79,9 +79,4 @@
|
|||||||
assert((int)f->calls > 0); \
|
assert((int)f->calls > 0); \
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -115,8 +115,4 @@ static int s_sub16_4(Filter *f)
|
|||||||
#undef ADD16
|
#undef ADD16
|
||||||
#undef SCAN16
|
#undef SCAN16
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -115,8 +115,4 @@ static int s_sub32_4(Filter *f)
|
|||||||
#undef ADD32
|
#undef ADD32
|
||||||
#undef SCAN32
|
#undef SCAN32
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -115,8 +115,4 @@ static int s_sub8_4(Filter *f)
|
|||||||
#undef ADD8
|
#undef ADD8
|
||||||
#undef SCAN8
|
#undef SCAN8
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+4
-9
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -180,9 +180,4 @@ static int s_sw32_e8e9(Filter *f)
|
|||||||
|
|
||||||
#undef SW32
|
#undef SW32
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -224,6 +224,13 @@ const FilterImp::FilterEntry FilterImp::filters[] = {
|
|||||||
{ 0x46, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le },
|
{ 0x46, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le },
|
||||||
{ 0x49, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le },
|
{ 0x49, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le },
|
||||||
|
|
||||||
|
// 24-bit calltrick for arm
|
||||||
|
{ 0x50, 8, 0x01ffffff, f_ct24arm_le, u_ct24arm_le, s_ct24arm_le },
|
||||||
|
{ 0x51, 8, 0x01ffffff, f_ct24arm_be, u_ct24arm_be, s_ct24arm_be },
|
||||||
|
|
||||||
|
// 26-bit calltrick for arm64
|
||||||
|
{ 0x52, 8, 0x03ffffff, f_ct26arm_le, u_ct26arm_le, s_ct26arm_le },
|
||||||
|
|
||||||
// 32-bit cto calltrick with jmp and jcc(swap 0x0f/0x8Y) and relative renumbering
|
// 32-bit cto calltrick with jmp and jcc(swap 0x0f/0x8Y) and relative renumbering
|
||||||
{ 0x80, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le },
|
{ 0x80, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le },
|
||||||
{ 0x81, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le },
|
{ 0x81, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le },
|
||||||
@@ -256,8 +263,4 @@ const FilterImp::FilterEntry FilterImp::filters[] = {
|
|||||||
|
|
||||||
const int FilterImp::n_filters = TABLESIZE(filters);
|
const int FilterImp::n_filters = TABLESIZE(filters);
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+178
-115
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2006 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,11 +22,14 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
#include "compress.h"
|
||||||
|
#include "packmast.h"
|
||||||
|
#include "packer.h"
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -35,6 +38,12 @@
|
|||||||
|
|
||||||
static bool head_done = 0;
|
static bool head_done = 0;
|
||||||
|
|
||||||
|
#if defined(UPX_VERSION_GITREV)
|
||||||
|
const char gitrev[] = UPX_VERSION_GITREV;
|
||||||
|
#else
|
||||||
|
const char gitrev[1] = { 0 };
|
||||||
|
#endif
|
||||||
|
|
||||||
void show_head(void)
|
void show_head(void)
|
||||||
{
|
{
|
||||||
FILE *f = con_term;
|
FILE *f = con_term;
|
||||||
@@ -48,14 +57,20 @@ void show_head(void)
|
|||||||
fg = con_fg(f,FG_GREEN);
|
fg = con_fg(f,FG_GREEN);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" Ultimate Packer for eXecutables\n"
|
" Ultimate Packer for eXecutables\n"
|
||||||
" Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006\n"
|
" Copyright (C) 1996 - " UPX_VERSION_YEAR "\n"
|
||||||
"UPX %-10s Markus Oberhumer, Laszlo Molnar & John Reiser %14s\n\n",
|
#if defined(UPX_VERSION_GITREV)
|
||||||
#if (ACC_OS_DOS16 || ACC_OS_DOS32)
|
"UPX git-%6.6s%c"
|
||||||
|
#else
|
||||||
|
"UPX %-11s"
|
||||||
|
#endif
|
||||||
|
" Markus Oberhumer, Laszlo Molnar & John Reiser %14s\n\n",
|
||||||
|
#if defined(UPX_VERSION_GITREV)
|
||||||
|
gitrev,
|
||||||
|
(sizeof(gitrev)-1 > 6 && gitrev[sizeof(gitrev)-2] == '+') ? '+' : ' ',
|
||||||
|
#elif (ACC_OS_DOS16 || ACC_OS_DOS32)
|
||||||
V("d"),
|
V("d"),
|
||||||
#elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
#elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
|
||||||
V("w"),
|
V("w"),
|
||||||
#elif 0 && defined(__linux__)
|
|
||||||
V("l"),
|
|
||||||
#else
|
#else
|
||||||
UPX_VERSION_STRING,
|
UPX_VERSION_STRING,
|
||||||
#endif
|
#endif
|
||||||
@@ -76,7 +91,7 @@ void show_usage(void)
|
|||||||
FILE *f = con_term;
|
FILE *f = con_term;
|
||||||
|
|
||||||
con_fprintf(f,"Usage: %s [-123456789dlthVL] [-qvfk] [-o file] %sfile..\n", progname,
|
con_fprintf(f,"Usage: %s [-123456789dlthVL] [-qvfk] [-o file] %sfile..\n", progname,
|
||||||
#if defined(__DJGPP__) || defined(__EMX__)
|
#if (ACC_OS_DOS32) && defined(__DJGPP__)
|
||||||
"[@]");
|
"[@]");
|
||||||
#else
|
#else
|
||||||
"");
|
"");
|
||||||
@@ -88,7 +103,79 @@ void show_usage(void)
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
void show_help(int x)
|
struct PackerNames
|
||||||
|
{
|
||||||
|
struct Entry {
|
||||||
|
const char* fname;
|
||||||
|
const char* sname;
|
||||||
|
};
|
||||||
|
Entry names[64];
|
||||||
|
size_t names_count;
|
||||||
|
const options_t *o;
|
||||||
|
PackerNames() : names_count(0), o(NULL) { }
|
||||||
|
void add(const Packer *p)
|
||||||
|
{
|
||||||
|
p->assertPacker();
|
||||||
|
assert(names_count < 64);
|
||||||
|
names[names_count].fname = p->getFullName(o);
|
||||||
|
names[names_count].sname = p->getName();
|
||||||
|
names_count++;
|
||||||
|
}
|
||||||
|
static Packer* visit(Packer *p, void *user)
|
||||||
|
{
|
||||||
|
PackerNames *self = (PackerNames *) user;
|
||||||
|
self->add(p);
|
||||||
|
delete p; p = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
static int __acc_cdecl_qsort cmp_fname(const void *a, const void *b) {
|
||||||
|
return strcmp(((const Entry *) a)->fname, ((const Entry *) b)->fname);
|
||||||
|
}
|
||||||
|
static int __acc_cdecl_qsort cmp_sname(const void *a, const void *b) {
|
||||||
|
return strcmp(((const Entry *) a)->sname, ((const Entry *) b)->sname);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void show_all_packers(FILE *f, int verbose)
|
||||||
|
{
|
||||||
|
options_t o; o.reset();
|
||||||
|
PackerNames pn; pn.o = &o;
|
||||||
|
PackMaster::visitAllPackers(PackerNames::visit, NULL, &o, &pn);
|
||||||
|
qsort(pn.names, pn.names_count, sizeof(PackerNames::Entry), PackerNames::cmp_fname);
|
||||||
|
size_t pos = 0;
|
||||||
|
for (size_t i = 0; i < pn.names_count; ++i)
|
||||||
|
{
|
||||||
|
const char *fn = pn.names[i].fname;
|
||||||
|
const char *sn = pn.names[i].sname;
|
||||||
|
if (verbose > 0)
|
||||||
|
{
|
||||||
|
con_fprintf(f, " %-36s %s\n", fn, sn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t fl = strlen(fn);
|
||||||
|
if (pos == 0) {
|
||||||
|
con_fprintf(f, " %s", fn);
|
||||||
|
pos = 2 + fl;
|
||||||
|
} else if (pos + 1 + fl > 80) {
|
||||||
|
con_fprintf(f, "\n %s", fn);
|
||||||
|
pos = 2 + fl;
|
||||||
|
} else {
|
||||||
|
con_fprintf(f, " %s", fn);
|
||||||
|
pos += 1 + fl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (verbose <= 0 && pn.names_count)
|
||||||
|
con_fprintf(f, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
void show_help(int verbose)
|
||||||
{
|
{
|
||||||
FILE *f = con_term;
|
FILE *f = con_term;
|
||||||
int fg;
|
int fg;
|
||||||
@@ -105,8 +192,8 @@ void show_help(int x)
|
|||||||
" -d decompress -l list compressed file\n"
|
" -d decompress -l list compressed file\n"
|
||||||
" -t test compressed file -V display version number\n"
|
" -t test compressed file -V display version number\n"
|
||||||
" -h give %s help -L display software license\n%s",
|
" -h give %s help -L display software license\n%s",
|
||||||
x == 0 ? "" : " --best compress best (can be slow for big files)\n",
|
verbose == 0 ? "" : " --best compress best (can be slow for big files)\n",
|
||||||
x == 0 ? "more" : "this", x == 0 ? "" : "\n");
|
verbose == 0 ? "more" : "this", verbose == 0 ? "" : "\n");
|
||||||
|
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options:\n");
|
con_fprintf(f,"Options:\n");
|
||||||
@@ -114,22 +201,29 @@ void show_help(int x)
|
|||||||
|
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" -q be quiet -v be verbose\n"
|
" -q be quiet -v be verbose\n"
|
||||||
" -oFILE write output to `FILE'\n"
|
" -oFILE write output to 'FILE'\n"
|
||||||
//" -f force overwrite of output files and compression of suspicious files\n"
|
//" -f force overwrite of output files and compression of suspicious files\n"
|
||||||
" -f force compression of suspicious files\n"
|
" -f force compression of suspicious files\n"
|
||||||
"%s%s"
|
"%s%s"
|
||||||
, (x == 0) ? " -k keep backup files\n" : ""
|
, (verbose == 0) ? " -k keep backup files\n" : ""
|
||||||
#if 1
|
#if 1
|
||||||
, (x > 0) ? " --no-color, --mono, --color, --no-progress change look\n" : ""
|
, (verbose > 0) ? " --no-color, --mono, --color, --no-progress change look\n" : ""
|
||||||
#else
|
#else
|
||||||
, ""
|
, ""
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
if (x > 0)
|
if (verbose > 0)
|
||||||
{
|
{
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"\nBackup options:\n");
|
con_fprintf(f,"\nCompression tuning options:\n");
|
||||||
|
fg = con_fg(f,fg);
|
||||||
|
con_fprintf(f,
|
||||||
|
" --brute try all available compression methods & filters [slow]\n"
|
||||||
|
" --ultra-brute try even more compression variants [very slow]\n"
|
||||||
|
"\n");
|
||||||
|
fg = con_fg(f,FG_YELLOW);
|
||||||
|
con_fprintf(f,"Backup options:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" -k, --backup keep backup files\n"
|
" -k, --backup keep backup files\n"
|
||||||
@@ -144,26 +238,16 @@ void show_help(int x)
|
|||||||
" --overlay=skip don't compress a file with an overlay\n"
|
" --overlay=skip don't compress a file with an overlay\n"
|
||||||
"\n");
|
"\n");
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options for atari/tos:\n");
|
|
||||||
fg = con_fg(f,fg);
|
|
||||||
con_fprintf(f,
|
|
||||||
" --all-methods try all available compression methods\n"
|
|
||||||
"\n");
|
|
||||||
fg = con_fg(f,FG_YELLOW);
|
|
||||||
con_fprintf(f,"Options for djgpp2/coff:\n");
|
con_fprintf(f,"Options for djgpp2/coff:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --coff produce COFF output [default: EXE]\n"
|
" --coff produce COFF output [default: EXE]\n"
|
||||||
" --all-methods try all available compression methods\n"
|
|
||||||
" --all-filters try all available preprocessing filters\n"
|
|
||||||
"\n");
|
"\n");
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options for dos/com:\n");
|
con_fprintf(f,"Options for dos/com:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --8086 make compressed com work on any 8086\n"
|
" --8086 make compressed com work on any 8086\n"
|
||||||
" --all-methods try all available compression methods\n"
|
|
||||||
" --all-filters try all available preprocessing filters\n"
|
|
||||||
"\n");
|
"\n");
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options for dos/exe:\n");
|
con_fprintf(f,"Options for dos/exe:\n");
|
||||||
@@ -171,56 +255,30 @@ void show_help(int x)
|
|||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --8086 make compressed exe work on any 8086\n"
|
" --8086 make compressed exe work on any 8086\n"
|
||||||
" --no-reloc put no relocations in to the exe header\n"
|
" --no-reloc put no relocations in to the exe header\n"
|
||||||
" --all-methods try all available compression methods\n"
|
|
||||||
"\n");
|
"\n");
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options for dos/sys:\n");
|
con_fprintf(f,"Options for dos/sys:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --8086 make compressed sys work on any 8086\n"
|
" --8086 make compressed sys work on any 8086\n"
|
||||||
" --all-methods try all available compression methods\n"
|
|
||||||
" --all-filters try all available preprocessing filters\n"
|
|
||||||
"\n");
|
"\n");
|
||||||
#if 0
|
|
||||||
fg = con_fg(f,FG_YELLOW);
|
|
||||||
con_fprintf(f,"Options for linux/386\n");
|
|
||||||
fg = con_fg(f,fg);
|
|
||||||
con_fprintf(f,
|
|
||||||
" --script use /usr/local/lib/upx/upx[bd] as decompressor\n"
|
|
||||||
" --script=/path/upxX use path/upxX as decompressor\n"
|
|
||||||
"\n");
|
|
||||||
#endif
|
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options for ps1/exe:\n");
|
con_fprintf(f,"Options for ps1/exe:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --all-methods try all available compression methods\n"
|
|
||||||
" --8-bit uses 8 bit size compression [default: 32 bit]\n"
|
" --8-bit uses 8 bit size compression [default: 32 bit]\n"
|
||||||
" --console-run enables client/host transfer compatibility\n"
|
" --8mib-ram 8 megabyte memory limit [default: 2 MiB]\n"
|
||||||
|
" --boot-only disables client/host transfer compatibility\n"
|
||||||
" --no-align don't align to 2048 bytes [enables: --console-run]\n"
|
" --no-align don't align to 2048 bytes [enables: --console-run]\n"
|
||||||
"\n");
|
"\n");
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options for tmt/adam:\n");
|
|
||||||
fg = con_fg(f,fg);
|
|
||||||
con_fprintf(f,
|
|
||||||
" --all-methods try all available compression methods\n"
|
|
||||||
" --all-filters try all available preprocessing filters\n"
|
|
||||||
"\n");
|
|
||||||
fg = con_fg(f,FG_YELLOW);
|
|
||||||
con_fprintf(f,"Options for vmlinuz/386\n");
|
|
||||||
fg = con_fg(f,fg);
|
|
||||||
con_fprintf(f,
|
|
||||||
" --all-methods try all available compression methods\n"
|
|
||||||
" --all-filters try all available preprocessing filters\n"
|
|
||||||
"\n");
|
|
||||||
fg = con_fg(f,FG_YELLOW);
|
|
||||||
con_fprintf(f,"Options for watcom/le:\n");
|
con_fprintf(f,"Options for watcom/le:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --le produce LE output [default: EXE]\n"
|
" --le produce LE output [default: EXE]\n"
|
||||||
"\n");
|
"\n");
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options for win32/pe & rtm32/pe:\n");
|
con_fprintf(f,"Options for win32/pe, win64/pe, rtm32/pe & arm/pe:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --compress-exports=0 do not compress the export section\n"
|
" --compress-exports=0 do not compress the export section\n"
|
||||||
@@ -228,58 +286,45 @@ void show_help(int x)
|
|||||||
" --compress-icons=0 do not compress any icons\n"
|
" --compress-icons=0 do not compress any icons\n"
|
||||||
" --compress-icons=1 compress all but the first icon\n"
|
" --compress-icons=1 compress all but the first icon\n"
|
||||||
" --compress-icons=2 compress all but the first icon directory [default]\n"
|
" --compress-icons=2 compress all but the first icon directory [default]\n"
|
||||||
|
" --compress-icons=3 compress all icons\n"
|
||||||
" --compress-resources=0 do not compress any resources at all\n"
|
" --compress-resources=0 do not compress any resources at all\n"
|
||||||
|
" --keep-resource=list do not compress resources specified by list\n"
|
||||||
" --strip-relocs=0 do not strip relocations\n"
|
" --strip-relocs=0 do not strip relocations\n"
|
||||||
" --strip-relocs=1 strip relocations [default]\n"
|
" --strip-relocs=1 strip relocations [default]\n"
|
||||||
" --all-methods try all available compression methods\n"
|
"\n");
|
||||||
" --all-filters try all available preprocessing filters\n"
|
fg = con_fg(f,FG_YELLOW);
|
||||||
|
con_fprintf(f,"Options for linux/elf:\n");
|
||||||
|
fg = con_fg(f,fg);
|
||||||
|
con_fprintf(f,
|
||||||
|
" --preserve-build-id copy .gnu.note.build-id to compressed output\n"
|
||||||
"\n");
|
"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
con_fprintf(f,
|
con_fprintf(f, "file.. executables to (de)compress\n");
|
||||||
"file.. executables to (de)compress\n"
|
|
||||||
"\n");
|
if (verbose > 0)
|
||||||
|
{
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"This version supports:\n");
|
con_fprintf(f,"\nThis version supports:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f," "
|
show_all_packers(f, verbose);
|
||||||
// TODO:
|
}
|
||||||
// support for mach/ppc32
|
else
|
||||||
// support for linux elf/ppc32
|
{
|
||||||
// support for linux elf/amd64
|
con_fprintf(f,"\nType '%s --help' for more detailed help.\n", progname);
|
||||||
" arm/pe,"
|
}
|
||||||
" atari/tos,"
|
|
||||||
" bvmlinuz/386,"
|
con_fprintf(f,"\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit https://upx.github.io\n"
|
||||||
" djgpp2/coff,"
|
// "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type 'upx -L'.\n"
|
||||||
" dos/com,"
|
|
||||||
" dos/exe,"
|
|
||||||
" dos/sys,"
|
|
||||||
"\n "
|
|
||||||
//" elks/8086,"
|
|
||||||
" linux/386,"
|
|
||||||
" linux/elf386,"
|
|
||||||
" linux/sh386,"
|
|
||||||
" ps1/exe,"
|
|
||||||
" rtm32/pe,"
|
|
||||||
" tmt/adam,"
|
|
||||||
"\n "
|
|
||||||
" vmlinux/386,"
|
|
||||||
" vmlinuz/386,"
|
|
||||||
" watcom/le,"
|
|
||||||
//" win16/ne,"
|
|
||||||
" win32/pe"
|
|
||||||
"\n\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.sf.net\n"
|
|
||||||
// "\n\nUPX comes with ABSOLUTELY NO WARRANTY; for details type `upx -L'.\n"
|
|
||||||
"");
|
"");
|
||||||
|
|
||||||
|
#if (DEBUG) || (TESTING)
|
||||||
#if defined(DEBUG) || defined(TESTING)
|
|
||||||
fg = con_fg(f,FG_RED);
|
fg = con_fg(f,FG_RED);
|
||||||
con_fprintf(f,"\nWARNING: this version is compiled with"
|
con_fprintf(f,"\nWARNING: this version is compiled with"
|
||||||
#if defined(DEBUG)
|
#if (DEBUG)
|
||||||
" -DDEBUG"
|
" -DDEBUG"
|
||||||
#endif
|
#endif
|
||||||
#if defined(TESTING)
|
#if (TESTING)
|
||||||
" -DTESTING"
|
" -DTESTING"
|
||||||
#endif
|
#endif
|
||||||
"\n");
|
"\n");
|
||||||
@@ -316,14 +361,14 @@ void show_license(void)
|
|||||||
);
|
);
|
||||||
int fg = con_fg(f,FG_CYAN);
|
int fg = con_fg(f,FG_CYAN);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" http://upx.sourceforge.net\n"
|
" https://upx.github.io\n"
|
||||||
" http://www.oberhumer.com/opensource/upx/\n"
|
" http://www.oberhumer.com/opensource/upx/\n"
|
||||||
);
|
);
|
||||||
(void)con_fg(f,FG_ORANGE);
|
(void)con_fg(f,FG_ORANGE);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
"\n"
|
"\n"
|
||||||
" Markus F.X.J. Oberhumer Laszlo Molnar\n"
|
" Markus F.X.J. Oberhumer Laszlo Molnar\n"
|
||||||
" <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>\n"
|
" <markus@oberhumer.com> <ezerotven+github@gmail.com>\n"
|
||||||
);
|
);
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
|
|
||||||
@@ -337,29 +382,47 @@ void show_license(void)
|
|||||||
|
|
||||||
void show_version(int x)
|
void show_version(int x)
|
||||||
{
|
{
|
||||||
FILE *f = stdout;
|
FILE *fp = stdout;
|
||||||
|
const char *v;
|
||||||
UNUSED(x);
|
UNUSED(x);
|
||||||
|
UNUSED(v);
|
||||||
|
|
||||||
#if (0 && ACC_CC_GNUC)
|
fprintf(fp, "upx %s\n", UPX_VERSION_STRING
|
||||||
fprintf(f,"upx %s (gcc 0x%06lx)\n", UPX_VERSION_STRING, ACC_CC_GNUC);
|
#if defined(UPX_VERSION_GITREV)
|
||||||
#else
|
"-git-" UPX_VERSION_GITREV
|
||||||
fprintf(f,"upx %s\n", UPX_VERSION_STRING);
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_NRV)
|
);
|
||||||
fprintf(f,"NRV data compression library %s\n", nrv_version_string());
|
#if (WITH_NRV)
|
||||||
|
v = upx_nrv_version_string();
|
||||||
|
if (v != NULL && v[0])
|
||||||
|
fprintf(fp, "NRV data compression library %s\n", v);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_UCL)
|
#if (WITH_UCL)
|
||||||
fprintf(f,"UCL data compression library %s\n", ucl_version_string());
|
v = upx_ucl_version_string();
|
||||||
|
if (v != NULL && v[0])
|
||||||
|
fprintf(fp, "UCL data compression library %s\n", v);
|
||||||
#endif
|
#endif
|
||||||
fprintf(f,"Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer\n");
|
#if (WITH_ZLIB)
|
||||||
fprintf(f,"Copyright (C) 1996-2006 Laszlo Molnar\n");
|
v = upx_zlib_version_string();
|
||||||
fprintf(f,"Copyright (C) 2000-2006 John F. Reiser\n");
|
if (v != NULL && v[0])
|
||||||
fprintf(f,"Copyright (C) 2002-2006 Jens Medoch\n");
|
fprintf(fp, "zlib data compression library %s\n", v);
|
||||||
fprintf(f,"UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname);
|
#endif
|
||||||
|
#if (WITH_LZMA)
|
||||||
|
v = upx_lzma_version_string();
|
||||||
|
if (v != NULL && v[0])
|
||||||
|
fprintf(fp, "LZMA SDK version %s\n", v);
|
||||||
|
#endif
|
||||||
|
fprintf(fp, "Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer\n");
|
||||||
|
fprintf(fp, "Copyright (C) 1996-2020 Laszlo Molnar\n");
|
||||||
|
fprintf(fp, "Copyright (C) 2000-2020 John F. Reiser\n");
|
||||||
|
fprintf(fp, "Copyright (C) 2002-2020 Jens Medoch\n");
|
||||||
|
#if (WITH_ZLIB)
|
||||||
|
fprintf(fp, "Copyright (C) 1995" "-2005 Jean-loup Gailly and Mark Adler\n");
|
||||||
|
#endif
|
||||||
|
#if (WITH_LZMA)
|
||||||
|
fprintf(fp, "Copyright (C) 1999" "-2006 Igor Pavlov\n");
|
||||||
|
#endif
|
||||||
|
fprintf(fp, "UPX comes with ABSOLUTELY NO WARRANTY; for details type '%s -L'.\n", progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+5
-8
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -338,6 +338,7 @@ void LeFile::countFixups(unsigned *counts) const
|
|||||||
break;
|
break;
|
||||||
case 6: // 16:32 pointer
|
case 6: // 16:32 pointer
|
||||||
counts[o] += 9;
|
counts[o] += 9;
|
||||||
|
// fall through
|
||||||
case 7: // 32-bit offset
|
case 7: // 32-bit offset
|
||||||
counts[fix[4]-1] += 4;
|
counts[fix[4]-1] += 4;
|
||||||
fix += (fix[1] & 0x10) ? 9 : 7;
|
fix += (fix[1] & 0x10) ? 9 : 7;
|
||||||
@@ -360,8 +361,4 @@ void LeFile::countFixups(unsigned *counts) const
|
|||||||
counts[o+1] += 4; // extra space for 0xFFFFFFFF
|
counts[o+1] += 4; // extra space for 0xFFFFFFFF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+15
-24
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_LEFILE_H
|
#ifndef __UPX_LEFILE_H
|
||||||
#define __UPX_LEFILE_H
|
#define __UPX_LEFILE_H 1
|
||||||
|
|
||||||
class InputFile;
|
class InputFile;
|
||||||
class OutputFile;
|
class OutputFile;
|
||||||
@@ -49,8 +49,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
enum { FIXUP_EXTRA = 3 };
|
enum { FIXUP_EXTRA = 3 };
|
||||||
|
|
||||||
struct le_header_t
|
__packed_struct(le_header_t)
|
||||||
{ // 0x00
|
// 0x00
|
||||||
char _[2]; // signature: 'LE' || 'LX'
|
char _[2]; // signature: 'LE' || 'LX'
|
||||||
char byte_order; // 0 little endian
|
char byte_order; // 0 little endian
|
||||||
char word_order; // 0 little endian
|
char word_order; // 0 little endian
|
||||||
@@ -112,33 +112,28 @@ protected:
|
|||||||
LE32 extra_heap_alloc;
|
LE32 extra_heap_alloc;
|
||||||
char reserved[12];
|
char reserved[12];
|
||||||
LE32 versioninfo;
|
LE32 versioninfo;
|
||||||
LE32 unkown;
|
LE32 unknown;
|
||||||
// 0xC0
|
// 0xC0
|
||||||
LE16 device_id;
|
LE16 device_id;
|
||||||
LE16 ddk_version;
|
LE16 ddk_version;
|
||||||
#endif
|
#endif
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct le_object_table_entry_t
|
__packed_struct(le_object_table_entry_t)
|
||||||
{
|
|
||||||
LE32 virtual_size;
|
LE32 virtual_size;
|
||||||
LE32 base_address;
|
LE32 base_address;
|
||||||
LE32 flags;
|
LE32 flags;
|
||||||
LE32 pagemap_index;
|
LE32 pagemap_index;
|
||||||
LE32 npages;
|
LE32 npages;
|
||||||
LE32 reserved;
|
LE32 reserved;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct le_pagemap_entry_t
|
__packed_struct(le_pagemap_entry_t)
|
||||||
{
|
|
||||||
unsigned char h;
|
unsigned char h;
|
||||||
unsigned char m;
|
unsigned char m;
|
||||||
unsigned char l;
|
unsigned char l;
|
||||||
unsigned char type; // 0x00-legal;0x40-iterated;0x80-invalid;0xC0-zeroed
|
unsigned char type; // 0x00-legal;0x40-iterated;0x80-invalid;0xC0-zeroed
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
virtual void readObjectTable();
|
virtual void readObjectTable();
|
||||||
virtual void writeObjectTable();
|
virtual void writeObjectTable();
|
||||||
@@ -185,8 +180,8 @@ protected:
|
|||||||
|
|
||||||
InputFile *fif;
|
InputFile *fif;
|
||||||
OutputFile *fof;
|
OutputFile *fof;
|
||||||
long le_offset;
|
unsigned le_offset;
|
||||||
long exe_offset;
|
unsigned exe_offset;
|
||||||
|
|
||||||
le_header_t ih;
|
le_header_t ih;
|
||||||
le_header_t oh;
|
le_header_t oh;
|
||||||
@@ -226,8 +221,4 @@ private:
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+837
-183
File diff suppressed because it is too large
Load Diff
+230
-56
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,76 +22,250 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_LINKER_H
|
#ifndef __UPX_LINKER_H
|
||||||
#define __UPX_LINKER_H
|
#define __UPX_LINKER_H 1
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// ElfLinker
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
class ElfLinker : private noncopyable {
|
||||||
|
friend class Packer;
|
||||||
|
|
||||||
class Linker
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Linker(const void *pdata, int plen, int pinfo);
|
const N_BELE_RTP::AbstractPolicy *bele; // target endianness
|
||||||
virtual ~Linker();
|
protected:
|
||||||
int addSection(const char *sect);
|
struct Section;
|
||||||
void addSection(const char *sname, const void *sdata, unsigned len);
|
struct Symbol;
|
||||||
const char *getLoader(int *llen);
|
struct Relocation;
|
||||||
int getSection(const char *name, int *slen) const;
|
|
||||||
int getLoaderSize() const { return olen; }
|
upx_byte *input;
|
||||||
void setLoaderAlignOffset(int phase);
|
int inputlen;
|
||||||
|
upx_byte *output;
|
||||||
|
int outputlen;
|
||||||
|
|
||||||
|
Section *head;
|
||||||
|
Section *tail;
|
||||||
|
|
||||||
|
Section **sections;
|
||||||
|
Symbol **symbols;
|
||||||
|
Relocation **relocations;
|
||||||
|
|
||||||
|
unsigned nsections;
|
||||||
|
unsigned nsections_capacity;
|
||||||
|
unsigned nsymbols;
|
||||||
|
unsigned nsymbols_capacity;
|
||||||
|
unsigned nrelocations;
|
||||||
|
unsigned nrelocations_capacity;
|
||||||
|
|
||||||
|
bool reloc_done;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// little endian
|
void preprocessSections(char *start, char *end);
|
||||||
virtual unsigned get32(const void *b) const { return get_le32(b); }
|
void preprocessSymbols(char *start, char *end);
|
||||||
virtual void set32(void *b, unsigned v) const { set_le32(b, v); }
|
void preprocessRelocations(char *start, char *end);
|
||||||
|
Section *findSection(const char *name, bool fatal = true) const;
|
||||||
|
Symbol *findSymbol(const char *name, bool fatal = true) const;
|
||||||
|
|
||||||
private:
|
Symbol *addSymbol(const char *name, const char *section, upx_uint64_t offset);
|
||||||
struct section;
|
Relocation *addRelocation(const char *section, unsigned off, const char *type,
|
||||||
struct jump;
|
const char *symbol, upx_uint64_t add);
|
||||||
|
|
||||||
char *iloader, *oloader;
|
|
||||||
int ilen, olen;
|
|
||||||
int info;
|
|
||||||
jump *jumps;
|
|
||||||
int njumps;
|
|
||||||
section *sections;
|
|
||||||
int nsections;
|
|
||||||
int frozen;
|
|
||||||
int align_hack;
|
|
||||||
int align_offset;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// disable copy and assignment
|
|
||||||
Linker(const Linker &); // {}
|
|
||||||
Linker& operator= (const Linker &); // { return *this; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class BeLinker : public Linker
|
|
||||||
{
|
|
||||||
typedef Linker super;
|
|
||||||
public:
|
public:
|
||||||
BeLinker(const void *pdata, int plen, int pinfo) :
|
ElfLinker();
|
||||||
super(pdata, plen, pinfo) { }
|
virtual ~ElfLinker();
|
||||||
|
|
||||||
|
virtual void init(const void *pdata, int plen);
|
||||||
|
// virtual void setLoaderAlignOffset(int phase);
|
||||||
|
virtual int addLoader(const char *sname);
|
||||||
|
void addLoader(const char *s, va_list ap);
|
||||||
|
#if 1 && (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x040100))
|
||||||
|
void __acc_cdecl_va addLoaderVA(const char *s, ...) __attribute__((__sentinel__));
|
||||||
|
#else
|
||||||
|
void __acc_cdecl_va addLoaderVA(const char *s, ...);
|
||||||
|
#endif
|
||||||
|
virtual Section *addSection(const char *sname, const void *sdata, int slen, unsigned p2align);
|
||||||
|
virtual int getSection(const char *sname, int *slen = NULL) const;
|
||||||
|
virtual int getSectionSize(const char *sname) const;
|
||||||
|
virtual upx_byte *getLoader(int *llen = NULL) const;
|
||||||
|
virtual void defineSymbol(const char *name, upx_uint64_t value);
|
||||||
|
virtual upx_uint64_t getSymbolOffset(const char *) const;
|
||||||
|
|
||||||
|
virtual void dumpSymbol(const Symbol *, unsigned flags, FILE *fp) const;
|
||||||
|
virtual void dumpSymbols(unsigned flags = 0, FILE *fp = NULL) const;
|
||||||
|
|
||||||
|
void alignWithByte(unsigned len, unsigned char b);
|
||||||
|
virtual void alignCode(unsigned len) { alignWithByte(len, 0); }
|
||||||
|
virtual void alignData(unsigned len) { alignWithByte(len, 0); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// big endian
|
virtual void relocate();
|
||||||
virtual unsigned get32(const void *b) const { return get_be32(b); }
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
virtual void set32(void *b, unsigned v) const { set_be32(b, v); }
|
const char *type);
|
||||||
|
|
||||||
private:
|
// target endianness abstraction
|
||||||
// disable copy and assignment
|
unsigned get_te16(const void *p) const { return bele->get16(p); }
|
||||||
BeLinker(const BeLinker &); // {}
|
unsigned get_te32(const void *p) const { return bele->get32(p); }
|
||||||
BeLinker& operator= (const BeLinker &); // { return *this; }
|
upx_uint64_t get_te64(const void *p) const { return bele->get64(p); }
|
||||||
|
void set_te16(void *p, unsigned v) const { bele->set16(p, v); }
|
||||||
|
void set_te32(void *p, unsigned v) const { bele->set32(p, v); }
|
||||||
|
void set_te64(void *p, upx_uint64_t v) const { bele->set64(p, v); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ElfLinker::Section : private noncopyable {
|
||||||
|
char *name;
|
||||||
|
void *input;
|
||||||
|
upx_byte *output;
|
||||||
|
unsigned size;
|
||||||
|
upx_uint64_t offset;
|
||||||
|
unsigned p2align; // log2
|
||||||
|
Section *next;
|
||||||
|
|
||||||
|
Section(const char *n, const void *i, unsigned s, unsigned a = 0);
|
||||||
|
~Section();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ElfLinker::Symbol : private noncopyable {
|
||||||
|
char *name;
|
||||||
|
Section *section;
|
||||||
|
upx_uint64_t offset;
|
||||||
|
|
||||||
|
Symbol(const char *n, Section *s, upx_uint64_t o);
|
||||||
|
~Symbol();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ElfLinker::Relocation : private noncopyable {
|
||||||
|
const Section *section;
|
||||||
|
unsigned offset;
|
||||||
|
const char *type;
|
||||||
|
const Symbol *value;
|
||||||
|
upx_uint64_t add; // used in .rela relocations
|
||||||
|
|
||||||
|
Relocation(const Section *s, unsigned o, const char *t, const Symbol *v, upx_uint64_t a);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// ElfLinker arch subclasses
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
class ElfLinkerAMD64 : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerARM64 : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerArmBE : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ElfLinkerArmBE() { bele = &N_BELE_RTP::be_policy; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerArmLE : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerArm64LE : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerM68k : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ElfLinkerM68k() { bele = &N_BELE_RTP::be_policy; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void alignCode(unsigned len);
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerMipsBE : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ElfLinkerMipsBE() { bele = &N_BELE_RTP::be_policy; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerMipsLE : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerPpc32 : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ElfLinkerPpc32() { bele = &N_BELE_RTP::be_policy; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerPpc64le : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerPpc64 : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ElfLinkerPpc64() { bele = &N_BELE_RTP::be_policy; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ElfLinkerX86 : public ElfLinker {
|
||||||
|
typedef ElfLinker super;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
|
||||||
|
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
|
||||||
|
const char *type);
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
Submodule
+1
Submodule src/lzma-sdk added at 426fe82d12
+430
-198
File diff suppressed because it is too large
Load Diff
+70
-60
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -31,38 +31,37 @@
|
|||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
// bool use_simple_mcheck()
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
static int use_mcheck = -1;
|
#if defined(__SANITIZE_ADDRESS__)
|
||||||
|
__acc_static_forceinline bool use_simple_mcheck() { return false; }
|
||||||
static int mcheck_init()
|
#elif (WITH_VALGRIND) && defined(RUNNING_ON_VALGRIND)
|
||||||
{
|
static int use_simple_mcheck_flag = -1;
|
||||||
if (use_mcheck < 0)
|
__acc_static_noinline void use_simple_mcheck_init()
|
||||||
{
|
|
||||||
use_mcheck = 1;
|
|
||||||
#if defined(WITH_VALGRIND) && defined(RUNNING_ON_VALGRIND)
|
|
||||||
if (RUNNING_ON_VALGRIND)
|
|
||||||
{
|
{
|
||||||
|
use_simple_mcheck_flag = 1;
|
||||||
|
if (RUNNING_ON_VALGRIND) {
|
||||||
|
use_simple_mcheck_flag = 0;
|
||||||
//fprintf(stderr, "upx: detected RUNNING_ON_VALGRIND\n");
|
//fprintf(stderr, "upx: detected RUNNING_ON_VALGRIND\n");
|
||||||
use_mcheck = 0;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
__acc_static_forceinline bool use_simple_mcheck()
|
||||||
|
{
|
||||||
|
if __acc_unlikely(use_simple_mcheck_flag < 0)
|
||||||
|
use_simple_mcheck_init();
|
||||||
|
return (bool) use_simple_mcheck_flag;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
__acc_static_forceinline bool use_simple_mcheck() { return true; }
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
return use_mcheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
MemBuffer::MemBuffer() :
|
MemBuffer::MemBuffer(upx_uint64_t size) :
|
||||||
b(NULL), b_size(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MemBuffer::MemBuffer(unsigned size) :
|
|
||||||
b(NULL), b_size(0)
|
b(NULL), b_size(0)
|
||||||
{
|
{
|
||||||
alloc(size);
|
alloc(size);
|
||||||
@@ -74,12 +73,24 @@ MemBuffer::~MemBuffer()
|
|||||||
this->dealloc();
|
this->dealloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// similar to BoundedPtr, except checks only at creation
|
||||||
|
unsigned char *MemBuffer::subref(char const *errfmt, unsigned skip, unsigned take)
|
||||||
|
{
|
||||||
|
if ((take + skip) < take // wrap-around
|
||||||
|
|| (take + skip) > b_size // overrun
|
||||||
|
) {
|
||||||
|
char buf[100]; snprintf(buf, sizeof(buf), errfmt, skip, take);
|
||||||
|
throwCantPack(buf);
|
||||||
|
}
|
||||||
|
return &b[skip];
|
||||||
|
}
|
||||||
|
|
||||||
void MemBuffer::dealloc()
|
void MemBuffer::dealloc()
|
||||||
{
|
{
|
||||||
if (b)
|
if (b != NULL)
|
||||||
{
|
{
|
||||||
checkState();
|
checkState();
|
||||||
if (use_mcheck)
|
if (use_simple_mcheck())
|
||||||
{
|
{
|
||||||
// remove magic constants
|
// remove magic constants
|
||||||
set_be32(b - 8, 0);
|
set_be32(b - 8, 0);
|
||||||
@@ -87,7 +98,7 @@ void MemBuffer::dealloc()
|
|||||||
set_be32(b + b_size, 0);
|
set_be32(b + b_size, 0);
|
||||||
set_be32(b + b_size + 4, 0);
|
set_be32(b + b_size + 4, 0);
|
||||||
//
|
//
|
||||||
::free(b - 8);
|
::free(b - 16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::free(b);
|
::free(b);
|
||||||
@@ -99,25 +110,34 @@ void MemBuffer::dealloc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned MemBuffer::getSizeForCompression(unsigned uncompressed_size, unsigned extra)
|
||||||
|
{
|
||||||
|
size_t bytes = mem_size(1, uncompressed_size, extra);
|
||||||
|
bytes += uncompressed_size/8 + 256;
|
||||||
|
return ACC_ICONV(unsigned, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned MemBuffer::getSizeForUncompression(unsigned uncompressed_size, unsigned extra)
|
||||||
|
{
|
||||||
|
size_t bytes = mem_size(1, uncompressed_size, extra);
|
||||||
|
// INFO: 3 bytes are the allowed overrun for the i386 asm_fast decompressors
|
||||||
|
#if (ACC_ARCH_I386)
|
||||||
|
bytes += 3;
|
||||||
|
#endif
|
||||||
|
return ACC_ICONV(unsigned, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MemBuffer::allocForCompression(unsigned uncompressed_size, unsigned extra)
|
void MemBuffer::allocForCompression(unsigned uncompressed_size, unsigned extra)
|
||||||
{
|
{
|
||||||
assert((int)uncompressed_size > 0);
|
unsigned size = getSizeForCompression(uncompressed_size, extra);
|
||||||
assert((int)extra >= 0);
|
|
||||||
unsigned size = uncompressed_size + uncompressed_size/8 + 256 + extra;
|
|
||||||
alloc(size);
|
alloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MemBuffer::allocForUncompression(unsigned uncompressed_size, unsigned extra)
|
void MemBuffer::allocForUncompression(unsigned uncompressed_size, unsigned extra)
|
||||||
{
|
{
|
||||||
assert((int)uncompressed_size > 0);
|
unsigned size = getSizeForUncompression(uncompressed_size, extra);
|
||||||
assert((int)extra >= 0);
|
|
||||||
unsigned size = uncompressed_size + extra;
|
|
||||||
// size += 512; // 512 safety bytes
|
|
||||||
// INFO: 3 bytes are the allowed overrun for the i386 asm_fast decompressors
|
|
||||||
#if (ACC_ARCH_I386)
|
|
||||||
size += 3;
|
|
||||||
#endif
|
|
||||||
alloc(size);
|
alloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +159,7 @@ void MemBuffer::fill(unsigned off, unsigned len, int value)
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#define PTR(p) ((unsigned) ((acc_uintptr_t)(p) & 0xffffffff))
|
#define PTR(p) ((unsigned) ((upx_uintptr_t)(p) & 0xffffffff))
|
||||||
#define MAGIC1(p) (PTR(p) ^ 0xfefdbeeb)
|
#define MAGIC1(p) (PTR(p) ^ 0xfefdbeeb)
|
||||||
#define MAGIC2(p) (PTR(p) ^ 0xfefdbeeb ^ 0x80024001)
|
#define MAGIC2(p) (PTR(p) ^ 0xfefdbeeb ^ 0x80024001)
|
||||||
|
|
||||||
@@ -150,7 +170,7 @@ void MemBuffer::checkState() const
|
|||||||
{
|
{
|
||||||
if (!b)
|
if (!b)
|
||||||
throwInternalError("block not allocated");
|
throwInternalError("block not allocated");
|
||||||
if (use_mcheck)
|
if (use_simple_mcheck())
|
||||||
{
|
{
|
||||||
if (get_be32(b - 4) != MAGIC1(b))
|
if (get_be32(b - 4) != MAGIC1(b))
|
||||||
throwInternalError("memory clobbered before allocated block 1");
|
throwInternalError("memory clobbered before allocated block 1");
|
||||||
@@ -163,29 +183,21 @@ void MemBuffer::checkState() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MemBuffer::alloc(unsigned size)
|
void MemBuffer::alloc(upx_uint64_t size)
|
||||||
{
|
{
|
||||||
if (use_mcheck < 0)
|
|
||||||
mcheck_init();
|
|
||||||
|
|
||||||
// NOTE: we don't automatically free a used buffer
|
// NOTE: we don't automatically free a used buffer
|
||||||
assert(b == NULL);
|
assert(b == NULL);
|
||||||
assert(b_size == 0);
|
assert(b_size == 0);
|
||||||
//
|
//
|
||||||
assert((int)size > 0);
|
assert(size > 0);
|
||||||
unsigned total = use_mcheck ? size + 16 : size;
|
size_t bytes = mem_size(1, size, use_simple_mcheck() ? 32 : 0);
|
||||||
assert((int)total > 0);
|
unsigned char *p = (unsigned char *) malloc(bytes);
|
||||||
unsigned char *p = (unsigned char *) malloc(total);
|
|
||||||
if (!p)
|
if (!p)
|
||||||
|
throwOutOfMemoryException();
|
||||||
|
b_size = ACC_ICONV(unsigned, size);
|
||||||
|
if (use_simple_mcheck())
|
||||||
{
|
{
|
||||||
//throw bad_alloc();
|
b = p + 16;
|
||||||
throw OutOfMemoryException("out of memory");
|
|
||||||
//exit(1);
|
|
||||||
}
|
|
||||||
b_size = size;
|
|
||||||
if (use_mcheck)
|
|
||||||
{
|
|
||||||
b = p + 8;
|
|
||||||
// store magic constants to detect buffer overruns
|
// store magic constants to detect buffer overruns
|
||||||
set_be32(b - 8, b_size);
|
set_be32(b - 8, b_size);
|
||||||
set_be32(b - 4, MAGIC1(b));
|
set_be32(b - 4, MAGIC1(b));
|
||||||
@@ -194,10 +206,8 @@ void MemBuffer::alloc(unsigned size)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
b = p ;
|
b = p ;
|
||||||
|
|
||||||
|
//fill(0, b_size, (rand() & 0xff) | 1); // debug
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_MEM_H
|
#ifndef __UPX_MEM_H
|
||||||
#define __UPX_MEM_H
|
#define __UPX_MEM_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -37,11 +37,14 @@
|
|||||||
class MemBuffer
|
class MemBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MemBuffer();
|
MemBuffer() : b(NULL), b_size(0) { }
|
||||||
MemBuffer(unsigned size);
|
explicit MemBuffer(upx_uint64_t size);
|
||||||
~MemBuffer();
|
~MemBuffer();
|
||||||
|
|
||||||
void alloc(unsigned size);
|
static unsigned getSizeForCompression(unsigned uncompressed_size, unsigned extra=0);
|
||||||
|
static unsigned getSizeForUncompression(unsigned uncompressed_size, unsigned extra=0);
|
||||||
|
|
||||||
|
void alloc(upx_uint64_t size);
|
||||||
void allocForCompression(unsigned uncompressed_size, unsigned extra=0);
|
void allocForCompression(unsigned uncompressed_size, unsigned extra=0);
|
||||||
void allocForUncompression(unsigned uncompressed_size, unsigned extra=0);
|
void allocForUncompression(unsigned uncompressed_size, unsigned extra=0);
|
||||||
|
|
||||||
@@ -52,7 +55,8 @@ public:
|
|||||||
unsigned getSize() const { return b_size; }
|
unsigned getSize() const { return b_size; }
|
||||||
|
|
||||||
operator unsigned char * () { return b; }
|
operator unsigned char * () { return b; }
|
||||||
//operator const unsigned char * () const { return b; }
|
operator const unsigned char * () const { return b; }
|
||||||
|
|
||||||
void *getVoidPtr() { return (void *) b; }
|
void *getVoidPtr() { return (void *) b; }
|
||||||
const void *getVoidPtr() const { return (const void *) b; }
|
const void *getVoidPtr() const { return (const void *) b; }
|
||||||
|
|
||||||
@@ -60,6 +64,11 @@ public:
|
|||||||
void clear(unsigned off, unsigned len) { fill(off, len, 0); }
|
void clear(unsigned off, unsigned len) { fill(off, len, 0); }
|
||||||
void clear() { fill(0, b_size, 0); }
|
void clear() { fill(0, b_size, 0); }
|
||||||
|
|
||||||
|
// If the entire range [skip, take+skip) is inside the buffer,
|
||||||
|
// then return &b[skip]; else throwCantPack(sprintf(errfmt, skip, take)).
|
||||||
|
// This is similar to BoundedPtr, except only checks once.
|
||||||
|
unsigned char *subref(char const *errfmt, unsigned skip, unsigned take);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned char *b;
|
unsigned char *b;
|
||||||
unsigned b_size;
|
unsigned b_size;
|
||||||
@@ -76,8 +85,4 @@ private:
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+3711
-1992
File diff suppressed because it is too large
Load Diff
+5
-9
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ void printClearLine(FILE *f)
|
|||||||
fflush(stdout); fflush(stderr);
|
fflush(stdout); fflush(stderr);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
f = stdout;
|
f = stdout;
|
||||||
con_fprintf(f,clear_line_msg);
|
con_fprintf(f, "%s", clear_line_msg);
|
||||||
fflush(f);
|
fflush(f);
|
||||||
printSetNl(0);
|
printSetNl(0);
|
||||||
}
|
}
|
||||||
@@ -253,8 +253,4 @@ void infoWriting(const char *what, long size)
|
|||||||
info("Writing %s: %ld bytes", what, size);
|
info("Writing %s: %ld bytes", what, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,706 +0,0 @@
|
|||||||
/* Getopt for GNU.
|
|
||||||
NOTE: getopt is now part of the C library, so if you don't know what
|
|
||||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
|
||||||
before changing it!
|
|
||||||
|
|
||||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation; either version 2, 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; if not, write to the Free Software
|
|
||||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef PROGNAME
|
|
||||||
#if 0
|
|
||||||
#ifndef EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#define PROGNAME(x) (x)
|
|
||||||
#else
|
|
||||||
#include "conf.h"
|
|
||||||
static const char *my_progname(const char *argv0)
|
|
||||||
{
|
|
||||||
return progname ? progname : argv0;
|
|
||||||
}
|
|
||||||
#define PROGNAME(x) my_progname(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
|
|
||||||
long-named option. Because this is not POSIX.2 compliant, it is
|
|
||||||
being phased out. */
|
|
||||||
/* #define GETOPT_COMPAT */
|
|
||||||
#undef GETOPT_COMPAT
|
|
||||||
|
|
||||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
|
||||||
but it behaves differently for the user, since it allows the user
|
|
||||||
to intersperse the options with the other arguments.
|
|
||||||
|
|
||||||
As `getopt' works, it permutes the elements of ARGV so that,
|
|
||||||
when it is done, all the options precede everything else. Thus
|
|
||||||
all application programs are extended to handle flexible argument order.
|
|
||||||
|
|
||||||
Setting the environment variable POSIXLY_CORRECT disables permutation.
|
|
||||||
Then the behavior is completely standard.
|
|
||||||
|
|
||||||
GNU application programs can use a third alternative mode in which
|
|
||||||
they can distinguish the relative order of options and other arguments. */
|
|
||||||
|
|
||||||
#include "mygetopt.h"
|
|
||||||
#define option mfx_option
|
|
||||||
#define optarg mfx_optarg
|
|
||||||
#define optind mfx_optind
|
|
||||||
#define opterr mfx_opterr
|
|
||||||
#define optopt mfx_optopt
|
|
||||||
#undef BAD_OPTION
|
|
||||||
|
|
||||||
/* For communication from `getopt' to the caller.
|
|
||||||
When `getopt' finds an option that takes an argument,
|
|
||||||
the argument value is returned here.
|
|
||||||
Also, when `ordering' is RETURN_IN_ORDER,
|
|
||||||
each non-option ARGV-element is returned here. */
|
|
||||||
|
|
||||||
char *optarg = NULL;
|
|
||||||
|
|
||||||
/* Index in ARGV of the next element to be scanned.
|
|
||||||
This is used for communication to and from the caller
|
|
||||||
and for communication between successive calls to `getopt'.
|
|
||||||
|
|
||||||
On entry to `getopt', zero means this is the first call; initialize.
|
|
||||||
|
|
||||||
When `getopt' returns EOF, this is the index of the first of the
|
|
||||||
non-option elements that the caller should itself scan.
|
|
||||||
|
|
||||||
Otherwise, `optind' communicates from one call to the next
|
|
||||||
how much of ARGV has been scanned so far. */
|
|
||||||
|
|
||||||
/* XXX 1003.2 says this must be 1 before any call. */
|
|
||||||
int optind = 0;
|
|
||||||
|
|
||||||
/* The next char to be scanned in the option-element
|
|
||||||
in which the last option character we returned was found.
|
|
||||||
This allows us to pick up the scan where we left off.
|
|
||||||
|
|
||||||
If this is zero, or a null string, it means resume the scan
|
|
||||||
by advancing to the next ARGV-element. */
|
|
||||||
|
|
||||||
static char *nextchar;
|
|
||||||
|
|
||||||
/* Callers store zero here to inhibit the error message
|
|
||||||
for unrecognized options. */
|
|
||||||
|
|
||||||
int opterr = 1;
|
|
||||||
|
|
||||||
/* Set to an option character which was unrecognized.
|
|
||||||
This must be initialized on some systems to avoid linking in the
|
|
||||||
system's own getopt implementation. */
|
|
||||||
|
|
||||||
#define BAD_OPTION '\0'
|
|
||||||
int optopt = BAD_OPTION;
|
|
||||||
|
|
||||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
|
||||||
|
|
||||||
If the caller did not specify anything,
|
|
||||||
the default is REQUIRE_ORDER if the environment variable
|
|
||||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
|
||||||
|
|
||||||
REQUIRE_ORDER means don't recognize them as options;
|
|
||||||
stop option processing when the first non-option is seen.
|
|
||||||
This is what Unix does.
|
|
||||||
This mode of operation is selected by either setting the environment
|
|
||||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
|
||||||
of the list of option characters.
|
|
||||||
|
|
||||||
PERMUTE is the default. We permute the contents of ARGV as we scan,
|
|
||||||
so that eventually all the non-options are at the end. This allows options
|
|
||||||
to be given in any order, even with programs that were not written to
|
|
||||||
expect this.
|
|
||||||
|
|
||||||
RETURN_IN_ORDER is an option available to programs that were written
|
|
||||||
to expect options and other ARGV-elements in any order and that care about
|
|
||||||
the ordering of the two. We describe each non-option ARGV-element
|
|
||||||
as if it were the argument of an option with character code 1.
|
|
||||||
Using `-' as the first character of the list of option characters
|
|
||||||
selects this mode of operation.
|
|
||||||
|
|
||||||
The special argument `--' forces an end of option-scanning regardless
|
|
||||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
|
||||||
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
|
|
||||||
|
|
||||||
static enum
|
|
||||||
{
|
|
||||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
|
||||||
} ordering;
|
|
||||||
|
|
||||||
/* Handle permutation of arguments. */
|
|
||||||
|
|
||||||
/* Describe the part of ARGV that contains non-options that have
|
|
||||||
been skipped. `first_nonopt' is the index in ARGV of the first of them;
|
|
||||||
`last_nonopt' is the index after the last of them. */
|
|
||||||
|
|
||||||
static int first_nonopt;
|
|
||||||
static int last_nonopt;
|
|
||||||
|
|
||||||
/* Exchange two adjacent subsequences of ARGV.
|
|
||||||
One subsequence is elements [first_nonopt,last_nonopt)
|
|
||||||
which contains all the non-options that have been skipped so far.
|
|
||||||
The other is elements [last_nonopt,optind), which contains all
|
|
||||||
the options processed since those non-options were skipped.
|
|
||||||
|
|
||||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
|
||||||
the new indices of the non-options in ARGV after they are moved.
|
|
||||||
|
|
||||||
To perform the swap, we first reverse the order of all elements. So
|
|
||||||
all options now come before all non options, but they are in the
|
|
||||||
wrong order. So we put back the options and non options in original
|
|
||||||
order by reversing them again. For example:
|
|
||||||
original input: a b c -x -y
|
|
||||||
reverse all: -y -x c b a
|
|
||||||
reverse options: -x -y c b a
|
|
||||||
reverse non options: -x -y a b c
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static void exchange (char **argv)
|
|
||||||
{
|
|
||||||
char *temp; char **first, **last;
|
|
||||||
|
|
||||||
/* Reverse all the elements [first_nonopt, optind) */
|
|
||||||
first = &argv[first_nonopt];
|
|
||||||
last = &argv[optind-1];
|
|
||||||
while (first < last) {
|
|
||||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
|
||||||
}
|
|
||||||
/* Put back the options in order */
|
|
||||||
first = &argv[first_nonopt];
|
|
||||||
first_nonopt += (optind - last_nonopt);
|
|
||||||
last = &argv[first_nonopt - 1];
|
|
||||||
while (first < last) {
|
|
||||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put back the non options in order */
|
|
||||||
first = &argv[first_nonopt];
|
|
||||||
last_nonopt = optind;
|
|
||||||
last = &argv[last_nonopt-1];
|
|
||||||
while (first < last) {
|
|
||||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
|
||||||
given in OPTSTRING.
|
|
||||||
|
|
||||||
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
|
||||||
then it is an option element. The characters of this element
|
|
||||||
(aside from the initial '-') are option characters. If `getopt'
|
|
||||||
is called repeatedly, it returns successively each of the option characters
|
|
||||||
from each of the option elements.
|
|
||||||
|
|
||||||
If `getopt' finds another option character, it returns that character,
|
|
||||||
updating `optind' and `nextchar' so that the next call to `getopt' can
|
|
||||||
resume the scan with the following option character or ARGV-element.
|
|
||||||
|
|
||||||
If there are no more option characters, `getopt' returns `EOF'.
|
|
||||||
Then `optind' is the index in ARGV of the first ARGV-element
|
|
||||||
that is not an option. (The ARGV-elements have been permuted
|
|
||||||
so that those that are not options now come last.)
|
|
||||||
|
|
||||||
OPTSTRING is a string containing the legitimate option characters.
|
|
||||||
If an option character is seen that is not listed in OPTSTRING,
|
|
||||||
return BAD_OPTION after printing an error message. If you set `opterr' to
|
|
||||||
zero, the error message is suppressed but we still return BAD_OPTION.
|
|
||||||
|
|
||||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
|
||||||
so the following text in the same ARGV-element, or the text of the following
|
|
||||||
ARGV-element, is returned in `optarg'. Two colons mean an option that
|
|
||||||
wants an optional arg; if there is text in the current ARGV-element,
|
|
||||||
it is returned in `optarg', otherwise `optarg' is set to zero.
|
|
||||||
|
|
||||||
If OPTSTRING starts with `-' or `+', it requests different methods of
|
|
||||||
handling the non-option ARGV-elements.
|
|
||||||
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
|
|
||||||
|
|
||||||
Long-named options begin with `--' instead of `-'.
|
|
||||||
Their names may be abbreviated as long as the abbreviation is unique
|
|
||||||
or is an exact match for some defined option. If they have an
|
|
||||||
argument, it follows the option name in the same ARGV-element, separated
|
|
||||||
from the option name by a `=', or else the in next ARGV-element.
|
|
||||||
When `getopt' finds a long-named option, it returns 0 if that option's
|
|
||||||
`flag' field is nonzero, the value of the option's `val' field
|
|
||||||
if the `flag' field is zero.
|
|
||||||
|
|
||||||
LONGOPTS is a vector of `struct option' terminated by an
|
|
||||||
element containing a name which is zero.
|
|
||||||
|
|
||||||
LONGIND returns the index in LONGOPT of the long-named option found.
|
|
||||||
It is only valid when a long-named option has been found by the most
|
|
||||||
recent call.
|
|
||||||
|
|
||||||
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
|
|
||||||
long-named options. */
|
|
||||||
|
|
||||||
static int _getopt_internal (int argc, char **argv, const char *optstring,
|
|
||||||
const struct option *longopts, int *longind,
|
|
||||||
int long_only)
|
|
||||||
{
|
|
||||||
static char empty_string[1];
|
|
||||||
int option_index;
|
|
||||||
|
|
||||||
if (longind != NULL)
|
|
||||||
*longind = -1;
|
|
||||||
|
|
||||||
optarg = 0;
|
|
||||||
|
|
||||||
/* Initialize the internal data when the first call is made.
|
|
||||||
Start processing options with ARGV-element 1 (since ARGV-element 0
|
|
||||||
is the program name); the sequence of previously skipped
|
|
||||||
non-option ARGV-elements is empty. */
|
|
||||||
|
|
||||||
if (optind == 0)
|
|
||||||
{
|
|
||||||
first_nonopt = last_nonopt = optind = 1;
|
|
||||||
|
|
||||||
nextchar = NULL;
|
|
||||||
|
|
||||||
/* Determine how to handle the ordering of options and nonoptions. */
|
|
||||||
|
|
||||||
if (optstring[0] == '-')
|
|
||||||
{
|
|
||||||
ordering = RETURN_IN_ORDER;
|
|
||||||
++optstring;
|
|
||||||
}
|
|
||||||
else if (optstring[0] == '+')
|
|
||||||
{
|
|
||||||
ordering = REQUIRE_ORDER;
|
|
||||||
++optstring;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
else if (getenv ("POSIXLY_CORRECT") != NULL)
|
|
||||||
ordering = REQUIRE_ORDER;
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
ordering = PERMUTE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextchar == NULL || *nextchar == '\0')
|
|
||||||
{
|
|
||||||
if (ordering == PERMUTE)
|
|
||||||
{
|
|
||||||
/* If we have just processed some options following some non-options,
|
|
||||||
exchange them so that the options come first. */
|
|
||||||
|
|
||||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
|
||||||
exchange (argv);
|
|
||||||
else if (last_nonopt != optind)
|
|
||||||
first_nonopt = optind;
|
|
||||||
|
|
||||||
/* Now skip any additional non-options
|
|
||||||
and extend the range of non-options previously skipped. */
|
|
||||||
|
|
||||||
while (optind < argc
|
|
||||||
&& (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
|
||||||
#ifdef GETOPT_COMPAT
|
|
||||||
&& (longopts == NULL
|
|
||||||
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
|
|
||||||
#endif /* GETOPT_COMPAT */
|
|
||||||
)
|
|
||||||
optind++;
|
|
||||||
last_nonopt = optind;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Special ARGV-element `--' means premature end of options.
|
|
||||||
Skip it like a null option,
|
|
||||||
then exchange with previous non-options as if it were an option,
|
|
||||||
then skip everything else like a non-option. */
|
|
||||||
|
|
||||||
if (optind != argc && !strcmp (argv[optind], "--"))
|
|
||||||
{
|
|
||||||
optind++;
|
|
||||||
|
|
||||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
|
||||||
exchange (argv);
|
|
||||||
else if (first_nonopt == last_nonopt)
|
|
||||||
first_nonopt = optind;
|
|
||||||
last_nonopt = argc;
|
|
||||||
|
|
||||||
optind = argc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we have done all the ARGV-elements, stop the scan
|
|
||||||
and back over any non-options that we skipped and permuted. */
|
|
||||||
|
|
||||||
if (optind == argc)
|
|
||||||
{
|
|
||||||
/* Set the next-arg-index to point at the non-options
|
|
||||||
that we previously skipped, so the caller will digest them. */
|
|
||||||
if (first_nonopt != last_nonopt)
|
|
||||||
optind = first_nonopt;
|
|
||||||
return EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we have come to a non-option and did not permute it,
|
|
||||||
either stop the scan or describe it to the caller and pass it by. */
|
|
||||||
|
|
||||||
if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
|
|
||||||
#ifdef GETOPT_COMPAT
|
|
||||||
&& (longopts == NULL
|
|
||||||
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
|
|
||||||
#endif /* GETOPT_COMPAT */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (ordering == REQUIRE_ORDER)
|
|
||||||
return EOF;
|
|
||||||
optarg = argv[optind++];
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We have found another option-ARGV-element.
|
|
||||||
Start decoding its characters. */
|
|
||||||
|
|
||||||
nextchar = (argv[optind] + 1
|
|
||||||
+ (longopts != NULL && argv[optind][1] == '-'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (longopts != NULL
|
|
||||||
&& ((argv[optind][0] == '-'
|
|
||||||
&& (argv[optind][1] == '-' || long_only))
|
|
||||||
#ifdef GETOPT_COMPAT
|
|
||||||
|| argv[optind][0] == '+'
|
|
||||||
#endif /* GETOPT_COMPAT */
|
|
||||||
))
|
|
||||||
{
|
|
||||||
const struct option *p;
|
|
||||||
char *s = nextchar;
|
|
||||||
int exact = 0;
|
|
||||||
int ambig = 0;
|
|
||||||
const struct option *pfound = NULL;
|
|
||||||
int indfound = 0;
|
|
||||||
int needexact = 0;
|
|
||||||
|
|
||||||
/* allow `--option#value' because you cannout assign a '='
|
|
||||||
to an environment variable under DOS command.com */
|
|
||||||
while (*s && *s != '=' && * s != '#')
|
|
||||||
s++;
|
|
||||||
|
|
||||||
/* Test all options for either exact match or abbreviated matches. */
|
|
||||||
for (p = longopts, option_index = 0; p->name;
|
|
||||||
p++, option_index++)
|
|
||||||
if (!strncmp (p->name, nextchar, (unsigned) (s - nextchar)))
|
|
||||||
{
|
|
||||||
if (p->has_arg & 0x10)
|
|
||||||
needexact = 1;
|
|
||||||
if ((unsigned) (s - nextchar) == strlen (p->name))
|
|
||||||
{
|
|
||||||
/* Exact match found. */
|
|
||||||
pfound = p;
|
|
||||||
indfound = option_index;
|
|
||||||
exact = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (pfound == NULL)
|
|
||||||
{
|
|
||||||
/* First nonexact match found. */
|
|
||||||
pfound = p;
|
|
||||||
indfound = option_index;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* Second nonexact match found. */
|
|
||||||
ambig = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* don't allow nonexact longoptions */
|
|
||||||
if (needexact && !exact)
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
fprintf (stderr, "%s: unrecognized option `%s'\n",
|
|
||||||
PROGNAME(argv[0]), argv[optind]);
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
optind++;
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
if (ambig && !exact)
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
|
||||||
PROGNAME(argv[0]), argv[optind]);
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
optind++;
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pfound != NULL)
|
|
||||||
{
|
|
||||||
int have_arg = (s[0] != '\0');
|
|
||||||
if (have_arg && (pfound->has_arg & 0xf))
|
|
||||||
have_arg = (s[1] != '\0');
|
|
||||||
option_index = indfound;
|
|
||||||
optind++;
|
|
||||||
if (have_arg)
|
|
||||||
{
|
|
||||||
/* Don't test has_arg with >, because some C compilers don't
|
|
||||||
allow it to be used on enums. */
|
|
||||||
if (pfound->has_arg & 0xf)
|
|
||||||
optarg = s + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
{
|
|
||||||
if (argv[optind - 1][1] == '-')
|
|
||||||
/* --option */
|
|
||||||
fprintf (stderr,
|
|
||||||
"%s: option `--%s' doesn't allow an argument\n",
|
|
||||||
PROGNAME(argv[0]), pfound->name);
|
|
||||||
else
|
|
||||||
/* +option or -option */
|
|
||||||
fprintf (stderr,
|
|
||||||
"%s: option `%c%s' doesn't allow an argument\n",
|
|
||||||
PROGNAME(argv[0]), argv[optind - 1][0], pfound->name);
|
|
||||||
}
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((pfound->has_arg & 0xf) == 1)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
if (optind < argc)
|
|
||||||
#else
|
|
||||||
if (optind < argc && (pfound->has_arg & 0x20) == 0)
|
|
||||||
#endif
|
|
||||||
optarg = argv[optind++];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
fprintf (stderr, "%s: option `--%s%s' requires an argument\n",
|
|
||||||
PROGNAME(argv[0]), pfound->name,
|
|
||||||
(pfound->has_arg & 0x20) ? "=" : "");
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
return optstring[0] == ':' ? ':' : BAD_OPTION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nextchar += strlen (nextchar);
|
|
||||||
if (longind != NULL)
|
|
||||||
*longind = option_index;
|
|
||||||
if (pfound->flag)
|
|
||||||
{
|
|
||||||
*(pfound->flag) = pfound->val;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return pfound->val;
|
|
||||||
}
|
|
||||||
/* Can't find it as a long option. If this is not getopt_long_only,
|
|
||||||
or the option starts with '--' or is not a valid short
|
|
||||||
option, then it's an error.
|
|
||||||
Otherwise interpret it as a short option. */
|
|
||||||
if (!long_only || argv[optind][1] == '-'
|
|
||||||
#ifdef GETOPT_COMPAT
|
|
||||||
|| argv[optind][0] == '+'
|
|
||||||
#endif /* GETOPT_COMPAT */
|
|
||||||
|| strchr (optstring, *nextchar) == NULL)
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
{
|
|
||||||
if (argv[optind][1] == '-')
|
|
||||||
/* --option */
|
|
||||||
fprintf (stderr, "%s: unrecognized option `--%s'\n",
|
|
||||||
PROGNAME(argv[0]), nextchar);
|
|
||||||
else
|
|
||||||
/* +option or -option */
|
|
||||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
|
||||||
PROGNAME(argv[0]), argv[optind][0], nextchar);
|
|
||||||
}
|
|
||||||
nextchar = empty_string;
|
|
||||||
optind++;
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
(void) &ambig; /* UNUSED */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Look at and handle the next option-character. */
|
|
||||||
|
|
||||||
{
|
|
||||||
char c = *nextchar++;
|
|
||||||
const char *temp = strchr (optstring, c);
|
|
||||||
|
|
||||||
/* Increment `optind' when we start to process its last character. */
|
|
||||||
if (*nextchar == '\0')
|
|
||||||
++optind;
|
|
||||||
|
|
||||||
if (temp == NULL || c == ':')
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
if (c < 040 || c >= 0177)
|
|
||||||
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
|
|
||||||
PROGNAME(argv[0]), c);
|
|
||||||
else
|
|
||||||
fprintf (stderr, "%s: unrecognized option `-%c'\n", PROGNAME(argv[0]), c);
|
|
||||||
#else
|
|
||||||
/* 1003.2 specifies the format of this message. */
|
|
||||||
fprintf (stderr, "%s: illegal option -- %c\n", PROGNAME(argv[0]), c);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
optopt = c;
|
|
||||||
return BAD_OPTION;
|
|
||||||
}
|
|
||||||
if (temp[1] == ':')
|
|
||||||
{
|
|
||||||
if (temp[2] == ':')
|
|
||||||
{
|
|
||||||
/* This is an option that accepts an argument optionally. */
|
|
||||||
if (*nextchar != '\0')
|
|
||||||
{
|
|
||||||
optarg = nextchar;
|
|
||||||
optind++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
optarg = 0;
|
|
||||||
nextchar = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This is an option that requires an argument. */
|
|
||||||
if (*nextchar != '\0')
|
|
||||||
{
|
|
||||||
optarg = nextchar;
|
|
||||||
/* If we end this ARGV-element by taking the rest as an arg,
|
|
||||||
we must advance to the next element now. */
|
|
||||||
optind++;
|
|
||||||
}
|
|
||||||
else if (optind == argc)
|
|
||||||
{
|
|
||||||
if (opterr)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
fprintf (stderr, "%s: option `-%c' requires an argument\n",
|
|
||||||
PROGNAME(argv[0]), c);
|
|
||||||
#else
|
|
||||||
/* 1003.2 specifies the format of this message. */
|
|
||||||
fprintf (stderr, "%s: option requires an argument -- %c\n",
|
|
||||||
PROGNAME(argv[0]), c);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
optopt = c;
|
|
||||||
if (optstring[0] == ':')
|
|
||||||
c = ':';
|
|
||||||
else
|
|
||||||
c = BAD_OPTION;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* We already incremented `optind' once;
|
|
||||||
increment it again when taking next ARGV-elt as argument. */
|
|
||||||
optarg = argv[optind++];
|
|
||||||
nextchar = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int mfx_getopt(int argc, char **argv, const char *optstring)
|
|
||||||
{
|
|
||||||
return _getopt_internal (argc, argv, optstring,
|
|
||||||
(const struct option *) 0,
|
|
||||||
(int *) 0,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int mfx_getopt_long(int argc, char **argv, const char *options,
|
|
||||||
const struct option *long_options, int *opt_index)
|
|
||||||
{
|
|
||||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TEST
|
|
||||||
|
|
||||||
/* Compile with -DTEST to make an executable for use in testing
|
|
||||||
the above definition of `getopt'. */
|
|
||||||
|
|
||||||
int
|
|
||||||
main (argc, argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
int digit_optind = 0;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
int this_option_optind = optind ? optind : 1;
|
|
||||||
|
|
||||||
c = getopt (argc, argv, "abc:d:0123456789");
|
|
||||||
if (c == EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
|
||||||
printf ("digits occur in two different argv-elements.\n");
|
|
||||||
digit_optind = this_option_optind;
|
|
||||||
printf ("option %c\n", c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'a':
|
|
||||||
printf ("option a\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
printf ("option b\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'c':
|
|
||||||
printf ("option c with value `%s'\n", optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BAD_OPTION:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optind < argc)
|
|
||||||
{
|
|
||||||
printf ("non-option ARGV-elements: ");
|
|
||||||
while (optind < argc)
|
|
||||||
printf ("%s ", argv[optind++]);
|
|
||||||
printf ("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TEST */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
-102
@@ -1,102 +0,0 @@
|
|||||||
/* Declarations for getopt.
|
|
||||||
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation; either version 2, 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; if not, write to the Free Software
|
|
||||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
||||||
|
|
||||||
#ifndef __MFX_GETOPT_H
|
|
||||||
#define __MFX_GETOPT_H 1
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
/* extern "C" { */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* For communication from `getopt' to the caller.
|
|
||||||
When `getopt' finds an option that takes an argument,
|
|
||||||
the argument value is returned here.
|
|
||||||
Also, when `ordering' is RETURN_IN_ORDER,
|
|
||||||
each non-option ARGV-element is returned here. */
|
|
||||||
|
|
||||||
extern char *mfx_optarg;
|
|
||||||
|
|
||||||
/* Index in ARGV of the next element to be scanned.
|
|
||||||
This is used for communication to and from the caller
|
|
||||||
and for communication between successive calls to `getopt'.
|
|
||||||
|
|
||||||
On entry to `getopt', zero means this is the first call; initialize.
|
|
||||||
|
|
||||||
When `getopt' returns EOF, this is the index of the first of the
|
|
||||||
non-option elements that the caller should itself scan.
|
|
||||||
|
|
||||||
Otherwise, `optind' communicates from one call to the next
|
|
||||||
how much of ARGV has been scanned so far. */
|
|
||||||
|
|
||||||
extern int mfx_optind;
|
|
||||||
|
|
||||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
|
||||||
for unrecognized options. */
|
|
||||||
|
|
||||||
extern int mfx_opterr;
|
|
||||||
|
|
||||||
/* Set to an option character which was unrecognized. */
|
|
||||||
|
|
||||||
extern int mfx_optopt;
|
|
||||||
|
|
||||||
/* Describe the long-named options requested by the application.
|
|
||||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
|
||||||
of `struct option' terminated by an element containing a name which is
|
|
||||||
zero.
|
|
||||||
|
|
||||||
The field `has_arg' is:
|
|
||||||
no_argument (or 0) if the option does not take an argument,
|
|
||||||
required_argument (or 1) if the option requires an argument,
|
|
||||||
optional_argument (or 2) if the option takes an optional argument.
|
|
||||||
|
|
||||||
If the field `flag' is not NULL, it points to a variable that is set
|
|
||||||
to the value given in the field `val' when the option is found, but
|
|
||||||
left unchanged if the option is not found.
|
|
||||||
|
|
||||||
To have a long-named option do something other than set an `int' to
|
|
||||||
a compiled-in constant, such as set a value from `optarg', set the
|
|
||||||
option's `flag' field to zero and its `val' field to a nonzero
|
|
||||||
value (the equivalent single-letter option character, if there is
|
|
||||||
one). For long options that have a zero `flag' field, `getopt'
|
|
||||||
returns the contents of the `val' field. */
|
|
||||||
|
|
||||||
struct mfx_option
|
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
/* has_arg can't be an enum because some compilers complain about
|
|
||||||
type mismatches in all the code that assumes it is an int. */
|
|
||||||
int has_arg;
|
|
||||||
int *flag;
|
|
||||||
int val;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
|
||||||
|
|
||||||
#define mfx_no_argument 0
|
|
||||||
#define mfx_required_argument 1
|
|
||||||
#define mfx_optional_argument 2
|
|
||||||
#define mfx_exact_argument 0x10 /* no abbrev. */
|
|
||||||
|
|
||||||
int mfx_getopt(int argc, char **argv, const char *shortopts);
|
|
||||||
int mfx_getopt_long(int argc, char **argv, const char *shortopts,
|
|
||||||
const struct mfx_option *longopts, int *longind);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
/* } */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __MFX_GETOPT_H */
|
|
||||||
+39
-21
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_OPTIONS_H
|
#ifndef __UPX_OPTIONS_H
|
||||||
#define __UPX_OPTIONS_H
|
#define __UPX_OPTIONS_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -45,13 +45,26 @@ enum {
|
|||||||
struct options_t {
|
struct options_t {
|
||||||
int cmd;
|
int cmd;
|
||||||
|
|
||||||
|
// mp (meta) options
|
||||||
|
int mp_compress_task;
|
||||||
|
bool mp_query_format;
|
||||||
|
bool mp_query_num_tasks;
|
||||||
|
|
||||||
// compression options
|
// compression options
|
||||||
int method;
|
int method;
|
||||||
|
bool method_lzma_seen;
|
||||||
|
bool method_nrv2b_seen;
|
||||||
|
bool method_nrv2d_seen;
|
||||||
|
bool method_nrv2e_seen;
|
||||||
int level; // compression level 1..10
|
int level; // compression level 1..10
|
||||||
int filter; // preferred filter from Packer::getFilters()
|
int filter; // preferred filter from Packer::getFilters()
|
||||||
|
bool ultra_brute;
|
||||||
bool all_methods; // try all available compression methods ?
|
bool all_methods; // try all available compression methods ?
|
||||||
|
bool all_methods_use_lzma;
|
||||||
bool all_filters; // try all available filters ?
|
bool all_filters; // try all available filters ?
|
||||||
bool no_filter; // force no filter
|
bool no_filter; // force no filter
|
||||||
|
bool prefer_ucl; // prefer UCL
|
||||||
|
bool exact; // user requires byte-identical decompression
|
||||||
|
|
||||||
// other options
|
// other options
|
||||||
int backup;
|
int backup;
|
||||||
@@ -62,6 +75,9 @@ struct options_t {
|
|||||||
bool no_env;
|
bool no_env;
|
||||||
bool no_progress;
|
bool no_progress;
|
||||||
const char *output_name;
|
const char *output_name;
|
||||||
|
bool preserve_mode;
|
||||||
|
bool preserve_ownership;
|
||||||
|
bool preserve_timestamp;
|
||||||
int small;
|
int small;
|
||||||
int verbose;
|
int verbose;
|
||||||
bool to_stdout;
|
bool to_stdout;
|
||||||
@@ -69,6 +85,7 @@ struct options_t {
|
|||||||
// debug options
|
// debug options
|
||||||
struct {
|
struct {
|
||||||
int debug_level;
|
int debug_level;
|
||||||
|
bool disable_random_id; // for Packer::getRandomId()
|
||||||
const char *dump_stub_loader;
|
const char *dump_stub_loader;
|
||||||
char fake_stub_version[4+1]; // for internal debugging
|
char fake_stub_version[4+1]; // for internal debugging
|
||||||
char fake_stub_year[4+1]; // for internal debugging
|
char fake_stub_year[4+1]; // for internal debugging
|
||||||
@@ -82,16 +99,14 @@ struct options_t {
|
|||||||
};
|
};
|
||||||
int overlay;
|
int overlay;
|
||||||
|
|
||||||
// compression runtime parameters - see struct ucl_compress_config_t
|
// compression runtime parameters - see struct XXX_compress_config_t
|
||||||
struct {
|
struct crp_t {
|
||||||
upx_uint max_offset;
|
lzma_compress_config_t crp_lzma;
|
||||||
upx_uint max_match;
|
ucl_compress_config_t crp_ucl;
|
||||||
int s_level;
|
zlib_compress_config_t crp_zlib;
|
||||||
int h_level;
|
void reset() { crp_lzma.reset(); crp_ucl.reset(); crp_zlib.reset(); }
|
||||||
int p_level;
|
};
|
||||||
int c_flags;
|
crp_t crp;
|
||||||
upx_uint m_size;
|
|
||||||
} crp;
|
|
||||||
|
|
||||||
// CPU
|
// CPU
|
||||||
enum {
|
enum {
|
||||||
@@ -120,6 +135,7 @@ struct options_t {
|
|||||||
bool boot_only;
|
bool boot_only;
|
||||||
bool no_align;
|
bool no_align;
|
||||||
bool do_8bit;
|
bool do_8bit;
|
||||||
|
bool do_8mib;
|
||||||
} ps1_exe;
|
} ps1_exe;
|
||||||
struct {
|
struct {
|
||||||
unsigned blocksize;
|
unsigned blocksize;
|
||||||
@@ -127,8 +143,11 @@ struct options_t {
|
|||||||
bool is_ptinterp; // is PT_INTERP, so don't adjust auxv_t
|
bool is_ptinterp; // is PT_INTERP, so don't adjust auxv_t
|
||||||
bool use_ptinterp; // use PT_INTERP /opt/upx/run
|
bool use_ptinterp; // use PT_INTERP /opt/upx/run
|
||||||
bool make_ptinterp; // make PT_INTERP [ignore current file!]
|
bool make_ptinterp; // make PT_INTERP [ignore current file!]
|
||||||
enum { SCRIPT_MAX = 32 };
|
bool unmap_all_pages; // thus /proc/self/exe vanishes
|
||||||
const char *script_name;
|
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
|
||||||
|
bool preserve_build_id; // copy the build-id to the compressed binary
|
||||||
|
bool android_shlib; // keep some ElfXX_Shdr for dlopen()
|
||||||
|
bool force_pie; // choose DF_1_PIE instead of is_shlib
|
||||||
} o_unix;
|
} o_unix;
|
||||||
struct {
|
struct {
|
||||||
bool le;
|
bool le;
|
||||||
@@ -139,7 +158,10 @@ struct options_t {
|
|||||||
int compress_resources;
|
int compress_resources;
|
||||||
signed char compress_rt[25]; // 25 == RT_LAST
|
signed char compress_rt[25]; // 25 == RT_LAST
|
||||||
int strip_relocs;
|
int strip_relocs;
|
||||||
|
const char *keep_resource;
|
||||||
} win32_pe;
|
} win32_pe;
|
||||||
|
|
||||||
|
void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct options_t *opt;
|
extern struct options_t *opt;
|
||||||
@@ -147,8 +169,4 @@ extern struct options_t *opt;
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+151
-1940
File diff suppressed because it is too large
Load Diff
+28
-198
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,230 +22,60 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@users.sourceforge.net
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_ARMPE_H
|
#ifndef __UPX_P_ARMPE_H
|
||||||
#define __UPX_P_ARMPE_H
|
#define __UPX_P_ARMPE_H 1
|
||||||
|
|
||||||
|
|
||||||
class PackArmPe_Interval;
|
|
||||||
class PackArmPe_Reloc;
|
|
||||||
class PackArmPe_Resource;
|
|
||||||
class PackArmPe_Export;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// w32/pe
|
// arm/pe
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
class PackArmPe : public Packer
|
class PackArmPe : public PeFile32
|
||||||
{
|
{
|
||||||
typedef Packer super;
|
typedef PeFile32 super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PackArmPe(InputFile *f);
|
PackArmPe(InputFile *f);
|
||||||
~PackArmPe();
|
virtual ~PackArmPe();
|
||||||
virtual int getVersion() const { return 13; }
|
|
||||||
virtual int getFormat() const { return UPX_F_WINCE_ARM_PE; }
|
virtual int getFormat() const { return UPX_F_WINCE_ARM_PE; }
|
||||||
virtual const char *getName() const { return "arm/pe"; }
|
virtual const char *getName() const { return "arm/pe"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "arm-wince.pe"; }
|
||||||
virtual const int *getCompressionMethods(int method, int level) const;
|
virtual const int *getCompressionMethods(int method, int level) const;
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
|
virtual void defineFilterSymbols(const Filter *) {}
|
||||||
|
|
||||||
|
virtual bool handleForceOption();
|
||||||
|
virtual void callCompressWithFilters(Filter &, int filter_strategy,
|
||||||
|
unsigned ih_codebase);
|
||||||
|
virtual void defineSymbols(unsigned ncsection, unsigned upxsection,
|
||||||
|
unsigned sizeof_oh, unsigned isize_isplit,
|
||||||
|
unsigned s1addr);
|
||||||
|
virtual void addNewRelocations(Reloc &, unsigned upxsection);
|
||||||
|
virtual unsigned getProcessImportParam(unsigned upxsection);
|
||||||
|
virtual void setOhDataBase(const pe_section_t *osection);
|
||||||
|
virtual void setOhHeaderSize(const pe_section_t *osection);
|
||||||
virtual void pack(OutputFile *fo);
|
virtual void pack(OutputFile *fo);
|
||||||
virtual void unpack(OutputFile *fo);
|
|
||||||
|
|
||||||
virtual bool canPack();
|
virtual bool canPack();
|
||||||
virtual int canUnpack();
|
|
||||||
|
|
||||||
// unpacker capabilities
|
|
||||||
virtual bool canUnpackVersion(int version) const
|
|
||||||
{ UNUSED(version); return false; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int readFileHeader();
|
virtual void buildLoader(const Filter *ft);
|
||||||
virtual bool testUnpackVersion(int version) const;
|
virtual Linker* newLinker() const;
|
||||||
|
|
||||||
virtual int buildLoader(const Filter *ft);
|
virtual const char *kernelDll() const { return "COREDLL.dll"; }
|
||||||
|
virtual void processImports2(unsigned, unsigned);
|
||||||
|
virtual void addStubImports();
|
||||||
|
|
||||||
unsigned pe_offset;
|
virtual void processTls(Interval *);
|
||||||
|
|
||||||
unsigned processImports();
|
bool use_thumb_stub;
|
||||||
void processImports(unsigned);
|
|
||||||
void rebuildImports(upx_byte *&);
|
|
||||||
upx_byte *oimport;
|
|
||||||
unsigned soimport;
|
|
||||||
upx_byte *oimpdlls;
|
|
||||||
unsigned soimpdlls;
|
|
||||||
|
|
||||||
void processRelocs();
|
|
||||||
void processRelocs(PackArmPe_Reloc *);
|
|
||||||
void rebuildRelocs(upx_byte *&);
|
|
||||||
upx_byte *orelocs;
|
|
||||||
unsigned sorelocs;
|
|
||||||
upx_byte *oxrelocs;
|
|
||||||
unsigned soxrelocs;
|
|
||||||
|
|
||||||
void processExports(PackArmPe_Export *);
|
|
||||||
void processExports(PackArmPe_Export *,unsigned);
|
|
||||||
void rebuildExports();
|
|
||||||
upx_byte *oexport;
|
|
||||||
unsigned soexport;
|
|
||||||
|
|
||||||
void processResources(PackArmPe_Resource *);
|
|
||||||
void processResources(PackArmPe_Resource *, unsigned);
|
|
||||||
void rebuildResources(upx_byte *&);
|
|
||||||
upx_byte *oresources;
|
|
||||||
unsigned soresources;
|
|
||||||
|
|
||||||
void processTls(PackArmPe_Interval *);
|
|
||||||
void processTls(PackArmPe_Reloc *,const PackArmPe_Interval *,unsigned);
|
|
||||||
void rebuildTls();
|
|
||||||
upx_byte *otls;
|
|
||||||
unsigned sotls;
|
|
||||||
|
|
||||||
unsigned stripDebug(unsigned);
|
|
||||||
|
|
||||||
unsigned icondir_offset;
|
|
||||||
int icondir_count;
|
|
||||||
|
|
||||||
bool importbyordinal;
|
|
||||||
bool kernel32ordinal;
|
|
||||||
unsigned tlsindex;
|
|
||||||
unsigned rvamin;
|
|
||||||
unsigned cimports; // rva of preprocessed imports
|
|
||||||
unsigned crelocs; // rva of preprocessed fixups
|
|
||||||
int big_relocs;
|
|
||||||
|
|
||||||
struct pe_header_t
|
|
||||||
{
|
|
||||||
// 0x0
|
|
||||||
char _[4]; // pemagic
|
|
||||||
LE16 cpu;
|
|
||||||
LE16 objects;
|
|
||||||
char __[12]; // timestamp + reserved
|
|
||||||
LE16 opthdrsize;
|
|
||||||
LE16 flags;
|
|
||||||
// optional header
|
|
||||||
char ___[4]; // coffmagic + linkerversion
|
|
||||||
LE32 codesize;
|
|
||||||
// 0x20
|
|
||||||
LE32 datasize;
|
|
||||||
LE32 bsssize;
|
|
||||||
LE32 entry;
|
|
||||||
LE32 codebase;
|
|
||||||
// 0x30
|
|
||||||
LE32 database;
|
|
||||||
// nt specific fields
|
|
||||||
LE32 imagebase;
|
|
||||||
LE32 objectalign;
|
|
||||||
LE32 filealign; // should set to 0x200 ?
|
|
||||||
// 0x40
|
|
||||||
char ____[16]; // versions
|
|
||||||
// 0x50
|
|
||||||
LE32 imagesize;
|
|
||||||
LE32 headersize;
|
|
||||||
LE32 chksum; // should set to 0
|
|
||||||
LE16 subsystem;
|
|
||||||
LE16 dllflags;
|
|
||||||
// 0x60
|
|
||||||
char _____[20]; // stack + heap sizes
|
|
||||||
// 0x74
|
|
||||||
LE32 ddirsentries; // usually 16
|
|
||||||
|
|
||||||
struct ddirs_t
|
|
||||||
{
|
|
||||||
LE32 vaddr;
|
|
||||||
LE32 size;
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct ddirs_t ddirs[16];
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct pe_section_t
|
|
||||||
{
|
|
||||||
char name[8];
|
|
||||||
LE32 vsize;
|
|
||||||
LE32 vaddr;
|
|
||||||
LE32 size;
|
|
||||||
LE32 rawdataptr;
|
|
||||||
char _[12];
|
|
||||||
LE32 flags;
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
pe_header_t ih, oh;
|
|
||||||
pe_section_t *isection;
|
|
||||||
|
|
||||||
static unsigned virta2objnum (unsigned, pe_section_t *, unsigned);
|
|
||||||
unsigned tryremove (unsigned, unsigned);
|
|
||||||
|
|
||||||
enum {
|
|
||||||
PEDIR_EXPORT = 0,
|
|
||||||
PEDIR_IMPORT = 1,
|
|
||||||
PEDIR_RESOURCE = 2,
|
|
||||||
PEDIR_EXCEPTION = 3, // Exception table
|
|
||||||
PEDIR_SEC = 4, // Certificate table (file pointer)
|
|
||||||
PEDIR_RELOC = 5,
|
|
||||||
PEDIR_DEBUG = 6,
|
|
||||||
PEDIR_COPYRIGHT = 7, // Architecture-specific data
|
|
||||||
PEDIR_GLOBALPTR = 8, // Global pointer
|
|
||||||
PEDIR_TLS = 9,
|
|
||||||
PEDIR_LOADCONF = 10, // Load Config Table
|
|
||||||
PEDIR_BOUNDIM = 11,
|
|
||||||
PEDIR_IAT = 12,
|
|
||||||
PEDIR_DELAYIMP = 13, // Delay Import Descriptor
|
|
||||||
PEDIR_COMRT = 14 // Com+ Runtime Header
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
PEFL_CODE = 0x20,
|
|
||||||
PEFL_DATA = 0x40,
|
|
||||||
PEFL_BSS = 0x80,
|
|
||||||
PEFL_INFO = 0x200,
|
|
||||||
PEFL_EXTRELS = 0x01000000, // extended relocations
|
|
||||||
PEFL_DISCARD = 0x02000000,
|
|
||||||
PEFL_NOCACHE = 0x04000000,
|
|
||||||
PEFL_NOPAGE = 0x08000000,
|
|
||||||
PEFL_SHARED = 0x10000000,
|
|
||||||
PEFL_EXEC = 0x20000000,
|
|
||||||
PEFL_READ = 0x40000000,
|
|
||||||
PEFL_WRITE = 0x80000000
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
RELOCS_STRIPPED = 0x0001,
|
|
||||||
EXECUTABLE = 0x0002,
|
|
||||||
LNUM_STRIPPED = 0x0004,
|
|
||||||
LSYMS_STRIPPED = 0x0008,
|
|
||||||
AGGRESSIVE_TRIM = 0x0010,
|
|
||||||
TWO_GIGS_AWARE = 0x0020,
|
|
||||||
FLITTLE_ENDIAN = 0x0080,
|
|
||||||
BITS_32_MACHINE = 0x0100,
|
|
||||||
DEBUG_STRIPPED = 0x0200,
|
|
||||||
REMOVABLE_SWAP = 0x0400,
|
|
||||||
SYSTEM_PROGRAM = 0x1000,
|
|
||||||
DLL_FLAG = 0x2000,
|
|
||||||
FBIG_ENDIAN = 0x8000
|
|
||||||
};
|
|
||||||
|
|
||||||
// predefined resource types
|
|
||||||
enum {
|
|
||||||
RT_CURSOR = 1, RT_BITMAP, RT_ICON, RT_MENU, RT_DIALOG, RT_STRING,
|
|
||||||
RT_FONTDIR, RT_FONT, RT_ACCELERATOR, RT_RCDATA, RT_MESSAGETABLE,
|
|
||||||
RT_GROUP_CURSOR, RT_GROUP_ICON = 14, RT_VERSION = 16, RT_DLGINCLUDE,
|
|
||||||
RT_PLUGPLAY = 19, RT_VXD, RT_ANICURSOR, RT_ANIICON, RT_HTML,
|
|
||||||
RT_MANIFEST, RT_LAST
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|||||||
+32
-39
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@users.sourceforge.net
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -31,11 +31,12 @@
|
|||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "packer.h"
|
#include "packer.h"
|
||||||
#include "p_com.h"
|
#include "p_com.h"
|
||||||
|
#include "linker.h"
|
||||||
|
|
||||||
static const
|
static const
|
||||||
#include "stub/l_com.h"
|
#include "stub/i086-dos16.com.h"
|
||||||
|
|
||||||
//#define TESTING
|
//#define TESTING 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -44,16 +45,11 @@ static const
|
|||||||
|
|
||||||
const int *PackCom::getCompressionMethods(int method, int level) const
|
const int *PackCom::getCompressionMethods(int method, int level) const
|
||||||
{
|
{
|
||||||
static const int m_nrv2b[] = { M_NRV2B_LE16, -1 };
|
static const int m_nrv2b[] = { M_NRV2B_LE16, M_END };
|
||||||
if (M_IS_NRV2B(method))
|
|
||||||
return m_nrv2b;
|
|
||||||
#if 0
|
#if 0
|
||||||
// NOT IMPLEMENTED
|
static const int m_nrv2d[] = { M_NRV2D_LE16, M_END };
|
||||||
static const int m_nrv2d[] = { M_NRV2D_LE16, -1 };
|
|
||||||
if (M_IS_NRV2D(method))
|
|
||||||
return m_nrv2d;
|
|
||||||
#endif
|
#endif
|
||||||
UNUSED(level);
|
UNUSED(method); UNUSED(level);
|
||||||
return m_nrv2b;
|
return m_nrv2b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +58,7 @@ const int *PackCom::getFilters() const
|
|||||||
{
|
{
|
||||||
static const int filters[] = {
|
static const int filters[] = {
|
||||||
0x06, 0x03, 0x04, 0x01, 0x05, 0x02,
|
0x06, 0x03, 0x04, 0x01, 0x05, 0x02,
|
||||||
-1 };
|
FT_END };
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,10 +94,9 @@ void PackCom::patchLoader(OutputFile *fo,
|
|||||||
upx_byte *loader, int lsize,
|
upx_byte *loader, int lsize,
|
||||||
unsigned calls)
|
unsigned calls)
|
||||||
{
|
{
|
||||||
const int filter_id = ph.filter;
|
|
||||||
const int e_len = getLoaderSectionStart("COMCUTPO");
|
const int e_len = getLoaderSectionStart("COMCUTPO");
|
||||||
const int d_len = lsize - e_len;
|
const int d_len = lsize - e_len;
|
||||||
assert(e_len > 0 && e_len < 256);
|
assert(e_len > 0 && e_len < 128);
|
||||||
assert(d_len > 0 && d_len < 256);
|
assert(d_len > 0 && d_len < 256);
|
||||||
|
|
||||||
const unsigned upper_end = ph.u_len + ph.overlap_overhead + d_len + 0x100;
|
const unsigned upper_end = ph.u_len + ph.overlap_overhead + d_len + 0x100;
|
||||||
@@ -111,22 +106,19 @@ void PackCom::patchLoader(OutputFile *fo,
|
|||||||
if (upper_end + stacksize > 0xfffe)
|
if (upper_end + stacksize > 0xfffe)
|
||||||
throwCantPack("file is too big for dos/com");
|
throwCantPack("file is too big for dos/com");
|
||||||
|
|
||||||
if (filter_id)
|
linker->defineSymbol("calltrick_calls", calls);
|
||||||
{
|
linker->defineSymbol("sp_limit", upper_end + stacksize);
|
||||||
assert(calls > 0);
|
linker->defineSymbol("bytes_to_copy", ph.c_len + lsize);
|
||||||
patch_le16(loader,lsize,"CT",calls);
|
linker->defineSymbol("copy_source", ph.c_len + lsize + 0x100);
|
||||||
}
|
linker->defineSymbol("copy_destination", upper_end);
|
||||||
|
linker->defineSymbol("neg_e_len", 0 - e_len);
|
||||||
|
linker->defineSymbol("NRV2B160", ph.u_len + ph.overlap_overhead);
|
||||||
|
|
||||||
|
relocateLoader();
|
||||||
|
loader = getLoader();
|
||||||
|
|
||||||
|
// some day we could use the relocation stuff for patchPackHeader too
|
||||||
patchPackHeader(loader,e_len);
|
patchPackHeader(loader,e_len);
|
||||||
|
|
||||||
// NOTE: Depends on: decompr_start == cutpoint+1 !!!
|
|
||||||
patch_le16(loader,e_len,"JM",upper_end - 0xff - d_len - getLoaderSection("UPX1HEAD"));
|
|
||||||
loader[getLoaderSectionStart("COMSUBSI") - 1] = (upx_byte) -e_len;
|
|
||||||
patch_le16(loader,e_len,"DI",upper_end);
|
|
||||||
patch_le16(loader,e_len,"SI",ph.c_len + lsize + 0x100);
|
|
||||||
patch_le16(loader,e_len,"CX",ph.c_len + lsize);
|
|
||||||
patch_le16(loader,e_len,"SP",upper_end + stacksize);
|
|
||||||
|
|
||||||
// write loader + compressed file
|
// write loader + compressed file
|
||||||
fo->write(loader,e_len); // entry
|
fo->write(loader,e_len); // entry
|
||||||
fo->write(obuf,ph.c_len);
|
fo->write(obuf,ph.c_len);
|
||||||
@@ -139,10 +131,10 @@ void PackCom::patchLoader(OutputFile *fo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PackCom::buildLoader(const Filter *ft)
|
void PackCom::buildLoader(const Filter *ft)
|
||||||
{
|
{
|
||||||
initLoader(nrv2b_loader,sizeof(nrv2b_loader));
|
initLoader(stub_i086_dos16_com, sizeof(stub_i086_dos16_com));
|
||||||
addLoader("COMMAIN1,COMSUBSI",
|
addLoader("COMMAIN1",
|
||||||
ph.first_offset_found == 1 ? "COMSBBBP" : "",
|
ph.first_offset_found == 1 ? "COMSBBBP" : "",
|
||||||
"COMPSHDI",
|
"COMPSHDI",
|
||||||
ft->id ? "COMCALLT" : "",
|
ft->id ? "COMCALLT" : "",
|
||||||
@@ -150,7 +142,7 @@ int PackCom::buildLoader(const Filter *ft)
|
|||||||
ft->id ? "NRVDDONE" : "NRVDRETU",
|
ft->id ? "NRVDDONE" : "NRVDRETU",
|
||||||
"NRVDECO1",
|
"NRVDECO1",
|
||||||
ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00",
|
ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00",
|
||||||
"NRVDECO2,NRV2B169",
|
"NRVDECO2",
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (ft->id)
|
if (ft->id)
|
||||||
@@ -158,7 +150,6 @@ int PackCom::buildLoader(const Filter *ft)
|
|||||||
assert(ft->calls > 0);
|
assert(ft->calls > 0);
|
||||||
addFilter16(ft->id);
|
addFilter16(ft->id);
|
||||||
}
|
}
|
||||||
return getLoaderSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -206,7 +197,7 @@ void PackCom::pack(OutputFile *fo)
|
|||||||
ft.addvalue = getCallTrickOffset();
|
ft.addvalue = getCallTrickOffset();
|
||||||
// compress
|
// compress
|
||||||
const unsigned overlap_range = ph.u_len < 0xFE00 - ft.addvalue ? 32 : 0;
|
const unsigned overlap_range = ph.u_len < 0xFE00 - ft.addvalue ? 32 : 0;
|
||||||
compressWithFilters(&ft, overlap_range);
|
compressWithFilters(&ft, overlap_range, NULL_cconf);
|
||||||
|
|
||||||
const int lsize = getLoaderSize();
|
const int lsize = getLoaderSize();
|
||||||
MemBuffer loader(lsize);
|
MemBuffer loader(lsize);
|
||||||
@@ -270,7 +261,9 @@ void PackCom::unpack(OutputFile *fo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
Linker* PackCom::newLinker() const
|
||||||
vi:ts=4:et
|
{
|
||||||
*/
|
return new ElfLinkerX86();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
|
|||||||
+10
-11
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_COM_H
|
#ifndef __UPX_P_COM_H
|
||||||
#define __UPX_P_COM_H
|
#define __UPX_P_COM_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -38,10 +38,12 @@ class PackCom : public Packer
|
|||||||
{
|
{
|
||||||
typedef Packer super;
|
typedef Packer super;
|
||||||
public:
|
public:
|
||||||
PackCom(InputFile *f) : super(f) { }
|
PackCom(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
||||||
virtual int getVersion() const { return 13; }
|
virtual int getVersion() const { return 13; }
|
||||||
virtual int getFormat() const { return UPX_F_DOS_COM; }
|
virtual int getFormat() const { return UPX_F_DOS_COM; }
|
||||||
virtual const char *getName() const { return "dos/com"; }
|
virtual const char *getName() const { return "dos/com"; }
|
||||||
|
//virtual const char *getFullName(const options_t *o) const { return o && o->cpu == o->CPU_8086 ? "i086-dos16.com" : "i286-dos16.com"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i086-dos16.com"; }
|
||||||
virtual const int *getCompressionMethods(int method, int level) const;
|
virtual const int *getCompressionMethods(int method, int level) const;
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
@@ -53,9 +55,10 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual unsigned getCallTrickOffset() const { return 0x100; }
|
virtual unsigned getCallTrickOffset() const { return 0x100; }
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
virtual void patchLoader(OutputFile *fo, upx_byte *, int, unsigned);
|
virtual void patchLoader(OutputFile *fo, upx_byte *, int, unsigned);
|
||||||
virtual void addFilter16(int filter_id);
|
virtual void addFilter16(int filter_id);
|
||||||
};
|
};
|
||||||
@@ -63,8 +66,4 @@ protected:
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+68
-49
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@users.sourceforge.net
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -31,11 +31,12 @@
|
|||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "packer.h"
|
#include "packer.h"
|
||||||
#include "p_djgpp2.h"
|
#include "p_djgpp2.h"
|
||||||
|
#include "linker.h"
|
||||||
|
|
||||||
static const
|
static const
|
||||||
#include "stub/l_djgpp2.h"
|
#include "stub/i386-dos32.djgpp2.h"
|
||||||
static const
|
static const
|
||||||
#include "stub/stubify.h"
|
#include "stub/i386-dos32.djgpp2-stubify.h"
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -45,13 +46,14 @@ static const
|
|||||||
PackDjgpp2::PackDjgpp2(InputFile *f) :
|
PackDjgpp2::PackDjgpp2(InputFile *f) :
|
||||||
super(f), coff_offset(0)
|
super(f), coff_offset(0)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(external_scnhdr_t) == 40);
|
bele = &N_BELE_RTP::le_policy;
|
||||||
COMPILE_TIME_ASSERT(sizeof(coff_header_t) == 0xa8);
|
COMPILE_TIME_ASSERT(sizeof(external_scnhdr_t) == 40)
|
||||||
COMPILE_TIME_ASSERT(sizeof(stubify_stub) == 2048);
|
COMPILE_TIME_ASSERT(sizeof(coff_header_t) == 0xa8)
|
||||||
COMPILE_TIME_ASSERT_ALIGNOF(external_scnhdr_t, char)
|
COMPILE_TIME_ASSERT_ALIGNED1(external_scnhdr_t)
|
||||||
COMPILE_TIME_ASSERT_ALIGNOF(coff_header_t, char)
|
COMPILE_TIME_ASSERT_ALIGNED1(coff_header_t)
|
||||||
COMPILE_TIME_ASSERT(STUBIFY_STUB_ADLER32 == 0xbf689ba8);
|
COMPILE_TIME_ASSERT(sizeof(stub_i386_dos32_djgpp2_stubify) == 2048)
|
||||||
COMPILE_TIME_ASSERT(STUBIFY_STUB_CRC32 == 0x2ae982b2);
|
COMPILE_TIME_ASSERT(STUB_I386_DOS32_DJGPP2_STUBIFY_ADLER32 == 0xbf689ba8)
|
||||||
|
COMPILE_TIME_ASSERT(STUB_I386_DOS32_DJGPP2_STUBIFY_CRC32 == 0x2ae982b2)
|
||||||
//printf("0x%08x\n", upx_adler32(stubify_stub, sizeof(stubify_stub)));
|
//printf("0x%08x\n", upx_adler32(stubify_stub, sizeof(stubify_stub)));
|
||||||
//assert(upx_adler32(stubify_stub, sizeof(stubify_stub)) == STUBIFY_STUB_ADLER32);
|
//assert(upx_adler32(stubify_stub, sizeof(stubify_stub)) == STUBIFY_STUB_ADLER32);
|
||||||
}
|
}
|
||||||
@@ -66,30 +68,40 @@ const int *PackDjgpp2::getCompressionMethods(int method, int level) const
|
|||||||
const int *PackDjgpp2::getFilters() const
|
const int *PackDjgpp2::getFilters() const
|
||||||
{
|
{
|
||||||
static const int filters[] = {
|
static const int filters[] = {
|
||||||
0x26, 0x24, 0x11, 0x14, 0x13, 0x16, 0x25, 0x15, 0x12,
|
0x26, 0x24, 0x49, 0x46, 0x16, 0x13, 0x14, 0x11,
|
||||||
-1 };
|
FT_ULTRA_BRUTE, 0x25, 0x15, 0x12,
|
||||||
|
FT_END };
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned PackDjgpp2::findOverlapOverhead(const upx_bytep buf,
|
unsigned PackDjgpp2::findOverlapOverhead(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned range,
|
unsigned range,
|
||||||
unsigned upper_limit) const
|
unsigned upper_limit) const
|
||||||
{
|
{
|
||||||
unsigned o = super::findOverlapOverhead(buf, range, upper_limit);
|
unsigned o = super::findOverlapOverhead(buf, tbuf, range, upper_limit);
|
||||||
o = (o + 0x3ff) &~ 0x1ff;
|
o = (o + 0x3ff) &~ 0x1ff;
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PackDjgpp2::buildLoader(const Filter *ft)
|
Linker* PackDjgpp2::newLinker() const
|
||||||
|
{
|
||||||
|
return new ElfLinkerX86;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PackDjgpp2::buildLoader(const Filter *ft)
|
||||||
{
|
{
|
||||||
// prepare loader
|
// prepare loader
|
||||||
initLoader(nrv_loader, sizeof(nrv_loader));
|
initLoader(stub_i386_dos32_djgpp2, sizeof(stub_i386_dos32_djgpp2));
|
||||||
addLoader("IDENTSTR,DJ2MAIN1",
|
addLoader("IDENTSTR,DJ2MAIN1",
|
||||||
ft->id ? "DJCALLT1" : "",
|
ft->id ? "DJCALLT1" : "",
|
||||||
"DJ2MAIN2",
|
ph.first_offset_found == 1 ? "DJ2MAIN2" : "",
|
||||||
getDecompressor(),
|
M_IS_LZMA(ph.method) ? "LZMA_INIT_STACK" : "",
|
||||||
|
getDecompressorSections(),
|
||||||
|
M_IS_LZMA(ph.method) ? "LZMA_DONE_STACK" : "",
|
||||||
"DJ2BSS00",
|
"DJ2BSS00",
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
@@ -99,8 +111,7 @@ int PackDjgpp2::buildLoader(const Filter *ft)
|
|||||||
addLoader("DJCALLT2", NULL);
|
addLoader("DJCALLT2", NULL);
|
||||||
addFilter32(ft->id);
|
addFilter32(ft->id);
|
||||||
}
|
}
|
||||||
addLoader("DJRETURN,+40DXXXX,UPX1HEAD", NULL);
|
addLoader("DJRETURN,+40C,UPX1HEAD", NULL);
|
||||||
return getLoaderSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,23 +131,23 @@ void PackDjgpp2::handleStub(OutputFile *fo)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// "stubify" stub
|
// "stubify" stub
|
||||||
info("Adding stub: %ld bytes", (long)sizeof(stubify_stub));
|
info("Adding stub: %ld bytes", (long)sizeof(stub_i386_dos32_djgpp2_stubify));
|
||||||
fo->write(stubify_stub, sizeof(stubify_stub));
|
fo->write(stub_i386_dos32_djgpp2_stubify, sizeof(stub_i386_dos32_djgpp2_stubify));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool is_dlm(InputFile *fi, long coff_offset)
|
static bool is_dlm(InputFile *fi, unsigned coff_offset)
|
||||||
{
|
{
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
long off;
|
unsigned off;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fi->seek(coff_offset, SEEK_SET);
|
fi->seek(coff_offset, SEEK_SET);
|
||||||
fi->readx(buf, 4);
|
fi->readx(buf, 4);
|
||||||
off = get_le32(buf);
|
off = get_le32(buf);
|
||||||
if (off < 0 || off > coff_offset + 4)
|
if (off > coff_offset + 4)
|
||||||
return false;
|
return false;
|
||||||
fi->seek(off, SEEK_SET);
|
fi->seek(off, SEEK_SET);
|
||||||
fi->readx(buf, 4);
|
fi->readx(buf, 4);
|
||||||
@@ -159,9 +170,9 @@ static void handle_allegropak(InputFile *fi, OutputFile *fo)
|
|||||||
if (memcmp(buf, "slh+", 4) != 0)
|
if (memcmp(buf, "slh+", 4) != 0)
|
||||||
return;
|
return;
|
||||||
pfsize = get_be32_signed(buf+4);
|
pfsize = get_be32_signed(buf+4);
|
||||||
if (pfsize <= 8 || (off_t) pfsize >= (off_t) fi->st.st_size)
|
if (pfsize <= 8 || pfsize >= (off_t) fi->st.st_size)
|
||||||
return;
|
return;
|
||||||
fi->seek(-pfsize, SEEK_END);
|
fi->seek(-(off_t)pfsize, SEEK_END);
|
||||||
} catch (const IOException&) {
|
} catch (const IOException&) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -290,33 +301,35 @@ void PackDjgpp2::pack(OutputFile *fo)
|
|||||||
ft.buf_len = usize - data->size;
|
ft.buf_len = usize - data->size;
|
||||||
ft.addvalue = text->vaddr - hdrsize;
|
ft.addvalue = text->vaddr - hdrsize;
|
||||||
// compress
|
// compress
|
||||||
compressWithFilters(&ft, 512);
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
|
// limit stack size needed for runtime decompression
|
||||||
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
|
compressWithFilters(&ft, 512, &cconf);
|
||||||
|
|
||||||
// patch coff header #2
|
// patch coff header #2
|
||||||
const unsigned lsize = getLoaderSize();
|
const unsigned lsize = getLoaderSize();
|
||||||
|
assert(lsize % 4 == 0);
|
||||||
text->size = lsize; // new size of .text
|
text->size = lsize; // new size of .text
|
||||||
data->size = ph.c_len; // new size of .data
|
data->size = ph.c_len; // new size of .data
|
||||||
|
|
||||||
if (bss->size < ph.overlap_overhead) // give it a .bss
|
unsigned stack = 1024 + ph.overlap_overhead + getDecompressorWrkmemSize();
|
||||||
bss->size = ph.overlap_overhead;
|
stack = ALIGN_UP(stack, 16u);
|
||||||
|
if (bss->size < stack) // give it a .bss
|
||||||
|
bss->size = stack;
|
||||||
|
|
||||||
text->scnptr = sizeof(coff_hdr);
|
text->scnptr = sizeof(coff_hdr);
|
||||||
data->scnptr = text->scnptr + text->size;
|
data->scnptr = text->scnptr + text->size;
|
||||||
data->vaddr = bss->vaddr + ((data->scnptr + data->size) & 0x1ff) - data->size + ph.overlap_overhead - 0x200;
|
data->vaddr = bss->vaddr + ((data->scnptr + data->size) & 0x1ff) - data->size + ph.overlap_overhead - 0x200;
|
||||||
coff_hdr.f_nscns = 3;
|
coff_hdr.f_nscns = 3;
|
||||||
|
|
||||||
// prepare loader
|
linker->defineSymbol("original_entry", coff_hdr.a_entry);
|
||||||
MemBuffer loader(lsize);
|
linker->defineSymbol("length_of_bss", ph.overlap_overhead / 4);
|
||||||
memcpy(loader, getLoader(), lsize);
|
defineDecompressorSymbols();
|
||||||
|
|
||||||
// patch loader
|
|
||||||
patchPackHeader(loader, lsize);
|
|
||||||
patch_le32(loader, lsize, "ENTR", coff_hdr.a_entry);
|
|
||||||
patchFilter32(loader, lsize, &ft);
|
|
||||||
patch_le32(loader, lsize, "BSSL", ph.overlap_overhead / 4);
|
|
||||||
assert(bss->vaddr == ((size + 0x1ff) &~ 0x1ff) + (text->vaddr &~ 0x1ff));
|
assert(bss->vaddr == ((size + 0x1ff) &~ 0x1ff) + (text->vaddr &~ 0x1ff));
|
||||||
patch_le32(loader, lsize, "OUTP", text->vaddr - hdrsize);
|
linker->defineSymbol("stack_for_lzma", bss->vaddr + bss->size);
|
||||||
patch_le32(loader, lsize, "INPP", data->vaddr);
|
linker->defineSymbol("start_of_uncompressed", text->vaddr - hdrsize);
|
||||||
|
linker->defineSymbol("start_of_compressed", data->vaddr);
|
||||||
|
defineFilterSymbols(&ft);
|
||||||
|
|
||||||
// we should not overwrite our decompressor during unpacking
|
// we should not overwrite our decompressor during unpacking
|
||||||
// the original coff header (which is put just before the
|
// the original coff header (which is put just before the
|
||||||
@@ -331,11 +344,21 @@ void PackDjgpp2::pack(OutputFile *fo)
|
|||||||
|
|
||||||
// because of a feature (bug?) in stub.asm we need some padding
|
// because of a feature (bug?) in stub.asm we need some padding
|
||||||
memcpy(obuf+data->size, "UPX", 3);
|
memcpy(obuf+data->size, "UPX", 3);
|
||||||
data->size = ALIGN_UP(data->size, 4);
|
data->size = ALIGN_UP(data->size, 4u);
|
||||||
|
|
||||||
|
linker->defineSymbol("DJ2MAIN1", coff_hdr.a_entry);
|
||||||
|
relocateLoader();
|
||||||
|
|
||||||
|
// prepare loader
|
||||||
|
MemBuffer loader(lsize);
|
||||||
|
memcpy(loader, getLoader(), lsize);
|
||||||
|
patchPackHeader(loader, lsize);
|
||||||
|
|
||||||
// write coff header, loader and compressed file
|
// write coff header, loader and compressed file
|
||||||
fo->write(&coff_hdr, sizeof(coff_hdr));
|
fo->write(&coff_hdr, sizeof(coff_hdr));
|
||||||
fo->write(loader, lsize);
|
fo->write(loader, lsize);
|
||||||
|
if (opt->debug.dump_stub_loader)
|
||||||
|
OutputFile::dump(opt->debug.dump_stub_loader, loader, lsize);
|
||||||
fo->write(obuf, data->size);
|
fo->write(obuf, data->size);
|
||||||
#if 0
|
#if 0
|
||||||
printf("%-13s: coff hdr : %8ld bytes\n", getName(), (long) sizeof(coff_hdr));
|
printf("%-13s: coff hdr : %8ld bytes\n", getName(), (long) sizeof(coff_hdr));
|
||||||
@@ -367,7 +390,7 @@ int PackDjgpp2::canUnpack()
|
|||||||
if (is_dlm(fi, coff_offset))
|
if (is_dlm(fi, coff_offset))
|
||||||
throwCantUnpack("can't handle DLM");
|
throwCantUnpack("can't handle DLM");
|
||||||
fi->seek(coff_offset, SEEK_SET);
|
fi->seek(coff_offset, SEEK_SET);
|
||||||
return readPackHeader(1024) ? 1 : -1;
|
return readPackHeader(4096) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -446,8 +469,4 @@ void PackDjgpp2::unpack(OutputFile *fo)
|
|||||||
handle_allegropak(fi, fo);
|
handle_allegropak(fi, fo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+14
-19
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_DJGPP2_H
|
#ifndef __UPX_P_DJGPP2_H
|
||||||
#define __UPX_P_DJGPP2_H
|
#define __UPX_P_DJGPP2_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -43,6 +43,7 @@ public:
|
|||||||
virtual int getVersion() const { return 14; }
|
virtual int getVersion() const { return 14; }
|
||||||
virtual int getFormat() const { return UPX_F_DJGPP2_COFF; }
|
virtual int getFormat() const { return UPX_F_DJGPP2_COFF; }
|
||||||
virtual const char *getName() const { return "djgpp2/coff"; }
|
virtual const char *getName() const { return "djgpp2/coff"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i386-dos32.djgpp2.coff"; }
|
||||||
virtual const int *getCompressionMethods(int method, int level) const;
|
virtual const int *getCompressionMethods(int method, int level) const;
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
@@ -57,25 +58,24 @@ protected:
|
|||||||
virtual int readFileHeader();
|
virtual int readFileHeader();
|
||||||
|
|
||||||
virtual unsigned findOverlapOverhead(const upx_bytep buf,
|
virtual unsigned findOverlapOverhead(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned range = 0,
|
unsigned range = 0,
|
||||||
unsigned upper_limit = ~0u) const;
|
unsigned upper_limit = ~0u) const;
|
||||||
virtual int buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
|
|
||||||
long coff_offset;
|
unsigned coff_offset;
|
||||||
|
|
||||||
struct external_scnhdr_t
|
__packed_struct(external_scnhdr_t)
|
||||||
{
|
|
||||||
char _[12]; // name, paddr
|
char _[12]; // name, paddr
|
||||||
LE32 vaddr;
|
LE32 vaddr;
|
||||||
LE32 size;
|
LE32 size;
|
||||||
LE32 scnptr;
|
LE32 scnptr;
|
||||||
char misc[12]; // relptr, lnnoptr, nreloc, nlnno
|
char misc[12]; // relptr, lnnoptr, nreloc, nlnno
|
||||||
char __[4]; // flags
|
char __[4]; // flags
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct coff_header_t
|
__packed_struct(coff_header_t)
|
||||||
{
|
|
||||||
// ext_file_hdr
|
// ext_file_hdr
|
||||||
LE16 f_magic;
|
LE16 f_magic;
|
||||||
LE16 f_nscns;
|
LE16 f_nscns;
|
||||||
@@ -96,8 +96,7 @@ protected:
|
|||||||
|
|
||||||
// section headers
|
// section headers
|
||||||
external_scnhdr_t sh[3];
|
external_scnhdr_t sh[3];
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
coff_header_t coff_hdr;
|
coff_header_t coff_hdr;
|
||||||
external_scnhdr_t *text,*data,*bss;
|
external_scnhdr_t *text,*data,*bss;
|
||||||
@@ -108,8 +107,4 @@ protected:
|
|||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+312
-243
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,24 +22,42 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_ELF_H
|
#ifndef __UPX_P_ELF_H
|
||||||
#define __UPX_P_ELF_H
|
#define __UPX_P_ELF_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// Some ELF type definitinons
|
// N_Elf
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
namespace TT_Elf {
|
namespace N_Elf {
|
||||||
|
|
||||||
|
// integral types
|
||||||
|
template <class THalf, class TWord, class TXword, class TAddr, class TOff>
|
||||||
|
struct ElfITypes
|
||||||
|
{
|
||||||
|
typedef THalf Half;
|
||||||
|
typedef TWord Word;
|
||||||
|
typedef TXword Xword;
|
||||||
|
typedef TAddr Addr;
|
||||||
|
typedef TOff Off;
|
||||||
|
typedef THalf Section;
|
||||||
|
typedef THalf Versym;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// The ELF file header. This appears at the start of every ELF file.
|
// The ELF file header. This appears at the start of every ELF file.
|
||||||
template <class Word, class Addr, class Off, class Half>
|
template <class TElfITypes>
|
||||||
struct Ehdr
|
__packed_struct(Ehdr)
|
||||||
{
|
typedef typename TElfITypes::Half Half;
|
||||||
|
typedef typename TElfITypes::Word Word;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
typedef typename TElfITypes::Off Off;
|
||||||
|
|
||||||
unsigned char e_ident[16]; /* Magic number and other info */
|
unsigned char e_ident[16]; /* Magic number and other info */
|
||||||
Half e_type; /* Object file type */
|
Half e_type; /* Object file type */
|
||||||
Half e_machine; /* Architecture */
|
Half e_machine; /* Architecture */
|
||||||
@@ -55,71 +73,72 @@ struct Ehdr
|
|||||||
Half e_shnum; /* Section header table entry count */
|
Half e_shnum; /* Section header table entry count */
|
||||||
Half e_shstrndx; /* Section header string table index */
|
Half e_shstrndx; /* Section header string table index */
|
||||||
|
|
||||||
enum { // e_ident[]
|
# define WANT_EHDR_ENUM 1
|
||||||
EI_CLASS = 4,
|
# include "p_elf_enum.h"
|
||||||
EI_DATA = 5, /* Data encoding */
|
__packed_struct_end()
|
||||||
EI_VERSION = 6,
|
|
||||||
EI_OSABI = 7,
|
|
||||||
EI_ABIVERSION = 8,
|
|
||||||
};
|
|
||||||
enum { // e_ident[EI_CLASS]
|
|
||||||
ELFCLASS32 = 1, /* 32-bit objects */
|
|
||||||
ELFCLASS64 = 2, /* 64-bit objects */
|
|
||||||
};
|
|
||||||
enum { // e_ident[EI_DATA]
|
|
||||||
ELFDATA2LSB = 1, /* 2's complement, little endian */
|
|
||||||
ELFDATA2MSB = 2 /* 2's complement, big endian */
|
|
||||||
};
|
|
||||||
enum { // e_ident[EI_OSABI]
|
|
||||||
ELFOSABI_LINUX = 3
|
|
||||||
};
|
|
||||||
enum { // e_type
|
|
||||||
ET_NONE = 0, /* No file type */
|
|
||||||
ET_REL = 1, /* Relocatable file */
|
|
||||||
ET_EXEC = 2, /* Executable file */
|
|
||||||
ET_DYN = 3, /* Shared object file */
|
|
||||||
ET_CORE = 4, /* Core file */
|
|
||||||
};
|
|
||||||
enum { // e_machine
|
|
||||||
EM_386 = 3,
|
|
||||||
EM_PPC = 20,
|
|
||||||
EM_PPC64 = 21,
|
|
||||||
EM_ARM = 40,
|
|
||||||
EM_X86_64 = 62,
|
|
||||||
};
|
|
||||||
enum { // e_version
|
|
||||||
EV_CURRENT = 1,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
|
|
||||||
template <class Word, class Addr>
|
template <class TElfITypes>
|
||||||
struct Dyn
|
__packed_struct(Dyn)
|
||||||
{
|
typedef typename TElfITypes::Xword Xword;
|
||||||
Word d_tag;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
|
Xword d_tag;
|
||||||
Addr d_val;
|
Addr d_val;
|
||||||
|
|
||||||
enum { // d_tag
|
# define WANT_DYN_ENUM 1
|
||||||
DT_NULL = 0, /* End flag */
|
# include "p_elf_enum.h"
|
||||||
DT_NEEDED = 1, /* Name of needed library */
|
__packed_struct_end()
|
||||||
DT_HASH = 4, /* Hash table of symbol names */
|
|
||||||
DT_STRTAB = 5, /* String table */
|
|
||||||
DT_SYMTAB = 6, /* Symbol table */
|
|
||||||
DT_STRSZ = 10, /* Sizeof string table */
|
|
||||||
};
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
} // namespace TT_Elf
|
|
||||||
|
|
||||||
|
|
||||||
namespace TT_Elf32 {
|
template <class TElfITypes>
|
||||||
|
__packed_struct(Rel)
|
||||||
|
typedef typename TElfITypes::Xword Xword;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
|
Addr r_offset;
|
||||||
|
Xword r_info;
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
|
template <class TElfITypes>
|
||||||
|
__packed_struct(Rela)
|
||||||
|
typedef typename TElfITypes::Xword Xword;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
|
Addr r_offset;
|
||||||
|
Xword r_info;
|
||||||
|
Xword r_addend;
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
|
template <class TElfITypes>
|
||||||
|
__packed_struct(External_Note)
|
||||||
|
typedef typename TElfITypes::Word Word;
|
||||||
|
|
||||||
|
Word xn_namesz; // includes terminating '\0'
|
||||||
|
Word xn_datasz;
|
||||||
|
Word xn_type;
|
||||||
|
//char xn_name[N]; // terminate with '\0'
|
||||||
|
//char xn_data[M]; // aligned to 0 mod 4
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace N_Elf
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// N_Elf32
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
namespace N_Elf32 {
|
||||||
|
|
||||||
|
template <class TElfITypes>
|
||||||
|
__packed_struct(Phdr)
|
||||||
|
typedef typename TElfITypes::Word Word;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
typedef typename TElfITypes::Off Off;
|
||||||
|
|
||||||
// Program segment header.
|
|
||||||
template <class Word, class Addr, class Off>
|
|
||||||
struct Phdr
|
|
||||||
{
|
|
||||||
Word p_type; /* Segment type */
|
Word p_type; /* Segment type */
|
||||||
Off p_offset; /* Segment file offset */
|
Off p_offset; /* Segment file offset */
|
||||||
Addr p_vaddr; /* Segment virtual address */
|
Addr p_vaddr; /* Segment virtual address */
|
||||||
@@ -129,24 +148,17 @@ struct Phdr
|
|||||||
Word p_flags; /* Segment flags */
|
Word p_flags; /* Segment flags */
|
||||||
Word p_align; /* Segment alignment */
|
Word p_align; /* Segment alignment */
|
||||||
|
|
||||||
enum { // p_type
|
# define WANT_PHDR_ENUM 1
|
||||||
PT_LOAD = 1, /* Loadable program segment */
|
# include "p_elf_enum.h"
|
||||||
PT_DYNAMIC = 2, /* Dynamic linking information */
|
__packed_struct_end()
|
||||||
PT_INTERP = 3, /* Name of program interpreter */
|
|
||||||
PT_PHDR = 6, /* Entry for header table itself */
|
|
||||||
};
|
|
||||||
|
|
||||||
enum { // p_flags
|
|
||||||
PF_X = 1, /* Segment is executable */
|
|
||||||
PF_W = 2, /* Segment is writable */
|
|
||||||
PF_R = 4, /* Segment is readable */
|
|
||||||
};
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class Word, class Addr, class Off>
|
template <class TElfITypes>
|
||||||
struct Shdr
|
__packed_struct(Shdr)
|
||||||
{
|
typedef typename TElfITypes::Word Word;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
typedef typename TElfITypes::Off Off;
|
||||||
|
|
||||||
Word sh_name; /* Section name (string tbl index) */
|
Word sh_name; /* Section name (string tbl index) */
|
||||||
Word sh_type; /* Section type */
|
Word sh_type; /* Section type */
|
||||||
Word sh_flags; /* Section flags */
|
Word sh_flags; /* Section flags */
|
||||||
@@ -158,93 +170,50 @@ struct Shdr
|
|||||||
Word sh_addralign; /* Section alignment */
|
Word sh_addralign; /* Section alignment */
|
||||||
Word sh_entsize; /* Entry size if section holds table */
|
Word sh_entsize; /* Entry size if section holds table */
|
||||||
|
|
||||||
enum { // sh_type
|
# define WANT_SHDR_ENUM 1
|
||||||
SHT_NULL = 0, /* Section header table entry unused */
|
# include "p_elf_enum.h"
|
||||||
SHT_PROGBITS = 1, /* Program data */
|
__packed_struct_end()
|
||||||
SHT_SYMTAB = 2, /* Symbol table */
|
|
||||||
SHT_STRTAB = 3, /* String table */
|
|
||||||
SHT_RELA = 4, /* Relocation entries with addends */
|
|
||||||
SHT_HASH = 5, /* Symbol hash table */
|
|
||||||
SHT_DYNAMIC = 6, /* Dynamic linking information */
|
|
||||||
SHT_NOTE = 7, /* Notes */
|
|
||||||
SHT_NOBITS = 8, /* Program space with no data (bss) */
|
|
||||||
SHT_REL = 9, /* Relocation entries, no addends */
|
|
||||||
SHT_SHLIB = 10, /* Reserved */
|
|
||||||
SHT_DYNSYM = 11, /* Dynamic linker symbol table */
|
|
||||||
/* 12, 13 hole */
|
|
||||||
SHT_INIT_ARRAY = 14, /* Array of constructors */
|
|
||||||
SHT_FINI_ARRAY = 15, /* Array of destructors */
|
|
||||||
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
|
|
||||||
SHT_GROUP = 17, /* Section group */
|
|
||||||
SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */
|
|
||||||
SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */
|
|
||||||
};
|
|
||||||
|
|
||||||
enum { // sh_flags
|
|
||||||
SHF_WRITE = (1 << 0), /* Writable */
|
|
||||||
SHF_ALLOC = (1 << 1), /* Occupies memory during execution */
|
|
||||||
SHF_EXECINSTR = (1 << 2), /* Executable */
|
|
||||||
SHF_MERGE = (1 << 4), /* Might be merged */
|
|
||||||
SHF_STRINGS = (1 << 5), /* Contains nul-terminated strings */
|
|
||||||
SHF_INFO_LINK = (1 << 6), /* `sh_info' contains SHT index */
|
|
||||||
SHF_LINK_ORDER = (1 << 7), /* Preserve order after combining */
|
|
||||||
};
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class TT16, class TT32, class TT64>
|
template <class TElfITypes>
|
||||||
struct Sym
|
__packed_struct(Sym)
|
||||||
{
|
typedef typename TElfITypes::Word Word;
|
||||||
TT32 st_name; /* symbol name (index into string table) */
|
typedef typename TElfITypes::Addr Addr;
|
||||||
TT32 st_value; /* symbol value */
|
typedef typename TElfITypes::Section Section;
|
||||||
TT32 st_size; /* symbol size */
|
|
||||||
|
Word st_name; /* symbol name (index into string table) */
|
||||||
|
Addr st_value; /* symbol value */
|
||||||
|
Word st_size; /* symbol size */
|
||||||
unsigned char st_info; /* symbol type and binding */
|
unsigned char st_info; /* symbol type and binding */
|
||||||
unsigned char st_other; /* symbol visibility */
|
unsigned char st_other; /* symbol visibility */
|
||||||
TT16 st_shndx; /* section index */
|
Section st_shndx; /* section index */
|
||||||
|
|
||||||
unsigned int st_bind(unsigned int x) const { return 0xf & (x>>4); }
|
# define WANT_SYM_ENUM 1
|
||||||
unsigned int st_type(unsigned int x) const { return 0xf & x ; }
|
# include "p_elf_enum.h"
|
||||||
unsigned char St_info(unsigned bind, unsigned type) const { return (bind<<4) + (0xf & type); }
|
|
||||||
|
|
||||||
enum { // st_bind (high 4 bits of st_info)
|
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
||||||
STB_LOCAL = 0, /* Local symbol */
|
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||||
STB_GLOBAL = 1, /* Global symbol */
|
static unsigned char make_st_info(unsigned bind, unsigned type)
|
||||||
STB_WEAK = 2, /* Weak symbol */
|
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
||||||
};
|
__packed_struct_end()
|
||||||
|
|
||||||
enum { // st_type (low 4 bits of st_info)
|
|
||||||
STT_NOTYPE = 0, /* Symbol type is unspecified */
|
|
||||||
STT_OBJECT = 1, /* Symbol is a data object */
|
|
||||||
STT_FUNC = 2, /* Symbol is a code object */
|
|
||||||
STT_SECTION = 3, /* Symbol associated with a section */
|
|
||||||
STT_FILE = 4, /* Symbol's name is file name */
|
|
||||||
STT_COMMON = 5, /* Symbol is a common data object */
|
|
||||||
STT_TLS = 6, /* Symbol is thread-local data object*/
|
|
||||||
};
|
|
||||||
|
|
||||||
enum { // st_other (visibility)
|
} // namespace N_Elf32
|
||||||
STV_DEFAULT = 0, /* Default symbol visibility rules */
|
|
||||||
STV_INTERNAL = 1, /* Processor specific hidden class */
|
|
||||||
STV_HIDDEN = 2, /* Sym unavailable in other modules */
|
|
||||||
STV_PROTECTED= 3, /* Not preemptible, not exported */
|
|
||||||
};
|
|
||||||
|
|
||||||
enum { // st_shndx
|
|
||||||
SHN_UNDEF = 0, /* Undefined section */
|
|
||||||
SHN_ABS = 0xfff1, /* Associated symbol is absolute */
|
|
||||||
SHN_COMMON = 0xfff2, /* Associated symbol is common */
|
|
||||||
};
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
} // namespace TT_Elf32
|
/*************************************************************************
|
||||||
|
// N_Elf64
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
namespace TT_Elf64 {
|
namespace N_Elf64 {
|
||||||
|
|
||||||
|
template <class TElfITypes>
|
||||||
|
__packed_struct(Phdr)
|
||||||
|
typedef typename TElfITypes::Word Word;
|
||||||
|
typedef typename TElfITypes::Xword Xword;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
typedef typename TElfITypes::Off Off;
|
||||||
|
|
||||||
// Program segment header.
|
|
||||||
template <class Word, class Xword, class Addr, class Off>
|
|
||||||
struct Phdr
|
|
||||||
{
|
|
||||||
Word p_type; /* Segment type */
|
Word p_type; /* Segment type */
|
||||||
Word p_flags; /* Segment flags */
|
Word p_flags; /* Segment flags */
|
||||||
Off p_offset; /* Segment file offset */
|
Off p_offset; /* Segment file offset */
|
||||||
@@ -254,24 +223,18 @@ struct Phdr
|
|||||||
Xword p_memsz; /* Segment size in memory */
|
Xword p_memsz; /* Segment size in memory */
|
||||||
Xword p_align; /* Segment alignment */
|
Xword p_align; /* Segment alignment */
|
||||||
|
|
||||||
enum { // p_type
|
# define WANT_PHDR_ENUM 1
|
||||||
PT_LOAD = 1, /* Loadable program segment */
|
# include "p_elf_enum.h"
|
||||||
PT_DYNAMIC = 2, /* Dynamic linking information */
|
__packed_struct_end()
|
||||||
PT_INTERP = 3, /* Name of program interpreter */
|
|
||||||
PT_PHDR = 6, /* Entry for header table itself */
|
|
||||||
};
|
|
||||||
|
|
||||||
enum { // p_flags
|
|
||||||
PF_X = 1, /* Segment is executable */
|
|
||||||
PF_W = 2, /* Segment is writable */
|
|
||||||
PF_R = 4, /* Segment is readable */
|
|
||||||
};
|
|
||||||
}
|
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
template <class Word, class Xword, class Addr, class Off>
|
template <class TElfITypes>
|
||||||
struct Shdr
|
__packed_struct(Shdr)
|
||||||
{
|
typedef typename TElfITypes::Word Word;
|
||||||
|
typedef typename TElfITypes::Xword Xword;
|
||||||
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
typedef typename TElfITypes::Off Off;
|
||||||
|
|
||||||
Word sh_name; /* Section name (string tbl index) */
|
Word sh_name; /* Section name (string tbl index) */
|
||||||
Word sh_type; /* Section type */
|
Word sh_type; /* Section type */
|
||||||
Xword sh_flags; /* Section flags */
|
Xword sh_flags; /* Section flags */
|
||||||
@@ -283,90 +246,196 @@ struct Shdr
|
|||||||
Xword sh_addralign; /* Section alignment */
|
Xword sh_addralign; /* Section alignment */
|
||||||
Xword sh_entsize; /* Entry size if section holds table */
|
Xword sh_entsize; /* Entry size if section holds table */
|
||||||
|
|
||||||
enum { // sh_type
|
# define WANT_SHDR_ENUM 1
|
||||||
SHT_NULL = 0, /* Section header table entry unused */
|
# include "p_elf_enum.h"
|
||||||
SHT_PROGBITS = 1, /* Program data */
|
__packed_struct_end()
|
||||||
SHT_SYMTAB = 2, /* Symbol table */
|
|
||||||
SHT_STRTAB = 3, /* String table */
|
|
||||||
SHT_RELA = 4, /* Relocation entries with addends */
|
template <class TElfITypes>
|
||||||
SHT_HASH = 5, /* Symbol hash table */
|
__packed_struct(Sym)
|
||||||
SHT_DYNAMIC = 6, /* Dynamic linking information */
|
typedef typename TElfITypes::Word Word;
|
||||||
SHT_NOTE = 7, /* Notes */
|
typedef typename TElfITypes::Xword Xword;
|
||||||
SHT_NOBITS = 8, /* Program space with no data (bss) */
|
typedef typename TElfITypes::Addr Addr;
|
||||||
SHT_REL = 9, /* Relocation entries, no addends */
|
typedef typename TElfITypes::Section Section;
|
||||||
SHT_SHLIB = 10, /* Reserved */
|
|
||||||
SHT_DYNSYM = 11, /* Dynamic linker symbol table */
|
Word st_name; /* symbol name (index into string table) */
|
||||||
/* 12, 13 hole */
|
unsigned char st_info; /* symbol type and binding */
|
||||||
SHT_INIT_ARRAY = 14, /* Array of constructors */
|
unsigned char st_other; /* symbol visibility */
|
||||||
SHT_FINI_ARRAY = 15, /* Array of destructors */
|
Section st_shndx; /* section index */
|
||||||
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
|
Addr st_value; /* symbol value */
|
||||||
SHT_GROUP = 17, /* Section group */
|
Xword st_size; /* symbol size */
|
||||||
SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */
|
|
||||||
SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */
|
# define WANT_SYM_ENUM 1
|
||||||
};
|
# include "p_elf_enum.h"
|
||||||
}
|
|
||||||
__attribute_packed;
|
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
||||||
|
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||||
|
static unsigned char make_st_info(unsigned bind, unsigned type)
|
||||||
|
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace N_Elf64
|
||||||
|
|
||||||
} // namespace TT_Elf64
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// now for the actual types
|
// aggregate types into an ElfClass
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
typedef TT_Elf ::Ehdr<LE32,LE32,LE32,LE16> Elf_LE32_Ehdr;
|
namespace N_Elf {
|
||||||
typedef TT_Elf32::Phdr<LE32,LE32,LE32> Elf_LE32_Phdr;
|
|
||||||
typedef TT_Elf32::Shdr<LE32,LE32,LE32> Elf_LE32_Shdr;
|
|
||||||
typedef TT_Elf ::Dyn <LE32,LE32> Elf_LE32_Dyn;
|
|
||||||
typedef TT_Elf32::Sym <LE16,LE32,void> Elf_LE32_Sym;
|
|
||||||
|
|
||||||
typedef TT_Elf ::Ehdr<unsigned int,unsigned int,unsigned int,unsigned short> Elf32_Ehdr;
|
template <class TP>
|
||||||
typedef TT_Elf32::Phdr<unsigned int,unsigned int,unsigned int> Elf32_Phdr;
|
struct ElfClass_32
|
||||||
typedef TT_Elf32::Shdr<unsigned int,unsigned int,unsigned int> Elf32_Shdr;
|
{
|
||||||
typedef TT_Elf ::Dyn <unsigned int,unsigned int> Elf32_Dyn;
|
typedef TP BeLePolicy;
|
||||||
typedef TT_Elf32::Sym <unsigned short,unsigned int,void> Elf32_Sym;
|
|
||||||
|
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Ehdr) == 52)
|
// integral types (target endianness)
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Phdr) == 32)
|
typedef typename TP::U16 TE16;
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Shdr) == 40)
|
typedef typename TP::U32 TE32;
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Dyn) == 8)
|
typedef typename TP::U64 TE64;
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Sym) == 16)
|
typedef N_Elf::ElfITypes<TE16, TE32, TE32, TE32, TE32> ElfITypes;
|
||||||
|
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Ehdr) == 52)
|
// ELF types
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Phdr) == 32)
|
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Shdr) == 40)
|
typedef N_Elf32::Phdr<ElfITypes> Phdr;
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Dyn) == 8)
|
typedef N_Elf32::Shdr<ElfITypes> Shdr;
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Sym) == 16)
|
typedef N_Elf ::Dyn <ElfITypes> Dyn;
|
||||||
|
typedef N_Elf ::Rel <ElfITypes> Rel;
|
||||||
|
typedef N_Elf ::Rela<ElfITypes> Rela;
|
||||||
|
typedef N_Elf32::Sym <ElfITypes> Sym;
|
||||||
|
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
||||||
|
|
||||||
|
static void compileTimeAssertions() {
|
||||||
|
BeLePolicy::compileTimeAssertions();
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Ehdr) == 52)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Phdr) == 32)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Shdr) == 40)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Dyn) == 8)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Rel) == 8)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Rela) == 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Sym) == 16)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Ehdr)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Phdr)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Shdr)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Dyn)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Rel)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Rela)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Sym)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef TT_Elf ::Ehdr<LE32,LE64,LE64,LE16> Elf_LE64_Ehdr;
|
template <class TP>
|
||||||
typedef TT_Elf64::Phdr<LE32,LE64,LE64,LE64> Elf_LE64_Phdr;
|
struct ElfClass_64
|
||||||
typedef TT_Elf64::Shdr<LE32,LE64,LE64,LE64> Elf_LE64_Shdr;
|
{
|
||||||
typedef TT_Elf ::Dyn <LE64,LE64> Elf_LE64_Dyn;
|
typedef TP BeLePolicy;
|
||||||
|
|
||||||
typedef TT_Elf ::Ehdr<unsigned int,unsigned long long,
|
// integral types (target endianness)
|
||||||
unsigned long long,unsigned short> Elf64_Ehdr;
|
typedef typename TP::U16 TE16;
|
||||||
typedef TT_Elf64::Phdr<unsigned int,unsigned long long,
|
typedef typename TP::U32 TE32;
|
||||||
unsigned long long,unsigned long long> Elf64_Phdr;
|
typedef typename TP::U64 TE64;
|
||||||
typedef TT_Elf64::Shdr<unsigned int,unsigned long long,
|
typedef N_Elf::ElfITypes<TE16, TE32, TE64, TE64, TE64> ElfITypes;
|
||||||
unsigned long long,unsigned long long> Elf64_Shdr;
|
|
||||||
typedef TT_Elf ::Dyn <unsigned long long,unsigned long long> Elf64_Dyn;
|
// ELF types
|
||||||
|
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
|
||||||
|
typedef N_Elf64::Phdr<ElfITypes> Phdr;
|
||||||
|
typedef N_Elf64::Shdr<ElfITypes> Shdr;
|
||||||
|
typedef N_Elf ::Dyn <ElfITypes> Dyn;
|
||||||
|
typedef N_Elf ::Rel <ElfITypes> Rel;
|
||||||
|
typedef N_Elf ::Rela<ElfITypes> Rela;
|
||||||
|
typedef N_Elf64::Sym <ElfITypes> Sym;
|
||||||
|
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
||||||
|
|
||||||
|
static void compileTimeAssertions() {
|
||||||
|
BeLePolicy::compileTimeAssertions();
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Ehdr) == 64)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Phdr) == 56)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Shdr) == 64)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Dyn) == 16)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Rel) == 16)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Rela) == 24)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(Sym) == 24)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Ehdr)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Phdr)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Shdr)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Dyn)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Rel)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Rela)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(Sym)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE64_Ehdr) == 64)
|
} // namespace N_Elf
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE64_Phdr) == 56)
|
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE64_Shdr) == 64)
|
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE64_Dyn) == 16)
|
|
||||||
|
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf64_Ehdr) == 64)
|
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf64_Phdr) == 56)
|
typedef N_Elf::ElfClass_32<N_BELE_CTP::HostPolicy> ElfClass_Host32;
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf64_Shdr) == 64)
|
typedef N_Elf::ElfClass_64<N_BELE_CTP::HostPolicy> ElfClass_Host64;
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf64_Dyn) == 16)
|
typedef N_Elf::ElfClass_32<N_BELE_CTP::BEPolicy> ElfClass_BE32;
|
||||||
|
typedef N_Elf::ElfClass_64<N_BELE_CTP::BEPolicy> ElfClass_BE64;
|
||||||
|
typedef N_Elf::ElfClass_32<N_BELE_CTP::LEPolicy> ElfClass_LE32;
|
||||||
|
typedef N_Elf::ElfClass_64<N_BELE_CTP::LEPolicy> ElfClass_LE64;
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// shortcuts
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
typedef ElfClass_Host32::Ehdr Elf32_Ehdr;
|
||||||
|
typedef ElfClass_Host32::Phdr Elf32_Phdr;
|
||||||
|
typedef ElfClass_Host32::Shdr Elf32_Shdr;
|
||||||
|
typedef ElfClass_Host32::Dyn Elf32_Dyn;
|
||||||
|
typedef ElfClass_Host32::Rel Elf32_Rel;
|
||||||
|
typedef ElfClass_Host32::Rela Elf32_Rela;
|
||||||
|
typedef ElfClass_Host32::Sym Elf32_Sym;
|
||||||
|
typedef ElfClass_Host32::External_Note Elf32_External_Note;
|
||||||
|
|
||||||
|
typedef ElfClass_Host64::Ehdr Elf64_Ehdr;
|
||||||
|
typedef ElfClass_Host64::Phdr Elf64_Phdr;
|
||||||
|
typedef ElfClass_Host64::Shdr Elf64_Shdr;
|
||||||
|
typedef ElfClass_Host64::Dyn Elf64_Dyn;
|
||||||
|
typedef ElfClass_Host64::Rel Elf64_Rel;
|
||||||
|
typedef ElfClass_Host64::Rela Elf64_Rela;
|
||||||
|
typedef ElfClass_Host64::Sym Elf64_Sym;
|
||||||
|
typedef ElfClass_Host64::External_Note Elf64_External_Note;
|
||||||
|
|
||||||
|
typedef ElfClass_BE32::Ehdr Elf_BE32_Ehdr;
|
||||||
|
typedef ElfClass_BE32::Phdr Elf_BE32_Phdr;
|
||||||
|
typedef ElfClass_BE32::Shdr Elf_BE32_Shdr;
|
||||||
|
typedef ElfClass_BE32::Dyn Elf_BE32_Dyn;
|
||||||
|
typedef ElfClass_BE32::Rel Elf_BE32_Rel;
|
||||||
|
typedef ElfClass_BE32::Rela Elf_BE32_Rela;
|
||||||
|
typedef ElfClass_BE32::Sym Elf_BE32_Sym;
|
||||||
|
typedef ElfClass_BE32::External_Note Elf_BE32_External_Note;
|
||||||
|
|
||||||
|
typedef ElfClass_BE64::Ehdr Elf_BE64_Ehdr;
|
||||||
|
typedef ElfClass_BE64::Phdr Elf_BE64_Phdr;
|
||||||
|
typedef ElfClass_BE64::Shdr Elf_BE64_Shdr;
|
||||||
|
typedef ElfClass_BE64::Dyn Elf_BE64_Dyn;
|
||||||
|
typedef ElfClass_BE64::Rel Elf_BE64_Rel;
|
||||||
|
typedef ElfClass_BE64::Rela Elf_BE64_Rela;
|
||||||
|
typedef ElfClass_BE64::Sym Elf_BE64_Sym;
|
||||||
|
typedef ElfClass_BE64::External_Note Elf_BE64_External_Note;
|
||||||
|
|
||||||
|
typedef ElfClass_LE32::Ehdr Elf_LE32_Ehdr;
|
||||||
|
typedef ElfClass_LE32::Phdr Elf_LE32_Phdr;
|
||||||
|
typedef ElfClass_LE32::Shdr Elf_LE32_Shdr;
|
||||||
|
typedef ElfClass_LE32::Dyn Elf_LE32_Dyn;
|
||||||
|
typedef ElfClass_LE32::Rel Elf_LE32_Rel;
|
||||||
|
typedef ElfClass_LE32::Rela Elf_LE32_Rela;
|
||||||
|
typedef ElfClass_LE32::Sym Elf_LE32_Sym;
|
||||||
|
typedef ElfClass_LE32::External_Note Elf_LE32_External_Note;
|
||||||
|
|
||||||
|
typedef ElfClass_LE64::Ehdr Elf_LE64_Ehdr;
|
||||||
|
typedef ElfClass_LE64::Phdr Elf_LE64_Phdr;
|
||||||
|
typedef ElfClass_LE64::Shdr Elf_LE64_Shdr;
|
||||||
|
typedef ElfClass_LE64::Dyn Elf_LE64_Dyn;
|
||||||
|
typedef ElfClass_LE64::Rel Elf_LE64_Rel;
|
||||||
|
typedef ElfClass_LE64::Rela Elf_LE64_Rela;
|
||||||
|
typedef ElfClass_LE64::Sym Elf_LE64_Sym;
|
||||||
|
typedef ElfClass_LE64::External_Note Elf_LE64_External_Note;
|
||||||
|
|
||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,304 @@
|
|||||||
|
/* p_elf_enum.h --
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2020 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>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// Use the preprocessor to work around
|
||||||
|
// - that the types embedding these enums have to be PODs, and
|
||||||
|
// deriving from an empty base class (which is the usual C++ way
|
||||||
|
// of "importing" enums) does not yield a POD any more
|
||||||
|
// - that older compilers do not correctly perform EBCO
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifdef WANT_EHDR_ENUM
|
||||||
|
#undef WANT_EHDR_ENUM
|
||||||
|
enum { // e_ident[]
|
||||||
|
EI_CLASS = 4,
|
||||||
|
EI_DATA = 5, /* Data encoding */
|
||||||
|
EI_VERSION = 6,
|
||||||
|
EI_OSABI = 7,
|
||||||
|
EI_ABIVERSION = 8
|
||||||
|
};
|
||||||
|
enum { // e_ident[EI_CLASS]
|
||||||
|
ELFCLASS32 = 1, /* 32-bit objects */
|
||||||
|
ELFCLASS64 = 2 /* 64-bit objects */
|
||||||
|
};
|
||||||
|
enum { // e_ident[EI_DATA]
|
||||||
|
ELFDATA2LSB = 1, /* 2's complement, little endian */
|
||||||
|
ELFDATA2MSB = 2 /* 2's complement, big endian */
|
||||||
|
};
|
||||||
|
enum { // e_ident[EI_OSABI]
|
||||||
|
ELFOSABI_NONE = 0, // == ELFOSABI_SYSV
|
||||||
|
ELFOSABI_NETBSD = 2,
|
||||||
|
ELFOSABI_LINUX = 3,
|
||||||
|
ELFOSABI_FREEBSD = 9,
|
||||||
|
ELFOSABI_OPENBSD = 12,
|
||||||
|
ELFOSABI_ARM = 97
|
||||||
|
};
|
||||||
|
enum { // e_type
|
||||||
|
ET_NONE = 0, /* No file type */
|
||||||
|
ET_REL = 1, /* Relocatable file */
|
||||||
|
ET_EXEC = 2, /* Executable file */
|
||||||
|
ET_DYN = 3, /* Shared object file */
|
||||||
|
ET_CORE = 4 /* Core file */
|
||||||
|
};
|
||||||
|
enum { // e_machine
|
||||||
|
EM_386 = 3,
|
||||||
|
EM_MIPS = 8,
|
||||||
|
EM_MIPS_RS3_LE = 10, /* MIPS R3000 little-endian */
|
||||||
|
EM_PPC = 20,
|
||||||
|
EM_PPC64 = 21,
|
||||||
|
EM_ARM = 40,
|
||||||
|
EM_X86_64 = 62,
|
||||||
|
EM_AARCH64 = 183
|
||||||
|
|
||||||
|
};
|
||||||
|
enum { // e_version
|
||||||
|
EV_CURRENT = 1
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WANT_PHDR_ENUM
|
||||||
|
#undef WANT_PHDR_ENUM
|
||||||
|
enum { // p_type
|
||||||
|
PT_LOAD = 1, /* Loadable program segment */
|
||||||
|
PT_DYNAMIC = 2, /* Dynamic linking information */
|
||||||
|
PT_INTERP = 3, /* Name of program interpreter */
|
||||||
|
PT_NOTE = 4, /* Auxiliary information (esp. OpenBSD) */
|
||||||
|
PT_PHDR = 6 /* Entry for header table itself */
|
||||||
|
, PT_GNU_STACK = 0x6474e551 /* Indicates stack executability */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // p_flags
|
||||||
|
PF_X = 1, /* Segment is executable */
|
||||||
|
PF_W = 2, /* Segment is writable */
|
||||||
|
PF_R = 4 /* Segment is readable */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WANT_SHDR_ENUM
|
||||||
|
#undef WANT_SHDR_ENUM
|
||||||
|
enum { // sh_type
|
||||||
|
SHT_NULL = 0, /* Section header table entry unused */
|
||||||
|
SHT_PROGBITS = 1, /* Program data */
|
||||||
|
SHT_SYMTAB = 2, /* Symbol table */
|
||||||
|
SHT_STRTAB = 3, /* String table */
|
||||||
|
SHT_RELA = 4, /* Relocation entries with addends */
|
||||||
|
SHT_HASH = 5, /* Symbol hash table */
|
||||||
|
SHT_DYNAMIC = 6, /* Dynamic linking information */
|
||||||
|
SHT_NOTE = 7, /* Notes */
|
||||||
|
SHT_NOBITS = 8, /* Program space with no data (bss) */
|
||||||
|
SHT_REL = 9, /* Relocation entries, no addends */
|
||||||
|
SHT_SHLIB = 10, /* Reserved */
|
||||||
|
SHT_DYNSYM = 11, /* Dynamic linker symbol table */
|
||||||
|
/* 12, 13 hole */
|
||||||
|
SHT_INIT_ARRAY = 14, /* Array of constructors */
|
||||||
|
SHT_FINI_ARRAY = 15, /* Array of destructors */
|
||||||
|
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
|
||||||
|
SHT_GROUP = 17, /* Section group */
|
||||||
|
SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */
|
||||||
|
SHT_GNU_LIBLIST = 0x6ffffff7 /* Prelink library list */
|
||||||
|
|
||||||
|
, SHT_LOOS = 0x60000000 /* LOcal OS; SHT_ANDROID_REL{,A} is +1, +2 */
|
||||||
|
, SHT_LOPROC = 0x70000000/* Start of processor-specific */
|
||||||
|
, SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3) /* ARM attributes section. */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // sh_flags
|
||||||
|
SHF_WRITE = (1 << 0), /* Writable */
|
||||||
|
SHF_ALLOC = (1 << 1), /* Occupies memory during execution */
|
||||||
|
SHF_EXECINSTR = (1 << 2), /* Executable */
|
||||||
|
SHF_MERGE = (1 << 4), /* Might be merged */
|
||||||
|
SHF_STRINGS = (1 << 5), /* Contains nul-terminated strings */
|
||||||
|
SHF_INFO_LINK = (1 << 6), /* 'sh_info' contains SHT index */
|
||||||
|
SHF_LINK_ORDER = (1 << 7) /* Preserve order after combining */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WANT_DYN_ENUM
|
||||||
|
#undef WANT_DYN_ENUM
|
||||||
|
enum { // d_tag
|
||||||
|
DT_NULL = 0, /* End flag */
|
||||||
|
DT_NEEDED = 1, /* Name of needed library */
|
||||||
|
DT_PLTRELSZ = 2, /* Size in bytes of PLT relocs */
|
||||||
|
DT_PLTGOT = 3, /* Processor defined value */
|
||||||
|
DT_HASH = 4, /* Hash table of symbol names */
|
||||||
|
DT_STRTAB = 5, /* String table */
|
||||||
|
DT_SYMTAB = 6, /* Symbol table */
|
||||||
|
DT_RELA = 7, /* Relocations which do contain an addend */
|
||||||
|
DT_RELASZ = 8, /* Total size of Rela relocs */
|
||||||
|
DT_RELAENT = 9, /* Size of one RELA relocation */
|
||||||
|
DT_STRSZ = 10, /* Size of string table */
|
||||||
|
DT_SYMENT = 11, /* Size of one symbol table entry */
|
||||||
|
DT_INIT = 12, /* Address of init function */
|
||||||
|
DT_FINI = 13, /* Address of termination function */
|
||||||
|
|
||||||
|
DT_REL = 17, /* Relocations which contain no addend */
|
||||||
|
DT_RELSZ = 18, /* Total size of Rel relocs */
|
||||||
|
DT_RELENT = 19, /* Size of one Rel relocation */
|
||||||
|
DT_PLTREL = 20, /* Type of reloc in PLT */
|
||||||
|
DT_TEXTREL = 22, /* Reloc might modify .text */
|
||||||
|
DT_JMPREL = 23, /* Address of PLT relocs */
|
||||||
|
DT_INIT_ARRAY = 25, /* Array with addresses of init fct */
|
||||||
|
DT_FINI_ARRAY = 26, /* Array with addresses of fini fct */
|
||||||
|
DT_INIT_ARRAYSZ= 27, /* size in bytes */
|
||||||
|
DT_FINI_ARRAYSZ= 28, /* size in bytes */
|
||||||
|
DT_PREINIT_ARRAY = 32, /* Array with addresses of preinit fct*/
|
||||||
|
DT_PREINIT_ARRAYSZ= 33, /* size in bytes */
|
||||||
|
DT_CHECKSUM = 0x6ffffdf8, /* Only for prelink? */
|
||||||
|
DT_GNU_HASH = 0x6ffffef5, /* GNU-style hash table */
|
||||||
|
DT_VERSYM = 0x6ffffff0, /* version[] for each symbol */
|
||||||
|
DT_FLAGS_1 = 0x6ffffffb, /* DF_1_* */
|
||||||
|
DT_VERDEF = 0x6ffffffc, /* version definitions[] */
|
||||||
|
DT_VERNEEDED= 0x6ffffffe /* version[] needed */
|
||||||
|
};
|
||||||
|
enum { // DT_FLAGS_1
|
||||||
|
DF_1_NOW = 0x00000001, /* Set RTLD_NOW for this object. */
|
||||||
|
DF_1_PIE = 0x08000000 // Position-Independent Executable (main program)
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WANT_SYM_ENUM
|
||||||
|
#undef WANT_SYM_ENUM
|
||||||
|
enum { // st_bind (high 4 bits of st_info)
|
||||||
|
STB_LOCAL = 0, /* Local symbol */
|
||||||
|
STB_GLOBAL = 1, /* Global symbol */
|
||||||
|
STB_WEAK = 2 /* Weak symbol */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // st_type (low 4 bits of st_info)
|
||||||
|
STT_NOTYPE = 0, /* Symbol type is unspecified */
|
||||||
|
STT_OBJECT = 1, /* Symbol is a data object */
|
||||||
|
STT_FUNC = 2, /* Symbol is a code object */
|
||||||
|
STT_SECTION = 3, /* Symbol associated with a section */
|
||||||
|
STT_FILE = 4, /* Symbol's name is file name */
|
||||||
|
STT_COMMON = 5, /* Symbol is a common data object */
|
||||||
|
STT_TLS = 6 /* Symbol is thread-local data object*/
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // st_other (visibility)
|
||||||
|
STV_DEFAULT = 0, /* Default symbol visibility rules */
|
||||||
|
STV_INTERNAL = 1, /* Processor specific hidden class */
|
||||||
|
STV_HIDDEN = 2, /* Sym unavailable in other modules */
|
||||||
|
STV_PROTECTED= 3 /* Not preemptible, not exported */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // st_shndx
|
||||||
|
SHN_UNDEF = 0, /* Undefined section */
|
||||||
|
SHN_ABS = 0xfff1, /* Associated symbol is absolute */
|
||||||
|
SHN_COMMON = 0xfff2 /* Associated symbol is common */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WANT_REL_ENUM //{
|
||||||
|
#undef WANT_REL_ENUM
|
||||||
|
static inline unsigned ELF32_R_TYPE(unsigned x) { return 0xff & x; }
|
||||||
|
static inline unsigned ELF64_R_TYPE(upx_uint64_t x) { return 0xffffffff & (unsigned)x; }
|
||||||
|
|
||||||
|
# undef R_PPC_RELATIVE
|
||||||
|
# undef R_PPC64_RELATIVE
|
||||||
|
# undef R_PPC_JMP_SLOT
|
||||||
|
# undef R_PPC64_JMP_SLOT
|
||||||
|
enum { // relocation types
|
||||||
|
R_386_RELATIVE = 8,
|
||||||
|
R_AARCH64_RELATIVE = 1027,
|
||||||
|
R_ARM_RELATIVE = 23,
|
||||||
|
R_PPC_RELATIVE = 22,
|
||||||
|
R_PPC64_RELATIVE = R_PPC_RELATIVE,
|
||||||
|
R_X86_64_RELATIVE = 8,
|
||||||
|
|
||||||
|
R_386_JMP_SLOT = 7,
|
||||||
|
R_AARCH64_JUMP_SLOT = 1026,
|
||||||
|
R_ARM_JUMP_SLOT = 22,
|
||||||
|
R_PPC_JMP_SLOT = 21,
|
||||||
|
R_PPC64_JMP_SLOT = R_PPC_JMP_SLOT,
|
||||||
|
R_X86_64_JUMP_SLOT = 7
|
||||||
|
|
||||||
|
, R_ARM_ABS32 = 2
|
||||||
|
, R_ARM_GLOB_DAT = 21
|
||||||
|
|
||||||
|
, R_AARCH64_ABS64 = 257
|
||||||
|
, R_AARCH64_GLOB_DAT = 1025
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif //}
|
||||||
|
|
||||||
|
#ifdef WANT_NHDR_ENUM
|
||||||
|
#undef WANT_NHDR_ENUM
|
||||||
|
enum { // ELF PT_NOTE types
|
||||||
|
#define ELF_NOTE_GNU_NAME "GNU\0"
|
||||||
|
NT_GNU_ABI_TAG = 1,
|
||||||
|
NT_GNU_HWCAP = 2,
|
||||||
|
NT_GNU_BUILD_ID = 3,
|
||||||
|
|
||||||
|
#define ELF_NOTE_OPENBSD_NAME "OpenBSD\0"
|
||||||
|
NHDR_OPENBSD_TAG = 1,
|
||||||
|
|
||||||
|
#define ELF_NOTE_NETBSD_NAME "NetBSD\0"
|
||||||
|
NHDR_NETBSD_TAG = 1,
|
||||||
|
NHDR_CHECKSUM_TAG = 2,
|
||||||
|
NHDR_PAX_TAG = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // descsz descriptor sizes
|
||||||
|
GNU_ABI_DESCSZ = 16, // int GNU_OS, major, minor, subminor;
|
||||||
|
NETBSD_DESCSZ = 4, // major_ver * (10**8) + minor
|
||||||
|
OPENBSD_DESCSZ = 4, // 32-bit zero
|
||||||
|
// CHECKSUM_DESCSZ is 2*sizeof(short) + sizeof(checksum)
|
||||||
|
PAX_DESCSZ = 4 // 32-bit mask
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // GNU OS/version
|
||||||
|
GNU_OS_LINUX = 0,
|
||||||
|
GNU_OS_HURD = 1,
|
||||||
|
GNU_OS_SOLARIS = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { // NetBSD checksum methods
|
||||||
|
CHECKSUM_CRC32 = 1,
|
||||||
|
CHECKSUM_MD5 = 2,
|
||||||
|
CHECKSUM_SHA1 = 3,
|
||||||
|
CHECKSUM_SHA256 = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ELF_NOTE_PAX_NAME "PaX\0"
|
||||||
|
enum { // NetBSD PaX bit values
|
||||||
|
PAX_MPROTECT = (1<<0), /* force enable Mprotect */
|
||||||
|
PAX_NOMPROTECT = (1<<1), /* force disable Mprotect */
|
||||||
|
PAX_GUARD = (1<<2), /* force enable SEGVguard */
|
||||||
|
PAX_NOGUARD = (1<<3), /* force disable SEGVguard */
|
||||||
|
PAX_ASLR = (1<<4), /* force enable ASLR */
|
||||||
|
PAX_NOASLR = (1<<5) /* force disable ASLR */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
-179
@@ -1,179 +0,0 @@
|
|||||||
/* p_elks.cpp --
|
|
||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
|
||||||
Copyright (C) 1996-2004 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 ml1050@cdata.tvnet.hu
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "conf.h"
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
#include "file.h"
|
|
||||||
#include "filter.h"
|
|
||||||
#include "packer.h"
|
|
||||||
#include "p_vmlinz.h"
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
static const
|
|
||||||
#include "stub/l_vmlinz.h"
|
|
||||||
|
|
||||||
// from elks-0.0.83/Documentation/boot.txt
|
|
||||||
static const unsigned kernel_entry = 0x100000;
|
|
||||||
static const unsigned stack_during_uncompression = 0x90000;
|
|
||||||
static const unsigned zimage_offset = 0x1000;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
const int *PackElks8086::getCompressionMethods(int method, int level) const
|
|
||||||
{
|
|
||||||
return Packer::getDefaultCompressionMethods_8(method, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const int *PackElks8086::getFilters() const
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
// common util routines
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
int PackElks8086::decompressKernel()
|
|
||||||
{
|
|
||||||
// not used
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PackElks8086::readKernel()
|
|
||||||
{
|
|
||||||
int klen = file_size - setup_size;
|
|
||||||
fi->seek(0, SEEK_SET);
|
|
||||||
|
|
||||||
setup_buf.alloc(setup_size);
|
|
||||||
fi->readx(setup_buf, setup_size);
|
|
||||||
|
|
||||||
ibuf.alloc(klen);
|
|
||||||
fi->readx(ibuf, klen);
|
|
||||||
|
|
||||||
obuf.allocForCompression(klen);
|
|
||||||
|
|
||||||
ph.u_len = klen;
|
|
||||||
ph.filter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
int PackElks8086::buildLoader(const Filter *ft)
|
|
||||||
{
|
|
||||||
// prepare loader
|
|
||||||
initLoader(nrv_loader, sizeof(nrv_loader));
|
|
||||||
// FIXME
|
|
||||||
UNUSED(ft);
|
|
||||||
return getLoaderSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PackElks8086::pack(OutputFile *fo)
|
|
||||||
{
|
|
||||||
readKernel();
|
|
||||||
|
|
||||||
// prepare filter
|
|
||||||
Filter ft(ph.level);
|
|
||||||
ft.buf_len = ph.u_len;
|
|
||||||
ft.addvalue = kernel_entry;
|
|
||||||
// compress
|
|
||||||
compressWithFilters(&ft, overlap_range);
|
|
||||||
|
|
||||||
const unsigned lsize = getLoaderSize();
|
|
||||||
MemBuffer loader(lsize);
|
|
||||||
memcpy(loader, getLoader(), lsize);
|
|
||||||
|
|
||||||
patchPackHeader(loader, lsize);
|
|
||||||
#if 0
|
|
||||||
// FIXME
|
|
||||||
patchFilter32(loader, lsize, &ft);
|
|
||||||
patch_le32(loader, lsize, "ESI1", zimage_offset + lsize);
|
|
||||||
patch_le32(loader, lsize, "KEIP", kernel_entry);
|
|
||||||
patch_le32(loader, lsize, "STAK", stack_during_uncompression);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
boot_sect_t * const bs = (boot_sect_t *) ((unsigned char *) setup_buf);
|
|
||||||
bs->sys_size = ALIGN_UP(lsize + ph.c_len, 16) / 16;
|
|
||||||
|
|
||||||
fo->write(setup_buf, setup_buf.getSize());
|
|
||||||
fo->write(loader, lsize);
|
|
||||||
fo->write(obuf, ph.c_len);
|
|
||||||
#if 0
|
|
||||||
printf("%-13s: setup : %8ld bytes\n", getName(), (long) setup_buf.getSize());
|
|
||||||
printf("%-13s: loader : %8ld bytes\n", getName(), (long) lsize);
|
|
||||||
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) ph.c_len);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// finally check the compression ratio
|
|
||||||
if (!checkFinalCompressionRatio(fo))
|
|
||||||
throwNotCompressible();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
// unpack
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
int PackElks8086::canUnpack()
|
|
||||||
{
|
|
||||||
if (readFileHeader() != getFormat())
|
|
||||||
return false;
|
|
||||||
fi->seek(setup_size, SEEK_SET);
|
|
||||||
return readPackHeader(1024) ? 1 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PackElks8086::unpack(OutputFile *)
|
|
||||||
{
|
|
||||||
// no uncompression support for this format yet
|
|
||||||
|
|
||||||
// FIXME: but we could write the uncompressed "Image" image
|
|
||||||
|
|
||||||
throwCantUnpack("build a new kernel instead :-)");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* if 0 */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
+269
-95
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@users.sourceforge.net
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -31,9 +31,10 @@
|
|||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "packer.h"
|
#include "packer.h"
|
||||||
#include "p_exe.h"
|
#include "p_exe.h"
|
||||||
|
#include "linker.h"
|
||||||
|
|
||||||
static const
|
static const
|
||||||
#include "stub/l_exe.h"
|
#include "stub/i086-dos16.exe.h"
|
||||||
|
|
||||||
#define RSFCRI 4096 // Reserved Space For Compressed Relocation Info
|
#define RSFCRI 4096 // Reserved Space For Compressed Relocation Info
|
||||||
#define MAXMATCH 0x2000
|
#define MAXMATCH 0x2000
|
||||||
@@ -49,14 +50,22 @@ static const
|
|||||||
PackExe::PackExe(InputFile *f) :
|
PackExe::PackExe(InputFile *f) :
|
||||||
super(f)
|
super(f)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32);
|
bele = &N_BELE_RTP::le_policy;
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(exe_header_t)
|
||||||
ih_exesize = ih_imagesize = ih_overlay = 0;
|
ih_exesize = ih_imagesize = ih_overlay = 0;
|
||||||
|
stack_for_lzma = 0;
|
||||||
|
use_clear_dirty_stack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const int *PackExe::getCompressionMethods(int method, int level) const
|
const int *PackExe::getCompressionMethods(int method, int level) const
|
||||||
{
|
{
|
||||||
bool small = ih_imagesize <= 256*1024;
|
bool small = ih_imagesize <= 256*1024;
|
||||||
|
// disable lzma for "--brute" unless explicitly given "--lzma"
|
||||||
|
// WARNING: this side effect persists for later files!
|
||||||
|
if (opt->all_methods_use_lzma && !opt->method_lzma_seen)
|
||||||
|
opt->all_methods_use_lzma = false;
|
||||||
return Packer::getDefaultCompressionMethods_8(method, level, small);
|
return Packer::getDefaultCompressionMethods_8(method, level, small);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +81,7 @@ int PackExe::fillExeHeader(struct exe_header_t *eh) const
|
|||||||
#define oh (*eh)
|
#define oh (*eh)
|
||||||
// fill new exe header
|
// fill new exe header
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
if (!opt->dos_exe.no_reloc)
|
if (!opt->dos_exe.no_reloc && !M_IS_LZMA(ph.method))
|
||||||
flag |= USEJUMP;
|
flag |= USEJUMP;
|
||||||
if (ih.relocs == 0)
|
if (ih.relocs == 0)
|
||||||
flag |= NORELOC;
|
flag |= NORELOC;
|
||||||
@@ -80,9 +89,17 @@ int PackExe::fillExeHeader(struct exe_header_t *eh) const
|
|||||||
memset(&oh,0,sizeof(oh));
|
memset(&oh,0,sizeof(oh));
|
||||||
oh.ident = 'M' + 'Z' * 256;
|
oh.ident = 'M' + 'Z' * 256;
|
||||||
oh.headsize16 = 2;
|
oh.headsize16 = 2;
|
||||||
oh.ip = 0;
|
|
||||||
|
|
||||||
oh.sp = ih.sp > 0x200 ? (unsigned) ih.sp : 0x200;
|
unsigned minsp = 0x200;
|
||||||
|
if (M_IS_LZMA(ph.method))
|
||||||
|
minsp = stack_for_lzma;
|
||||||
|
minsp = ALIGN_UP(minsp, 16u);
|
||||||
|
assert(minsp < 0xff00);
|
||||||
|
if (oh.sp > minsp)
|
||||||
|
minsp = oh.sp;
|
||||||
|
if (minsp < 0xff00 - 2)
|
||||||
|
minsp = ALIGN_UP(minsp, 2u);
|
||||||
|
oh.sp = minsp;
|
||||||
|
|
||||||
unsigned destpara = (ph.u_len + ph.overlap_overhead - ph.c_len + 31) / 16;
|
unsigned destpara = (ph.u_len + ph.overlap_overhead - ph.c_len + 31) / 16;
|
||||||
oh.ss = ph.c_len/16 + destpara;
|
oh.ss = ph.c_len/16 + destpara;
|
||||||
@@ -94,63 +111,14 @@ int PackExe::fillExeHeader(struct exe_header_t *eh) const
|
|||||||
|
|
||||||
if (oh.ss != ih.ss)
|
if (oh.ss != ih.ss)
|
||||||
flag |= SS;
|
flag |= SS;
|
||||||
if (oh.sp != ih.sp)
|
if (oh.sp != ih.sp || M_IS_LZMA(ph.method))
|
||||||
flag |= SP;
|
flag |= SP;
|
||||||
return flag;
|
return flag;
|
||||||
#undef oh
|
#undef oh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackExe::addLoaderEpilogue(int flag)
|
||||||
int PackExe::buildLoader(const Filter *)
|
|
||||||
{
|
{
|
||||||
struct exe_header_t tmp_oh;
|
|
||||||
int flag = fillExeHeader(&tmp_oh);
|
|
||||||
|
|
||||||
// prepare loader
|
|
||||||
initLoader(nrv_loader,sizeof(nrv_loader));
|
|
||||||
addLoader("EXEENTRY",
|
|
||||||
relocsize ? "EXERELPU" : "",
|
|
||||||
"EXEMAIN4,+G5DXXXX,UPX1HEAD,EXECUTPO",
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
if (ph.method == M_NRV2B_8)
|
|
||||||
addLoader("NRV2B16S", // decompressor
|
|
||||||
ph.u_len > DI_LIMIT ? "N2B64K01" : "",
|
|
||||||
"NRV2BEX1",
|
|
||||||
opt->cpu == opt->CPU_8086 ? "N2BX8601" : "N2B28601",
|
|
||||||
"NRV2BEX2",
|
|
||||||
opt->cpu == opt->CPU_8086 ? "N2BX8602" : "N2B28602",
|
|
||||||
"NRV2BEX3",
|
|
||||||
ph.c_len > 0xffff ? "N2B64K02" : "",
|
|
||||||
"NRV2BEX9,NRV2B16E",
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
else if (ph.method == M_NRV2D_8)
|
|
||||||
addLoader("NRV2D16S",
|
|
||||||
ph.u_len > DI_LIMIT ? "N2D64K01" : "",
|
|
||||||
"NRV2DEX1",
|
|
||||||
opt->cpu == opt->CPU_8086 ? "N2DX8601" : "N2D28601",
|
|
||||||
"NRV2DEX2",
|
|
||||||
opt->cpu == opt->CPU_8086 ? "N2DX8602" : "N2D28602",
|
|
||||||
"NRV2DEX3",
|
|
||||||
ph.c_len > 0xffff ? "N2D64K02" : "",
|
|
||||||
"NRV2DEX9,NRV2D16E",
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
else if (ph.method == M_NRV2E_8)
|
|
||||||
addLoader("NRV2E16S",
|
|
||||||
ph.u_len > DI_LIMIT ? "N2E64K01" : "",
|
|
||||||
"NRV2EEX1",
|
|
||||||
opt->cpu == opt->CPU_8086 ? "N2EX8601" : "N2E28601",
|
|
||||||
"NRV2EEX2",
|
|
||||||
opt->cpu == opt->CPU_8086 ? "N2EX8602" : "N2E28602",
|
|
||||||
"NRV2EEX3",
|
|
||||||
ph.c_len > 0xffff ? "N2E64K02" : "",
|
|
||||||
"NRV2EEX9,NRV2E16E",
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
else
|
|
||||||
throwInternalError("unknown compression method");
|
|
||||||
addLoader("EXEMAIN5", NULL);
|
addLoader("EXEMAIN5", NULL);
|
||||||
if (relocsize)
|
if (relocsize)
|
||||||
addLoader(ph.u_len <= DI_LIMIT || (ph.u_len & 0x7fff) >= relocsize ? "EXENOADJ" : "EXEADJUS",
|
addLoader(ph.u_len <= DI_LIMIT || (ph.u_len & 0x7fff) >= relocsize ? "EXENOADJ" : "EXEADJUS",
|
||||||
@@ -162,6 +130,7 @@ int PackExe::buildLoader(const Filter *)
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
addLoader("EXEMAIN8",
|
addLoader("EXEMAIN8",
|
||||||
|
device_driver ? "DEVICEEND" : "",
|
||||||
(flag & SS) ? "EXESTACK" : "",
|
(flag & SS) ? "EXESTACK" : "",
|
||||||
(flag & SP) ? "EXESTASP" : "",
|
(flag & SP) ? "EXESTASP" : "",
|
||||||
(flag & USEJUMP) ? "EXEJUMPF" : "",
|
(flag & USEJUMP) ? "EXEJUMPF" : "",
|
||||||
@@ -172,7 +141,132 @@ int PackExe::buildLoader(const Filter *)
|
|||||||
"EXERETIP",
|
"EXERETIP",
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
return getLoaderSize();
|
|
||||||
|
linker->defineSymbol("original_cs", ih.cs);
|
||||||
|
linker->defineSymbol("original_ip", ih.ip);
|
||||||
|
linker->defineSymbol("original_sp", ih.sp);
|
||||||
|
linker->defineSymbol("original_ss", ih.ss);
|
||||||
|
linker->defineSymbol("reloc_size",
|
||||||
|
(ph.u_len <= DI_LIMIT || (ph.u_len & 0x7fff)
|
||||||
|
>= relocsize ? 0 : MAXRELOCS) - relocsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PackExe::buildLoader(const Filter *)
|
||||||
|
{
|
||||||
|
// get flag
|
||||||
|
exe_header_t dummy_oh;
|
||||||
|
int flag = fillExeHeader(&dummy_oh);
|
||||||
|
|
||||||
|
initLoader(stub_i086_dos16_exe, sizeof(stub_i086_dos16_exe));
|
||||||
|
|
||||||
|
if (M_IS_LZMA(ph.method))
|
||||||
|
{
|
||||||
|
addLoader("LZMA_DEC00",
|
||||||
|
opt->small ? "LZMA_DEC10" : "LZMA_DEC20",
|
||||||
|
"LZMA_DEC30",
|
||||||
|
use_clear_dirty_stack ? "LZMA_DEC31" : "",
|
||||||
|
"LZMA_DEC32",
|
||||||
|
ph.u_len > 0xffff ? "LZMA_DEC33" : "",
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
addLoaderEpilogue(flag);
|
||||||
|
defineDecompressorSymbols();
|
||||||
|
const unsigned lsize0 = getLoaderSize();
|
||||||
|
|
||||||
|
// Lzma decompression code starts at ss:0x10, and its size is
|
||||||
|
// lsize bytes. It also needs getDecompressorWrkmemSize() bytes
|
||||||
|
// during uncompression. It also uses some stack, so 0x100
|
||||||
|
// more bytes are allocated
|
||||||
|
stack_for_lzma = 0x10 + lsize0 + getDecompressorWrkmemSize() + 0x100;
|
||||||
|
stack_for_lzma = ALIGN_UP(stack_for_lzma, 16u);
|
||||||
|
|
||||||
|
unsigned clear_dirty_stack_low = 0x10 + lsize0;
|
||||||
|
clear_dirty_stack_low = ALIGN_UP(clear_dirty_stack_low, 2u);
|
||||||
|
if (use_clear_dirty_stack)
|
||||||
|
linker->defineSymbol("clear_dirty_stack_low", clear_dirty_stack_low);
|
||||||
|
|
||||||
|
relocateLoader();
|
||||||
|
const unsigned lsize = getLoaderSize();
|
||||||
|
assert(lsize0 == lsize);
|
||||||
|
MemBuffer loader(lsize);
|
||||||
|
memcpy(loader, getLoader(), lsize);
|
||||||
|
|
||||||
|
MemBuffer compressed_lzma;
|
||||||
|
compressed_lzma.allocForCompression(lsize);
|
||||||
|
unsigned c_len_lzma = MemBuffer::getSizeForCompression(lsize);
|
||||||
|
int r = upx_compress(loader, lsize, compressed_lzma, &c_len_lzma,
|
||||||
|
NULL, M_NRV2B_LE16, 9, NULL, NULL);
|
||||||
|
assert(r == UPX_E_OK); assert(c_len_lzma < lsize);
|
||||||
|
|
||||||
|
info("lzma+relocator code compressed: %u -> %u", lsize, c_len_lzma);
|
||||||
|
// reinit the loader
|
||||||
|
initLoader(stub_i086_dos16_exe, sizeof(stub_i086_dos16_exe));
|
||||||
|
// prepare loader
|
||||||
|
if (device_driver)
|
||||||
|
addLoader("DEVICEENTRY,LZMADEVICE,DEVICEENTRY2", NULL);
|
||||||
|
|
||||||
|
linker->addSection("COMPRESSED_LZMA", compressed_lzma, c_len_lzma, 0);
|
||||||
|
addLoader("LZMAENTRY,NRV2B160,NRVDDONE,NRVDECO1,NRVGTD00,NRVDECO2",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (device_driver)
|
||||||
|
addLoader("DEVICEENTRY,DEVICEENTRY2", NULL);
|
||||||
|
|
||||||
|
addLoader("EXEENTRY",
|
||||||
|
M_IS_LZMA(ph.method) && device_driver ? "LONGSUB" : "SHORTSUB",
|
||||||
|
"JNCDOCOPY",
|
||||||
|
relocsize ? "EXERELPU" : "",
|
||||||
|
"EXEMAIN4",
|
||||||
|
M_IS_LZMA(ph.method) ? "" : "EXEMAIN4B",
|
||||||
|
"EXEMAIN4C",
|
||||||
|
M_IS_LZMA(ph.method) ? "COMPRESSED_LZMA_START,COMPRESSED_LZMA" : "",
|
||||||
|
"+G5DXXXX,UPX1HEAD,EXECUTPO",
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (ph.method == M_NRV2B_8)
|
||||||
|
addLoader("NRV2B16S", // decompressor
|
||||||
|
ph.u_len > DI_LIMIT ? "N2B64K01" : "",
|
||||||
|
"NRV2BEX1",
|
||||||
|
opt->cpu == opt->CPU_8086 ? "N2BX8601" : "N2B28601",
|
||||||
|
"NRV2BEX2",
|
||||||
|
opt->cpu == opt->CPU_8086 ? "N2BX8602" : "N2B28602",
|
||||||
|
"NRV2BEX3",
|
||||||
|
ph.c_len > 0xffff ? "N2B64K02" : "",
|
||||||
|
"NRV2BEX9",
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
else if (ph.method == M_NRV2D_8)
|
||||||
|
addLoader("NRV2D16S",
|
||||||
|
ph.u_len > DI_LIMIT ? "N2D64K01" : "",
|
||||||
|
"NRV2DEX1",
|
||||||
|
opt->cpu == opt->CPU_8086 ? "N2DX8601" : "N2D28601",
|
||||||
|
"NRV2DEX2",
|
||||||
|
opt->cpu == opt->CPU_8086 ? "N2DX8602" : "N2D28602",
|
||||||
|
"NRV2DEX3",
|
||||||
|
ph.c_len > 0xffff ? "N2D64K02" : "",
|
||||||
|
"NRV2DEX9",
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
else if (ph.method == M_NRV2E_8)
|
||||||
|
addLoader("NRV2E16S",
|
||||||
|
ph.u_len > DI_LIMIT ? "N2E64K01" : "",
|
||||||
|
"NRV2EEX1",
|
||||||
|
opt->cpu == opt->CPU_8086 ? "N2EX8601" : "N2E28601",
|
||||||
|
"NRV2EEX2",
|
||||||
|
opt->cpu == opt->CPU_8086 ? "N2EX8602" : "N2E28602",
|
||||||
|
"NRV2EEX3",
|
||||||
|
ph.c_len > 0xffff ? "N2E64K02" : "",
|
||||||
|
"NRV2EEX9",
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
else if M_IS_LZMA(ph.method)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
throwInternalError("unknown compression method");
|
||||||
|
|
||||||
|
addLoaderEpilogue(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,9 +281,13 @@ int PackExe::readFileHeader()
|
|||||||
if (ih.ident != 'M' + 'Z'*256 && ih.ident != 'Z' + 'M'*256)
|
if (ih.ident != 'M' + 'Z'*256 && ih.ident != 'Z' + 'M'*256)
|
||||||
return 0;
|
return 0;
|
||||||
ih_exesize = ih.m512 + ih.p512*512 - (ih.m512 ? 512 : 0);
|
ih_exesize = ih.m512 + ih.p512*512 - (ih.m512 ? 512 : 0);
|
||||||
|
if (!ih_exesize) {
|
||||||
|
ih_exesize = file_size;
|
||||||
|
}
|
||||||
ih_imagesize = ih_exesize - ih.headsize16*16;
|
ih_imagesize = ih_exesize - ih.headsize16*16;
|
||||||
ih_overlay = file_size - ih_exesize;
|
ih_overlay = file_size - ih_exesize;
|
||||||
if (ih.m512+ih.p512*512u < sizeof (ih))
|
if (file_size < (int)sizeof(ih)
|
||||||
|
|| ((ih.m512 | ih.p512) && ih.m512+ih.p512*512u < sizeof (ih)))
|
||||||
throwCantPack("illegal exe header");
|
throwCantPack("illegal exe header");
|
||||||
if (file_size < (off_t)ih_exesize || ih_imagesize <= 0 || ih_imagesize > ih_exesize)
|
if (file_size < (off_t)ih_exesize || ih_imagesize <= 0 || ih_imagesize > ih_exesize)
|
||||||
throwCantPack("exe header corrupted");
|
throwCantPack("exe header corrupted");
|
||||||
@@ -231,6 +329,9 @@ unsigned optimize_relocs(upx_byte *b, const unsigned size,
|
|||||||
const upx_byte *relocs, const unsigned nrelocs,
|
const upx_byte *relocs, const unsigned nrelocs,
|
||||||
upx_byte *crel, bool *has_9a)
|
upx_byte *crel, bool *has_9a)
|
||||||
{
|
{
|
||||||
|
if (opt->exact)
|
||||||
|
throwCantPackExact();
|
||||||
|
|
||||||
upx_byte * const crel_save = crel;
|
upx_byte * const crel_save = crel;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned seg_high = 0;
|
unsigned seg_high = 0;
|
||||||
@@ -305,7 +406,7 @@ unsigned optimize_relocs(upx_byte *b, const unsigned size,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
unsigned offs = addr - es*16;
|
unsigned offs = addr - es*16;
|
||||||
if (offs >= 3 && b[es*16 + offs-3] == 0x9a)
|
if (offs >= 3 && b[es*16 + offs-3] == 0x9a && offs > di + 3)
|
||||||
{
|
{
|
||||||
for (t = di; t < offs-3; t++)
|
for (t = di; t < offs-3; t++)
|
||||||
if (b[es*16+t] == 0x9a && get_le16(b+es*16+t+3) <= seg_high)
|
if (b[es*16+t] == 0x9a && get_le16(b+es*16+t+3) <= seg_high)
|
||||||
@@ -367,6 +468,8 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
|
|
||||||
checkAlreadyPacked(ibuf, UPX_MIN(ih_imagesize, 127u));
|
checkAlreadyPacked(ibuf, UPX_MIN(ih_imagesize, 127u));
|
||||||
|
|
||||||
|
device_driver = get_le32(ibuf) == 0xffffffffu;
|
||||||
|
|
||||||
// relocations
|
// relocations
|
||||||
has_9a = false;
|
has_9a = false;
|
||||||
upx_byte *w = ibuf + ih_imagesize;
|
upx_byte *w = ibuf + ih_imagesize;
|
||||||
@@ -380,7 +483,7 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
for (ic = 0; ic < ih.relocs; ic++)
|
for (ic = 0; ic < ih.relocs; ic++)
|
||||||
{
|
{
|
||||||
unsigned jc = get_le32(wr+4*ic);
|
unsigned jc = get_le32(wr+4*ic);
|
||||||
set_le32(wr+4*ic, (jc>>16)*16+(jc&0xffff));
|
set_le32(wr+4*ic, ((jc>>16)*16+(jc&0xffff)) & 0xfffff);
|
||||||
}
|
}
|
||||||
qsort(wr,ih.relocs,4,le32_compare);
|
qsort(wr,ih.relocs,4,le32_compare);
|
||||||
relocsize = optimize_relocs(ibuf, ih_imagesize, wr, ih.relocs, w, &has_9a);
|
relocsize = optimize_relocs(ibuf, ih_imagesize, wr, ih.relocs, w, &has_9a);
|
||||||
@@ -405,12 +508,17 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
ph.u_len = ih_imagesize + relocsize;
|
ph.u_len = ih_imagesize + relocsize;
|
||||||
// prepare filter
|
// prepare filter
|
||||||
Filter ft(ph.level);
|
Filter ft(ph.level);
|
||||||
// compress
|
// compress (max_match = 8192)
|
||||||
compressWithFilters(&ft, 32, 0, NULL, 0, MAXMATCH);
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
|
cconf.conf_ucl.max_match = MAXMATCH;
|
||||||
|
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
|
||||||
|
compressWithFilters(&ft, 32, &cconf);
|
||||||
|
|
||||||
|
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
||||||
if (ph.max_run_found + ph.max_match_found > 0x8000)
|
if (ph.max_run_found + ph.max_match_found > 0x8000)
|
||||||
throwCantPack("decompressor limit exceeded, send a bugreport");
|
throwCantPack("decompressor limit exceeded, send a bugreport");
|
||||||
|
|
||||||
#ifdef TESTING
|
#if TESTING
|
||||||
if (opt->debug.debug_level)
|
if (opt->debug.debug_level)
|
||||||
{
|
{
|
||||||
printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len);
|
printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len);
|
||||||
@@ -474,21 +582,25 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
}
|
}
|
||||||
extra_info[eisize++] = (unsigned char) flag;
|
extra_info[eisize++] = (unsigned char) flag;
|
||||||
|
|
||||||
|
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
||||||
|
linker->defineSymbol("bx_magic", 0x7FFF + 0x10 * ((packedsize & 15) + 1));
|
||||||
|
|
||||||
|
unsigned decompressor_entry = 1 + (packedsize & 15);
|
||||||
|
if (M_IS_LZMA(ph.method))
|
||||||
|
decompressor_entry = 0x10;
|
||||||
|
linker->defineSymbol("decompressor_entry", decompressor_entry);
|
||||||
|
|
||||||
// patch loader
|
// patch loader
|
||||||
if (flag & USEJUMP)
|
if (flag & USEJUMP)
|
||||||
{
|
{
|
||||||
// I use a relocation entry to set the original cs
|
// I use a relocation entry to set the original cs
|
||||||
unsigned n = find_le32(loader,lsize,get_le32("IPCS"));
|
unsigned n = getLoaderSectionStart("EXEJUMPF") + 1;
|
||||||
patch_le32(loader,lsize,get_le32("IPCS"), ih.cs*0x10000 + ih.ip);
|
|
||||||
n += packedsize + 2;
|
n += packedsize + 2;
|
||||||
oh.relocs = 1;
|
oh.relocs = 1;
|
||||||
oh.firstreloc = (n & 0xf) + ((n >> 4) << 16);
|
oh.firstreloc = (n & 0xf) + ((n >> 4) << 16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
patch_le16(loader,lsize,"IP",ih.ip);
|
|
||||||
if (ih.cs)
|
|
||||||
patch_le16(loader,lsize,"CS",ih.cs);
|
|
||||||
oh.relocs = 0;
|
oh.relocs = 0;
|
||||||
oh.firstreloc = ih.cs * 0x10000 + ih.ip;
|
oh.firstreloc = ih.cs * 0x10000 + ih.ip;
|
||||||
}
|
}
|
||||||
@@ -497,36 +609,33 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
// oh.relocoffs = offsetof(exe_header_t, firstreloc);
|
// oh.relocoffs = offsetof(exe_header_t, firstreloc);
|
||||||
oh.relocoffs = ptr_diff(&oh.firstreloc, &oh);
|
oh.relocoffs = ptr_diff(&oh.firstreloc, &oh);
|
||||||
|
|
||||||
if (flag & SP)
|
linker->defineSymbol("destination_segment", oh.ss - ph.c_len / 16 - e_len / 16);
|
||||||
patch_le16(loader,lsize,"SP",ih.sp);
|
linker->defineSymbol("source_segment", e_len / 16 + (copysize - firstcopy) / 16);
|
||||||
if (flag & SS)
|
linker->defineSymbol("copy_offset", firstcopy - 2);
|
||||||
patch_le16(loader,lsize,"SS",ih.ss);
|
linker->defineSymbol("words_to_copy",firstcopy / 2);
|
||||||
if (relocsize)
|
|
||||||
patch_le16(loader,lsize,"RS",(ph.u_len <= DI_LIMIT || (ph.u_len & 0x7fff) >= relocsize ? 0 : MAXRELOCS) - relocsize);
|
|
||||||
|
|
||||||
patchPackHeader(loader,e_len);
|
linker->defineSymbol("exe_stack_sp", oh.sp);
|
||||||
|
linker->defineSymbol("exe_stack_ss", oh.ss);
|
||||||
patch_le16(loader,e_len,"BX",0x800F + 0x10*((packedsize&15)+1) - 0x10);
|
linker->defineSymbol("interrupt", get_le16(ibuf + 8));
|
||||||
patch_le16(loader,e_len,"BP",(packedsize&15)+1);
|
linker->defineSymbol("attribute", get_le16(ibuf + 4));
|
||||||
|
linker->defineSymbol("orig_strategy", get_le16(ibuf + 6));
|
||||||
unsigned destpara = oh.ss - ph.c_len/16;
|
|
||||||
patch_le16(loader,e_len,"ES",destpara-e_len/16);
|
|
||||||
patch_le16(loader,e_len,"DS",e_len/16+(copysize-firstcopy)/16);
|
|
||||||
patch_le16(loader,e_len,"SI",firstcopy-2);
|
|
||||||
patch_le16(loader,e_len,"CX",firstcopy/2);
|
|
||||||
|
|
||||||
// finish --stub support
|
|
||||||
//if (ih.relocoffs >= 0x40 && memcmp(&ih.relocoffs,">TIPPACH",8))
|
|
||||||
// throwCantPack("FIXME");
|
|
||||||
|
|
||||||
const unsigned outputlen = sizeof(oh)+lsize+packedsize+eisize;
|
const unsigned outputlen = sizeof(oh)+lsize+packedsize+eisize;
|
||||||
oh.m512 = outputlen & 511;
|
oh.m512 = outputlen & 511;
|
||||||
oh.p512 = (outputlen + 511) >> 9;
|
oh.p512 = (outputlen + 511) >> 9;
|
||||||
|
|
||||||
//fprintf(stderr,"\ne_len=%x d_len=%x clen=%x oo=%x ulen=%x destp=%x copys=%x images=%x",e_len,d_len,packedsize,ph.overlap_overhead,ph.u_len,destpara,copysize,ih_imagesize);
|
const char *exeentry = M_IS_LZMA(ph.method) ? "LZMAENTRY" : "EXEENTRY";
|
||||||
|
oh.ip = device_driver ? getLoaderSection(exeentry) - 2 : 0;
|
||||||
|
|
||||||
|
defineDecompressorSymbols();
|
||||||
|
relocateLoader();
|
||||||
|
memcpy(loader, getLoader(), lsize);
|
||||||
|
patchPackHeader(loader,e_len);
|
||||||
|
|
||||||
|
//fprintf(stderr,"\ne_len=%x d_len=%x c_len=%x oo=%x ulen=%x destp=%x copys=%x images=%x",e_len,d_len,packedsize,ph.overlap_overhead,ph.u_len,destpara,copysize,ih_imagesize);
|
||||||
|
|
||||||
// write header + write loader + compressed file
|
// write header + write loader + compressed file
|
||||||
#ifdef TESTING
|
#if TESTING
|
||||||
if (opt->debug.debug_level)
|
if (opt->debug.debug_level)
|
||||||
printf("\n%d %d %d %d\n",(int)sizeof(oh),e_len,packedsize,d_len);
|
printf("\n%d %d %d %d\n",(int)sizeof(oh),e_len,packedsize,d_len);
|
||||||
#endif
|
#endif
|
||||||
@@ -567,7 +676,7 @@ int PackExe::canUnpack()
|
|||||||
return false;
|
return false;
|
||||||
const off_t off = ih.headsize16 * 16;
|
const off_t off = ih.headsize16 * 16;
|
||||||
fi->seek(off, SEEK_SET);
|
fi->seek(off, SEEK_SET);
|
||||||
bool b = readPackHeader(128);
|
bool b = readPackHeader(4096);
|
||||||
return b && (off + (off_t) ph.c_len <= file_size);
|
return b && (off + (off_t) ph.c_len <= file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +806,72 @@ void PackExe::unpack(OutputFile *fo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Linker* PackExe::newLinker() const
|
||||||
|
{
|
||||||
|
return new ElfLinkerX86();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
vi:ts=4:et
|
|
||||||
|
memory layout at decompression time
|
||||||
|
===================================
|
||||||
|
|
||||||
|
normal exe
|
||||||
|
----------
|
||||||
|
|
||||||
|
a, at load time
|
||||||
|
|
||||||
|
(e - copying code, C - compressed data, d - decompressor+relocator,
|
||||||
|
x - not specified, U - uncompressed code+data, R uncompressed relocation)
|
||||||
|
|
||||||
|
eeCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCdddd
|
||||||
|
^ CS:0 ^ SS:0
|
||||||
|
|
||||||
|
b, after copying
|
||||||
|
|
||||||
|
xxxxxxxxxxxxxxxCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCdddd
|
||||||
|
^ES:DI=0 ^ DS:SI=0 ^ CS=SS, IP in range 0..0xf
|
||||||
|
|
||||||
|
c, after uncompression
|
||||||
|
|
||||||
|
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUURRdddd
|
||||||
|
^ ES:DI
|
||||||
|
|
||||||
|
device driver
|
||||||
|
-------------
|
||||||
|
|
||||||
|
the file has 2 entry points, CS:0 in device driver mode, and
|
||||||
|
CS:exe_as_device_entry in normal mode. the code in section DEVICEENTRY
|
||||||
|
sets up the same environment for section EXEENTRY, as it would see in normal
|
||||||
|
execution mode.
|
||||||
|
|
||||||
|
lzma uncompression for normal exes
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
(n - nrv2b uncompressor, l - nrv2b compressed lzma + relocator code)
|
||||||
|
|
||||||
|
a, at load time
|
||||||
|
|
||||||
|
nneelllCCCCCCCCCCCCCCCCCCCCCCCCC
|
||||||
|
|
||||||
|
^ CS:0 ^ SS:0
|
||||||
|
|
||||||
|
b, after nrv2b
|
||||||
|
|
||||||
|
nneelllCCCCCCCCCCCCCCCCCCCCCCCCC dddd
|
||||||
|
^ CS:0 ^ SS:0x10
|
||||||
|
|
||||||
|
after this, normal ee code runs
|
||||||
|
|
||||||
|
lzma + device driver
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
(D - device driver adapter)
|
||||||
|
|
||||||
|
a, at load time
|
||||||
|
|
||||||
|
DDnneelllCCCCCCCCCCCCCCCCCCCCCCCCC
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
|
|||||||
+16
-14
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_EXE_H
|
#ifndef __UPX_P_EXE_H
|
||||||
#define __UPX_P_EXE_H
|
#define __UPX_P_EXE_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -42,6 +42,8 @@ public:
|
|||||||
virtual int getVersion() const { return 13; }
|
virtual int getVersion() const { return 13; }
|
||||||
virtual int getFormat() const { return UPX_F_DOS_EXE; }
|
virtual int getFormat() const { return UPX_F_DOS_EXE; }
|
||||||
virtual const char *getName() const { return "dos/exe"; }
|
virtual const char *getName() const { return "dos/exe"; }
|
||||||
|
//virtual const char *getFullName(const options_t *o) const { return o && o->cpu == o->CPU_8086 ? "i086-dos16.exe" : "i286-dos16.exe"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i086-dos16.exe"; }
|
||||||
virtual const int *getCompressionMethods(int method, int level) const;
|
virtual const int *getCompressionMethods(int method, int level) const;
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
@@ -68,10 +70,11 @@ protected:
|
|||||||
virtual int readFileHeader(void);
|
virtual int readFileHeader(void);
|
||||||
|
|
||||||
virtual int fillExeHeader(struct exe_header_t *) const;
|
virtual int fillExeHeader(struct exe_header_t *) const;
|
||||||
virtual int buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
|
void addLoaderEpilogue(int flag);
|
||||||
|
|
||||||
struct exe_header_t
|
__packed_struct(exe_header_t)
|
||||||
{
|
|
||||||
LE16 ident;
|
LE16 ident;
|
||||||
LE16 m512;
|
LE16 m512;
|
||||||
LE16 p512;
|
LE16 p512;
|
||||||
@@ -87,8 +90,7 @@ protected:
|
|||||||
LE16 relocoffs;
|
LE16 relocoffs;
|
||||||
char __[2]; // overlnum
|
char __[2]; // overlnum
|
||||||
LE32 firstreloc;
|
LE32 firstreloc;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
exe_header_t ih, oh;
|
exe_header_t ih, oh;
|
||||||
|
|
||||||
@@ -98,6 +100,7 @@ protected:
|
|||||||
unsigned relocsize;
|
unsigned relocsize;
|
||||||
|
|
||||||
bool has_9a;
|
bool has_9a;
|
||||||
|
bool device_driver;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NORELOC = 1,
|
NORELOC = 1,
|
||||||
@@ -107,13 +110,12 @@ protected:
|
|||||||
MINMEM = 16,
|
MINMEM = 16,
|
||||||
MAXMEM = 32
|
MAXMEM = 32
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsigned stack_for_lzma; // stack size required for lzma
|
||||||
|
bool use_clear_dirty_stack;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+4888
-975
File diff suppressed because it is too large
Load Diff
+500
-140
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
Copyright (C) 2000-2004 John F. Reiser
|
Copyright (C) 2000-2020 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,14 +22,16 @@
|
|||||||
If not, write to the Free Software Foundation, Inc.,
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar John F. Reiser
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu jreiser@BitWagon.com
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
|
John F. Reiser
|
||||||
|
<jreiser@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_LX_ELF_H //{
|
#ifndef __UPX_P_LX_ELF_H //{
|
||||||
#define __UPX_P_LX_ELF_H
|
#define __UPX_P_LX_ELF_H 1
|
||||||
|
|
||||||
|
|
||||||
class PackLinuxElf : public PackUnix
|
class PackLinuxElf : public PackUnix
|
||||||
{
|
{
|
||||||
@@ -37,7 +39,7 @@ class PackLinuxElf : public PackUnix
|
|||||||
public:
|
public:
|
||||||
PackLinuxElf(InputFile *f);
|
PackLinuxElf(InputFile *f);
|
||||||
virtual ~PackLinuxElf();
|
virtual ~PackLinuxElf();
|
||||||
/*virtual int buildLoader(const Filter *);*/
|
/*virtual void buildLoader(const Filter *);*/
|
||||||
virtual bool canUnpackVersion(int version) const { return (version >= 11); }
|
virtual bool canUnpackVersion(int version) const { return (version >= 11); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -47,27 +49,59 @@ protected:
|
|||||||
// because they depend on Elf32 or Elf64 data structures, which differ.
|
// because they depend on Elf32 or Elf64 data structures, which differ.
|
||||||
|
|
||||||
virtual void pack1(OutputFile *, Filter &) = 0; // generate executable header
|
virtual void pack1(OutputFile *, Filter &) = 0; // generate executable header
|
||||||
virtual void pack2(OutputFile *, Filter &) = 0; // append compressed data
|
virtual int pack2(OutputFile *, Filter &) = 0; // append compressed data
|
||||||
//virtual void pack3(OutputFile *, Filter &) = 0; // append loader
|
virtual off_t pack3(OutputFile *, Filter &) = 0; // append loader
|
||||||
virtual void pack4(OutputFile *, Filter &) = 0; // append pack header
|
//virtual void pack4(OutputFile *, Filter &) = 0; // append pack header
|
||||||
|
|
||||||
virtual void generateElfHdr(
|
virtual void generateElfHdr(
|
||||||
OutputFile *,
|
OutputFile *,
|
||||||
void const *proto,
|
void const *proto,
|
||||||
unsigned const brka
|
unsigned const brka
|
||||||
) = 0;
|
) = 0;
|
||||||
virtual int buildLinuxLoader(
|
virtual void defineSymbols(Filter const *);
|
||||||
upx_byte const *const proto, // assembly-only sections
|
virtual void addStubEntrySections(Filter const *);
|
||||||
unsigned const szproto,
|
virtual void unpack(OutputFile *fo);
|
||||||
upx_byte const *const fold, // linked assembly + C section
|
|
||||||
unsigned const szfold,
|
virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const = 0;
|
||||||
Filter const *ft
|
static unsigned elf_hash(char const *) /*const*/;
|
||||||
) = 0;
|
static unsigned gnu_hash(char const *) /*const*/;
|
||||||
virtual void unpack(OutputFile *fo) = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static unsigned int const asl_delta = (1u<<12); // --android-shlib extra page
|
||||||
|
unsigned e_type;
|
||||||
|
unsigned e_phnum; /* Program header table entry count */
|
||||||
|
unsigned e_shnum;
|
||||||
|
MemBuffer file_image; // if ET_DYN investigation
|
||||||
|
char const *dynstr; // from DT_STRTAB
|
||||||
|
|
||||||
unsigned sz_phdrs; // sizeof Phdr[]
|
unsigned sz_phdrs; // sizeof Phdr[]
|
||||||
unsigned sz_elf_hdrs; // all Elf headers
|
unsigned sz_elf_hdrs; // all Elf headers
|
||||||
|
unsigned sz_pack2; // after pack2(), before loader
|
||||||
|
unsigned sz_pack2a; // after pack2() of all PT_LOAD
|
||||||
|
unsigned lg2_page; // log2(PAGE_SIZE)
|
||||||
|
unsigned page_size; // 1u<<lg2_page
|
||||||
|
bool is_pie; // is Position-Independent-Executable (ET_DYN main program)
|
||||||
|
unsigned xct_off; // shared library: file offset of SHT_EXECINSTR
|
||||||
|
unsigned hatch_off; // file offset of escape hatch
|
||||||
|
unsigned o_binfo; // offset to first b_info
|
||||||
|
upx_uint64_t load_va; // PT_LOAD[0].p_vaddr
|
||||||
|
upx_uint64_t xct_va; // minimum SHT_EXECINSTR virtual address
|
||||||
|
upx_uint64_t jni_onload_va; // runtime &JNI_OnLoad
|
||||||
|
upx_uint64_t user_init_va;
|
||||||
|
unsigned user_init_off; // within file_image
|
||||||
|
|
||||||
|
upx_uint16_t e_machine;
|
||||||
|
unsigned char ei_class;
|
||||||
|
unsigned char ei_data;
|
||||||
|
unsigned char ei_osabi;
|
||||||
|
char const *osabi_note;
|
||||||
|
unsigned upx_dt_init; // DT_INIT, DT_PREINIT_ARRAY, DT_INIT_ARRAY
|
||||||
|
static unsigned const DT_NUM = 34; // elf.h
|
||||||
|
unsigned dt_table[DT_NUM]; // 1+ index in PT_DYNAMIC
|
||||||
|
|
||||||
|
unsigned char const *buildid_data;
|
||||||
|
int o_elf_shnum; // num output Shdrs
|
||||||
|
static unsigned char o_shstrtab[];
|
||||||
};
|
};
|
||||||
|
|
||||||
class PackLinuxElf32 : public PackLinuxElf
|
class PackLinuxElf32 : public PackLinuxElf
|
||||||
@@ -77,55 +111,138 @@ public:
|
|||||||
PackLinuxElf32(InputFile *f);
|
PackLinuxElf32(InputFile *f);
|
||||||
virtual ~PackLinuxElf32();
|
virtual ~PackLinuxElf32();
|
||||||
protected:
|
protected:
|
||||||
virtual int checkEhdr(
|
virtual void PackLinuxElf32help1(InputFile *f);
|
||||||
Elf32_Ehdr const *ehdr,
|
virtual int checkEhdr(Elf32_Ehdr const *ehdr) const;
|
||||||
unsigned char e_machine,
|
virtual bool canPack();
|
||||||
unsigned char ei_class,
|
|
||||||
unsigned char ei_data) const;
|
// These ARM routines are essentially common to big/little endian,
|
||||||
|
// but the class hierarchy splits after this class.
|
||||||
|
virtual void ARM_defineSymbols(Filter const *ft);
|
||||||
|
virtual void ARM_updateLoader(OutputFile *);
|
||||||
|
virtual int ARM_is_QNX(void);
|
||||||
|
|
||||||
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
virtual void pack2(OutputFile *, Filter &); // append compressed data
|
virtual int pack2(OutputFile *, Filter &); // append compressed data
|
||||||
//virtual void pack3(OutputFile *, Filter &); // append loader
|
virtual off_t pack3(OutputFile *, Filter &); // append loader
|
||||||
virtual void pack4(OutputFile *, Filter &); // append pack header
|
virtual void pack4(OutputFile *, Filter &); // append pack header
|
||||||
virtual void unpack(OutputFile *fo);
|
virtual void unpack(OutputFile *fo);
|
||||||
|
virtual void unRel32(unsigned dt_rel, Elf32_Rel *rel0, unsigned relsz,
|
||||||
|
MemBuffer &membuf, unsigned const load_off, OutputFile *fo);
|
||||||
|
|
||||||
virtual void generateElfHdr(
|
virtual void generateElfHdr(
|
||||||
OutputFile *,
|
OutputFile *,
|
||||||
void const *proto,
|
void const *proto,
|
||||||
unsigned const brka
|
unsigned const brka
|
||||||
);
|
);
|
||||||
|
virtual void defineSymbols(Filter const *);
|
||||||
|
virtual void buildLinuxLoader(
|
||||||
|
upx_byte const *const proto, // assembly-only sections
|
||||||
|
unsigned const szproto,
|
||||||
|
upx_byte const *const fold, // linked assembly + C section
|
||||||
|
unsigned const szfold,
|
||||||
|
Filter const *ft
|
||||||
|
);
|
||||||
virtual off_t getbrk(const Elf32_Phdr *phdr, int e_phnum) const;
|
virtual off_t getbrk(const Elf32_Phdr *phdr, int e_phnum) const;
|
||||||
virtual void patchLoader();
|
virtual void patchLoader();
|
||||||
virtual void updateLoader(OutputFile *fo);
|
virtual void updateLoader(OutputFile *fo);
|
||||||
virtual unsigned find_LOAD_gap(Elf32_Phdr const *const phdri, unsigned const k,
|
virtual unsigned find_LOAD_gap(Elf32_Phdr const *const phdri, unsigned const k,
|
||||||
unsigned const e_phnum);
|
unsigned const e_phnum);
|
||||||
|
virtual off_t getbase(const Elf32_Phdr *phdr, int e_phnum) const;
|
||||||
|
bool calls_crt1(Elf32_Rel const *rel, int sz);
|
||||||
|
|
||||||
|
virtual Elf32_Sym const *elf_lookup(char const *) const;
|
||||||
|
virtual unsigned elf_get_offset_from_address(unsigned) const;
|
||||||
|
Elf32_Phdr const *elf_find_ptype(unsigned type, Elf32_Phdr const *phdr0, unsigned phnum);
|
||||||
|
Elf32_Shdr const *elf_find_section_name(char const *) const;
|
||||||
|
Elf32_Shdr const *elf_find_section_type(unsigned) const;
|
||||||
|
unsigned check_pt_load(Elf32_Phdr const *);
|
||||||
|
unsigned check_pt_dynamic(Elf32_Phdr const *);
|
||||||
|
void invert_pt_dynamic(Elf32_Dyn const *);
|
||||||
|
void const *elf_find_dynamic(unsigned) const;
|
||||||
|
Elf32_Dyn const *elf_has_dynamic(unsigned) const;
|
||||||
|
virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const;
|
||||||
|
virtual int adjABS(Elf32_Sym *sym, unsigned delta);
|
||||||
|
|
||||||
|
char const *get_str_name(unsigned st_name, unsigned symnum) const;
|
||||||
|
char const *get_dynsym_name(unsigned symnum, unsigned relnum) const;
|
||||||
protected:
|
protected:
|
||||||
Elf32_Ehdr ehdri; // from input file
|
Elf32_Ehdr ehdri; // from input file
|
||||||
|
MemBuffer lowmem; // especially for shlib
|
||||||
Elf32_Phdr *phdri; // for input file
|
Elf32_Phdr *phdri; // for input file
|
||||||
|
Elf32_Shdr *shdri; // from input file
|
||||||
|
Elf32_Phdr const *gnu_stack; // propagate NX
|
||||||
|
unsigned e_phoff;
|
||||||
|
unsigned e_shoff;
|
||||||
|
unsigned sz_dynseg; // PT_DYNAMIC.p_memsz
|
||||||
|
unsigned so_slide;
|
||||||
|
unsigned char *note_body; // concatenated contents of PT_NOTEs, if any
|
||||||
|
unsigned note_size; // total size of PT_NOTEs
|
||||||
|
unsigned n_jmp_slot;
|
||||||
|
unsigned plt_off;
|
||||||
|
unsigned page_mask; // AND clears the offset-within-page
|
||||||
|
|
||||||
struct cprElfHdr1 {
|
Elf32_Dyn const *dynseg; // from PT_DYNAMIC
|
||||||
|
unsigned int const *hashtab; // from DT_HASH
|
||||||
|
unsigned int const *gashtab; // from DT_GNU_HASH
|
||||||
|
Elf32_Sym const *dynsym; // from DT_SYMTAB
|
||||||
|
Elf32_Sym const *jni_onload_sym;
|
||||||
|
char const *shstrtab; // via Elf32_Shdr
|
||||||
|
|
||||||
|
Elf32_Shdr *sec_strndx;
|
||||||
|
Elf32_Shdr const *sec_dynsym;
|
||||||
|
Elf32_Shdr const *sec_dynstr;
|
||||||
|
unsigned symnum_end;
|
||||||
|
unsigned strtab_end;
|
||||||
|
|
||||||
|
__packed_struct(cprElfHdr1)
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[1];
|
Elf32_Phdr phdr[1];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct cprElfHdr2 {
|
__packed_struct(cprElfHdr2)
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[2];
|
Elf32_Phdr phdr[2];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct cprElfHdr3 {
|
__packed_struct(cprElfHdr3)
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[3];
|
Elf32_Phdr phdr[3];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
cprElfHdr3 elfout;
|
__packed_struct(cprElfHdrNetBSD)
|
||||||
|
Elf32_Ehdr ehdr;
|
||||||
|
Elf32_Phdr phdr[4];
|
||||||
|
unsigned char notes[512];
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
cprElfHdrNetBSD elfout;
|
||||||
|
|
||||||
|
__packed_struct(cprElfShdr3)
|
||||||
|
Elf32_Shdr shdr[3];
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
cprElfShdr3 shdrout;
|
||||||
|
|
||||||
|
struct Elf32_Nhdr {
|
||||||
|
unsigned namesz;
|
||||||
|
unsigned descsz;
|
||||||
|
unsigned type;
|
||||||
|
//unsigned char body[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
static void compileTimeAssertions() {
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr1) == 52 + 1*32 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr2) == 52 + 2*32 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr3) == 52 + 3*32 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdrNetBSD) == 52 + 4*32 + 512)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr1)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr2)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr3)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdrNetBSD)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -135,88 +252,175 @@ class PackLinuxElf64 : public PackLinuxElf
|
|||||||
public:
|
public:
|
||||||
PackLinuxElf64(InputFile *f);
|
PackLinuxElf64(InputFile *f);
|
||||||
virtual ~PackLinuxElf64();
|
virtual ~PackLinuxElf64();
|
||||||
/*virtual int buildLoader(const Filter *);*/
|
/*virtual void buildLoader(const Filter *);*/
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int checkEhdr(
|
virtual void PackLinuxElf64help1(InputFile *f);
|
||||||
Elf64_Ehdr const *ehdr,
|
virtual int checkEhdr(Elf64_Ehdr const *ehdr) const;
|
||||||
unsigned char e_machine,
|
virtual bool canPack();
|
||||||
unsigned char ei_class,
|
|
||||||
unsigned char ei_data) const;
|
|
||||||
|
|
||||||
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
virtual void pack2(OutputFile *, Filter &); // append compressed data
|
virtual int pack2(OutputFile *, Filter &); // append compressed data
|
||||||
//virtual void pack3(OutputFile *, Filter &); // append loader
|
virtual off_t pack3(OutputFile *, Filter &); // append loader
|
||||||
virtual void pack4(OutputFile *, Filter &); // append pack header
|
virtual void pack4(OutputFile *, Filter &); // append pack header
|
||||||
virtual void unpack(OutputFile *fo);
|
virtual void unpack(OutputFile *fo);
|
||||||
|
virtual void unRela64(upx_uint64_t dt_rela, Elf64_Rela *rela0, unsigned relasz,
|
||||||
|
MemBuffer &membuf, upx_uint64_t const load_off, upx_uint64_t const old_dtinit,
|
||||||
|
OutputFile *fo);
|
||||||
|
|
||||||
virtual void generateElfHdr(
|
virtual void generateElfHdr(
|
||||||
OutputFile *,
|
OutputFile *,
|
||||||
void const *proto,
|
void const *proto,
|
||||||
unsigned const brka
|
unsigned const brka
|
||||||
);
|
);
|
||||||
|
virtual void defineSymbols(Filter const *);
|
||||||
|
virtual void buildLinuxLoader(
|
||||||
|
upx_byte const *const proto, // assembly-only sections
|
||||||
|
unsigned const szproto,
|
||||||
|
upx_byte const *const fold, // linked assembly + C section
|
||||||
|
unsigned const szfold,
|
||||||
|
Filter const *ft
|
||||||
|
);
|
||||||
virtual off_t getbrk(const Elf64_Phdr *phdr, int e_phnum) const;
|
virtual off_t getbrk(const Elf64_Phdr *phdr, int e_phnum) const;
|
||||||
virtual void patchLoader();
|
virtual void patchLoader();
|
||||||
virtual void updateLoader(OutputFile *fo);
|
virtual void updateLoader(OutputFile *fo);
|
||||||
virtual unsigned find_LOAD_gap(Elf64_Phdr const *const phdri, unsigned const k,
|
virtual unsigned find_LOAD_gap(Elf64_Phdr const *const phdri, unsigned const k,
|
||||||
unsigned const e_phnum);
|
unsigned const e_phnum);
|
||||||
|
bool calls_crt1(Elf64_Rela const *rela, int sz);
|
||||||
|
|
||||||
|
virtual Elf64_Sym const *elf_lookup(char const *) const;
|
||||||
|
virtual upx_uint64_t elf_get_offset_from_address(upx_uint64_t) const;
|
||||||
|
Elf64_Phdr const *elf_find_ptype(unsigned type, Elf64_Phdr const *phdr0, unsigned phnum);
|
||||||
|
Elf64_Shdr const *elf_find_section_name(char const *) const;
|
||||||
|
Elf64_Shdr const *elf_find_section_type(unsigned) const;
|
||||||
|
upx_uint64_t check_pt_load(Elf64_Phdr const *);
|
||||||
|
upx_uint64_t check_pt_dynamic(Elf64_Phdr const *);
|
||||||
|
void invert_pt_dynamic(Elf64_Dyn const *);
|
||||||
|
void const *elf_find_dynamic(unsigned) const;
|
||||||
|
Elf64_Dyn const *elf_has_dynamic(unsigned) const;
|
||||||
|
virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const;
|
||||||
|
virtual int adjABS(Elf64_Sym *sym, unsigned delta);
|
||||||
|
|
||||||
|
char const *get_str_name(unsigned st_name, unsigned symnum) const;
|
||||||
|
char const *get_dynsym_name(unsigned symnum, unsigned relnum) const;
|
||||||
protected:
|
protected:
|
||||||
Elf64_Ehdr ehdri; // from input file
|
Elf64_Ehdr ehdri; // from input file
|
||||||
|
MemBuffer lowmem; // especially for shlib
|
||||||
Elf64_Phdr *phdri; // for input file
|
Elf64_Phdr *phdri; // for input file
|
||||||
|
Elf64_Shdr *shdri; // from input file
|
||||||
|
Elf64_Phdr const *gnu_stack; // propagate NX
|
||||||
|
upx_uint64_t e_phoff;
|
||||||
|
upx_uint64_t e_shoff;
|
||||||
|
upx_uint64_t sz_dynseg; // PT_DYNAMIC.p_memsz
|
||||||
|
upx_uint64_t so_slide;
|
||||||
|
unsigned char *note_body; // concatenated contents of PT_NOTEs, if any
|
||||||
|
unsigned note_size; // total size of PT_NOTEs
|
||||||
|
unsigned n_jmp_slot;
|
||||||
|
upx_uint64_t plt_off;
|
||||||
|
upx_uint64_t page_mask; // AND clears the offset-within-page
|
||||||
|
|
||||||
struct cprElfHdr1 {
|
Elf64_Dyn const *dynseg; // from PT_DYNAMIC
|
||||||
|
unsigned int const *hashtab; // from DT_HASH
|
||||||
|
unsigned int const *gashtab; // from DT_GNU_HASH
|
||||||
|
Elf64_Sym const *dynsym; // from DT_SYMTAB
|
||||||
|
Elf64_Sym const *jni_onload_sym;
|
||||||
|
char const *shstrtab; // via Elf64_Shdr
|
||||||
|
|
||||||
|
Elf64_Shdr *sec_strndx;
|
||||||
|
Elf64_Shdr const *sec_dynsym;
|
||||||
|
Elf64_Shdr const *sec_dynstr;
|
||||||
|
unsigned symnum_end;
|
||||||
|
unsigned strtab_end;
|
||||||
|
|
||||||
|
__packed_struct(cprElfHdr1)
|
||||||
Elf64_Ehdr ehdr;
|
Elf64_Ehdr ehdr;
|
||||||
Elf64_Phdr phdr[1];
|
Elf64_Phdr phdr[1];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct cprElfHdr2 {
|
__packed_struct(cprElfHdr2)
|
||||||
Elf64_Ehdr ehdr;
|
Elf64_Ehdr ehdr;
|
||||||
Elf64_Phdr phdr[2];
|
Elf64_Phdr phdr[2];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct cprElfHdr3 {
|
__packed_struct(cprElfHdr3)
|
||||||
Elf64_Ehdr ehdr;
|
Elf64_Ehdr ehdr;
|
||||||
Elf64_Phdr phdr[3];
|
Elf64_Phdr phdr[3];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
cprElfHdr3 elfout;
|
__packed_struct(cprElfHdr4)
|
||||||
|
Elf64_Ehdr ehdr;
|
||||||
|
Elf64_Phdr phdr[4];
|
||||||
|
l_info linfo;
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
cprElfHdr4 elfout;
|
||||||
|
|
||||||
|
__packed_struct(cprElfShdr3)
|
||||||
|
Elf64_Shdr shdr[3];
|
||||||
|
__packed_struct_end()
|
||||||
|
|
||||||
|
cprElfShdr3 shdrout;
|
||||||
|
|
||||||
|
static void compileTimeAssertions() {
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr1) == 64 + 1*56 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr2) == 64 + 2*56 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr3) == 64 + 3*56 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr4) == 64 + 4*56 + 12)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr1)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr2)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr3)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr4)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PackLinuxElf32Be : public PackLinuxElf32
|
class PackLinuxElf32Be : public PackLinuxElf32
|
||||||
{
|
{
|
||||||
typedef PackLinuxElf32 super;
|
typedef PackLinuxElf32 super;
|
||||||
protected:
|
protected:
|
||||||
PackLinuxElf32Be(InputFile *f) : super(f) { }
|
PackLinuxElf32Be(InputFile *f) : super(f) {
|
||||||
|
bele = &N_BELE_RTP::be_policy;
|
||||||
|
PackLinuxElf32help1(f);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
virtual acc_uint64l_t get_native64(const void *b) const { return get_be64(b); }
|
class PackLinuxElf32Le : public PackLinuxElf32
|
||||||
virtual unsigned get_native32(const void *b) const { return get_be32(b); }
|
{
|
||||||
virtual unsigned get_native16(const void *b) const { return get_be16(b); }
|
typedef PackLinuxElf32 super;
|
||||||
virtual void set_native64(void *b, acc_uint64l_t v) const { set_be64(b, v); }
|
protected:
|
||||||
virtual void set_native32(void *b, unsigned v) const { set_be32(b, v); }
|
PackLinuxElf32Le(InputFile *f) : super(f) {
|
||||||
virtual void set_native16(void *b, unsigned v) const { set_be16(b, v); }
|
bele = &N_BELE_RTP::le_policy;
|
||||||
|
PackLinuxElf32help1(f);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PackLinuxElf64Le : public PackLinuxElf64
|
class PackLinuxElf64Le : public PackLinuxElf64
|
||||||
{
|
{
|
||||||
typedef PackLinuxElf64 super;
|
typedef PackLinuxElf64 super;
|
||||||
protected:
|
protected:
|
||||||
PackLinuxElf64Le(InputFile *f) : super(f) { }
|
PackLinuxElf64Le(InputFile *f) : super(f) {
|
||||||
|
lg2_page=16;
|
||||||
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
|
page_size=1u<<lg2_page;
|
||||||
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
|
bele = &N_BELE_RTP::le_policy;
|
||||||
virtual unsigned get_native16(const void *b) const { return get_le16(b); }
|
PackLinuxElf64help1(f);
|
||||||
virtual void set_native64(void *b, acc_uint64l_t v) const { set_le64(b, v); }
|
}
|
||||||
virtual void set_native32(void *b, unsigned v) const { set_le32(b, v); }
|
|
||||||
virtual void set_native16(void *b, unsigned v) const { set_le16(b, v); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PackLinuxElf64Be : public PackLinuxElf64
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf64 super;
|
||||||
|
protected:
|
||||||
|
PackLinuxElf64Be(InputFile *f) : super(f) {
|
||||||
|
lg2_page=16;
|
||||||
|
page_size=1u<<lg2_page;
|
||||||
|
bele = &N_BELE_RTP::be_policy;
|
||||||
|
PackLinuxElf64help1(f);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// linux/elf64amd
|
// linux/elf64amd
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -228,27 +432,34 @@ public:
|
|||||||
PackLinuxElf64amd(InputFile *f);
|
PackLinuxElf64amd(InputFile *f);
|
||||||
virtual ~PackLinuxElf64amd();
|
virtual ~PackLinuxElf64amd();
|
||||||
virtual int getFormat() const { return UPX_F_LINUX_ELF64_AMD; }
|
virtual int getFormat() const { return UPX_F_LINUX_ELF64_AMD; }
|
||||||
virtual const char *getName() const { return "linux/ElfAMD"; }
|
virtual const char *getName() const { return "linux/amd64"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "amd64-linux.elf"; }
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
virtual bool canPack();
|
|
||||||
protected:
|
protected:
|
||||||
virtual void pack3(OutputFile *, Filter &); // append loader
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
virtual const int *getCompressionMethods(int method, int level) const;
|
virtual void buildLoader(const Filter *);
|
||||||
virtual int buildLinuxLoader(
|
virtual Linker* newLinker() const;
|
||||||
upx_byte const *const proto, // assembly-only sections
|
virtual void defineSymbols(Filter const *);
|
||||||
unsigned const szproto,
|
|
||||||
upx_byte const *const fold, // linked assembly + C section
|
|
||||||
unsigned const szfold,
|
|
||||||
Filter const *ft
|
|
||||||
);
|
|
||||||
virtual int buildLoader(const Filter *);
|
|
||||||
virtual void generateElfHdr(
|
|
||||||
OutputFile *,
|
|
||||||
void const *proto,
|
|
||||||
unsigned const brka
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PackLinuxElf64arm : public PackLinuxElf64Le
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf64Le super;
|
||||||
|
public:
|
||||||
|
PackLinuxElf64arm(InputFile *f);
|
||||||
|
virtual ~PackLinuxElf64arm();
|
||||||
|
virtual int getFormat() const { return UPX_F_LINUX_ELF64_ARM; }
|
||||||
|
virtual const char *getName() const { return "linux/arm64"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "arm64-linux.elf"; }
|
||||||
|
virtual const int *getFilters() const;
|
||||||
|
protected:
|
||||||
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
virtual void buildLoader(const Filter *);
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
|
virtual void defineSymbols(Filter const *);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// linux/elf32ppc
|
// linux/elf32ppc
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -260,20 +471,119 @@ public:
|
|||||||
PackLinuxElf32ppc(InputFile *f);
|
PackLinuxElf32ppc(InputFile *f);
|
||||||
virtual ~PackLinuxElf32ppc();
|
virtual ~PackLinuxElf32ppc();
|
||||||
virtual int getFormat() const { return UPX_F_LINUX_ELFPPC32; }
|
virtual int getFormat() const { return UPX_F_LINUX_ELFPPC32; }
|
||||||
virtual const char *getName() const { return "linux/ElfPPC"; }
|
virtual const char *getName() const { return "linux/ppc32"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "powerpc-linux.elf"; }
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
virtual bool canPack();
|
|
||||||
protected:
|
protected:
|
||||||
virtual void pack3(OutputFile *, Filter &); // append loader
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
virtual const int *getCompressionMethods(int method, int level) const;
|
virtual void buildLoader(const Filter *);
|
||||||
virtual int buildLinuxLoader(
|
virtual Linker* newLinker() const;
|
||||||
upx_byte const *const proto, // assembly-only sections
|
};
|
||||||
unsigned const szproto,
|
|
||||||
upx_byte const *const fold, // linked assembly + C section
|
/*************************************************************************
|
||||||
unsigned const szfold,
|
// linux/elf64ppcle
|
||||||
Filter const *ft
|
**************************************************************************/
|
||||||
);
|
|
||||||
virtual int buildLoader(const Filter *);
|
class PackLinuxElf64ppcle : public PackLinuxElf64Le
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf64Le super;
|
||||||
|
public:
|
||||||
|
PackLinuxElf64ppcle(InputFile *f);
|
||||||
|
virtual ~PackLinuxElf64ppcle();
|
||||||
|
virtual int getFormat() const { return UPX_F_LINUX_ELFPPC64LE; }
|
||||||
|
virtual const char *getName() const { return "linux/ppc64le"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "powerpc64le-linux.elf"; }
|
||||||
|
virtual const int *getFilters() const;
|
||||||
|
protected:
|
||||||
|
unsigned lg2_page; // log2(PAGE_SIZE)
|
||||||
|
unsigned page_size; // 1u<<lg2_page
|
||||||
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
virtual void buildLoader(const Filter *);
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class PackLinuxElf64ppc : public PackLinuxElf64Be
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf64Be super;
|
||||||
|
public:
|
||||||
|
PackLinuxElf64ppc(InputFile *f);
|
||||||
|
virtual ~PackLinuxElf64ppc();
|
||||||
|
virtual int getFormat() const { return UPX_F_LINUX_ELFPPC64; }
|
||||||
|
virtual const char *getName() const { return "linux/ppc64"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "powerpc64-linux.elf"; }
|
||||||
|
virtual const int *getFilters() const;
|
||||||
|
protected:
|
||||||
|
unsigned lg2_page; // log2(PAGE_SIZE)
|
||||||
|
unsigned page_size; // 1u<<lg2_page
|
||||||
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
virtual void buildLoader(const Filter *);
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// linux/elf386
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
class PackLinuxElf32x86 : public PackLinuxElf32Le
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf32Le super;
|
||||||
|
public:
|
||||||
|
PackLinuxElf32x86(InputFile *f);
|
||||||
|
virtual ~PackLinuxElf32x86();
|
||||||
|
virtual int getFormat() const { return UPX_F_LINUX_ELF_i386; }
|
||||||
|
virtual const char *getName() const { return "linux/i386"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i386-linux.elf"; }
|
||||||
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
|
||||||
|
virtual void buildLoader(const Filter *);
|
||||||
|
virtual void addStubEntrySections(Filter const *);
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
|
virtual void defineSymbols(Filter const *);
|
||||||
|
};
|
||||||
|
|
||||||
|
class PackBSDElf32x86 : public PackLinuxElf32x86
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf32x86 super;
|
||||||
|
public:
|
||||||
|
PackBSDElf32x86(InputFile *f);
|
||||||
|
virtual ~PackBSDElf32x86();
|
||||||
|
virtual int getFormat() const = 0;
|
||||||
|
virtual const char *getName() const = 0;
|
||||||
|
virtual const char *getFullName(const options_t *) const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
|
||||||
|
virtual void buildLoader(const Filter *);
|
||||||
|
};
|
||||||
|
|
||||||
|
class PackFreeBSDElf32x86 : public PackBSDElf32x86
|
||||||
|
{
|
||||||
|
typedef PackBSDElf32x86 super;
|
||||||
|
public:
|
||||||
|
PackFreeBSDElf32x86(InputFile *f);
|
||||||
|
virtual ~PackFreeBSDElf32x86();
|
||||||
|
virtual int getFormat() const { return UPX_F_BSD_ELF_i386; }
|
||||||
|
virtual const char *getName() const { return "freebsd/i386"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i386-freebsd.elf"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class PackNetBSDElf32x86 : public PackLinuxElf32x86
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf32x86 super;
|
||||||
|
public:
|
||||||
|
PackNetBSDElf32x86(InputFile *f);
|
||||||
|
virtual ~PackNetBSDElf32x86();
|
||||||
|
virtual int getFormat() const { return UPX_F_BSD_ELF_i386; }
|
||||||
|
virtual const char *getName() const { return "netbsd/i386"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i386-netbsd.elf"; }
|
||||||
|
protected:
|
||||||
|
virtual void buildLoader(const Filter *ft);
|
||||||
virtual void generateElfHdr(
|
virtual void generateElfHdr(
|
||||||
OutputFile *,
|
OutputFile *,
|
||||||
void const *proto,
|
void const *proto,
|
||||||
@@ -281,59 +591,109 @@ protected:
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*************************************************************************
|
class PackOpenBSDElf32x86 : public PackBSDElf32x86
|
||||||
// linux/elf386
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
class PackLinuxI386elf : public PackLinuxI386
|
|
||||||
{
|
{
|
||||||
typedef PackLinuxI386 super;
|
typedef PackBSDElf32x86 super;
|
||||||
public:
|
public:
|
||||||
PackLinuxI386elf(InputFile *f);
|
PackOpenBSDElf32x86(InputFile *f);
|
||||||
virtual ~PackLinuxI386elf();
|
virtual ~PackOpenBSDElf32x86();
|
||||||
virtual int getVersion() const { return 13; }
|
virtual int getFormat() const { return UPX_F_BSD_ELF_i386; }
|
||||||
virtual int getFormat() const { return UPX_F_LINUX_ELF_i386; }
|
virtual const char *getName() const { return "openbsd/i386"; }
|
||||||
virtual const char *getName() const { return "linux/elf386"; }
|
virtual const char *getFullName(const options_t *) const { return "i386-openbsd.elf"; }
|
||||||
virtual const int *getFilters() const;
|
|
||||||
virtual int buildLoader(const Filter *);
|
|
||||||
|
|
||||||
virtual void unpack(OutputFile *fo);
|
|
||||||
|
|
||||||
virtual bool canPack();
|
|
||||||
virtual bool canUnpackVersion(int version) const
|
|
||||||
{ return (version >= 11); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void buildLoader(const Filter *ft);
|
||||||
|
virtual void generateElfHdr(
|
||||||
|
OutputFile *,
|
||||||
|
void const *proto,
|
||||||
|
unsigned const brka
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// linux/elfarm
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
class PackLinuxElf32armLe : public PackLinuxElf32Le
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf32Le super;
|
||||||
|
public:
|
||||||
|
PackLinuxElf32armLe(InputFile *f);
|
||||||
|
virtual ~PackLinuxElf32armLe();
|
||||||
|
virtual int getFormat() const { return UPX_F_LINUX_ELF32_ARMEL; }
|
||||||
|
virtual const char *getName() const { return "linux/arm"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "arm-linux.elf"; }
|
||||||
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const int *getCompressionMethods(int method, int level) const;
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
virtual void pack2(OutputFile *, Filter &); // append compressed data
|
virtual void buildLoader(const Filter *);
|
||||||
virtual void pack3(OutputFile *, Filter &); // append loader
|
virtual void updateLoader(OutputFile *);
|
||||||
virtual void pack4(OutputFile *, Filter &); // append pack header
|
virtual void defineSymbols(Filter const *);
|
||||||
|
};
|
||||||
|
|
||||||
virtual void patchLoader();
|
class PackLinuxElf32armBe : public PackLinuxElf32Be
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf32Be super;
|
||||||
|
public:
|
||||||
|
PackLinuxElf32armBe(InputFile *f);
|
||||||
|
virtual ~PackLinuxElf32armBe();
|
||||||
|
virtual int getFormat() const { return UPX_F_LINUX_ELF32_ARMEB; }
|
||||||
|
virtual const char *getName() const { return "linux/armeb"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "armeb-linux.elf"; }
|
||||||
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
Elf32_Ehdr ehdri; // from input file
|
protected:
|
||||||
Elf32_Phdr *phdri; // for input file
|
virtual const int *getCompressionMethods(int method, int level) const;
|
||||||
unsigned sz_phdrs; // sizeof Phdr[]
|
virtual Linker* newLinker() const;
|
||||||
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
virtual void buildLoader(const Filter *);
|
||||||
|
virtual void updateLoader(OutputFile *);
|
||||||
|
virtual void defineSymbols(Filter const *);
|
||||||
|
};
|
||||||
|
|
||||||
char *file_image; // if ET_DYN investigation
|
class PackLinuxElf32mipseb : public PackLinuxElf32Be
|
||||||
Elf32_Dyn const *dynseg; // from PT_DYNAMIC
|
{
|
||||||
unsigned int const *hashtab; // from DT_HASH
|
typedef PackLinuxElf32Be super;
|
||||||
char const *dynstr; // from DT_STRTAB
|
public:
|
||||||
Elf32_Sym const *dynsym; // from DT_SYMTAB
|
PackLinuxElf32mipseb(InputFile *f);
|
||||||
|
virtual ~PackLinuxElf32mipseb();
|
||||||
|
virtual int getFormat() const { return UPX_F_LINUX_ELF32_MIPSEB; }
|
||||||
|
virtual const char *getName() const { return "linux/mips"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "mips-linux.elf"; }
|
||||||
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
static unsigned elf_hash(char const *) /*const*/;
|
protected:
|
||||||
virtual void const *elf_find_dynamic(unsigned) const;
|
virtual Linker* newLinker() const;
|
||||||
virtual Elf32_Sym const *elf_lookup(char const *) const;
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
virtual unsigned elf_get_offset_from_address(unsigned) const;
|
virtual void buildLoader(const Filter *);
|
||||||
virtual unsigned find_LOAD_gap(Elf32_Phdr const *const phdri, unsigned const k,
|
virtual void updateLoader(OutputFile *);
|
||||||
unsigned const e_phnum);
|
virtual void defineSymbols(Filter const *);
|
||||||
|
};
|
||||||
|
|
||||||
|
class PackLinuxElf32mipsel : public PackLinuxElf32Le
|
||||||
|
{
|
||||||
|
typedef PackLinuxElf32Le super;
|
||||||
|
public:
|
||||||
|
PackLinuxElf32mipsel(InputFile *f);
|
||||||
|
virtual ~PackLinuxElf32mipsel();
|
||||||
|
virtual int getFormat() const { return UPX_F_LINUX_ELF32_MIPSEL; }
|
||||||
|
virtual const char *getName() const { return "linux/mipsel"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "mipsel-linux.elf"; }
|
||||||
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
virtual void buildLoader(const Filter *);
|
||||||
|
virtual void updateLoader(OutputFile *);
|
||||||
|
virtual void defineSymbols(Filter const *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /*} already included */
|
#endif /*} already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+261
-202
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2006 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
Copyright (C) 2001-2006 John F. Reiser
|
Copyright (C) 2001-2020 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,8 +22,11 @@
|
|||||||
If not, write to the Free Software Foundation, Inc.,
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar John F. Reiser
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu jreiser@BitWagon.com
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
|
John F. Reiser
|
||||||
|
<jreiser@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -51,10 +54,35 @@
|
|||||||
// linux/386 (generic "execve" format)
|
// linux/386 (generic "execve" format)
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
PackLinuxI386::PackLinuxI386(InputFile *f) : super(f),
|
||||||
|
ei_osabi(Elf32_Ehdr::ELFOSABI_LINUX), osabi_note(NULL)
|
||||||
|
{
|
||||||
|
bele = &N_BELE_RTP::le_policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackBSDI386::PackBSDI386(InputFile *f) : super(f)
|
||||||
|
{
|
||||||
|
// Shell scripts need help specifying the target operating system.
|
||||||
|
// Elf input will override this with .e_ident[EI_OSABI] or PT_NOTE.
|
||||||
|
// [2006-09-27: Today's only runtime stub for shell is for linux.]
|
||||||
|
if (Elf32_Ehdr::ELFOSABI_LINUX==opt->o_unix.osabi0) {
|
||||||
|
// Disallow an incompatibility.
|
||||||
|
ei_osabi = Elf32_Ehdr::ELFOSABI_NONE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ei_osabi = opt->o_unix.osabi0; // might be ELFOSABI_NONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const
|
static const
|
||||||
#include "stub/l_lx_exec86.h"
|
#include "stub/i386-linux.elf.execve-entry.h"
|
||||||
static const
|
static const
|
||||||
#include "stub/fold_exec86.h"
|
#include "stub/i386-linux.elf.execve-fold.h"
|
||||||
|
|
||||||
|
static const
|
||||||
|
#include "stub/i386-bsd.elf.execve-entry.h"
|
||||||
|
static const
|
||||||
|
#include "stub/i386-bsd.elf.execve-fold.h"
|
||||||
|
|
||||||
|
|
||||||
const int *PackLinuxI386::getCompressionMethods(int method, int level) const
|
const int *PackLinuxI386::getCompressionMethods(int method, int level) const
|
||||||
@@ -66,21 +94,37 @@ const int *PackLinuxI386::getFilters() const
|
|||||||
{
|
{
|
||||||
static const int filters[] = {
|
static const int filters[] = {
|
||||||
0x49, 0x46,
|
0x49, 0x46,
|
||||||
// FIXME 2002-11-11: We use stub/fold_exec86.asm, which calls the
|
|
||||||
// decompressor multiple times, and unfilter is independent of decompress.
|
|
||||||
// Currently only filters 0x49, 0x46, 0x80..0x87 can handle this;
|
|
||||||
// and 0x80..0x87 are regarded as "untested".
|
|
||||||
#if 0
|
|
||||||
0x26, 0x24, 0x11, 0x14, 0x13, 0x16, 0x25, 0x15, 0x12,
|
0x26, 0x24, 0x11, 0x14, 0x13, 0x16, 0x25, 0x15, 0x12,
|
||||||
#endif
|
|
||||||
#if 0
|
#if 0
|
||||||
|
// 0x80..0x87 are regarded as "untested".
|
||||||
0x83, 0x86, 0x80, 0x84, 0x87, 0x81, 0x82, 0x85,
|
0x83, 0x86, 0x80, 0x84, 0x87, 0x81, 0x82, 0x85,
|
||||||
0x24, 0x16, 0x13, 0x14, 0x11, 0x25, 0x15, 0x12,
|
0x24, 0x16, 0x13, 0x14, 0x11, 0x25, 0x15, 0x12,
|
||||||
#endif
|
#endif
|
||||||
-1 };
|
FT_END };
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_stub_brk(Elf_LE32_Phdr *const phdr1, unsigned brka)
|
||||||
|
{
|
||||||
|
#define PAGE_MASK (~0ul<<12)
|
||||||
|
// linux-2.6.14 binfmt_elf.c: SIGKILL if (0==.p_memsz) on a page boundary
|
||||||
|
unsigned const brkb = brka | ((0==(~PAGE_MASK & brka)) ? 0x20 : 0);
|
||||||
|
phdr1->p_type = PT_LOAD; // be sure
|
||||||
|
phdr1->p_offset = ~PAGE_MASK & brkb;
|
||||||
|
phdr1->p_vaddr = brkb;
|
||||||
|
phdr1->p_paddr = brkb;
|
||||||
|
phdr1->p_filesz = 0;
|
||||||
|
phdr1->p_memsz = 0;
|
||||||
|
if (0==phdr1->p_flags) {
|
||||||
|
phdr1->p_flags = Elf32_Phdr::PF_R|Elf32_Phdr::PF_W;
|
||||||
|
}
|
||||||
|
if (0==phdr1->p_align) {
|
||||||
|
phdr1->p_align = 0x1000;
|
||||||
|
}
|
||||||
|
#undef PAGE_MASK
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PackLinuxI386::generateElfHdr(
|
PackLinuxI386::generateElfHdr(
|
||||||
OutputFile *fo,
|
OutputFile *fo,
|
||||||
@@ -88,9 +132,8 @@ PackLinuxI386::generateElfHdr(
|
|||||||
unsigned const brka
|
unsigned const brka
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cprElfHdr1 *const h1 = (cprElfHdr1 *)&elfout;
|
cprElfHdr2 *const h2 = (cprElfHdr2 *)(void *)&elfout;
|
||||||
cprElfHdr2 *const h2 = (cprElfHdr2 *)&elfout;
|
cprElfHdr3 *const h3 = (cprElfHdr3 *)(void *)&elfout;
|
||||||
cprElfHdr3 *const h3 = (cprElfHdr3 *)&elfout;
|
|
||||||
memcpy(h3, proto, sizeof(*h3)); // reads beyond, but OK
|
memcpy(h3, proto, sizeof(*h3)); // reads beyond, but OK
|
||||||
|
|
||||||
assert(h2->ehdr.e_phoff == sizeof(Elf32_Ehdr));
|
assert(h2->ehdr.e_phoff == sizeof(Elf32_Ehdr));
|
||||||
@@ -108,30 +151,22 @@ PackLinuxI386::generateElfHdr(
|
|||||||
|
|
||||||
// Info for OS kernel to set the brk()
|
// Info for OS kernel to set the brk()
|
||||||
if (brka) {
|
if (brka) {
|
||||||
h2->phdr[1].p_type = PT_LOAD; // be sure
|
set_stub_brk(&h2->phdr[1], brka);
|
||||||
h2->phdr[1].p_offset = 0xfff&brka;
|
|
||||||
h2->phdr[1].p_vaddr = brka;
|
|
||||||
h2->phdr[1].p_paddr = brka;
|
|
||||||
h2->phdr[1].p_filesz = 0;
|
|
||||||
h2->phdr[1].p_memsz = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ph.format==UPX_F_LINUX_i386 ) {
|
if (ph.format==UPX_F_LINUX_i386
|
||||||
assert(h1->ehdr.e_phnum==1);
|
|| ph.format==UPX_F_LINUX_SH_i386
|
||||||
memset(&h1->linfo, 0, sizeof(h1->linfo));
|
|| ph.format==UPX_F_BSD_i386
|
||||||
fo->write(h1, sizeof(*h1));
|
) {
|
||||||
}
|
// SELinux, PAx, grSecurity demand no PF_W if PF_X.
|
||||||
else if (ph.format==UPX_F_LINUX_ELF_i386) {
|
// kernel-2.6.12-2.3.legacy_FC3 has a bug which demands
|
||||||
|
// a PT_LOAD with PF_W, else SIGSEGV when clearing page fragment
|
||||||
|
// on low page of ".bss", which is the high page of .text.
|
||||||
|
// So the minimum number of PT_LOAD is 2.
|
||||||
assert(h2->ehdr.e_phnum==2);
|
assert(h2->ehdr.e_phnum==2);
|
||||||
memset(&h2->linfo, 0, sizeof(h2->linfo));
|
memset(&h2->linfo, 0, sizeof(h2->linfo));
|
||||||
fo->write(h2, sizeof(*h2));
|
fo->write(h2, sizeof(*h2));
|
||||||
}
|
}
|
||||||
else if (ph.format==UPX_F_LINUX_SH_i386) {
|
|
||||||
assert(h2->ehdr.e_phnum==1);
|
|
||||||
h2->ehdr.e_phnum = 2;
|
|
||||||
memset(&h2->linfo, 0, sizeof(h2->linfo));
|
|
||||||
fo->write(h2, sizeof(*h2));
|
|
||||||
}
|
|
||||||
else if (ph.format==UPX_F_LINUX_ELFI_i386) {
|
else if (ph.format==UPX_F_LINUX_ELFI_i386) {
|
||||||
assert(h3->ehdr.e_phnum==3);
|
assert(h3->ehdr.e_phnum==3);
|
||||||
memset(&h3->linfo, 0, sizeof(h3->linfo));
|
memset(&h3->linfo, 0, sizeof(h3->linfo));
|
||||||
@@ -148,7 +183,16 @@ PackLinuxI386::pack1(OutputFile *fo, Filter &)
|
|||||||
// create a pseudo-unique program id for our paranoid stub
|
// create a pseudo-unique program id for our paranoid stub
|
||||||
progid = getRandomId();
|
progid = getRandomId();
|
||||||
|
|
||||||
generateElfHdr(fo, linux_i386exec_fold, 0);
|
generateElfHdr(fo, stub_i386_linux_elf_execve_fold, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PackBSDI386::pack1(OutputFile *fo, Filter &)
|
||||||
|
{
|
||||||
|
// create a pseudo-unique program id for our paranoid stub
|
||||||
|
progid = getRandomId();
|
||||||
|
|
||||||
|
generateElfHdr(fo, stub_i386_bsd_elf_execve_fold, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -158,10 +202,11 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
|
|||||||
(elfout.ehdr.e_phentsize * elfout.ehdr.e_phnum) +
|
(elfout.ehdr.e_phentsize * elfout.ehdr.e_phnum) +
|
||||||
sizeof(l_info) +
|
sizeof(l_info) +
|
||||||
((elfout.ehdr.e_phnum==3) ? (unsigned) elfout.phdr[2].p_memsz : 0) ;
|
((elfout.ehdr.e_phnum==3) ? (unsigned) elfout.phdr[2].p_memsz : 0) ;
|
||||||
unsigned len = fo->getBytesWritten();
|
unsigned nw = fo->getBytesWritten();
|
||||||
set_native32(&elfout.phdr[0].p_filesz, len);
|
elfout.phdr[0].p_filesz = nw;
|
||||||
|
nw = 0u-((0u-elfout.phdr[0].p_align) & (0u-nw)); // ALIGN_UP
|
||||||
super::pack4(fo, ft); // write PackHeader and overlay_offset
|
super::pack4(fo, ft); // write PackHeader and overlay_offset
|
||||||
|
set_stub_brk(&elfout.phdr[1], nw + elfout.phdr[0].p_vaddr);
|
||||||
|
|
||||||
#if 0 // {
|
#if 0 // {
|
||||||
// /usr/bin/strip from RedHat 8.0 (binutils-2.13.90.0.2-2)
|
// /usr/bin/strip from RedHat 8.0 (binutils-2.13.90.0.2-2)
|
||||||
@@ -178,48 +223,56 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
|
|||||||
|
|
||||||
// Supply a "linking view" that covers everything,
|
// Supply a "linking view" that covers everything,
|
||||||
// so that 'strip' does not omit everything.
|
// so that 'strip' does not omit everything.
|
||||||
Elf32_Shdr shdr;
|
Elf_LE32_Shdr shdr;
|
||||||
// The section header string table.
|
// The section header string table.
|
||||||
char const shstrtab[] = "\0.\0.shstrtab";
|
char const shstrtab[] = "\0.\0.shstrtab";
|
||||||
|
|
||||||
unsigned eod = elfout.phdr[0].p_filesz;
|
unsigned eod = elfout.phdr[0].p_filesz;
|
||||||
set_native32(&elfout.ehdr.e_shoff, eod);
|
elfout.ehdr.e_shoff = eod;
|
||||||
set_native16(&elfout.ehdr.e_shentsize, sizeof(shdr));
|
elfout.ehdr.e_shentsize = sizeof(shdr);
|
||||||
set_native16(&elfout.ehdr.e_shnum, 3);
|
elfout.ehdr.e_shnum = 3;
|
||||||
set_native16(&elfout.ehdr.e_shstrndx, 2);
|
elfout.ehdr.e_shstrndx = 2;
|
||||||
|
|
||||||
// An empty Elf32_Shdr for space as a null index.
|
// An empty Elf32_Shdr for space as a null index.
|
||||||
memset(&shdr, 0, sizeof(shdr));
|
memset(&shdr, 0, sizeof(shdr));
|
||||||
set_native32(&shdr.sh_type, Elf32_Shdr::SHT_NULL);
|
shdr.sh_type = Elf32_Shdr::SHT_NULL;
|
||||||
fo->write(&shdr, sizeof(shdr));
|
fo->write(&shdr, sizeof(shdr));
|
||||||
|
|
||||||
// Cover all the bits we need at runtime.
|
// Cover all the bits we need at runtime.
|
||||||
memset(&shdr, 0, sizeof(shdr));
|
memset(&shdr, 0, sizeof(shdr));
|
||||||
set_native32(&shdr.sh_name, 1);
|
shdr.sh_name = 1;
|
||||||
set_native32(&shdr.sh_type, Elf32_Shdr::SHT_PROGBITS);
|
shdr.sh_type = Elf32_Shdr::SHT_PROGBITS;
|
||||||
set_native32(&shdr.sh_flags, Elf32_Shdr::SHF_ALLOC);
|
shdr.sh_flags = Elf32_Shdr::SHF_ALLOC;
|
||||||
set_native32(&shdr.sh_addr, elfout.phdr[0].p_vaddr);
|
shdr.sh_addr = elfout.phdr[0].p_vaddr;
|
||||||
set_native32(&shdr.sh_offset, overlay_offset);
|
shdr.sh_offset = overlay_offset;
|
||||||
set_native32(&shdr.sh_size, eod - overlay_offset);
|
shdr.sh_size = eod - overlay_offset;
|
||||||
set_native32(&shdr.sh_addralign, 4096);
|
shdr.sh_addralign = 4096;
|
||||||
fo->write(&shdr, sizeof(shdr));
|
fo->write(&shdr, sizeof(shdr));
|
||||||
|
|
||||||
// A section header for the section header string table.
|
// A section header for the section header string table.
|
||||||
memset(&shdr, 0, sizeof(shdr));
|
memset(&shdr, 0, sizeof(shdr));
|
||||||
set_native32(&shdr.sh_name, 3);
|
shdr.sh_name = 3;
|
||||||
set_native32(&shdr.sh_type, Elf32_Shdr::SHT_STRTAB);
|
shdr.sh_type = Elf32_Shdr::SHT_STRTAB;
|
||||||
set_native32(&shdr.sh_offset, 3*sizeof(shdr) + eod);
|
shdr.sh_offset = 3*sizeof(shdr) + eod;
|
||||||
set_native32(&shdr.sh_size, sizeof(shstrtab));
|
shdr.sh_size = sizeof(shstrtab);
|
||||||
fo->write(&shdr, sizeof(shdr));
|
fo->write(&shdr, sizeof(shdr));
|
||||||
|
|
||||||
fo->write(shstrtab, sizeof(shstrtab));
|
fo->write(shstrtab, sizeof(shstrtab));
|
||||||
#endif // }
|
#endif // }
|
||||||
|
|
||||||
|
|
||||||
|
// Cannot pre-round .p_memsz. If .p_filesz < .p_memsz, then kernel
|
||||||
|
// tries to make .bss, which requires PF_W.
|
||||||
|
// But strict SELinux (or PaX, grSecurity) disallows PF_W with PF_X.
|
||||||
|
#if 0 /*{*/
|
||||||
#undef PAGE_MASK
|
#undef PAGE_MASK
|
||||||
#define PAGE_MASK (~0u<<12)
|
#define PAGE_MASK (~0u<<12)
|
||||||
// pre-calculate for benefit of runtime disappearing act via munmap()
|
// pre-calculate for benefit of runtime disappearing act via munmap()
|
||||||
elfout.phdr[0].p_memsz = PAGE_MASK & (~PAGE_MASK + elfout.phdr[0].p_filesz);
|
elfout.phdr[0].p_memsz = PAGE_MASK & (~PAGE_MASK + elfout.phdr[0].p_filesz);
|
||||||
#undef PAGE_MASK
|
#undef PAGE_MASK
|
||||||
|
#else /*}{*/
|
||||||
|
elfout.phdr[0].p_memsz = elfout.phdr[0].p_filesz;
|
||||||
|
#endif /*}*/
|
||||||
|
|
||||||
// rewrite Elf header
|
// rewrite Elf header
|
||||||
fo->seek(0, SEEK_SET);
|
fo->seek(0, SEEK_SET);
|
||||||
@@ -235,7 +288,12 @@ umax(unsigned a, unsigned b)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
Linker *PackLinuxI386::newLinker() const
|
||||||
|
{
|
||||||
|
return new ElfLinkerX86;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
PackLinuxI386::buildLinuxLoader(
|
PackLinuxI386::buildLinuxLoader(
|
||||||
upx_byte const *const proto,
|
upx_byte const *const proto,
|
||||||
unsigned const szproto,
|
unsigned const szproto,
|
||||||
@@ -246,90 +304,54 @@ PackLinuxI386::buildLinuxLoader(
|
|||||||
{
|
{
|
||||||
initLoader(proto, szproto);
|
initLoader(proto, szproto);
|
||||||
|
|
||||||
struct b_info h; memset(&h, 0, sizeof(h));
|
|
||||||
unsigned fold_hdrlen = 0;
|
unsigned fold_hdrlen = 0;
|
||||||
if (0 < szfold) {
|
if (0 < szfold) {
|
||||||
cprElfHdr1 const *const hf = (cprElfHdr1 const *)fold;
|
cprElfHdr1 const *const hf = (cprElfHdr1 const *)fold;
|
||||||
fold_hdrlen = umax(0x80, sizeof(hf->ehdr) +
|
fold_hdrlen = sizeof(hf->ehdr) + hf->ehdr.e_phentsize * hf->ehdr.e_phnum +
|
||||||
hf->ehdr.e_phentsize * hf->ehdr.e_phnum + sizeof(l_info) );
|
sizeof(l_info);
|
||||||
h.sz_unc = (szfold < fold_hdrlen) ? 0 : (szfold - fold_hdrlen);
|
if (0 == get_le32(fold_hdrlen + fold)) {
|
||||||
h.b_method = (unsigned char) ph.method;
|
// inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
|
||||||
h.b_ftid = (unsigned char) ph.filter;
|
fold_hdrlen = umax(0x80, fold_hdrlen);
|
||||||
h.b_cto8 = (unsigned char) ph.filter_cto;
|
|
||||||
}
|
}
|
||||||
unsigned char const *const uncLoader = fold_hdrlen + fold;
|
|
||||||
|
|
||||||
unsigned char *const cprLoader = new unsigned char[sizeof(h) + h.sz_unc];
|
|
||||||
if (0 < szfold) {
|
|
||||||
unsigned sz_cpr;
|
|
||||||
int r = upx_compress(uncLoader, h.sz_unc, sizeof(h) + cprLoader, &sz_cpr,
|
|
||||||
NULL, ph.method, 10, NULL, NULL );
|
|
||||||
h.sz_cpr = sz_cpr;
|
|
||||||
if (r != UPX_E_OK || h.sz_cpr >= h.sz_unc)
|
|
||||||
throwInternalError("loader compression failed");
|
|
||||||
}
|
}
|
||||||
memcpy(cprLoader, &h, sizeof(h));
|
|
||||||
|
|
||||||
// This adds the definition to the "library", to be used later.
|
// This adds the definition to the "library", to be used later.
|
||||||
linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + h.sz_cpr);
|
// NOTE: the stub is NOT compressed! The savings is not worth it.
|
||||||
delete [] cprLoader;
|
linker->addSection("FOLDEXEC", fold + fold_hdrlen, szfold - fold_hdrlen, 0);
|
||||||
|
|
||||||
n_mru = ft->n_mru;
|
n_mru = ft->n_mru;
|
||||||
|
|
||||||
// Here is a quick summary of the format of the output file:
|
// Rely on "+80CXXXX" [etc] in getDecompressorSections() packer_c.cpp */
|
||||||
linker->setLoaderAlignOffset(
|
// // Here is a quick summary of the format of the output file:
|
||||||
// Elf32_Edhr
|
// linker->setLoaderAlignOffset(
|
||||||
sizeof(elfout.ehdr) +
|
// // Elf32_Edhr
|
||||||
// Elf32_Phdr: 1 for exec86, 2 for sh86, 3 for elf86
|
// sizeof(elfout.ehdr) +
|
||||||
(elfout.ehdr.e_phentsize * elfout.ehdr.e_phnum) +
|
// // Elf32_Phdr: 1 for exec86, 2 for sh86, 3 for elf86
|
||||||
// checksum UPX! lsize version format
|
// (elfout.ehdr.e_phentsize * elfout.ehdr.e_phnum) +
|
||||||
sizeof(l_info) +
|
// // checksum UPX! lsize version format
|
||||||
// PT_DYNAMIC with DT_NEEDED "forwarded" from original file
|
// sizeof(l_info) +
|
||||||
((elfout.ehdr.e_phnum==3) ? (unsigned) elfout.phdr[2].p_memsz : 0) +
|
// // PT_DYNAMIC with DT_NEEDED "forwarded" from original file
|
||||||
// p_progid, p_filesize, p_blocksize
|
// ((elfout.ehdr.e_phnum==3) ? (unsigned) elfout.phdr[2].p_memsz : 0) +
|
||||||
sizeof(p_info) +
|
// // p_progid, p_filesize, p_blocksize
|
||||||
// compressed data
|
// sizeof(p_info) +
|
||||||
b_len + ph.c_len );
|
// // compressed data
|
||||||
// entry to stub
|
// b_len + ph.c_len );
|
||||||
|
// // entry to stub
|
||||||
addLoader("LEXEC000", NULL);
|
addLoader("LEXEC000", NULL);
|
||||||
|
|
||||||
if (ft->id) {
|
if (ft->id) {
|
||||||
if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate
|
|
||||||
addLoader("LXUNF000", NULL);
|
|
||||||
addLoader("LXUNF002", NULL);
|
|
||||||
if (0x80==(ft->id & 0xF0)) {
|
|
||||||
if (256==n_mru) {
|
|
||||||
addLoader("MRUBYTE0", NULL);
|
|
||||||
}
|
|
||||||
else if (n_mru) {
|
|
||||||
addLoader("LXMRU005", NULL);
|
|
||||||
}
|
|
||||||
if (n_mru) {
|
|
||||||
addLoader("LXMRU006", NULL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addLoader("LXMRU007", NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (0x40==(ft->id & 0xF0)) {
|
|
||||||
addLoader("LXUNF008", NULL);
|
|
||||||
}
|
|
||||||
addLoader("LXUNF010", NULL);
|
|
||||||
}
|
|
||||||
if (n_mru) {
|
if (n_mru) {
|
||||||
addLoader("LEXEC009", NULL);
|
addLoader("LEXEC009", NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addLoader("LEXEC010", NULL);
|
addLoader("LEXEC010", NULL);
|
||||||
addLoader(getDecompressor(), NULL);
|
linker->defineSymbol("filter_cto", ft->cto);
|
||||||
|
linker->defineSymbol("filter_length",
|
||||||
|
(ft->id & 0xf) % 3 == 0 ? ft->calls :
|
||||||
|
ft->lastcall - ft->calls * 4);
|
||||||
|
addLoader(getDecompressorSections(), NULL);
|
||||||
addLoader("LEXEC015", NULL);
|
addLoader("LEXEC015", NULL);
|
||||||
if (ft->id) {
|
if (ft->id) {
|
||||||
if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate
|
{ // decompr, unfilter not separate
|
||||||
if (0x80!=(ft->id & 0xF0)) {
|
|
||||||
addLoader("LXUNF042", NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { // decompr, unfilter not separate
|
|
||||||
if (0x80==(ft->id & 0xF0)) {
|
if (0x80==(ft->id & 0xF0)) {
|
||||||
addLoader("LEXEC110", NULL);
|
addLoader("LEXEC110", NULL);
|
||||||
if (n_mru) {
|
if (n_mru) {
|
||||||
@@ -340,41 +362,48 @@ PackLinuxI386::buildLinuxLoader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
addFilter32(ft->id);
|
addFilter32(ft->id);
|
||||||
if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate
|
{ // decompr always unfilters
|
||||||
if (0x80==(ft->id & 0xF0)) {
|
|
||||||
if (0==n_mru) {
|
|
||||||
addLoader("LXMRU058", NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addLoader("LXUNF035", NULL);
|
|
||||||
}
|
|
||||||
else { // decompr always unfilters
|
|
||||||
addLoader("LEXEC017", NULL);
|
addLoader("LEXEC017", NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
addLoader("LEXEC017", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
addLoader("IDENTSTR", NULL);
|
addLoader("IDENTSTR", NULL);
|
||||||
addLoader("LEXEC020", NULL);
|
addLoader("LEXEC020", NULL);
|
||||||
addLoader("FOLDEXEC", NULL);
|
addLoader("FOLDEXEC", NULL);
|
||||||
|
if (M_IS_LZMA(ph.method)) {
|
||||||
char *ptr_cto = (char *)const_cast<unsigned char *>(getLoader());
|
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
|
||||||
int sz_cto = getLoaderSize();
|
upx_uint32_t properties = // lc, lp, pb, dummy
|
||||||
if (0x20==(ft->id & 0xF0) || 0x30==(ft->id & 0xF0)) { // push byte '?' ; cto8
|
(res->lit_context_bits << 0) |
|
||||||
patch_le16(ptr_cto, sz_cto, "\x6a?", 0x6a + (ft->cto << 8));
|
(res->lit_pos_bits << 8) |
|
||||||
checkPatch(NULL, 0, 0, 0); // reset
|
(res->pos_bits << 16);
|
||||||
|
if (linker->bele->isBE()) // big endian - bswap32
|
||||||
|
acc_swab32s(&properties);
|
||||||
|
linker->defineSymbol("lzma_properties", properties);
|
||||||
|
// -2 for properties
|
||||||
|
linker->defineSymbol("lzma_c_len", ph.c_len - 2);
|
||||||
|
linker->defineSymbol("lzma_u_len", ph.u_len);
|
||||||
|
unsigned const stack = getDecompressorWrkmemSize();
|
||||||
|
linker->defineSymbol("lzma_stack_adjust", 0u - stack);
|
||||||
}
|
}
|
||||||
// PackHeader and overlay_offset at the end of the output file,
|
if (0x80==(ft->id & 0xF0)) {
|
||||||
// after the compressed data.
|
int const mru = ft->n_mru ? 1+ ft->n_mru : 0;
|
||||||
|
if (mru && mru!=256) {
|
||||||
return getLoaderSize();
|
unsigned const is_pwr2 = (0==((mru -1) & mru));
|
||||||
|
linker->defineSymbol("NMRU", mru - is_pwr2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
relocateLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
PackLinuxI386::buildLoader(Filter const *ft)
|
PackLinuxI386::buildLoader(Filter const *ft)
|
||||||
{
|
{
|
||||||
unsigned const sz_fold = sizeof(linux_i386exec_fold);
|
unsigned const sz_fold = sizeof(stub_i386_linux_elf_execve_fold);
|
||||||
MemBuffer buf(sz_fold);
|
MemBuffer buf(sz_fold);
|
||||||
memcpy(buf, linux_i386exec_fold, sz_fold);
|
memcpy(buf, stub_i386_linux_elf_execve_fold, sz_fold);
|
||||||
|
|
||||||
// patch loader
|
// patch loader
|
||||||
// note: we only can use /proc/<pid>/fd when exetype > 0.
|
// note: we only can use /proc/<pid>/fd when exetype > 0.
|
||||||
@@ -384,22 +413,32 @@ PackLinuxI386::buildLoader(Filter const *ft)
|
|||||||
patch_le32(buf,sz_fold,"UPX3",progid);
|
patch_le32(buf,sz_fold,"UPX3",progid);
|
||||||
patch_le32(buf,sz_fold,"UPX2",exetype > 0 ? 0 : 0x7fffffff);
|
patch_le32(buf,sz_fold,"UPX2",exetype > 0 ? 0 : 0x7fffffff);
|
||||||
|
|
||||||
// get fresh filter
|
buildLinuxLoader(
|
||||||
Filter fold_ft = *ft;
|
stub_i386_linux_elf_execve_entry, sizeof(stub_i386_linux_elf_execve_entry),
|
||||||
fold_ft.init(ft->id, ft->addvalue);
|
|
||||||
int preferred_ctos[2] = {ft->cto, -1};
|
|
||||||
fold_ft.preferred_ctos = preferred_ctos;
|
|
||||||
|
|
||||||
// filter
|
|
||||||
optimizeFilter(&fold_ft, buf, sz_fold);
|
|
||||||
bool success = fold_ft.filter(buf + sizeof(cprElfHdr2), sz_fold - sizeof(cprElfHdr2));
|
|
||||||
(void)success;
|
|
||||||
|
|
||||||
return buildLinuxLoader(
|
|
||||||
linux_i386exec_loader, sizeof(linux_i386exec_loader),
|
|
||||||
buf, sz_fold, ft );
|
buf, sz_fold, ft );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PackBSDI386::buildLoader(Filter const *ft)
|
||||||
|
{
|
||||||
|
unsigned const sz_fold = sizeof(stub_i386_bsd_elf_execve_fold);
|
||||||
|
MemBuffer buf(sz_fold);
|
||||||
|
memcpy(buf, stub_i386_bsd_elf_execve_fold, sz_fold);
|
||||||
|
|
||||||
|
// patch loader
|
||||||
|
// note: we only can use /proc/<pid>/fd when exetype > 0.
|
||||||
|
// also, we sleep much longer when compressing a script.
|
||||||
|
checkPatch(NULL, 0, 0, 0); // reset
|
||||||
|
patch_le32(buf,sz_fold,"UPX4",exetype > 0 ? 3 : 15); // sleep time
|
||||||
|
patch_le32(buf,sz_fold,"UPX3",progid);
|
||||||
|
patch_le32(buf,sz_fold,"UPX2",exetype > 0 ? 0 : 0x7fffffff);
|
||||||
|
|
||||||
|
buildLinuxLoader(
|
||||||
|
stub_i386_bsd_elf_execve_entry, sizeof(stub_i386_bsd_elf_execve_entry),
|
||||||
|
buf, sz_fold, ft );
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: getLoaderPrefixSize is unused?
|
||||||
int PackLinuxI386::getLoaderPrefixSize() const
|
int PackLinuxI386::getLoaderPrefixSize() const
|
||||||
{
|
{
|
||||||
return 116;
|
return 116;
|
||||||
@@ -410,8 +449,8 @@ int PackLinuxI386::getLoaderPrefixSize() const
|
|||||||
// some ELF utitlity functions
|
// some ELF utitlity functions
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
// basic check of an Linux ELF Ehdr
|
// basic check of a Linux ELF Ehdr
|
||||||
int PackLinuxI386::checkEhdr(const Elf32_Ehdr *ehdr) const
|
int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
|
||||||
{
|
{
|
||||||
const unsigned char * const buf = ehdr->e_ident;
|
const unsigned char * const buf = ehdr->e_ident;
|
||||||
|
|
||||||
@@ -451,34 +490,6 @@ int PackLinuxI386::checkEhdr(const Elf32_Ehdr *ehdr) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t PackLinuxI386::getbrk(const Elf32_Phdr *phdr, int e_phnum) const
|
|
||||||
{
|
|
||||||
off_t brka = 0;
|
|
||||||
for (int j = 0; j < e_phnum; ++phdr, ++j) {
|
|
||||||
if (phdr->PT_LOAD == phdr->p_type) {
|
|
||||||
off_t b = phdr->p_vaddr + phdr->p_memsz;
|
|
||||||
if (b > brka)
|
|
||||||
brka = b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return brka;
|
|
||||||
}
|
|
||||||
|
|
||||||
off_t PackLinuxI386::getbase(const Elf32_Phdr *phdr, int e_phnum) const
|
|
||||||
{
|
|
||||||
off_t base = ~0u;
|
|
||||||
for (int j = 0; j < e_phnum; ++phdr, ++j) {
|
|
||||||
if (phdr->PT_LOAD == phdr->p_type) {
|
|
||||||
if (phdr->p_vaddr < (unsigned) base)
|
|
||||||
base = phdr->p_vaddr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (0!=base) {
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
return 0x12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
@@ -489,9 +500,10 @@ bool PackLinuxI386::canPack()
|
|||||||
if (exetype != 0)
|
if (exetype != 0)
|
||||||
return super::canPack();
|
return super::canPack();
|
||||||
|
|
||||||
Elf32_Ehdr ehdr;
|
Elf_LE32_Ehdr ehdr;
|
||||||
unsigned char *buf = ehdr.e_ident;
|
unsigned char *buf = ehdr.e_ident;
|
||||||
|
|
||||||
|
fi->seek(0, SEEK_SET);
|
||||||
fi->readx(&ehdr, sizeof(ehdr));
|
fi->readx(&ehdr, sizeof(ehdr));
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
|
|
||||||
@@ -499,12 +511,61 @@ bool PackLinuxI386::canPack()
|
|||||||
const unsigned l = get_le32(buf);
|
const unsigned l = get_le32(buf);
|
||||||
|
|
||||||
int elf = checkEhdr(&ehdr);
|
int elf = checkEhdr(&ehdr);
|
||||||
if (elf >= 0)
|
if (elf >= 0) {
|
||||||
{
|
|
||||||
// NOTE: ELF executables are now handled by p_lx_elf.cpp,
|
// NOTE: ELF executables are now handled by p_lx_elf.cpp,
|
||||||
// so we only handle them here if force_execve
|
// so we only handle them here if force_execve
|
||||||
if (elf == 0 && opt->o_unix.force_execve)
|
if (elf == 0 && opt->o_unix.force_execve) {
|
||||||
exetype = 1;
|
exetype = 1;
|
||||||
|
|
||||||
|
unsigned osabi0 = ehdr.e_ident[Elf32_Ehdr::EI_OSABI];
|
||||||
|
switch (osabi0) {
|
||||||
|
case Elf32_Ehdr::ELFOSABI_LINUX:
|
||||||
|
case Elf32_Ehdr::ELFOSABI_FREEBSD:
|
||||||
|
case Elf32_Ehdr::ELFOSABI_NETBSD:
|
||||||
|
case Elf32_Ehdr::ELFOSABI_OPENBSD:
|
||||||
|
ei_osabi = osabi0; // Proudly declares its osabi in Ehdr.
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
unsigned const e_phnum = get_te16(&ehdr.e_phnum);
|
||||||
|
if (e_phnum<=(512/sizeof(Elf32_Phdr))) {
|
||||||
|
union {
|
||||||
|
unsigned char buf2[512];
|
||||||
|
//Elf32_Phdr phdr;
|
||||||
|
} u;
|
||||||
|
fi->seek(get_te32(&ehdr.e_phoff), SEEK_SET);
|
||||||
|
fi->readx(u.buf2, sizeof(u.buf2));
|
||||||
|
fi->seek(0, SEEK_SET);
|
||||||
|
Elf32_Phdr const *phdr = (Elf32_Phdr *) u.buf2;
|
||||||
|
for (unsigned j=0; j < e_phnum; ++phdr, ++j) {
|
||||||
|
if (phdr->PT_NOTE == get_te32(&phdr->p_type)) {
|
||||||
|
unsigned const offset = get_te32(&phdr->p_offset);
|
||||||
|
struct Elf32_Note note; memset(¬e, 0, sizeof(note));
|
||||||
|
fi->seek(offset, SEEK_SET);
|
||||||
|
fi->readx(¬e, sizeof(note));
|
||||||
|
fi->seek(0, SEEK_SET);
|
||||||
|
if (4==get_te32(¬e.descsz)
|
||||||
|
&& 1==get_te32(¬e.type)
|
||||||
|
&& 0==note.end ) {
|
||||||
|
if (0==strcmp("NetBSD", (char const *)note.text)) {
|
||||||
|
ei_osabi = Elf32_Ehdr::ELFOSABI_NETBSD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (0==strcmp("OpenBSD", (char const *)note.text)) {
|
||||||
|
ei_osabi = Elf32_Ehdr::ELFOSABI_OPENBSD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (UPX_F_BSD_i386==getFormat()
|
||||||
|
&& !(Elf32_Ehdr::ELFOSABI_FREEBSD==ei_osabi
|
||||||
|
|| Elf32_Ehdr::ELFOSABI_NETBSD ==ei_osabi
|
||||||
|
|| Elf32_Ehdr::ELFOSABI_OPENBSD==ei_osabi )) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (l == 0x00640107 || l == 0x00640108 || l == 0x0064010b || l == 0x006400cc)
|
else if (l == 0x00640107 || l == 0x00640108 || l == 0x0064010b || l == 0x006400cc)
|
||||||
{
|
{
|
||||||
@@ -513,15 +574,17 @@ bool PackLinuxI386::canPack()
|
|||||||
// FIXME: N_TRSIZE, N_DRSIZE
|
// FIXME: N_TRSIZE, N_DRSIZE
|
||||||
// FIXME: check for aout shared libraries
|
// FIXME: check for aout shared libraries
|
||||||
}
|
}
|
||||||
#if defined(__linux__)
|
else { // shell scripts and other interpreters
|
||||||
// only compress scripts when running under Linux
|
if (Elf32_Ehdr::ELFOSABI_LINUX!=ei_osabi) {
|
||||||
|
return false; // so far, only Linux has runtime stub for shell
|
||||||
|
}
|
||||||
else if (!memcmp(buf, "#!/", 3)) // #!/bin/sh
|
else if (!memcmp(buf, "#!/", 3)) // #!/bin/sh
|
||||||
exetype = -1;
|
exetype = -1;
|
||||||
else if (!memcmp(buf, "#! /", 4)) // #! /bin/sh
|
else if (!memcmp(buf, "#! /", 4)) // #! /bin/sh
|
||||||
exetype = -1;
|
exetype = -1;
|
||||||
else if (!memcmp(buf, "\xca\xfe\xba\xbe", 4)) // Java bytecode
|
else if (!memcmp(buf, "\xca\xfe\xba\xbe", 4)) // Java bytecode
|
||||||
exetype = -2;
|
exetype = -2;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
return super::canPack();
|
return super::canPack();
|
||||||
}
|
}
|
||||||
@@ -532,17 +595,17 @@ void PackLinuxI386::patchLoader() { }
|
|||||||
|
|
||||||
void PackLinuxI386::patchLoaderChecksum()
|
void PackLinuxI386::patchLoaderChecksum()
|
||||||
{
|
{
|
||||||
unsigned char *const ptr = const_cast<unsigned char *>(getLoader());
|
unsigned char *const ptr = getLoader();
|
||||||
l_info *const lp = (l_info *)(sizeof(elfout.ehdr) +
|
l_info *const lp = (l_info *)(sizeof(elfout.ehdr) +
|
||||||
(elfout.ehdr.e_phnum * elfout.ehdr.e_phentsize) + (char *)&elfout );
|
(elfout.ehdr.e_phnum * elfout.ehdr.e_phentsize) + (char *)&elfout );
|
||||||
// checksum for loader + p_info
|
// checksum for loader + p_info
|
||||||
lp->l_checksum = 0;
|
lp->l_checksum = 0;
|
||||||
lp->l_magic = UPX_ELF_MAGIC;
|
lp->l_magic = UPX_ELF_MAGIC;
|
||||||
lp->l_lsize = (unsigned short) lsize;
|
set_te16(&lp->l_lsize, (upx_uint16_t) lsize);
|
||||||
lp->l_version = (unsigned char) ph.version;
|
lp->l_version = (unsigned char) ph.version;
|
||||||
lp->l_format = (unsigned char) ph.format;
|
lp->l_format = (unsigned char) ph.format;
|
||||||
// INFO: lp->l_checksum is currently unused
|
// INFO: lp->l_checksum is currently unused
|
||||||
lp->l_checksum = upx_adler32(ptr, lsize);
|
set_te32(&lp->l_checksum, upx_adler32(ptr, lsize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -551,8 +614,4 @@ void PackLinuxI386::updateLoader(OutputFile *fo)
|
|||||||
elfout.ehdr.e_entry = fo->getBytesWritten() + elfout.phdr[0].p_vaddr;
|
elfout.ehdr.e_entry = fo->getBytesWritten() + elfout.phdr[0].p_vaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+60
-31
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,12 +22,15 @@
|
|||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
|
John F. Reiser
|
||||||
|
<jreiser@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_LX_EXC_H
|
#ifndef __UPX_P_LX_EXC_H
|
||||||
#define __UPX_P_LX_EXC_H
|
#define __UPX_P_LX_EXC_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -38,17 +41,18 @@ class PackLinuxI386 : public PackUnixLe32
|
|||||||
{
|
{
|
||||||
typedef PackUnixLe32 super;
|
typedef PackUnixLe32 super;
|
||||||
public:
|
public:
|
||||||
PackLinuxI386(InputFile *f) : super(f) { }
|
PackLinuxI386(InputFile *f);
|
||||||
virtual void generateElfHdr(
|
virtual void generateElfHdr(
|
||||||
OutputFile *,
|
OutputFile *,
|
||||||
void const *proto,
|
void const *proto,
|
||||||
unsigned const brka
|
unsigned const brka
|
||||||
);
|
);
|
||||||
virtual int getFormat() const { return UPX_F_LINUX_i386; }
|
virtual int getFormat() const { return UPX_F_LINUX_i386; }
|
||||||
virtual const char *getName() const { return "linux/386"; }
|
virtual const char *getName() const { return "linux.exec/i386"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i386-linux.elf.execve"; }
|
||||||
virtual const int *getCompressionMethods(int method, int level) const;
|
virtual const int *getCompressionMethods(int method, int level) const;
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
virtual int buildLoader(const Filter *);
|
virtual void buildLoader(const Filter *);
|
||||||
|
|
||||||
virtual bool canPack();
|
virtual bool canPack();
|
||||||
|
|
||||||
@@ -59,8 +63,9 @@ protected:
|
|||||||
virtual void pack4(OutputFile *, Filter &); // append PackHeader
|
virtual void pack4(OutputFile *, Filter &); // append PackHeader
|
||||||
|
|
||||||
// loader util
|
// loader util
|
||||||
|
virtual Linker* newLinker() const;
|
||||||
virtual int getLoaderPrefixSize() const;
|
virtual int getLoaderPrefixSize() const;
|
||||||
virtual int buildLinuxLoader(
|
virtual void buildLinuxLoader(
|
||||||
upx_byte const *const proto, // assembly-only sections
|
upx_byte const *const proto, // assembly-only sections
|
||||||
unsigned const szproto,
|
unsigned const szproto,
|
||||||
upx_byte const *const fold, // linked assembly + C section
|
upx_byte const *const fold, // linked assembly + C section
|
||||||
@@ -74,9 +79,7 @@ protected:
|
|||||||
virtual void updateLoader(OutputFile *);
|
virtual void updateLoader(OutputFile *);
|
||||||
|
|
||||||
// ELF util
|
// ELF util
|
||||||
virtual int checkEhdr(const Elf32_Ehdr *ehdr) const;
|
virtual int checkEhdr(const Elf_LE32_Ehdr *ehdr) const;
|
||||||
virtual off_t getbrk(const Elf32_Phdr *phdr, int e_phnum) const;
|
|
||||||
virtual off_t getbase(const Elf32_Phdr *phdr, int e_phnum) const;
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
UPX_ELF_MAGIC = 0x5850557f // "\x7fUPX"
|
UPX_ELF_MAGIC = 0x5850557f // "\x7fUPX"
|
||||||
@@ -84,36 +87,62 @@ protected:
|
|||||||
|
|
||||||
unsigned n_mru;
|
unsigned n_mru;
|
||||||
|
|
||||||
struct cprElfHdr1 {
|
__packed_struct(cprElfHdr1)
|
||||||
Elf32_Ehdr ehdr;
|
Elf_LE32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[1];
|
Elf_LE32_Phdr phdr[1];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct cprElfHdr2 {
|
__packed_struct(cprElfHdr2)
|
||||||
Elf32_Ehdr ehdr;
|
Elf_LE32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[2];
|
Elf_LE32_Phdr phdr[2];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
struct cprElfHdr3 {
|
__packed_struct(cprElfHdr3)
|
||||||
Elf32_Ehdr ehdr;
|
Elf_LE32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[3];
|
Elf_LE32_Phdr phdr[3];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
}
|
__packed_struct_end()
|
||||||
__attribute_packed;
|
|
||||||
|
|
||||||
cprElfHdr3 elfout;
|
cprElfHdr3 elfout;
|
||||||
|
|
||||||
|
struct Elf32_Note {
|
||||||
|
unsigned namesz; // 8
|
||||||
|
unsigned descsz; // 4
|
||||||
|
unsigned type; // 1
|
||||||
|
char text[0x18 - 4*4]; // "OpenBSD"
|
||||||
|
unsigned end; // 0
|
||||||
|
} elfnote;
|
||||||
|
|
||||||
|
unsigned char ei_osabi;
|
||||||
|
char const *osabi_note;
|
||||||
|
|
||||||
|
static void compileTimeAssertions() {
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr1) == 52 + 1*32 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr2) == 52 + 2*32 + 12)
|
||||||
|
COMPILE_TIME_ASSERT(sizeof(cprElfHdr3) == 52 + 3*32 + 12)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr1)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr2)
|
||||||
|
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr3)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class PackBSDI386 : public PackLinuxI386
|
||||||
|
{
|
||||||
|
typedef PackLinuxI386 super;
|
||||||
|
public:
|
||||||
|
PackBSDI386(InputFile *f);
|
||||||
|
virtual int getFormat() const { return UPX_F_BSD_i386; }
|
||||||
|
virtual const char *getName() const { return "bsd.exec/i386"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i386-bsd.elf.execve"; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
|
|
||||||
|
virtual void buildLoader(const Filter *);
|
||||||
|
};
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+44
-41
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2006 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
Copyright (C) 2000-2006 John F. Reiser
|
Copyright (C) 2000-2020 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,8 +22,11 @@
|
|||||||
If not, write to the Free Software Foundation, Inc.,
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar John F. Reiser
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu jreiser@BitWagon.com
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
|
John F. Reiser
|
||||||
|
<jreiser@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -48,20 +51,20 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
static const
|
static const
|
||||||
#include "stub/l_lx_pti86.h"
|
#include "stub/i386-linux.elf.interp-entry.h"
|
||||||
static const
|
static const
|
||||||
#include "stub/fold_pti86.h"
|
#include "stub/i386-linux.elf.interp-fold.h"
|
||||||
|
|
||||||
PackLinuxI386interp::PackLinuxI386interp(InputFile *f) :
|
PackLinuxElf32x86interp::PackLinuxElf32x86interp(InputFile *f) :
|
||||||
super(f)
|
super(f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PackLinuxI386interp::~PackLinuxI386interp()
|
PackLinuxElf32x86interp::~PackLinuxElf32x86interp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackLinuxI386interp::canPack()
|
bool PackLinuxElf32x86interp::canPack()
|
||||||
{
|
{
|
||||||
if (opt->o_unix.make_ptinterp) {
|
if (opt->o_unix.make_ptinterp) {
|
||||||
return true;
|
return true;
|
||||||
@@ -72,14 +75,14 @@ bool PackLinuxI386interp::canPack()
|
|||||||
return super::canPack();
|
return super::canPack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxI386interp::pack1(OutputFile *fo, Filter &)
|
void PackLinuxElf32x86interp::pack1(OutputFile *fo, Filter &)
|
||||||
{
|
{
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
fi->readx(&ehdri, sizeof(ehdri));
|
fi->readx(&ehdri, sizeof(ehdri));
|
||||||
assert(ehdri.e_phoff == sizeof(Elf32_Ehdr)); // checked by canPack()
|
assert(ehdri.e_phoff == sizeof(Elf32_Ehdr)); // checked by canPack()
|
||||||
sz_phdrs = ehdri.e_phnum * ehdri.e_phentsize;
|
sz_phdrs = ehdri.e_phnum * ehdri.e_phentsize;
|
||||||
|
|
||||||
phdri = new Elf32_Phdr[(unsigned)ehdri.e_phnum];
|
phdri = New(Elf32_Phdr, ehdri.e_phnum);
|
||||||
fi->seek(ehdri.e_phoff, SEEK_SET);
|
fi->seek(ehdri.e_phoff, SEEK_SET);
|
||||||
fi->readx(phdri, sz_phdrs);
|
fi->readx(phdri, sz_phdrs);
|
||||||
|
|
||||||
@@ -111,7 +114,7 @@ void PackLinuxI386interp::pack1(OutputFile *fo, Filter &)
|
|||||||
h3.phdr[2].p_align = 1;
|
h3.phdr[2].p_align = 1;
|
||||||
|
|
||||||
if (opt->o_unix.make_ptinterp) { // unusual "once per release"
|
if (opt->o_unix.make_ptinterp) { // unusual "once per release"
|
||||||
elfout = h3;
|
*(cprElfHdr3 *)(void *)&elfout = h3;
|
||||||
elfout.ehdr.e_phnum = 1;
|
elfout.ehdr.e_phnum = 1;
|
||||||
fo->write(&elfout, elfout.ehdr.e_ehsize + elfout.ehdr.e_phentsize);
|
fo->write(&elfout, elfout.ehdr.e_ehsize + elfout.ehdr.e_phentsize);
|
||||||
}
|
}
|
||||||
@@ -121,18 +124,18 @@ void PackLinuxI386interp::pack1(OutputFile *fo, Filter &)
|
|||||||
#undef E
|
#undef E
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackLinuxI386interp::pack2(OutputFile *fo, Filter &ft)
|
int PackLinuxElf32x86interp::pack2(OutputFile *fo, Filter &ft)
|
||||||
{
|
{
|
||||||
if (opt->o_unix.make_ptinterp) {
|
if (opt->o_unix.make_ptinterp) {
|
||||||
return; // ignore current input file!
|
return 1; // ignore current input file!
|
||||||
}
|
}
|
||||||
super::pack2(fo, ft);
|
return super::pack2(fo, ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef PAGE_MASK
|
#undef PAGE_MASK
|
||||||
#define PAGE_MASK (~0u<<12)
|
#define PAGE_MASK (~0u<<12)
|
||||||
|
|
||||||
void PackLinuxI386interp::pack3(OutputFile *fo, Filter &/*ft*/)
|
off_t PackLinuxElf32x86interp::pack3(OutputFile *fo, Filter &/*ft*/)
|
||||||
{
|
{
|
||||||
unsigned base = getbase(phdri, ehdri.e_phnum);
|
unsigned base = getbase(phdri, ehdri.e_phnum);
|
||||||
unsigned sz = PAGE_MASK & (~PAGE_MASK + elfout.phdr[0].p_filesz);
|
unsigned sz = PAGE_MASK & (~PAGE_MASK + elfout.phdr[0].p_filesz);
|
||||||
@@ -144,26 +147,26 @@ void PackLinuxI386interp::pack3(OutputFile *fo, Filter &/*ft*/)
|
|||||||
}
|
}
|
||||||
elfout.phdr[0].p_paddr = elfout.phdr[0].p_vaddr = base - sz;
|
elfout.phdr[0].p_paddr = elfout.phdr[0].p_vaddr = base - sz;
|
||||||
if (opt->o_unix.make_ptinterp) {
|
if (opt->o_unix.make_ptinterp) {
|
||||||
initLoader(linux_i386pti_loader, sizeof(linux_i386pti_loader));
|
initLoader(stub_i386_linux_elf_interp_entry, sizeof(stub_i386_linux_elf_interp_entry));
|
||||||
linker->addSection("FOLDEXEC", linux_i386pti_fold, sizeof(linux_i386pti_fold));
|
linker->addSection("FOLDEXEC", stub_i386_linux_elf_interp_fold, sizeof(stub_i386_linux_elf_interp_fold), 0);
|
||||||
|
|
||||||
addLoader("LXPTI000", NULL);
|
addLoader("LXPTI000", NULL);
|
||||||
|
|
||||||
addLoader("LXPTI040", NULL);
|
addLoader("LXPTI040", NULL);
|
||||||
ph.method = M_NRV2B_LE32; addLoader(getDecompressor(), NULL);
|
ph.method = M_NRV2B_LE32; addLoader(getDecompressorSections(), NULL);
|
||||||
addLoader("LXPTI090", NULL);
|
addLoader("LXPTI090", NULL);
|
||||||
|
|
||||||
addLoader("LXPTI041", NULL);
|
addLoader("LXPTI041", NULL);
|
||||||
ph.method = M_NRV2D_LE32; addLoader(getDecompressor(), NULL);
|
ph.method = M_NRV2D_LE32; addLoader(getDecompressorSections(), NULL);
|
||||||
addLoader("LXPTI090", NULL);
|
addLoader("LXPTI090", NULL);
|
||||||
|
|
||||||
addLoader("LXPTI042", NULL);
|
addLoader("LXPTI042", NULL);
|
||||||
ph.method = M_NRV2E_LE32; addLoader(getDecompressor(), NULL);
|
ph.method = M_NRV2E_LE32; addLoader(getDecompressorSections(), NULL);
|
||||||
addLoader("LXPTI090", NULL);
|
addLoader("LXPTI090", NULL);
|
||||||
|
|
||||||
addLoader("LXPTI043", NULL);
|
//addLoader("LXPTI043", NULL);
|
||||||
ph.method = M_CL1B_LE32; addLoader(getDecompressor(), NULL);
|
//ph.method = M_CL1B_LE32; addLoader(getDecompressorSections(), NULL);
|
||||||
addLoader("LXPTI090", NULL);
|
//addLoader("LXPTI090", NULL);
|
||||||
|
|
||||||
addLoader("LXPTI091", NULL);
|
addLoader("LXPTI091", NULL);
|
||||||
|
|
||||||
@@ -188,21 +191,25 @@ void PackLinuxI386interp::pack3(OutputFile *fo, Filter &/*ft*/)
|
|||||||
else {
|
else {
|
||||||
updateLoader(fo);
|
updateLoader(fo);
|
||||||
}
|
}
|
||||||
|
return fo->getBytesWritten();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PackLinuxI386interp::unpack(OutputFile *fo)
|
void PackLinuxElf32x86interp::unpack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
#define MAX_INTERP_HDR 512
|
#define MAX_INTERP_HDR 512
|
||||||
char bufehdr[MAX_INTERP_HDR];
|
union {
|
||||||
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *)bufehdr;
|
unsigned char buf[MAX_INTERP_HDR];
|
||||||
Elf32_Phdr const *phdr = (Elf32_Phdr *)(1+ehdr);
|
//struct { Elf32_Ehdr ehdr; Elf32_Phdr phdr; } e;
|
||||||
|
} u;
|
||||||
|
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *) u.buf;
|
||||||
|
Elf32_Phdr const *phdr = (Elf32_Phdr *) (u.buf + sizeof(*ehdr));
|
||||||
|
|
||||||
unsigned szb_info = sizeof(b_info);
|
unsigned szb_info = sizeof(b_info);
|
||||||
{
|
{
|
||||||
fi->seek(0, SEEK_SET);
|
fi->seek(0, SEEK_SET);
|
||||||
fi->readx(bufehdr, MAX_INTERP_HDR);
|
fi->readx(u.buf, MAX_INTERP_HDR);
|
||||||
unsigned const e_entry = get_native32(&ehdr->e_entry);
|
unsigned const e_entry = get_te32(&ehdr->e_entry);
|
||||||
if (e_entry < 0x401180) { /* old style, 8-byte b_info */
|
if (e_entry < 0x401180) { /* old style, 8-byte b_info */
|
||||||
szb_info = 2*sizeof(unsigned);
|
szb_info = 2*sizeof(unsigned);
|
||||||
}
|
}
|
||||||
@@ -211,16 +218,16 @@ void PackLinuxI386interp::unpack(OutputFile *fo)
|
|||||||
fi->seek(overlay_offset, SEEK_SET);
|
fi->seek(overlay_offset, SEEK_SET);
|
||||||
p_info hbuf;
|
p_info hbuf;
|
||||||
fi->readx(&hbuf, sizeof(hbuf));
|
fi->readx(&hbuf, sizeof(hbuf));
|
||||||
unsigned orig_file_size = get_native32(&hbuf.p_filesize);
|
unsigned orig_file_size = get_te32(&hbuf.p_filesize);
|
||||||
blocksize = get_native32(&hbuf.p_blocksize);
|
blocksize = get_te32(&hbuf.p_blocksize);
|
||||||
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
|
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
|
||||||
throwCantUnpack("file header corrupted");
|
throwCantUnpack("file header corrupted");
|
||||||
|
|
||||||
ibuf.alloc(blocksize + OVERHEAD);
|
ibuf.alloc(blocksize + OVERHEAD);
|
||||||
b_info bhdr; memset(&bhdr, 0, sizeof(bhdr));
|
b_info bhdr; memset(&bhdr, 0, sizeof(bhdr));
|
||||||
fi->readx(&bhdr, szb_info);
|
fi->readx(&bhdr, szb_info);
|
||||||
ph.u_len = get_native32(&bhdr.sz_unc);
|
ph.u_len = get_te32(&bhdr.sz_unc);
|
||||||
ph.c_len = get_native32(&bhdr.sz_cpr);
|
ph.c_len = get_te32(&bhdr.sz_cpr);
|
||||||
ph.filter_cto = bhdr.b_cto8;
|
ph.filter_cto = bhdr.b_cto8;
|
||||||
|
|
||||||
// Uncompress Ehdr and Phdrs.
|
// Uncompress Ehdr and Phdrs.
|
||||||
@@ -274,7 +281,7 @@ void PackLinuxI386interp::unpack(OutputFile *fo)
|
|||||||
|
|
||||||
// check for end-of-file
|
// check for end-of-file
|
||||||
fi->readx(&bhdr, szb_info);
|
fi->readx(&bhdr, szb_info);
|
||||||
unsigned const sz_unc = ph.u_len = get_native32(&bhdr.sz_unc);
|
unsigned const sz_unc = ph.u_len = get_te32(&bhdr.sz_unc);
|
||||||
|
|
||||||
if (sz_unc == 0) { // uncompressed size 0 -> EOF
|
if (sz_unc == 0) { // uncompressed size 0 -> EOF
|
||||||
// note: magic is always stored le32
|
// note: magic is always stored le32
|
||||||
@@ -300,8 +307,4 @@ void PackLinuxI386interp::unpack(OutputFile *fo)
|
|||||||
#undef MAX_INTERP_HDR
|
#undef MAX_INTERP_HDR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
+17
-17
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2004 Laszlo Molnar
|
Copyright (C) 1996-2020 Laszlo Molnar
|
||||||
Copyright (C) 2000-2004 John F. Reiser
|
Copyright (C) 2000-2020 John F. Reiser
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
@@ -22,43 +22,43 @@
|
|||||||
If not, write to the Free Software Foundation, Inc.,
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar John F. Reiser
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu jreiser@BitWagon.com
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
|
|
||||||
|
John F. Reiser
|
||||||
|
<jreiser@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_LX_INTERP_H //{
|
#ifndef __UPX_P_LX_INTERP_H //{
|
||||||
#define __UPX_P_LX_INTERP_H
|
#define __UPX_P_LX_INTERP_H 1
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// linux/interp386
|
// linux/interp386
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
class PackLinuxI386interp : public PackLinuxI386elf
|
class PackLinuxElf32x86interp : public PackLinuxElf32x86
|
||||||
{
|
{
|
||||||
typedef PackLinuxI386elf super;
|
typedef PackLinuxElf32x86 super;
|
||||||
public:
|
public:
|
||||||
PackLinuxI386interp(InputFile *f);
|
PackLinuxElf32x86interp(InputFile *f);
|
||||||
virtual ~PackLinuxI386interp();
|
virtual ~PackLinuxElf32x86interp();
|
||||||
virtual int getVersion() const { return 13; }
|
virtual int getVersion() const { return 13; }
|
||||||
virtual int getFormat() const { return UPX_F_LINUX_ELFI_i386; }
|
virtual int getFormat() const { return UPX_F_LINUX_ELFI_i386; }
|
||||||
virtual const char *getName() const { return "linux/elfi386"; }
|
virtual const char *getName() const { return "linux/elfi386"; }
|
||||||
|
virtual const char *getFullName(const options_t *) const { return "i386-linux.elf.interp"; }
|
||||||
|
|
||||||
virtual bool canPack();
|
virtual bool canPack();
|
||||||
virtual void unpack(OutputFile *fo);
|
virtual void unpack(OutputFile *fo);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
virtual void pack1(OutputFile *, Filter &); // generate executable header
|
||||||
virtual void pack2(OutputFile *, Filter &); // append compressed data
|
virtual int pack2(OutputFile *, Filter &); // append compressed data
|
||||||
virtual void pack3(OutputFile *, Filter &); // build loader
|
virtual off_t pack3(OutputFile *, Filter &); // build loader
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /*} already included */
|
#endif /*} already included */
|
||||||
|
|
||||||
|
/* vim:set ts=4 sw=4 et: */
|
||||||
/*
|
|
||||||
vi:ts=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