Compare commits

...

1330 Commits

Author SHA1 Message Date
Markus F.X.J. Oberhumer f37a7811f9 Merge. 2007-03-08 03:00:00 +01:00
László Molnár 9173c10239 yet another spelling fix 2007-03-07 17:00:18 +01:00
László Molnár 318b31550d spelling fixes 2007-03-07 14:22:37 +01:00
Markus F.X.J. Oberhumer c18ebc63a6 dos/exe: enable optimized code paths. 2007-03-06 18:14:32 +01:00
Markus F.X.J. Oberhumer d704694272 Merge. 2007-03-06 15:57:13 +01:00
Markus F.X.J. Oberhumer 1cfec3bdf7 dos/exe: enable one small optimization. 2007-03-06 15:56:51 +01:00
John Reiser fe6ea6bc10 merge 2007-03-06 06:44:26 -08:00
Markus F.X.J. Oberhumer d29c8df45e dos/exe improvements, not enabled yet. 2007-03-06 15:08:24 +01:00
John Reiser 71f996af95 spelling 2007-03-05 21:26:36 -08:00
Markus F.X.J. Oberhumer d9722ad6b3 dos/exe: make sure minsp is even. 2007-03-04 19:27:04 +01:00
Markus F.X.J. Oberhumer 398fd8028c Spelling fixes. 2007-03-04 17:39:21 +01:00
Markus F.X.J. Oberhumer 1345a3cfd3 Bump tentative release date. 2007-03-04 17:13:11 +01:00
Markus F.X.J. Oberhumer 7eb0b195b8 dos/exe: don't clear the dirty stack - DOS does not do this either 2007-03-04 17:10:32 +01:00
Markus F.X.J. Oberhumer 009caee82d docs: typo fixes. 2007-03-04 17:01:50 +01:00
Markus F.X.J. Oberhumer 3bdc805a22 dos/exe: only use bx_magic when needed. 2007-03-04 17:01:32 +01:00
Markus F.X.J. Oberhumer ac457792b4 Minor dos/exe stub optimizations. 2007-03-04 16:47:13 +01:00
Markus F.X.J. Oberhumer 1377b54b9e dos/exe: optimize M_PIA_small. 2007-03-04 15:20:09 +01:00
Markus F.X.J. Oberhumer 66418ffc8c Reorganize dos/exe. No stub changes. 2007-03-04 15:14:44 +01:00
László Molnár b4c4b1fb70 dos/exe: fixed a bug in relocation handling 2007-03-01 16:57:12 +01:00
Markus F.X.J. Oberhumer ffe4a4b047 dos/exe: clear the dirty stack. 2007-02-26 13:55:12 +01:00
László Molnár 753ce45310 dos/exe: better minsp approximation 2007-02-26 12:54:49 +01:00
Markus F.X.J. Oberhumer fece0d73e7 Update NEWS. Bump version date. 2007-02-26 01:37:03 +01:00
Markus F.X.J. Oberhumer edce076e68 Minor Makefile updates. 2007-02-26 01:33:08 +01:00
Markus F.X.J. Oberhumer 675d0a009a Use M_IS_LZMA. 2007-02-26 01:32:36 +01:00
Markus F.X.J. Oberhumer 5d41b5a4db Fix shld macro. 2007-02-26 00:52:18 +01:00
László Molnár fe53b135eb pe: better icon compression handling 2007-02-24 23:25:11 +01:00
László Molnár 5b1c154ee2 NEWS update 2007-02-23 13:46:52 +01:00
László Molnár 816d882611 dos/exe: nrv2b compressed lzma decompressor added 2007-02-23 13:34:12 +01:00
Markus F.X.J. Oberhumer 12bcb09051 Small Makefile updates. 2007-02-21 17:11:42 +01:00
László Molnár c59c69a85f p_exe.cpp: added some comments 2007-02-20 13:49:18 +01:00
Markus F.X.J. Oberhumer bdd0daaf6f Added ElfLinker::addLoaderVA(). 2007-02-20 07:36:34 +01:00
Markus F.X.J. Oberhumer cfad7c8356 Small cleanups. 2007-02-19 03:52:33 +01:00
John Reiser b2b8a128d0 merge 2007-02-18 10:10:17 -08:00
Markus F.X.J. Oberhumer 1cfad80ca2 Introduce a special "ignore_reloc_overflow" section. 2007-02-18 18:29:26 +01:00
John Reiser a5a80e41b8 merge 2007-02-18 09:09:17 -08:00
Markus F.X.J. Oberhumer 152f8e92bf Yet some more Watcom optimizations. 2007-02-18 05:43:31 +01:00
Markus F.X.J. Oberhumer 0323560b49 More Watcom optimizations. 2007-02-18 04:41:33 +01:00
Markus F.X.J. Oberhumer d3bc84a2f7 Some Watcom optimizations. 2007-02-18 03:55:46 +01:00
Markus F.X.J. Oberhumer 8a82c259bd Switching back to using Watcom C - this seems to work. 2007-02-18 03:02:00 +01:00
Markus F.X.J. Oberhumer 46009c7658 i086 Makefile.extra update. 2007-02-18 02:32:47 +01:00
Markus F.X.J. Oberhumer 6f760308bd Some cleanasm.py updates. 2007-02-18 01:32:30 +01:00
John Reiser c346f8f17d merge 2007-02-16 08:06:37 -08:00
John Reiser af1d059fff PackUnix::getLoader() result is not 'const' 2007-02-16 08:05:10 -08:00
John Reiser 5562b21a20 PackMach* checkAlreadyPacked() 2007-02-16 08:02:59 -08:00
Markus F.X.J. Oberhumer 8f68f31877 Use Wine + Digital Mars C/C++ in small model. Does not work yet. 2007-02-16 15:22:01 +01:00
Markus F.X.J. Oberhumer ce7e94030c Added i086/l_test.c. Cleanups. 2007-02-16 08:52:31 +01:00
Markus F.X.J. Oberhumer ccf5a1b972 Add some more funcs to cc_test.c. 2007-02-13 09:48:37 +01:00
Markus F.X.J. Oberhumer 0d5ae77efc Some more dos/exe updates. 2007-02-13 02:25:32 +01:00
Markus F.X.J. Oberhumer 1695096d18 Commit rebuilt files as well. 2007-02-13 00:39:43 +01:00
Markus F.X.J. Oberhumer 6db0b7cf18 lzma for dos/exe works! 2007-02-13 00:39:15 +01:00
John Reiser 575b43b0d4 NEWS: Mach/i386 and Mach/fat 2007-02-12 15:22:22 -08:00
László Molnár 7b39b05894 lzma for dos/exe seems to work with tainted watcom macros 2007-02-12 18:28:24 +01:00
László Molnár 8bea9e0a5e fixed some watcom support macros 2007-02-12 15:38:47 +01:00
László Molnár 2255b32e45 LZMA for dos/exe integration work. Does not work yet. 2007-02-12 15:12:36 +01:00
Markus F.X.J. Oberhumer b62573ae8f More work on lzma for dos/exe. 2007-02-11 21:20:00 +01:00
Markus F.X.J. Oberhumer 44ed84f5cf Added lzma for dos/exe. Glue code and integration is still missing. 2007-02-11 07:54:16 +01:00
Markus F.X.J. Oberhumer d008c834be Merge. 2007-02-11 04:52:53 +01:00
Markus F.X.J. Oberhumer 2d3a914aee Some i086 updates. 2007-02-11 04:52:33 +01:00
John Reiser 7324f4c3d1 PackMach* filters only the [1st] largest executable LC_SEGMNET 2007-02-10 17:47:04 -08:00
Markus F.X.J. Oberhumer 50c8860a50 Added first version of a clean-room wcc support library implementation. 2007-02-11 01:06:37 +01:00
Markus F.X.J. Oberhumer 6456de7188 i086: added cc_test for examining internal compiler library calls. 2007-02-11 01:02:36 +01:00
John Reiser 23c629f2aa i386-darwin.macho works! 2007-02-10 13:14:27 -08:00
John Reiser 2bf154f74f i386-darwin.macho: decompressor overrun, bswap Mach_fat_header 2007-02-10 10:57:02 -08:00
John Reiser b598ad1bc0 i386-darwin.macho runtime stub 2007-02-10 09:16:49 -08:00
Markus F.X.J. Oberhumer ace24ad68e Minor portability fixes. 2007-02-08 16:17:32 +01:00
Markus F.X.J. Oberhumer 750c1a0f27 Avoid compiler warnings. 2007-02-08 15:00:42 +01:00
John Reiser 52d89bd66b PackMachFat has trouble with --fileinfo 2007-02-07 22:24:42 -08:00
John Reiser 8cfb9d35e9 fix ui report after PackMachFat::unpack 2007-02-07 22:03:15 -08:00
John Reiser 2f529158a0 OutputFile::unset_extent() sets bytes_written 2007-02-07 22:02:28 -08:00
John Reiser 6e68ab6d9e canUnpack() and unpack() for PackMachBase, PackMachFat 2007-02-07 21:30:18 -08:00
John Reiser 7a3c55af35 fix SEEK_END when set_extent() 2007-02-07 21:21:19 -08:00
John Reiser fb39d6304a Enable --lzma for PackMach*. 2007-02-07 11:23:21 -08:00
John Reiser 4cb57d9059 OutputFile::unset_extent(); endianness in Mach_fat_* and PackMachBase::b_info 2007-02-06 13:11:31 -08:00
John Reiser 42d69bd0e5 debug PackMachFat 2007-02-05 22:34:23 -08:00
John Reiser f27b399f81 PackMachFat 2007-02-05 14:00:41 -08:00
John Reiser a545a3938f FileBase::set_extent(offset, length) constrains seek() and tell() 2007-02-03 13:31:44 -08:00
John Reiser d1e352c9ee PackMachI386 2007-02-03 11:40:25 -08:00
John Reiser 99be1e798b PackMachPPC32 2007-02-03 11:04:57 -08:00
John Reiser 2132a28a17 UPX_F_MACH_i386 and skeleton stub. (Much of PackMachI386 is incomplete.) 2007-02-02 13:51:51 -08:00
John Reiser 8b1cc28783 templates to prepare for Mach-O i386 and Universal ("fat") executables 2007-01-31 20:25:13 -08:00
Markus F.X.J. Oberhumer 78364ac830 Small Watcom updates. 2007-01-31 14:28:15 +01:00
Markus F.X.J. Oberhumer 6e5f5732b5 brandelf.py: do not write "Linux" any longer as newer ldd's (e.g.
from glibc-common-2.5-10.fc6) do not like this.
2007-01-31 05:58:17 +01:00
Markus F.X.J. Oberhumer 87844254d1 Minor Makefile updates. 2007-01-31 05:53:38 +01:00
Markus F.X.J. Oberhumer 08ef9f69fb Very minor portability fixes. 2007-01-30 20:36:59 +01:00
Markus F.X.J. Oberhumer 5fbd1b78e7 Added non-working experimental infrastructure for using OpenWatcom 1.6
to support i086 + lzma.
2007-01-30 20:25:20 +01:00
Markus F.X.J. Oberhumer 39f5eb753f Bump version for next release. 2007-01-23 22:17:02 +01:00
Markus F.X.J. Oberhumer f4cbe3f300 Added tag for RELEASE_292. 2007-01-23 22:13:01 +01:00
Markus F.X.J. Oberhumer 70632e5541 Bump release date. 2007-01-23 22:11:23 +01:00
John Reiser 0bba700105 merge 2007-01-23 10:35:20 -08:00
John Reiser b71aaccff3 fix amd64-linux.elf-entry.S invoking large programs (>3MB compressed) 2007-01-23 10:34:33 -08:00
Markus F.X.J. Oberhumer 7271ae9611 Small updates. 2007-01-23 13:50:39 +01:00
László Molnár 6e32dff2ad armpe_tester.c updated to work with files containing 4 sections 2007-01-17 21:53:18 +01:00
László Molnár 8f7c898c08 use an exception instead of assert() for overlay checking (bug #1624840) 2007-01-16 12:58:35 +01:00
Markus F.X.J. Oberhumer f4a9815f48 Keep entries sorted in stub/Makefile. 2007-01-15 07:46:22 +01:00
John Reiser 0f8d5c7e98 arm-linux.kernel.vmlinux.S remove unused sections 2007-01-14 13:40:50 -08:00
Markus F.X.J. Oberhumer 5e83596a1b Enter 2007. 2007-01-14 13:08:58 +01:00
Markus F.X.J. Oberhumer 6361213e07 More portability fixes. 2007-01-14 12:47:38 +01:00
John Reiser 9c59a5d9b6 p_vmlinx test jig for ARM 2007-01-13 17:30:03 -08:00
John Reiser bb04844bd5 Decompressor for UPX_F_VMLINUX_ARM follows ELF convention 2007-01-13 15:26:05 -08:00
Markus F.X.J. Oberhumer 0b988176fa Portability fixes. 2007-01-10 17:16:59 +01:00
Markus F.X.J. Oberhumer a354f18a2d Consistently use .arch nojumps on i086 and i386. 2007-01-09 22:40:01 +01:00
Markus F.X.J. Oberhumer a7ca0fec88 Merge. 2007-01-09 18:31:13 +01:00
Markus F.X.J. Oberhumer 06eec508df Cosmetic macros.S cleanups. 2007-01-09 18:27:53 +01:00
John Reiser 10dc580a3a tweak i386-linux.kernel.vmlinux-head.S 2007-01-08 13:56:47 -08:00
John Reiser 2f6ae3ef01 merge 2007-01-07 16:33:04 -08:00
John Reiser 392e803905 vmlinux/AMD64 works 2007-01-07 16:31:46 -08:00
John Reiser 83a5fb585b ELF External_Note 2007-01-03 06:54:48 -08:00
László Molnár c6205ffbe0 tls index should be zero after decompression 2007-01-02 18:16:16 +01:00
Markus F.X.J. Oberhumer c04737ce20 Cosmetic cleanup. 2006-12-31 15:51:17 +01:00
John Reiser 11b92172fe PackVmlinuxBase my_boot_label; kernel Makefiles 2006-12-25 13:55:28 -08:00
László Molnár 3a6c574376 pe: correctly handle import table with 0 entries during decompression (#1620733) 2006-12-24 16:25:36 +01:00
Markus F.X.J. Oberhumer b21ce925fb Factor out a common Packer::defineFilterSymbols(). Enable filters
0x49 and 0x49 for all i386-dos32.* formats. Needs testing.
2006-12-22 16:39:42 +01:00
Markus F.X.J. Oberhumer de9dcc4ed6 Enable filters 0x49 and 0x46 for win32/pe. This needs some more testing. 2006-12-22 15:28:14 +01:00
Markus F.X.J. Oberhumer 9e77dbfe20 Added an assertion to make sure I've really understood the semantics
of the ctok32 filter length.
2006-12-22 15:19:51 +01:00
Markus F.X.J. Oberhumer 4cee0676a4 Consistently rename section names of ctok32 filter. 2006-12-22 14:22:45 +01:00
Markus F.X.J. Oberhumer 8ad9d21db3 Also add ICHECK() calls to p_armpe.cpp. 2006-12-22 13:37:19 +01:00
Markus F.X.J. Oberhumer 8ba8317eea sf.net bug #1620733: As a very first step, added two calls to
ICHECK(dname,1). Of course we still need a proper fix for this.
2006-12-22 13:35:39 +01:00
Markus F.X.J. Oberhumer d221187f24 Misc cosmetical cleanups. 2006-12-22 12:36:55 +01:00
Markus F.X.J. Oberhumer db54ec294f Added some missing stub/tmp/*.bin.dump files. 2006-12-20 10:50:49 +01:00
John Reiser 1d39796e3f PackVmlinuxBase::canPack bug for AMD64 with holes between PT_LOAD 2006-12-19 18:18:47 -08:00
John Reiser cd6a318903 cleanup merge 2006-12-19 16:19:19 -08:00
John Reiser 73090b98ab merge 2006-12-19 16:16:20 -08:00
John Reiser 745de1abab refactor PackVmlinuxBase::pack() 2006-12-19 16:12:59 -08:00
John Reiser 961031efc1 make_st_info() 2006-12-19 16:12:15 -08:00
Markus F.X.J. Oberhumer 2487595778 vmlinux: U32 already has target-endian representation, so there is no need
to call BeLePolicy::get32() here.
2006-12-19 22:39:37 +01:00
John Reiser 5c4863d504 refactor PackVmlinuxBase ::canUnpack(), ::unpack() 2006-12-19 10:58:20 -08:00
Markus F.X.J. Oberhumer 5e3a658932 Made a method pure virtual. 2006-12-19 16:21:57 +01:00
Markus F.X.J. Oberhumer cb4704c821 Cosmetic cleanups. 2006-12-19 15:22:50 +01:00
Markus F.X.J. Oberhumer cc0b7d1492 Use the preprocessor to make sure that the ELF types are PODs. 2006-12-19 14:43:14 +01:00
Markus F.X.J. Oberhumer f8ebbf8b08 Rework p_elf.h. 2006-12-19 14:24:35 +01:00
Markus F.X.J. Oberhumer 8795f60bf1 vmlinux: use template types throughout. 2006-12-19 11:06:58 +01:00
Markus F.X.J. Oberhumer f00c0a9436 Fix typo. 2006-12-19 11:04:47 +01:00
Markus F.X.J. Oberhumer 767bc71870 Expose integral types in p_elf.h. 2006-12-19 10:49:13 +01:00
John Reiser 4c068e3e00 PackVmlinuxBase::canPack(); templates are fun! 2006-12-18 22:55:38 -08:00
John Reiser 277d862172 PackVmlinuxBase try template definitions in .cpp file 2006-12-18 20:17:10 -08:00
John Reiser dbed6a47bb PackVmlinuxBase use simple templates 2006-12-18 20:08:24 -08:00
Markus F.X.J. Oberhumer 94f3749784 vmlinux refactoring: move destructor into PackVmlinuxBase. 2006-12-19 00:48:38 +01:00
Markus F.X.J. Oberhumer 728e6d851e Introduce ElfClass and PackVmlinuxBase for refactoring elf based packers. 2006-12-19 00:37:35 +01:00
Markus F.X.J. Oberhumer 11e863545f Strip trailing whitespace. 2006-12-18 16:56:14 +01:00
Markus F.X.J. Oberhumer dde49f0bb4 Try to avoid fatal filter failures by better scanning during the setup phase. 2006-12-18 16:54:14 +01:00
Markus F.X.J. Oberhumer a37a75aecc First step for preprocessing dumps with xstrip.py. Not working yet. 2006-12-18 16:39:57 +01:00
John Reiser e43e3aeb1c arm-linux.kernel documentation update for Debian on nslu2 2006-12-17 18:49:38 -08:00
John Reiser a8fe529814 arm-linux.kernel preserve .e_flags 2006-12-17 17:39:47 -08:00
John Reiser d9f5e2bb08 arm-linux.kernel alignment fix 2006-12-17 16:34:21 -08:00
John Reiser dfa83b0ac8 arm-linux.kernel methods 2006-12-17 15:34:13 -08:00
John Reiser bd5cef1411 unfilter for arm-linux.kernel 2006-12-17 14:53:10 -08:00
John Reiser cd70b48831 src/stub/src/arch/arm/v5a directory 2006-12-17 13:24:14 -08:00
John Reiser 50ebf8088a R_ARM_ABS8 2006-12-17 13:19:37 -08:00
John Reiser c5cfb7eb40 more arm-linux.kernel work 2006-12-16 22:02:51 -08:00
John Reiser bccaafda6d arm-linux stub interfacing for lzma 2006-12-16 17:16:32 -08:00
John Reiser bf0086d7b5 arm-linux.kernel decompressor 2006-12-16 14:52:22 -08:00
John Reiser 7e65938ca6 fix filename in initial comment 2006-12-16 08:40:41 -08:00
John Reiser 112eff2509 add UPX_F_VMLINUX_AMD64, UPX_F_VMLINUX_ARM 2006-12-16 08:13:34 -08:00
Markus F.X.J. Oberhumer d7837d9179 Use FT_ULTRA_BRUTE. 2006-12-12 10:06:24 +01:00
Markus F.X.J. Oberhumer 6cdd057f80 Coding style cleanups. 2006-12-12 10:05:57 +01:00
Markus F.X.J. Oberhumer 5a03b213fb More stricter check in xstrip.py. 2006-12-12 07:50:05 +01:00
Markus F.X.J. Oberhumer f270213246 Make sure ph.first_offset_found is set. 2006-12-12 07:49:50 +01:00
László Molnár 2e1795c5ba win32/pe: loadconf data should not be put into section 2 2006-12-10 23:42:27 +01:00
Markus F.X.J. Oberhumer 732d6710d3 Remove misleading "const" from Linker::preprocessXX(). 2006-12-10 00:38:28 +01:00
Markus F.X.J. Oberhumer edf384d2ee Micro-optimization: save 1 byte in tmt/adam stub. 2006-12-09 13:56:47 +01:00
László Molnár c307640826 use memcmp instead of strncmp when searching for ljmp 2006-12-08 19:20:35 +01:00
Markus F.X.J. Oberhumer a77b598f82 Implement a micro-optimization which has been on our TODO list for ages:
remove "or ebp,-1" when not needed
2006-12-08 09:20:14 +01:00
Markus F.X.J. Oberhumer 217420cfa5 Also verifyOverlappingDecompression() for watcom/le. 2006-12-06 12:20:22 +01:00
Markus F.X.J. Oberhumer f2b9dff596 More work so that watom/le now uses compressWithFilters(). 2006-12-06 11:08:32 +01:00
Markus F.X.J. Oberhumer ae945ed315 Clean up help and avoid using backticks as quoting chars. 2006-12-06 08:11:55 +01:00
Markus F.X.J. Oberhumer 770c153c76 Start using FT_ULTRA_BRUTE. 2006-12-06 07:42:43 +01:00
Markus F.X.J. Oberhumer 29c4a7e606 Remove debugging leftover. 2006-12-06 07:34:57 +01:00
Markus F.X.J. Oberhumer 8875470b37 Refactored compressWithFilters(). 2006-12-06 07:27:23 +01:00
Markus F.X.J. Oberhumer 6e52364bcb Minor cleanup of callback code. 2006-12-05 17:09:18 +01:00
Markus F.X.J. Oberhumer 7015d616b4 Whitespace changes. 2006-12-05 17:06:37 +01:00
László Molnár 92e6da3260 use the current version of http://www.gnu.org/licenses/gpl.txt 2006-12-05 12:16:42 +01:00
László Molnár 9220b6f1d5 win32/pe should only handle ix86 files 2006-12-03 10:46:14 +01:00
Markus F.X.J. Oberhumer 1d0d538d0c Added new option '--ultra-brute'. 2006-12-01 02:47:46 +01:00
Markus F.X.J. Oberhumer 83052eafae Minor cleanups. 2006-12-01 00:57:03 +01:00
Markus F.X.J. Oberhumer fa95c3c4a2 Display full format name with --fileinfo. 2006-11-30 23:34:19 +01:00
Markus F.X.J. Oberhumer 665dcf221b Cosmetic cleanup. 2006-11-30 23:21:47 +01:00
Markus F.X.J. Oberhumer 8f73dbd253 Mention --compress-icons=3. 2006-11-30 23:18:21 +01:00
Markus F.X.J. Oberhumer 826312cbad Show all supported formats in show_help(). 2006-11-30 23:17:22 +01:00
Markus F.X.J. Oberhumer 72a18f2b3f Added Packer::getFullName() method. 2006-11-29 06:44:48 +01:00
Markus F.X.J. Oberhumer a6b5e3d0ae Bump version for next release. 2006-11-29 05:41:39 +01:00
Markus F.X.J. Oberhumer 1b321f4fa3 Added tag for RELEASE_291. 2006-11-29 05:14:25 +01:00
Markus F.X.J. Oberhumer fbde0b9f35 Bump release date. 2006-11-29 03:43:29 +01:00
Markus F.X.J. Oberhumer 0e5f5e54cc Initalize isrtm member. 2006-11-27 17:35:16 +01:00
Markus F.X.J. Oberhumer cbb5902066 Improve xstrip.py. 2006-11-25 15:36:56 +01:00
Markus F.X.J. Oberhumer 92ec1b0598 Add and use stub/scripts/xstrip.py. 2006-11-23 05:27:40 +01:00
Markus F.X.J. Oberhumer a62fc3abff Try to remove .shstrtab, .strtab and .symtab sections. This does not seem to
work with objcopy.
2006-11-23 03:31:43 +01:00
Markus F.X.J. Oberhumer 08f8e55446 More updates on bin2h.py. 2006-11-23 03:11:53 +01:00
Markus F.X.J. Oberhumer 68f54a3247 Updated bin2h.py. 2006-11-23 02:23:39 +01:00
Markus F.X.J. Oberhumer 29c099fe56 Disallow --exact with --overlay=strip. 2006-11-22 19:29:07 +01:00
Markus F.X.J. Oberhumer 76b81c7b35 More stricter check for arm-wince Debian. 2006-11-22 18:52:57 +01:00
László Molnár d6b33ffd6b pe: --compress-icons=3 option added to compress all icons 2006-11-22 15:28:35 +01:00
Markus F.X.J. Oberhumer 16b9873fa8 Quick workaround for arm-wince build with Debian cross-compiler packages. 2006-11-22 01:56:59 +01:00
Markus F.X.J. Oberhumer ba4a686d1c Fix endian issue in execve formats. 2006-11-21 18:42:38 +01:00
László Molnár 4be3d79e12 arm/pe: fix "missing" icon & version info resource problem for wince 5 2006-11-21 18:25:23 +01:00
Markus F.X.J. Oberhumer 2569b09dbe Added debugging option --disable-random-id. 2006-11-21 18:17:51 +01:00
Markus F.X.J. Oberhumer 5d71e69941 Added two checks for throwCantPackExact. 2006-11-21 18:01:16 +01:00
Markus F.X.J. Oberhumer 16163bf20b Initial support for option '--exact'. 2006-11-21 17:53:11 +01:00
Markus F.X.J. Oberhumer f1a97fecbd Minor cleanups. 2006-11-21 17:35:22 +01:00
Markus F.X.J. Oberhumer a050f82f0e Implemented the remaining missing pieces of compress_zlib. 2006-11-21 17:19:24 +01:00
Markus F.X.J. Oberhumer ef7beea334 Cosmetic cleanups. 2006-11-21 16:17:47 +01:00
Markus F.X.J. Oberhumer 3f4acb33f9 First step for possibly using ElfLinker with linux execve/interp/shell stubs
as well.
2006-11-21 16:00:25 +01:00
Markus F.X.J. Oberhumer 14822e6395 Now that it seems to work, disable usage of pre-compressed stubs again. 2006-11-21 07:14:07 +01:00
Markus F.X.J. Oberhumer e82db4ed38 Use proper const_cast. 2006-11-21 06:32:13 +01:00
Markus F.X.J. Oberhumer 87b7ea9cf3 Add LZMA support for pre-compressed stubs. 2006-11-21 06:09:04 +01:00
Markus F.X.J. Oberhumer 787b1fceff Actually generate and use pre-compressed stubs. Currently this is mainly
for testing as the self-packed upx binary does get _larger_ this way.
2006-11-21 05:29:29 +01:00
Markus F.X.J. Oberhumer 140d6ad839 Avoid compiler warning. 2006-11-21 05:09:01 +01:00
Markus F.X.J. Oberhumer 46e8e22236 Prepare generating pre-compressed stubs. 2006-11-21 05:03:25 +01:00
Markus F.X.J. Oberhumer c386db2b33 Small cosmetic changes. 2006-11-21 05:01:54 +01:00
Markus F.X.J. Oberhumer 8dad091c6b Decompress pre-compressed stubs in Linker::init(). 2006-11-21 05:01:00 +01:00
Markus F.X.J. Oberhumer 3365ccbb9c Implemented upx_zlib_decompress(). 2006-11-21 04:42:47 +01:00
Markus F.X.J. Oberhumer 2ced230965 Updated packers to use new stub names. 2006-11-21 03:40:11 +01:00
Markus F.X.J. Oberhumer 989d10a3e1 Rebuilt all stubs with new bin2h.py and --ident=auto-stub. 2006-11-21 03:36:48 +01:00
Markus F.X.J. Oberhumer 62d8c69774 Enhanced bin2h.py: added --ident=auto, added --compress=XXX. 2006-11-21 03:34:08 +01:00
Markus F.X.J. Oberhumer cf704257b0 Remove some traces of patch_le32. 2006-11-20 18:19:37 +01:00
Markus F.X.J. Oberhumer a6cb6f57d3 Introduce Packer::relocateLoader(). This is the first step of finally getting
rid of all Packer::patchXXX() methods.
2006-11-20 18:10:23 +01:00
Markus F.X.J. Oberhumer 141c703ed5 Use ld option --no-warn-mismatch when generating binary output. 2006-11-20 17:36:04 +01:00
John Reiser 796d58867b use separate stub/armeb-linux.elf-entry and fold 2006-11-20 08:02:28 -08:00
Markus F.X.J. Oberhumer 2f483ec8e8 Fix compression ratio check. 2006-11-20 13:48:34 +01:00
Markus F.X.J. Oberhumer e338918773 Disable new/delete for bele policies. 2006-11-20 12:57:49 +01:00
Markus F.X.J. Oberhumer d9effc58cf Added initial version of armeb-linux.elf stubs. Completely untested. 2006-11-20 12:40:57 +01:00
Markus F.X.J. Oberhumer 05d03f97fc Introduce Packer::bele. 2006-11-20 12:01:59 +01:00
Markus F.X.J. Oberhumer 03e891c0e8 Remove implicit magic from OptVar copy operator and introduce oassign()
function instead.
2006-11-20 11:04:31 +01:00
Markus F.X.J. Oberhumer 4dfe9d52e9 Don't be too strict when checking the compression ratio (sf.net
feature request #1596111).
2006-11-20 09:40:46 +01:00
John Reiser 9e65692b69 Merge 2006-11-19 14:32:28 -08:00
John Reiser 0687c9a57a PackLinuxElf32::ARM_buildLoader endianness bugs 2006-11-19 14:28:15 -08:00
Markus F.X.J. Oberhumer ffe1287016 Added option '--cpr-lzma-ds=XX'. 2006-11-19 18:50:35 +01:00
Markus F.X.J. Oberhumer 75b7e7260f Merge. 2006-11-19 05:16:12 +01:00
Markus F.X.J. Oberhumer d631e081bc arm-linux.elf: make two symbols global. 2006-11-19 05:09:01 +01:00
John Reiser db5843d904 branch merge 2006-11-18 19:57:56 -08:00
John Reiser 5ec16153f7 PackLinuxElf64amd::defineSymbols forgot a get_native64() 2006-11-18 19:52:55 -08:00
Markus F.X.J. Oberhumer 8c873ccdc8 watcom/le: initialize memory when aligning. 2006-11-18 21:59:59 +01:00
Markus F.X.J. Oberhumer c95088f8d5 Merge. 2006-11-18 20:55:07 +01:00
Markus F.X.J. Oberhumer 519fa55df7 ps1/exe: fill pad.code section with zeros. 2006-11-18 20:54:10 +01:00
John Reiser b8dda033ed branch merge 2006-11-18 11:51:23 -08:00
John Reiser 0359e9c5c7 members of struct l_info loader header must be little endian 2006-11-18 11:42:08 -08:00
Markus F.X.J. Oberhumer d822b4a62a Store shentsize in target byte-order. 2006-11-18 18:25:11 +01:00
Markus F.X.J. Oberhumer d9e8c953b1 Fixed some ElfLinker endian issues. 2006-11-18 17:43:29 +01:00
Markus F.X.J. Oberhumer 9eca502026 Make upx build with gcc-2.95 again. 2006-11-18 14:37:22 +01:00
Markus F.X.J. Oberhumer cd0efe3edb Some atari/tos cleanups. 2006-11-18 02:39:11 +01:00
Markus F.X.J. Oberhumer 8146e9cbcd Implemented some small atari/tos optimizations. 2006-11-17 18:47:33 +01:00
Markus F.X.J. Oberhumer 5d95275024 Add some more calls to f-objstrip. 2006-11-17 14:50:59 +01:00
Markus F.X.J. Oberhumer 49a97eea4b More brandelf.py updates. 2006-11-17 14:50:42 +01:00
Markus F.X.J. Oberhumer 36e9c27e9c Updated brandelf.py. 2006-11-16 22:23:01 +01:00
Markus F.X.J. Oberhumer 6e5153cd07 Minor Makefile updates. 2006-11-16 21:14:58 +01:00
Markus F.X.J. Oberhumer c73da864c8 Avoid -Wshadow warnings. 2006-11-16 20:14:14 +01:00
Markus F.X.J. Oberhumer 071bb75700 Use new addLoader() method. 2006-11-16 20:12:53 +01:00
Markus F.X.J. Oberhumer 99374de340 Clean up stub sources. 2006-11-16 19:36:13 +01:00
Markus F.X.J. Oberhumer db7ae4ed5d Improve Packer:addLoader(). We're still somewhat limited because of gcc-bug
#29823 (see http://gcc.gnu.org/PR29823).
2006-11-16 18:52:20 +01:00
Markus F.X.J. Oberhumer e61f481881 Added .DELETE_ON_ERROR rules. 2006-11-16 18:49:34 +01:00
Markus F.X.J. Oberhumer 396a3ad2fc Small atari cleanups. 2006-11-13 10:51:45 +01:00
Markus F.X.J. Oberhumer be235ddc38 Removed unused Packer::freezeLoader(). Changed return type of
buildLoader() from "int" to "void".
2006-11-12 20:57:08 +01:00
Markus F.X.J. Oberhumer 9e72ecd93d Fix version date. 2006-11-12 18:49:48 +01:00
Markus F.X.J. Oberhumer 8e0bd936eb atari/tos now seems to work again. 2006-11-12 18:25:46 +01:00
Markus F.X.J. Oberhumer 9d0270dcd6 We have to bswap32 lzma_properties on big-endian machines. 2006-11-12 18:10:42 +01:00
Markus F.X.J. Oberhumer 713415c354 Fix broken "glibc sscanf bug workaround". 2006-11-12 14:47:50 +01:00
Markus F.X.J. Oberhumer 786550572e More work on atari/tos. 2006-11-12 13:46:38 +01:00
Markus F.X.J. Oberhumer 46caeddc81 Added some more debugging support to Linker. 2006-11-12 13:45:27 +01:00
Markus F.X.J. Oberhumer 71bfde2bfe Bump tentative release date. 2006-11-12 10:59:27 +01:00
Markus F.X.J. Oberhumer 76771b845a Started work on atari/tos. 2006-11-12 10:58:04 +01:00
Markus F.X.J. Oberhumer a74e239e28 Major cleanup of ElfLinker. 2006-11-12 10:57:18 +01:00
Markus F.X.J. Oberhumer 6e763b0b42 Updated options. 2006-11-12 10:56:17 +01:00
Markus F.X.J. Oberhumer 2f41ece017 Minor cleanups. 2006-11-10 13:49:22 +01:00
Markus F.X.J. Oberhumer 01cd5fe0d5 Added tag BRANCHPOINT_FOR_upx2.hg . 2006-11-08 21:09:50 +01:00
Markus F.X.J. Oberhumer ed12ff7bb3 Updated NEWS from 2.03 release. 2006-11-07 19:56:15 +01:00
Markus F.X.J. Oberhumer f1386bb60d Update NEWS. 2006-11-07 14:07:43 +01:00
Markus F.X.J. Oberhumer 417bd06e76 Fixed --brute and --lzma for dos/exe. 2006-11-07 13:58:32 +01:00
Markus F.X.J. Oberhumer 91e46e3cf8 Small cleanups. 2006-11-07 13:43:43 +01:00
Markus F.X.J. Oberhumer deb5139c4d Re-enable --crp-ms= option. 2006-11-07 13:37:46 +01:00
Markus F.X.J. Oberhumer 862ac5d014 Update options_t::crp_t to directly use the XXX_compress_config_t types. 2006-11-07 13:11:36 +01:00
Markus F.X.J. Oberhumer 028235d421 Keep variable names sorted. 2006-11-07 10:24:54 +01:00
Markus F.X.J. Oberhumer 143d399849 Updated two "xchg" commands to produce byte-identical results with UPX 2.02. 2006-11-07 09:35:00 +01:00
László Molnár 375f171e47 dos/com&sys: correctly set carry bit by using "sub si,-xx" instead of "add si,xx" 2006-11-06 17:54:37 +01:00
László Molnár 387edcf4b2 dos/com: fix fatal bug #1589758 2006-11-03 15:52:20 +01:00
Markus F.X.J. Oberhumer 011cd37cfb Small cleanup of arm sources. 2006-10-30 14:10:51 +01:00
Markus F.X.J. Oberhumer 0d4254f319 Added tc_objdump_disasm_options. 2006-10-30 13:21:48 +01:00
Markus F.X.J. Oberhumer 4c407c2850 Rebuild all stubs. Minor Makefile cleanup. 2006-10-25 04:08:59 +02:00
John Reiser 829e2d6c5d set e_shentsize to work around bug in binutils [mostly cosmetic] 2006-10-24 09:43:50 -07:00
John Reiser a31c4bd474 more renaming for i386-linux.kernel.vmlinux-head.h 2006-10-24 09:29:01 -07:00
John Reiser 17f24dc377 PackBvmlinuzI386 allow x86_64 2006-10-18 08:35:25 -07:00
John Reiser de3e9f2809 vmlinuz/386 fix for physical_start not at bzimage_offset 2006-10-16 17:18:19 -07:00
John Reiser 4442a282e1 fix filename in #includ 2006-10-16 10:52:57 -07:00
John Reiser 261010f23d fix comment 2006-10-16 06:12:58 -07:00
John Reiser ede44ca6ee vmlinux/386 naming convention for source files 2006-10-16 06:11:49 -07:00
John Reiser 452a953234 vmlinux/386 check for __ksymtab; fix unpack 2006-10-15 14:51:02 -07:00
John Reiser 2b122562ad new file i386-linux.kernel.head-vmlinux.S 2006-10-14 14:55:10 -07:00
John Reiser 6891bc3da3 vmlinux/i386: fix filters, 0x400000 start, integration with kernel build 2006-10-14 14:52:30 -07:00
Markus F.X.J. Oberhumer b31b8cd7f0 Added option '--crp-lzma-fb='. Started tuning lzma compression
levels '-1' and '-2'.
2006-10-12 14:23:22 +02:00
Markus F.X.J. Oberhumer e1379ac5ce Removed debugging leftover. 2006-10-12 13:48:07 +02:00
Markus F.X.J. Oberhumer 0ef3f75d7a Introduced class OptVar for tracking optionally set options. Also
added three new options for finetuning lzma compression.
2006-10-12 13:47:15 +02:00
Markus F.X.J. Oberhumer 407a9e5be0 Clean up NEWS. 2006-10-11 13:47:12 +02:00
Markus F.X.J. Oberhumer 892bb9bf30 Re-add "beta" string to versions. 2006-10-11 13:06:17 +02:00
Markus F.X.J. Oberhumer 47ac871a12 Added version_string() functions for the compression algorithms. Also
reserved M_DEFLATE and added a mostly empty compress_zlib.cpp.
2006-10-11 12:56:28 +02:00
László Molnár a38c3e7f6d ps1: initialize an uninitialized variable 2006-10-10 15:44:02 +02:00
Markus F.X.J. Oberhumer 08818355d1 Updated README.SRC. 2006-10-10 11:23:32 +02:00
Markus F.X.J. Oberhumer 0a68afef00 Bump version for next release. 2006-10-08 22:38:57 +02:00
Markus F.X.J. Oberhumer 2c0783e327 Added tag for RELEASE_290. 2006-10-08 22:35:47 +02:00
Markus F.X.J. Oberhumer c2e5e45c84 Fix UINT64_MAX. 2006-10-06 08:42:12 +02:00
John Reiser 014236c861 amd64 stub: fix length of move for non-small programs 2006-10-04 08:38:06 -07:00
Markus F.X.J. Oberhumer 610fd7561b Bump tentative release date. Update NEWS. 2006-10-04 09:26:34 +02:00
Markus F.X.J. Oberhumer d6f4480a4f Removed debugging leftover. 2006-10-04 09:17:59 +02:00
Markus F.X.J. Oberhumer 28a6ac09ad Initialize a field in constructor. 2006-10-04 09:14:13 +02:00
John Reiser 86e4d24476 avoid circularity of sz_pack2 in PackLinuxElf64amd::defineSymbols() 2006-10-03 20:21:36 -07:00
John Reiser 913a697ab2 Remove dead code and uses of sz_pack2 from PackLinuxElf32::ARM_defineSymbols() 2006-10-03 19:28:08 -07:00
Markus F.X.J. Oberhumer ebef2b1e44 Avoid a printf warning. 2006-10-04 00:16:55 +02:00
Markus F.X.J. Oberhumer a61457b422 Added some debugging support via Linker::dumpSymbols(). 2006-10-03 23:48:19 +02:00
László Molnár 8f7f1135df win32/pe: size of tls_value should be 32 bits 2006-10-03 17:01:47 +02:00
John Reiser 89612c10c9 NEWS and document /proc/self/exe 2006-10-03 07:20:59 -07:00
John Reiser d55bfb32f1 merge 2006-10-03 07:01:55 -07:00
John Reiser d2b72cf496 sync 2006-10-03 06:59:10 -07:00
László Molnár 8d90fffd46 NEWS updates for 2.90 2006-10-03 15:56:39 +02:00
John Reiser b84af27a86 typo "pop %eax" [not caught by assembler?] 2006-10-01 16:19:17 -07:00
John Reiser b45f28f3e9 propagate changes from *.S to *.h 2006-10-01 14:42:39 -07:00
John Reiser bfa1b5656a preserve readlink("/proc/self/exe",,) in environment " =" 2006-10-01 14:41:09 -07:00
John Reiser 47f946cd65 fix the comments 2006-10-01 14:25:14 -07:00
John Reiser 970e7bfcda CPU_TYPE_I386 2006-10-01 14:24:20 -07:00
John Reiser a81c7a7cd6 PackBSDI386 clarify osabi issues. 2006-09-27 14:38:42 -07:00
John Reiser b0e1bd239f Pack shell scripts for Linux only (and not *BSD, for example [no stub!]) 2006-09-26 16:21:28 -07:00
John Reiser 53ca41717a Document /proc/self/exe and workaround. 2006-09-25 13:02:07 -07:00
Markus F.X.J. Oberhumer 6a5bee0cdd Updated test-stub-compression. 2006-09-09 13:03:04 +02:00
Markus F.X.J. Oberhumer fd3ae51f83 Remove trailing whitespace. 2006-09-09 11:00:33 +02:00
Markus F.X.J. Oberhumer 5e5954a808 Use gcc-4.1.1 again for mipsel. 2006-09-09 10:57:13 +02:00
John Reiser add8540909 Integrate upx-2.90beta1-ps1-20060908.bz2 from Jens. 2006-09-08 14:09:30 -07:00
John Reiser 06a302aed0 Integrate upx-2.90beta1-ps1-20060907 from Jens. 2006-09-07 10:44:19 -07:00
John Reiser 147432d38d list fastest possible inline expansion (saves 3 cycles) 2006-09-06 11:19:18 -07:00
John Reiser 2a003ff72b merge 2006-09-06 10:55:37 -07:00
John Reiser 8660d3324d "revert -r eae1090d512738ac64c783be70258ababc8b6513" to sync with Markus 2006-09-06 10:52:06 -07:00
John Reiser 6c59b73ae5 PackLinuxElf64::generateElfHdr() .p_flags are only 32 bits 2006-09-06 10:36:50 -07:00
Markus F.X.J. Oberhumer 80218c1eca Atari/tos is currently broken, so throw an InternalError. 2006-09-06 14:31:30 +02:00
John Reiser f24d96d59f document alternate getbit 2006-09-04 20:09:03 -07:00
Markus F.X.J. Oberhumer d14bd49f46 Updated mips Makefile. 2006-09-04 14:23:21 +02:00
Markus F.X.J. Oberhumer 1a692a0873 Tuned mips compiler flags. 2006-09-03 19:14:49 +02:00
Markus F.X.J. Oberhumer 631a1a4ddc Cosmetic changes. 2006-09-03 19:13:35 +02:00
Markus F.X.J. Oberhumer 57df7601d9 mipsel: use -mtune=r4000 and -fno-sched-spec for small size reduction. 2006-09-02 14:53:31 +02:00
Markus F.X.J. Oberhumer f7650000aa Enable -fwrapv for mipsel. 2006-09-02 14:16:46 +02:00
Markus F.X.J. Oberhumer 6f93c2d9b2 Updated Makefiles. 2006-09-02 14:14:15 +02:00
Markus F.X.J. Oberhumer 1654764968 Disable lua for now. 2006-09-01 02:38:35 +02:00
Markus F.X.J. Oberhumer 1a1b8416e2 Use f-embed_objinfo for arm-linux. 2006-09-01 02:36:24 +02:00
Markus F.X.J. Oberhumer 36c66d52a6 Added SQUEEZE macro to better canonicalize the dumps. 2006-09-01 02:09:16 +02:00
Markus F.X.J. Oberhumer 68fe43d488 Strip trailing whitespace. 2006-09-01 01:35:51 +02:00
Markus F.X.J. Oberhumer 877b9ee23b Stub: provide debugging disassembly for arm. 2006-09-01 01:34:20 +02:00
Markus F.X.J. Oberhumer 80ff93beeb Explicitly strip section .note.GNU-stack from objects. 2006-08-30 20:15:07 +02:00
Markus F.X.J. Oberhumer b9ddd2812b Create disassembly for i386-dos32.djgpp2-stubify.h. 2006-08-30 19:38:39 +02:00
László Molnár ba54b56de4 another update for ps1/exe from Jens 2006-08-30 12:42:49 +02:00
Markus F.X.J. Oberhumer 85be67bc2d Removed some temporary tags. Info: you can use the file .hg/localtags
to define per-repository local tags which are not shared.
2006-08-30 00:21:13 +02:00
Markus F.X.J. Oberhumer ae20e01d2c Started renaming some loader symbols - now that we have a real
linker we really should improve readability and avoid those
old cryptic names.
2006-08-30 00:11:40 +02:00
Markus F.X.J. Oberhumer d094e8c3fc Added stub/tmp/*.dump files to the Mercurial repository.
These .dump files are embedded in the .h stubs anyway, but we
really want to see some diffs to better understand what has
changed in a commit.
2006-08-30 00:06:47 +02:00
Markus F.X.J. Oberhumer f009fe1f63 Start work on updating p_tos. 2006-08-29 23:46:21 +02:00
Markus F.X.J. Oberhumer 2007fe5f49 More small Makefile changes. 2006-08-29 23:08:26 +02:00
László Molnár 84989ffa04 merge 2006-08-29 17:11:03 +02:00
László Molnár 31b629a19c ps1/exe updated from jens 2006-08-29 16:25:59 +02:00
Markus F.X.J. Oberhumer e762d9e274 Yet another minor Makfile update. 2006-08-29 16:05:17 +02:00
Markus F.X.J. Oberhumer 6833267b19 Cleanups in stub Makefiles. 2006-08-29 14:37:06 +02:00
Markus F.X.J. Oberhumer 05f2833388 Detabified. 2006-08-29 13:43:06 +02:00
Markus F.X.J. Oberhumer 0d026ef18d Removed trailing whitespace. 2006-08-29 13:41:13 +02:00
Markus F.X.J. Oberhumer b756d93891 Use absolute symbols to store offsets in m68k stub. 2006-08-28 09:48:01 +02:00
Markus F.X.J. Oberhumer f54513586d Implemented alignCode() for m68k. 2006-08-28 09:09:29 +02:00
Markus F.X.J. Oberhumer 6c519c237e Renamed Linker::align() to alignCode(). We still have to add
some way to express alignData().
2006-08-28 08:58:43 +02:00
John Reiser 4ffde4db98 8-byte align LZMA_DEC20 2006-08-27 10:03:12 -07:00
Markus F.X.J. Oberhumer 41847d31e7 More m68k rearrangments. 2006-08-26 13:25:37 +02:00
Markus F.X.J. Oberhumer 24ce25bb5c Updated READMEs. 2006-08-26 13:25:04 +02:00
Markus F.X.J. Oberhumer e051b69e80 Use -fwrapv for m68k stubs. 2006-08-26 12:57:21 +02:00
Markus F.X.J. Oberhumer 59283d1164 More work on m68k. 2006-08-24 20:48:09 +02:00
Markus F.X.J. Oberhumer 0de32a5edc Small Makefile cleanup. 2006-08-24 14:07:53 +02:00
Markus F.X.J. Oberhumer 4f80066dcb New ACC version. 2006-08-24 12:39:45 +02:00
Markus F.X.J. Oberhumer 04ddc8003f Started work on m68k. 2006-08-24 03:56:11 +02:00
Markus F.X.J. Oberhumer 3213f98d66 Added recursive targes extra-all and extra-clean. 2006-08-24 01:34:57 +02:00
Markus F.X.J. Oberhumer 1f16f85c51 Reorganized Makefile.extra. 2006-08-24 01:34:24 +02:00
Markus F.X.J. Oberhumer c03cb3a11c All stubs now depend on Makefile and thus will get rebuilt more often. 2006-08-24 01:34:06 +02:00
László Molnár 62e29a6546 let us see the relocation info in the disassembled stubs 2006-08-23 14:43:37 +02:00
László Molnár 3574b065d6 fixed prototype of ElfLinkerMipsLE::relocate1 2006-08-23 14:35:28 +02:00
Markus F.X.J. Oberhumer c0c47f41be Added initial lzma support for m68k. 2006-08-23 13:58:16 +02:00
Markus F.X.J. Oberhumer 37761d580f Updated for bin-upx-20060823. 2006-08-23 13:11:01 +02:00
Markus F.X.J. Oberhumer e075c8e691 Updated unused code. 2006-08-23 11:30:42 +02:00
Markus F.X.J. Oberhumer 0c61ca1a6b Renamed addLinkerSymbols() to defineSymbols(). 2006-08-23 11:20:06 +02:00
John Reiser 1846fa1f54 PackLinuxElf start loader at 0 mod 8 2006-08-22 21:22:49 -07:00
John Reiser 579ce20cad remove patchFilter32() 2006-08-22 20:49:28 -07:00
John Reiser 12e4bcba5d Elf64 sets .p_flags for 0-length .bss 2006-08-22 11:23:55 -07:00
László Molnár b4f57dee3b arm.v4t-wince.pe: minor cleanups 2006-08-22 14:16:46 +02:00
Markus F.X.J. Oberhumer f11673ae3f Removed Packer::patchDecompressor(). 2006-08-22 11:05:18 +02:00
Markus F.X.J. Oberhumer a27af7dd7e Small update. 2006-08-22 11:02:54 +02:00
Markus F.X.J. Oberhumer 2b26a3cc14 Updated .hgignore. 2006-08-22 10:59:16 +02:00
Markus F.X.J. Oberhumer 47c4849694 Added support for debug.dump_stub_loader. 2006-08-22 10:48:04 +02:00
John Reiser 30a4adf331 Reduce usage of patchDecompressor() 2006-08-21 21:19:48 -07:00
John Reiser 117a721166 ElfLinker::addSection ==> addLoader 2006-08-21 19:52:09 -07:00
John Reiser 1a219e62ba Bvmlinuz: linker->defineSymbol() instead of patchDecompressor() 2006-08-21 14:26:42 -07:00
John Reiser c8d54b324b Only PC-relative relocations get range checked. 2006-08-21 14:26:08 -07:00
John Reiser 0ac2971fc1 add UPX_F_BSD_ELF_i386 to the exceptions for patchDecompressor() 2006-08-21 12:09:46 -07:00
Markus F.X.J. Oberhumer 348a40201b Introduce $(tc_bfdarch) and generate disassemblies to verify code quality. 2006-08-21 20:55:37 +02:00
Markus F.X.J. Oberhumer 9f20ddc800 Removed Packer::patchVersion() and Packer::patchVersionYear(). 2006-08-21 20:28:14 +02:00
Markus F.X.J. Oberhumer 6f1cc2c1e5 Renamed ElfLinker::addSection(sname) to addLoader(). 2006-08-21 20:07:42 +02:00
Markus F.X.J. Oberhumer 601cd95277 Removed Packer::getIdentstr(). 2006-08-21 19:57:43 +02:00
Markus F.X.J. Oberhumer 8e9ce59ef2 Minor Makefile cleanups. 2006-08-21 16:40:20 +02:00
László Molnár d76ef8e3cf arm/pe: use embed_objinfo in the Makefile
made some symbols globals in arm.v4a-wince.pe.S & arm.v4t-wince.pe.S
2006-08-21 15:20:20 +02:00
John Reiser c19ffafd8d i386-linux.elf decompress does not need cto8 2006-08-20 11:19:37 -07:00
Markus F.X.J. Oberhumer 996a99ad75 Some linker.cpp cleanups. 2006-08-20 11:15:36 +02:00
Markus F.X.J. Oberhumer affb926d44 Whitespace cleanups. 2006-08-20 11:08:38 +02:00
John Reiser c506e534aa propagate to .h in stub/ 2006-08-19 18:41:45 -07:00
John Reiser 9994315070 un-debug 2006-08-19 18:40:49 -07:00
John Reiser 4f0d89ef8b convert PackMachPPC32 to new Linker 2006-08-19 15:28:16 -07:00
Markus F.X.J. Oberhumer aab984618d Fix newLinker() for mach/ppc32. 2006-08-19 14:29:40 +02:00
Markus F.X.J. Oberhumer 8b662bc6b5 Removed trailing whitespace. 2006-08-19 14:01:39 +02:00
Markus F.X.J. Oberhumer 03ce7a8db3 Removed all old linker classes - we exclusively use ElfLinker now. 2006-08-19 14:00:22 +02:00
Markus F.X.J. Oberhumer 033e7928b5 Minor Makefile updates. 2006-08-19 13:05:16 +02:00
Markus F.X.J. Oberhumer b095f2a158 Strip trailing whitespace from objdump info. 2006-08-18 13:22:38 +02:00
Markus F.X.J. Oberhumer 196c0e0ebc Added embed_objinfo macro. 2006-08-18 13:18:10 +02:00
Markus F.X.J. Oberhumer 8ab309630b Keep old alloca() code around. 2006-08-18 12:26:41 +02:00
Markus F.X.J. Oberhumer 42bac47a71 Improve automatic dependency information by using '-MT'. 2006-08-18 12:26:06 +02:00
Markus F.X.J. Oberhumer 3bc4de2236 Added missing stubs to hg repo. 2006-08-18 12:25:34 +02:00
John Reiser a6e4b45a38 --force-execve for *BSD/386 2006-08-17 17:35:33 -07:00
John Reiser 28e97ccaf2 avoid symbol 'byte' 2006-08-17 17:18:37 -07:00
Markus F.X.J. Oberhumer 255781c029 Minor cleanups. 2006-08-17 13:09:51 +02:00
John Reiser 7f5635ea8c Section LZMA_ELF00 saves time (but no space) by not clearing CProb[]. 2006-08-16 19:49:09 -07:00
Markus F.X.J. Oberhumer 4f18ec726c Rebuilt with bin-upx-20060816 (untested mipsel changes). 2006-08-16 19:40:33 +02:00
Markus F.X.J. Oberhumer 263622d628 Updated for bin-upx-20060816. 2006-08-16 19:37:25 +02:00
László Molnár 1dfd2443ac name of file comments fixed 2006-08-16 15:29:11 +02:00
Markus F.X.J. Oberhumer 881bd53f60 Small Makefile cleanups. 2006-08-16 09:50:00 +02:00
Markus F.X.J. Oberhumer ec4404b1ba We have to use "dword ptr" instead of "dword" ! 2006-08-16 09:38:49 +02:00
Markus F.X.J. Oberhumer badaeac81f Use "jmps" macro instead of #define. 2006-08-16 09:34:27 +02:00
Markus F.X.J. Oberhumer 618d5ddaff More renaming. 2006-08-16 09:24:31 +02:00
Markus F.X.J. Oberhumer 4ed74af868 More renaming. 2006-08-16 09:07:00 +02:00
Markus F.X.J. Oberhumer 123d9af7d0 More renaming in arch/i386. 2006-08-16 08:39:58 +02:00
Markus F.X.J. Oberhumer 4f17b30915 Started renaming .asm files to .S. 2006-08-16 08:13:36 +02:00
Markus F.X.J. Oberhumer 1fc265b0aa Use symbolic stride again. 2006-08-16 07:59:21 +02:00
John Reiser afae9b8d17 merge 2006-08-15 14:01:53 -07:00
John Reiser 481be44879 Work around assembler bug: double-indexing by symbolic stride fails. 2006-08-15 14:00:35 -07:00
Markus F.X.J. Oberhumer b8530b0f0b Whitespace cleanups. 2006-08-15 22:48:04 +02:00
Markus F.X.J. Oberhumer 69de79684f Removed some unused files. 2006-08-15 22:41:05 +02:00
Markus F.X.J. Oberhumer 6e6fd057b5 Cleaned up stub/Makefile. 2006-08-15 22:38:40 +02:00
John Reiser 4b0ebf2b80 merge 2006-08-15 12:11:36 -07:00
John Reiser ee82c32119 'dword' is a symbol to libexec/gcc/i686-unknown-linux-gnu/3.4.6/cc1 2006-08-15 12:10:54 -07:00
Markus F.X.J. Oberhumer 3fe6731035 Disable WITH_LUA for now. 2006-08-15 19:23:03 +02:00
Markus F.X.J. Oberhumer 1c3f3b5705 Removed last dependency on nasm assembler. 2006-08-15 18:50:41 +02:00
Markus F.X.J. Oberhumer def1ccffc4 Rebuilt with bin-upx-20060815. 2006-08-15 18:39:05 +02:00
Markus F.X.J. Oberhumer fa2e531343 Updated for bin-upx-20060815. 2006-08-15 18:38:38 +02:00
Markus F.X.J. Oberhumer 814ddbc6cc Remove duplicate inclusion. 2006-08-15 17:20:23 +02:00
John Reiser 267e8dcfb6 Omit double include of macros2.ash. 2006-08-15 07:22:52 -07:00
John Reiser 49ec1561f8 merge 2006-08-15 07:11:06 -07:00
John Reiser e2dc612153 Add cl1_d32_2.ash. 2006-08-15 07:08:50 -07:00
Markus F.X.J. Oberhumer 8f225431fe Minor updates to Makefile and stubs. 2006-08-15 10:23:45 +02:00
Markus F.X.J. Oberhumer 194be5e0b7 Moved o2bin.pl to UNUSED. 2006-08-15 09:21:39 +02:00
John Reiser 6788a05dd1 convert powerpc-darwin.macho-entry.h to new linker 2006-08-14 21:20:30 -07:00
John Reiser 6a7066ac2f Avoid linker->setLoaderAlignOffset(). 2006-08-14 19:21:15 -07:00
John Reiser ec5ff4e973 merge 2006-08-14 13:06:53 -07:00
John Reiser fe6d460531 rebuild: arm-unknown-linux-gnu-gcc-4.1.0, i386-linux-gcc-3.4.6;
powerpc/32/ppc_regs.h
2006-08-14 12:30:33 -07:00
John Reiser 9cb97af10f begin conversion to new linker 2006-08-14 12:10:34 -07:00
John Reiser 1c784eea3d typo for i386-bsd.elf-main.o 2006-08-14 12:09:42 -07:00
László Molnár 59dd33a461 ps1/exe updates from Jens 2006-08-14 17:15:26 +02:00
László Molnár 97ebd912dc rebuilt arm.v4t-wince.pe.h 2006-08-14 14:26:40 +02:00
Markus F.X.J. Oberhumer 742fcc060c Update NEWS. 2006-08-14 08:46:55 +02:00
Markus F.X.J. Oberhumer 3ad5cb8a23 Merge. 2006-08-14 08:44:58 +02:00
John Reiser 0d1f12e31a Use better name osabi_note. 2006-08-13 20:14:14 -07:00
John Reiser a8ddf8f66d Detect PT_NOTE for NetBSD, OpenBSD. 2006-08-13 20:00:44 -07:00
John Reiser f7a9c0a248 Mention lzma, *BSD, linux workaround [needs clarification.] 2006-08-13 12:44:40 -07:00
John Reiser 190badb395 arm-unknown-linux-gnu-gcc-4.1.0 2006-08-13 12:32:42 -07:00
Markus F.X.J. Oberhumer 3d91ab6c31 Introduced bele_policy.h. 2006-08-13 15:30:26 +02:00
Markus F.X.J. Oberhumer c15b8d71bc Removed trailing whitespace. 2006-08-13 14:47:24 +02:00
John Reiser 5a707dba8a fix NRV_TAIL, ELFMAINY 2006-08-11 20:45:43 -07:00
John Reiser ffd2fcde6b sections NRV_HEAD, NRV_TAIL replace NRV_COMMON 2006-08-11 20:29:51 -07:00
László Molnár 8e4056c1e4 vmlinuz/386: fixed zlib uncompression problem on dos 2006-08-11 17:59:12 +02:00
László Molnár 1554e2b135 lzma support for ps1 from Jens 2006-08-11 11:18:01 +02:00
John Reiser 4715cbb70d PackLinuxI386::newLinker() is a new ElfLinkerX86;
re-generate i386-linux.elf.execve-entry.h after lzma_d_cs.S
2006-08-10 18:48:32 -07:00
John Reiser fd1611079a auto-define symbol *ABS* in section *ABS*
(for i386-linux.elf.execve-entry.h  R_386_PC  *ABS*)
2006-08-10 17:02:36 -07:00
John Reiser 8edc03df64 PackLinuxI386::newLinker(); also use arm-unknown-linux-gnu-gcc-4.1.0
to re-compile stub/src/arch/arm/v4t/lzma_d_cf.S, lzma_d_cs.S .
2006-08-10 16:52:20 -07:00
László Molnár 9f5c0af5b8 step 0 of refactoring arm/pe & win32/pe ready 2006-07-26 14:00:36 +02:00
László Molnár 6d6eeba5d5 refactoring of arm/pe and win32/pe started 2006-07-25 18:30:12 +02:00
László Molnár 5dfb64ef71 arm.v4a-wince.pe.h rebuilt 2006-07-25 12:31:45 +02:00
John Reiser e5bda7add7 save 28 bytes (> 10%) in arch/arm/v4a/nrv2b_d8.S 2006-07-24 14:48:06 -07:00
John Reiser 77f9b336bd ARM lzma_d_cf.S use .Lf labels to save space in arm-linux.elf-entry.h 2006-07-24 06:26:04 -07:00
László Molnár cf930d0dde merge 2006-07-24 11:06:06 +02:00
László Molnár f01c94e8bc arm/pe: nrv2b support for v4a mode 2006-07-23 21:50:51 +02:00
László Molnár 0d774527b4 merge. arm/pe lzma updates 2006-07-23 21:08:27 +02:00
John Reiser 58ba9496d0 arm-linux lzma_d.c omit -fPIC enables using r10 2006-07-23 09:13:47 -07:00
John Reiser 1993e94e53 ARM lzma bug in cacheflush 2006-07-23 07:19:35 -07:00
László Molnár 3bcc06ed09 arm/pe: lzma works for v4t too
minor changes in v4a code
2006-07-23 16:13:10 +02:00
John Reiser 2f6ce88e28 ARM Linux lzma work 2006-07-22 20:53:15 -07:00
John Reiser cd1dec9fc7 PackLinuxElf32arm lzma cache flush; 5th arg to f_decompress is on stack 2006-07-22 11:39:29 -07:00
John Reiser 05872d7650 arm-linux nrv2b works: conditon code bug, cache flush, cache lookahead 2006-07-22 08:48:04 -07:00
László Molnár 1dcee2ffa2 lzma for arm/pe v4a works 2006-07-22 17:30:09 +02:00
John Reiser 5f622efb77 nrv2e PackLinuxElf32armLe works 2006-07-21 19:10:48 -07:00
John Reiser 52e8326d54 work on PackLinuxElf32arm; add nrv2b_d8.S 2006-07-21 13:11:02 -07:00
László Molnár 436532bed7 arm/pe: lzma support for v4a (untested) 2006-07-21 15:08:29 +02:00
László Molnár d15e789200 nrv2d support for arm/pe v4a mode 2006-07-20 18:11:14 +02:00
John Reiser 98942f5528 work on PackLinuxElf32arm, including nrv2d and lzma 2006-07-19 17:29:17 -07:00
László Molnár c7c21dc122 rebuilt some i386 stubs 2006-07-18 13:45:22 +02:00
László Molnár 4500c1d1a4 lzma should be working again for most of the i386 formats 2006-07-18 13:44:44 +02:00
John Reiser b8b983dded nrv2d decompressor for PackLinuxElf64amd 2006-07-17 15:02:37 -07:00
John Reiser d6a6673971 nrv2d decompressor for PackLinuxElf32ppc 2006-07-17 13:23:49 -07:00
László Molnár 0580fe8db8 merge 2006-07-17 17:39:45 +02:00
László Molnár c727e24138 win32/pe works with lzma again 2006-07-17 17:38:44 +02:00
László Molnár b83698ebf5 Packer::defineDecompressorSymbols added 2006-07-17 17:34:03 +02:00
László Molnár 3fbbaa5130 really fixed i386 lzma stub 2006-07-17 17:33:03 +02:00
John Reiser 2f48b840ae merge 2006-07-17 08:06:06 -07:00
John Reiser efdee11d5a lzma PackLinuxElf32ppc works! 2006-07-17 08:05:31 -07:00
László Molnár 4c87e11aeb 8 bit relocation overflow detection added to ElfLinker 2006-07-17 16:58:24 +02:00
László Molnár e881e008b8 fixes for the i386 nrv2b & nrv2d stubs 2006-07-17 16:56:17 +02:00
László Molnár 1b2837915d small conversion related fix to the lzma stub 2006-07-17 16:54:41 +02:00
László Molnár d076a6724f merge 2006-07-17 12:13:08 +02:00
John Reiser 386af71c39 add lzma_d.S for PackLinuxElf32ppc 2006-07-16 22:35:35 -07:00
John Reiser 49f277192c hacking lzma PackLinuxElf32ppc 2006-07-16 22:32:55 -07:00
John Reiser 5974a6276b undebug powerpc-linux.elf-entry.S 2006-07-16 19:06:04 -07:00
John Reiser e06a390771 PackLinuxElf32ppc works (except lzma) 2006-07-16 19:01:17 -07:00
John Reiser b34e204676 PackLinuxElf32ppc conversion; alignment in *::Section 2006-07-16 15:04:16 -07:00
John Reiser 755d990dfd unify buildLinuxLoader using addStubEntrySections and addLinkerSymbols 2006-07-16 09:48:22 -07:00
John Reiser 7185358b98 lzma PackLinuxElf64amd works! 2006-07-15 20:05:41 -07:00
John Reiser 3843ec1e02 lzma for PackLinuxElf64amd 2006-07-15 16:01:53 -07:00
John Reiser cfc5631d5d PackLinuxElf64amd works (except for lzma) 2006-07-15 13:46:37 -07:00
John Reiser e64555aca0 hacking PackLinuxElf64amd 2006-07-14 19:43:38 -07:00
John Reiser ef52ebb529 workaround i386 assembler misfeature 2006-07-14 06:33:40 -07:00
John Reiser c98136ca4f fix error in assembler conversion 2006-07-13 21:10:42 -07:00
László Molnár 65f44d24ca miniacc support for arm-wince-pe 2006-07-13 16:50:26 +02:00
John Reiser 44f20782fd cleanup after merge; AMD64 ElfLinker 2006-07-12 11:42:03 -07:00
John Reiser 9b1d76a5d0 Added tag main-2006-07-12 for changeset 72fe9925b247073cd8342d8bff07adc47b72173f 2006-07-12 11:26:15 -07:00
John Reiser 21b5074ce8 Added tag jfr-2006-07-12 for changeset 8afead5e7182950592970330c218913fecfbe390 2006-07-12 11:24:52 -07:00
John Reiser 0b8825fecb i386 conversion stub conversion; nrv2b_d32_2.ash etc. 2006-07-12 11:15:14 -07:00
László Molnár 3d3c20e507 ElfLinker improvements
Sections/symbols/relocations are allocated dynamically
Sections use an internal copy of their input data
2006-07-11 14:40:58 +02:00
László Molnár 67a282f19f class nocopy introduced 2006-07-11 13:58:13 +02:00
John Reiser 92023b533a merge 2006-07-10 13:26:39 -07:00
John Reiser c1d14c150e How to debug i386-linux.kernel.vmlinu[xz] under qemu 2006-07-10 13:25:39 -07:00
László Molnár aa656c74d5 merge 2006-07-10 13:30:04 +02:00
László Molnár e39b7ffe30 ps1/exe updates from Jens Medoch 2006-07-10 13:28:27 +02:00
John Reiser 1897148abc convert i386-bsd.elf-entry.asm 2006-07-09 20:07:37 -07:00
John Reiser b76118802a ElfLinkerPpc32 2006-07-09 19:52:23 -07:00
John Reiser 8266aa3343 i386/nrv2d_d32_2.ash 2006-07-09 19:15:03 -07:00
John Reiser ab0c349261 workaround ElfLinker not handling addSection(,,) from dynamic block 2006-07-09 17:29:22 -07:00
John Reiser d5e0e66426 PackLinuxElf32x86::newLinker() 2006-07-09 16:59:41 -07:00
John Reiser c5b3107f83 start converting PackLinuxElf32x86 to ElfLinker 2006-07-09 10:17:52 -07:00
John Reiser 1a0a64e4de ::addStubEntrySections() with default ELFMAINX 2006-07-09 08:48:06 -07:00
John Reiser 6bd9805bcc start converting PackLinuxElf64amd to ElfLinker 2006-07-09 08:14:04 -07:00
László Molnár f74c2af65c conversion of atari/tos to ElfLinker finished 2006-07-07 17:49:30 +02:00
László Molnár 9531bdf674 fixed a bug in ElfLinker 2006-07-07 16:57:15 +02:00
László Molnár 76e705e7ee more atari/tos work 2006-07-07 09:20:43 +02:00
László Molnár d35211328e ElfLinker: rela support added 2006-07-07 08:51:48 +02:00
László Molnár b7bbd81dda conversion of atari/tos to ElfLinker started 2006-07-06 18:30:34 +02:00
László Molnár 9836dd5d10 merge 2006-07-06 10:27:31 +02:00
László Molnár 2109ad320d ps1: nrv2b & nrv2d converted to gas
updated README.SRC
removed app-asm5900.pl
2006-07-06 09:20:05 +02:00
László Molnár c026121c0e mips conversion to ElfLinker almost ready 2006-07-06 00:54:14 +02:00
László Molnár ee0c87f7b1 mips conversion started 2006-07-05 18:32:52 +02:00
John Reiser 709fb93a22 sizeof(shstrtab) already includes terminating '\0' 2006-07-05 05:40:24 -07:00
László Molnár b38cd0a48d merge 2006-07-05 13:02:14 +02:00
László Molnár 264435c32d rebuilt the stubs 2006-07-05 13:00:42 +02:00
László Molnár c285929ad3 i386/macros2.ash: ctojr32 fixes 2006-07-04 23:30:50 +02:00
John Reiser 1cbea8157d merge 2006-07-04 08:59:29 -07:00
John Reiser 0a10334f1b more *BSD, especially do_xmap() for OpenBSD 2006-07-04 08:59:00 -07:00
László Molnár f0d5a6ebac vmlinu[xz] using nrv2e converted to ElfLinker 2006-07-04 17:36:54 +02:00
László Molnár db7086b5e6 pe: ignore duplicated relocation records 2006-07-04 14:11:56 +02:00
John Reiser 0e92280b33 *BSD elf-fold escape hatch differs from Linux 2006-07-03 19:35:56 -07:00
John Reiser 0d7255158a OpenBSD "pro-active security" causes headaches 2006-07-03 16:35:21 -07:00
László Molnár 33564b68dd loader.txt updated 2006-07-03 15:13:53 +02:00
Markus F.X.J. Oberhumer ba942b952a Merge. 2006-07-03 14:56:45 +02:00
Markus F.X.J. Oberhumer bd7f28896e Minor cleanups. 2006-07-03 14:54:50 +02:00
John Reiser 18fe124696 ::generateElfHdr() sets .e_ident[Elf32_Ehdr::EI_OSABI] 2006-07-03 05:51:45 -07:00
John Reiser ea3a3b6e1c Elf32_Ehdr::ELFOSABI_LINUX 2006-07-03 05:47:01 -07:00
Markus F.X.J. Oberhumer e6c06aacff New brandelf.py script. 2006-07-03 13:00:53 +02:00
Markus F.X.J. Oberhumer 1aee92cd5c Introduced $(tc_bfdname). 2006-07-03 12:19:20 +02:00
Markus F.X.J. Oberhumer 40c4cad491 Rebuilt. 2006-07-03 12:07:34 +02:00
László Molnár 013d46fb02 merge 2006-07-03 10:46:32 +02:00
László Molnár f0f465411f win32/pe using nrv2e converted to ElfLinker 2006-07-03 09:21:51 +02:00
John Reiser 32ce83475d more *BSD arrangements 2006-07-02 21:54:44 -07:00
John Reiser ec0d3f5b5d merge 2006-07-02 19:28:19 -07:00
John Reiser 75294b9146 FreeBSD, NetBSD, OpenBSD on equal footing 2006-07-02 19:27:08 -07:00
Markus F.X.J. Oberhumer 26a0eb68ef Merge. 2006-07-03 01:42:12 +02:00
Markus F.X.J. Oberhumer b983e29fb0 Fix compilation on big endian machines. Remove trailing whitespace. 2006-07-03 01:40:59 +02:00
John Reiser 68dadabc29 BSD/elf386 2006-07-02 16:25:31 -07:00
László Molnár ed9fd3f0e0 watcom/le using nrv2e converted to ElfLinker 2006-07-02 23:21:15 +02:00
László Molnár fa9573436a tmp/adam using nrv2e converted to ElfLinker 2006-07-02 22:39:53 +02:00
László Molnár 6d2058c3b7 reloc32 uncommented 2006-07-02 22:32:12 +02:00
John Reiser 0d7f93b877 unused: getrusage personality msync getcwd 2006-07-02 12:04:12 -07:00
László Molnár f022c9d510 dos/djgpp2 using nrv2e converted to ElfLinker 2006-07-01 17:29:41 +02:00
László Molnár 5964a06386 arm/pe works with ElfLinker 2006-07-01 12:36:07 +02:00
László Molnár f14dc4a4e9 ElfLinkerArmLe fixes 2006-07-01 12:25:26 +02:00
László Molnár fd56e2534c fixed alignment handling typo 2006-07-01 09:40:12 +02:00
László Molnár 08962a74ab started the arm/pe conversion to ElfLinker 2006-07-01 00:21:53 +02:00
László Molnár f850d36c52 dos/com & dos/sys: use the new ElfLinker features 2006-07-01 00:21:06 +02:00
László Molnár c5fb161477 ElfLinker updates
commented out the debugging printfs
now it's possible to set the offset of sections
aligment handling simplified
ElfLinkerArmPE introduced
2006-07-01 00:10:02 +02:00
László Molnár bfc2fab33f use "//" instead of "#" for comments 2006-07-01 00:01:35 +02:00
John Reiser ec9d6c4fd2 workaround linux bug which demands writeable PT_LOAD for .bss 2006-06-29 19:07:02 -07:00
John Reiser 6135d61e3d *-fold.h depends on *.lds 2006-06-29 17:01:38 -07:00
John Reiser a677242a2c Bvmlinuz remember to patchDecompressor() 2006-06-29 13:58:41 -07:00
John Reiser 6602f30112 true==checkCompressionRatio() means success 2006-06-29 12:07:01 -07:00
Markus F.X.J. Oberhumer a4b8dc18c1 Strip unneeded symbols and sections from i086-* stubs. 2006-06-29 19:09:16 +02:00
Markus F.X.J. Oberhumer c0d4741f88 Merge. 2006-06-29 18:43:36 +02:00
László Molnár b33718180c ElfLinkerX86 introduced.
Simple alignment handling added to ElfLinker.
dos/exe device drivers can be compressed again.
2006-06-29 18:21:01 +02:00
John Reiser 3872393b29 call freezeLoader 2006-06-29 06:08:57 -07:00
John Reiser 1d72a7df99 propagate IMAGE_OFFSET from commandline 2006-06-29 05:57:28 -07:00
Markus F.X.J. Oberhumer 5455908772 Merge. 2006-06-29 14:39:42 +02:00
Markus F.X.J. Oberhumer 8882192fac Minor cleanups. 2006-06-29 14:38:18 +02:00
Markus F.X.J. Oberhumer 7b77491c06 Refactoring: move fields ui_pass and ui_total_passes from class
Packer into class UiPacker.
2006-06-29 14:37:01 +02:00
László Molnár 20bf214d6e dos/com & dos/sys: xchg si,di vs. xchg di,si difference fixed. i086-dos16.com.h rebuilt 2006-06-29 14:27:25 +02:00
Markus F.X.J. Oberhumer 8ab3e63aeb First start of refactoring field ph out of class Packer. 2006-06-29 14:26:49 +02:00
László Molnár 0dc03214c5 merge 2006-06-29 11:51:47 +02:00
John Reiser 362e98b43d lzma: limit stack to ~28KB for decompressing kernel 2006-06-28 22:34:12 -07:00
John Reiser 193e085cf0 limit stack to ~28KB for decompressing kernel 2006-06-28 22:30:05 -07:00
John Reiser e0df2a342b merge 2006-06-28 22:20:24 -07:00
John Reiser ba19ccac43 tabify the commented Makefile 2006-06-28 22:18:48 -07:00
Markus F.X.J. Oberhumer d7261b7a78 Remove debugging code. 2006-06-29 07:00:06 +02:00
Markus F.X.J. Oberhumer 0d80173efd Update some structs for future features. 2006-06-29 06:42:17 +02:00
Markus F.X.J. Oberhumer 930f07d15e Move upx_compress_result_t handling into right place. 2006-06-29 06:24:24 +02:00
Markus F.X.J. Oberhumer 66df7389d2 Refactoring: pass upx_compress_config_t to Packer::compressWithFilters()
so that formats can set conf_lzma.max_num_probs.

Also renamed compression parameters to use cconf & cresult.
2006-06-29 06:15:28 +02:00
Markus F.X.J. Oberhumer c7bf0b6ddd Removed trailing whitespace. 2006-06-29 05:12:39 +02:00
Markus F.X.J. Oberhumer 0bc361adeb Introduced conf_lzma.max_num_probs to limit stack size for decompression. 2006-06-29 05:12:01 +02:00
John Reiser 4fff523a6d Merge 2006-06-28 19:45:58 -07:00
John Reiser 67e09fb342 kernel Makefile; fix cross-platform endian trouble 2006-06-28 19:44:02 -07:00
Markus F.X.J. Oberhumer c360806f47 Small Makefile updates. 2006-06-29 04:16:58 +02:00
Markus F.X.J. Oberhumer 7b74b73b08 Start using binutils-multiarch-2.17. 2006-06-29 01:52:05 +02:00
László Molnár e9a851c0d4 dos/exe: migrated to ElfLinker 2006-06-29 00:44:12 +02:00
Markus F.X.J. Oberhumer b13b169149 Fixed assembly for binutils-2.16.91. 2006-06-29 00:38:12 +02:00
László Molnár 455329a745 dos/sys: got rid of the "next" symbol 2006-06-29 00:28:47 +02:00
László Molnár a68b76c8b4 undefined symbols are initialized to "0xdeaddead" 2006-06-29 00:22:45 +02:00
László Molnár 96e3899216 increased the maximum number of symbols 2006-06-29 00:22:03 +02:00
Markus F.X.J. Oberhumer 771ab5ea9a Added notes about binutils-multiarch-2.17. 2006-06-29 00:11:06 +02:00
László Molnár 3c87e6b270 merge 2006-06-28 15:10:01 +02:00
László Molnár 6d8afec510 ElfLinker started. Dos/com & dos/sys formats converted 2006-06-28 14:45:58 +02:00
John Reiser 89e25657d8 fix cross-platform endian trouble with ELF headers 2006-06-27 13:07:31 -07:00
John Reiser 29387f1fcf lzma Elf i386 minor tuning 2006-06-27 09:53:28 -07:00
John Reiser 58e885c052 un-debug 2006-06-26 17:21:45 -07:00
John Reiser 984dfcd7e1 adapt to new 2-byte replacement for LzmaDecodeProperties() 2006-06-26 17:16:45 -07:00
Markus F.X.J. Oberhumer 3785479086 Use custom encoding for LZMA properties. 2006-06-26 17:28:46 +02:00
Markus F.X.J. Oberhumer 8ed280907c Merge. 2006-06-26 14:36:29 +02:00
Markus F.X.J. Oberhumer d742671205 Update comment. 2006-06-26 14:36:10 +02:00
John Reiser 87e72c28a4 no PROT_WRITE for .text on i386-linux.elf.shell 2006-06-25 06:05:53 -07:00
John Reiser 4dee357362 optimize PackLinuxI386::buildLinuxLoader 2006-06-25 05:56:36 -07:00
John Reiser 431f4b9b0d fix i386-linux.elf.shell 2006-06-25 05:44:39 -07:00
John Reiser dd5b7825d5 save 4 bytes in __LZMA_ELF00__ 2006-06-24 16:48:43 -07:00
John Reiser 02bc48925a lzma ELF minimal CLzmaDecoderState each time 2006-06-24 14:44:40 -07:00
John Reiser 4eb505755e lzma for ELF 2006-06-24 14:00:41 -07:00
Markus F.X.J. Oberhumer 83e94a70ea Narrow try/catch. 2006-06-24 17:53:26 +02:00
Markus F.X.J. Oberhumer 8a150b27c3 Update comment. 2006-06-24 17:39:10 +02:00
John Reiser 1a51451ec2 ELF stub uses getSizeForCompression() 2006-06-23 19:32:29 -07:00
Markus F.X.J. Oberhumer 41e51bfb77 Assert dst_len buffer size in upx_compress(). 2006-06-23 17:50:39 +02:00
Markus F.X.J. Oberhumer 7e1d9bc768 Split options_t::crp into multiple structs. 2006-06-23 16:23:31 +02:00
Markus F.X.J. Oberhumer ba065ec1d8 Improve error code reporting in compression wrappers. 2006-06-23 15:52:10 +02:00
Markus F.X.J. Oberhumer fe057a91c8 Cleanup: removed upx_bool and upx_uint types. 2006-06-23 15:00:33 +02:00
László Molnár d2c36eefc9 pe: fixed unpack problem in rebuildImports() 2006-06-23 11:17:26 +02:00
John Reiser 28d56bab04 Merge 2006-06-22 21:30:59 -07:00
John Reiser 2500eff90d more LZMA debugging for Linux i386 ELF 2006-06-22 21:25:18 -07:00
Markus F.X.J. Oberhumer 153446b3a1 Fixed debugging code. 2006-06-23 05:40:35 +02:00
Markus F.X.J. Oberhumer 391f5caaa2 Added precondition assertions to upx_decompress(). 2006-06-23 05:27:42 +02:00
Markus F.X.J. Oberhumer cc0df92444 Added some more checks. 2006-06-23 04:02:06 +02:00
John Reiser 03910d67c3 M_LZMA bug tracking: decompress fails but says OK 2006-06-22 17:18:17 -07:00
Markus F.X.J. Oberhumer fec5cc864e Update Makefile. 2006-06-23 01:02:47 +02:00
Markus F.X.J. Oberhumer cb78362713 Use inner class UiPacker::State. 2006-06-22 19:40:43 +02:00
Markus F.X.J. Oberhumer 4c5b1a6ff4 Added some assertions to track down a win32/pe unpack problem which
shows up on 64-bit machines.
2006-06-22 16:47:10 +02:00
László Molnár 83c5727698 merge 2006-06-22 16:17:09 +02:00
László Molnár 80838ff1e9 watcom/le: lzma seems to work 2006-06-22 16:15:32 +02:00
Markus F.X.J. Oberhumer 29e8d072b7 Simplify C++ style in Linker. 2006-06-22 16:12:48 +02:00
Markus F.X.J. Oberhumer d7592f01e1 Renamed method. 2006-06-22 16:00:03 +02:00
László Molnár 392f283d9e added some comments 2006-06-22 15:54:25 +02:00
Markus F.X.J. Oberhumer bcd738ebbb Introduced Packer::patchDecompressorGetExtraStacksize(). 2006-06-22 15:35:38 +02:00
László Molnár 8020c52c48 merge 2006-06-22 15:04:39 +02:00
László Molnár 3f566e541d djgpp2: lzma seems to work 2006-06-22 15:00:15 +02:00
Markus F.X.J. Oberhumer be4a631dc8 Bump version. 2006-06-22 14:50:09 +02:00
Markus F.X.J. Oberhumer 0bfdf908c1 Fixed typo. 2006-06-22 14:20:05 +02:00
Markus F.X.J. Oberhumer 6f2fc23f77 Added LZMA license information. 2006-06-22 14:11:58 +02:00
Markus F.X.J. Oberhumer f3a47c7e70 Add more lzma_d.ash includes. 2006-06-22 14:07:23 +02:00
Markus F.X.J. Oberhumer 36349ffabb Removed trailing whitespace. 2006-06-22 14:06:21 +02:00
John Reiser b13f7366cf freezeLoader() sooner in PackLinuxElf32x86::buildLinuxLoader() 2006-06-21 17:08:58 -07:00
John Reiser 9181bcd9a7 CT24ARM needs big+little endian versions 2006-06-21 13:57:12 -07:00
Markus F.X.J. Oberhumer 7dbc1d894b Add default defines like -Dstub_i386_dos32_djgpp2=1 to nasm. 2006-06-21 21:31:20 +02:00
Markus F.X.J. Oberhumer 5720445d15 Use ebx for state pointer. Decrease local stack size. 2006-06-21 14:34:23 +02:00
Markus F.X.J. Oberhumer a90027521d Prepare Makefile for integrating lua-5.1.1 into upx. 2006-06-20 15:35:23 +02:00
Markus F.X.J. Oberhumer e02d400bf6 Avoid djgpp2 link error. 2006-06-20 15:25:38 +02:00
Markus F.X.J. Oberhumer efadb8fd31 More lzma stubs. 2006-06-19 23:19:34 +02:00
Markus F.X.J. Oberhumer a19d06561b Added amd64 implementations of lzma. 2006-06-19 22:33:18 +02:00
Markus F.X.J. Oberhumer 0b685d11c9 More lzma updates - win32/pe + lzma seems to work. 2006-06-19 22:08:06 +02:00
Markus F.X.J. Oberhumer 28f019d672 Merge. 2006-06-19 19:21:23 +02:00
Markus F.X.J. Oberhumer bf5cbfffc2 Start major refactoring. 2006-06-19 19:20:50 +02:00
László Molnár fe021e7c51 w32/pe: added Virtualloc and VirtualFree to the import list 2006-06-19 15:05:28 +02:00
Markus F.X.J. Oberhumer c42fb54bc6 Assorted cleanups. 2006-06-17 18:54:11 +02:00
Markus F.X.J. Oberhumer 9382b68781 Fix srcdir for VPATH build. 2006-06-16 20:08:21 +02:00
Markus F.X.J. Oberhumer 178198a417 Merge. 2006-06-16 17:52:50 +02:00
John Reiser 7068e90771 Merge 2006-06-16 06:53:56 -07:00
Markus F.X.J. Oberhumer 1c762f23d0 Simplify stub/Makefile. 2006-06-16 15:51:59 +02:00
John Reiser fd2b9a6e21 filter 0x51 (ARM call trick, big-endian at compress time) 2006-06-16 06:49:37 -07:00
Markus F.X.J. Oberhumer db43910288 Enter 2006. 2006-06-16 15:17:29 +02:00
Markus F.X.J. Oberhumer f248c0460e Use -mcpu=405 for powerpc stubs. Also run sstrip on powerpc-linux.elf-fold. 2006-06-16 14:36:13 +02:00
Markus F.X.J. Oberhumer b8e3c0ceb4 Allow ~/bin/bin-upx in addition to ~/local/bin/bin-upx. 2006-06-16 14:11:11 +02:00
Markus F.X.J. Oberhumer b5053d889e Updated toplevel Makefile. 2006-06-16 14:09:22 +02:00
Markus F.X.J. Oberhumer 12ba7776b3 Comment out unused upx_crc32(). 2006-06-16 14:08:56 +02:00
Markus F.X.J. Oberhumer 7817e88d03 Updated stub/Makefile. 2006-06-16 13:26:36 +02:00
Markus F.X.J. Oberhumer 8dec65853d Fixed another bad merge issue. 2006-06-16 12:34:37 +02:00
Markus F.X.J. Oberhumer 88e3cb3be1 Stub: remove files again which seem to have been brought back by some merge. 2006-06-16 12:31:14 +02:00
John Reiser fa702b48e3 unify PackLinuxElf32arm...::pack1() 2006-06-15 15:41:00 -07:00
John Reiser 299dcf6686 Merge 2006-06-15 12:21:01 -07:00
Markus F.X.J. Oberhumer 27f9ae5bbb Small cleanups. 2006-06-15 19:59:30 +02:00
Markus F.X.J. Oberhumer 9cb3a853f1 Added option --MMD= to gpp_inc.py for automated dependencies. 2006-06-15 19:03:18 +02:00
Markus F.X.J. Oberhumer 95c8ef4148 Added a number of convenience Makefiles. 2006-06-15 18:07:23 +02:00
Markus F.X.J. Oberhumer a41bb52014 Updated comments. 2006-06-15 18:03:24 +02:00
Markus F.X.J. Oberhumer 914cd7221e Updated. 2006-06-15 17:57:22 +02:00
Markus F.X.J. Oberhumer 2dfc0a58ab Renamed src/stub/util/ to src/stub/tools/ . 2006-06-15 17:56:57 +02:00
Markus F.X.J. Oberhumer 0c9f3c638a Explicitly list all required files for ~/local/bin/bin-upx/. 2006-06-15 17:52:30 +02:00
Markus F.X.J. Oberhumer a966d6acf1 Mention GNU make 3.81. 2006-06-15 17:27:04 +02:00
Markus F.X.J. Oberhumer 1e0c38b5f9 Renamed i386-linux-sstrip to sstrip. 2006-06-15 08:41:33 +02:00
Markus F.X.J. Oberhumer d3323d6550 Major refactoring of src/stub directory. 2006-06-15 08:17:50 +02:00
John Reiser ebed0b9f20 allow brev() in-place 2006-06-14 20:21:39 -07:00
John Reiser f654a453dc ARM_pack3() unifies big/little endian and HostPolicy 2006-06-14 16:06:50 -07:00
John Reiser 10decf94cc fix delete[] file_image 2006-06-14 11:41:49 -07:00
John Reiser 96dd4817f1 unify PackLinuxElf32...::canPack(); also ARM buildLinuxLoader() 2006-06-14 11:33:16 -07:00
Markus F.X.J. Oberhumer 72906cdc6a Removed all files from src/stub directory. 2006-06-14 17:37:59 +02:00
Markus F.X.J. Oberhumer fba4375be0 Cleanups. 2006-06-14 17:06:33 +02:00
Markus F.X.J. Oberhumer 75120676ad Introduced BEPolicy and LEPolicy. 2006-06-14 14:45:49 +02:00
Markus F.X.J. Oberhumer 7daf63fd3f Merge. 2006-06-14 11:48:44 +02:00
Markus F.X.J. Oberhumer 014de25f6f Disable lzma by default for now. 2006-06-14 11:42:24 +02:00
John Reiser 3fc6535012 un-debug Makefile 2006-06-13 19:02:21 -07:00
John Reiser 4fc0a32572 Do not brev() strings in stub for PackLinuxEl32armBe. 2006-06-13 18:55:26 -07:00
John Reiser dcc704a357 debug PackLinuxElf32armBe. Also unify subroutines. 2006-06-13 15:51:29 -07:00
John Reiser bd8acbde97 PackLinuxElf32armBe (Linux ARM big-endian) 2006-06-13 11:48:54 -07:00
John Reiser 112b10c19d avoid randomness for progid in Elf 2006-06-13 08:53:41 -07:00
John Reiser d89e561a85 PackLinuxElf32armLe, PackLinuxElf32armBe 2006-06-13 08:51:02 -07:00
John Reiser 49c1da79c8 PackLinuxElf32arm ==> PackLinuxElf32armLe 2006-06-13 08:27:14 -07:00
John Reiser 0a72f00175 Elf_BE32_* 2006-06-13 08:25:30 -07:00
John Reiser 1af5820db0 hack printf() 2006-06-13 08:24:38 -07:00
John Reiser c117491549 arm-9tdmi-linux-gnu-gcc is gcc-3.4.5-glibc-2.3.6; old was gcc-3.4.1-glibc-2.3.3 2006-06-12 11:05:52 -07:00
Markus F.X.J. Oberhumer d8748f4270 Introduced MemBuffer::getSizeForCompression(). 2006-06-12 13:18:55 +02:00
Markus F.X.J. Oberhumer c0ba6e13e4 Check for .hg directory when generating ChangeLog. 2006-06-11 13:05:57 +02:00
Markus F.X.J. Oberhumer c34daf1a35 Make code -Wshadow warning free. 2006-06-11 12:25:19 +02:00
Markus F.X.J. Oberhumer d461b53235 Renamed variable clen to c_len and ulen to u_len. 2006-06-11 12:13:37 +02:00
Markus F.X.J. Oberhumer c3ee14eb67 Introduced upx_compress_result_t. 2006-06-11 12:09:25 +02:00
Markus F.X.J. Oberhumer 869fb8e327 Merge. 2006-06-11 00:01:56 +02:00
John Reiser fbbc3024d6 Linux ARM cacheflush 2006-06-10 14:41:50 -07:00
Markus F.X.J. Oberhumer f1ba0c0aa7 More lzma stuff. 2006-06-09 18:36:53 +02:00
Markus F.X.J. Oberhumer 54340ab4bf Renamed environment variable UCLDIR to UPX_UCLDIR. 2006-06-09 15:22:42 +02:00
Markus F.X.J. Oberhumer 39732eee5e Merge. 2006-06-09 09:30:42 +02:00
Markus F.X.J. Oberhumer a9e4526a6d Rearranged compression interface. 2006-06-09 09:28:32 +02:00
John Reiser 57a6d2abf9 Merge 2006-06-08 20:51:59 -07:00
John Reiser d6246941ac fix f_unfilter 0x50 2006-06-08 20:48:43 -07:00
László Molnár 2eb91f9b91 do not assume osection[0].rawdataptr > 0 during decompression 2006-06-08 16:52:54 +02:00
Markus F.X.J. Oberhumer 34ae413607 Initial lzma support. 2006-06-07 04:42:15 +02:00
Markus F.X.J. Oberhumer ee9f8c184b Small updates. 2006-06-06 19:07:38 +02:00
Markus F.X.J. Oberhumer 7a84afcbdb Sort .hgtags. 2006-06-06 17:42:43 +02:00
Markus F.X.J. Oberhumer b8a16ea99d Merge. 2006-06-06 17:38:39 +02:00
Markus F.X.J. Oberhumer 095466d5c7 Added tag RELEASE_201 for changeset a916a2fe22de45167d25abcb40008315f415221c 2006-06-06 17:36:52 +02:00
Markus F.X.J. Oberhumer 89cfa22c3f Final cleanups for 2.01. 2006-06-06 17:36:34 +02:00
John Reiser 1f18050930 elf32arm escape hatch: avoid Elf32_Ehdr if possible 2006-06-02 08:51:02 -07:00
John Reiser 537b78d564 fix elf32arm unmapping hatch 2006-06-01 22:48:52 -07:00
John Reiser 717fd57ce1 remember b_info for Elf headers; also: escape hatch 2006-06-01 12:00:05 -07:00
John Reiser 3fb7786868 [re-]comment-out debugging 'int3' 2006-06-01 11:12:30 -07:00
John Reiser 17ecfc9765 new class PackLinuxElf32arm : PackLinuxElf32Le;
Unify some functions in leaf classes by moving to parent class.
2006-06-01 06:37:44 -07:00
John Reiser 5326260a76 new elf32arm; small effects in elf86, linux.hh 2006-06-01 06:32:33 -07:00
John Reiser e7522f4bdf branch merge 2006-05-24 13:59:43 -07:00
John Reiser 504deeff42 ET_DYN cannot be old format for decompression 2006-05-24 13:15:39 -07:00
Markus F.X.J. Oberhumer b7785b64cf Small cleanups to keep p_armpe & p_w32pe in sync. 2006-05-24 19:21:26 +02:00
László Molnár f914cb6858 pe: added support for empty resource section 2006-05-24 17:14:09 +02:00
John Reiser 91051d2521 Try to merge with mainline. 2006-05-23 17:52:05 -07:00
John Reiser 51536a7acd decompression PackLinuxElf32x86.ET_DYN 2006-05-23 17:42:35 -07:00
Markus F.X.J. Oberhumer 263ccab6e3 Updated NEWS for --brute bugfix. 2006-05-23 13:25:19 +02:00
John Reiser 9f87755dcb Note fix to --force-execve for PaX, grSecurity, strict SELinux. 2006-05-22 15:15:21 -07:00
John Reiser 60b4cca5e5 use powerpc-750-linux-gnu/gcc-3.4.3.20050210-glibc-2.2.5 2006-05-22 13:14:54 -07:00
John Reiser d2718e99a4 Change class PackLinuxI386elf : public PackLinuxI386
into   class PackLinuxElf32x86 : public PackLinuxElf32Le : public PackLinuxElf32
which makes the code for compressing ELF (for direct-to-memory decompression)
cleaner because ELF has some of the class tree to itself.
This assumes PROT_EXEC|PROT_WRITE ought to work.
This is checked at runtime, and if it fails then
give a message on stderr and exit(127).

Modify --force-execve so that runtime avoids PROT_EXEC|PROT_WRITE.
Then executables compressed with --force-execve will run under
PaX, grSecurity, and strict SELinux.
2006-05-21 13:58:24 -07:00
John Reiser 69a00c0ab3 *BSD requires -1==fd for MAP_ANONYMOUS
stub/l_lx_exec.c stub/l_lx_sh.c stub/l_lx_sh86.asm
2006-05-21 13:45:57 -07:00
Markus F.X.J. Oberhumer 3272d23917 Renamed variable hdr_clen to hdr_c_len. 2006-05-20 13:44:36 +02:00
Markus F.X.J. Oberhumer 7f0545cae7 Check result of hdr compression. 2006-05-20 13:37:34 +02:00
Markus F.X.J. Oberhumer 68f35deb86 Fixed a rare boundary problem in Packer::compressWithFilters().
The comparision if an update might be possible later was using
"<" instead of "<=" which resulted in missing calls to
findOverlapOverhead() and buildLoader().

Also, the comparision had not been updated for the newly added
hdr_clen fields.

This fixes sf.net bug #1477825.
2006-05-20 13:29:01 +02:00
Markus F.X.J. Oberhumer c4f4035072 Updated NEWS. 2006-05-18 19:01:03 +02:00
László Molnár a7d8845952 mention --keep-resource in NEWS and help.cpp 2006-05-18 15:54:35 +02:00
Markus F.X.J. Oberhumer a3378393b0 Removed scripts/. 2006-05-18 15:35:35 +02:00
László Molnár 3dfe0ad478 pe: fined grain control over resource compression 2006-05-18 15:20:37 +02:00
László Molnár 9a3b7a4f3f arm/pe: really fix the memory leak 2006-05-18 15:20:11 +02:00
László Molnár 78579b1103 pe: do not crash on out of bounds bogus relocation records 2006-05-18 15:19:55 +02:00
László Molnár 7d50344512 pe: fixed a memory leak in the resource handling code 2006-05-18 15:19:13 +02:00
László Molnár 7a00c12065 arm/pe: minor cleanup in the thumb mode stub 2006-05-18 15:18:50 +02:00
László Molnár af71e67681 arm/pe: saved 4 bytes in the arm mode stub 2006-05-18 15:18:36 +02:00
László Molnár b3e20fc324 arm/pe: no need to try to precompute the size of relocations 2006-05-18 15:18:13 +02:00
László Molnár bd1014abb6 dos/exe: saved some bytes in device driver mode 2006-05-18 15:17:53 +02:00
László Molnár 7f76664a5d Merged with mainline 2006-05-18 13:10:15 +02:00
Markus F.X.J. Oberhumer 0a5a80b05d Updated .hgignore. 2006-05-18 10:48:06 +02:00
Markus F.X.J. Oberhumer 2d63da0660 Support automatic ChangeLog generation. 2006-05-18 10:16:59 +02:00
Markus F.X.J. Oberhumer 8387527d2e Updated .hgignore. 2006-05-18 09:37:18 +02:00
Markus F.X.J. Oberhumer 5d03ba7d63 Added .hgignore. 2006-05-18 09:08:38 +02:00
Markus F.X.J. Oberhumer 0ece50c122 Removed .cvsignore and .gitignore files. 2006-05-18 09:02:00 +02:00
Markus F.X.J. Oberhumer f2ac297252 Updated tags. 2006-05-18 08:27:19 +02:00
László Molnár 0ca8ae17d4 updated my email address 2006-05-17 21:05:46 +02:00
convert-repo 88ca87cf9e update tags 2006-05-11 10:41:33 +00:00
László Molnár 0d69d228e4 arm/pe: no need to allocate extra memory in the import table
committer: ml1050 <ml1050> 1147090379 +0000
2006-05-08 12:12:59 +00:00
Markus F.X.J. Oberhumer a3afe95306 Updated NEWS.
committer: mfx <mfx> 1147081195 +0000
2006-05-08 09:39:55 +00:00
Markus F.X.J. Oberhumer 9fb4af8658 Updated Makefile.
committer: mfx <mfx> 1147081156 +0000
2006-05-08 09:39:16 +00:00
László Molnár 9bb6ba9311 dos/exe: device driver support added (thanks Michael Devore)
committer: ml1050 <ml1050> 1147078121 +0000
2006-05-08 08:48:41 +00:00
Markus F.X.J. Oberhumer faa42ba341 Updated the master Makefile
to be more friendly to people without the special stub build tools.

committer: mfx <mfx> 1146764116 +0000
2006-05-04 17:35:16 +00:00
László Molnár 596827a912 remove obsolete files: l_armpe.asm l_armpe.h l_armpe_c.c l_armpe_s.S
committer: ml1050 <ml1050> 1146763209 +0000
2006-05-04 17:20:09 +00:00
László Molnár 89b4292445 saved 2 bytes
committer: ml1050 <ml1050> 1146763076 +0000
2006-05-04 17:17:56 +00:00
László Molnár dd88737414 it works on wince now (only with dlls)
committer: ml1050 <ml1050> 1146763013 +0000
2006-05-04 17:16:53 +00:00
László Molnár 5456cfc304 arm/pe: use the new linker friendly stubs
two linkers: one for arm mode, one for thumb mode
the import address table is moved to the stubs area of compressed files
changed the alignment of some header fields
the command line option "--8086" can be used to force thumb mode on

committer: ml1050 <ml1050> 1146647520 +0000
2006-05-03 09:12:00 +00:00
László Molnár 1e66096ea7 arm/pe stubs: the import address table is moved to the stub
committer: ml1050 <ml1050> 1146646915 +0000
2006-05-03 09:01:55 +00:00
John Reiser 2b6ae3908c /usr/bin/dyld can be a "fat binary" [how stupid!]
m_mac_mach32.c fold_machppc32.S fold_machppc32.h

committer: jreiser <jreiser> 1146434013 +0000
2006-04-30 21:53:33 +00:00
László Molnár 1924612479 a small fix for the thumb stub
committer: ml1050 <ml1050> 1146224685 +0000
2006-04-28 11:44:45 +00:00
László Molnár 2af5bdeaab added some debugging code
committer: ml1050 <ml1050> 1146154452 +0000
2006-04-27 16:14:12 +00:00
László Molnár b28565b38d new files: l_armpea.h l_armpet.h
committer: ml1050 <ml1050> 1146154411 +0000
2006-04-27 16:13:31 +00:00
László Molnár fec602362b added new virtual function createLinker()
committer: ml1050 <ml1050> 1146153290 +0000
2006-04-27 15:54:50 +00:00
László Molnár 6753c5f45a trying to implement the user space loader on native wince
committer: ml1050 <ml1050> 1146152386 +0000
2006-04-27 15:39:46 +00:00
Markus F.X.J. Oberhumer 2f3c108d42 Next version will be 2.01.
committer: mfx <mfx> 1146140843 +0000
2006-04-27 12:27:23 +00:00
Markus F.X.J. Oberhumer ce6d99bdb4 More README updates.
committer: mfx <mfx> 1146086335 +0000
2006-04-26 21:18:55 +00:00
Markus F.X.J. Oberhumer 86d4125893 Updates.
committer: mfx <mfx> 1146086189 +0000
2006-04-26 21:16:29 +00:00
Markus F.X.J. Oberhumer 3a18f00379 Prepared 2.00 release notes.
committer: mfx <mfx> 1146085621 +0000
2006-04-26 21:07:01 +00:00
Markus F.X.J. Oberhumer e6274904a7 Rebuilt using i386-linux-ld-2.16.1 and i386-linux-objcopy-2.16.1.
committer: mfx <mfx> 1146079399 +0000
2006-04-26 19:23:19 +00:00
Markus F.X.J. Oberhumer 3677395444 Add version suffix to the binutils we use. Prefix all linux/386 tools
with i386-linux-.

committer: mfx <mfx> 1146079325 +0000
2006-04-26 19:22:05 +00:00
László Molnár 22ba35b3b5 new arm/pe assembly with UPX linker support
committer: ml1050 <ml1050> 1145955479 +0000
2006-04-25 08:57:59 +00:00
Markus F.X.J. Oberhumer 9c1ab9979b Split "$Id" strings so that CVS does not interfere. Explicitlty
use ".p2align" and ".balign" instead of ".align".

committer: mfx <mfx> 1145864788 +0000
2006-04-24 07:46:28 +00:00
John Reiser eaa463e1c9 Insert copyright notice (equivalent to ident_s.ash) into stub by hand
because buildLoader is not fully working yet
	l_lx_elf64amd.S l_lx_elfppc32.S l_mac_ppc32.S

committer: jreiser <jreiser> 1145825498 +0000
2006-04-23 20:51:38 +00:00
John Reiser 6984be48c3 build sync: compile using crosstool gcc-3.4.3.20050507-glibc-2.3.5
committer: jreiser <jreiser> 1145820281 +0000
2006-04-23 19:24:41 +00:00
John Reiser b739bd3d79 Work better with SELinux. We still require allow_execmem.
p_lx_elf.cpp
	stub/fold_elfppc32.h
	stub/l_lx_elfppc32.h
	stub/l_lx_elfppc32.S
	stub/m_lx_elfppc32.c

committer: jreiser <jreiser> 1145666524 +0000
2006-04-22 00:42:04 +00:00
John Reiser 23f3e4396c For elf64and and elfppc32: -fno-exceptions -fno-asynchronous-unwind-tables
committer: jreiser <jreiser> 1145666377 +0000
2006-04-22 00:39:37 +00:00
John Reiser c264750924 Adapt better to SELinux. We still need allow_execmem.
p_lx_elf.cpp
	stub/a_lx_elf64.c
	stub/l_lx_elf64amd.h
	stub/l_lx_elf64amd.lds
	stub/l_lx_elf64amd.S
	stub/fold_elf64amd.h

committer: jreiser <jreiser> 1145657332 +0000
2006-04-21 22:08:52 +00:00
John Reiser c155f0a5d5 Better fit with SELinux. Now requires only execmem, which Fedora Core 5
enables as default for non-confined [ordinary] executables.
	l_lx_elf.c
	l_lx_elf86.asm
	l_lx_elf86.h
	l_lx_elf86.lds
	fold_elf86.asm
	fold_elf86.h

committer: jreiser <jreiser> 1145634453 +0000
2006-04-21 15:47:33 +00:00
László Molnár 76734f086d added an arm/linux based loader/tester for arm/pe files
committer: ml1050 <ml1050> 1145605029 +0000
2006-04-21 07:37:09 +00:00
Markus F.X.J. Oberhumer 4f2d1172dd Added a note about --force-execve. Converted quoting from using
backticks to single-quotes.

committer: mfx <mfx> 1145444708 +0000
2006-04-19 11:05:08 +00:00
Markus F.X.J. Oberhumer 75caf4e297 Fix spelling in NEWS.
committer: mfx <mfx> 1145436378 +0000
2006-04-19 08:46:18 +00:00
Markus F.X.J. Oberhumer 509ab8261f Avoid code bloat in the official builds.
committer: mfx <mfx> 1145436321 +0000
2006-04-19 08:45:21 +00:00
Markus F.X.J. Oberhumer 1e05b40d4f Whitespace changes.
committer: mfx <mfx> 1145436164 +0000
2006-04-19 08:42:44 +00:00
Markus F.X.J. Oberhumer 451390f835 Updated NEWS.
committer: mfx <mfx> 1145435924 +0000
2006-04-19 08:38:44 +00:00
John Reiser 58cce9d2f8 Give message on stderr when SELinux enforcing mode inhibits execution.
l_lx_elf.c fold_elf86.asm fold_elf86.h

committer: jreiser <jreiser> 1145393418 +0000
2006-04-18 20:50:18 +00:00
László Molnár 2eb6e3b0ea arm/pe & w32/pe: disable filters for files with broken headers
committer: ml1050 <ml1050> 1145356307 +0000
2006-04-18 10:31:47 +00:00
John Reiser fb1181ed26 Allow executables >=3MB on elf64amd; -r1.69 on 2005-11-12 forgot to remove check.
committer: jreiser <jreiser> 1145139994 +0000
2006-04-15 22:26:34 +00:00
Markus F.X.J. Oberhumer 6d5e1d529d Updated NEWS.
committer: mfx <mfx> 1144968512 +0000
2006-04-13 22:48:32 +00:00
John Reiser 0e0ca08924 Propagate changes from linux.hh.
fold_elf86.h fold_pti86.h fold_sh86.h

committer: jreiser <jreiser> 1144967510 +0000
2006-04-13 22:31:50 +00:00
John Reiser 5d948a67a8 Propagate changes from linux.hh.
Also adjust calling segquence of upx_main() to shave a few bytes.
	l_lx_exec.c fold_exec86.asm fold_exec86.h

committer: jreiser <jreiser> 1144967447 +0000
2006-04-13 22:30:47 +00:00
John Reiser 6a4db2ecab Linux syscalls can clobber any input register, thanks to gcc and
the lack of a Linux kernel ABI.
	linux.hh

committer: jreiser <jreiser> 1144967342 +0000
2006-04-13 22:29:02 +00:00
Markus F.X.J. Oberhumer f700273624 Really bump the release date.
committer: mfx <mfx> 1144944628 +0000
2006-04-13 16:10:28 +00:00
Markus F.X.J. Oberhumer 0c198e0ccc Set tentative release date.
committer: mfx <mfx> 1144944070 +0000
2006-04-13 16:01:10 +00:00
Markus F.X.J. Oberhumer 71ffbbc420 Prepared 1.96 release.
committer: mfx <mfx> 1144943500 +0000
2006-04-13 15:51:40 +00:00
Markus F.X.J. Oberhumer 4fd09b889d Updated .cvsignore.
committer: mfx <mfx> 1144943334 +0000
2006-04-13 15:48:54 +00:00
László Molnár 4cb2a3eebe show image size change in info mode
committer: ml1050 <ml1050> 1144941392 +0000
2006-04-13 15:16:32 +00:00
László Molnár c25186b1f6 minor documentation updates
committer: ml1050 <ml1050> 1144941274 +0000
2006-04-13 15:14:34 +00:00
László Molnár 779033d0bc added filter (id: 0x50) support to the stub
the data cache is written back before the stub jumps to the uncompressed code

committer: ml1050 <ml1050> 1144931349 +0000
2006-04-13 12:29:09 +00:00
László Molnár 3e31560e7d added a new filter for ARM 24-bit naive calltrick
committer: ml1050 <ml1050> 1144931022 +0000
2006-04-13 12:23:42 +00:00
László Molnár d23d7e8775 removed unneeded entry point address check
committer: ml1050 <ml1050> 1144745835 +0000
2006-04-11 08:57:15 +00:00
László Molnár f6fdf5cb7f show image size change in info mode
committer: ml1050 <ml1050> 1144671675 +0000
2006-04-10 12:21:15 +00:00
Markus F.X.J. Oberhumer 1879ccd27d Next version will be 2.00.
committer: mfx <mfx> 1144586292 +0000
2006-04-09 12:38:12 +00:00
Markus F.X.J. Oberhumer 08c0796719 Avoid warnings when building for m68k.
committer: mfx <mfx> 1144523702 +0000
2006-04-08 19:15:02 +00:00
Markus F.X.J. Oberhumer edc7994ce5 Prepared 1.95 release.
committer: mfx <mfx> 1144522884 +0000
2006-04-08 19:01:24 +00:00
Markus F.X.J. Oberhumer bcfcfbd064 Added some more operators.
committer: mfx <mfx> 1144522838 +0000
2006-04-08 19:00:38 +00:00
Markus F.X.J. Oberhumer 9e79b3258d Make const-correct to avoid warning.
committer: mfx <mfx> 1144522792 +0000
2006-04-08 18:59:52 +00:00
John Reiser 243873cd2d Workaround inconsistent SIZEOF_HEADERS in stub/*.lds.
Test with --force-execve and --no-filter.
	p_lx_exc.cpp p_lx_sh.cpp stub/l_lx_sh86.asm stub/l_lx_sh86.h

committer: jreiser <jreiser> 1144381286 +0000
2006-04-07 03:41:26 +00:00
Markus F.X.J. Oberhumer c7b8a4b0c1 Updated.
committer: mfx <mfx> 1144320028 +0000
2006-04-06 10:40:28 +00:00
Markus F.X.J. Oberhumer e39e0c7140 Added .gitignore files.
committer: mfx <mfx> 1144319429 +0000
2006-04-06 10:30:29 +00:00
Markus F.X.J. Oberhumer d4a3f11dbb Whitespace changes.
committer: mfx <mfx> 1144318755 +0000
2006-04-06 10:19:15 +00:00
Markus F.X.J. Oberhumer 0962f266b3 Whitespace changes.
committer: mfx <mfx> 1144314053 +0000
2006-04-06 09:00:53 +00:00
Markus F.X.J. Oberhumer 69e4d3fdad Bumped tentative release date.
committer: mfx <mfx> 1144313563 +0000
2006-04-06 08:52:43 +00:00
Markus F.X.J. Oberhumer c0908f463a Added files to "clean" target.
committer: mfx <mfx> 1144313493 +0000
2006-04-06 08:51:33 +00:00
Markus F.X.J. Oberhumer b00a61a17b Updated.
committer: mfx <mfx> 1144313468 +0000
2006-04-06 08:51:08 +00:00
László Molnár 553c2f886a arm/pe: thumb mode dll support added
committer: ml1050 <ml1050> 1144312217 +0000
2006-04-06 08:30:17 +00:00
László Molnár 4fd9c5772a arm/pe:
v4 ARM mode stub support with assembly decompressor by John
dll support for v4 ARM mode
unpacking support

committer: ml1050 <ml1050> 1144249762 +0000
2006-04-05 15:09:22 +00:00
Markus F.X.J. Oberhumer 04e0e06d85 Whitespace changes.
committer: mfx <mfx> 1144235344 +0000
2006-04-05 11:09:04 +00:00
Markus F.X.J. Oberhumer 4d7829d72b New ACC version.
committer: mfx <mfx> 1144235271 +0000
2006-04-05 11:07:51 +00:00
John Reiser 6b751aac57 Fix return from THUMB to ARM mode on ARMv4T. Document r6 unused.
committer: jreiser <jreiser> 1143650112 +0000
2006-03-29 16:35:12 +00:00
László Molnár 813349fd23 arm/pe: support for nrv2b, support for cpu = 0x1c2, certificate info now removed
committer: ml1050 <ml1050> 1143614738 +0000
2006-03-29 06:45:38 +00:00
John Reiser 16a2744782 find_SEGMENT_gap() like find_LOAD_gap(). Use it to avoid checksum trouble.
p_mach.cpp p_mach.h

committer: jreiser <jreiser> 1143576015 +0000
2006-03-28 20:00:15 +00:00
John Reiser 7b6870db22 Fix bug: bad test for reaching back too far in SAFE mode. (Thank you, Laszlo.)
committer: jreiser <jreiser> 1143564998 +0000
2006-03-28 16:56:38 +00:00
Markus F.X.J. Oberhumer 3e38e7d52c Small cleanups.
committer: mfx <mfx> 1143474969 +0000
2006-03-27 15:56:09 +00:00
László Molnár 8142d3474d get_le32 reimplemented in assembly
committer: ml1050 <ml1050> 1143473260 +0000
2006-03-27 15:27:40 +00:00
Markus F.X.J. Oberhumer 8773649de6 Make code warning-free.
committer: mfx <mfx> 1143464312 +0000
2006-03-27 12:58:32 +00:00
Markus F.X.J. Oberhumer c117920ff9 Add -Wall -Werror to cross-compiler flags.
committer: mfx <mfx> 1143463128 +0000
2006-03-27 12:38:48 +00:00
László Molnár c8dd2a3eb8 arm/pe: use -march=armv4t instead of v5
committer: ml1050 <ml1050> 1143462067 +0000
2006-03-27 12:21:07 +00:00
Markus F.X.J. Oberhumer 90b1817e92 Undef PAGE_{MASK,SIZE} in conf.h.
committer: mfx <mfx> 1143454717 +0000
2006-03-27 10:18:37 +00:00
Markus F.X.J. Oberhumer d6c3ff5997 Cleanups.
committer: mfx <mfx> 1143454663 +0000
2006-03-27 10:17:43 +00:00
László Molnár 984ec25132 arm/pe: the assembly thumb mode decompressor is used in the stub
arm/pe: the C part of the stub is compiled as thumb

committer: ml1050 <ml1050> 1143449862 +0000
2006-03-27 08:57:42 +00:00
John Reiser a7bff34784 Fix THUMB mode return to ARM mode on ARMv4T. Spend 18 bytes to inline
most of get1b via conditional subroutine call idiom.

committer: jreiser <jreiser> 1143302120 +0000
2006-03-25 15:55:20 +00:00
John Reiser a6e7afbc91 Fix bug: first 'add' instead of 'adc' at get1_n2b. (Thank you, Laszlo.)
committer: jreiser <jreiser> 1143228535 +0000
2006-03-24 19:28:55 +00:00
John Reiser 33f1d63b64 Fix bug: first 'add' at get1_n2e instead of 'adc'.
Also conditionally assemble SAFE mode for buffer checking (default off).

committer: jreiser <jreiser> 1143228361 +0000
2006-03-24 19:26:01 +00:00
John Reiser f95e171e11 Workaround linux-2.6.14 binfmt_elf.c: SIGKILL if (0==.p_memsz) on a page boundary.
p_lx_elf.cpp p_lx_exc.cpp

committer: jreiser <jreiser> 1143057770 +0000
2006-03-22 20:02:50 +00:00
Markus F.X.J. Oberhumer c82b50b212 Bumped tentative release date.
committer: mfx <mfx> 1142610024 +0000
2006-03-17 15:40:24 +00:00
Markus F.X.J. Oberhumer 2b402b77f1 Updated short-list of supported executable formats.
committer: mfx <mfx> 1142609852 +0000
2006-03-17 15:37:32 +00:00
Markus F.X.J. Oberhumer adcb551020 Increase alignment to 16.
committer: mfx <mfx> 1142608657 +0000
2006-03-17 15:17:37 +00:00
Markus F.X.J. Oberhumer 2680aabe06 Removed bogus __attribute_packed from struct udll.
committer: mfx <mfx> 1142607440 +0000
2006-03-17 14:57:20 +00:00
Markus F.X.J. Oberhumer d5c0533b74 Allow the PE sections to cross a page boundary.
committer: mfx <mfx> 1142603590 +0000
2006-03-17 13:53:10 +00:00
Markus F.X.J. Oberhumer 609307668b Use $(MAKEFILE_LIST) for dependencies.
committer: mfx <mfx> 1142527291 +0000
2006-03-16 16:41:31 +00:00
Markus F.X.J. Oberhumer cdaf36572a Use UPX_VERSION_DATE_ISO from src/version.h.
committer: mfx <mfx> 1142527194 +0000
2006-03-16 16:39:54 +00:00
Markus F.X.J. Oberhumer 033c8d5d51 Updated.
committer: mfx <mfx> 1142523608 +0000
2006-03-16 15:40:08 +00:00
Markus F.X.J. Oberhumer 6216ec1d6a Mention John as a main author.
committer: mfx <mfx> 1142522272 +0000
2006-03-16 15:17:52 +00:00
László Molnár 6c9c67f6c5 DEP hack: it seems we need to patch the flags of section "UPX1" too
committer: ml1050 <ml1050> 1142508181 +0000
2006-03-16 11:23:01 +00:00
Markus F.X.J. Oberhumer 5bd32b5521 Commented out "int3" debugging leftovers.
committer: mfx <mfx> 1142312678 +0000
2006-03-14 05:04:38 +00:00
Markus F.X.J. Oberhumer 549336f75b Use boolean instead of bitwise logic.
committer: mfx <mfx> 1142311485 +0000
2006-03-14 04:44:45 +00:00
Markus F.X.J. Oberhumer f0e75f30b3 Fixed typo in comment.
committer: mfx <mfx> 1142310885 +0000
2006-03-14 04:34:45 +00:00
Markus F.X.J. Oberhumer 144c09f175 Rebuilt i386-linux stubs by gcc-3.4.6.
committer: mfx <mfx> 1142310823 +0000
2006-03-14 04:33:43 +00:00
Markus F.X.J. Oberhumer ee50c0f97c Corrected app_*.pl dependency.
committer: mfx <mfx> 1142309988 +0000
2006-03-14 04:19:48 +00:00
John Reiser ade921bf02 %.asy and %.asx depend onf $(APP_I386)
committer: jreiser <jreiser> 1142306625 +0000
2006-03-14 03:23:45 +00:00
John Reiser 676cacff04 gcc-4.1.0 vs. mmap()
linux.hh
	fold_elf86.asm  l_lx_elf.c
	fold_exec86.asm l_lx_exec.c
	fold_pti86.asm  l_lx_pti.c
	fold_sh86.asm   l_lx_sh.c    l_lx_sh86.asm
	l_lx_sep.c

committer: jreiser <jreiser> 1142305438 +0000
2006-03-14 03:03:58 +00:00
Markus F.X.J. Oberhumer a3097d5e25 Added a dependency.
committer: mfx <mfx> 1142303569 +0000
2006-03-14 02:32:49 +00:00
Markus F.X.J. Oberhumer fd78148558 Fixed typo in disabled code.
committer: mfx <mfx> 1142302679 +0000
2006-03-14 02:17:59 +00:00
Markus F.X.J. Oberhumer a4d79d7375 Small cosmetic changes.
committer: mfx <mfx> 1142302586 +0000
2006-03-14 02:16:26 +00:00
Markus F.X.J. Oberhumer df04e8183d Filter parameters should be called "ft" instead of "fp".
committer: mfx <mfx> 1142301730 +0000
2006-03-14 02:02:10 +00:00
Markus F.X.J. Oberhumer c43c484a62 Re-synced both files a little bit.
committer: mfx <mfx> 1142301586 +0000
2006-03-14 01:59:46 +00:00
Markus F.X.J. Oberhumer 0608c35669 Added some more OBJSTRIP. Small cleanups.
committer: mfx <mfx> 1142298790 +0000
2006-03-14 01:13:10 +00:00
Markus F.X.J. Oberhumer 7dd4d06e26 Added some more calls to $(OBJSTRIP_LINUX_I386) after $(NASM) invocations.
committer: mfx <mfx> 1142288478 +0000
2006-03-13 22:21:18 +00:00
John Reiser 1ee0310b86 silence complaint from ld "cannot find entry symbol _start; defaulting to 10000000"
committer: jreiser <jreiser> 1142285749 +0000
2006-03-13 21:35:49 +00:00
Markus F.X.J. Oberhumer cc0a52038f Rebuilt i386-linux stubs with gcc-4.1.0 for small size decrease.
committer: mfx <mfx> 1142248018 +0000
2006-03-13 11:06:58 +00:00
Markus F.X.J. Oberhumer 6aed1fe231 Updated.
committer: mfx <mfx> 1142247976 +0000
2006-03-13 11:06:16 +00:00
Markus F.X.J. Oberhumer 680608fe18 Portability fix.
committer: mfx <mfx> 1142247872 +0000
2006-03-13 11:04:32 +00:00
Markus F.X.J. Oberhumer ec6acbc602 Small fix to make valid ANSI C again.
committer: mfx <mfx> 1142247837 +0000
2006-03-13 11:03:57 +00:00
John Reiser cb7ee4c5d2 _syscall1nr() for _exit; [still wastes 4 bytes]
committer: jreiser <jreiser> 1142210712 +0000
2006-03-13 00:45:12 +00:00
Markus F.X.J. Oberhumer 88d5798f45 Bumped versions for starting 1.95 development.
committer: mfx <mfx> 1142090576 +0000
2006-03-11 15:22:56 +00:00
Markus F.X.J. Oberhumer fcc22a0aa3 Added UPX_VERSION_DATE_ISO.
committer: mfx <mfx> 1142085195 +0000
2006-03-11 13:53:15 +00:00
Markus F.X.J. Oberhumer aabefff298 Prepared for release 1.94.
committer: mfx <mfx> 1142081862 +0000
2006-03-11 12:57:42 +00:00
Markus F.X.J. Oberhumer ed25c64e97 Updated.
committer: mfx <mfx> 1142081797 +0000
2006-03-11 12:56:37 +00:00
Markus F.X.J. Oberhumer b7dc870c2d Centered strings.
committer: mfx <mfx> 1142081776 +0000
2006-03-11 12:56:16 +00:00
Markus F.X.J. Oberhumer 9bea608843 Don't suppress errors with -qq.
committer: mfx <mfx> 1142081041 +0000
2006-03-11 12:44:01 +00:00
Markus F.X.J. Oberhumer 9db1732c36 Added a note that we should upgrade to gcc-4.1.0 on i386-linux.
committer: mfx <mfx> 1142074774 +0000
2006-03-11 10:59:34 +00:00
Markus F.X.J. Oberhumer 39f1a70174 Small update.
committer: mfx <mfx> 1142036155 +0000
2006-03-11 00:15:55 +00:00
Markus F.X.J. Oberhumer 1810440355 Added __attribute__((__sentinel__)) to Packer::addLoader(). This is
a new gcc-4.1 feature.

committer: mfx <mfx> 1142035833 +0000
2006-03-11 00:10:33 +00:00
Markus F.X.J. Oberhumer 37ac8f179e New ACC version.
committer: mfx <mfx> 1142035385 +0000
2006-03-11 00:03:05 +00:00
Markus F.X.J. Oberhumer 626a09328f Updated.
committer: mfx <mfx> 1141807336 +0000
2006-03-08 08:42:16 +00:00
Markus F.X.J. Oberhumer 8d489d0d77 New ACC version.
committer: mfx <mfx> 1141798968 +0000
2006-03-08 06:22:48 +00:00
Markus F.X.J. Oberhumer 776f3db0d7 Detabified.
committer: mfx <mfx> 1141795978 +0000
2006-03-08 05:32:58 +00:00
John Reiser 6046057b88 Commentary on SELinux and UPX.
committer: jreiser <jreiser> 1141686040 +0000
2006-03-06 23:00:40 +00:00
Markus F.X.J. Oberhumer 7e85d9e549 Updated.
committer: mfx <mfx> 1141679044 +0000
2006-03-06 21:04:04 +00:00
Markus F.X.J. Oberhumer 01c8a8b1c2 Disabled an expensive run-time assertion.
committer: mfx <mfx> 1141642878 +0000
2006-03-06 11:01:18 +00:00
Markus F.X.J. Oberhumer c9bf6ac9ae No need to preserve eax in clearstack.
committer: mfx <mfx> 1141642647 +0000
2006-03-06 10:57:27 +00:00
John Reiser 62e4d69be9 re-compile from changed m_lx_elfppc32.c
committer: jreiser <jreiser> 1141605710 +0000
2006-03-06 00:41:50 +00:00
John Reiser 62ac733b09 simplify and save a few bytes
committer: jreiser <jreiser> 1141488398 +0000
2006-03-04 16:06:38 +00:00
John Reiser c3b3e1b1b9 MAP_DENYWRITE
committer: jreiser <jreiser> 1141484579 +0000
2006-03-04 15:02:59 +00:00
John Reiser a791e96e00 Fix do_xmap() to work under SElinux. Also trim unneeded code.
committer: jreiser <jreiser> 1141413353 +0000
2006-03-03 19:15:53 +00:00
John Reiser e87f5521c1 conditionally compile debugging printf
committer: jreiser <jreiser> 1141365595 +0000
2006-03-03 05:59:55 +00:00
John Reiser 366a708f3a Generalize to more than 2 PT_LOAD using find_LOAD_gap; needed for linux/ElfAMD.
Also simplifies, and applies to both ::pack and ::unpack.
	p_lx_elf.cpp p_lx_elf.h

committer: jreiser <jreiser> 1141348876 +0000
2006-03-03 01:21:16 +00:00
John Reiser 70ba662574 Avoid overwrite of obuf when hdr_buf and non-first method.
committer: jreiser <jreiser> 1141327368 +0000
2006-03-02 19:22:48 +00:00
John Reiser b389abd99f PackLinuxElf64amd::getCompressionMethods allows both nrv2b and nrv2e
committer: jreiser <jreiser> 1141326792 +0000
2006-03-02 19:13:12 +00:00
John Reiser 4aa2d14fe3 acknowledge unused results to avoid compiler warnings treated as errors
committer: jreiser <jreiser> 1141326721 +0000
2006-03-02 19:12:01 +00:00
John Reiser af7de75ad4 Allow unfilter when verifyOverlappingDecompression, for convenience
in end-to-end checksum.
	packer.h packer.cpp p_unix.cpp

committer: jreiser <jreiser> 1141252960 +0000
2006-03-01 22:42:40 +00:00
John Reiser d461ebbda1 fix packExtent checksums and lengths (of uncompressed data) for 0!=hdr_ulen
committer: jreiser <jreiser> 1141241763 +0000
2006-03-01 19:36:03 +00:00
John Reiser 55ef94abcd 8-bit decompressors for ARM; minimize space aggressively
arm_nrv2b_d8.S arm_nrv2e_d8.S

committer: jreiser <jreiser> 1140993873 +0000
2006-02-26 22:44:33 +00:00
John Reiser afaf489d99 save space aggressively
committer: jreiser <jreiser> 1140713717 +0000
2006-02-23 16:55:17 +00:00
John Reiser 20e4cbfd13 passes first tests! Only untested feature: large offset which forces
minimum match length to be >=3.
	arm_nrv2b_d32.S arm_nrv2e_d32.S

committer: jreiser <jreiser> 1140677145 +0000
2006-02-23 06:45:45 +00:00
John Reiser f3b8c9f34e debugging
committer: jreiser <jreiser> 1140634679 +0000
2006-02-22 18:57:59 +00:00
John Reiser 45e8ff25a5 hand-tuned decompressors for 32-bit NRV on ARM
arm_nrv2b_d32.S arm_nrv2e_d32.S

committer: jreiser <jreiser> 1140535945 +0000
2006-02-21 15:32:25 +00:00
John Reiser 268e322e1c Extra parameter for compressWithFilters and packExtent,
to fix 2-pass problem with --brute on linux/elf386.
Only one decompression method is allowed, chosen by
smallest output for .text; but Elf headers come first.
	packer.cpp packer.h p_unix.cpp p_unix.h p_lx_elf.cpp

committer: jreiser <jreiser> 1140241030 +0000
2006-02-18 05:37:10 +00:00
Markus F.X.J. Oberhumer d3bcba6a05 Removed "volatile" from global var "opt" - this was only needed
a long time ago to work around problems with ancient C++ compilers.

committer: mfx <mfx> 1140002094 +0000
2006-02-15 11:14:54 +00:00
Markus F.X.J. Oberhumer cc4ef1944d Make sure we only touch exactly one page. Update comments.
committer: mfx <mfx> 1139928961 +0000
2006-02-14 14:56:01 +00:00
Markus F.X.J. Oberhumer 5aa8486265 Prefer restoring the original protection flags.
committer: mfx <mfx> 1139928517 +0000
2006-02-14 14:48:37 +00:00
László Molnár fd181673cd a little more comments on the DEP hack stuff
committer: ml1050 <ml1050> 1139927444 +0000
2006-02-14 14:30:44 +00:00
László Molnár 62c9547c4e added some comments on the DEP hack stuff
committer: ml1050 <ml1050> 1139918135 +0000
2006-02-14 11:55:35 +00:00
Markus F.X.J. Oberhumer cdd117bfb9 Rearranged debug options.
committer: mfx <mfx> 1139916141 +0000
2006-02-14 11:22:21 +00:00
Markus F.X.J. Oberhumer 304ba57dad Clear the dirty stack on win32/pe.
committer: mfx <mfx> 1139914965 +0000
2006-02-14 11:02:45 +00:00
Markus F.X.J. Oberhumer 69eaaa4177 Revert previous checkin.
committer: mfx <mfx> 1139914479 +0000
2006-02-14 10:54:39 +00:00
Markus F.X.J. Oberhumer 452ac52fcb Added an overloaded addLoader() method.
committer: mfx <mfx> 1139913550 +0000
2006-02-14 10:39:10 +00:00
Markus F.X.J. Oberhumer 40cf489290 Avoid possibly clobbering edx.
committer: mfx <mfx> 1139881592 +0000
2006-02-14 01:46:32 +00:00
Markus F.X.J. Oberhumer 891d6be4a6 Removed options_t::win32_pe::strip_loadconf.
For compatibility reasons the option is still accepted (but
ignored) during commandline parsing.

committer: mfx <mfx> 1139866279 +0000
2006-02-13 21:31:19 +00:00
Markus F.X.J. Oberhumer 5d45ce5cf7 Removed an already fixed item.
committer: mfx <mfx> 1139864523 +0000
2006-02-13 21:02:03 +00:00
Markus F.X.J. Oberhumer a0f2241f3a Added comment.
committer: mfx <mfx> 1139862668 +0000
2006-02-13 20:31:08 +00:00
Markus F.X.J. Oberhumer aa513bf7d3 Quick fix for the Win32 startup crash. Needs more testing.
committer: mfx <mfx> 1139861398 +0000
2006-02-13 20:09:58 +00:00
Markus F.X.J. Oberhumer b2d65febc8 Small update.
committer: mfx <mfx> 1139843847 +0000
2006-02-13 15:17:27 +00:00
Markus F.X.J. Oberhumer 23a6d326e8 Bump tentative release date. Update READMEs.
committer: mfx <mfx> 1139840129 +0000
2006-02-13 14:15:29 +00:00
Markus F.X.J. Oberhumer 5b2f1b6d8b Introduced UPX_VERSION_YEAR.
committer: mfx <mfx> 1139826163 +0000
2006-02-13 10:22:43 +00:00
Markus F.X.J. Oberhumer b4e9ad031b Break strings so that CVS does not try to expand keywords.
committer: mfx <mfx> 1139786765 +0000
2006-02-12 23:26:05 +00:00
Markus F.X.J. Oberhumer 8b7ebcf040 Enter 2006.
committer: mfx <mfx> 1139778883 +0000
2006-02-12 21:14:43 +00:00
Markus F.X.J. Oberhumer af05296631 Made ps1/exe work again.
committer: mfx <mfx> 1139776798 +0000
2006-02-12 20:39:58 +00:00
Markus F.X.J. Oberhumer 29d693de2d New ACC version.
committer: mfx <mfx> 1139772863 +0000
2006-02-12 19:34:23 +00:00
Markus F.X.J. Oberhumer 51ac5172f5 #undef PAGE_{MASK,SIZE} to fix build problems on some machines.
committer: mfx <mfx> 1139743226 +0000
2006-02-12 11:20:26 +00:00
Markus F.X.J. Oberhumer 24ce1ef5e7 Enter 2006.
committer: mfx <mfx> 1139742400 +0000
2006-02-12 11:06:40 +00:00
Markus F.X.J. Oberhumer f6d1e269d1 Prepare for new release.
committer: mfx <mfx> 1139742224 +0000
2006-02-12 11:03:44 +00:00
Markus F.X.J. Oberhumer 62c2f5228d Rebuilt stubs.
committer: mfx <mfx> 1139742130 +0000
2006-02-12 11:02:10 +00:00
Markus F.X.J. Oberhumer 9882d9683b Updated.
committer: mfx <mfx> 1139741935 +0000
2006-02-12 10:58:55 +00:00
Markus F.X.J. Oberhumer 45ce89ee1f Removed trailing whitespace.
committer: mfx <mfx> 1139741919 +0000
2006-02-12 10:58:39 +00:00
László Molnár bfb9df1553 win32/pe: R6002 runtime errors worked around
committer: ml1050 <ml1050> 1139505685 +0000
2006-02-09 17:21:25 +00:00
László Molnár a5f79204ce set use_dep_hack to true
committer: ml1050 <ml1050> 1139404812 +0000
2006-02-08 13:20:12 +00:00
László Molnár e322613d84 workaround added for a msvc runtime "protection"
committer: ml1050 <ml1050> 1139393823 +0000
2006-02-08 10:17:03 +00:00
Markus F.X.J. Oberhumer fbb60f5191 Refactored a new mem_replace() function.
committer: mfx <mfx> 1138984802 +0000
2006-02-03 16:40:02 +00:00
Markus F.X.J. Oberhumer 899e7d2f39 Added internal debugging options '--fake-stub-version=X.XX' and
'--fake-stub-year=XXXX'.

These might prove useful for building up a test suite which is able to
check binary identity of compressed executables between UPX releases
where the implementation of a specific format has not changed.

committer: mfx <mfx> 1138960010 +0000
2006-02-03 09:46:50 +00:00
László Molnár 8e2aa07747 load config support for win32/pe dlls
committer: ml1050 <ml1050> 1138878465 +0000
2006-02-02 11:07:45 +00:00
Markus F.X.J. Oberhumer a0d262cd76 New ACC version.
committer: mfx <mfx> 1138683583 +0000
2006-01-31 04:59:43 +00:00
Markus F.X.J. Oberhumer b43a7edee4 Preliminary bump some version information.
committer: mfx <mfx> 1138080865 +0000
2006-01-24 05:34:25 +00:00
Markus F.X.J. Oberhumer 7760bbd77c New ACC version.
committer: mfx <mfx> 1138080385 +0000
2006-01-24 05:26:25 +00:00
Markus F.X.J. Oberhumer 9c0f1b02a7 Small Makefile updates.
committer: mfx <mfx> 1138080320 +0000
2006-01-24 05:25:20 +00:00
Markus F.X.J. Oberhumer 4ecfff4d8d Print a #define for the _SIZE. Enter 2006. Add John's name.
committer: mfx <mfx> 1138080110 +0000
2006-01-24 05:21:50 +00:00
László Molnár ac03b89f38 docs updates for 1.94
committer: ml1050 <ml1050> 1137999714 +0000
2006-01-23 07:01:54 +00:00
László Molnár 620174aea9 copyright text added
committer: ml1050 <ml1050> 1137999649 +0000
2006-01-23 07:00:49 +00:00
Markus F.X.J. Oberhumer ab50d28bc4 New ACC version.
committer: mfx <mfx> 1134926345 +0000
2005-12-18 17:19:05 +00:00
Markus F.X.J. Oberhumer b5318602d1 Fixed compilation problem.
committer: mfx <mfx> 1134926052 +0000
2005-12-18 17:14:12 +00:00
John Reiser bff2a63ea2 prefetching does not help length of match
l_lx_elf64amd.S amd_d_nrv2b.S amd_d_nrv2e.S

committer: jreiser <jreiser> 1132290120 +0000
2005-11-18 05:02:00 +00:00
László Molnár aacfb8820e better load_conf directory support. still needs some work.
committer: ml1050 <ml1050> 1132077577 +0000
2005-11-15 17:59:37 +00:00
John Reiser 98e8c031d0 generated header files
fold_elf64amd.h l_lx_elf64amd.h

committer: jreiser <jreiser> 1131994505 +0000
2005-11-14 18:55:05 +00:00
John Reiser beb4319d1e tune for better branch prediction by avoiding more than 3 in a 16-byte block
amd_d_nrv2b.S amd_d_nrv2e.S l_lx_elf64amd.S

committer: jreiser <jreiser> 1131994471 +0000
2005-11-14 18:54:31 +00:00
John Reiser 2558243c83 de-tabify; also speculate 1-byte loads to save a cycle or two
amd_d_nrv2b.S amd_d_nrv2e.S l_lx_elf64amd.S

committer: jreiser <jreiser> 1131943590 +0000
2005-11-14 04:46:30 +00:00
John Reiser b670e8d1ac tuning
amd_bxx.S amd_d_nrv2b.S amd_d_nrv2e.S l_lx_elf64amd.S

committer: jreiser <jreiser> 1131939243 +0000
2005-11-14 03:34:03 +00:00
John Reiser 68f8358f06 tune: avoid MOVSB for literals; inline default case of NEXTB macros
committer: jreiser <jreiser> 1131923823 +0000
2005-11-13 23:17:03 +00:00
John Reiser db5a099097 CLD and documentation
amd_d_nrv2e.S l_lx_elf64amd.S fold_elf64amd.S

committer: jreiser <jreiser> 1131854052 +0000
2005-11-13 03:54:12 +00:00
John Reiser ce33ffb62a handle compressed executables larger than 3MB on Elf64amd
committer: jreiser <jreiser> 1131833508 +0000
2005-11-12 22:11:48 +00:00
John Reiser 59a2fb9cfd recompile generated .h after source changes
fold_elf64amd.h l_lx_elf64amd.h

committer: jreiser <jreiser> 1131824699 +0000
2005-11-12 19:44:59 +00:00
John Reiser 75bba319de tuning, and prepare for large executables (>3MB compressed)
p_lx_elf.cpp stub/a_lx_elf64.c stub/amd_d_nrv2e.S
	stub/fold_elf64amd.S stub/l_lx_elf64amd.S

committer: jreiser <jreiser> 1131824655 +0000
2005-11-12 19:44:15 +00:00
John Reiser f78e9261f3 Do initLoader() properly, instead of relying on the amount of stack space
that is in use when ::buildLinuxLoader is called.

committer: jreiser <jreiser> 1131597922 +0000
2005-11-10 04:45:22 +00:00
Markus F.X.J. Oberhumer 5f77562333 Cleanup.
committer: mfx <mfx> 1131596991 +0000
2005-11-10 04:29:51 +00:00
Markus F.X.J. Oberhumer 5c4f01a68d New ACC version.
committer: mfx <mfx> 1131596966 +0000
2005-11-10 04:29:26 +00:00
Markus F.X.J. Oberhumer 35f6f998e6 Avoid warnings. Detabified.
committer: mfx <mfx> 1131593815 +0000
2005-11-10 03:36:55 +00:00
John Reiser 6737a3ae09 PackLinuxElf64amd
p_lx_elf.h p_lx_elf.cpp packmast.cpp

committer: jreiser <jreiser> 1131570778 +0000
2005-11-09 21:12:58 +00:00
John Reiser 09559bee8c Elf64
p_unix.h p_elf.h

committer: jreiser <jreiser> 1131570530 +0000
2005-11-09 21:08:50 +00:00
John Reiser f487ea27a8 UPX_F_LINUX_ELF64_AMD
committer: jreiser <jreiser> 1131568333 +0000
2005-11-09 20:32:13 +00:00
John Reiser a3d95f239a Generated .h header files for AMD x86_64
fold_elf64amd.h l_lx_elf64amd.h

committer: jreiser <jreiser> 1131566912 +0000
2005-11-09 20:08:32 +00:00
John Reiser 023c06e178 Support for 64-bit AMD x86_64
Makefile
Added Files:
	a_lx_elf64.c amd_bxx.S amd_d_nrv2e.S amd_regs.h
	fold_elf64amd.S l_lx_elf64amd.S l_lx_elf64amd.lds

committer: jreiser <jreiser> 1131566835 +0000
2005-11-09 20:07:15 +00:00
John Reiser 414a6c1c9e Enhance to handle both Elf32 and Elf64, and little/big endian.
http://buildroot.uclibc.org/cgi-bin/viewcvs.cgi/trunk/buildroot/toolchain/sstrip/sstrip.c
Revision 11028 [Added Tue Aug 2 18:20:34 2005 PDT (3 months, 1 week ago) by mjn3]

committer: jreiser <jreiser> 1131566192 +0000
2005-11-09 19:56:32 +00:00
John Reiser 910e18fb22 b_method 5th argument to f_decompress
l_lx_exec.c l_lx_pti.c l_lx_sep.c l_lx_sh.c

committer: jreiser <jreiser> 1131565060 +0000
2005-11-09 19:37:40 +00:00
John Reiser ac441fd1cf definitions for Elf64_*
committer: jreiser <jreiser> 1131564732 +0000
2005-11-09 19:32:12 +00:00
John Reiser 0c328372b5 Allow __uClibc_main and __uClibc_start_main like __libc_start_main.
committer: jreiser <jreiser> 1127269046 +0000
2005-09-21 02:17:26 +00:00
Markus F.X.J. Oberhumer 55ef60a6d4 Rebuilt with gcc-3.4.4.
committer: mfx <mfx> 1127188101 +0000
2005-09-20 03:48:21 +00:00
Markus F.X.J. Oberhumer c33584e683 Detabified.
committer: mfx <mfx> 1126929315 +0000
2005-09-17 03:55:15 +00:00
Markus F.X.J. Oberhumer ee8c7453bd Small updates.
committer: mfx <mfx> 1126927283 +0000
2005-09-17 03:21:23 +00:00
John Reiser 0330369603 remove debugging strut
l_lx_elf86.asm l_lx_elf86.h

committer: jreiser <jreiser> 1126892616 +0000
2005-09-16 17:43:36 +00:00
John Reiser 3f7b642c7d Linux i386 allow compression of position-independent main executables (gcc -pie).
p_elf.h p_lx_elf.cpp p_lx_elf.h p_lx_exc.cpp
	stub/fold_elf86.asm stub/fold_elf86.h stub/l_lx_elf.c
	stub/l_lx_elf86.asm stub/l_lx_elf86.h stub/l_lx_elf86.lds
	stub/linux.hh

committer: jreiser <jreiser> 1126886896 +0000
2005-09-16 16:08:16 +00:00
László Molnár eb6c51426a fixed a nasty relocation handling error which could produce broken
compressed files

committer: ml1050 <ml1050> 1126865811 +0000
2005-09-16 10:16:51 +00:00
Markus F.X.J. Oberhumer 0337bdb9fd Added support for UCL_USE_ASM.
committer: mfx <mfx> 1126844111 +0000
2005-09-16 04:15:11 +00:00
Markus F.X.J. Oberhumer 7aedc62058 Removed some old and dead code.
committer: mfx <mfx> 1126744217 +0000
2005-09-15 00:30:17 +00:00
Markus F.X.J. Oberhumer bfc835cbbf Added some more tests to upx_sanity_check(). Disable these for production
builds - code bloat.

committer: mfx <mfx> 1126743964 +0000
2005-09-15 00:26:04 +00:00
Markus F.X.J. Oberhumer 5c6ba30c48 New ACC version.
committer: mfx <mfx> 1126741199 +0000
2005-09-14 23:39:59 +00:00
Markus F.X.J. Oberhumer 8fe4824ed2 Fix typo.
committer: mfx <mfx> 1126295791 +0000
2005-09-09 19:56:31 +00:00
Markus F.X.J. Oberhumer d40cb3bd55 Cosmetic cleanups.
committer: mfx <mfx> 1126295335 +0000
2005-09-09 19:48:55 +00:00
Markus F.X.J. Oberhumer 4bcd3ac5d7 Mention arm/pe.
committer: mfx <mfx> 1126294945 +0000
2005-09-09 19:42:25 +00:00
Markus F.X.J. Oberhumer e2b8e9dea9 Avoid some warnings about unused args.
committer: mfx <mfx> 1126294727 +0000
2005-09-09 19:38:47 +00:00
László Molnár 572314bf3f support for arm/WinCE ("arm/pe") exes
committer: ml1050 <ml1050> 1126255781 +0000
2005-09-09 08:49:41 +00:00
Markus F.X.J. Oberhumer 14d303d331 Small updates according to latest glibc headers.
committer: mfx <mfx> 1126184484 +0000
2005-09-08 13:01:24 +00:00
Markus F.X.J. Oberhumer 24ffaa0738 Added BE64 and LE64 types.
committer: mfx <mfx> 1126183138 +0000
2005-09-08 12:38:58 +00:00
Markus F.X.J. Oberhumer 5d9b6d056d Small updates.
committer: mfx <mfx> 1126029328 +0000
2005-09-06 17:55:28 +00:00
Markus F.X.J. Oberhumer 5c28ff15ba Changes for new ACC version.
committer: mfx <mfx> 1126029282 +0000
2005-09-06 17:54:42 +00:00
Markus F.X.J. Oberhumer 06ceb2f2a1 New ACC version.
committer: mfx <mfx> 1126029264 +0000
2005-09-06 17:54:24 +00:00
Markus F.X.J. Oberhumer 7373e1dd8b Updated.
committer: mfx <mfx> 1122416155 +0000
2005-07-26 22:15:55 +00:00
Markus F.X.J. Oberhumer 4b1a9e714d New ACC version.
committer: mfx <mfx> 1122416002 +0000
2005-07-26 22:13:22 +00:00
Markus F.X.J. Oberhumer 9d76136358 Use gcc-3.4.4 for Linux stubs.
committer: mfx <mfx> 1122415958 +0000
2005-07-26 22:12:38 +00:00
Markus F.X.J. Oberhumer b3502420ad Removed patches/patch-elfcode.h and the patches/ directory - these
fixes now are already in upstream binutils for quite some time.

committer: mfx <mfx> 1119797919 +0000
2005-06-26 14:58:39 +00:00
Markus F.X.J. Oberhumer dd7ac7cca9 Updated.
committer: mfx <mfx> 1119614331 +0000
2005-06-24 11:58:51 +00:00
Markus F.X.J. Oberhumer 31dfa18e9b Updated.
committer: mfx <mfx> 1119613913 +0000
2005-06-24 11:51:53 +00:00
Markus F.X.J. Oberhumer 3e785008d3 Avoid warnings.
committer: mfx <mfx> 1119613856 +0000
2005-06-24 11:50:56 +00:00
Markus F.X.J. Oberhumer 6b7c7f755c Avoid warnings about unused vars.
committer: mfx <mfx> 1119613814 +0000
2005-06-24 11:50:14 +00:00
Markus F.X.J. Oberhumer c55a8a8703 Added some more sanity checks.
committer: mfx <mfx> 1119613748 +0000
2005-06-24 11:49:08 +00:00
Markus F.X.J. Oberhumer 64c97308ac Portability fix for gcc -ftrapv option.
committer: mfx <mfx> 1119613504 +0000
2005-06-24 11:45:04 +00:00
Markus F.X.J. Oberhumer 3551b0b95a Updated.
committer: mfx <mfx> 1119613441 +0000
2005-06-24 11:44:01 +00:00
Markus F.X.J. Oberhumer 9f16b5c4af Recompiled stubs.
committer: mfx <mfx> 1119613249 +0000
2005-06-24 11:40:49 +00:00
Markus F.X.J. Oberhumer 9777e549cb New upstream version.
committer: mfx <mfx> 1119613222 +0000
2005-06-24 11:40:22 +00:00
Markus F.X.J. Oberhumer fbfced1b93 New ACC version.
committer: mfx <mfx> 1119613192 +0000
2005-06-24 11:39:52 +00:00
John Reiser 1a84b4681c fix sign-extend bug
committer: jreiser <jreiser> 1114311664 +0000
2005-04-24 03:01:04 +00:00
John Reiser 4bf81b8e1c propagate compiled changes due to ppc_bxx.S
stub/fold_elfppc32.h stub/fold_machppc32.h

committer: jreiser <jreiser> 1114229942 +0000
2005-04-23 04:19:02 +00:00
John Reiser c282e7fdb4 PPC branch+call trick: filter first 4MB only
filteri.cpp filter/ppcbxx.h stub/ppc_bxx.S

committer: jreiser <jreiser> 1114229877 +0000
2005-04-23 04:17:57 +00:00
John Reiser d339ee3135 PackLinuxElf32::unpack forgot several get_native32()
committer: jreiser <jreiser> 1114229735 +0000
2005-04-23 04:15:35 +00:00
Markus F.X.J. Oberhumer 1de95de299 Updated.
committer: mfx <mfx> 1111664629 +0000
2005-03-24 11:43:49 +00:00
Markus F.X.J. Oberhumer 96c998a1d7 Updated for current glibc.
committer: mfx <mfx> 1111664285 +0000
2005-03-24 11:38:05 +00:00
Markus F.X.J. Oberhumer b5413c0156 Added John to main banner.
committer: mfx <mfx> 1110936050 +0000
2005-03-16 01:20:50 +00:00
Markus F.X.J. Oberhumer 7371c195ff Allocate larger xtrasize based on ih.datasize.
committer: mfx <mfx> 1110936001 +0000
2005-03-16 01:20:01 +00:00
Markus F.X.J. Oberhumer 0866a1996b Added two checks for buffer overflows as suggested by Giovanni Bajo.
committer: mfx <mfx> 1110732210 +0000
2005-03-13 16:43:30 +00:00
Markus F.X.J. Oberhumer 41f44c4e78 Updated.
committer: mfx <mfx> 1110731666 +0000
2005-03-13 16:34:26 +00:00
Markus F.X.J. Oberhumer 131712c3bd New ACC version.
committer: mfx <mfx> 1110731645 +0000
2005-03-13 16:34:05 +00:00
Markus F.X.J. Oberhumer bae12aaab7 Added more global operators.
committer: mfx <mfx> 1110731448 +0000
2005-03-13 16:30:48 +00:00
Markus F.X.J. Oberhumer 74d5844d8c Tried to make 64-bit clean. John, please have a look!
committer: mfx <mfx> 1110731221 +0000
2005-03-13 16:27:01 +00:00
Markus F.X.J. Oberhumer c87908266a Fix a compilation problem with older compilers.
committer: mfx <mfx> 1110730245 +0000
2005-03-13 16:10:45 +00:00
Markus F.X.J. Oberhumer f788d76b8c Added several __attribute_packed.
committer: mfx <mfx> 1110730186 +0000
2005-03-13 16:09:46 +00:00
Markus F.X.J. Oberhumer 41031e572e Updated.
committer: mfx <mfx> 1110729509 +0000
2005-03-13 15:58:29 +00:00
Markus F.X.J. Oberhumer f8a0864c1b Final updates. Really.
committer: mfx <mfx> 1109817185 +0000
2005-03-03 02:33:05 +00:00
Markus F.X.J. Oberhumer 949587334c Updates.
committer: mfx <mfx> 1109816699 +0000
2005-03-03 02:24:59 +00:00
Markus F.X.J. Oberhumer 0bc6a1a7f1 Updated.
committer: mfx <mfx> 1109765803 +0000
2005-03-02 12:16:43 +00:00
Markus F.X.J. Oberhumer 0d9cbfe927 Updated.
committer: mfx <mfx> 1109756565 +0000
2005-03-02 09:42:45 +00:00
Markus F.X.J. Oberhumer 8742a524c3 Small updates.
committer: mfx <mfx> 1109750922 +0000
2005-03-02 08:08:42 +00:00
Markus F.X.J. Oberhumer 79bf2297b5 New simple and modern Makefile.
committer: mfx <mfx> 1109750619 +0000
2005-03-02 08:03:39 +00:00
Markus F.X.J. Oberhumer 32e9e23630 Removed old Makfiles (horrible cruft dating back from 1998).
committer: mfx <mfx> 1109750572 +0000
2005-03-02 08:02:52 +00:00
Markus F.X.J. Oberhumer 7f1cecba92 Got changed. We must sync our toolchains.
committer: mfx <mfx> 1109750498 +0000
2005-03-02 08:01:38 +00:00
Markus F.X.J. Oberhumer efd30c61c3 Use namespace.
committer: mfx <mfx> 1109750346 +0000
2005-03-02 07:59:06 +00:00
Markus F.X.J. Oberhumer 4c97b11207 Added OBJSTRIP_xxx variables.
committer: mfx <mfx> 1109734187 +0000
2005-03-02 03:29:47 +00:00
John Reiser 58ea0ab745 use "~0u" to force unsigned bitmasks
committer: jreiser <jreiser> 1109691309 +0000
2005-03-01 15:35:09 +00:00
Markus F.X.J. Oberhumer 3547c71ad5 New ACC version.
committer: mfx <mfx> 1109674986 +0000
2005-03-01 11:03:06 +00:00
Markus F.X.J. Oberhumer 044d6b2ce2 Updated some ELF constants.
committer: mfx <mfx> 1109674932 +0000
2005-03-01 11:02:12 +00:00
Markus F.X.J. Oberhumer a0b26b6c06 Added Elf32_Dyn.
committer: mfx <mfx> 1109671693 +0000
2005-03-01 10:08:13 +00:00
Markus F.X.J. Oberhumer 8e3bfde439 Use templates.
committer: mfx <mfx> 1109671197 +0000
2005-03-01 09:59:57 +00:00
Markus F.X.J. Oberhumer 6507de959b Remove "struct" keywords.
committer: mfx <mfx> 1109671153 +0000
2005-03-01 09:59:13 +00:00
Markus F.X.J. Oberhumer 56d09bf3b5 Avoid warning.
committer: mfx <mfx> 1109669763 +0000
2005-03-01 09:36:03 +00:00
Markus F.X.J. Oberhumer 232754b978 Removed trailing whitespace.
committer: mfx <mfx> 1109669261 +0000
2005-03-01 09:27:41 +00:00
Markus F.X.J. Oberhumer 75ef603308 Linker updates from Laszlo. Needs some testing.
committer: mfx <mfx> 1109669078 +0000
2005-03-01 09:24:38 +00:00
Markus F.X.J. Oberhumer a5a2fcee4d Avoid warning.
committer: mfx <mfx> 1109345414 +0000
2005-02-25 15:30:14 +00:00
John Reiser f86d57bfe3 mmap() needs in-range fd; b_method as arg5 to decompress
l_lx_elfppc32.S l_lx_elfppc32.h
	ppc_d_nrv2e.S
	ppc_d_nrv2b.S

committer: jreiser <jreiser> 1109217478 +0000
2005-02-24 03:57:58 +00:00
John Reiser 615615b1df Unmap the compressed program before running the uncompressed.
fold_elfppc32.S fold_elfppc32.h

committer: jreiser <jreiser> 1109129677 +0000
2005-02-23 03:34:37 +00:00
John Reiser aeba0ce170 add dependencies for ppc_bxx.S and ppc_d_nrv2e.S
Makefile fold_elfppc32.h l_mac_ppc32.h

committer: jreiser <jreiser> 1109093661 +0000
2005-02-22 17:34:21 +00:00
John Reiser 5ce60aad53 data cache prefetch
ppc_d_nrv2e.S l_lx_elfppc32.h

committer: jreiser <jreiser> 1109034808 +0000
2005-02-22 01:13:28 +00:00
John Reiser dbc01de9a0 remove debugg-only 'trap'
committer: jreiser <jreiser> 1109012788 +0000
2005-02-21 19:06:28 +00:00
John Reiser dfaf3f24fc fix bad merge
p_lx_elf.h p_lx_exc.cpp

committer: jreiser <jreiser> 1108944786 +0000
2005-02-21 00:13:06 +00:00
John Reiser 14b0527e79 fix compiler waring
committer: jreiser <jreiser> 1108941316 +0000
2005-02-20 23:15:16 +00:00
John Reiser f0148c3161 prepare for M_CL1B
committer: jreiser <jreiser> 1108940729 +0000
2005-02-20 23:05:29 +00:00
John Reiser 6a5e3d924d p_lx_interp, p_mach
committer: jreiser <jreiser> 1108940412 +0000
2005-02-20 23:00:12 +00:00
John Reiser 664a82e7c9 Start re-organizing the packing of Elf, by making Elf32 come first,
with Big endian and Little endian derived from it.
I386 still uses the old way, but PowerPC (both Linux and Darwin [Mac])
use the new way.
	p_elf.h p_lx_elf.cpp p_lx_elf.h p_lx_exc.cpp p_lx_exc.h
	p_unix.cpp p_unix.h p_vmlinx.cpp p_vmlinx.h p_vmlinz.cpp

committer: jreiser <jreiser> 1108940224 +0000
2005-02-20 22:57:04 +00:00
John Reiser e2763b4826 new packers PackMachPPC32 PackLinuxElf32ppc PackLinuxI386interp
packmast.cpp
	p_lx_interp.h

committer: jreiser <jreiser> 1108939957 +0000
2005-02-20 22:52:37 +00:00
John Reiser afb29b19c2 PowerPC branch [and call] trick
committer: jreiser <jreiser> 1108939726 +0000
2005-02-20 22:48:46 +00:00
John Reiser 8d60343940 allow better handling for no_filter option;
new options is_ptinterp, use_ptintep, make_ptinterp;
reserve codes for M_CL1B.
	compress.ch conf.h main.cpp options.h

committer: jreiser <jreiser> 1108939577 +0000
2005-02-20 22:46:17 +00:00
John Reiser 67a77f1880 Packer for Macintosh Darwin Mach-o PowerPC32
Added Files:
	p_mach.cpp p_mach.h

committer: jreiser <jreiser> 1108863998 +0000
2005-02-20 01:46:38 +00:00
John Reiser c933974174 branch trick for PowerPC32
committer: jreiser <jreiser> 1108863063 +0000
2005-02-20 01:31:03 +00:00
John Reiser 19715903fb New stubs pti86 (PT_INTERP for Linux x86), Linux Elf PowerPC-32,
Apple Macintosh Darwin PowerPC-32.

committer: jreiser <jreiser> 1108862148 +0000
2005-02-20 01:15:48 +00:00
John Reiser c88f72fd15 disinguish between __i386__ and generic
committer: jreiser <jreiser> 1108861387 +0000
2005-02-20 01:03:07 +00:00
John Reiser 7818596271 stub loader for Linux Elf PowerPC32
Added Files:
	m_lx_elfppc32.c l_lx_elfppc32.lds
	fold_elfppc32.S l_lx_elfppc32.S
	fold_elfppc32.h l_lx_elfppc32.h  [these two created by Makefile]

committer: jreiser <jreiser> 1108861182 +0000
2005-02-20 00:59:42 +00:00
John Reiser 9cb8d7bca6 stub loader for Macintosh (Darwin) Mach-o PowerPC32
Added Files:
	l_mac_ppc32.S fold_machppc32.S m_mac_mach32.c
	l_mac_ppc32.h fold_machppc32.h [these two created by Makefile]

committer: jreiser <jreiser> 1108860254 +0000
2005-02-20 00:44:14 +00:00
John Reiser 46f9256114 PowerPC unfilter, decompress, and register definitions
Added Files:
	ppc_bxx.S ppc_d_nrv2e.S ppc_regs.h

committer: jreiser <jreiser> 1108855959 +0000
2005-02-19 23:32:39 +00:00
John Reiser c26ef87202 Let the UPX loader be an Elf PT_INTERP /opt/upx/run
Added Files:
	p_lx_interp.cpp stub/l_lx_pti.c stub/fold_pti86.asm
	stub/fold_pti86.h stub/l_lx_pti86.asm stub/l_lx_pti86.h
	stub/l_lx_pti86.lds

committer: jreiser <jreiser> 1108855010 +0000
2005-02-19 23:16:50 +00:00
John Reiser 89fee5b835 allow more sections; print failing section on overflow
committer: jreiser <jreiser> 1108850756 +0000
2005-02-19 22:05:56 +00:00
John Reiser f5795eb01b make_hatch() is called from l_lx_sep86.asm, so cannot be 'static'
committer: jreiser <jreiser> 1108850437 +0000
2005-02-19 22:00:37 +00:00
László Molnár dbf0c9f016 msg.cpp: fixed possible sigsegv caused by a tricky filename
committer: ml1050 <ml1050> 1108382780 +0000
2005-02-14 12:06:20 +00:00
Markus F.X.J. Oberhumer 586b43048f Bump version.
committer: mfx <mfx> 1107807914 +0000
2005-02-07 20:25:14 +00:00
Markus F.X.J. Oberhumer 63b9ee61d2 Prepare UPX 1.93 release.
committer: mfx <mfx> 1107804731 +0000
2005-02-07 19:32:11 +00:00
Markus F.X.J. Oberhumer 3b9eff7f34 Enter 2005; added all needed stub files to CVS.
committer: mfx <mfx> 1107804447 +0000
2005-02-07 19:27:27 +00:00
John Reiser 59668c5fc1 ::pack3 to set .p_filesz; also set blocksize to allow giant scripts as input
p_lx_sh.cpp p_lx_sh.h

committer: jreiser <jreiser> 1105479043 +0000
2005-01-11 21:30:43 +00:00
Markus F.X.J. Oberhumer 3ed786fb5c Updated.
committer: mfx <mfx> 1103717402 +0000
2004-12-22 12:10:02 +00:00
Markus F.X.J. Oberhumer 0cd5eb5472 Use gcc-3.4.3 for Linux stubs.
committer: mfx <mfx> 1103717370 +0000
2004-12-22 12:09:30 +00:00
Markus F.X.J. Oberhumer ff571b96cb New ACC version.
committer: mfx <mfx> 1103717337 +0000
2004-12-22 12:08:57 +00:00
John Reiser 36b852e6bf %cs at entry to decompressor varies a _lot_ among Linux 2.4.x, 2.6.y kernels.
Decompressor must adapt; no universal constants exist for __BOOT_CS, _BOOT_DS.
	p_vmlinx.cpp stub/l_vmlinz.asm

committer: jreiser <jreiser> 1103605278 +0000
2004-12-21 05:01:18 +00:00
John Reiser f0c21c7203 Enhance documentation for process flow and testing.
Include some notes for compressing kernels from Linux 2.4.x.

committer: jreiser <jreiser> 1103513947 +0000
2004-12-20 03:39:07 +00:00
John Reiser 0516d8260c Fix stack synchronization bug at end of unfilter.
[The confusing fake "conditional compilation" strikes again!]

committer: jreiser <jreiser> 1103513713 +0000
2004-12-20 03:35:13 +00:00
John Reiser 1418f57b96 Fix bugs between Filter.addvalue and ckt32 macro call: [re-]compressed
Linux kernels were not booting.  Explain .addvalue better.
Set kernel stack pointer for boot-time decompression according to
Linux kernel documentation.
	     p_vmlinx.cpp      p_vmlinz.cpp
	stub/l_vmlinx.asm stub/l_vmlinz.asm
	filter/cto.h filter/ctoj.h filter/ctok.h

committer: jreiser <jreiser> 1103326936 +0000
2004-12-17 23:42:16 +00:00
Markus F.X.J. Oberhumer b24fb59c94 New upstream version.
committer: mfx <mfx> 1101602738 +0000
2004-11-28 00:45:38 +00:00
Markus F.X.J. Oberhumer 8fcf2bcd59 Fix bele.h to use strict PODs. This should fix build problems reported on ARM.
committer: mfx <mfx> 1098709362 +0000
2004-10-25 13:02:42 +00:00
Markus F.X.J. Oberhumer 079b808a56 Updated.
committer: mfx <mfx> 1098709263 +0000
2004-10-25 13:01:03 +00:00
Markus F.X.J. Oberhumer a4e01e28db New ACC version.
committer: mfx <mfx> 1098709116 +0000
2004-10-25 12:58:36 +00:00
Markus F.X.J. Oberhumer ec1ef9099f Updated.
committer: mfx <mfx> 1096637333 +0000
2004-10-01 13:28:53 +00:00
Markus F.X.J. Oberhumer ac724c7e6c New PS1 version from Jens.
committer: mfx <mfx> 1096637259 +0000
2004-10-01 13:27:39 +00:00
Markus F.X.J. Oberhumer ec25835525 New ACC version.
committer: mfx <mfx> 1096636709 +0000
2004-10-01 13:18:29 +00:00
Markus F.X.J. Oberhumer d4841a641c Updates.
committer: mfx <mfx> 1092135204 +0000
2004-08-10 10:53:24 +00:00
Markus F.X.J. Oberhumer 5612460720 New ACC version.
committer: mfx <mfx> 1092134926 +0000
2004-08-10 10:48:46 +00:00
John Reiser 465ea6429f "new []" requires matching "delete []"
committer: jreiser <jreiser> 1090882098 +0000
2004-07-26 22:48:18 +00:00
Markus F.X.J. Oberhumer ed9057ca83 Cleanups.
committer: mfx <mfx> 1090594763 +0000
2004-07-23 14:59:23 +00:00
Markus F.X.J. Oberhumer 14ced962db Cleanup.
committer: mfx <mfx> 1090583778 +0000
2004-07-23 11:56:18 +00:00
Markus F.X.J. Oberhumer 1aff6b862d Replaced ACC with miniACC.
committer: mfx <mfx> 1090583659 +0000
2004-07-23 11:54:19 +00:00
Markus F.X.J. Oberhumer ef490c4220 Updates.
committer: mfx <mfx> 1090577049 +0000
2004-07-23 10:04:09 +00:00
Markus F.X.J. Oberhumer 0dda83cbbc Updated.
committer: mfx <mfx> 1090577037 +0000
2004-07-23 10:03:57 +00:00
Markus F.X.J. Oberhumer fa4efec3b5 Bumped version numbers.
committer: mfx <mfx> 1090283329 +0000
2004-07-20 00:28:49 +00:00
Markus F.X.J. Oberhumer 814eabb88e Final updates for upx 1.92.
committer: mfx <mfx> 1090281040 +0000
2004-07-19 23:50:40 +00:00
John Reiser 95021e4977 mention vmlinux/i386
NEWS README README.1ST

committer: jreiser <jreiser> 1090261436 +0000
2004-07-19 18:23:56 +00:00
Markus F.X.J. Oberhumer d17fb7ebf0 Updated.
committer: mfx <mfx> 1090258607 +0000
2004-07-19 17:36:47 +00:00
Markus F.X.J. Oberhumer df9aa9ac32 Misc updates.
committer: mfx <mfx> 1090256162 +0000
2004-07-19 16:56:02 +00:00
Markus F.X.J. Oberhumer 9110517893 Check for .NET (win32/net) files.
committer: mfx <mfx> 1090256077 +0000
2004-07-19 16:54:37 +00:00
Markus F.X.J. Oberhumer 8204c7deb6 Small portability fixes.
committer: mfx <mfx> 1090256008 +0000
2004-07-19 16:53:28 +00:00
Markus F.X.J. Oberhumer 6662f8985e New ACC version.
committer: mfx <mfx> 1090253767 +0000
2004-07-19 16:16:07 +00:00
John Reiser a2b305ed3b Don't spend too much time compressing large symbol tables.
committer: jreiser <jreiser> 1090072585 +0000
2004-07-17 13:56:25 +00:00
John Reiser ce3d3a850c Allow any number of contiguous PT_LOAD.
p_vmlinx.cpp p_vmlinx.h

committer: jreiser <jreiser> 1090040793 +0000
2004-07-17 05:06:33 +00:00
Markus F.X.J. Oberhumer 212b674bc2 Portability fixes. Avoid some warnings.
committer: mfx <mfx> 1089734843 +0000
2004-07-13 16:07:23 +00:00
John Reiser 2980a6b4bb save 4 bytes
committer: jreiser <jreiser> 1089733580 +0000
2004-07-13 15:46:20 +00:00
Markus F.X.J. Oberhumer 435c0a9e82 New ACC version.
committer: mfx <mfx> 1089731989 +0000
2004-07-13 15:19:49 +00:00
Markus F.X.J. Oberhumer 4102cd7c91 Detabified.
committer: mfx <mfx> 1089731601 +0000
2004-07-13 15:13:21 +00:00
Markus F.X.J. Oberhumer b4b603819d Comment out cl1_d32.ash for now.
committer: mfx <mfx> 1089731343 +0000
2004-07-13 15:09:03 +00:00
Markus F.X.J. Oberhumer 20e3707e69 Updated some comments.
committer: mfx <mfx> 1089731255 +0000
2004-07-13 15:07:35 +00:00
John Reiser fc6eeaaea8 Decodes a format similar to nrv2b, except that a run of literals
is counted and phased instead of always 1-hot (no more 9/8 expansion).

committer: jreiser <jreiser> 1089692385 +0000
2004-07-13 04:19:45 +00:00
Markus F.X.J. Oberhumer 41799955ce Updated.
committer: mfx <mfx> 1089687731 +0000
2004-07-13 03:02:11 +00:00
Markus F.X.J. Oberhumer efb4ec9cb8 New ACC version.
committer: mfx <mfx> 1089687481 +0000
2004-07-13 02:58:01 +00:00
Markus F.X.J. Oberhumer 4dbda29f82 New upstream version.
committer: mfx <mfx> 1089687264 +0000
2004-07-13 02:54:24 +00:00
Markus F.X.J. Oberhumer befaa3c501 Detabified.
committer: mfx <mfx> 1089685145 +0000
2004-07-13 02:19:05 +00:00
John Reiser f41edf9e21 more Example twiddling
committer: jreiser <jreiser> 1089683530 +0000
2004-07-13 01:52:10 +00:00
John Reiser 754f10f0b0 update Example from linux kernel debuggin
committer: jreiser <jreiser> 1089674802 +0000
2004-07-12 23:26:42 +00:00
John Reiser 5d331fdf69 new file format vmlinux/i386
Modified Files:
	Makefile conf.h help.cpp linker.cpp p_elf.h packer.cpp
	packerf.cpp packmast.cpp stub/Makefile stub/l_vmlinz.asm
Added Files:
	p_vmlinx.h p_vmlinx.cpp stub/l_vmlinx.asm

committer: jreiser <jreiser> 1089652867 +0000
2004-07-12 17:21:07 +00:00
Markus F.X.J. Oberhumer cbf1dbe2cb Added new win32/pe option `--strip-loadconf'.
committer: mfx <mfx> 1089630382 +0000
2004-07-12 11:06:22 +00:00
Markus F.X.J. Oberhumer 3177de92fb New ACC version.
committer: mfx <mfx> 1089162904 +0000
2004-07-07 01:15:04 +00:00
Markus F.X.J. Oberhumer 3878890783 Prefer gcc-3.4.0 over gcc-3.4.1. Converted PF_TO_PROT into a macro (small size gain).
committer: mfx <mfx> 1088832985 +0000
2004-07-03 05:36:25 +00:00
Markus F.X.J. Oberhumer 61594f7873 Misc cleanups.
committer: mfx <mfx> 1088804669 +0000
2004-07-02 21:44:29 +00:00
Markus F.X.J. Oberhumer f412b5e0cd Fixed Win64 warnings.
committer: mfx <mfx> 1088804606 +0000
2004-07-02 21:43:26 +00:00
Markus F.X.J. Oberhumer f14d594a1a New ACC version.
committer: mfx <mfx> 1088804565 +0000
2004-07-02 21:42:45 +00:00
Markus F.X.J. Oberhumer f0279d23d3 Bumped version to start working on 1.92.
committer: mfx <mfx> 1088568203 +0000
2004-06-30 04:03:23 +00:00
Markus F.X.J. Oberhumer 18ef55ac14 Final updates for upx-1.91.
committer: mfx <mfx> 1088566877 +0000
2004-06-30 03:41:17 +00:00
Markus F.X.J. Oberhumer 0010c50de6 Updated.
committer: mfx <mfx> 1088552416 +0000
2004-06-29 23:40:16 +00:00
Markus F.X.J. Oberhumer 130699a33b Updated.
committer: mfx <mfx> 1088541938 +0000
2004-06-29 20:45:38 +00:00
Markus F.X.J. Oberhumer 5a8d60d3e0 Assorted fixes.
committer: mfx <mfx> 1088541880 +0000
2004-06-29 20:44:40 +00:00
Markus F.X.J. Oberhumer 603dc83c1a Fixed wrong n_mru storage in putPackHeader().
committer: mfx <mfx> 1088541728 +0000
2004-06-29 20:42:08 +00:00
Markus F.X.J. Oberhumer 51106e730b Updated.
committer: mfx <mfx> 1088532712 +0000
2004-06-29 18:11:52 +00:00
Markus F.X.J. Oberhumer 23ec864130 Removed trailing whitespace.
committer: mfx <mfx> 1088532664 +0000
2004-06-29 18:11:04 +00:00
Markus F.X.J. Oberhumer 5349bd0b2a Stricter check of some PE values.
committer: mfx <mfx> 1088532595 +0000
2004-06-29 18:09:55 +00:00
Markus F.X.J. Oberhumer 74d70fe1d9 New ACC version.
committer: mfx <mfx> 1088531787 +0000
2004-06-29 17:56:27 +00:00
Markus F.X.J. Oberhumer 041865c320 Misc cleanups.
committer: mfx <mfx> 1088103372 +0000
2004-06-24 18:56:12 +00:00
Markus F.X.J. Oberhumer 6a7d555ad7 Recompute tlsindex in buildLoader() as suggested by Laszlo.
committer: mfx <mfx> 1088101947 +0000
2004-06-24 18:32:27 +00:00
Markus F.X.J. Oberhumer 18262f79c7 New upstream version.
committer: mfx <mfx> 1087253885 +0000
2004-06-14 22:58:05 +00:00
John Reiser 9769599f1d Avoid "ASCII armor" area below 16MB (0x01000000) for exec-shield and
pre-linked PT_INTERP such as ld-linux.so.2
	l_lx_elf86.asm l_lx_elf86.lds l_lx_sh86.asm l_lx_sh86.lds

committer: jreiser <jreiser> 1084925700 +0000
2004-05-19 00:15:00 +00:00
John Reiser aee150474c Revamp do_xmap() to work under exec-shield and exec-shield-randomize,
and with pre-linked PT_INTERP such as ld-linux.so.2.
	l_lx_elf.c l_lx_sh.c

committer: jreiser <jreiser> 1084923593 +0000
2004-05-18 23:39:53 +00:00
Markus F.X.J. Oberhumer 0e45021a5a Bumped version-date.
committer: mfx <mfx> 1084324462 +0000
2004-05-12 01:14:22 +00:00
Markus F.X.J. Oberhumer 241abcc89c Whitespace changes.
committer: mfx <mfx> 1084324421 +0000
2004-05-12 01:13:41 +00:00
Markus F.X.J. Oberhumer 90fc32a56e Small cleanup.
committer: mfx <mfx> 1084324395 +0000
2004-05-12 01:13:15 +00:00
Markus F.X.J. Oberhumer 7ce85ab712 Fixes for gcc 3.4 (-funit-at-a-time). Reduced size of stubs a little bit.
committer: mfx <mfx> 1084323518 +0000
2004-05-12 00:58:38 +00:00
Markus F.X.J. Oberhumer 55cde23f10 Updated for gcc 3.4.0 release.
committer: mfx <mfx> 1084317169 +0000
2004-05-11 23:12:49 +00:00
Markus F.X.J. Oberhumer a19e6cd4f5 Detabified.
committer: mfx <mfx> 1084317075 +0000
2004-05-11 23:11:15 +00:00
Markus F.X.J. Oberhumer 06f8c55908 Fixed partial reads.
committer: mfx <mfx> 1084308720 +0000
2004-05-11 20:52:00 +00:00
Markus F.X.J. Oberhumer b10f68d20a New ACC version.
committer: mfx <mfx> 1084307588 +0000
2004-05-11 20:33:08 +00:00
John Reiser ed8a71bba1 recognize another variation of head.S: ljmp $0x10,...
committer: jreiser <jreiser> 1084136848 +0000
2004-05-09 21:07:28 +00:00
John Reiser fee6f17caf explicit PHDRS to control number of Elf32_Phdr: no PT_GNU_STACK
l_lx_elf86.lds l_lx_exec86.lds l_lx_sep86.lds l_lx_sh86.lds

committer: jreiser <jreiser> 1083997506 +0000
2004-05-08 06:25:06 +00:00
Markus F.X.J. Oberhumer 767e4e2ce6 New ps1/exe version from Jens.
committer: mfx <mfx> 1083813373 +0000
2004-05-06 03:16:13 +00:00
Markus F.X.J. Oberhumer 23f5370dcf Added cdecl.
committer: mfx <mfx> 1083812698 +0000
2004-05-06 03:04:58 +00:00
Markus F.X.J. Oberhumer 37ae689328 New PS1 version from Jens.
committer: mfx <mfx> 1081901413 +0000
2004-04-14 00:10:13 +00:00
Markus F.X.J. Oberhumer 123b33efd4 New upstream version.
committer: mfx <mfx> 1081448201 +0000
2004-04-08 18:16:41 +00:00
Markus F.X.J. Oberhumer 736ec9d9e5 Now requires djasm-2.04-mfx1.
committer: mfx <mfx> 1081387577 +0000
2004-04-08 01:26:17 +00:00
John Reiser 5a94136764 "python -c" works, so python is a shell. [However, scripts often use:
#!/usr/bin/env python
instead of
	#!/usr/bin/python
because for a long time python was not "blessed" by living in /usr/bin;
many users have python in /usr/local or some other place in $PATH.
And /usr/bin/env does not take "-c".]

committer: jreiser <jreiser> 1081041516 +0000
2004-04-04 01:18:36 +00:00
John Reiser 1555be40b7 fix alignment of loader after packing multiple blocks
p_lx_elf.h p_lx_elf.cpp

committer: jreiser <jreiser> 1080880623 +0000
2004-04-02 04:37:03 +00:00
Markus F.X.J. Oberhumer 60b7a3c33b Updated to gcc-3.4 20040314 prerelease.
committer: mfx <mfx> 1080195627 +0000
2004-03-25 06:20:27 +00:00
Markus F.X.J. Oberhumer a5d8e575bd Building the Linux stub is now completely freestanding of any libc/kernel headers.
committer: mfx <mfx> 1080194907 +0000
2004-03-25 06:08:27 +00:00
Markus F.X.J. Oberhumer 23db1d375c *** empty log message ***
committer: mfx <mfx> 1080194792 +0000
2004-03-25 06:06:32 +00:00
Markus F.X.J. Oberhumer e06722d121 Finally fixed long-standing reloc bug.
committer: mfx <mfx> 1080194776 +0000
2004-03-25 06:06:16 +00:00
John Reiser 81e77a8b2b linux-2.6.4 has different code in head.S
committer: jreiser <jreiser> 1079655854 +0000
2004-03-19 00:24:14 +00:00
Markus F.X.J. Oberhumer 5c567c5a76 Converted ctojr32 to use macro-local defines.
committer: mfx <mfx> 1075806803 +0000
2004-02-03 11:13:23 +00:00
Markus F.X.J. Oberhumer b8e698bde3 Added CPU instructions to all nasm source files.
FIXME: ctojr32 needs CPU 486 because it uses bswap.

committer: mfx <mfx> 1075806034 +0000
2004-02-03 11:00:34 +00:00
Markus F.X.J. Oberhumer 440b5b2608 Build updates.
committer: mfx <mfx> 1075804038 +0000
2004-02-03 10:27:18 +00:00
Markus F.X.J. Oberhumer 8b2e7ffe0b New ACC version.
committer: mfx <mfx> 1075803957 +0000
2004-02-03 10:25:57 +00:00
Markus F.X.J. Oberhumer 1018a96b31 Enter 2004.
committer: mfx <mfx> 1074624720 +0000
2004-01-20 18:52:00 +00:00
Markus F.X.J. Oberhumer 5f87e9891b Enter 2004.
committer: mfx <mfx> 1074623868 +0000
2004-01-20 18:37:48 +00:00
Markus F.X.J. Oberhumer 19564ed27e Cleanups.
committer: mfx <mfx> 1074623253 +0000
2004-01-20 18:27:33 +00:00
Markus F.X.J. Oberhumer f4022af48a Fixes for gcc 3.4 20040118.
committer: mfx <mfx> 1074619023 +0000
2004-01-20 17:17:03 +00:00
Markus F.X.J. Oberhumer 2d1de8b9e9 New ACC version.
committer: mfx <mfx> 1074109375 +0000
2004-01-14 19:42:55 +00:00
Markus F.X.J. Oberhumer cdbfdee725 Updates.
committer: mfx <mfx> 1071922490 +0000
2003-12-20 12:14:50 +00:00
Markus F.X.J. Oberhumer ac64126a66 Use gcc-3.4 20031206 (experimental) for smallest Linux stubs.
committer: mfx <mfx> 1071920621 +0000
2003-12-20 11:43:41 +00:00
Markus F.X.J. Oberhumer 97153e8e09 Compile fixes for PGI C++.
committer: mfx <mfx> 1071917829 +0000
2003-12-20 10:57:09 +00:00
Markus F.X.J. Oberhumer b9c976304a Avoid unused variables.
committer: mfx <mfx> 1071779657 +0000
2003-12-18 20:34:17 +00:00
Markus F.X.J. Oberhumer 670b67cc98 Updated.
committer: mfx <mfx> 1071754494 +0000
2003-12-18 13:34:54 +00:00
Markus F.X.J. Oberhumer ccecaa741c New ACC version.
committer: mfx <mfx> 1071754470 +0000
2003-12-18 13:34:30 +00:00
Markus F.X.J. Oberhumer 07230edec0 New ACC version.
committer: mfx <mfx> 1069787548 +0000
2003-11-25 19:12:28 +00:00
Markus F.X.J. Oberhumer de1a4b4da4 Cleanups.
committer: mfx <mfx> 1068991974 +0000
2003-11-16 14:12:54 +00:00
Markus F.X.J. Oberhumer aba5c40b17 New ACC version.
committer: mfx <mfx> 1068991888 +0000
2003-11-16 14:11:28 +00:00
Markus F.X.J. Oberhumer a55b3480ef Small updates.
committer: mfx <mfx> 1066732696 +0000
2003-10-21 10:38:16 +00:00
Markus F.X.J. Oberhumer bcb5e7d852 New ACC version.
committer: mfx <mfx> 1066732570 +0000
2003-10-21 10:36:10 +00:00
Markus F.X.J. Oberhumer e4f6378dfe Added support for amd64 (aka x86_64) cross compiler.
committer: mfx <mfx> 1064515134 +0000
2003-09-25 18:38:54 +00:00
Markus F.X.J. Oberhumer f616d2edf1 New upstream version.
committer: mfx <mfx> 1063623307 +0000
2003-09-15 10:55:07 +00:00
Markus F.X.J. Oberhumer bffb138b9c New ACC version.
committer: mfx <mfx> 1063544494 +0000
2003-09-14 13:01:34 +00:00
Markus F.X.J. Oberhumer b49fc6c081 Changed -O2 flag to -O15 for new nasm version.
committer: mfx <mfx> 1063502219 +0000
2003-09-14 01:16:59 +00:00
Markus F.X.J. Oberhumer 570b195ed6 Fixed cdecl.
committer: mfx <mfx> 1062472677 +0000
2003-09-02 03:17:57 +00:00
Markus F.X.J. Oberhumer b0e961b90b New ACC version.
committer: mfx <mfx> 1062472636 +0000
2003-09-02 03:17:16 +00:00
Markus F.X.J. Oberhumer 919a899c39 New ACC version.
committer: mfx <mfx> 1062077078 +0000
2003-08-28 13:24:38 +00:00
Markus F.X.J. Oberhumer 655094239c Cleanups.
committer: mfx <mfx> 1061224700 +0000
2003-08-18 16:38:20 +00:00
Markus F.X.J. Oberhumer 8eda698a9c New ACC version.
committer: mfx <mfx> 1061224659 +0000
2003-08-18 16:37:39 +00:00
Markus F.X.J. Oberhumer d1753c6df9 Misc cleanups.
committer: mfx <mfx> 1060699283 +0000
2003-08-12 14:41:23 +00:00
Markus F.X.J. Oberhumer 3db0b0e8fe New ACC version.
committer: mfx <mfx> 1060699213 +0000
2003-08-12 14:40:13 +00:00
Markus F.X.J. Oberhumer 8d5d6bd1a5 Updated TODO list.
committer: mfx <mfx> 1060091356 +0000
2003-08-05 13:49:16 +00:00
Markus F.X.J. Oberhumer 05f6f4d2ff Bump version date.
committer: mfx <mfx> 1060090111 +0000
2003-08-05 13:28:31 +00:00
Markus F.X.J. Oberhumer 9e154e33c3 Win64 updates.
committer: mfx <mfx> 1060086924 +0000
2003-08-05 12:35:24 +00:00
Markus F.X.J. Oberhumer 5125f4d4ac New ACC version.
committer: mfx <mfx> 1060086835 +0000
2003-08-05 12:33:55 +00:00
Markus F.X.J. Oberhumer 365a3c0432 Cleanups.
committer: mfx <mfx> 1059739807 +0000
2003-08-01 12:10:07 +00:00
Markus F.X.J. Oberhumer ab37b5ea0c New ACC version.
committer: mfx <mfx> 1059739715 +0000
2003-08-01 12:08:35 +00:00
Markus F.X.J. Oberhumer 20ddd8590d New ACC version.
committer: mfx <mfx> 1059549679 +0000
2003-07-30 07:21:19 +00:00
Markus F.X.J. Oberhumer 69d9aa6c69 Some fixes for latest gcc 3.4 snapshot.
committer: mfx <mfx> 1059510876 +0000
2003-07-29 20:34:36 +00:00
Markus F.X.J. Oberhumer 2163231401 New ACC version.
committer: mfx <mfx> 1059510824 +0000
2003-07-29 20:33:44 +00:00
Markus F.X.J. Oberhumer f513373693 Updated.
committer: mfx <mfx> 1058967901 +0000
2003-07-23 13:45:01 +00:00
Markus F.X.J. Oberhumer ed0e3b9af4 Small cleanups.
committer: mfx <mfx> 1058967699 +0000
2003-07-23 13:41:39 +00:00
Markus F.X.J. Oberhumer 4205c699ac Correct rounding issue when displaying the compression ratio.
committer: mfx <mfx> 1058789628 +0000
2003-07-21 12:13:48 +00:00
Markus F.X.J. Oberhumer 4e64cdac15 Final round of portab fixes - UPX should now compile on any halfway
modern C++ compiler.

committer: mfx <mfx> 1058789145 +0000
2003-07-21 12:05:45 +00:00
Markus F.X.J. Oberhumer bbbea34d74 New ACC version.
committer: mfx <mfx> 1058788892 +0000
2003-07-21 12:01:32 +00:00
Markus F.X.J. Oberhumer 66565f7238 Some portab fixes.
committer: mfx <mfx> 1058450658 +0000
2003-07-17 14:04:18 +00:00
Markus F.X.J. Oberhumer 9cb922425e Whitespace changes.
committer: mfx <mfx> 1058450247 +0000
2003-07-17 13:57:27 +00:00
Markus F.X.J. Oberhumer 268e13c572 New ACC version.
committer: mfx <mfx> 1058449640 +0000
2003-07-17 13:47:20 +00:00
John Reiser 03f1f615e5 filter 0x49 for [b]vmlinuz; 2nd parameter for ckt32 (addvalue)
p_vmlinz.cpp stub/macros.ash
	stub/l_lx_elf86.asm
	stub/l_lx_exec86.asm
	stub/l_vmlinz.asm

committer: jreiser <jreiser> 1058406408 +0000
2003-07-17 01:46:48 +00:00
John Reiser 94152391b1 patch ULEN for LZCKLLT1; filter 0x49 still not working
committer: jreiser <jreiser> 1058382714 +0000
2003-07-16 19:11:54 +00:00
John Reiser 2d403e07bb clear eflags; set cs; set ecx for LZCKLLT1; more documentation
committer: jreiser <jreiser> 1058382511 +0000
2003-07-16 19:08:31 +00:00
Markus F.X.J. Oberhumer 48ec581539 Renamed the options sub-structs for more consistency. Some portab fixes.
committer: mfx <mfx> 1058221575 +0000
2003-07-14 22:26:15 +00:00
Markus F.X.J. Oberhumer f9054529c1 New ACC version.
committer: mfx <mfx> 1058104401 +0000
2003-07-13 13:53:21 +00:00
Markus F.X.J. Oberhumer 67d9ff987c Updated.
committer: mfx <mfx> 1058050408 +0000
2003-07-12 22:53:28 +00:00
Markus F.X.J. Oberhumer a3bb8f00fd Updates for latest ACC changes.
committer: mfx <mfx> 1058050328 +0000
2003-07-12 22:52:08 +00:00
Markus F.X.J. Oberhumer 48846c7226 New ACC version.
committer: mfx <mfx> 1058045717 +0000
2003-07-12 21:35:17 +00:00
Markus F.X.J. Oberhumer ad8648f668 New ACC version.
committer: mfx <mfx> 1057743808 +0000
2003-07-09 09:43:28 +00:00
Markus F.X.J. Oberhumer c7224c7727 Added some important TODO entries.
committer: mfx <mfx> 1054071077 +0000
2003-05-27 21:31:17 +00:00
Markus F.X.J. Oberhumer b2949259c5 Portability updates.
committer: mfx <mfx> 1054071025 +0000
2003-05-27 21:30:25 +00:00
Markus F.X.J. Oberhumer 757bdd1264 New ACC version.
committer: mfx <mfx> 1054070133 +0000
2003-05-27 21:15:33 +00:00
Markus F.X.J. Oberhumer ec1e5849eb Remove debug output.
committer: mfx <mfx> 1054069636 +0000
2003-05-27 21:07:16 +00:00
Markus F.X.J. Oberhumer 1752fab911 New ACC version.
committer: mfx <mfx> 1054069577 +0000
2003-05-27 21:06:17 +00:00
Markus F.X.J. Oberhumer b0748388b2 New upstream version.
committer: mfx <mfx> 1052654076 +0000
2003-05-11 11:54:36 +00:00
Markus F.X.J. Oberhumer 175899013e Updated.
committer: mfx <mfx> 1051152491 +0000
2003-04-24 02:48:11 +00:00
Markus F.X.J. Oberhumer c448d15a8f New ACC version.
committer: mfx <mfx> 1051152474 +0000
2003-04-24 02:47:54 +00:00
Markus F.X.J. Oberhumer 5c7bca5b3e Updates.
committer: mfx <mfx> 1050612607 +0000
2003-04-17 20:50:07 +00:00
Markus F.X.J. Oberhumer 390cdbba2d New ACC version.
committer: mfx <mfx> 1050608556 +0000
2003-04-17 19:42:36 +00:00
Markus F.X.J. Oberhumer 256b8f066f New version from Jens.
committer: mfx <mfx> 1049938824 +0000
2003-04-10 01:40:24 +00:00
Markus F.X.J. Oberhumer 30915862cd New upstream version.
committer: mfx <mfx> 1049683526 +0000
2003-04-07 02:45:26 +00:00
Markus F.X.J. Oberhumer eeb1dfaf8f Updated.
committer: mfx <mfx> 1049676306 +0000
2003-04-07 00:45:06 +00:00
Markus F.X.J. Oberhumer 90161bc3a7 New ACC version.
committer: mfx <mfx> 1049665216 +0000
2003-04-06 21:40:16 +00:00
Markus F.X.J. Oberhumer a1064dc2cb New ps1/exe version from Jens.
committer: mfx <mfx> 1049665152 +0000
2003-04-06 21:39:12 +00:00
Markus F.X.J. Oberhumer b8a9b321fa Updated.
committer: mfx <mfx> 1049665135 +0000
2003-04-06 21:38:55 +00:00
Markus F.X.J. Oberhumer a3e80b1628 Fixed call to typeid().
committer: mfx <mfx> 1049380061 +0000
2003-04-03 14:27:41 +00:00
Markus F.X.J. Oberhumer 350ebfc47d *** empty log message ***
committer: mfx <mfx> 1049380046 +0000
2003-04-03 14:27:26 +00:00
Markus F.X.J. Oberhumer b9b75c536c *** empty log message ***
committer: mfx <mfx> 1049237553 +0000
2003-04-01 22:52:33 +00:00
Markus F.X.J. Oberhumer 8b74704bbf *** empty log message ***
committer: mfx <mfx> 1049203016 +0000
2003-04-01 13:16:56 +00:00
Markus F.X.J. Oberhumer bead894e49 Updated.
committer: mfx <mfx> 1049194128 +0000
2003-04-01 10:48:48 +00:00
John Reiser 502f9b5a00 better hadling of Linux AT_SYSINFO (32 <= a_type)
committer: jreiser <jreiser> 1048872136 +0000
2003-03-28 17:22:16 +00:00
Markus F.X.J. Oberhumer cd15b7d5af *** empty log message ***
committer: mfx <mfx> 1048717636 +0000
2003-03-26 22:27:16 +00:00
Markus F.X.J. Oberhumer 0c1d544e98 *** empty log message ***
committer: mfx <mfx> 1048663373 +0000
2003-03-26 07:22:53 +00:00
Markus F.X.J. Oberhumer 728be1867f *** empty log message ***
committer: mfx <mfx> 1048662806 +0000
2003-03-26 07:13:26 +00:00
Markus F.X.J. Oberhumer 09578df46b New ACC system.
committer: mfx <mfx> 1048662134 +0000
2003-03-26 07:02:14 +00:00
Markus F.X.J. Oberhumer b29f5b7c09 *** empty log message ***
committer: mfx <mfx> 1048661664 +0000
2003-03-26 06:54:24 +00:00
Markus F.X.J. Oberhumer 10f602fca7 *** empty log message ***
committer: mfx <mfx> 1048661243 +0000
2003-03-26 06:47:23 +00:00
Markus F.X.J. Oberhumer 2f8917f450 wc/le: Refuse to pack files without relocations. This should be fixed.
committer: mfx <mfx> 1048283863 +0000
2003-03-21 21:57:43 +00:00
Markus F.X.J. Oberhumer b57f48d543 Updated.
committer: mfx <mfx> 1046369903 +0000
2003-02-27 18:18:23 +00:00
Markus F.X.J. Oberhumer 87a4d8455d Updated.
committer: mfx <mfx> 1046366795 +0000
2003-02-27 17:26:35 +00:00
Markus F.X.J. Oberhumer b14df392fa Updated.
committer: mfx <mfx> 1045574984 +0000
2003-02-18 13:29:44 +00:00
Markus F.X.J. Oberhumer 437c34a68c Small cleanups.
committer: mfx <mfx> 1044946475 +0000
2003-02-11 06:54:35 +00:00
Markus F.X.J. Oberhumer b218cec3d7 Updated for VC7.
committer: mfx <mfx> 1044418804 +0000
2003-02-05 04:20:04 +00:00
Markus F.X.J. Oberhumer f19c91243a Cleanups.
committer: mfx <mfx> 1044346802 +0000
2003-02-04 08:20:02 +00:00
Markus F.X.J. Oberhumer 882e1be2db Cleanups.
committer: mfx <mfx> 1044346308 +0000
2003-02-04 08:11:48 +00:00
Markus F.X.J. Oberhumer 8e21c1e965 Updated.
committer: mfx <mfx> 1043776870 +0000
2003-01-28 18:01:10 +00:00
Markus F.X.J. Oberhumer f3970eaed9 Updated.
committer: mfx <mfx> 1043694056 +0000
2003-01-27 19:00:56 +00:00
Markus F.X.J. Oberhumer ac4b8f8617 Use MemBuffer.clear().
committer: mfx <mfx> 1043693892 +0000
2003-01-27 18:58:12 +00:00
Markus F.X.J. Oberhumer 51c28020de Use a MemBuffer instead of a pointer.
committer: mfx <mfx> 1043693800 +0000
2003-01-27 18:56:40 +00:00
Markus F.X.J. Oberhumer fd525ae7df Portability fixes.
committer: mfx <mfx> 1043693750 +0000
2003-01-27 18:55:50 +00:00
Markus F.X.J. Oberhumer a282171318 Rewritten.
committer: mfx <mfx> 1043693646 +0000
2003-01-27 18:54:06 +00:00
Markus F.X.J. Oberhumer c3040d1636 Updated.
committer: mfx <mfx> 1043693611 +0000
2003-01-27 18:53:31 +00:00
John Reiser c76c07aea0 prepare to allow multiple decompressors and multiple unfilters
committer: jreiser <jreiser> 1043441624 +0000
2003-01-24 20:53:44 +00:00
László Molnár 1282ed333a djgpp2/coff updates
committer: ml1050 <ml1050> 1043312061 +0000
2003-01-23 08:54:21 +00:00
Markus F.X.J. Oberhumer 32e76e88cf Updated.
committer: mfx <mfx> 1043211831 +0000
2003-01-22 05:03:51 +00:00
Markus F.X.J. Oberhumer fc0d3ff118 Updated.
committer: mfx <mfx> 1043101129 +0000
2003-01-20 22:18:49 +00:00
Markus F.X.J. Oberhumer 0bd05c0d67 Updated.
committer: mfx <mfx> 1042994191 +0000
2003-01-19 16:36:31 +00:00
Markus F.X.J. Oberhumer ff2c5300b8 New upstream version.
committer: mfx <mfx> 1042993977 +0000
2003-01-19 16:32:57 +00:00
Markus F.X.J. Oberhumer a38989dfbf Updated.
committer: mfx <mfx> 1042930217 +0000
2003-01-18 22:50:17 +00:00
Markus F.X.J. Oberhumer e387c6bc56 Portability updates.
committer: mfx <mfx> 1042930101 +0000
2003-01-18 22:48:21 +00:00
John Reiser 5eb81c0ec4 omit unfilter when .b_ftid==0
committer: jreiser <jreiser> 1042755704 +0000
2003-01-16 22:21:44 +00:00
Markus F.X.J. Oberhumer f92b617c43 Updated.
committer: mfx <mfx> 1042742278 +0000
2003-01-16 18:37:58 +00:00
Markus F.X.J. Oberhumer 8f25c72085 Consistently use const Class &' instead of Class const &'.
committer: mfx <mfx> 1042741665 +0000
2003-01-16 18:27:45 +00:00
Markus F.X.J. Oberhumer 7860e7a249 Updated.
committer: mfx <mfx> 1042741465 +0000
2003-01-16 18:24:25 +00:00
Markus F.X.J. Oberhumer a2e3ceb8c8 Portability updates.
committer: mfx <mfx> 1042738038 +0000
2003-01-16 17:27:18 +00:00
Markus F.X.J. Oberhumer e96ad21db1 Added support for Intel C++ 7.0.
committer: mfx <mfx> 1042686101 +0000
2003-01-16 03:01:41 +00:00
Markus F.X.J. Oberhumer 888ac8a220 Updated.
committer: mfx <mfx> 1042654719 +0000
2003-01-15 18:18:39 +00:00
Markus F.X.J. Oberhumer 29db8bca3a Major cleanup.
committer: mfx <mfx> 1042637889 +0000
2003-01-15 13:38:09 +00:00
Markus F.X.J. Oberhumer 63d49f0143 Updated.
committer: mfx <mfx> 1042637875 +0000
2003-01-15 13:37:55 +00:00
Markus F.X.J. Oberhumer 378224c6ba Updated.
committer: mfx <mfx> 1042634011 +0000
2003-01-15 12:33:31 +00:00
Markus F.X.J. Oberhumer 2f3e7a82b5 Detabified.
committer: mfx <mfx> 1042632555 +0000
2003-01-15 12:09:15 +00:00
Markus F.X.J. Oberhumer 960f020277 Fixed typos.
committer: mfx <mfx> 1042632460 +0000
2003-01-15 12:07:40 +00:00
Markus F.X.J. Oberhumer 6962da718c Added some calls to MemBuffer::checkState().
committer: mfx <mfx> 1042580584 +0000
2003-01-14 21:43:04 +00:00
Markus F.X.J. Oberhumer 42575d9f57 Use NULL instead of 0.
committer: mfx <mfx> 1042580552 +0000
2003-01-14 21:42:32 +00:00
Markus F.X.J. Oberhumer 03fb0d95c6 Rewrote MemBuffer to do some internal checks.
committer: mfx <mfx> 1042580463 +0000
2003-01-14 21:41:03 +00:00
Markus F.X.J. Oberhumer beb766b005 Major cleanup. Jens, please have a look.
committer: mfx <mfx> 1042576817 +0000
2003-01-14 20:40:17 +00:00
Markus F.X.J. Oberhumer 29c1f67057 Cleanup.
committer: mfx <mfx> 1042576530 +0000
2003-01-14 20:35:30 +00:00
Markus F.X.J. Oberhumer a709b38065 Use new file+MemBuffer methods.
committer: mfx <mfx> 1042576321 +0000
2003-01-14 20:32:01 +00:00
Markus F.X.J. Oberhumer ec5840fb2a Added overloaded write functions for MemBuffer.
committer: mfx <mfx> 1042576236 +0000
2003-01-14 20:30:36 +00:00
Markus F.X.J. Oberhumer 9511e3c9b1 Added ALIGN_GAP(a,b) marco.
committer: mfx <mfx> 1042576135 +0000
2003-01-14 20:28:55 +00:00
Markus F.X.J. Oberhumer 9190e7d51a Use new allocForCompression().
committer: mfx <mfx> 1042575473 +0000
2003-01-14 20:17:53 +00:00
Markus F.X.J. Oberhumer cff830c43b Cleanup.
committer: mfx <mfx> 1042575285 +0000
2003-01-14 20:14:45 +00:00
Markus F.X.J. Oberhumer e31c45dc10 Allow a number of extra bytes in the allocForXXX() methods.
committer: mfx <mfx> 1042575213 +0000
2003-01-14 20:13:33 +00:00
Markus F.X.J. Oberhumer e1da733810 Updated.
committer: mfx <mfx> 1042567596 +0000
2003-01-14 18:06:36 +00:00
Markus F.X.J. Oberhumer b8c34036a5 Cleanups.
committer: mfx <mfx> 1042565088 +0000
2003-01-14 17:24:48 +00:00
Markus F.X.J. Oberhumer d771f219f0 Bumped version.
committer: mfx <mfx> 1042565001 +0000
2003-01-14 17:23:21 +00:00
Markus F.X.J. Oberhumer d8280343f9 Makefiles updated.
committer: mfx <mfx> 1042564758 +0000
2003-01-14 17:19:18 +00:00
Markus F.X.J. Oberhumer c7b9395866 Detabified.
committer: mfx <mfx> 1042564671 +0000
2003-01-14 17:17:51 +00:00
Markus F.X.J. Oberhumer 992ceee52b CLeanups.
committer: mfx <mfx> 1042480204 +0000
2003-01-13 17:50:04 +00:00
Markus F.X.J. Oberhumer 2162a01848 Enter 2003.
committer: mfx <mfx> 1042478199 +0000
2003-01-13 17:16:39 +00:00
Markus F.X.J. Oberhumer 102e0f0a98 Re-worked the Makefiles.
committer: mfx <mfx> 1042477974 +0000
2003-01-13 17:12:54 +00:00
John Reiser 4e0967e0a1 Code to supply a "linking view" for /usr/bin/strip.
(Not used today because yet another bug is worse.)  See
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=81644

committer: jreiser <jreiser> 1042341933 +0000
2003-01-12 03:25:33 +00:00
John Reiser 73dc4eede0 Elf_LE32_Shdr; set_native16()
p_elf.h p_unix.h

committer: jreiser <jreiser> 1042341777 +0000
2003-01-12 03:22:57 +00:00
Markus F.X.J. Oberhumer 5e5ea9f6e4 Cleanups.
committer: mfx <mfx> 1041858220 +0000
2003-01-06 13:03:40 +00:00
Markus F.X.J. Oberhumer e537f25857 Default to `-cpu=i686'.
committer: mfx <mfx> 1041858189 +0000
2003-01-06 13:03:09 +00:00
Markus F.X.J. Oberhumer 47aea88c27 Whitespace changes.
committer: mfx <mfx> 1041858159 +0000
2003-01-06 13:02:39 +00:00
Markus F.X.J. Oberhumer 0237bf8915 Updated.
committer: mfx <mfx> 1041858132 +0000
2003-01-06 13:02:12 +00:00
Markus F.X.J. Oberhumer 3a7032f21c Updated.
committer: mfx <mfx> 1041162781 +0000
2002-12-29 11:53:01 +00:00
John Reiser 54d01790b5 Linux 2.5.53 has some Elf32_auxv_t.a_type >= 32
committer: jreiser <jreiser> 1040352519 +0000
2002-12-20 02:48:39 +00:00
John Reiser fb3375112e [B]VMLINUZ for 0x40 series filters
packerf.cpp p_vmlinz.cpp

committer: jreiser <jreiser> 1039144160 +0000
2002-12-06 03:09:20 +00:00
John Reiser 554f22a14f ckt32 for 0x40 series filters
committer: jreiser <jreiser> 1039144122 +0000
2002-12-06 03:08:42 +00:00
Markus F.X.J. Oberhumer eb6a6e3909 Cleanups.
committer: mfx <mfx> 1037132993 +0000
2002-11-12 20:29:53 +00:00
Markus F.X.J. Oberhumer 041947507f Small patch from Jens.
committer: mfx <mfx> 1037131376 +0000
2002-11-12 20:02:56 +00:00
Markus F.X.J. Oberhumer ff03ac17b2 Cosmetic changes.
committer: mfx <mfx> 1037106750 +0000
2002-11-12 13:12:30 +00:00
John Reiser 12c6cd8021 Comment on current state of stub/fold* vs decompress, and independent unfilter.
p_lx_elf.cpp p_lx_exc.cpp

committer: jreiser <jreiser> 1037072124 +0000
2002-11-12 03:35:24 +00:00
John Reiser de6e8c8020 upx_itoa() in assembler to enforce no relocation
Makefile l_lx_exec.c upx_itoa.asm

committer: jreiser <jreiser> 1037070863 +0000
2002-11-12 03:14:23 +00:00
Markus F.X.J. Oberhumer f3b64cfe78 Bumped version.
committer: mfx <mfx> 1037068905 +0000
2002-11-12 02:41:45 +00:00
449 changed files with 117496 additions and 16894 deletions
-4
View File
@@ -1,4 +0,0 @@
.cvsignore
ChangeLog.cvs*
build
maint
+51
View File
@@ -0,0 +1,51 @@
syntax: regexp
^\.bzr
^ChangeLog
^Makevars.global
^build
^maint
syntax: glob
Makevars.local
*.a
*.dll
*.lib
*.py[cdo]
*.so
*.swp
doc/*.1
doc/*.doc
doc/*.html
doc/*.man
doc/*.ps
doc/*.tex
src/GNUmakefile
src/MMakefile
src/compress_nrv*
src/*.mft
src/*.rc
src/*.d
src/*.exe
src/*.map
src/*.o
src/*.obj
src/*.out
src/*.res
src/*.ttp
stub/**MMakefile
stub/**.*-stamp
stub/tmp*/*
stub/**/tmp*/*
stub/tools/armpe/armpe_tester
stub/tools/sstrip/amd64-linux-sstrip
stub/tools/sstrip/i386-linux-sstrip
stub/tools/sstrip/sstrip
+15
View File
@@ -0,0 +1,15 @@
140415ffbcef86a42b4d672249927364430d3d38 RELEASE_111
223ac5b23f9731ceac9ff8d65167df4900776e36 RELEASE_190
2c753c5bf38e7322715e2a5c6c5381111bd7a61a RELEASE_194
2ee65b77f9117651e2e5517b2edede23698d73ca RELEASE_196
396983c065fc743cb5b9703e266ca87eeff8a6ee RELEASE_291
70402aeee6e0e4fc2889658ed8cee44461c0b0a8 RELEASE_200
a1c61174f54aac714f59ac20fcba839d71e64c5c RELEASE_292
a916a2fe22de45167d25abcb40008315f415221c RELEASE_201
a935d577fc7dd9c2c87761c9c702805da6ce1e51 RELEASE_193
b0353253b0b3d062eb5adb50d4b665a96620da45 RELEASE_195
b82ef51896199484afe5b0553af7d1e59b7ce428 BRANCHPOINT_FOR_upx2.hg
c2e0cd4d621b047f254f2def42132a03683ff52c RELEASE_192
d276aa09033c24d0981bc3f4fee5628aecc988ad RELEASE_290
eb1ce56dce7dd1835964362470610925963b9043 RELEASE_110
ed96891ef795bceec6b7ff3ca1ca7764431bfb39 RELEASE_191
+2 -2
View File
@@ -8,8 +8,8 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2002 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2007 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
Limitations and other things which are not (yet) supported: Limitations and other things which are not (yet) supported:
+14 -15
View File
@@ -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.
+31 -17
View File
@@ -1,33 +1,47 @@
# Toplevel Makefile for UPX #
# UPX toplevel Makefile - needs GNU make 3.80 or better
#
SHELL = /bin/sh MAKEFLAGS += -rR
.SUFFIXES:
export SHELL = /bin/sh
srcdir = . srcdir = .
top_srcdir = . top_srcdir = .
-include $(top_srcdir)/Makevars.global ./Makevars.local
# info: src/stub needs GNU make 3.81 and special build tools
BUILD_STUB = 0
ifneq ($(wildcard $(HOME)/local/bin/bin-upx/.),)
BUILD_STUB = 1
endif
ifneq ($(wildcard $(HOME)/bin/bin-upx/.),)
BUILD_STUB = 1
endif
ifneq ($(findstring $(firstword $(MAKE_VERSION)),3.79 3.79.1 3.80),)
BUILD_STUB = 0
endif
default:
@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
false
zip:
cd .. && rm -f upx-current.zip && zip -r upx-current.zip upx
cvs-admin-ko:
cvs admin -ko .
cvs update
ifneq ($(wildcard .hg/data/.),)
# automatically generate ChangeLog from local Mercurial repo
ChangeLog: ChangeLog:
perl $(srcdir)/scripts/cvs2cl.pl --utc -f ChangeLog.cvs hg log --style=changelog > $@
.PHONY: ChangeLog
endif
.PHONY: all mostlyclean clean distclean maintainer-clean .PHONY: default all mostlyclean clean distclean maintainer-clean
.PHONY: dist cvs-admin-ko ChangeLog
.NOEXPORT:
+142 -32
View File
@@ -2,19 +2,119 @@
User visible changes for UPX User visible changes for UPX
================================================================== ==================================================================
[ BETA VERSION - please see README.1ST for some more info ] 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 occuring 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):
* 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/ppc32
* new format: added support for mach/ppc32 (Apple Mac OS X)
* win32/pe: hopefully working "load config" support
* win32/pe: R6002 runtime errors worked around
* win32/pe: the stub now clears the dirty stack
Changes in 1.93 beta (07 Feb 2005):
* vmlinuz/386: fixes to support more kernels
Changes in 1.92 beta (20 Jul 2004):
* win32/pe: added option '--strip-loadconf' to strip the SEH load
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]
* vmlinux/386: new format that directly supports building Linux kernels
* source code: now compiles cleanly under Win64
Changes in 1.91 beta (30 Jun 2004):
* djgpp2/coff: added support for recent binutils versions
* linux/elf386, linux/sh386: lots of improvements
* vmlinuz/386: added support for recent kernels
* watcom/le: don't crash on files without relocations
* win32/pe: stricter checks of some PE values
* option '--brute' now implies '--crp-ms=999999'.
* source code: much improved portability using ACC, the
Automatic Compiler Configuration
* source code: compile fixes for strict ISO C++ compilers
* source code: compile fixes for Win64
* re-synced with upx 1.25 branch
Changes in 1.90 beta (11 Nov 2002): Changes in 1.90 beta (11 Nov 2002):
* UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING
* 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
* documentation updates * documentation updates
Changes in 1.11 beta (20 Dec 2000): Changes in 1.11 beta (20 Dec 2000):
* UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING
* vmlinuz/386: new format - UPX now supports bootable linux kernels * vmlinuz/386: new format - UPX now supports bootable linux kernels
* linux/elf386: added the new ELF direct-to-memory executable format - no * linux/elf386: added the new ELF direct-to-memory executable format - no
more temp files are needed for decompression! more temp files are needed for decompression!
@@ -25,6 +125,15 @@ Changes in 1.11 beta (20 Dec 2000):
================================================================== ==================================================================
Changes in 1.25 (29 Jun 2004)
* INFO: http://upx.sourceforge.net is the permanent UPX home page
* watcom/le: don't crash on files without relocations
* win32/pe: stricter checks of some PE values
* source code: much improved portability using ACC, the
Automatic Compiler Configuration
* source code: compile fixes for strict ISO C++ compilers
* source code: compile fixes for Win64
Changes in 1.24 (07 Nov 2002) Changes in 1.24 (07 Nov 2002)
* djgpp2/coff: stricter check of the COFF header to work around a * djgpp2/coff: stricter check of the COFF header to work around a
problem with certain binutils versions problem with certain binutils versions
@@ -41,13 +150,13 @@ Changes in 1.23 (05 Sep 2002)
Changes in 1.22 (27 Jun 2002) Changes in 1.22 (27 Jun 2002)
* atari/tos: the stub now flushes the CPU cache to avoid * atari/tos: the stub now flushes the CPU cache to avoid
problems on 68030+ machines problems on 68030+ machines
* source code: additional compiler support for Borland C++ 5.5.1, * source code: additional compiler support for Borland C++,
Digital Mars C++ 8.28 and Watcom C++ 11.0c 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
@@ -61,7 +170,6 @@ Changes in 1.20 (23 May 2001)
our unstable development releases 1.1x and 1.9x] our unstable development releases 1.1x and 1.9x]
Changes in 1.08 (30 Apr 2001) Changes in 1.08 (30 Apr 2001)
* INFO: http://upx.sourceforge.net now is the new permanent UPX home page
* new native port to atari/tos * new native port to atari/tos
* win32/pe: shortened the identstring * win32/pe: shortened the identstring
* source code: portability fixes - UPX now builds cleanly under m68k CPUs * source code: portability fixes - UPX now builds cleanly under m68k CPUs
@@ -86,7 +194,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
@@ -94,7 +202,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
@@ -102,7 +210,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)
@@ -130,7 +238,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
@@ -153,7 +261,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
@@ -163,7 +271,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)
@@ -179,7 +287,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
@@ -188,32 +296,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)
@@ -227,20 +335,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
@@ -257,7 +365,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
@@ -281,7 +389,7 @@ Changes in 0.40 (05 Oct 1998)
* fixed a small but fatal bug in dos/sys introduced in 0.30 * fixed a small but fatal bug in dos/sys introduced in 0.30
* fixed a rare bug in dos/exe * fixed a rare bug in dos/exe
* worked around a bug in djgpp's strip 2.8 * worked around a bug in djgpp's strip 2.8
* Allegro packfile support should work now * djgpp/coff: Allegro packfile support should work now
* added dos/exeh compression method (works on 386+) * added dos/exeh compression method (works on 386+)
Changes in 0.30 (27 Jul 1998) Changes in 0.30 (27 Jul 1998)
@@ -298,3 +406,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 -*-
+3 -8
View File
@@ -8,8 +8,8 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2002 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2007 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
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
@@ -42,8 +42,6 @@ More formats:
- freebsd/386 (generic), freebsd/elf386 (specialized). - freebsd/386 (generic), freebsd/elf386 (specialized).
Probably could share most of the linux code. Probably could share most of the linux code.
- Windows CE
- add support for self-extracting HTML pages using a Javascript stub - add support for self-extracting HTML pages using a Javascript stub
(like the AlgART HTML Packer "AHP") (like the AlgART HTML Packer "AHP")
@@ -58,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)
@@ -70,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:
+11 -25
View File
@@ -8,26 +8,11 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2002 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2007 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
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.22, and the next stable release
will be called version 2.00.
The main news since 1.22 are support for bootable Linux kernels ("vmlinuz/386")
and direct Linux ELF-to-memory decompression ("linux/elf386"), so there's
no reason to use the unstable versions unless you want to try the new formats.
WELCOME WELCOME
======= =======
@@ -52,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
@@ -70,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.
@@ -85,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.
@@ -111,7 +96,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 ;-)
@@ -123,8 +108,9 @@ THE FUTURE
COPYRIGHT COPYRIGHT
========= =========
Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2007 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.
@@ -143,7 +129,7 @@ Markus & Laszlo
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu markus@oberhumer.com ml1050@users.sourceforge.net
+12 -12
View File
@@ -8,24 +8,24 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2007 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net
WARNING - UNSTABLE BETA VERSION WARNING - UNSTABLE BETA VERSION
=============================== ===============================
All versions 1.9x are unstable beta releases - use them only for testing, The current stable release is 2.02, and the next stable release
and never distribute a program that is packed with them ! will be called version 3.00.
There will be hidden bugs. Really.
The current stable release is 1.24, and the next stable release
will be called version 2.00.
The main news since 1.24 are: MAJOR NEWS IN UPX 3
- slightly better compression using the new NRV2E algorithm ===================
- new options for compression tuining (e.g. `--brute')
- support for bootable Linux kernels ("vmlinuz/386") The main news since UPX 2 are:
- direct Linux ELF-to-memory decompression ("linux/elf386")
- support for playstation exes ("ps1/exe") * new format: added support for linux elf/arm
- lots of new bugs ;-) take care
* better compression using the LZMA algorithm (option '--lzma')
+22 -30
View File
@@ -66,49 +66,42 @@ Prerequisites
Tools needed to build/modify the UPX sources Tools needed to build/modify the UPX sources
-------------------------------------------- --------------------------------------------
- A modern C++ compiler like gcc 2.95.3 or Visual C++ 6 - A C++ compiler supporting inner classes, templates, exceptions
and RTTI.
- GNU make for Win32 - GNU make 3.80 or better (GNU make 3.81 recommened).
http://upx.sourceforge.net/download/tools/
- GNU make for DOS
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/
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.01 (DOS / Windows) set UPX_UCLDIR=c:\src\ucl-1.03 (DOS / Windows)
export UCLDIR=$HOME/local/src/ucl-1.01 (Unix) export UPX_UCLDIR=$HOME/local/src/ucl-1.03 (Unix)
then type Set the environment variable UPX_LZMADIR to point to your
to your unpacked lzma443.tar.bz2 source directory, e.g.
make target=linux # on linux export UPX_LZMADIR=$HOME/local/src/lzma-4.43 (Unix)
make target=djgpp2 # for djgpp2
make target=mingw32 # for mingw32 Finally type
make target=cygwin # cygwin 1.3.x
make target=no-cygwin # for mingw32 as included in cygwin make
make target=vc6 # for Visual C++ 6.0
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.34 - the Netwide Assembler - GNU make 3.81 or better
http://upx.sourceforge.net/download/tools/ http://savannah.gnu.org/projects/make/
http://nasm.sourceforge.net/
- A68K - a 68000 macro assembler - Perl & Python
http://upx.sourceforge.net/download/tools/
- djasm - an assembler for the djgpp stub - A number of cross-assemblers and cross-compilers - precompiled
http://upx.sourceforge.net/download/tools/ binaries for i386-linux hosts are available from
http://sourceforge.net/project/showfiles.php?group_id=2331
- Perl 5.004 or better
- Linux (for the linux/386 stubs)
Misc. notes Misc. notes
@@ -123,9 +116,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.
*** ***
@@ -150,3 +140,5 @@ Patches/Contributions
diff -uNr olddirectory newdirectory diff -uNr olddirectory newdirectory
# vi:ts=4:et
+4 -4
View File
@@ -8,8 +8,8 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2002 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2007 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
.___.. . .___.. .
@@ -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
+15 -12
View File
@@ -1,4 +1,14 @@
UPX TODO list. Last updated 2002-11-11. UPX TODO list. Last updated 2006-12-08.
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 - check all <const_cast> to make sure they are not invalid
@@ -6,6 +16,8 @@ UPX TODO list. Last updated 2002-11-11.
(info: bla bla). Also ui.cpp (total_*). (info: bla bla). Also ui.cpp (total_*).
-----------------------------------------------------------------------
IMPROVED COMPRESSION RATIO IMPROVED COMPRESSION RATIO
========================== ==========================
@@ -29,8 +41,6 @@ ALL FORMATS
- implement `--cpu=486' option to use bswap on the 32-bit formats - implement `--cpu=486' option to use bswap on the 32-bit formats
(if cpu >= 486) (if cpu >= 486)
- consider removing "or ebp,-1" when not needed
FORMAT DJGPP2/COFF FORMAT DJGPP2/COFF
================== ==================
@@ -65,6 +75,8 @@ FORMAT TMT/ADAM
FORMAT WATCOM/LE FORMAT WATCOM/LE
================ ================
- handle files without relocations
- the decompressors are already aligned, no need for an - the decompressors are already aligned, no need for an
extra alignment extra alignment
@@ -72,10 +84,6 @@ FORMAT WATCOM/LE
- handle holes in the file - handle holes in the file
- implement compressWithFilters()
- add a call to verifyOverlappingDecompression()
FORMAT WIN16/NE FORMAT WIN16/NE
=============== ===============
@@ -91,11 +99,6 @@ FORMAT WIN32/PE
- decrease runtime memory overhead - 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 - medium - ml) rebuild exports
3 - difficult) don't compress the BSS section and other holes. 3 - difficult) don't compress the BSS section and other holes.
4 - medium - ml) fix when objectalign < 0x1000 4 - medium - ml) fix when objectalign < 0x1000
-6
View File
@@ -1,6 +0,0 @@
upx.1
upx.doc
upx.html
upx.man
upx.ps
upx.tex
+53 -36
View File
@@ -1,34 +1,51 @@
#
# UPX doc Makefile - needs GNU make 3.80 or better
#
MAKEFLAGS += -rR
.SUFFIXES:
SHELL = /bin/sh SHELL = /bin/sh
top_srcdir = .. # internal make variables
comma := ,
empty :=
space := $(empty) $(empty)
tab := $(empty) $(empty)
PACKAGE = upx # update $PATH for our special stub build tools
VERSION_DATE = 11 Nov 2002 ifneq ($(wildcard $(HOME)/local/bin/bin-upx/.),)
VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h) export PATH := $(HOME)/local/bin/bin-upx:$(PATH)
endif
ifneq ($(wildcard $(HOME)/bin/bin-upx/.),)
export PATH := $(HOME)/bin/bin-upx:$(PATH)
endif
TRIMSPACE = cat
TRIMSPACE = sed -e 's/ *$$//' # /***********************************************************************
# //
# ************************************************************************/
top_srcdir ?= ..
PACKAGE = upx
VERSION_DATE := $(shell sed -n 's/^.*UPX_VERSION_DATE_ISO .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
RTRIM := sed -e 's/[ $(tab)]*$$//'
DETAB2 := sed -e 's/$(tab)/ /g'
BUILT_SOURCES = upx.1 upx.doc upx.html upx.man upx.ps upx.tex BUILT_SOURCES = upx.1 upx.doc upx.html 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 +54,32 @@ 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) > $@
@-rm -f pod2htm*
.pod.tex: %.doc : %.pod
pod2text < $< | $(RTRIM) > $@
%.html : %.pod
pod2html --noindex $< | $(RTRIM) | $(DETAB2) > $@
@rm -f pod2htm*
%.man : %.1
nroff -man $< | $(RTRIM) > $@
%.ps : %.1
groff -man $< | $(RTRIM) > $@
%.tex : %.pod
pod2latex $< pod2latex $<
.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:
+19 -3
View File
@@ -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-2007 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.
@@ -57,9 +57,25 @@ 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.
Because the UPX runtime stub removes all traces of the compressed file
from the address space, then the Linux kernel erases the symlink
/proc/self/exe. 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. 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.
+26 -65
View File
@@ -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 (they are all 8 character length strings):
addLoader("PEMAIN20", addLoader("PEMAIN20",
ih.entry ? "PEDOJUMP" : "PERETURN", ih.entry ? "PEDOJUMP" : "PERETURN",
@@ -19,71 +11,40 @@ in the following way (they are all 8 character length strings):
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__
xor eax, eax section PEISDLL1
label1: cmpb [esp + 8], 1
jmps label1 jnz reloc_end_jmp
;__FOOBARZZ__ section PEMAIN21
reloc_end_jmp:
p_foo.cpp section PERETURN
--------- xor eax, eax
inc eax
ret 0x0C
section PEDOJUMP
jmp original_entry
addLoader("FOOBAR00", NULL); Everything works as you would expect. If you want to add the code
fragment which is in `section PERETURN' to the runtime stub, then
This will add the assembly section starting from __FOOBAR00__ and ending simply use `addLoader("PERETURN")' in the C++ source.
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.
+43
View File
@@ -0,0 +1,43 @@
UPX and SELinux
March 6, 2006
When a program that has been compressed by UPX is run, the decompressor
must create and write new memory pages of executable instructions.
SELinux (Security Enhanced Linux) directly controls the conditions
under which generating and/or executing new instructions is allowed,
so the configuration settings of SELinux affect the running of programs
that have been compressed by UPX.
In SELinux "strict enforcing" mode (the most restrictive), generating
new instructions at runtime is not allowed at all: any page with
PROT_EXEC permission must be mapped from a file in a mounted filesystem
that has 'x' [eXecute] permission, and the generation of such files is
also tightly controlled. A program that was compressed by UPX will not
run in SELinux strict enforcing mode. Attempts will fail with exit
code 127, and a record will be added to the history file
/var/log/audit/audit.log.
In "targeted enforcing" mode, SELinux pays close attention mostly to
designated processes that run with elevated privileges: web server,
print server, login server, etc. Ordinary user excutables receive
much less scrutiny. However, one of the eventual goals of SELinux is to
eradicate runtime generation of instructions because of the possibility
for exploitation by malware (virus, trojan, key logger, privilege
elevation exploit, etc.) Thus targeted enforcing mode notices and
logs the use of "execmem" capability that is used by a program which
was compressed by UPX. In keeping with the goal of eventual prohibition,
SELinux ordinarily would deny execmem. However, most current SELinux
systems, including Fedora Core 5 [set for release March 15, 2006],
override this with "allow_exemem=1" in /etc/selinux/targeted/booleans.
Thus a program compressed by UPX will run in the default installed
configuration (targeted enforcing, allow_execmem=1) of SELinux under
Fedora Core 5. Each invocation will add a few lines to the log file
/var/log/audit/audit.log, one line for each use of execmem. If the
SELinux policy becomes more restrictive in the future, then a special
SELinux class or other mechanism must be created for compressed programs,
or else UPX-compressed executables will not run then.
In its "permissive" modes, SELinux just logs the potential problems,
but otherwise does not interfere. A program compressed by UPX will run
in any permissive mode.
+107 -74
View File
@@ -12,15 +12,16 @@ 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-2002 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2007 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
B<UPX> is a portable, extendable, high-performance executable packer for B<UPX> is a portable, extendable, high-performance executable packer for
several different executable formats. It achieves an excellent compression several different executable formats. It achieves an excellent compression
ratio and offers I<*very*> fast decompression. Your executables suffer ratio and offers I<*very*> fast decompression. Your executables suffer
no memory overhead or other drawbacks for most of the formats supported. no memory overhead or other drawbacks for most of the formats supported,
because of in-place decompression.
While you may use B<UPX> freely for both non-commercial and commercial While you may use B<UPX> freely for both non-commercial and commercial
executables (for details see the file LICENSE), we would highly executables (for details see the file LICENSE), we would highly
@@ -36,11 +37,6 @@ is considered not politically correct ;-) ]
B<UPX> comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE. B<UPX> comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE.
Having said that, we think that B<UPX> is quite stable now. Indeed we
have compressed lots of files without any problems. Also, the
current version has undergone several months of beta testing -
actually it's more than 4 years since our first public beta back in 1998.
This is the first production quality release, and we plan that future 1.xx This is the first production quality release, and we plan that future 1.xx
releases will be backward compatible with this version. releases will be backward compatible with this version.
@@ -55,7 +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 even on my old Pentium 133 - very fast decompression: about 10 MB/sec on an ancient Pentium 133,
about 200 MB/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
@@ -78,8 +75,13 @@ 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 (exe and dll)
* linux/elfamd64
* linux/elfppc32
* mach/elfppc32
- portable: UPX is written in portable endian-neutral C++ - portable: UPX is written in portable endian-neutral C++
@@ -136,6 +138,9 @@ 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>
[ ...to be written... - type `B<upx --help>' for now ] [ ...to be written... - type `B<upx --help>' for now ]
@@ -166,29 +171,17 @@ Compression level B<--best> may take a long time.
=back =back
Note that compression level B<-9> can be somewhat slow for large 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.
Since UPX 0.70 there is also an extra compression level B<--best> which Quick info for achieving the best compression ratio:
squeezes out even some more compression ratio. While it is usually fine
to use this option with your favorite .com file it may take a long time
to compress a multi-megabyte program. You have been warned.
Tips 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>.
Info: the option B<--brute> is an abbrevation for all the options
B<S<--best> S<--all-methods> S<--all-filters>>.
=item * =item *
@@ -204,12 +197,15 @@ 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 auxiliary data attached after the logical end of
an executable, and it often contains application specific data
(this is a common practice to avoid an extra data file, though
it would be better to use resource sections).
B<UPX> handles overlays like many other executable packers do: it simply B<UPX> handles overlays like many other executable packers do: it simply
copies the overlay after the compressed image. This works with some copies the overlay after the compressed image. This works with some
files, but doesn't work with others. files, but doesn't work with others, depending on how an application
actually accesses this overlayed data.
Since version 0.90 UPX defaults to B<--overlay=copy> for
all executable formats.
--overlay=copy Copy any extra data attached to the file. [DEFAULT] --overlay=copy Copy any extra data attached to the file. [DEFAULT]
@@ -238,7 +234,8 @@ environment variable because of a COMMAND.COM limitation.
Not all of the options are valid in the environment variable - Not all of the options are valid in the environment variable -
B<UPX> will tell you. B<UPX> will tell you.
You can use the B<--no-env> option to turn this support off. You can explicitly use the B<--no-env> option to ignore the
environment variable.
@@ -250,6 +247,7 @@ This is the executable format used by the Atari ST/TT, a Motorola 68000
based personal computer which was popular in the late '80s. Support based personal computer which was popular in the late '80s. Support
of this format is only because of nostalgic feelings of one of of this format is only because of nostalgic feelings of one of
the authors and serves no practical purpose :-). the authors and serves no practical purpose :-).
See http://www.freemint.de for more info.
Packed programs will be byte-identical to the original after uncompression. Packed programs will be byte-identical to the original after uncompression.
All debug information will be stripped, though. All debug information will be stripped, though.
@@ -320,9 +318,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.
@@ -350,11 +345,11 @@ 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 KByte 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
disable this behaviour (see below). disable this functionality (see below).
B<UPX> automatically handles Allegro packfiles. B<UPX> automatically handles Allegro packfiles.
@@ -385,7 +380,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").
@@ -413,14 +408,14 @@ General user's overview
or network I/O. or network I/O.
Depending on the statistics of usage and access, and the relative Depending on the statistics of usage and access, and the relative
speeds of CPU, RAM, swap space, /tmp, and filesystem 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 filesystem. 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,
@@ -429,7 +424,7 @@ General user's overview
then compression may win anyway. then compression may win anyway.
Currently, executables compressed by UPX do not share RAM at runtime Currently, executables compressed by UPX do not share RAM at runtime
in the way that executables mapped from a filesystem do. As a in the way that executables mapped from a file system do. As a
result, if the same program is run simultaneously by more than one result, if the same program is run simultaneously by more than one
process, then using the compressed version will require more RAM and/or process, then using the compressed version will require more RAM and/or
swap space. So, shell programs (bash, csh, etc.) and ``make'' swap space. So, shell programs (bash, csh, etc.) and ``make''
@@ -518,7 +513,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.
@@ -607,7 +602,7 @@ Extra options available for this executable format:
Please read the general Linux description first. Please read the general Linux description first.
The generic linux/386 format decompresses to /tmp and needs The generic linux/386 format decompresses to /tmp and needs
/proc filesystem support. It starts the decompressed program /proc file system support. It starts the decompressed program
via the execve() syscall. via the execve() syscall.
Linux/386 is only selected if the specialized linux/elf386 Linux/386 is only selected if the specialized linux/elf386
@@ -619,11 +614,11 @@ How it works:
For files which are not ELF and not a script for a known "-c" shell, For files which are not ELF and not a script for a known "-c" shell,
UPX uses kernel execve(), which first requires decompressing to a UPX uses kernel execve(), which first requires decompressing to a
temporary file in the filesystem. 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 filesystem buffers. the entire process takes places within the file system buffers.
A compressed executable consists of the UPX stub and an overlay A compressed executable consists of the UPX stub and an overlay
which contains the original program in a compressed form. which contains the original program in a compressed form.
@@ -649,7 +644,7 @@ Specific drawbacks:
decompression, but you still need it for the full execution time decompression, but you still need it for the full execution time
of the program. of the program.
- You must have /proc filesystem support as the stub wants to open - You must have /proc file system support as the stub wants to open
/proc/<pid>/exe and needs /proc/<pid>/fd/X. This also means that you /proc/<pid>/exe and needs /proc/<pid>/fd/X. This also means that you
cannot compress programs that are used during the boot sequence cannot compress programs that are used during the boot sequence
before /proc is mounted. before /proc is mounted.
@@ -661,7 +656,7 @@ 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 MB emacs (which
is less than 1 MB when compressed :-). is less than 1 MB when compressed :-).
Extra options available for this executable format: Extra options available for this executable format:
@@ -677,21 +672,25 @@ Extra options available for this executable format:
This is the executable format used by the Sony PlayStation (PSone), This is the executable format used by the Sony PlayStation (PSone),
a Mips R3000 based gaming console which is popular since the late '90s. a Mips R3000 based gaming console which is popular since the late '90s.
Support of this format is very similar to the Atari one, because of Support of this format is very similar to the Atari one, because of
nostalgic feelings of one of the authors, but this format maybe serves nostalgic feelings of one of the authors.
a practical purpose ;-).
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.
Maximum uncompressed size: ~1998848 bytes. Maximum uncompressed size: ~1.89 / ~7.60 Mbytes.
Notes: Notes:
- UPX creates as default a suitable executable for CD-Mastering
and console transfer. For a CD-Master main executable you could also try
the special option "--boot-only" as described below.
- 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:
@@ -700,14 +699,23 @@ 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.
--8-bit Uses 8 bit size compression [default: 32 bit]
--8mb-ram PSone has 8 MB ram available [default: 2 MB]
--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. This will slightly increase the compression alignment. May slightly improves the compression ratio,
ratio, but the compressed executable will not work but the compressed executable will not boot from a CD.
when started from a CD. Use it for console transfer only !
=head2 NOTES FOR RTM32/PE =head2 NOTES FOR RTM32/PE and ARM/PE
Same as win32/pe. Same as win32/pe.
@@ -751,15 +759,15 @@ Benefits:
- Better compression (but note that the kernel was already compressed, - Better compression (but note that the kernel was already compressed,
so the improvement is not as large as with other formats). so the improvement is not as large as with other formats).
Still, the bytes saved may be essential for special needs like Still, the bytes saved may be essential for special needs like
bootdisks. boot disks.
For example, this is what I get for my 2.2.16 kernel: For example, this is what I get for my 2.2.16 kernel:
1589708 vmlinux 1589708 vmlinux
641073 bzImage [original] 641073 bzImage [original]
560755 bzImage.upx [compressed by "upx -9"] 560755 bzImage.upx [compressed by "upx -9"]
- Much faster decompression at kernel boot time (but decompression - Much faster decompression at kernel boot time (but kernel
speed is not really an issue these days). decompression speed is not really an issue these days).
Drawbacks: Drawbacks:
@@ -798,13 +806,14 @@ 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. If you start can see increased memory usage of your compressed files because the whole
several instances of huge compressed programs you're wasting memory program is loaded into memory at startup.
because the common segements of the program won't get shared If you start several instances of huge compressed programs you're
across the instances. wasting memory because the common segments of the program won't
get shared across the instances.
On the other hand if you're compressing only smaller programs, or 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
smaller, but it's still there. smaller, but it's still there.
@@ -812,12 +821,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 kbytes 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.
@@ -834,9 +850,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.
@@ -847,7 +880,7 @@ Extra options available for this executable format:
address greater or equal to 0x400000. Usually the address greater or equal to 0x400000. Usually the
compressed files becomes smaller, but some files compressed files becomes smaller, but some files
may become larger. Note that the resulting file will may become larger. Note that the resulting file will
not work under Win32s. not work under Windows 3.x (Win32s).
UPX never strips relocations from a DLL UPX never strips relocations from a DLL
regardless of this option. regardless of this option.
@@ -893,13 +926,13 @@ Please report all bugs immediately to the authors.
=head1 COPYRIGHT =head1 COPYRIGHT
Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser Copyright (C) 2000-2007 John F. Reiser
Copyright (C) 2002 Jens Medoch Copyright (C) 2002-2007 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.
View File
-101
View File
@@ -1,101 +0,0 @@
The GNU bfd binary file descriptor package, part of the GNU binutils package,
contains code to recognize an Elf file by looking at fields in the file header.
Many programs (such as gdb, size, objdump, objcopy, strip and others) use bfd.
Unfortunately, bfd has been overly strict. In releases
binutils-2.9.1.0.4, binutils-2.9.1.0.23, binutils-2.9.5.0.0,
binutils-2.10.1,
gdb-4.17, gdb-5.0,
and probably others,
bfd does not recognize a file with zero in Elf32_Ehdr.e_shoff, .e_shentsize,
or .e_shnum, even though the operating system kernel does not care, and many
bfd clients would work just fine in these cases.
Because of its desire to create small size compressed executables, UPX
generates and uses Elf files with zero in .e_shoff, .e_shentsizes, and .e_shnum.
As a result, many widely-distributed instances of gdb, size, objdump, etc.,
refuse to work on UPX-packed executables.
Here is a patch to bfd/elfcode.h which enables many bfd clients to work
with UPX-packed executables. The last two lines of the patch are
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
return -1;
--- elfcode.h.orig Mon Jun 16 11:45:32 1997
+++ elfcode.h Sat Apr 22 10:18:56 2000
@@ -1,5 +1,5 @@
/* ELF executable support for BFD.
- Copyright 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Copyright 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
in "UNIX System V Release 4, Programmers Guide: ANSI C and
@@ -517,14 +517,14 @@
elf_debug_file (i_ehdrp);
#endif
- /* If there is no section header table, we're hosed. */
- if (i_ehdrp->e_shoff == 0)
+ /* If there is no section header table, and relocatable, then we're hosed. */
+ if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_type == ET_REL)
goto got_wrong_format_error;
/* As a simple sanity check, verify that the what BFD thinks is the
size of each section header table entry actually matches the size
- recorded in the file. */
- if (i_ehdrp->e_shentsize != sizeof (x_shdr))
+ recorded in the file, but only if there are any sections. */
+ if (i_ehdrp->e_shentsize != sizeof (x_shdr) && i_ehdrp->e_shnum != 0)
goto got_wrong_format_error;
ebd = get_elf_backend_data (abfd);
@@ -579,6 +579,7 @@
/* Allocate space for a copy of the section header table in
internal form, seek to the section header table in the file,
read it in, and convert it to internal form. */
+ if (i_ehdrp->e_shnum!=0) {
i_shdrp = ((Elf_Internal_Shdr *)
bfd_alloc (abfd, sizeof (*i_shdrp) * i_ehdrp->e_shnum));
elf_elfsections (abfd) = ((Elf_Internal_Shdr **)
@@ -609,6 +610,7 @@
if (! bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx))
goto got_no_match;
}
+ }
/* Read in the program headers. */
if (i_ehdrp->e_phnum == 0)
@@ -644,6 +646,7 @@
bfd_section_from_shdr with it (since this particular strtab is
used to find all of the ELF section names.) */
+ if (i_ehdrp->e_shstrndx != 0) {
shstrtab = bfd_elf_get_str_section (abfd, i_ehdrp->e_shstrndx);
if (!shstrtab)
goto got_no_match;
@@ -657,6 +660,7 @@
if (! bfd_section_from_shdr (abfd, shindex))
goto got_no_match;
}
+ }
/* Let the backend double check the format and override global
information. */
@@ -930,7 +934,7 @@
{
Elf_Internal_Shdr *hdr;
Elf_Internal_Shdr *verhdr;
- long symcount; /* Number of external ELF symbols */
+ unsigned long symcount; /* Number of external ELF symbols */
elf_symbol_type *sym; /* Pointer to current bfd symbol */
elf_symbol_type *symbase; /* Buffer for generated bfd symbols */
Elf_Internal_Sym i_sym;
@@ -978,7 +982,7 @@
sym = symbase = NULL;
else
{
- long i;
+ unsigned long i;
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
return -1;
View File
-1865
View File
File diff suppressed because it is too large Load Diff
-19
View File
@@ -1,19 +0,0 @@
GNUmakefile
*.0??
*.dat
*.idb
*.img
*.map
*.raw
*.rel
*.pdb
*.upx
.gdbinit
.Attic
.deps
compress_nrv.*
upx
upx_nrv
upx_nrv.*
upx_ucl
upx_ucl.*
+61 -598
View File
@@ -1,625 +1,88 @@
# #
# UPX Makefile (GNU make) - works with unix/win32/djgpp2 # UPX Makefile - needs GNU make 3.80 or better
#
# usage:
# `make target=linux' # linux
# `make target=djggp2' # dos32 - djggp2 2.03
# `make target=cygwin' # win32 - cygwin 1.3.x
# `make target=mingw32' # win32 - mingw32
# `make target=no-cygwin' # win32 - mingw32 as included in cygwin 1.3.x
# `make target=bcc' # win32 - Borland C++ 5.5.1
# `make target=dmc' # win32 - Digital Mars C++ 8.30
# `make target=vc6' # win32 - Visual C++ 6.0
# `make target=wcc' # win32 - Watcom C++ 11.0c
# `make target=cross-m68k-linux' # m68k-linux cross compiler
# `make target=cross-mingw32' # i586-mingw32msvc cross compiler
# `make target=cross-mint' # m68k-atari-mint cross compiler
# #
MAKEFLAGS += -rR
# configuration section
ifeq ($(strip $(UCLDIR)),)
# change this to reflect where the UCL library is
UCLDIR = $(HOME)/local/src/ucl-1.01
endif
##target =
DEBUG = 0
# -------------------------------------------------------
# You should not have to change anything below this line.
# -------------------------------------------------------
SHELL = /bin/sh
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .a .c .cpp .exe .lib .o .obj .rc .res .ttp export SHELL = /bin/sh
override e = $($1) $(EXTRA_$1) $(upx_$1) $($(basename $(notdir $@)).$1)
ifndef srcdir
srcdir = . srcdir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
top_srcdir = .. srcdir := $(shell echo '$(srcdir)' | sed 's,/*$$,,')
VPATH = $(srcdir)
# auto-detect the target unless given on the commandline
ifeq ($(strip $(target)),)
##target = djgpp2
ifneq ($(strip $(wildcard /usr/include/linux)),)
target = linux
endif endif
##ifneq ($(strip $(wildcard /platform/sun4?/kernel/unix)),) ifndef top_srcdir
##target = sparc top_srcdir := $(srcdir)/..
##endif endif
-include $(top_srcdir)/Makevars.global ./Makevars.local
ifneq ($(srcdir),.)
##$(info Info: using VPATH . $(srcdir))
VPATH := . $(srcdir)
endif endif
ifeq ($(strip $(target)),) ifeq ($(CXX),)
include please_specify_a_target CXX = g++
endif endif
ifneq ($(findstring $(firstword $(CXX)),g++),)
USE_GNUC ?= 1
# util var for use in the rules - basename of the current target endif
override T = $(basename $@) ifeq ($(USE_GNUC),1)
CXXFLAGS += -MMD
# /***********************************************************************
# // object files
# ************************************************************************/
# these use exceptions & RTTI
OBJECTS1 = \
compress$o except$o file$o lefile$o \
filter$o linker$o mem$o msg$o stdcxx$o work$o ui$o \
packer$o packerf$o packhead$o packmast$o \
p_com$o p_djgpp2$o p_elks$o p_exe$o \
p_lx_elf$o p_lx_exc$o p_lx_sep$o p_lx_sh$o \
p_ps1$o p_sys$o p_tmt$o p_tos$o \
p_unix$o p_vmlinz$o p_w16ne$o p_w32pe$o p_wcle$o
# no exceptions or RTTI
OBJECTS2 = \
filteri$o help$o main$o mygetopt$o snprintf$o util$o \
c_init$o c_file$o c_none$o c_screen$o \
s_object$o s_djgpp2$o s_vcsa$o s_win32$o
# pure C sources
OBJECTS3 =
OBJECTS = $(OBJECTS1) $(OBJECTS2) $(OBJECTS3)
LIBS =
RESOURCES =
# /***********************************************************************
# // compiler settings
# ************************************************************************/
###
### default compiler (gcc under unix)
###
o = .o
a = .a
e =
CC = gcc
DEFS =
INCLUDES =
##INCLUDES = -I. -I$(srcdir)
CFLAGS_OUTPUT = -o $@
LINK_EXE = $(CXXLD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
STUBEDIT_EXE =
STUBIFY_EXE =
CHMOD_EXE =
# C++ defaults are set later
CXX =
CXXLD =
CXXFLAGS_OUTPUT =
###
### gcc defaults
###
##CFLAGS_WERROR = -Werror
CFLAGS_WERROR =
CFLAGS_W = $(CFLAGS_WERROR)
CFLAGS_W += -Wall -W -Wcast-align -Wcast-qual -Wmissing-prototypes -Wpointer-arith -Wshadow -Wwrite-strings
CFLAGS_M =
##CFLAGS_M += -fno-builtin
##CFLAGS_M += -malign-functions=0 -malign-jumps=0 -malign-loops=0
##CFLAGS_O = -Os -fstrict-aliasing
##CFLAGS_O = -O2 -fstrict-aliasing
CFLAGS_O = -O2 -fno-strict-aliasing
CFLAGS = $(CFLAGS_W) $(CFLAGS_M) $(CFLAGS_O)
CXXFLAGS = $(CFLAGS) -Wsynth -fconserve-space
CXXFLAGS1 = $(CXXFLAGS)
##CXXFLAGS1 += -fasynchronous-exceptions
CXXFLAGS2 = $(CXXFLAGS) -fno-exceptions -fno-rtti
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
DEFS += -DDEBUG CXXFLAGS += -O0 -g
## DEFS += -DTESTING
endif
ifeq ($(DEBUG),1)
LDFLAGS = -g
else else
LDFLAGS = -s CXXFLAGS += -O2
endif endif
LDFLAGS += -Wl,-Map,$T.map CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wpointer-arith -Wwrite-strings -Werror
LDLIBS = -lz ##CXXFLAGS += -Wshadow
LIBDIRS =
DOS_LDLIBS =
DOS_LIBDIRS =
###
### compression library
###
UCLDIR:=$(strip $(subst \,/,$(UCLDIR)))
NRVDIR:=$(strip $(subst \,/,$(NRVDIR)))
u = ucl
U = UCL
upx_exe_tail =
include $(srcdir)/Makefile.inc
ifneq ($(strip $(wildcard $(NRVDIR)/include/nrv)),)
u = nrv
U = NRV
upx_exe_tail = _$(u)
include $(srcdir)/Makefile.inc
endif endif
upx_exe = upx$(upx_exe_tail)$(e) CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
CXXLD ?= $(CXX)
override tmp := -Wl,--rpath, exeext ?= .out
LDRPATH := $(addprefix $(tmp),$(LIBDIRS)) libext ?= .a
LIBDIRS += . objext ?= .o
LDLIBDIRS := $(addprefix -L,$(LIBDIRS))
##LDFLAGS += $(LDRPATH) upx_SOURCES := $(wildcard $(srcdir)/*.cpp)
LDFLAGS += $(LDLIBDIRS) upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
# we need UCL and zlib - you can set envvar UPX_UCLDIR
### ifneq ($(wildcard $(UPX_UCLDIR)/include/ucl/ucl.h),)
### Linux INCLUDES += -I$(UPX_UCLDIR)/include
### LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
ifeq ($(target),linux)
override arch := $(shell uname -m | sed -e 's/^i[3456789]86$$/i386/')
DEFS += '-DUPX_CONFIG_H="config_h/linux.h"'
DEFS += -D_FILE_OFFSET_BITS=64
LDLIBS += -lmcheck
ifeq ($(arch),i386)
CC += -march=i386 -mcpu=i586
##CFLAGS_M += -mno-schedule-prologue
endif endif
##CFLAGS_WERROR = -Werror LIBS += -lucl -lz
# you should set envvar UPX_LZMADIR to point to your unpacked lzma443.tar.bz2
ifeq (1,2) # checkergcc ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
CC = checkergcc DEFS += -DWITH_LZMA=1
CXX = checkerg++ INCLUDES += -I$(UPX_LZMADIR)
else
ifeq ($(DEBUG),1)
##CFLAGS += -O0 -gstabs+3
##CFLAGS += -O0 -gdwarf-2
CFLAGS += -O0 -g
else
##LDFLAGS += -static
STUBEDIT_EXE = objcopy -S -R .comment -R .note $@
ifeq ($(arch),i386)
STUBIFY_EXE = perl $(srcdir)/stub/scripts/brandelf.pl $@
CHMOD_EXE = chmod 755 $@
endif
endif
endif
endif # linux
###
### Linux cross compilers
###
ifeq ($(target),cross-m68k-linux)
CC = m68k-linux-gcc
DEFS += '-DUPX_CONFIG_H="config_h/linux.h"'
##LDLIBS += -lmcheck
endif # cross-m68k-linux
###
### sparc-sun-solaris2.8
###
ifeq ($(target),sparc)
CC = gcc
DEFS += '-DUPX_CONFIG_H="config_h/sparc_sun_solaris28.h"'
endif # sparc
ifeq ($(target),XXX-sparc)
DEFS += '-DUPX_CONFIG_H="config_h/sparc_sun_solaris28.h"'
INCLUDES += -I/home/ethmola/local/include
ifeq (1,2) # native compiler
CFLAGS = -O0 -g
CXXFLAGS1 =
CXXFLAGS2 =
DEFS += -DUSE_STDNAMESPACE
else # gcc
CFLAGS += -O0 -gstabs+
endif
ifeq (1,2) # purify
DEFS += -D__PURIFY__
CXXLD := purify $(CXXLD)
endif
endif # XXX-sparc
###
### Atari cross compiler
###
ifeq ($(target),cross-mint)
e = .ttp
CC = m68k-atari-mint-gcc
CC += -m68000
endif
ifeq ($(target),cross-mint-m68040)
e = .ttp
CC = m68k-atari-mint-gcc
CC += -m68040
endif
ifeq ($(target),cross-mint-m68020-60)
e = .ttp
CC = m68k-atari-mint-gcc
CC += -m68020-60 -m68881
endif endif
### all: upx$(exeext)
### djgpp2 .DELETE_ON_ERROR: upx$(exeext) $(upx_OBJECTS)
###
ifeq ($(target),djgpp2) upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
e = .exe $($(notdir $@).PRE_LINK_STEP)
CC += -march=i386 -mcpu=i586 $(strip $(CXXLD) $(call e,CPPFLAGS) $(call e,CXXFLAGS) $(call e,LDFLAGS) -o $@ $(upx_OBJECTS) $(call e,LDADD) $(call e,LIBS))
##CFLAGS_M += -mno-schedule-prologue $($(notdir $@).POST_LINK_STEP)
CFLAGS_WERROR = -Werror
STUBEDIT_EXE = stubedit $@ bufsize=0xfc00 %.o : %.cpp
ifneq ($(strip $(wildcard $(DJDIR)/bin/mfxdjstubify.ex[eE])),) $(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<)
ifneq ($(strip $(wildcard $(DJDIR)/bin/cwsdstub.ex[eE])),)
STUBIFY_EXE = mfxdjstubify -v -s $(DJDIR)/bin/cwsdstub.exe $(upx_exe)
endif
endif
endif # djgpp2
### ifeq ($(USE_GNUC),1)
### cygwin / mingw32 ##compress_lzma$(objext) : CXXFLAGS += -O3 -fomit-frame-pointer
### compress_lzma$(objext) : CXXFLAGS += -Wno-cast-qual
compress_lzma$(objext) : CXXFLAGS += -Wno-non-virtual-dtor
ifeq ($(target),cygwin) compress_lzma$(objext) : CXXFLAGS += -Wno-shadow
e = .exe compress_lzma$(objext) : CXXFLAGS += -Wno-unused
CC += -march=i386 -mcpu=i586 ##compress_lzma$(objext) : CXXFLAGS += -Wno-error
CXXLD = g++
##CFLAGS_M += -mno-schedule-prologue
endif
ifeq ($(target),mingw32)
e = .exe
CC = gcc -mno-cygwin
CC += -march=i386 -mcpu=i586
CXXLD = g++ -mno-cygwin
##CFLAGS_M += -mno-schedule-prologue
endif
# mingw32 as included in cygwin
ifeq ($(target),no-cygwin)
e = .exe
CC = gcc -mno-cygwin
CC += -march=i386 -mcpu=i586
CXXLD = g++ -mno-cygwin
##CFLAGS_M += -mno-schedule-prologue
endif
# mingw32 cross compiler
ifeq ($(target),cross-mingw32)
e = .exe
CC = i586-mingw32msvc-gcc
CC += -march=i386 -mcpu=i586
CXXLD = i586-mingw32msvc-g++
##CFLAGS_M += -mno-schedule-prologue
endif endif
### mostlyclean clean distclean maintainer-clean:
### Borland C++ 5.5.1 rm -f *.d *.map *.o *.obj *.res upx.exe upx.out upx.ttp upx$(exeext)
###
ifeq ($(target),bcc) -include *.d
o = .obj .PHONY: all mostlyclean clean distclean maintainer-clean
a = .lib
e = .exe
CC = bcc32 -q
CFLAGS = -w -w-aus -g1
CXXFLAGS1 = $(CFLAGS)
CXXFLAGS2 = $(CFLAGS) -x- -xd- -RT-
CFLAGS_OUTPUT = -o$@
LDFLAGS =
LDLIBS = $(DOS_LDLIBS) zlib114.lib
ifneq ($(strip $(DOS_LIBDIRS)),)
LIB := $(DOS_LIBDIRS);$(LIB)
endif
export LIB
ifeq ($(DEBUG),1)
CFLAGS += -Od -d
else
CFLAGS += -O2 -d
endif
LINK_EXE = $(CXXLD) $(LDFLAGS) -e$@ $^ $(LDLIBS)
endif # bcc
###
### Digital Mars C++ 8.30
###
ifeq ($(target),dmc)
o = .obj
a = .lib
e = .exe
CC = dmc -mn
CFLAGS = -w- -wx
CXXFLAGS1 = $(CFLAGS) -Aa -Ab -Ae -Ar
CXXFLAGS2 = $(CFLAGS) -Aa -Ab
CFLAGS_OUTPUT = -o$@
LDFLAGS =
LDLIBS = $(DOS_LDLIBS)
ifneq ($(strip $(DOS_LIBDIRS)),)
LIB := $(DOS_LIBDIRS);$(LIB)
endif
export LIB
ifeq ($(DEBUG),1)
CFLAGS += -o- -g -s
else
CFLAGS += -o
endif
LINK_EXE = $(CXXLD) $(LDFLAGS) -o$@ $^ $(LDLIBS)
endif # dmc
###
### Visual C++ 6 (aka Microsoft C/C++ Compiler 12.00)
###
ifeq ($(target),vc6)
o = .obj
a = .lib
e = .exe
CC = cl -nologo
CFLAGS = -W4 -WX
CXXFLAGS1 = $(CFLAGS) -EHac -GR
CXXFLAGS2 = $(CFLAGS)
LDFLAGS =
LINK_LDFLAGS = /link /map:$T.map
ifneq ($(strip $(DOS_LIBDIRS)),)
LIB := $(DOS_LIBDIRS);$(LIB)
endif
export LIB
ifeq (1,2)
# statically link libc.lib
CC += -ML
LDLIBS = $(u)_s.lib setargv.obj
else
# link against msvcrt.dll
CC += -MD
LDLIBS = $(DOS_LDLIBS) zlib114.lib setargv.obj
endif
ifeq ($(DEBUG),1)
CFLAGS += -Od -ZI
LINK_LDFLAGS += /debug
else
CFLAGS += -O2 -GF
LINK_LDFLAGS += /release
endif
RESOURCES = upx.res
##LINK_LDFLAGS += /verbose
LINK_EXE = $(CXXLD) $(LDFLAGS) -Fe$@ $^ $(LDLIBS) $(LINK_LDFLAGS)
endif # vc6
###
### Watcom C++ 11.0c
###
ifeq ($(target),wcc)
o = .obj
a = .lib
e = .exe
CC = wcl386 -zq -bt=nt -mf -5r
CFLAGS = -zc -w5 -we
CXXFLAGS1 = $(CFLAGS) -xs -xr
CXXFLAGS2 = $(CFLAGS)
CFLAGS_OUTPUT = -fo=$@
LDFLAGS = -k0x100000 -fm
LDLIBS = $(DOS_LDLIBS)
INCLUDES:=$(strip $(subst /,\\,$(INCLUDES)))
ifeq (1,2)
WCL386:=$(INCLUDES)
export WCL386
INCLUDES:=
endif
ifneq ($(strip $(DOS_LIBDIRS)),)
LIB := $(DOS_LIBDIRS);$(LIB)
endif
export LIB
ifeq ($(DEBUG),1)
CFLAGS +=
else
# note: it seems that the optimizer is generating bad code with `-ox'
CFLAGS += -olr
endif
LINK_EXE = $(CXXLD) $(LDFLAGS) -fe=$@ $^ $(LDLIBS)
endif # wcc
# /***********************************************************************
# // malloc debuggers and memory checkers - somewhat obsolete, use valgrind
# ************************************************************************/
ifeq (1,2)
# compile in extra valgrind support
CFLAGS += -DWITH_VALGRIND
endif
ifeq (1,2)
LDLIBS += -lefence
endif
ifeq (1,2)
CFLAGS += -DWITH_DMALLOC
LDLIBS += -ldmalloc
endif
ifeq (1,2)
CFLAGS += -DWITH_GC -DLINUX_THREADS -D_REENTRANT
LDLIBS += -lgc -lpthread
# only needed when using -static:
##LDFLAGS += -Wl,-defsym,_DYNAMIC=0
endif
# /***********************************************************************
# // finish settings
# ************************************************************************/
# C++ defaults
ifeq ($(strip $(CXX)),)
ifeq ($(strip $(CC)),gcc)
CXX = g++
else
CXX = $(CC)
endif
endif
ifeq ($(strip $(CXXLD)),)
CXXLD = $(CXX)
endif
ifeq ($(strip $(CXXFLAGS_OUTPUT)),)
CXXFLAGS_OUTPUT = $(CFLAGS_OUTPUT)
endif
# extra flags
DEFS += $(EXTRA_DEFS)
CFLAGS += $(EXTRA_CFLAGS)
CFLAGS_W += $(EXTRA_CFLAGS_W)
CFLAGS_M += $(EXTRA_CFLAGS_M)
CFLAGS_O += $(EXTRA_CFLAGS_O)
CXXFLAGS1 += $(EXTRA_CXXFLAGS1)
CXXFLAGS2 += $(EXTRA_CXXFLAGS2)
LDFLAGS += $(EXTRA_LDFLAGS)
LDLIBS += $(EXTRA_LDLIBS)
# To better deal with asynchronous exceptions we compile all source
# files with exception handling and RTTI enabled - the size overhead
# is negligible.
CXXFLAGS2 = $(CXXFLAGS1)
# /***********************************************************************
# // main targets
# ************************************************************************/
all: $(upx_exe)
.PHONY: all mostlyclean clean distclean maintainer-clean untabify tags
$(upx_exe): $(OBJECTS) $(LIBS) $(RESOURCES)
$(LINK_EXE)
$(STUBEDIT_EXE)
$(STUBIFY_EXE)
$(CHMOD_EXE)
mostlyclean:
-rm -f *.d *.err *.i *.log *.map *~ gdb-trans*
clean: mostlyclean
-rm -f *.a *.lib *.o *.obj *.res *.tds tags TAGS ID
-rm -f *.idb *.pdb
-rm -f $(upx_exe) upx upx.exe upx.ttp upx_nrv upx_nrv.exe upx_nrv.ttp upx_ucl upx_ucl.exe upx_ucl.ttp
-rm -rf .deps
distclean: clean
maintainer-clean: distclean
untabify:
mfxtu -d4 -t *.h *.cpp *.ch
mfxtu -d8 -t stub/[ln]*.asm stub/*.ash stub/*.[cs]
tags TAGS:
ctags *.h *.cpp *.ch
ID:
mkid *.h *.cpp *.ch
# /***********************************************************************
# // rules
# ************************************************************************/
%$o : %.c
$(CC) $(DEFS) $(INCLUDES) $(CFLAGS) $(CFLAGS_OUTPUT) -c $<
%$o : %.cpp
$(CXX) $(DEFS) $(INCLUDES) $(CXXFLAGS1) $(CXXFLAGS_OUTPUT) -c $<
ifneq ($(strip $(OBJECTS2)),)
$(OBJECTS2): %$o : %.cpp
$(CXX) $(DEFS) $(INCLUDES) $(CXXFLAGS2) $(CXXFLAGS_OUTPUT) -c $<
endif
%.res : %.rc
rc -l 0x409 -fo$@ $<
# /***********************************************************************
# // dependencies
# ************************************************************************/
include $(srcdir)/Makefile.dep
# vi:nowrap
-16
View File
@@ -1,16 +0,0 @@
# /***********************************************************************
# // automated dependencies
# ************************************************************************/
CFLAGS += -Wp,-MMD,.deps/$(*F).pp
ifeq ($(strip $(wildcard .deps)),)
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
else
DEP_FILES := $(wildcard .deps/*.pp)
ifneq ($(strip $(DEP_FILES)),)
include $(DEP_FILES)
endif
endif
-39
View File
@@ -1,39 +0,0 @@
UDIR := $($(U)DIR)
ifneq ($(strip $(wildcard $(UDIR)/include)),) # { include
DEFS += -DWITH_$(U)
INCLUDES += -I$(UDIR)/include
ifneq ($(strip $(wildcard $(UDIR)/build/$(target)/src/.libs)),)
LIBDIRS += $(UDIR)/build/$(target)/src/.libs
endif
ifneq ($(strip $(wildcard $(UDIR)/src/.libs)),)
LIBDIRS += $(UDIR)/src/.libs
endif
ifeq ($(DEBUG),1)
ifneq ($(strip $(wildcard $(UDIR)/build/debug/src/.libs)),)
LIBDIRS += $(UDIR)/build/debug/src/.libs
endif
endif
ifneq ($(strip $(wildcard $(UDIR)/build/release/src/.libs)),)
LIBDIRS += $(UDIR)/build/release/src/.libs
endif
ifneq ($(strip $(wildcard $(UDIR)/build/src/.libs)),)
LIBDIRS += $(UDIR)/build/src/.libs
endif
ifneq ($(strip $(wildcard $(UDIR))),)
LIBDIRS += $(UDIR)
DOS_LIBDIRS := $(DOS_LIBDIRS);$(UDIR)
endif
LDLIBS += -l$(u)
DOS_LDLIBS += $(u).lib
DEFS := $(DEFS)
INCLUDES := $(INCLUDES)
LIBDIRS := $(LIBDIRS)
LDLIBS := $(LDLIBS)
DOS_LDLIBS := $(DOS_LDLIBS)
endif # } include
+484 -212
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -34,132 +34,147 @@
// core // core
**************************************************************************/ **************************************************************************/
inline unsigned get_be16(const void *bb) inline unsigned get_be16(const void *p)
{ {
const upx_bytep b = (const upx_bytep) bb; #if defined(ACC_UA_GET_BE16)
unsigned v; return ACC_UA_GET_BE16(p);
v = (unsigned) b[1] << 0;
v |= (unsigned) b[0] << 8;
return v;
}
inline void set_be16(void *bb, unsigned v)
{
upx_bytep b = (upx_bytep) bb;
b[1] = (unsigned char) (v >> 0);
b[0] = (unsigned char) (v >> 8);
}
inline unsigned get_be24(const void *bb)
{
const upx_bytep b = (const upx_bytep) bb;
unsigned v;
v = (unsigned) b[2] << 0;
v |= (unsigned) b[1] << 8;
v |= (unsigned) b[0] << 16;
return v;
}
inline void set_be24(void *bb, unsigned v)
{
upx_bytep b = (upx_bytep) bb;
b[2] = (unsigned char) (v >> 0);
b[1] = (unsigned char) (v >> 8);
b[0] = (unsigned char) (v >> 16);
}
inline unsigned get_be32(const void *bb)
{
const upx_bytep b = (const upx_bytep) bb;
unsigned v;
v = (unsigned) b[3] << 0;
v |= (unsigned) b[2] << 8;
v |= (unsigned) b[1] << 16;
v |= (unsigned) b[0] << 24;
return v;
}
inline void set_be32(void *bb, unsigned v)
{
upx_bytep b = (upx_bytep) bb;
b[3] = (unsigned char) (v >> 0);
b[2] = (unsigned char) (v >> 8);
b[1] = (unsigned char) (v >> 16);
b[0] = (unsigned char) (v >> 24);
}
inline unsigned get_le16(const void *bb)
{
#if defined(__i386__)
return * (const unsigned short *) bb;
#else #else
const upx_bytep b = (const upx_bytep) bb; return acc_ua_get_be16(p);
unsigned v;
v = (unsigned) b[0] << 0;
v |= (unsigned) b[1] << 8;
return v;
#endif #endif
} }
inline void set_le16(void *bb, unsigned v) inline void set_be16(void *p, unsigned v)
{ {
#if defined(__i386__) #if defined(ACC_UA_SET_BE16)
(* (unsigned short *) bb) = (unsigned short) (v & 0xffff); ACC_UA_SET_BE16(p, v);
#else #else
upx_bytep b = (upx_bytep) bb; acc_ua_set_be16(p, v);
b[0] = (unsigned char) (v >> 0);
b[1] = (unsigned char) (v >> 8);
#endif #endif
} }
inline unsigned get_be24(const void *p)
inline unsigned get_le24(const void *bb)
{ {
const upx_bytep b = (const upx_bytep) bb; #if defined(ACC_UA_GET_BE24)
unsigned v; return ACC_UA_GET_BE24(p);
v = (unsigned) b[0] << 0;
v |= (unsigned) b[1] << 8;
v |= (unsigned) b[2] << 16;
return v;
}
inline void set_le24(void *bb, unsigned v)
{
upx_bytep b = (upx_bytep) bb;
b[0] = (unsigned char) (v >> 0);
b[1] = (unsigned char) (v >> 8);
b[2] = (unsigned char) (v >> 16);
}
inline unsigned get_le32(const void *bb)
{
#if defined(__i386__)
return * (const unsigned *) bb;
#else #else
const upx_bytep b = (const upx_bytep) bb; return acc_ua_get_be24(p);
unsigned v;
v = (unsigned) b[0] << 0;
v |= (unsigned) b[1] << 8;
v |= (unsigned) b[2] << 16;
v |= (unsigned) b[3] << 24;
return v;
#endif #endif
} }
inline void set_le32(void *bb, unsigned v) inline void set_be24(void *p, unsigned v)
{ {
#if defined(__i386__) #if defined(ACC_UA_SET_BE24)
(* (unsigned *) bb) = v; ACC_UA_SET_BE24(p, v);
#else #else
upx_bytep b = (upx_bytep) bb; acc_ua_set_be24(p, v);
b[0] = (unsigned char) (v >> 0); #endif
b[1] = (unsigned char) (v >> 8); }
b[2] = (unsigned char) (v >> 16);
b[3] = (unsigned char) (v >> 24); inline unsigned get_be32(const void *p)
{
#if defined(ACC_UA_GET_BE32)
return ACC_UA_GET_BE32(p);
#else
return acc_ua_get_be32(p);
#endif
}
inline void set_be32(void *p, unsigned v)
{
#if defined(ACC_UA_SET_BE32)
ACC_UA_SET_BE32(p, v);
#else
acc_ua_set_be32(p, v);
#endif
}
inline acc_uint64l_t get_be64(const void *p)
{
#if defined(ACC_UA_GET_BE64)
return ACC_UA_GET_BE64(p);
#else
return acc_ua_get_be64(p);
#endif
}
inline void set_be64(void *p, acc_uint64l_t v)
{
#if defined(ACC_UA_SET_BE64)
ACC_UA_SET_BE64(p, v);
#else
acc_ua_set_be64(p, v);
#endif
}
inline unsigned get_le16(const void *p)
{
#if defined(ACC_UA_GET_LE16)
return ACC_UA_GET_LE16(p);
#else
return acc_ua_get_le16(p);
#endif
}
inline void set_le16(void *p, unsigned v)
{
#if defined(ACC_UA_SET_LE16)
ACC_UA_SET_LE16(p, v);
#else
acc_ua_set_le16(p, v);
#endif
}
inline unsigned get_le24(const void *p)
{
#if defined(ACC_UA_GET_LE24)
return ACC_UA_GET_LE24(p);
#else
return acc_ua_get_le24(p);
#endif
}
inline void set_le24(void *p, unsigned v)
{
#if defined(ACC_UA_SET_LE24)
ACC_UA_SET_LE24(p, v);
#else
acc_ua_set_le24(p, v);
#endif
}
inline unsigned get_le32(const void *p)
{
#if defined(ACC_UA_GET_LE32)
return ACC_UA_GET_LE32(p);
#else
return acc_ua_get_le32(p);
#endif
}
inline void set_le32(void *p, unsigned v)
{
#if defined(ACC_UA_SET_LE32)
ACC_UA_SET_LE32(p, v);
#else
acc_ua_set_le32(p, v);
#endif
}
inline acc_uint64l_t get_le64(const void *p)
{
#if defined(ACC_UA_GET_LE64)
return ACC_UA_GET_LE64(p);
#else
return acc_ua_get_le64(p);
#endif
}
inline void set_le64(void *p, acc_uint64l_t v)
{
#if defined(ACC_UA_SET_LE64)
ACC_UA_SET_LE64(p, v);
#else
acc_ua_set_le64(p, v);
#endif #endif
} }
@@ -168,122 +183,270 @@ inline void set_le32(void *bb, unsigned 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 int sign_bit = 1 << (bits - 1); const unsigned sign_bit = 1u << (bits - 1);
v |= -(v & sign_bit); v &= sign_bit | (sign_bit - 1);
return v; //v = (v ^ sign_bit) - sign_bit;
v |= 0 - (v & sign_bit);
return (int) v;
} }
inline int get_be16_signed(const void *bb) inline acc_int64l_t sign_extend(acc_uint64l_t v, unsigned bits)
{ {
int v = get_be16(bb); const acc_uint64l_t sign_bit = ACC_UINT64_C(1) << (bits - 1);
v &= sign_bit | (sign_bit - 1);
//v = (v ^ sign_bit) - sign_bit;
v |= 0 - (v & sign_bit);
return (acc_int64l_t) v;
}
inline int get_be16_signed(const void *p)
{
unsigned v = get_be16(p);
return sign_extend(v, 16); return sign_extend(v, 16);
} }
inline int get_be24_signed(const void *bb) inline int get_be24_signed(const void *p)
{ {
int v = get_be24(bb); unsigned v = get_be24(p);
return sign_extend(v, 24); return sign_extend(v, 24);
} }
inline int get_be32_signed(const void *bb) inline int get_be32_signed(const void *p)
{ {
int v = get_be32(bb); unsigned v = get_be32(p);
return sign_extend(v, 32); return sign_extend(v, 32);
} }
inline int get_le16_signed(const void *bb) inline acc_int64l_t get_be64_signed(const void *p)
{ {
int v = get_le16(bb); acc_uint64l_t v = get_be64(p);
return sign_extend(v, 64);
}
inline int get_le16_signed(const void *p)
{
unsigned v = get_le16(p);
return sign_extend(v, 16); return sign_extend(v, 16);
} }
inline int get_le24_signed(const void *bb) inline int get_le24_signed(const void *p)
{ {
int v = get_le24(bb); unsigned v = get_le24(p);
return sign_extend(v, 24); return sign_extend(v, 24);
} }
inline int get_le32_signed(const void *bb) inline int get_le32_signed(const void *p)
{ {
int v = get_le32(bb); unsigned v = get_le32(p);
return sign_extend(v, 32); return sign_extend(v, 32);
} }
inline acc_int64l_t get_le64_signed(const void *p)
{
acc_uint64l_t v = get_le64(p);
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 acc_uint16e_t *p)
{
return acc_swab16(*p);
}
inline unsigned acc_swap32p(const acc_uint32e_t *p)
{
return acc_swab32(*p);
}
inline void acc_swab16s(acc_uint16e_t *p)
{
*p = acc_swab16(*p);
}
inline void acc_swab32s(acc_uint32e_t *p)
{
*p = 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
// constructor, no destructor, no virtual functions and no default
// 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 ]
**************************************************************************/ **************************************************************************/
class BE16 struct BE16
{ {
unsigned char d[2]; unsigned char d[2];
public: //inline BE16() { }
BE16& operator = (const BE16 &v) { memcpy(d, v.d, sizeof(d)); return *this; } //BE16(unsigned v) { set_be16(d, v); }
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; }
operator const unsigned () const { return get_be16(d); } operator unsigned () const { return get_be16(d); }
} }
__attribute_packed; __attribute_packed;
class BE32 struct BE32
{ {
unsigned char d[4]; unsigned char d[4];
public: //inline BE32() { }
BE32& operator = (const BE32 &v) { memcpy(d, v.d, sizeof(d)); return *this; } //BE32(unsigned v) { set_be32(d, v); }
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; }
operator const unsigned () const { return get_be32(d); } operator unsigned () const { return get_be32(d); }
} }
__attribute_packed; __attribute_packed;
class LE16 struct BE64
{
unsigned char d[8];
//inline BE64() { }
//BE64(acc_uint64l_t v) { set_be64(d, v); }
BE64& operator = (acc_uint64l_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 -= (acc_uint64l_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 /= (acc_uint64l_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 |= (acc_uint64l_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 <<= (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); }
}
__attribute_packed;
struct LE16
{ {
unsigned char d[2]; unsigned char d[2];
public: //inline LE16() { }
LE16& operator = (const LE16 &v) { memcpy(d, v.d, sizeof(d)); return *this; } //LE16(unsigned v) { set_le16(d, v); }
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; }
operator const unsigned () const { return get_le16(d); } operator unsigned () const { return get_le16(d); }
} }
__attribute_packed; __attribute_packed;
class LE32 struct LE32
{ {
unsigned char d[4]; unsigned char d[4];
public: //inline LE32() { }
LE32& operator = (const LE32 &v) { memcpy(d, v.d, sizeof(d)); return *this; } //LE32(unsigned v) { set_le32(d, v); }
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; }
operator const unsigned () const { return get_le32(d); } operator unsigned () const { return get_le32(d); }
}
__attribute_packed;
struct LE64
{
unsigned char d[8];
//inline LE64() { }
//LE64(acc_uint64l_t v) { set_le64(d, v); }
LE64& operator = (acc_uint64l_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 -= (acc_uint64l_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 /= (acc_uint64l_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 |= (acc_uint64l_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 <<= (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); }
} }
__attribute_packed; __attribute_packed;
@@ -292,46 +455,78 @@ __attribute_packed;
// global operators // global operators
**************************************************************************/ **************************************************************************/
inline bool operator < (const BE16& v1, const BE16& v2) template <class T>
{ inline T* operator + (T* ptr, const BE16& v) { return ptr + (unsigned) v; }
return (const unsigned)v1 < (const unsigned)v2; template <class T>
} inline T* operator + (const BE16& v, T* ptr) { return ptr + (unsigned) v; }
template <class T>
inline bool operator < (const BE32& v1, const BE32& v2) inline T* operator - (T* ptr, const BE16& v) { return ptr - (unsigned) v; }
{
return (const unsigned)v1 < (const unsigned)v2;
}
inline bool operator < (const LE16& v1, const LE16& v2)
{
return (const unsigned)v1 < (const unsigned)v2;
}
inline bool operator < (const LE32& v1, const LE32& v2)
{
return (const unsigned)v1 < (const unsigned)v2;
}
template <class T> template <class T>
inline T* operator + (T* ptr, const BE16& v) { return ptr + (const unsigned) v; } inline T* operator + (T* ptr, const BE32& v) { return ptr + (unsigned) v; }
template <class T> template <class T>
inline T* operator - (T* ptr, const BE16& v) { return ptr - (const unsigned) v; } inline T* operator + (const BE32& v, T* ptr) { return ptr + (unsigned) v; }
template <class T>
inline T* operator - (T* ptr, const BE32& v) { return ptr - (unsigned) v; }
// these are not implemented on purpose and will cause link-time errors
template <class T> T* operator + (T* ptr, const BE64& v);
template <class T> T* operator + (const BE64& v, T* ptr);
template <class T> T* operator - (T* ptr, const BE64& v);
template <class T> template <class T>
inline T* operator + (T* ptr, const BE32& v) { return ptr + (const unsigned) v; } inline T* operator + (T* ptr, const LE16& v) { return ptr + (unsigned) v; }
template <class T> template <class T>
inline T* operator - (T* ptr, const BE32& v) { return ptr - (const unsigned) v; } inline T* operator + (const LE16& v, T* ptr) { return ptr + (unsigned) v; }
template <class T>
inline T* operator - (T* ptr, const LE16& v) { return ptr - (unsigned) v; }
template <class T> template <class T>
inline T* operator + (T* ptr, const LE16& v) { return ptr + (const unsigned) v; } inline T* operator + (T* ptr, const LE32& v) { return ptr + (unsigned) v; }
template <class T> template <class T>
inline T* operator - (T* ptr, const LE16& v) { return ptr - (const unsigned) v; } inline T* operator + (const LE32& v, T* ptr) { return ptr + (unsigned) v; }
template <class T>
inline T* operator - (T* ptr, const LE32& v) { return ptr - (unsigned) v; }
template <class T> // these are not implemented on purpose and will cause link-time errors
inline T* operator + (T* ptr, const LE32& v) { return ptr + (const unsigned) v; } template <class T> T* operator + (T* ptr, const LE64& v);
template <class T> template <class T> T* operator + (const LE64& v, T* ptr);
inline T* operator - (T* ptr, const LE32& v) { return ptr - (const unsigned) v; } template <class T> T* operator - (T* ptr, const LE64& v);
/*************************************************************************
// global overloads
**************************************************************************/
#if 1 && !defined(ALIGN_DOWN)
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); }
#endif
#if !defined(UPX_MAX)
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); }
#endif
/************************************************************************* /*************************************************************************
@@ -339,29 +534,106 @@ inline T* operator - (T* ptr, const LE32& v) { return ptr - (const unsigned) v;
**************************************************************************/ **************************************************************************/
// for use with qsort() // for use with qsort()
int be16_compare(const void *e1, const void *e2); extern "C" {
int be24_compare(const void *e1, const void *e2); int __acc_cdecl_qsort be16_compare(const void *, const void *);
int be32_compare(const void *e1, const void *e2); int __acc_cdecl_qsort be24_compare(const void *, const void *);
int le16_compare(const void *e1, const void *e2); int __acc_cdecl_qsort be32_compare(const void *, const void *);
int le24_compare(const void *e1, const void *e2); int __acc_cdecl_qsort be64_compare(const void *, const void *);
int le32_compare(const void *e1, const void *e2); int __acc_cdecl_qsort le16_compare(const void *, const void *);
int be16_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort le24_compare(const void *, const void *);
int be24_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort le32_compare(const void *, const void *);
int be32_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort le64_compare(const void *, const void *);
int le16_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort be16_compare_signed(const void *, const void *);
int le24_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort be24_compare_signed(const void *, const void *);
int le32_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort be32_compare_signed(const void *, const void *);
int __acc_cdecl_qsort be64_compare_signed(const void *, const void *);
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 le32_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
} // extern "C"
// just for testing... // just for testing...
#if 0 && defined(__i386__) && defined(__GNUC_VERSION_HEX__) #if !defined(ACC_CFG_NO_UNALIGNED)
# if (__GNUC_VERSION_HEX__ >= 0x030100) #if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x030200)
typedef unsigned short LE16_unaligned __attribute__((__packed__,__aligned__(1))); typedef acc_uint16e_t LE16_unaligned __attribute__((__aligned__(1)));
typedef unsigned int LE32_unaligned __attribute__((__packed__,__aligned__(1))); typedef acc_uint32e_t LE32_unaligned __attribute__((__aligned__(1)));
# define LE16 LE16_unaligned # ifndef LE16
# define LE32 LE32_unaligned # define LE16 LE16_unaligned
# endif # endif
# ifndef LE32
# define LE32 LE32_unaligned
# endif
#endif #endif
#if 0 && (ACC_ARCH_I386) && (ACC_CC_INTELC)
typedef __declspec(align(1)) acc_uint16e_t LE16_unaligned;
typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned;
# ifndef LE16
# define LE16 LE16_unaligned
# endif
# ifndef LE32
# define LE32 LE32_unaligned
# endif
#endif
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_MSC) && (_MSC_VER >= 1200)
typedef __declspec(align(1)) acc_uint16e_t LE16_unaligned;
typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned;
# ifndef LE16
# define LE16 LE16_unaligned
# endif
# ifndef LE32
# define LE32 LE32_unaligned
# endif
# pragma warning(disable: 4244) // Wx: conversion, possible loss of data
#endif
#endif
/*************************************************************************
// Provide namespaces and classes to abtract endianness policies.
//
// CTP - Compile-Time Polymorphism (templates)
// RTP - Run-Time Polymorphism (virtual functions)
**************************************************************************/
// forward declarations
namespace N_BELE_CTP {
class BEPolicy; class LEPolicy;
extern const BEPolicy be_policy;
extern const LEPolicy le_policy;
}
namespace N_BELE_RTP {
class AbstractPolicy;
class BEPolicy; class LEPolicy;
extern const BEPolicy be_policy;
extern const LEPolicy le_policy;
}
namespace N_BELE_CTP {
#define BELE_CTP 1
#include "bele_policy.h"
#undef BELE_CTP
}
namespace N_BELE_RTP {
#define BELE_RTP 1
#include "bele_policy.h"
#undef BELE_RTP
}
namespace N_BELE_CTP {
template <class T>
inline const N_BELE_RTP::AbstractPolicy* getRTP();
template <>
inline const N_BELE_RTP::AbstractPolicy* getRTP<BEPolicy>()
{ return &N_BELE_RTP::be_policy; }
template <>
inline const N_BELE_RTP::AbstractPolicy* getRTP<LEPolicy>()
{ return &N_BELE_RTP::le_policy; }
}
#endif /* already included */ #endif /* already included */
+283
View File
@@ -0,0 +1,283 @@
/* bele_policy.h -- access memory in BigEndian and LittleEndian byte order
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 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>
*/
#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
#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 acc_uint64l_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, acc_uint64l_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 acc_uint64l_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 acc_uint64l_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, acc_uint64l_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 acc_uint64l_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 acc_uint64l_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, acc_uint64l_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 acc_uint64l_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 acc_uint16e_t U16;
typedef acc_uint32e_t U32;
typedef acc_uint64l_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
/*
vi:ts=4:et:nowrap
*/
+115
View File
@@ -0,0 +1,115 @@
/* bptr.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 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>
*/
#ifndef __UPX_BPTR_H
#define __UPX_BPTR_H
/*************************************************************************
// BoundedPtr
**************************************************************************/
template <class T>
class BoundedPtr
{
// typedef BoundedPtr<T> Self;
public:
typedef T* StoredType;
typedef T* PointerType;
typedef T& ReferenceType;
~BoundedPtr() { }
explicit BoundedPtr(void* base, unsigned size, T* ptr=0)
: ptr_(ptr), base_(base), size_(size) { check(); }
BoundedPtr& operator= (const BoundedPtr& other) {
assert(base_ == other.base_); assert(size_ == other.size_);
ptr_ = other.ptr_; check(); return *this;
}
BoundedPtr& operator= (T* other) {
ptr_ = other; check(); return *this;
}
operator T* () { check(); return ptr_; }
operator const T* () const { check(); return ptr_; }
BoundedPtr& operator += (size_t n) {
checkStrict(); ptr_ += n; checkStrict(); return *this;
}
BoundedPtr& operator -= (size_t n) {
checkStrict(); ptr_ -= n; checkStrict(); return *this;
}
BoundedPtr& operator ++ (void) {
checkStrict(); ptr_ += 1; checkStrict(); return *this;
}
// T* operator ++ (int) {
// T* p = ptr_; checkStrict(); ptr_ += 1; checkStrict(); return p;
// }
// BoundedPtr& operator -- (void) {
// checkStrict(); ptr_ -= 1; checkStrict(); return *this;
// }
private:
void checkNULL() const {
if (!ptr_)
throwCantUnpack("unexpected NULL pointer; take care!");
}
void checkRange(size_t extra=0) const {
size_t off = (const char *) ptr_ - (const char *) base_;
if (off > size_ || off + extra > size_)
throwCantUnpack("pointer out of range; take care!");
}
void checkStrict(size_t extra=0) const {
checkNULL();
checkRange(extra);
}
void check(size_t extra=0) const {
if (ptr_) checkRange(extra);
}
T* ptr_;
void* base_;
size_t size_;
// disable copy
BoundedPtr(const BoundedPtr&); // {}
// BoundedPtr& operator= (const BoundedPtr&); // { return *this; }
// disable dynamic allocation
DISABLE_NEW_DELETE
};
#endif /* already included */
/*
vi:ts=4:et
*/
+3 -3
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -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;
+5 -5
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -81,7 +81,7 @@ static int do_init(FILE *f)
if (opt->console == CON_NONE || opt->to_stdout) if (opt->console == CON_NONE || opt->to_stdout)
return con_mode; return con_mode;
try_init(&console_file,f); try_init(&console_file,f);
if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO) || !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 defined(USE_ANSI)
@@ -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);
@@ -142,7 +142,7 @@ console_t console_init =
}; };
void con_fprintf(FILE *f, const char *format, ...) void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
{ {
va_list args; va_list args;
char buf[80*25]; char buf[80*25];
+3 -3
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -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;
+5 -5
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -88,7 +88,7 @@ static screen_t *do_construct(screen_t *s, int fd)
static screen_t *screen = NULL; static screen_t *screen = NULL;
static void do_destroy(void) static void __acc_cdecl_atexit do_destroy(void)
{ {
if (screen) if (screen)
{ {
@@ -130,7 +130,7 @@ static int init(FILE *f, int o, int now)
if (!screen) if (!screen)
screen = do_construct(screen_djgpp2_construct(),fd); screen = do_construct(screen_djgpp2_construct(),fd);
#endif #endif
#if defined(__MFX_WIN32) #if defined(USE_SCREEN_WIN32)
if (!screen) if (!screen)
screen = do_construct(screen_win32_construct(),fd); screen = do_construct(screen_win32_construct(),fd);
#endif #endif
@@ -295,7 +295,7 @@ 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 defined(USE_FRAMES)
-242
View File
@@ -1,242 +0,0 @@
/* compress.ch --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 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 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_NRV2E_LE16)
{
int n = (method - M_NRV2B_LE32) % 3;
if (n == 0)
conf.bb_size = 32;
else if (n == 1)
conf.bb_size = 8;
else
conf.bb_size = 16;
}
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
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
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
default:
throwInternalError("unknown decompression method");
break;
}
return r;
}
#endif /* upx_test_overlap */
/*
vi:ts=4:et:nowrap
*/
+186 -13
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -27,23 +27,196 @@
#include "conf.h" #include "conf.h"
#include "compress.h"
#include "mem.h"
#include <zlib.h>
#if defined(WITH_NRV) /*************************************************************************
# include "compress_nrv.ch" //
**************************************************************************/
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
{
if (len == 0)
return adler;
assert(buf != NULL);
#if 0
return adler32(adler, (const Bytef *) buf, len); // zlib
#elif defined(WITH_UCL) #elif defined(WITH_UCL)
# define upx_adler32 upx_adler32 return ucl_adler32(adler, (const ucl_bytep) buf, len);
//# define upx_crc32 upx_crc32
# define upx_compress upx_compress
# define upx_decompress upx_decompress
# if (UPX_VERSION_HEX >= 0x019000)
# define ALG_NRV2E
# define upx_test_overlap upx_test_overlap
# endif
# include "compress.ch"
#else #else
# error # error
#endif #endif
}
#if 0 /* UNUSED */
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
{
if (len == 0)
return crc;
assert(buf != NULL);
#if 0
return crc32(crc, (const Bytef *) buf, len); // zlib
#elif defined(WITH_UCL)
return ucl_crc32(crc, (const ucl_bytep) buf, len);
#else
# error
#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
if (0) {
}
#if defined(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 defined(WITH_NRV)
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
r = upx_nrv_compress(src, src_len, dst, dst_len,
cb, method, level, cconf, cresult);
#endif
#if defined(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
// 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 (0) {
}
#if defined(WITH_LZMA)
else if (M_IS_LZMA(method))
r = upx_lzma_decompress(src, src_len, dst, dst_len, method, cresult);
#endif
#if defined(WITH_NRV)
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
r = upx_nrv_decompress(src, src_len, dst, dst_len, method, cresult);
#endif
#if defined(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 defined(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, 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 (0) {
}
#if defined(WITH_LZMA)
else if (M_IS_LZMA(method))
r = upx_lzma_test_overlap(buf, src_off, src_len, dst_len, method, cresult);
#endif
#if defined(WITH_NRV)
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
r = upx_nrv_test_overlap(buf, src_off, src_len, dst_len, method, cresult);
#endif
#if defined(WITH_UCL)
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
r = upx_ucl_test_overlap(buf, src_off, src_len, dst_len, method, cresult);
#endif
else {
throwInternalError("unknown decompression method");
}
return r;
}
/* /*
+118
View File
@@ -0,0 +1,118 @@
/* compress.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 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>
*/
#ifndef __UPX_COMPRESS_H
#define __UPX_COMPRESS_H
/*************************************************************************
//
**************************************************************************/
#if defined(WITH_LZMA)
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, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult );
#endif
#if defined(WITH_NRV)
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, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult );
#endif
#if defined(WITH_UCL)
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, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult );
#endif
#if defined(WITH_ZLIB)
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, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult );
#endif
#endif /* already included */
/*
vi:ts=4:et
*/
+527
View File
@@ -0,0 +1,527 @@
/* compress_lzma.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 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>
*/
#include "conf.h"
#include "compress.h"
void lzma_compress_config_t::reset()
{
memset(this, 0, sizeof(*this));
pos_bits.reset();
lit_pos_bits.reset();
lit_context_bits.reset();
dict_size.reset();
fast_mode = 2;
num_fast_bytes.reset();
match_finder_cycles = 0;
max_num_probs = 0;
}
#if !defined(WITH_LZMA)
extern int compress_lzma_dummy;
int compress_lzma_dummy = 0;
#else
// 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.
/*************************************************************************
// cruft because of pseudo-COM layer
**************************************************************************/
#undef USE_LZMA_PROPERTIES
#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
{
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;
memcpy(data, b_buf + b_pos, size);
b_pos += size;
if (processedSize != NULL) *processedSize = size;
return S_OK;
}
struct OutStream : public ISequentialOutStream, public CMyUnknownImp
{
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;
memcpy(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
{
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
#if (ACC_CC_INTELC) && defined(__linux__)
# pragma warning(disable: 424) // #424: extra ";" ignored
#endif
#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];
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;
pr[7].vt = VT_BSTR;
// setup defaults
pr[0].uintVal = 2; // 0 .. 4
pr[1].uintVal = 0; // 0 .. 4
pr[2].uintVal = 3; // 0 .. 8
pr[3].uintVal = 4 * 1024 * 1024; // 1 .. 2**30
pr[4].uintVal = 2;
pr[5].uintVal = 64; // 5 .. 273
pr[6].uintVal = 0;
#ifdef COMPRESS_MF_BT4
static wchar_t matchfinder[] = L"BT4";
#endif
assert(NCompress::NLZMA::FindMatchFinder(matchfinder) >= 0);
pr[7].bstrVal = matchfinder;
#if 1
pr[0].uintVal = lzma_compress_config_t::pos_bits_t::default_value_c;
pr[1].uintVal = lzma_compress_config_t::lit_pos_bits_t::default_value_c;
pr[2].uintVal = lzma_compress_config_t::lit_context_bits_t::default_value_c;
pr[3].uintVal = lzma_compress_config_t::dict_size_t::default_value_c;
pr[5].uintVal = lzma_compress_config_t::num_fast_bytes_t::default_value_c;
#endif
// method overrides
if (method >= 0x100) {
pr[0].uintVal = (method >> 16) & 15;
pr[1].uintVal = (method >> 12) & 15;
pr[2].uintVal = (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 MB of stack during runtime decompression.
pr[1].uintVal = 4;
pr[2].uintVal = 8;
#endif
// FIXME: tune these settings according to level
switch (level)
{
case 1:
pr[3].uintVal = 256 * 1024;
pr[4].uintVal = 0;
pr[5].uintVal = 8;
break;
case 2:
pr[3].uintVal = 256 * 1024;
pr[4].uintVal = 0;
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
pr[3].uintVal = 8 * 1024 * 1024;
break;
case 10:
pr[3].uintVal = src_len;
break;
default:
goto error;
}
// cconf overrides
if (lcconf)
{
oassign(pr[0].uintVal, lcconf->pos_bits);
oassign(pr[1].uintVal, lcconf->lit_pos_bits);
oassign(pr[2].uintVal, lcconf->lit_context_bits);
oassign(pr[3].uintVal, lcconf->dict_size);
oassign(pr[5].uintVal, lcconf->num_fast_bytes);
}
// limit dictionary size
if (pr[3].uintVal > src_len)
pr[3].uintVal = src_len;
// limit num_probs
if (lcconf && lcconf->max_num_probs)
{
for (;;)
{
unsigned n = 1846 + (768 << (pr[2].uintVal + pr[1].uintVal));
if (n <= lcconf->max_num_probs)
break;
if (pr[1].uintVal > pr[2].uintVal)
{
if (pr[1].uintVal == 0)
goto error;
pr[1].uintVal -= 1;
}
else
{
if (pr[2].uintVal == 0)
goto error;
pr[2].uintVal -= 1;
}
}
}
res->pos_bits = pr[0].uintVal;
res->lit_pos_bits = pr[1].uintVal;
res->lit_context_bits = pr[2].uintVal;
res->dict_size = pr[3].uintVal;
res->fast_mode = pr[4].uintVal;
res->num_fast_bytes = pr[5].uintVal;
res->match_finder_cycles = pr[6].uintVal;
//res->num_probs = LzmaGetNumProbs(&s.Properties));
//res->num_probs = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
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);
#ifndef _NO_EXCEPTIONS
try {
#else
# error
#endif
if (enc.SetCoderProperties(propIDs, pr, 8) != 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);
#if defined(USE_LZMA_PROPERTIES)
os.b_pos = 1;
#else
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((t << 3) | res->pos_bits);
os.WriteByte((res->lit_pos_bits << 4) | (res->lit_context_bits));
#endif
rh = enc.Code(&is, &os, NULL, NULL, &progress);
#ifndef _NO_EXCEPTIONS
} catch (...) { rh = E_OUTOFMEMORY; }
#endif
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 = 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 defined(USE_LZMA_PROPERTIES)
if (src_len < 2)
goto error;
rh = LzmaDecodeProperties(&s.Properties, src, src_len);
if (rh != 0)
goto error;
src += 1; src_len -= 1;
#else
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;
#endif
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);
UNUSED(cresult);
return r;
}
/*************************************************************************
// test_overlap
**************************************************************************/
int upx_lzma_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult )
{
assert(M_IS_LZMA(method));
// FIXME - implement this
// Note that Packer::verifyOverlappingDecompression() will
// verify the final result in any case.
UNUSED(buf);
unsigned overlap_overhead = src_off + src_len - *dst_len;
//printf("upx_lzma_test_overlap: %d\n", overlap_overhead);
if ((int)overlap_overhead >= 256)
return UPX_E_OK;
UNUSED(cresult);
return UPX_E_ERROR;
}
/*************************************************************************
// misc
**************************************************************************/
const char *upx_lzma_version_string(void)
{
// FIXME
// return NULL;
return "4.43";
}
#endif /* WITH_LZMA */
/*
vi:ts=4:et:nowrap
*/
+291
View File
@@ -0,0 +1,291 @@
/* compress_ucl.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 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>
*/
#include "conf.h"
#include "compress.h"
#if !defined(WITH_UCL)
extern int compress_ucl_dummy;
int compress_ucl_dummy = 0;
#else
#if 1 && !defined(UCL_USE_ASM) && (ACC_ARCH_I386)
# if (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_WATCOMC)
# define UCL_USE_ASM
# endif
#endif
#if defined(UCL_NO_ASM)
# undef UCL_USE_ASM
#endif
#if defined(ACC_CFG_NO_UNALIGNED)
# undef UCL_USE_ASM
#endif
#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
/*************************************************************************
//
**************************************************************************/
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 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)
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, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult )
{
int r;
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
**************************************************************************/
const char *upx_ucl_version_string(void)
{
return ucl_version_string();
}
#endif /* WITH_UCL */
/*
vi:ts=4:et:nowrap
*/
+230
View File
@@ -0,0 +1,230 @@
/* compress_zlib.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 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>
*/
#include "conf.h"
#include "compress.h"
void zlib_compress_config_t::reset()
{
memset(this, 0, sizeof(*this));
mem_level.reset();
window_bits.reset();
strategy.reset();
}
#if !defined(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 = const_cast<upx_bytep>(src); // UNCONST
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 = const_cast<upx_bytep>(src); // UNCONST
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
**************************************************************************/
int upx_zlib_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult )
{
assert(method == M_DEFLATE);
// FIXME - implement this
// Note that Packer::verifyOverlappingDecompression() will
// verify the final result in any case.
UNUSED(buf);
unsigned overlap_overhead = src_off + src_len - *dst_len;
//printf("upx_zlib_test_overlap: %d\n", overlap_overhead);
if ((int)overlap_overhead >= 256)
return UPX_E_OK;
UNUSED(cresult);
return UPX_E_ERROR;
}
/*************************************************************************
// misc
**************************************************************************/
const char *upx_zlib_version_string(void)
{
return zlibVersion();
}
#endif /* WITH_ZLIB */
/*
vi:ts=4:et:nowrap
*/
+514 -338
View File
File diff suppressed because it is too large Load Diff
View File
-229
View File
@@ -1,229 +0,0 @@
/* pseudo <config.h> for Linux */
#ifndef __UPX_CONFIG_H
#define __UPX_CONFIG_H
/* $TOP$ */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your memcmp is broken. */
/* #undef NO_MEMCMP */
/* Define to `long' if <stddef.h> doesn't define. */
/* #undef ptrdiff_t */
/* Define when using the dmalloc package. */
/* #undef WITH_DMALLOC */
/* Define if you have the access function. */
#define HAVE_ACCESS 1
/* Define if you have the atoi function. */
#define HAVE_ATOI 1
/* Define if you have the chmod function. */
#define HAVE_CHMOD 1
/* Define if you have the chown function. */
#define HAVE_CHOWN 1
/* Define if you have the ctime function. */
#define HAVE_CTIME 1
/* Define if you have the difftime function. */
#define HAVE_DIFFTIME 1
/* Define if you have the fchmod function. */
#define HAVE_FCHMOD 1
/* Define if you have the fileno function. */
#define HAVE_FILENO 1
/* Define if you have the fstat function. */
#define HAVE_FSTAT 1
/* Define if you have the XXX function. */
#define HAVE_GETPID 1
/* Define if you have the XXX function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the getumask function. */
/* #undef HAVE_GETUMASK */
/* Define if you have the gmtime function. */
#define HAVE_GMTIME 1
/* Define if you have the index function. */
#define HAVE_INDEX 1
/* Define if you have the isatty function. */
#define HAVE_ISATTY 1
/* Define if you have the lstat function. */
#define HAVE_LSTAT 1
/* Define if you have the localtime function. */
#define HAVE_LOCALTIME 1
/* Define if you have the memcmp function. */
#define HAVE_MEMCMP 1
/* Define if you have the memcpy function. */
#define HAVE_MEMCPY 1
/* Define if you have the memmove function. */
#define HAVE_MEMMOVE 1
/* Define if you have the memset function. */
#define HAVE_MEMSET 1
/* Define if you have the mktime function. */
#define HAVE_MKTIME 1
/* Define if you have the setmode function. */
/* #undef HAVE_SETMODE */
/* Define if you have the stat function. */
#define HAVE_STAT 1
/* Define if you have the strcasecmp function. */
#define HAVE_STRCASECMP 1
/* Define if you have the strchr function. */
#define HAVE_STRCHR 1
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1
/* Define if you have the strftime function. */
#define HAVE_STRFTIME 1
/* Define if you have the stricmp function. */
/* #undef HAVE_STRICMP */
/* Define if you have the strncasecmp function. */
#define HAVE_STRNCASECMP 1
/* Define if you have the strnicmp function. */
/* #undef HAVE_STRNICMP */
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the tzset function. */
#define HAVE_TZSET 1
/* Define if you have the umask function. */
#define HAVE_UMASK 1
/* Define if you have the utime function. */
#define HAVE_UTIME 1
/* Define if you have the vsnprintf function. */
#define HAVE_VSNPRINTF 1
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define if you have the <curses.h> header file. */
#define HAVE_CURSES_H 1
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <linux/kd.h> header file. */
#define HAVE_LINUX_KD_H 1
/* Define if you have the <linux/kdev_t.h> header file. */
#define HAVE_LINUX_KDEV_T_H 1
/* Define if you have the <linux/major.h> header file. */
#define HAVE_LINUX_MAJOR_H 1
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <ncurses.h> header file. */
#define HAVE_NCURSES_H 1
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/times.h> header file. */
#define HAVE_SYS_TIMES_H 1
/* Define if you have the <sys/utime.h> header file. */
/* #undef HAVE_SYS_UTIME_H */
/* Define if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* $BOTTOM$ */
#if defined(HAVE_GMTIME) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_GMTIME
#endif
#if defined(HAVE_LOCALTIME) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_LOCALTIME
#endif
#if defined(HAVE_STRFTIME) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_STRFTIME
#endif
#if defined(HAVE_SYS_RESOURCE_H) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_SYS_RESOURCE_H
#endif
#if defined(HAVE_SYS_TIMES_H) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_SYS_TIMES_H
#endif
#endif /* already included */
/*
vi:ts=4
*/
-226
View File
@@ -1,226 +0,0 @@
/* pseudo <config.h> for sparc-sun-solaris2.8 */
#ifndef __UPX_CONFIG_H
#define __UPX_CONFIG_H
/* $TOP$ */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your memcmp is broken. */
/* #undef NO_MEMCMP */
/* Define to `long' if <stddef.h> doesn't define. */
/* #undef ptrdiff_t */
/* Define when using the dmalloc package. */
/* #undef WITH_DMALLOC */
/* Define if you have the access function. */
#define HAVE_ACCESS 1
/* Define if you have the atoi function. */
#define HAVE_ATOI 1
/* Define if you have the chmod function. */
#define HAVE_CHMOD 1
/* Define if you have the chown function. */
#define HAVE_CHOWN 1
/* Define if you have the ctime function. */
#define HAVE_CTIME 1
/* Define if you have the difftime function. */
#define HAVE_DIFFTIME 1
/* Define if you have the fchmod function. */
#define HAVE_FCHMOD 1
/* Define if you have the fileno function. */
#define HAVE_FILENO 1
/* Define if you have the fstat function. */
#define HAVE_FSTAT 1
/* Define if you have the XXX function. */
#define HAVE_GETPID 1
/* Define if you have the XXX function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the getumask function. */
/* #undef HAVE_GETUMASK */
/* Define if you have the gmtime function. */
#define HAVE_GMTIME 1
/* Define if you have the index function. */
#define HAVE_INDEX 1
/* Define if you have the isatty function. */
#define HAVE_ISATTY 1
/* Define if you have the lstat function. */
#define HAVE_LSTAT 1
/* Define if you have the localtime function. */
#define HAVE_LOCALTIME 1
/* Define if you have the memcmp function. */
#define HAVE_MEMCMP 1
/* Define if you have the memcpy function. */
#define HAVE_MEMCPY 1
/* Define if you have the memmove function. */
#define HAVE_MEMMOVE 1
/* Define if you have the memset function. */
#define HAVE_MEMSET 1
/* Define if you have the mktime function. */
#define HAVE_MKTIME 1
/* Define if you have the setmode function. */
/* #undef HAVE_SETMODE */
/* Define if you have the stat function. */
#define HAVE_STAT 1
/* Define if you have the strcasecmp function. */
#define HAVE_STRCASECMP 1
/* Define if you have the strchr function. */
#define HAVE_STRCHR 1
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1
/* Define if you have the strftime function. */
#define HAVE_STRFTIME 1
/* Define if you have the stricmp function. */
/* #undef HAVE_STRICMP */
/* Define if you have the strncasecmp function. */
#define HAVE_STRNCASECMP 1
/* Define if you have the strnicmp function. */
/* #undef HAVE_STRNICMP */
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the tzset function. */
#define HAVE_TZSET 1
/* Define if you have the umask function. */
#define HAVE_UMASK 1
/* Define if you have the utime function. */
#define HAVE_UTIME 1
/* Define if you have the vsnprintf function. */
#define HAVE_VSNPRINTF 1
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define if you have the <curses.h> header file. */
#define HAVE_CURSES_H 1
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <linux/kd.h> header file. */
#define HAVE_LINUX_KD_H 1
/* Define if you have the <linux/kdev_t.h> header file. */
#define HAVE_LINUX_KDEV_T_H 1
/* Define if you have the <linux/major.h> header file. */
#define HAVE_LINUX_MAJOR_H 1
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <ncurses.h> header file. */
#define HAVE_NCURSES_H 1
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/times.h> header file. */
#define HAVE_SYS_TIMES_H 1
/* Define if you have the <sys/utime.h> header file. */
/* #undef HAVE_SYS_UTIME_H */
/* Define if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* $BOTTOM$ */
#if defined(HAVE_GMTIME) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_GMTIME
#endif
#if defined(HAVE_LOCALTIME) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_LOCALTIME
#endif
#if defined(HAVE_STRFTIME) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_STRFTIME
#endif
#if defined(HAVE_SYS_RESOURCE_H) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_SYS_RESOURCE_H
#endif
#if defined(HAVE_SYS_TIMES_H) && !defined(TIME_WITH_SYS_TIME)
# undef /**/ HAVE_SYS_TIMES_H
#endif
#endif /* already included */
/*
vi:ts=4
*/
+13 -10
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -34,8 +34,9 @@
#undef USE_CONSOLE #undef USE_CONSOLE
#undef USE_ANSI #undef USE_ANSI
#undef USE_SCREEN #undef USE_SCREEN
#undef USE_SCREEN_VCSA
#undef USE_SCREEN_CURSES #undef USE_SCREEN_CURSES
#undef USE_SCREEN_VCSA
#undef USE_SCREEN_WIN32
#undef USE_FRAMES #undef USE_FRAMES
#if defined(WITH_GUI) && !defined(NO_CONSOLE) #if defined(WITH_GUI) && !defined(NO_CONSOLE)
@@ -57,10 +58,12 @@
#if 1 && defined(__DJGPP__) #if 1 && defined(__DJGPP__)
# define USE_SCREEN # define USE_SCREEN
#endif #elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
#if 1 && defined(__MFX_WIN32)
# define USE_SCREEN # define USE_SCREEN
# define USE_SCREEN_WIN32
#elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
# define USE_SCREEN
# define USE_SCREEN_WIN32
#endif #endif
@@ -114,16 +117,16 @@ 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;
#if defined(__GNUC__) #if defined(__GNUC__)
void con_fprintf(FILE *f, const char *format, ...) void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
__attribute__((format(printf,2,3))); __attribute__((__format__(printf,2,3)));
#else #else
void con_fprintf(FILE *f, const char *format, ...); void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...);
#endif #endif
+22 -15
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -35,7 +35,7 @@
long Throwable::counter = 0; long Throwable::counter = 0;
Throwable::Throwable(const char *m, int e, bool w) 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)
{ {
if (m) if (m)
@@ -47,7 +47,7 @@ Throwable::Throwable(const char *m, int e, bool w)
} }
Throwable::Throwable(Throwable const &other) Throwable::Throwable(const Throwable &other) NOTHROW
: super(other), msg(NULL), err(other.err), is_warning(other.is_warning) : super(other), msg(NULL), err(other.err), is_warning(other.is_warning)
{ {
if (other.msg) if (other.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");
@@ -174,22 +179,24 @@ void throwEOFException(const char *msg, int e)
// //
**************************************************************************/ **************************************************************************/
const char *prettyName(const char *n) const char *prettyName(const char *n) NOTHROW
{ {
if (n == NULL) if (n == NULL)
return ""; return "(null)";
while (*n >= '0' && *n <= '9') // gcc while (*n)
n++; {
if (strncmp(n, "class ", 6) == 0) // Visual C++ if (*n >= '0' && *n <= '9') // Linux ABI
n += 6; n++;
else if (*n == ' ')
n++;
else if (strncmp(n, "class ", 6) == 0) // Visual C++
n += 6;
else
break;
}
return n; return n;
} }
const char *prettyName(const std::type_info &ti)
{
return prettyName(ti.name());
}
/* /*
vi:ts=4:et vi:ts=4:et
+26 -29
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -31,8 +31,7 @@
#ifdef __cplusplus #ifdef __cplusplus
const char *prettyName(const char *n); const char *prettyName(const char *n) NOTHROW;
const char *prettyName(const std::type_info &ti);
/************************************************************************* /*************************************************************************
@@ -43,13 +42,13 @@ class Throwable : public std::exception
{ {
typedef std::exception super; typedef std::exception super;
protected: protected:
Throwable(const char *m = 0, int e = 0, bool w = false); Throwable(const char *m = 0, int e = 0, bool w = false) NOTHROW;
public: public:
Throwable(Throwable const &); Throwable(const Throwable &) NOTHROW;
virtual ~Throwable() NOTHROW; virtual ~Throwable() NOTHROW;
const char *getMsg() const { return msg; } const char *getMsg() const NOTHROW { return msg; }
int getErrno() const { return err; } int getErrno() const NOTHROW { return err; }
bool isWarning() const { return is_warning; } bool isWarning() const NOTHROW { return is_warning; }
private: private:
char *msg; char *msg;
int err; int err;
@@ -58,12 +57,9 @@ protected:
private: private:
// disable assignment // disable assignment
Throwable& operator= (Throwable const &); Throwable& operator= (const Throwable &);
// disable dynamic allocation // disable dynamic allocation
#ifndef new DISABLE_NEW_DELETE
static void *operator new (size_t); // {}
static void *operator new[] (size_t); // {}
#endif
private: private:
static long counter; // for debugging static long counter; // for debugging
@@ -75,7 +71,7 @@ class Exception : public Throwable
{ {
typedef Throwable super; typedef Throwable super;
public: public:
Exception(const char *m = 0, int e = 0, bool w = false) : super(m,e,w) { } Exception(const char *m = 0, int e = 0, bool w = false) NOTHROW : super(m,e,w) { }
}; };
@@ -84,7 +80,7 @@ class Error : public Throwable
{ {
typedef Throwable super; typedef Throwable super;
public: public:
Error(const char *m = 0, int e = 0) : super(m,e) { } Error(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
}; };
@@ -96,7 +92,7 @@ class OutOfMemoryException : public Exception
{ {
typedef Exception super; typedef Exception super;
public: public:
OutOfMemoryException(const char *m = 0, int e = 0) : super(m,e) { } OutOfMemoryException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
}; };
@@ -104,7 +100,7 @@ class IOException : public Exception
{ {
typedef Exception super; typedef Exception super;
public: public:
IOException(const char *m = 0, int e = 0) : super(m,e) { } IOException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
}; };
@@ -112,7 +108,7 @@ class EOFException : public IOException
{ {
typedef IOException super; typedef IOException super;
public: public:
EOFException(const char *m = 0, int e = 0) : super(m,e) { } EOFException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
}; };
@@ -120,7 +116,7 @@ class FileNotFoundException : public IOException
{ {
typedef IOException super; typedef IOException super;
public: public:
FileNotFoundException(const char *m = 0, int e = 0) : super(m,e) { } FileNotFoundException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
}; };
@@ -128,7 +124,7 @@ class FileAlreadyExistsException : public IOException
{ {
typedef IOException super; typedef IOException super;
public: public:
FileAlreadyExistsException(const char *m = 0, int e = 0) : super(m,e) { } FileAlreadyExistsException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
}; };
@@ -140,35 +136,35 @@ class OverlayException : public Exception
{ {
typedef Exception super; typedef Exception super;
public: public:
OverlayException(const char *m = 0, bool w = false) : super(m,0,w) { } OverlayException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { }
}; };
class CantPackException : public Exception class CantPackException : public Exception
{ {
typedef Exception super; typedef Exception super;
public: public:
CantPackException(const char *m = 0, bool w = false) : super(m,0,w) { } CantPackException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { }
}; };
class UnknownExecutableFormatException : public CantPackException class UnknownExecutableFormatException : public CantPackException
{ {
typedef CantPackException super; typedef CantPackException super;
public: public:
UnknownExecutableFormatException(const char *m = 0, bool w = false) : super(m,w) { } UnknownExecutableFormatException(const char *m = 0, bool w = false) NOTHROW : super(m,w) { }
}; };
class AlreadyPackedException : public CantPackException class AlreadyPackedException : public CantPackException
{ {
typedef CantPackException super; typedef CantPackException super;
public: public:
AlreadyPackedException(const char *m = 0) : super(m) { is_warning = true; } AlreadyPackedException(const char *m = 0) NOTHROW : super(m) { is_warning = true; }
}; };
class NotCompressibleException : public CantPackException class NotCompressibleException : public CantPackException
{ {
typedef CantPackException super; typedef CantPackException super;
public: public:
NotCompressibleException(const char *m = 0) : super(m) { } NotCompressibleException(const char *m = 0) NOTHROW : super(m) { }
}; };
@@ -176,14 +172,14 @@ class CantUnpackException : public Exception
{ {
typedef Exception super; typedef Exception super;
public: public:
CantUnpackException(const char *m = 0, bool w = false) : super(m,0,w) { } CantUnpackException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { }
}; };
class NotPackedException : public CantUnpackException class NotPackedException : public CantUnpackException
{ {
typedef CantUnpackException super; typedef CantUnpackException super;
public: public:
NotPackedException(const char *m = 0) : super(m,true) { } NotPackedException(const char *m = 0) NOTHROW : super(m,true) { }
}; };
@@ -195,7 +191,7 @@ class InternalError : public Error
{ {
typedef Error super; typedef Error super;
public: public:
InternalError(const char *m = 0) : super(m,0) { } InternalError(const char *m = 0) NOTHROW : super(m,0) { }
}; };
@@ -212,6 +208,7 @@ public:
#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;
+116 -70
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -40,13 +40,15 @@ void File::chmod(const char *name, int mode)
#if defined(HAVE_CHMOD) #if defined(HAVE_CHMOD)
if (::chmod(name,mode) != 0) if (::chmod(name,mode) != 0)
throwIOException(name,errno); throwIOException(name,errno);
#else
UNUSED(name); UNUSED(mode);
#endif #endif
} }
void File::rename(const char *old_, const char *new_) void File::rename(const char *old_, const char *new_)
{ {
#if 1 && defined(__DJGPP__) #if defined(__DJGPP__)
if (::_rename(old_,new_) != 0) if (::_rename(old_,new_) != 0)
#else #else
if (::rename(old_,new_) != 0) if (::rename(old_,new_) != 0)
@@ -67,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));
} }
@@ -102,6 +104,10 @@ void FileBase::sopen()
assert(0); assert(0);
#endif #endif
} }
if (!(_fd < 0)) {
::fstat(_fd, &st);
_length = st.st_size;
}
} }
@@ -115,6 +121,8 @@ bool FileBase::close()
_flags = 0; _flags = 0;
_mode = 0; _mode = 0;
_name = NULL; _name = NULL;
_offset = 0;
_length = 0;
return ok; return ok;
} }
@@ -128,29 +136,13 @@ void FileBase::closex()
int FileBase::read(void *buf, int len) int FileBase::read(void *buf, int len)
{ {
int l;
if (!isOpen() || len < 0) if (!isOpen() || len < 0)
throwIOException("bad read"); throwIOException("bad read");
if (len == 0) errno = 0;
return 0; long l = acc_safe_hread(_fd, buf, len);
for (;;) if (errno)
{ throwIOException("read error",errno);
#if 1 && defined(__DJGPP__) return (int) l;
l = ::_read(_fd, buf, len);
#else
l = ::read(_fd, buf, len);
#endif
if (l < 0)
{
#if defined(EINTR)
if (errno == EINTR)
continue;
#endif
throwIOException("read error",errno);
}
break;
}
return l;
} }
@@ -165,26 +157,12 @@ int FileBase::readx(void *buf, int len)
void FileBase::write(const void *buf, int len) void FileBase::write(const void *buf, int len)
{ {
int l;
if (!isOpen() || len < 0) if (!isOpen() || len < 0)
throwIOException("bad write"); throwIOException("bad write");
if (len == 0) errno = 0;
return; long l = acc_safe_hwrite(_fd, buf, len);
for (;;) if (l != len)
{ throwIOException("write error",errno);
#if 1 && defined(__DJGPP__)
l = ::_write(_fd,buf,len);
#else
l = ::write(_fd,buf,len);
#endif
#if defined(EINTR)
if (l < 0 && errno == EINTR)
continue;
#endif
if (l != len)
throwIOException("write error",errno);
break;
}
} }
@@ -192,10 +170,17 @@ void FileBase::seek(off_t off, int whence)
{ {
if (!isOpen()) if (!isOpen())
throwIOException("bad seek 1"); throwIOException("bad seek 1");
if (whence == SEEK_SET && off < 0) if (whence == SEEK_SET) {
throwIOException("bad seek 2"); if (off < 0)
if (whence == SEEK_END && off > 0) throwIOException("bad seek 2");
throwIOException("bad seek 3"); off += _offset;
}
if (whence == SEEK_END) {
if (off > 0)
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);
} }
@@ -208,7 +193,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;
} }
@@ -233,6 +230,8 @@ void InputFile::sopen(const char *name, int flags, int shflags)
_flags = flags; _flags = flags;
_shflags = shflags; _shflags = shflags;
_mode = 0; _mode = 0;
_offset = 0;
_length = 0;
FileBase::sopen(); FileBase::sopen();
if (!isOpen()) if (!isOpen())
{ {
@@ -259,14 +258,16 @@ int InputFile::readx(void *buf, int len)
int InputFile::read(MemBuffer *buf, int len) int InputFile::read(MemBuffer *buf, int len)
{ {
buf->checkState();
assert((unsigned)len <= buf->getSize()); assert((unsigned)len <= buf->getSize());
return super::read(buf->getVoidPtr(), len); return read(buf->getVoidPtr(), len);
} }
int InputFile::readx(MemBuffer *buf, int len) int InputFile::readx(MemBuffer *buf, int len)
{ {
buf->checkState();
assert((unsigned)len <= buf->getSize()); assert((unsigned)len <= buf->getSize());
return super::readx(buf->getVoidPtr(), len); return read(buf->getVoidPtr(), len);
} }
@@ -315,6 +316,8 @@ void OutputFile::sopen(const char *name, int flags, int shflags, int mode)
_flags = flags; _flags = flags;
_shflags = shflags; _shflags = shflags;
_mode = mode; _mode = mode;
_offset = 0;
_length = 0;
FileBase::sopen(); FileBase::sopen();
if (!isOpen()) if (!isOpen())
{ {
@@ -335,29 +338,18 @@ void OutputFile::sopen(const char *name, int flags, int shflags, int mode)
bool OutputFile::openStdout(int flags, bool force) bool OutputFile::openStdout(int flags, bool force)
{ {
close(); close();
if (!force) int fd = STDOUT_FILENO;
{ if (!force && acc_isatty(fd))
if (!isafile(STDOUT_FILENO)) return false;
return false;
}
_fd = STDOUT_FILENO;
_name = "<stdout>"; _name = "<stdout>";
_flags = flags; _flags = flags;
_shflags = -1; _shflags = -1;
_mode = 0; _mode = 0;
if (flags != 0) _offset = 0;
{ _length = 0;
assert(flags == O_BINARY); if (flags && acc_set_binmode(fd, 1) == -1)
#if defined(__MINT__) throwIOException(_name, errno);
__set_binmode(stdout, 1); _fd = fd;
#elif defined(HAVE_SETMODE) && defined(USE_SETMODE)
if (setmode(_fd, O_BINARY) == -1)
throwIOException(_name,errno);
#if defined(__DJGPP__)
__djgpp_set_ctrl_c(1);
#endif
#endif
}
return true; return true;
} }
@@ -368,6 +360,60 @@ 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;
::fstat(_fd, &my_st);
return my_st.st_size;
}
void OutputFile::write(const MemBuffer *buf, int len)
{
buf->checkState();
assert((unsigned)len <= buf->getSize());
write(buf->getVoidPtr(), len);
}
void OutputFile::write(const MemBuffer &buf, int len)
{
write(&buf, len);
}
void OutputFile::rewrite(const void *buf, int len)
{
assert(!opt->to_stdout);
write(buf, len);
bytes_written -= len; // restore
}
void OutputFile::seek(off_t off, int whence)
{
assert(!opt->to_stdout);
super::seek(off,whence);
}
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) {
::fstat(_fd, &st);
_length = st.st_size - offset;
}
}
off_t OutputFile::unset_extent()
{
_offset = 0;
_length = ::lseek(_fd, 0, SEEK_END);
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)
{ {
@@ -375,7 +421,7 @@ void OutputFile::dump(const char *name, const void *buf, int len, int flags)
flags = O_CREAT | O_BINARY | O_TRUNC; flags = O_CREAT | O_BINARY | O_TRUNC;
flags |= O_WRONLY; flags |= O_WRONLY;
OutputFile f; OutputFile f;
f.open(name, flags, 0666); f.open(name, flags, 0600);
f.write(buf, len); f.write(buf, len);
f.closex(); f.closex();
} }
+18 -17
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -38,6 +38,9 @@ class MemBuffer;
class File class File
{ {
protected:
File() { }
virtual ~File() { }
public: public:
static void chmod(const char *name, int mode); static void chmod(const char *name, int mode);
static void rename(const char *old_, const char *new_); static void rename(const char *old_, const char *new_);
@@ -56,6 +59,8 @@ 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(); void sopen();
@@ -70,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;
}; };
@@ -123,23 +130,17 @@ public:
virtual bool openStdout(int flags=0, bool force=false); virtual bool openStdout(int flags=0, bool force=false);
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 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; }
#if (UPX_VERSION_HEX >= 0x019000) // 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 void seek(off_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
}
#endif
// 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);
@@ -153,7 +154,7 @@ protected:
// //
**************************************************************************/ **************************************************************************/
#if 0 #if 0 /* NOT USED */
class MemoryOutputFile : public FileBase class MemoryOutputFile : public FileBase
{ {
typedef FileBase super; typedef FileBase super;
+22 -8
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -21,8 +21,8 @@
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 Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
*/ */
@@ -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
+4 -3
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -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().
+77 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -383,6 +383,81 @@ 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) \
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
/* /*
vi:ts=4:et:nowrap vi:ts=4:et:nowrap
+19 -5
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -36,11 +36,11 @@ static int F(Filter *f)
#ifdef U #ifdef U
// filter // filter
upx_byte *b = f->buf; upx_byte *b = f->buf;
const unsigned addvalue = f->addvalue;
#else #else
// scan // scan
const upx_byte *b = f->buf; const upx_byte *b = f->buf;
#endif #endif
const unsigned addvalue = f->addvalue;
const unsigned size = f->buf_len; const unsigned size = f->buf_len;
unsigned ic, jc, kc; unsigned ic, jc, kc;
@@ -52,11 +52,24 @@ static int F(Filter *f)
unsigned char buf[256]; unsigned char buf[256];
memset(buf,0,256); memset(buf,0,256);
// A call to a destination that is inside the buffer
// will be rewritten and marked with cto8 as first byte.
// So, a call to a destination that is outside the buffer
// must not conflict with the mark.
// 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)
{ {
buf[b[ic+1]] |= 1; if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
return -1;
} }
else
buf[b[ic+1]] |= 1;
}
if (getcto(f, buf) < 0) if (getcto(f, buf) < 0)
return -1; return -1;
@@ -74,6 +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)
{ {
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
#ifdef U #ifdef U
set_be32(b+ic+1,jc+addvalue+cto); set_be32(b+ic+1,jc+addvalue+cto);
#endif #endif
+17 -9
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser Copyright (C) 2000-2007 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
@@ -40,11 +40,11 @@ static int F(Filter *f)
#ifdef U #ifdef U
// filter // filter
upx_byte *b = f->buf; upx_byte *b = f->buf;
const unsigned addvalue = f->addvalue;
#else #else
// scan // scan
const upx_byte *b = f->buf; const upx_byte *b = f->buf;
#endif #endif
const unsigned addvalue = f->addvalue;
const unsigned size = f->buf_len; const unsigned size = f->buf_len;
unsigned ic, jc, kc; unsigned ic, jc, kc;
@@ -57,10 +57,18 @@ static int F(Filter *f)
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)
{ {
buf[b[ic+1]] |= 1; if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
return -1;
} }
else
buf[b[ic+1]] |= 1;
}
if (getcto(f, buf) < 0) if (getcto(f, buf) < 0)
return -1; return -1;
@@ -78,6 +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)
{ {
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
#ifdef U #ifdef U
set_be32(b+ic+1,jc+addvalue+cto); set_be32(b+ic+1,jc+addvalue+cto);
#endif #endif
@@ -134,8 +143,7 @@ static int U(Filter *f)
const unsigned size5 = f->buf_len - 5; const unsigned size5 = f->buf_len - 5;
const unsigned addvalue = f->addvalue; const unsigned addvalue = f->addvalue;
const unsigned cto = (unsigned)f->cto << 24; const unsigned cto = (unsigned)f->cto << 24;
unsigned lastcall = 0; // unsigned lastcall = 0; // lastcall is not used in COND macro
unsigned ic, jc; unsigned ic, jc;
for (ic = 0; ic < size5; ic++) for (ic = 0; ic < size5; ic++)
@@ -147,7 +155,7 @@ static int U(Filter *f)
set_le32(b+ic+1,jc-ic-1-addvalue-cto); set_le32(b+ic+1,jc-ic-1-addvalue-cto);
f->calls++; f->calls++;
ic += 4; ic += 4;
f->lastcall = lastcall = ic+1; f->lastcall = ic+1;
} }
else else
f->noncalls++; f->noncalls++;
+8 -3
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser Copyright (C) 2000-2007 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
@@ -30,6 +30,10 @@
*/ */
#if (ACC_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1300))
# pragma warning(disable: 4702) // W4: unreachable code
#endif
/************************************************************************* /*************************************************************************
// filter / scan // filter / scan
@@ -131,6 +135,7 @@ static int F(Filter *f)
{ {
buf[b[ic+1]] |= 1; buf[b[ic+1]] |= 1;
} }
UNUSED(which);
if (getcto(f, buf) < 0) if (getcto(f, buf) < 0)
return -1; return -1;
+15 -6
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser Copyright (C) 2000-2007 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
@@ -40,11 +40,11 @@ static int F(Filter *f)
#ifdef U #ifdef U
// filter // filter
upx_byte *b = f->buf; upx_byte *b = f->buf;
const unsigned addvalue = f->addvalue;
#else #else
// scan // scan
const upx_byte *b = f->buf; const upx_byte *b = f->buf;
#endif #endif
const unsigned addvalue = f->addvalue;
const unsigned size = f->buf_len; const unsigned size = f->buf_len;
unsigned const id = f->id; unsigned const id = f->id;
@@ -58,10 +58,18 @@ static int F(Filter *f)
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)
{ {
buf[b[ic+1]] |= 1; if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
return -1;
} }
else
buf[b[ic+1]] |= 1;
}
if (getcto(f, buf) < 0) if (getcto(f, buf) < 0)
return -1; return -1;
@@ -79,6 +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)
{ {
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
#ifdef U #ifdef U
set_be32(b+ic+1,jc+addvalue+cto); set_be32(b+ic+1,jc+addvalue+cto);
#endif #endif
+2 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
+2 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
+155
View File
@@ -0,0 +1,155 @@
/* ppcbxx.h -- PowerPC Branch trick
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2004-2007 John F. Reiser
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>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
/*************************************************************************
// filter / scan
**************************************************************************/
#define W_CTO 4 /* width of cto; must match stub/ppc_bxx.S */
static int F(Filter *f)
{
#ifdef U
// filter
upx_byte *b = f->buf;
const unsigned addvalue = f->addvalue;
#else
// scan
const upx_byte *b = f->buf;
#endif
const unsigned size = umin(f->buf_len, -(~0u<<(32 - (6+ W_CTO))));
const unsigned size4 = size -4;
unsigned ic;
unsigned calls = 0, noncalls = 0;
unsigned lastnoncall = size, lastcall = 0;
// find 26-2-W_CTO bits of displacements that contain no targets
{
unsigned char buf[256];
unsigned short wbuf[256];
const size_t WW = (size_t)0 - ((~(size_t)0) << W_CTO); // ???
memset(wbuf, 0, sizeof(wbuf));
memset(buf , 0, WW);
memset(buf + WW, 1, 256 - WW);
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
unsigned const off = (int)(get_be32(b+ic)<<6) >>6;
if (size <= (off & (~0u<<2))+ic) {
buf[(~(~0u<<W_CTO)) & (off>>(26 - W_CTO))] |= 1;
++wbuf[0xff&(off>>18)];
}
}
if (getcto(f, buf) < 0) {
if (0!=W_CTO) // FIXME: what is this ???
return -1;
f->cto = 0;
}
}
const unsigned char cto8 = f->cto;
#ifdef U
const unsigned cto = (unsigned)f->cto << (24+2 - W_CTO);
#endif
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
unsigned const word = get_be32(b+ic);
unsigned const off = (int)(word<<6) >>6;
unsigned const jc = (off & (~0u<<2))+ic;
// try to detect 'real' calls only
if (jc < size) {
#ifdef U
set_be32(b+ic,(0xfc000003&word) | (jc+addvalue+cto));
#endif
calls++;
lastcall = ic;
}
else {
assert(0==W_CTO // FIXME: what is this ???
|| (~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != cto8); // this should not happen
lastnoncall = ic;
noncalls++;
}
}
f->calls = calls;
f->noncalls = noncalls;
f->lastcall = lastcall;
#if 0
printf("\ncalls=%d noncalls=%d text_size=%x calltrickoffset=%x\n",
calls,noncalls,size,cto8);
#endif
return 0;
}
/*************************************************************************
// unfilter
**************************************************************************/
#ifdef U
static int U(Filter *f)
{
upx_byte *b = f->buf;
const unsigned size4 = umin(f->buf_len - 4, -(~0u<<(32 - (6+ W_CTO))));
const unsigned addvalue = f->addvalue;
unsigned ic;
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
unsigned const word = get_be32(b+ic);
if ((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) == f->cto) {
unsigned const jc = word & (~(~0u<<(26 - W_CTO)) & (~0u<<2));
set_be32(b+ic, (0xfc000003&word)|(0x03fffffc&(jc-ic-addvalue)));
f->calls++;
f->lastcall = ic;
}
else {
f->noncalls++;
}
}
return 0;
}
#endif
#undef F
#undef U
#undef W_CTO
/*
vi:ts=4:et:nowrap
*/
+2 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
+2 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
+2 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
+2 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
+2 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
+31 -5
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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,19 @@
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 ml1050@users.sourceforge.net
*/ */
#include "conf.h" #include "conf.h"
#include "filter.h" #include "filter.h"
static unsigned
umin(unsigned const a, unsigned const b)
{
return (a<=b) ? a : b;
}
#define set_dummy(p, v) ((void)0) #define set_dummy(p, v) ((void)0)
#define get_8(p) (*(p)) #define get_8(p) (*(p))
@@ -103,7 +109,7 @@
#define COND1(b,x) (b[x] == 0xe8 || b[x] == 0xe9) #define COND1(b,x) (b[x] == 0xe8 || b[x] == 0xe9)
#define COND2(b,x,lc) (lc!=(x) && 0xf==b[(x)-1] && 0x80<=b[x] && b[x]<=0x8f) #define COND2(b,x,lc) (lc!=(x) && 0xf==b[(x)-1] && 0x80<=b[x] && b[x]<=0x8f)
#define COND(b,x,lc,id) (COND1(b,x) || ((9<=(0xf&(id))) && COND2(b,x,lc))) #define COND(b,x,lc,id) (COND1(b,x) || ((9<=(0xf&(id))) && COND2(b,x,lc)))
#define F f_ctok32_e8e9_bswap_le #define F f_ctok32_e8e9_bswap_le
#define U u_ctok32_e8e9_bswap_le #define U u_ctok32_e8e9_bswap_le
#include "filter/ctok.h" #include "filter/ctok.h"
@@ -145,6 +151,19 @@
#undef COND_CALL #undef COND_CALL
/*************************************************************************
// PowerPC branch [incl. call] trick
**************************************************************************/
#define COND(b,x) (18==(get_be32(b+x)>>26))
#define F f_ppcbxx
#define U u_ppcbxx
#include "filter/ppcbxx.h"
#define F s_ppcbxx
#include "filter/ppcbxx.h"
#undef COND
/************************************************************************* /*************************************************************************
// database for use in class Filter // database for use in class Filter
**************************************************************************/ **************************************************************************/
@@ -205,6 +224,10 @@ 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 },
// 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 },
@@ -230,9 +253,12 @@ const FilterImp::FilterEntry FilterImp::filters[] = {
{ 0xb1,99, 0, f_sub32_2, u_sub32_2, s_sub32_2 }, { 0xb1,99, 0, f_sub32_2, u_sub32_2, s_sub32_2 },
{ 0xb2,99, 0, f_sub32_3, u_sub32_3, s_sub32_3 }, { 0xb2,99, 0, f_sub32_3, u_sub32_3, s_sub32_3 },
{ 0xb3,99, 0, f_sub32_4, u_sub32_4, s_sub32_4 }, { 0xb3,99, 0, f_sub32_4, u_sub32_4, s_sub32_4 },
// PowerPC branch+call trick
{ 0xd0, 8, 0, f_ppcbxx, u_ppcbxx, s_ppcbxx },
}; };
const int FilterImp::n_filters = HIGH(filters); const int FilterImp::n_filters = TABLESIZE(filters);
/* /*
+157 -67
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -27,6 +27,9 @@
#include "conf.h" #include "conf.h"
#include "compress.h"
#include "packmast.h"
#include "packer.h"
/************************************************************************* /*************************************************************************
@@ -47,12 +50,12 @@ void show_head(void)
#define V(x) (strcmp(UPX_VERSION_STRING, UPX_VERSION_STRING4) ? UPX_VERSION_STRING : UPX_VERSION_STRING x) #define V(x) (strcmp(UPX_VERSION_STRING, UPX_VERSION_STRING4) ? UPX_VERSION_STRING : UPX_VERSION_STRING x)
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\n" " Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007\n"
"UPX %-12s Markus F.X.J. Oberhumer & Laszlo Molnar %20s\n\n", "UPX %-10s Markus Oberhumer, Laszlo Molnar & John Reiser %14s\n\n",
#if defined(__MFX_DOS) #if (ACC_OS_DOS16 || ACC_OS_DOS32)
V("d"), V("d"),
#elif defined(__MFX_WIN32) #elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
V("w"), V("w"),
#elif 0 && defined(__linux__) #elif 0 && defined(__linux__)
V("l"), V("l"),
@@ -62,6 +65,8 @@ void show_head(void)
UPX_VERSION_DATE); UPX_VERSION_DATE);
fg = con_fg(f,fg); fg = con_fg(f,fg);
#undef V #undef V
UNUSED(fg);
} }
@@ -86,7 +91,77 @@ void show_usage(void)
// //
**************************************************************************/ **************************************************************************/
void show_help(int x) struct PackerNames
{
struct Entry {
const char* fname;
const char* sname;
};
Entry names[32];
size_t names_count;
const options_t *o;
PackerNames() : names_count(0), o(NULL) { }
void add(const Packer *p)
{
p->assertPacker();
assert(names_count < 32);
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);
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(pn.visit, NULL, &o, &pn);
qsort(pn.names, pn.names_count, sizeof(PackerNames::Entry), pn.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)
{
con_fprintf(f, " %-32s %s\n", fn, sn);
}
else
{
if (pos == 0) {
con_fprintf(f, " %s", fn);
pos = 2 + strlen(fn);
} else if (pos + 1 + strlen(fn) > 80) {
con_fprintf(f, "\n %s", fn);
pos = 2 + strlen(fn);
} else {
con_fprintf(f, " %s", fn);
pos += 1 + strlen(fn);
}
}
}
if (!verbose && pn.names_count)
con_fprintf(f, "\n");
}
/*************************************************************************
//
**************************************************************************/
void show_help(int verbose)
{ {
FILE *f = con_term; FILE *f = con_term;
int fg; int fg;
@@ -103,8 +178,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 very 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");
@@ -112,22 +187,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\n"
" --ultra-brute try even more compression variants\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"
@@ -138,17 +220,15 @@ void show_help(int x)
fg = con_fg(f,fg); fg = con_fg(f,fg);
con_fprintf(f, con_fprintf(f,
" --overlay=copy copy any extra data attached to the file [default]\n" " --overlay=copy copy any extra data attached to the file [default]\n"
" --overlay=strip strip any extra data attached to the file [dangerous]\n" " --overlay=strip strip any extra data attached to the file [DANGEROUS]\n"
" --overlay=skip don't compress a file with an overlay\n" " --overlay=skip don't compress a file with an overlay\n"
"\n"); "\n");
#if 1
fg = con_fg(f,FG_YELLOW); fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Options for atari/tos:\n"); con_fprintf(f,"Options for atari/tos:\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" " --all-methods try all available compression methods\n"
"\n"); "\n");
#endif
fg = con_fg(f,FG_YELLOW); 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);
@@ -190,16 +270,16 @@ void show_help(int x)
" --script=/path/upxX use path/upxX as decompressor\n" " --script=/path/upxX use path/upxX as decompressor\n"
"\n"); "\n");
#endif #endif
#if 1
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" " --all-methods try all available compression methods\n"
" --no-align don't align to mode2 sector format\n" " --8-bit uses 8 bit size compression [default: 32 bit]\n"
" --8mb-ram 8 megabyte memory limit [default: 2 mb]\n"
" --boot-only disables client/host transfer compatibility\n"
" --no-align don't align to 2048 bytes [enables: --console-run]\n"
"\n"); "\n");
#endif
#if 1
fg = con_fg(f,FG_YELLOW); fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Options for tmt/adam:\n"); con_fprintf(f,"Options for tmt/adam:\n");
fg = con_fg(f,fg); fg = con_fg(f,fg);
@@ -207,16 +287,13 @@ void show_help(int x)
" --all-methods try all available compression methods\n" " --all-methods try all available compression methods\n"
" --all-filters try all available preprocessing filters\n" " --all-filters try all available preprocessing filters\n"
"\n"); "\n");
#endif
#if 1
fg = con_fg(f,FG_YELLOW); fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Options for [b]vmlinuz/386\n"); con_fprintf(f,"Options for vmlinuz/386\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" " --all-methods try all available compression methods\n"
" --all-filters try all available preprocessing filters\n" " --all-filters try all available preprocessing filters\n"
"\n"); "\n");
#endif
fg = con_fg(f,FG_YELLOW); 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);
@@ -224,7 +301,7 @@ void show_help(int x)
" --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, 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"
@@ -232,7 +309,9 @@ 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" " --all-methods try all available compression methods\n"
@@ -240,34 +319,23 @@ void show_help(int x)
"\n"); "\n");
} }
con_fprintf(f, con_fprintf(f, "file.. executables to (de)compress\n");
"file.. executables to (de)compress\n"
"\n");
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"This version supports:\n");
fg = con_fg(f,fg);
con_fprintf(f," "
"atari/tos, "
"bvmlinuz/386, "
"djgpp2/coff, "
"dos/com, "
"dos/exe, "
"dos/sys,\n "
//"elks/8086, "
"linux/386, "
"linux/elf386, "
"linux/sh386, "
"ps1/exe, "
"rtm32/pe, "
"tmt/adam,\n "
"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 (verbose > 0)
{
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"\nThis version supports:\n");
fg = con_fg(f,fg);
show_all_packers(f, verbose);
}
else
{
con_fprintf(f,"\nType '%s --help' for more detailed help.\n", progname);
}
con_fprintf(f,"\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.sf.net\n"
// "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type 'upx -L'.\n"
"");
#if defined(DEBUG) || defined(TESTING) #if defined(DEBUG) || defined(TESTING)
fg = con_fg(f,FG_RED); fg = con_fg(f,FG_RED);
@@ -281,6 +349,8 @@ void show_help(int x)
"\n"); "\n");
fg = con_fg(f,fg); fg = con_fg(f,fg);
#endif #endif
UNUSED(fg);
} }
@@ -320,6 +390,8 @@ void show_license(void)
" <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>\n" " <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>\n"
); );
fg = con_fg(f,fg); fg = con_fg(f,fg);
UNUSED(fg);
} }
@@ -329,25 +401,43 @@ 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 && defined(__GNUC__) fprintf(fp, "upx %s\n", UPX_VERSION_STRING);
fprintf(f,"upx %s (gcc 0x%lx)\n", UPX_VERSION_STRING, __GNUC_VERSION_HEX__);
#else
fprintf(f,"upx %s\n", UPX_VERSION_STRING);
#endif
#if defined(WITH_NRV) #if defined(WITH_NRV)
fprintf(f,"NRV data compression library %s\n", nrv_version_string()); 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 defined(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-2002 Markus Franz Xaver Johannes Oberhumer\n"); #if defined(WITH_ZLIB)
fprintf(f,"Copyright (C) 1996-2002 Laszlo Molnar\n"); v = upx_zlib_version_string();
fprintf(f,"Copyright (C) 2000-2002 John F. Reiser\n"); if (v != NULL && v[0])
fprintf(f,"Copyright (C) 2002 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 defined(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-2007 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(fp, "Copyright (C) 1996-2007 Laszlo Molnar\n");
fprintf(fp, "Copyright (C) 2000-2007 John F. Reiser\n");
fprintf(fp, "Copyright (C) 2002-2007 Jens Medoch\n");
#if defined(WITH_ZLIB)
fprintf(fp, "Copyright (C) 1995" "-2005 Jean-loup Gailly and Mark Adler\n");
#endif
#if defined(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);
} }
+2 -2
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
+4 -4
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -219,8 +219,8 @@ protected:
private: private:
// disable copy and assignment // disable copy and assignment
LeFile(LeFile const &); // {} LeFile(const LeFile &); // {}
LeFile& operator= (LeFile const &); // { return *this; } LeFile& operator= (const LeFile &); // { return *this; }
}; };
+811 -157
View File
File diff suppressed because it is too large Load Diff
+184 -46
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -30,64 +30,202 @@
#define __UPX_LINKER_H #define __UPX_LINKER_H
class Linker /*************************************************************************
// ElfLinker
**************************************************************************/
class ElfLinker : private nocopy
{ {
friend class Packer;
public: public:
Linker(const void *pdata, int plen, int pinfo); const N_BELE_RTP::AbstractPolicy *bele;
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, unsigned offset);
struct section; Relocation *addRelocation(const char *section, unsigned off, const char *type,
struct jump; const char *symbol, unsigned add);
char *iloader, *oloader; public:
int ilen, olen; ElfLinker();
int info; virtual ~ElfLinker();
jump *jumps;
int njumps;
section *sections;
int nsections;
int frozen;
int align_hack;
int align_offset;
private: virtual void init(const void *pdata, int plen);
// disable copy and assignment //virtual void setLoaderAlignOffset(int phase);
Linker(Linker const &); // {} virtual int addLoader(const char *sname);
Linker& operator= (Linker const &); // { return *this; } void addLoader(const char *s, va_list ap);
#if 1 && (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, unsigned value);
virtual unsigned 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:
virtual void relocate();
virtual void relocate1(const Relocation *, upx_byte *location,
unsigned value, const char *type);
}; };
class BeLinker : public Linker struct ElfLinker::Section : private nocopy
{ {
typedef Linker super; char *name;
public: void *input;
BeLinker(const void *pdata, int plen, int pinfo) : upx_byte *output;
super(pdata, plen, pinfo) { } unsigned size;
unsigned offset;
unsigned p2align; // log2
Section *next;
protected: Section(const char *n, const void *i, unsigned s, unsigned a=0);
// big endian ~Section();
virtual unsigned get32(const void *b) const { return get_be32(b); }
virtual void set32(void *b, unsigned v) const { set_be32(b, v); }
private:
// disable copy and assignment
BeLinker(BeLinker const &); // {}
BeLinker& operator= (BeLinker const &); // { return *this; }
}; };
struct ElfLinker::Symbol : private nocopy
{
char *name;
Section *section;
unsigned offset;
Symbol(const char *n, Section *s, unsigned o);
~Symbol();
};
struct ElfLinker::Relocation : private nocopy
{
const Section *section;
unsigned offset;
const char *type;
const Symbol *value;
unsigned add; // used in .rela relocations
Relocation(const Section *s, unsigned o, const char *t,
const Symbol *v, unsigned 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,
unsigned 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,
unsigned value, const char *type);
};
class ElfLinkerArmLE : public ElfLinker
{
typedef ElfLinker super;
protected:
virtual void relocate1(const Relocation *, upx_byte *location,
unsigned 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,
unsigned value, const char *type);
};
class ElfLinkerMipsLE : public ElfLinker
{
typedef ElfLinker super;
protected:
virtual void relocate1(const Relocation *, upx_byte *location,
unsigned 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,
unsigned 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,
unsigned value, const char *type);
};
#endif /* already included */ #endif /* already included */
+471 -245
View File
File diff suppressed because it is too large Load Diff
+150 -41
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -34,11 +34,40 @@
// //
**************************************************************************/ **************************************************************************/
MemBuffer::MemBuffer(unsigned size) : static int use_mcheck = -1;
ptr(NULL), alloc_ptr(NULL), alloc_size(0)
static int mcheck_init()
{ {
if (size > 0) if (use_mcheck < 0)
alloc(size, 0); {
use_mcheck = 1;
#if defined(WITH_VALGRIND) && defined(RUNNING_ON_VALGRIND)
if (RUNNING_ON_VALGRIND)
{
//fprintf(stderr, "upx: detected RUNNING_ON_VALGRIND\n");
use_mcheck = 0;
}
#endif
}
return use_mcheck;
}
/*************************************************************************
//
**************************************************************************/
MemBuffer::MemBuffer() :
b(NULL), b_size(0)
{
if (use_mcheck < 0)
mcheck_init();
}
MemBuffer::MemBuffer(unsigned size) :
b(NULL), b_size(0)
{
alloc(size);
} }
@@ -49,59 +78,139 @@ MemBuffer::~MemBuffer()
void MemBuffer::dealloc() void MemBuffer::dealloc()
{ {
if (alloc_ptr) if (b)
::free(alloc_ptr); {
alloc_ptr = ptr = NULL; checkState();
alloc_size = 0; if (use_mcheck)
{
// remove magic constants
set_be32(b - 8, 0);
set_be32(b - 4, 0);
set_be32(b + b_size, 0);
set_be32(b + b_size + 4, 0);
//
::free(b - 16);
}
else
::free(b);
b = NULL;
b_size = 0;
}
else
assert(b_size == 0);
} }
unsigned MemBuffer::getSize() const unsigned MemBuffer::getSizeForCompression(unsigned uncompressed_size, unsigned extra)
{ {
if (!alloc_ptr) assert((int)uncompressed_size > 0);
return 0; assert((int)extra >= 0);
unsigned size = alloc_size - (ptr - alloc_ptr); unsigned size = uncompressed_size + uncompressed_size/8 + 256 + extra;
assert((int)size > 0); return size;
}
unsigned MemBuffer::getSizeForUncompression(unsigned uncompressed_size, unsigned extra)
{
assert((int)uncompressed_size > 0);
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
return size; return size;
} }
void MemBuffer::alloc(unsigned size, unsigned base_offset) void MemBuffer::allocForCompression(unsigned uncompressed_size, unsigned extra)
{ {
// NOTE: we don't automaticlly free a used buffer unsigned size = getSizeForCompression(uncompressed_size, extra);
assert(alloc_ptr == NULL); alloc(size);
assert((int)size > 0); }
size = base_offset + size;
alloc_ptr = (unsigned char *) malloc(size);
if (!alloc_ptr) void MemBuffer::allocForUncompression(unsigned uncompressed_size, unsigned extra)
{
unsigned size = getSizeForUncompression(uncompressed_size, extra);
alloc(size);
}
void MemBuffer::fill(unsigned off, unsigned len, int value)
{
checkState();
assert((int)off >= 0);
assert((int)len >= 0);
assert(off <= b_size);
assert(len <= b_size);
assert(off + len <= b_size);
if (len > 0)
memset(b + off, value, len);
}
/*************************************************************************
//
**************************************************************************/
#define PTR(p) ((unsigned) ((acc_uintptr_t)(p) & 0xffffffff))
#define MAGIC1(p) (PTR(p) ^ 0xfefdbeeb)
#define MAGIC2(p) (PTR(p) ^ 0xfefdbeeb ^ 0x80024001)
unsigned MemBuffer::global_alloc_counter = 0;
void MemBuffer::checkState() const
{
if (!b)
throwInternalError("block not allocated");
if (use_mcheck)
{ {
//throw bad_alloc(); if (get_be32(b - 4) != MAGIC1(b))
throwCantPack("out of memory"); throwInternalError("memory clobbered before allocated block 1");
//exit(1); if (get_be32(b - 8) != b_size)
throwInternalError("memory clobbered before allocated block 2");
if (get_be32(b + b_size) != MAGIC2(b))
throwInternalError("memory clobbered past end of allocated block");
} }
alloc_size = size; assert((int)b_size > 0);
ptr = alloc_ptr + base_offset;
} }
void MemBuffer::alloc(unsigned size) void MemBuffer::alloc(unsigned size)
{ {
alloc(size, 0); if (use_mcheck < 0)
} mcheck_init();
// NOTE: we don't automatically free a used buffer
assert(b == NULL);
assert(b_size == 0);
//
assert((int)size > 0);
unsigned total = use_mcheck ? size + 32 : size;
assert((int)total > 0);
unsigned char *p = (unsigned char *) malloc(total);
if (!p)
{
//throw bad_alloc();
throw OutOfMemoryException("out of memory");
//exit(1);
}
b_size = size;
if (use_mcheck)
{
b = p + 16;
// store magic constants to detect buffer overruns
set_be32(b - 8, b_size);
set_be32(b - 4, MAGIC1(b));
set_be32(b + b_size, MAGIC2(b));
set_be32(b + b_size + 4, global_alloc_counter++);
}
else
b = p ;
void MemBuffer::allocForCompression(unsigned uncompressed_size) //fill(0, b_size, (rand() & 0xff) | 1); // debug
{
assert((int)uncompressed_size > 0);
alloc(uncompressed_size + uncompressed_size/8 + 256, 0);
}
void MemBuffer::allocForUncompression(unsigned uncompressed_size)
{
assert((int)uncompressed_size > 0);
//alloc(uncompressed_size + 3 + 512, 0); // 512 safety bytes
alloc(uncompressed_size + 3, 0); // 3 bytes for asm_fast decompresion
} }
+25 -27
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -37,46 +37,44 @@
class MemBuffer class MemBuffer
{ {
public: public:
MemBuffer(unsigned size=0); MemBuffer();
explicit MemBuffer(unsigned size);
~MemBuffer(); ~MemBuffer();
static unsigned getSizeForCompression(unsigned uncompressed_size, unsigned extra=0);
static unsigned getSizeForUncompression(unsigned uncompressed_size, unsigned extra=0);
void alloc(unsigned size); void alloc(unsigned size);
void allocForCompression(unsigned uncompressed_size); void allocForCompression(unsigned uncompressed_size, unsigned extra=0);
void allocForUncompression(unsigned uncompressed_size); void allocForUncompression(unsigned uncompressed_size, unsigned extra=0);
void dealloc(); void dealloc();
const unsigned char *getBuf() const { return ptr; } void checkState() const;
unsigned getSize() const;
operator unsigned char * () { return ptr; } unsigned getSize() const { return b_size; }
//operator const unsigned char * () const { return ptr; }
void *getVoidPtr() { return (void *) ptr; } operator unsigned char * () { return b; }
const void *getVoidPtr() const { return (const void *) ptr; } //operator const unsigned char * () const { return b; }
void *getVoidPtr() { return (void *) b; }
const void *getVoidPtr() const { return (const void *) b; }
void fill(unsigned off, unsigned len, int value);
void clear(unsigned off, unsigned len) { fill(off, len, 0); }
void clear() { fill(0, b_size, 0); }
private: private:
void alloc(unsigned size, unsigned base_offset); unsigned char *b;
unsigned b_size;
protected: static unsigned global_alloc_counter;
unsigned char *ptr;
unsigned char *alloc_ptr;
unsigned alloc_size;
private:
// disable copy and assignment // disable copy and assignment
MemBuffer(MemBuffer const &); // {} MemBuffer(const MemBuffer &); // {}
MemBuffer& operator= (MemBuffer const &); // { return *this; } MemBuffer& operator= (const MemBuffer &); // { return *this; }
// disable dynamic allocation // disable dynamic allocation
#ifndef new DISABLE_NEW_DELETE
static void *operator new (size_t); // {}
static void *operator new[] (size_t); // {}
#endif
#ifndef delete
//static void operator delete (void *) {}
//static void operator delete[] (void *) {}
#endif
}; };
#endif /* already included */ #endif /* already included */
+6713
View File
File diff suppressed because it is too large Load Diff
+27 -15
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -66,9 +66,9 @@ void printClearLine(FILE *f)
static void pr_print(bool c, const char *msg) static void pr_print(bool c, const char *msg)
{ {
if (c && !opt->to_stdout) if (c && !opt->to_stdout)
con_fprintf(stderr,msg); con_fprintf(stderr, "%s", msg);
else else
fprintf(stderr,msg); fprintf(stderr, "%s", msg);
} }
static void pr_error(const char *iname, const char *msg, bool is_warning) static void pr_error(const char *iname, const char *msg, bool is_warning)
@@ -88,7 +88,7 @@ static void pr_error(const char *iname, const char *msg, bool is_warning)
// This hack is needed, otherwise error messages may get lost // This hack is needed, otherwise error messages may get lost
// when the cursor is not yet at the bottom of the screen. // when the cursor is not yet at the bottom of the screen.
// At least I can use some colors then... // At least I can use some colors then...
bool c = isatty(STDERR_FILENO) ? 1 : 0; bool c = acc_isatty(STDERR_FILENO) ? 1 : 0;
int fg = con_fg(stderr,FG_BRTRED); int fg = con_fg(stderr,FG_BRTRED);
upx_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"%s: ", progname); upx_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"%s: ", progname);
@@ -103,23 +103,35 @@ static void pr_error(const char *iname, const char *msg, bool is_warning)
fg = con_fg(stderr,fg); fg = con_fg(stderr,fg);
UNUSED(is_warning); UNUSED(is_warning);
UNUSED(fg);
} }
void printErr(const char *iname, const Throwable *e) void printErr(const char *iname, const Throwable *e)
{ {
char buf[1024]; char buf[1024];
size_t l;
upx_snprintf(buf, sizeof(buf), "%s", prettyName(typeid(*e))); upx_snprintf(buf, sizeof(buf), "%s", prettyName(typeid(*e).name()));
if (e->getMsg()) l = strlen(buf);
upx_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),": %s", e->getMsg()); if (l < sizeof(buf) && e->getMsg())
if (e->getErrno()) upx_snprintf(buf+l, sizeof(buf)-l, ": %s", e->getMsg());
upx_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),": %s", strerror(e->getErrno())); l = strlen(buf);
if (l < sizeof(buf) && e->getErrno()) {
upx_snprintf(buf+l, sizeof(buf)-l, ": %s", strerror(e->getErrno()));
#if 1
// some compilers (e.g. Borland C++) put a trailing '\n'
// into strerror() result
l = strlen(buf);
while (l-- > 0 && (buf[l] == '\n' || buf[l] == ' '))
buf[l] = 0;
#endif
}
pr_error(iname,buf,e->isWarning()); pr_error(iname,buf,e->isWarning());
} }
void printErr(const char *iname, const char *format, ...) void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
{ {
va_list args; va_list args;
char buf[1024]; char buf[1024];
@@ -132,7 +144,7 @@ void printErr(const char *iname, const char *format, ...)
} }
void printWarn(const char *iname, const char *format, ...) void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
{ {
va_list args; va_list args;
char buf[1024]; char buf[1024];
@@ -189,7 +201,7 @@ void infoHeader()
info_header = 0; info_header = 0;
} }
void infoHeader(const char *format, ...) void __acc_cdecl_va infoHeader(const char *format, ...)
{ {
if (opt->info_mode <= 0) if (opt->info_mode <= 0)
return; return;
@@ -203,7 +215,7 @@ void infoHeader(const char *format, ...)
} }
void info(const char *format, ...) void __acc_cdecl_va info(const char *format, ...)
{ {
if (opt->info_mode <= 0) if (opt->info_mode <= 0)
return; return;
@@ -218,7 +230,7 @@ void info(const char *format, ...)
} }
void infoWarning(const char *format, ...) void __acc_cdecl_va infoWarning(const char *format, ...)
{ {
if (opt->info_mode <= 0) if (opt->info_mode <= 0)
{ {
+40 -30
View File
@@ -21,11 +21,22 @@
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "tailor.h"
#undef PROGNAME
#if 0
#ifndef EOF #ifndef EOF
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#endif #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 /* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
@@ -54,8 +65,6 @@
#define optind mfx_optind #define optind mfx_optind
#define opterr mfx_opterr #define opterr mfx_opterr
#define optopt mfx_optopt #define optopt mfx_optopt
#define my_index strchr
#define my_strlen strlen
#undef BAD_OPTION #undef BAD_OPTION
/* For communication from `getopt' to the caller. /* For communication from `getopt' to the caller.
@@ -167,7 +176,7 @@ static int last_nonopt;
static void exchange (char **argv) static void exchange (char **argv)
{ {
char *temp, **first, **last; char *temp; char **first, **last;
/* Reverse all the elements [first_nonopt, optind) */ /* Reverse all the elements [first_nonopt, optind) */
first = &argv[first_nonopt]; first = &argv[first_nonopt];
@@ -382,15 +391,10 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
int indfound = 0; int indfound = 0;
int needexact = 0; int needexact = 0;
#if defined(DOSISH)
/* allow `--option#value' because you cannout assign a '=' /* allow `--option#value' because you cannout assign a '='
to an environment variable under DOS command.com */ to an environment variable under DOS command.com */
while (*s && *s != '=' && * s != '#') while (*s && *s != '=' && * s != '#')
s++; s++;
#else
while (*s && *s != '=')
s++;
#endif
/* Test all options for either exact match or abbreviated matches. */ /* Test all options for either exact match or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; for (p = longopts, option_index = 0; p->name;
@@ -399,7 +403,7 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
{ {
if (p->has_arg & 0x10) if (p->has_arg & 0x10)
needexact = 1; needexact = 1;
if ((unsigned) (s - nextchar) == my_strlen (p->name)) if ((unsigned) (s - nextchar) == strlen (p->name))
{ {
/* Exact match found. */ /* Exact match found. */
pfound = p; pfound = p;
@@ -423,8 +427,8 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
{ {
if (opterr) if (opterr)
fprintf (stderr, "%s: unrecognized option `%s'\n", fprintf (stderr, "%s: unrecognized option `%s'\n",
argv[0], argv[optind]); PROGNAME(argv[0]), argv[optind]);
nextchar += my_strlen (nextchar); nextchar += strlen (nextchar);
optind++; optind++;
return BAD_OPTION; return BAD_OPTION;
} }
@@ -432,8 +436,8 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
{ {
if (opterr) if (opterr)
fprintf (stderr, "%s: option `%s' is ambiguous\n", fprintf (stderr, "%s: option `%s' is ambiguous\n",
argv[0], argv[optind]); PROGNAME(argv[0]), argv[optind]);
nextchar += my_strlen (nextchar); nextchar += strlen (nextchar);
optind++; optind++;
return BAD_OPTION; return BAD_OPTION;
} }
@@ -459,14 +463,14 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
/* --option */ /* --option */
fprintf (stderr, fprintf (stderr,
"%s: option `--%s' doesn't allow an argument\n", "%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name); PROGNAME(argv[0]), pfound->name);
else else
/* +option or -option */ /* +option or -option */
fprintf (stderr, fprintf (stderr,
"%s: option `%c%s' doesn't allow an argument\n", "%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[optind - 1][0], pfound->name); PROGNAME(argv[0]), argv[optind - 1][0], pfound->name);
} }
nextchar += my_strlen (nextchar); nextchar += strlen (nextchar);
return BAD_OPTION; return BAD_OPTION;
} }
} }
@@ -482,13 +486,13 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
{ {
if (opterr) if (opterr)
fprintf (stderr, "%s: option `--%s%s' requires an argument\n", fprintf (stderr, "%s: option `--%s%s' requires an argument\n",
argv[0], pfound->name, PROGNAME(argv[0]), pfound->name,
(pfound->has_arg & 0x20) ? "=" : ""); (pfound->has_arg & 0x20) ? "=" : "");
nextchar += my_strlen (nextchar); nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : BAD_OPTION; return optstring[0] == ':' ? ':' : BAD_OPTION;
} }
} }
nextchar += my_strlen (nextchar); nextchar += strlen (nextchar);
if (longind != NULL) if (longind != NULL)
*longind = option_index; *longind = option_index;
if (pfound->flag) if (pfound->flag)
@@ -506,31 +510,31 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
#ifdef GETOPT_COMPAT #ifdef GETOPT_COMPAT
|| argv[optind][0] == '+' || argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */ #endif /* GETOPT_COMPAT */
|| my_index (optstring, *nextchar) == NULL) || strchr (optstring, *nextchar) == NULL)
{ {
if (opterr) if (opterr)
{ {
if (argv[optind][1] == '-') if (argv[optind][1] == '-')
/* --option */ /* --option */
fprintf (stderr, "%s: unrecognized option `--%s'\n", fprintf (stderr, "%s: unrecognized option `--%s'\n",
argv[0], nextchar); PROGNAME(argv[0]), nextchar);
else else
/* +option or -option */ /* +option or -option */
fprintf (stderr, "%s: unrecognized option `%c%s'\n", fprintf (stderr, "%s: unrecognized option `%c%s'\n",
argv[0], argv[optind][0], nextchar); PROGNAME(argv[0]), argv[optind][0], nextchar);
} }
nextchar = empty_string; nextchar = empty_string;
optind++; optind++;
return BAD_OPTION; return BAD_OPTION;
} }
ambig = ambig; (void) &ambig; /* UNUSED */
} }
/* Look at and handle the next option-character. */ /* Look at and handle the next option-character. */
{ {
char c = *nextchar++; char c = *nextchar++;
const char *temp = my_index (optstring, c); const char *temp = strchr (optstring, c);
/* Increment `optind' when we start to process its last character. */ /* Increment `optind' when we start to process its last character. */
if (*nextchar == '\0') if (*nextchar == '\0')
@@ -543,12 +547,12 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
#if 0 #if 0
if (c < 040 || c >= 0177) if (c < 040 || c >= 0177)
fprintf (stderr, "%s: unrecognized option, character code 0%o\n", fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
argv[0], c); PROGNAME(argv[0]), c);
else else
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); fprintf (stderr, "%s: unrecognized option `-%c'\n", PROGNAME(argv[0]), c);
#else #else
/* 1003.2 specifies the format of this message. */ /* 1003.2 specifies the format of this message. */
fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); fprintf (stderr, "%s: illegal option -- %c\n", PROGNAME(argv[0]), c);
#endif #endif
} }
optopt = c; optopt = c;
@@ -584,11 +588,11 @@ static int _getopt_internal (int argc, char **argv, const char *optstring,
{ {
#if 0 #if 0
fprintf (stderr, "%s: option `-%c' requires an argument\n", fprintf (stderr, "%s: option `-%c' requires an argument\n",
argv[0], c); PROGNAME(argv[0]), c);
#else #else
/* 1003.2 specifies the format of this message. */ /* 1003.2 specifies the format of this message. */
fprintf (stderr, "%s: option requires an argument -- %c\n", fprintf (stderr, "%s: option requires an argument -- %c\n",
argv[0], c); PROGNAME(argv[0]), c);
#endif #endif
} }
optopt = c; optopt = c;
@@ -694,3 +698,9 @@ main (argc, argv)
} }
#endif /* TEST */ #endif /* TEST */
/*
vi:ts=4:et:nowrap
*/
+3 -3
View File
@@ -19,7 +19,7 @@
#define __MFX_GETOPT_H 1 #define __MFX_GETOPT_H 1
#ifdef __cplusplus #ifdef __cplusplus
//extern "C" { /* extern "C" { */
#endif #endif
/* For communication from `getopt' to the caller. /* For communication from `getopt' to the caller.
@@ -96,7 +96,7 @@ int mfx_getopt_long(int argc, char **argv, const char *shortopts,
const struct mfx_option *longopts, int *longind); const struct mfx_option *longopts, int *longind);
#ifdef __cplusplus #ifdef __cplusplus
//} /* } */
#endif #endif
#endif /* _GETOPT_H */ #endif /* __MFX_GETOPT_H */
+53 -30
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -47,15 +47,22 @@ struct options_t {
// compression options // compression options
int method; int method;
int level; // compression level 1..10 bool method_lzma_seen;
int filter; // preferred filter from Packer::getFilters() bool method_nrv2b_seen;
bool all_methods; // try all available compression methods ? bool method_nrv2d_seen;
bool all_filters; // try all available filters ? bool method_nrv2e_seen;
int level; // compression level 1..10
int filter; // preferred filter from Packer::getFilters()
bool ultra_brute;
bool all_methods; // try all available compression methods ?
bool all_methods_use_lzma;
bool all_filters; // try all available filters ?
bool no_filter; // force no filter
bool exact; // user requires byte-identical decompression
// other options // other options
int backup; int backup;
int console; int console;
int debug;
int force; int force;
int info_mode; int info_mode;
bool ignorewarn; bool ignorewarn;
@@ -66,6 +73,15 @@ struct options_t {
int verbose; int verbose;
bool to_stdout; bool to_stdout;
// debug options
struct {
int debug_level;
bool disable_random_id; // for Packer::getRandomId()
const char *dump_stub_loader;
char fake_stub_version[4+1]; // for internal debugging
char fake_stub_year[4+1]; // for internal debugging
} debug;
// overlay handling // overlay handling
enum { enum {
SKIP_OVERLAY = 0, SKIP_OVERLAY = 0,
@@ -74,16 +90,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 {
@@ -99,38 +113,47 @@ struct options_t {
// options for various executable formats // options for various executable formats
struct { struct {
bool force_stub; bool split_segments;
bool no_reloc; } atari_tos;
} dos;
struct { struct {
bool coff; bool coff;
} djgpp2; } djgpp2_coff;
struct { struct {
bool force_stub;
bool no_reloc;
} dos_exe;
struct {
bool boot_only;
bool no_align; bool no_align;
} ps1; bool do_8bit;
struct { bool do_8mb;
bool split_segments; } ps1_exe;
} tos;
struct { struct {
unsigned blocksize; unsigned blocksize;
bool force_execve; // force the linux/386 execve format bool force_execve; // force the linux/386 execve format
bool 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 make_ptinterp; // make PT_INTERP [ignore current file!]
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
enum { SCRIPT_MAX = 32 }; enum { SCRIPT_MAX = 32 };
const char *script_name; const char *script_name;
} unix; } o_unix;
struct { struct {
bool le; bool le;
} wcle; } watcom_le;
struct { struct {
int compress_exports; int compress_exports;
int compress_icons; int compress_icons;
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;
} w32pe; const char *keep_resource;
} win32_pe;
void reset();
}; };
extern struct options_t * volatile opt; extern struct options_t *opt;
#endif /* already included */ #endif /* already included */
+1141
View File
File diff suppressed because it is too large Load Diff
+73
View File
@@ -0,0 +1,73 @@
/* p_armpe.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 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@users.sourceforge.net
*/
#ifndef __UPX_P_ARMPE_H
#define __UPX_P_ARMPE_H
/*************************************************************************
// arm/pe
**************************************************************************/
class PackArmPe : public PeFile
{
typedef PeFile super;
public:
PackArmPe(InputFile *f);
virtual ~PackArmPe();
virtual int getFormat() const { return UPX_F_WINCE_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 *getFilters() const;
virtual void pack(OutputFile *fo);
virtual bool canPack();
virtual int canUnpack();
protected:
virtual void buildLoader(const Filter *ft);
virtual Linker* newLinker() const;
virtual unsigned processImports();
virtual void processImports(unsigned, unsigned);
virtual void rebuildImports(upx_byte *&);
virtual void processTls(Interval *);
bool use_thumb_stub;
};
#endif /* already included */
/*
vi:ts=4:et
*/
+35 -38
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -31,9 +31,10 @@
#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
@@ -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,18 +131,18 @@ 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" : "",
"COMMAIN2""UPX1HEAD""COMCUTPO""NRV2B160", "COMMAIN2,UPX1HEAD,COMCUTPO,NRV2B160",
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();
} }
@@ -170,7 +161,7 @@ void PackCom::addFilter16(int filter_id)
if (filter_id % 3 == 0) if (filter_id % 3 == 0)
addLoader("CALLTR16", addLoader("CALLTR16",
filter_id < 4 ? "CT16SUB0" : "", filter_id < 4 ? "CT16SUB0" : "",
filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I086" : "CT16I286""CT16SUB0"), filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I086" : "CT16I286,CT16SUB0"),
"CALLTRI2", "CALLTRI2",
getFormat() == UPX_F_DOS_COM ? "CORETURN" : "", getFormat() == UPX_F_DOS_COM ? "CORETURN" : "",
NULL NULL
@@ -180,7 +171,7 @@ void PackCom::addFilter16(int filter_id)
"CALLTRI5", "CALLTRI5",
getFormat() == UPX_F_DOS_COM ? "CT16JEND" : "CT16JUL2", getFormat() == UPX_F_DOS_COM ? "CT16JEND" : "CT16JUL2",
filter_id < 4 ? "CT16SUB1" : "", filter_id < 4 ? "CT16SUB1" : "",
filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I087" : "CT16I287""CT16SUB1"), filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I087" : "CT16I287,CT16SUB1"),
"CALLTRI6", "CALLTRI6",
NULL NULL
); );
@@ -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,6 +261,12 @@ void PackCom::unpack(OutputFile *fo)
} }
Linker* PackCom::newLinker() const
{
return new ElfLinkerX86();
}
/* /*
vi:ts=4:et vi:ts=4:et
*/ */
+8 -6
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -38,10 +38,11 @@ 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 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;
@@ -52,10 +53,11 @@ public:
virtual int canUnpack(); virtual int canUnpack();
protected: protected:
virtual const 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);
}; };
+143 -91
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -31,12 +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/stubify.h" #include "stub/i386-dos32.djgpp2.h"
static const static const
#include "stub/l_djgpp2.h" #include "stub/i386-dos32.djgpp2-stubify.h"
/************************************************************************* /*************************************************************************
@@ -46,13 +46,16 @@ 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)
#if defined(STUBIFY_STUB_ADLER32) COMPILE_TIME_ASSERT_ALIGNED1(external_scnhdr_t)
COMPILE_TIME_ASSERT_ALIGNED1(coff_header_t)
COMPILE_TIME_ASSERT(sizeof(stub_i386_dos32_djgpp2_stubify) == 2048)
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);
#endif
} }
@@ -65,8 +68,9 @@ 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;
} }
@@ -81,25 +85,32 @@ unsigned PackDjgpp2::findOverlapOverhead(const upx_bytep buf,
} }
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
); );
if (ft->id) if (ft->id)
{ {
assert(ft->calls > 0); assert(ft->calls > 0);
addLoader("DJCALLT2",NULL); addLoader("DJCALLT2", NULL);
addFilter32(ft->id); addFilter32(ft->id);
} }
addLoader("DJRETURN+40DXXXXUPX1HEAD",NULL); addLoader("DJRETURN,+40C,UPX1HEAD", NULL);
return getLoaderSize();
} }
@@ -109,18 +120,18 @@ int PackDjgpp2::buildLoader(const Filter *ft)
void PackDjgpp2::handleStub(OutputFile *fo) void PackDjgpp2::handleStub(OutputFile *fo)
{ {
if (fo && !opt->djgpp2.coff) if (fo && !opt->djgpp2_coff.coff)
{ {
if (coff_offset > 0) if (coff_offset > 0)
{ {
// copy stub from exe // copy stub from exe
Packer::handleStub(fi,fo,coff_offset); Packer::handleStub(fi, fo, coff_offset);
} }
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));
} }
} }
} }
@@ -132,14 +143,14 @@ static bool is_dlm(InputFile *fi, long coff_offset)
long off; long 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 < 0 || 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);
if (memcmp(buf,"DLMF",4) == 0) if (memcmp(buf, "DLMF", 4) == 0)
return true; return true;
} catch (const IOException&) { } catch (const IOException&) {
} }
@@ -158,7 +169,7 @@ 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 || pfsize >= fi->st.st_size) if (pfsize <= 8 || (off_t) pfsize >= (off_t) fi->st.st_size)
return; return;
fi->seek(-pfsize, SEEK_END); fi->seek(-pfsize, SEEK_END);
} catch (const IOException&) { } catch (const IOException&) {
@@ -179,25 +190,25 @@ int PackDjgpp2::readFileHeader()
unsigned char hdr[0x1c]; unsigned char hdr[0x1c];
unsigned char magic[8]; unsigned char magic[8];
fi->seek(0,SEEK_SET); fi->seek(0, SEEK_SET);
fi->readx(hdr,sizeof(hdr)); fi->readx(hdr, sizeof(hdr));
if (get_le16(hdr) == 0x5a4d) // MZ exe signature, stubbed? if (get_le16(hdr) == 0x5a4d) // MZ exe signature, stubbed?
{ {
coff_offset = 512 * get_le16(hdr+4); coff_offset = 512 * get_le16(hdr+4);
if (get_le16(hdr+2) != 0) if (get_le16(hdr+2) != 0)
coff_offset += get_le16(hdr+2) - 512; coff_offset += get_le16(hdr+2) - 512;
fi->seek(512,SEEK_SET); fi->seek(512, SEEK_SET);
fi->readx(magic,8); fi->readx(magic, 8);
if (memcmp("go32stub",magic,8) != 0) if (memcmp("go32stub", magic, 8) != 0)
return 0; // not V2 image return 0; // not V2 image
fi->seek(coff_offset,SEEK_SET); fi->seek(coff_offset, SEEK_SET);
if (fi->read(&coff_hdr,sizeof(coff_hdr)) != sizeof(coff_hdr)) if (fi->read(&coff_hdr, sizeof(coff_hdr)) != sizeof(coff_hdr))
throwCantPack("skipping djgpp symlink"); throwCantPack("skipping djgpp symlink");
} }
else else
{ {
fi->seek(coff_offset,SEEK_SET); fi->seek(coff_offset, SEEK_SET);
fi->readx(&coff_hdr,0xa8); fi->readx(&coff_hdr, 0xa8);
} }
if (coff_hdr.f_magic != 0x014c) // I386MAGIC if (coff_hdr.f_magic != 0x014c) // I386MAGIC
return 0; return 0;
@@ -220,7 +231,7 @@ void PackDjgpp2::stripDebug()
coff_hdr.f_symptr = 0; coff_hdr.f_symptr = 0;
coff_hdr.f_nsyms = 0; coff_hdr.f_nsyms = 0;
coff_hdr.f_flags = 0x10f; // 0x100: "32 bit machine: LSB first" coff_hdr.f_flags = 0x10f; // 0x100: "32 bit machine: LSB first"
memset(text->misc,0,12); memset(text->misc, 0, 12);
} }
@@ -232,7 +243,7 @@ bool PackDjgpp2::canPack()
{ {
if (!readFileHeader()) if (!readFileHeader())
return false; return false;
if (is_dlm(fi,coff_offset)) if (is_dlm(fi, coff_offset))
throwCantPack("can't handle DLM"); throwCantPack("can't handle DLM");
if (opt->force == 0) if (opt->force == 0)
@@ -269,56 +280,60 @@ void PackDjgpp2::pack(OutputFile *fo)
// read file // read file
const unsigned size = text->size + data->size; const unsigned size = text->size + data->size;
const unsigned tpos = text->scnptr; const unsigned tpos = text->scnptr;
const unsigned usize = size + (tpos & 0x1ff); const unsigned hdrsize = 20 + 28 + sizeof(external_scnhdr_t) * coff_hdr.f_nscns;
const unsigned hdrsize = 20 + 28 + (40 * coff_hdr.f_nscns); const unsigned usize = size + hdrsize;
if (hdrsize < sizeof(coff_hdr) || hdrsize > tpos) if (hdrsize < sizeof(coff_hdr) || hdrsize > tpos)
throwCantPack("coff header error"); throwCantPack("coff header error");
if (hdrsize > (tpos & 0x1ff))
throwCantPack("unsupported coff header");
ibuf.alloc(usize); ibuf.alloc(usize);
obuf.allocForCompression(usize); obuf.allocForCompression(usize);
fi->seek(coff_offset,SEEK_SET); fi->seek(coff_offset, SEEK_SET);
fi->readx(ibuf,hdrsize); // orig. coff header fi->readx(ibuf, hdrsize); // orig. coff header
memset(ibuf + hdrsize, 0, tpos - hdrsize); fi->seek(coff_offset + tpos, SEEK_SET);
fi->seek(coff_offset+tpos,SEEK_SET); fi->readx(ibuf + hdrsize, size);
fi->readx(ibuf + (tpos & 0x1ff),size);
// prepare packheader // prepare packheader
ph.u_len = usize; ph.u_len = usize;
// prepare filter // prepare filter
Filter ft(ph.level); Filter ft(ph.level);
ft.buf_len = usize - data->size; ft.buf_len = usize - data->size;
ft.addvalue = text->vaddr & ~0x1ff; 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: ~28KB 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 &~ 0x1ff); 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
// the original coff header (which is put just before the
// beginning of the original .text section)
assert(text->vaddr > hdrsize + lsize + sizeof(coff_hdr));
// patch coff header #3 // patch coff header #3
text->vaddr = sizeof(coff_hdr); text->vaddr = sizeof(coff_hdr);
@@ -327,13 +342,23 @@ void PackDjgpp2::pack(OutputFile *fo)
bss->size -= ph.overlap_overhead; bss->size -= ph.overlap_overhead;
// 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, 4);
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);
fo->write(obuf,data->size); if (opt->debug.dump_stub_loader)
OutputFile::dump(opt->debug.dump_stub_loader, loader, lsize);
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));
printf("%-13s: loader : %8ld bytes\n", getName(), (long) lsize); printf("%-13s: loader : %8ld bytes\n", getName(), (long) lsize);
@@ -345,7 +370,7 @@ void PackDjgpp2::pack(OutputFile *fo)
// handle overlay // handle overlay
// FIXME: only Allegro pakfiles are supported // FIXME: only Allegro pakfiles are supported
handle_allegropak(fi,fo); handle_allegropak(fi, fo);
// finally check the compression ratio // finally check the compression ratio
if (!checkFinalCompressionRatio(fo)) if (!checkFinalCompressionRatio(fo))
@@ -361,10 +386,10 @@ int PackDjgpp2::canUnpack()
{ {
if (!readFileHeader()) if (!readFileHeader())
return false; return false;
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;
} }
@@ -379,19 +404,30 @@ void PackDjgpp2::unpack(OutputFile *fo)
ibuf.alloc(ph.c_len); ibuf.alloc(ph.c_len);
obuf.allocForUncompression(ph.u_len); obuf.allocForUncompression(ph.u_len);
fi->seek(coff_offset + ph.buf_offset + ph.getPackHeaderSize(),SEEK_SET); fi->seek(coff_offset + ph.buf_offset + ph.getPackHeaderSize(), SEEK_SET);
fi->readx(ibuf,ph.c_len); fi->readx(ibuf, ph.c_len);
// decompress // decompress
decompress(ibuf,obuf); decompress(ibuf, obuf);
coff_header_t *chdr = (coff_header_t*) obuf.getVoidPtr();
text = chdr->sh;
data = text + 1;
const unsigned hdrsize = 20 + 28
+ sizeof(external_scnhdr_t) * chdr->f_nscns;
unsigned addvalue;
if (ph.version >= 14)
addvalue = text->vaddr - hdrsize;
else
addvalue = text->vaddr &~ 0x1ff; // for old versions
// unfilter // unfilter
if (ph.filter) if (ph.filter)
{ {
memcpy(&coff_hdr,obuf,sizeof(coff_hdr));
Filter ft(ph.level); Filter ft(ph.level);
ft.init(ph.filter, text->vaddr &~ 0x1ff); ft.init(ph.filter, addvalue);
ft.cto = (unsigned char) ph.filter_cto; ft.cto = (unsigned char) ph.filter_cto;
if (ph.version < 11) if (ph.version < 11)
{ {
@@ -402,18 +438,34 @@ void PackDjgpp2::unpack(OutputFile *fo)
ft.unfilter(obuf, ph.u_len - data->size); ft.unfilter(obuf, ph.u_len - data->size);
} }
// fixup for the aligning bug in strip 2.8+ if (ph.version < 14)
text = ((coff_header_t*) (unsigned char *) obuf)->sh;
data = text + 1;
text->scnptr &= 0x1ff;
data->scnptr = text->scnptr + text->size;
// write decompressed file
if (fo)
{ {
fo->write(obuf,ph.u_len); // fixup for the aligning bug in strip 2.8+
handle_allegropak(fi,fo); text->scnptr &= 0x1ff;
data->scnptr = text->scnptr + text->size;
// write decompressed file
if (fo)
fo->write(obuf, ph.u_len);
} }
else
{
// write the header
// some padding might be required between the end
// of the header and the start of the .text section
const unsigned padding = text->scnptr - hdrsize;
ibuf.clear(0, padding);
if (fo)
{
fo->write(obuf, hdrsize);
fo->write(ibuf, padding);
fo->write(obuf + hdrsize, ph.u_len - hdrsize);
}
}
if (fo)
handle_allegropak(fi, fo);
} }
+7 -5
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -40,9 +40,10 @@ class PackDjgpp2 : public Packer
public: public:
PackDjgpp2(InputFile *f); PackDjgpp2(InputFile *f);
virtual int getVersion() const { return 13; } 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"; }
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;
@@ -59,7 +60,8 @@ protected:
virtual unsigned findOverlapOverhead(const upx_bytep buf, virtual unsigned findOverlapOverhead(const upx_bytep buf,
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; long coff_offset;
+358 -47
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -31,71 +31,382 @@
/************************************************************************* /*************************************************************************
// Some ELF type definitinons // N_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.
struct Elf_LE32_Ehdr template <class TElfITypes>
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 */
LE16 e_type; /* Object file type */ Half e_type; /* Object file type */
LE16 e_machine; /* Architecture */ Half e_machine; /* Architecture */
LE32 e_version; /* Object file version */ Word e_version; /* Object file version */
LE32 e_entry; /* Entry point virtual address */ Addr e_entry; /* Entry point virtual address */
LE32 e_phoff; /* Program header table file offset */ Off e_phoff; /* Program header table file offset */
LE32 e_shoff; /* Section header table file offset */ Off e_shoff; /* Section header table file offset */
LE32 e_flags; /* Processor-specific flags */ Word e_flags; /* Processor-specific flags */
LE16 e_ehsize; /* ELF header size in bytes */ Half e_ehsize; /* ELF header size in bytes */
LE16 e_phentsize; /* Program header table entry size */ Half e_phentsize; /* Program header table entry size */
LE16 e_phnum; /* Program header table entry count */ Half e_phnum; /* Program header table entry count */
LE16 e_shentsize; /* Section header table entry size */ Half e_shentsize; /* Section header table entry size */
LE16 e_shnum; /* Section header table entry count */ Half e_shnum; /* Section header table entry count */
LE16 e_shstrndx; /* Section header string table index */ Half e_shstrndx; /* Section header string table index */
# define WANT_EHDR_ENUM 1
# include "p_elf_enum.h"
} }
__attribute_packed; __attribute_packed;
// Program segment header. template <class TElfITypes>
struct Elf_LE32_Phdr struct Dyn
{ {
LE32 p_type; /* Segment type */ typedef typename TElfITypes::Xword Xword;
LE32 p_offset; /* Segment file offset */ typedef typename TElfITypes::Addr Addr;
LE32 p_vaddr; /* Segment virtual address */
LE32 p_paddr; /* Segment physical address */
LE32 p_filesz; /* Segment size in file */
LE32 p_memsz; /* Segment size in memory */
LE32 p_flags; /* Segment flags */
LE32 p_align; /* Segment alignment */
// Values for p_type Xword d_tag;
enum { Addr d_val;
PT_LOAD = 1, /* Loadable program segment */
PT_DYNAMIC = 2, /* Dynamic linking information */
PT_PHDR = 6 /* Entry for header table itself */
};
// Values for p_flags # define WANT_DYN_ENUM 1
enum { PF_X = (1 << 0) }; /* Segment is executable */ # include "p_elf_enum.h"
enum { PF_W = (1 << 1) }; /* Segment is writable */
enum { PF_R = (1 << 2) }; /* Segment is readable */
} }
__attribute_packed; __attribute_packed;
struct Elf_LE32_Dyn template <class TElfITypes>
struct External_Note
{ {
LE32 d_tag; typedef typename TElfITypes::Word Word;
LE32 d_val;
enum { // tags Word xn_namesz; // includes terminating '\0'
DT_NULL = 0, /* End flag */ Word xn_datasz;
DT_NEEDED = 1, /* Name of needed library */ Word xn_type;
DT_STRTAB = 5, /* String table */ //char xn_name[N]; // terminate with '\0'
DT_STRSZ = 10 /* Sizeof string table */ //char xn_data[M]; // aligned to 0 mod 4
};
} }
__attribute_packed; __attribute_packed;
} // namespace N_Elf
/*************************************************************************
// N_Elf32
**************************************************************************/
namespace N_Elf32 {
template <class TElfITypes>
struct Phdr
{
typedef typename TElfITypes::Word Word;
typedef typename TElfITypes::Addr Addr;
typedef typename TElfITypes::Off Off;
Word p_type; /* Segment type */
Off p_offset; /* Segment file offset */
Addr p_vaddr; /* Segment virtual address */
Addr p_paddr; /* Segment physical address */
Word p_filesz; /* Segment size in file */
Word p_memsz; /* Segment size in memory */
Word p_flags; /* Segment flags */
Word p_align; /* Segment alignment */
# define WANT_PHDR_ENUM 1
# include "p_elf_enum.h"
}
__attribute_packed;
template <class TElfITypes>
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_type; /* Section type */
Word sh_flags; /* Section flags */
Addr sh_addr; /* Section virtual addr at execution */
Off sh_offset; /* Section file offset */
Word sh_size; /* Section size in bytes */
Word sh_link; /* Link to another section */
Word sh_info; /* Additional section information */
Word sh_addralign; /* Section alignment */
Word sh_entsize; /* Entry size if section holds table */
# define WANT_SHDR_ENUM 1
# include "p_elf_enum.h"
}
__attribute_packed;
template <class TElfITypes>
struct Sym
{
typedef typename TElfITypes::Word Word;
typedef typename TElfITypes::Addr Addr;
typedef typename TElfITypes::Section Section;
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_other; /* symbol visibility */
Section st_shndx; /* section index */
# define WANT_SYM_ENUM 1
# include "p_elf_enum.h"
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 (bind<<4) + (0xf & type); }
}
__attribute_packed;
} // namespace N_Elf32
/*************************************************************************
// N_Elf64
**************************************************************************/
namespace N_Elf64 {
template <class TElfITypes>
struct Phdr
{
typedef typename TElfITypes::Word Word;
typedef typename TElfITypes::Xword Xword;
typedef typename TElfITypes::Addr Addr;
typedef typename TElfITypes::Off Off;
Word p_type; /* Segment type */
Word p_flags; /* Segment flags */
Off p_offset; /* Segment file offset */
Addr p_vaddr; /* Segment virtual address */
Addr p_paddr; /* Segment physical address */
Xword p_filesz; /* Segment size in file */
Xword p_memsz; /* Segment size in memory */
Xword p_align; /* Segment alignment */
# define WANT_PHDR_ENUM 1
# include "p_elf_enum.h"
}
__attribute_packed;
template <class TElfITypes>
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_type; /* Section type */
Xword sh_flags; /* Section flags */
Addr sh_addr; /* Section virtual addr at execution */
Off sh_offset; /* Section file offset */
Xword sh_size; /* Section size in bytes */
Word sh_link; /* Link to another section */
Word sh_info; /* Additional section information */
Xword sh_addralign; /* Section alignment */
Xword sh_entsize; /* Entry size if section holds table */
# define WANT_SHDR_ENUM 1
# include "p_elf_enum.h"
}
__attribute_packed;
template <class TElfITypes>
struct Sym
{
typedef typename TElfITypes::Word Word;
typedef typename TElfITypes::Xword Xword;
typedef typename TElfITypes::Addr Addr;
typedef typename TElfITypes::Section Section;
Word st_name; /* symbol name (index into string table) */
unsigned char st_info; /* symbol type and binding */
unsigned char st_other; /* symbol visibility */
Section st_shndx; /* section index */
Addr st_value; /* symbol value */
Xword st_size; /* symbol size */
# define WANT_SYM_ENUM 1
# include "p_elf_enum.h"
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 (bind<<4) + (0xf & type); }
}
__attribute_packed;
} // namespace N_Elf64
/*************************************************************************
// aggregate types into an ElfClass
**************************************************************************/
namespace N_Elf {
template <class TP>
struct ElfClass_32
{
typedef TP BeLePolicy;
// integral types
typedef typename TP::U16 U16;
typedef typename TP::U32 U32;
typedef typename TP::U64 U64;
typedef N_Elf::ElfITypes<U16, U32, U32, U32, U32> ElfITypes;
// ELF types
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
typedef N_Elf32::Phdr<ElfITypes> Phdr;
typedef N_Elf32::Shdr<ElfITypes> Shdr;
typedef N_Elf ::Dyn <ElfITypes> Dyn;
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(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(Sym)
}
};
template <class TP>
struct ElfClass_64
{
typedef TP BeLePolicy;
// integral types
typedef typename TP::U16 U16;
typedef typename TP::U32 U32;
typedef typename TP::U64 U64;
typedef N_Elf::ElfITypes<U16, U32, U64, U64, U64> ElfITypes;
// 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_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(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(Sym)
}
};
} // namespace N_Elf
typedef N_Elf::ElfClass_32<N_BELE_CTP::HostPolicy> ElfClass_Host32;
typedef N_Elf::ElfClass_64<N_BELE_CTP::HostPolicy> ElfClass_Host64;
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::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::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::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::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::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::Sym Elf_LE64_Sym;
typedef ElfClass_LE64::External_Note Elf_LE64_External_Note;
#endif /* already included */ #endif /* already included */
+185
View File
@@ -0,0 +1,185 @@
/* p_elf_enum.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 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@users.sourceforge.net
*/
/*************************************************************************
// 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_PPC = 20,
EM_PPC64 = 21,
EM_ARM = 40,
EM_X86_64 = 62
};
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 */
};
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 */
};
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_HASH = 4, /* Hash table of symbol names */
DT_STRTAB = 5, /* String table */
DT_SYMTAB = 6, /* Symbol table */
DT_STRSZ = 10 /* Sizeof string table */
};
#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
/*
vi:ts=4:et
*/
+10 -10
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -94,13 +94,12 @@ void PackElks8086::readKernel()
// //
**************************************************************************/ **************************************************************************/
int PackElks8086::buildLoader(const Filter *ft) void PackElks8086::buildLoader(const Filter *ft)
{ {
// prepare loader // prepare loader
initLoader(nrv_loader, sizeof(nrv_loader)); initLoader(nrv_loader, sizeof(nrv_loader));
// FIXME // FIXME
UNUSED(ft); UNUSED(ft);
return getLoaderSize();
} }
@@ -113,7 +112,7 @@ void PackElks8086::pack(OutputFile *fo)
ft.buf_len = ph.u_len; ft.buf_len = ph.u_len;
ft.addvalue = kernel_entry; ft.addvalue = kernel_entry;
// compress // compress
compressWithFilters(&ft, overlap_range); compressWithFilters(&ft, overlap_range, NULL_cconf);
const unsigned lsize = getLoaderSize(); const unsigned lsize = getLoaderSize();
MemBuffer loader(lsize); MemBuffer loader(lsize);
@@ -122,10 +121,11 @@ void PackElks8086::pack(OutputFile *fo)
patchPackHeader(loader, lsize); patchPackHeader(loader, lsize);
#if 0 #if 0
// FIXME // FIXME
patchFilter32(loader, lsize, &ft); defineFilterSymbols(&ft);
patch_le32(loader, lsize, "ESI1", zimage_offset + lsize); defineDecompressorSymbols();
patch_le32(loader, lsize, "KEIP", kernel_entry); //patch_le32(loader, lsize, "ESI1", zimage_offset + lsize);
patch_le32(loader, lsize, "STAK", stack_during_uncompression); //patch_le32(loader, lsize, "KEIP", kernel_entry);
//patch_le32(loader, lsize, "STAK", stack_during_uncompression);
#endif #endif
boot_sect_t * const bs = (boot_sect_t *) ((unsigned char *) setup_buf); boot_sect_t * const bs = (boot_sect_t *) ((unsigned char *) setup_buf);
+285 -111
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -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,8 +50,15 @@ static const
PackExe::PackExe(InputFile *f) : PackExe::PackExe(InputFile *f) :
super(f) super(f)
{ {
bele = &N_BELE_RTP::le_policy;
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32); COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32);
ih_exesize = ih_imagesize = ih_overlay = 0; ih_exesize = ih_imagesize = ih_overlay = 0;
stack_for_lzma = 0;
use_clear_dirty_stack = false;
// disable lzma for "--brute" unless explicitly given "--lzma"
if (opt->all_methods_use_lzma && !opt->method_lzma_seen)
opt->all_methods_use_lzma = false;
} }
@@ -72,7 +80,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.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 +88,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 ? 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 +110,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 +129,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 +140,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);
} }
@@ -213,7 +306,7 @@ bool PackExe::canPack()
fi->readx(&offs,sizeof (offs)); fi->readx(&offs,sizeof (offs));
if (ih.relocoffs >= 0x40 && offs) if (ih.relocoffs >= 0x40 && offs)
{ {
if (opt->dos.force_stub) if (opt->dos_exe.force_stub)
opt->overlay = opt->COPY_OVERLAY; opt->overlay = opt->COPY_OVERLAY;
else else
throwCantPack("can't pack new-exe"); throwCantPack("can't pack new-exe");
@@ -231,6 +324,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;
@@ -293,7 +389,9 @@ unsigned optimize_relocs(upx_byte *b, const unsigned size,
{ {
addr = get_le32(relocs+4*i); addr = get_le32(relocs+4*i);
//printf ("%x\n",es*16+di); //printf ("%x\n",es*16+di);
if (addr - es*16 > 0xfffe) if ((addr - es*16 > 0xfffe)
|| (i == nrelocs - 1 && addr - es * 16 > 0xff00)
)
{ {
// segment change // segment change
t = 1+(0xffff-di)/254; t = 1+(0xffff-di)/254;
@@ -303,7 +401,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)
@@ -338,7 +436,7 @@ unsigned optimize_relocs(upx_byte *b, const unsigned size,
set_le16 (crel_save+2,seg_high); set_le16 (crel_save+2,seg_high);
//OutputFile::dump("x.rel", crel_save, crel - crel_save); //OutputFile::dump("x.rel", crel_save, crel - crel_save);
return crel - crel_save; return (unsigned) (crel - crel_save);
} }
@@ -365,6 +463,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;
@@ -403,13 +503,18 @@ 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();
if (ph.max_run_found + ph.max_match_found > 0x8000) cconf.conf_ucl.max_match = MAXMATCH;
throwCantPack("decompressor limit exceeded, send a bugreport"); cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB 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)
throwCantPack("decompressor limit exceeded, send a bugreport");
#ifdef TESTING #ifdef TESTING
if (opt->debug) 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);
printf("offsets: %d - %d\nmatches: %d - %d\nruns: %d - %d\n", printf("offsets: %d - %d\nmatches: %d - %d\nruns: %d - %d\n",
@@ -437,8 +542,8 @@ void PackExe::pack(OutputFile *fo)
// set oh.min & oh.max // set oh.min & oh.max
ic = ih.min*16 + ih_imagesize; ic = ih.min*16 + ih_imagesize;
if (ic < oh.ss*16 + oh.sp) if (ic < oh.ss*16u + oh.sp)
ic = oh.ss*16 + oh.sp; ic = oh.ss*16u + oh.sp;
oh.min = (ic - (packedsize + lsize)) / 16; oh.min = (ic - (packedsize + lsize)) / 16;
ic = oh.min + (ih.max - ih.min); ic = oh.min + (ih.max - ih.min);
oh.max = ic < 0xffff && ih.max != 0xffff ? ic : 0xffff; oh.max = ic < 0xffff && ih.max != 0xffff ? ic : 0xffff;
@@ -472,60 +577,61 @@ 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;
} }
// g++ 3.1 does not like the following line... // g++ 3.1 does not like the following line...
// 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 #ifdef TESTING
if (opt->debug) 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
fo->write(&oh,sizeof(oh)); fo->write(&oh,sizeof(oh));
@@ -565,7 +671,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);
} }
@@ -605,12 +711,11 @@ void PackExe::unpack(OutputFile *fo)
{ {
relocs -= get_le16(obuf+ph.u_len-2); relocs -= get_le16(obuf+ph.u_len-2);
ph.u_len -= 2; ph.u_len -= 2;
upx_byte *p;
wrkmem.alloc(4*MAXRELOCS); wrkmem.alloc(4*MAXRELOCS);
unsigned es = 0,ones = get_le16(relocs); unsigned es = 0, ones = get_le16(relocs);
unsigned seghi = get_le16(relocs+2); const unsigned seghi = get_le16(relocs+2);
p = relocs + 4; const upx_byte *p = relocs + 4;
while (ones) while (ones)
{ {
@@ -628,10 +733,10 @@ void PackExe::unpack(OutputFile *fo)
dorel = true; dorel = true;
if (*p == 0) if (*p == 0)
{ {
upx_byte *q; const upx_byte *q;
for (q = obuf+es*16+di; !(*q == 0x9a && get_le16(q+3) <= seghi); q++) for (q = obuf+es*16+di; !(*q == 0x9a && get_le16(q+3) <= seghi); q++)
; ;
di = q - (obuf+es*16) + 3; di = ptr_diff(q, obuf+es*16) + 3;
} }
else if (*p == 1) else if (*p == 1)
{ {
@@ -668,15 +773,15 @@ void PackExe::unpack(OutputFile *fo)
oh.ss = ih.ss; oh.ss = ih.ss;
if (flag & MAXMEM) if (flag & MAXMEM)
imagesize -= 2, oh.max = get_le16(ibuf+imagesize); { imagesize -= 2; oh.max = get_le16(ibuf+imagesize); }
if (flag & MINMEM) if (flag & MINMEM)
imagesize -= 2, oh.min = get_le16(ibuf+imagesize); { imagesize -= 2; oh.min = get_le16(ibuf+imagesize); }
if (flag & SP) if (flag & SP)
imagesize -= 2, oh.sp = get_le16(ibuf+imagesize); { imagesize -= 2; oh.sp = get_le16(ibuf+imagesize); }
if (flag & SS) if (flag & SS)
imagesize -= 2, oh.ss = get_le16(ibuf+imagesize); { imagesize -= 2; oh.ss = get_le16(ibuf+imagesize); }
unsigned ip = (flag & USEJUMP) ? get_le32(ibuf+imagesize-4) : ih.firstreloc; unsigned ip = (flag & USEJUMP) ? get_le32(ibuf+imagesize-4) : (unsigned) ih.firstreloc;
oh.ip = ip & 0xffff; oh.ip = ip & 0xffff;
oh.cs = ip >> 16; oh.cs = ip >> 16;
@@ -696,6 +801,75 @@ void PackExe::unpack(OutputFile *fo)
} }
Linker* PackExe::newLinker() const
{
return new ElfLinkerX86();
}
/*
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
*/
/* /*
vi:ts=4:et vi:ts=4:et
*/ */
+11 -4
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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 ml1050@users.sourceforge.net
*/ */
@@ -42,6 +42,7 @@ 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 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,7 +69,9 @@ 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 struct exe_header_t
{ {
@@ -98,6 +101,7 @@ protected:
unsigned relocsize; unsigned relocsize;
bool has_9a; bool has_9a;
bool device_driver;
enum { enum {
NORELOC = 1, NORELOC = 1,
@@ -107,6 +111,9 @@ protected:
MINMEM = 16, MINMEM = 16,
MAXMEM = 32 MAXMEM = 32
}; };
unsigned stack_for_lzma; // stack size required for lzma
bool use_clear_dirty_stack;
}; };
+1824 -270
View File
File diff suppressed because it is too large Load Diff
+404 -32
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser Copyright (C) 2000-2007 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 <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/ */
@@ -31,52 +34,421 @@
#define __UPX_P_LX_ELF_H #define __UPX_P_LX_ELF_H
class PackLinuxElf : public PackUnix
{
typedef PackUnix super;
public:
PackLinuxElf(InputFile *f);
virtual ~PackLinuxElf();
/*virtual void buildLoader(const Filter *);*/
virtual bool canUnpackVersion(int version) const { return (version >= 11); }
protected:
virtual const int *getCompressionMethods(int method, int level) const;
// All other virtual functions in this class must be pure virtual
// because they depend on Elf32 or Elf64 data structures, which differ.
virtual void pack1(OutputFile *, Filter &) = 0; // generate executable header
virtual void pack2(OutputFile *, Filter &) = 0; // append compressed data
virtual void pack3(OutputFile *, Filter &) = 0; // append loader
//virtual void pack4(OutputFile *, Filter &) = 0; // append pack header
virtual void generateElfHdr(
OutputFile *,
void const *proto,
unsigned const brka
) = 0;
virtual void defineSymbols(Filter const *);
virtual void addStubEntrySections(Filter const *);
virtual void unpack(OutputFile *fo) = 0;
protected:
char *file_image; // if ET_DYN investigation
char const *dynstr; // from DT_STRTAB
unsigned sz_phdrs; // sizeof Phdr[]
unsigned sz_elf_hdrs; // all Elf headers
unsigned sz_pack2; // after pack2(), before loader
unsigned short e_machine;
unsigned char ei_class;
unsigned char ei_data;
unsigned char ei_osabi;
char const *osabi_note;
};
class PackLinuxElf32 : public PackLinuxElf
{
typedef PackLinuxElf super;
public:
PackLinuxElf32(InputFile *f);
virtual ~PackLinuxElf32();
protected:
virtual int checkEhdr(Elf32_Ehdr const *ehdr) const;
virtual bool canPack();
// 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 void pack1(OutputFile *, Filter &); // generate executable header
virtual void pack2(OutputFile *, Filter &); // append compressed data
virtual void pack3(OutputFile *, Filter &); // append loader
virtual void pack4(OutputFile *, Filter &); // append pack header
virtual void unpack(OutputFile *fo);
virtual void generateElfHdr(
OutputFile *,
void const *proto,
unsigned const brka
);
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 void patchLoader();
virtual void updateLoader(OutputFile *fo);
virtual unsigned find_LOAD_gap(Elf32_Phdr const *const phdri, unsigned const k,
unsigned const e_phnum);
virtual off_t getbase(const Elf32_Phdr *phdr, int e_phnum) const;
static unsigned elf_hash(char const *) /*const*/;
virtual void const *elf_find_dynamic(unsigned) const;
virtual Elf32_Sym const *elf_lookup(char const *) const;
virtual unsigned elf_get_offset_from_address(unsigned) const;
protected:
Elf32_Ehdr ehdri; // from input file
Elf32_Phdr *phdri; // for input file
Elf32_Dyn const *dynseg; // from PT_DYNAMIC
unsigned int const *hashtab; // from DT_HASH
Elf32_Sym const *dynsym; // from DT_SYMTAB
struct cprElfHdr1 {
Elf32_Ehdr ehdr;
Elf32_Phdr phdr[1];
l_info linfo;
}
__attribute_packed;
struct cprElfHdr2 {
Elf32_Ehdr ehdr;
Elf32_Phdr phdr[2];
l_info linfo;
}
__attribute_packed;
struct cprElfHdr3 {
Elf32_Ehdr ehdr;
Elf32_Phdr phdr[3];
l_info linfo;
}
__attribute_packed;
cprElfHdr3 elfout;
struct Elf32_Note {
unsigned namesz; // 8
unsigned descsz; // 4
unsigned type; // 1
char text[0x18 - 4*4]; // "OpenBSD"
unsigned end; // 0
} elfnote;
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 PackLinuxElf64 : public PackLinuxElf
{
typedef PackLinuxElf super;
public:
PackLinuxElf64(InputFile *f);
virtual ~PackLinuxElf64();
/*virtual void buildLoader(const Filter *);*/
protected:
virtual int checkEhdr(Elf64_Ehdr const *ehdr) const;
virtual void pack1(OutputFile *, Filter &); // generate executable header
virtual void pack2(OutputFile *, Filter &); // append compressed data
virtual void pack3(OutputFile *, Filter &); // append loader
virtual void pack4(OutputFile *, Filter &); // append pack header
virtual void unpack(OutputFile *fo);
virtual void generateElfHdr(
OutputFile *,
void const *proto,
unsigned const brka
);
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 void patchLoader();
virtual void updateLoader(OutputFile *fo);
virtual unsigned find_LOAD_gap(Elf64_Phdr const *const phdri, unsigned const k,
unsigned const e_phnum);
protected:
Elf64_Ehdr ehdri; // from input file
Elf64_Phdr *phdri; // for input file
struct cprElfHdr1 {
Elf64_Ehdr ehdr;
Elf64_Phdr phdr[1];
l_info linfo;
}
__attribute_packed;
struct cprElfHdr2 {
Elf64_Ehdr ehdr;
Elf64_Phdr phdr[2];
l_info linfo;
}
__attribute_packed;
struct cprElfHdr3 {
Elf64_Ehdr ehdr;
Elf64_Phdr phdr[3];
l_info linfo;
}
__attribute_packed;
cprElfHdr3 elfout;
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_ALIGNED1(cprElfHdr1)
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr2)
COMPILE_TIME_ASSERT_ALIGNED1(cprElfHdr3)
}
};
class PackLinuxElf32Be : public PackLinuxElf32
{
typedef PackLinuxElf32 super;
protected:
PackLinuxElf32Be(InputFile *f) : super(f) { bele = &N_BELE_RTP::be_policy; }
virtual acc_uint64l_t get_native64(const void *b) const { return get_be64(b); }
virtual unsigned get_native32(const void *b) const { return get_be32(b); }
virtual unsigned get_native16(const void *b) const { return get_be16(b); }
virtual void set_native64(void *b, acc_uint64l_t v) const { set_be64(b, v); }
virtual void set_native32(void *b, unsigned v) const { set_be32(b, v); }
virtual void set_native16(void *b, unsigned v) const { set_be16(b, v); }
};
class PackLinuxElf32Le : public PackLinuxElf32
{
typedef PackLinuxElf32 super;
protected:
PackLinuxElf32Le(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
virtual unsigned get_native16(const void *b) const { return get_le16(b); }
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 PackLinuxElf64Le : public PackLinuxElf64
{
typedef PackLinuxElf64 super;
protected:
PackLinuxElf64Le(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
virtual unsigned get_native16(const void *b) const { return get_le16(b); }
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); }
};
/*************************************************************************
// linux/elf64amd
**************************************************************************/
class PackLinuxElf64amd : public PackLinuxElf64Le
{
typedef PackLinuxElf64Le super;
public:
PackLinuxElf64amd(InputFile *f);
virtual ~PackLinuxElf64amd();
virtual int getFormat() const { return UPX_F_LINUX_ELF64_AMD; }
virtual const char *getName() const { return "linux/ElfAMD"; }
virtual const char *getFullName(const options_t *) const { return "amd64-linux.elf"; }
virtual const int *getFilters() const;
virtual bool canPack();
protected:
virtual void pack1(OutputFile *, Filter &); // generate executable header
//virtual void pack3(OutputFile *, Filter &); // append loader
virtual void buildLoader(const Filter *);
virtual Linker* newLinker() const;
virtual void defineSymbols(Filter const *);
};
/*************************************************************************
// linux/elf32ppc
**************************************************************************/
class PackLinuxElf32ppc : public PackLinuxElf32Be
{
typedef PackLinuxElf32Be super;
public:
PackLinuxElf32ppc(InputFile *f);
virtual ~PackLinuxElf32ppc();
virtual int getFormat() const { return UPX_F_LINUX_ELFPPC32; }
virtual const char *getName() const { return "linux/ElfPPC"; }
virtual const char *getFullName(const options_t *) const { return "powerpc-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;
};
/************************************************************************* /*************************************************************************
// linux/elf386 // linux/elf386
**************************************************************************/ **************************************************************************/
class PackLinuxI386elf : public PackLinuxI386 class PackLinuxElf32x86 : public PackLinuxElf32Le
{ {
typedef PackLinuxI386 super; typedef PackLinuxElf32Le super;
public: public:
PackLinuxI386elf(InputFile *f); PackLinuxElf32x86(InputFile *f);
virtual ~PackLinuxI386elf(); virtual ~PackLinuxElf32x86();
virtual int getVersion() const { return 13; }
virtual int getFormat() const { return UPX_F_LINUX_ELF_i386; } virtual int getFormat() const { return UPX_F_LINUX_ELF_i386; }
virtual const char *getName() const { return "linux/elf386"; } virtual const char *getName() const { return "linux/elf386"; }
virtual const char *getFullName(const options_t *) const { return "i386-linux.elf"; }
virtual const int *getFilters() const; virtual const int *getFilters() const;
virtual int buildLoader(const Filter *);
virtual void unpack(OutputFile *fo); virtual void unpack(OutputFile *fo);
virtual bool canPack();
virtual bool canUnpackVersion(int version) const
{ return (version >= 11); }
protected: protected:
struct Extent { virtual void pack1(OutputFile *, Filter &); // generate executable header
off_t offset;
off_t size; virtual void buildLoader(const Filter *);
}; virtual void addStubEntrySections(Filter const *);
virtual void packExtent(Extent const &x, virtual Linker* newLinker() const;
unsigned &total_in, unsigned &total_out, Filter *, OutputFile *); virtual void defineSymbols(Filter const *);
virtual void unpackExtent(unsigned wanted, OutputFile *fo, };
unsigned &total_in, unsigned &total_out,
unsigned &c_adler, unsigned &u_adler, class PackBSDElf32x86 : public PackLinuxElf32x86
bool first_PF_X, unsigned szb_info ); {
typedef PackLinuxElf32x86 super;
public:
PackBSDElf32x86(InputFile *f);
virtual ~PackBSDElf32x86();
virtual int getFormat() const { return UPX_F_BSD_ELF_i386; }
virtual const char *getName() const { return "BSD/elf386"; }
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 void patchLoader();
Elf_LE32_Ehdr ehdri; // from input file
Elf_LE32_Phdr *phdri; // for input file
unsigned sz_phdrs; // sizeof Phdr[]
virtual void buildLoader(const Filter *);
}; };
class PackFreeBSDElf32x86 : public PackBSDElf32x86
{
typedef PackBSDElf32x86 super;
public:
PackFreeBSDElf32x86(InputFile *f);
virtual ~PackFreeBSDElf32x86();
virtual const char *getFullName(const options_t *) const { return "i386-freebsd.elf"; }
};
class PackNetBSDElf32x86 : public PackBSDElf32x86
{
typedef PackBSDElf32x86 super;
public:
PackNetBSDElf32x86(InputFile *f);
virtual ~PackNetBSDElf32x86();
virtual const char *getFullName(const options_t *) const { return "i386-netbsd.elf"; }
};
class PackOpenBSDElf32x86 : public PackBSDElf32x86
{
typedef PackBSDElf32x86 super;
public:
PackOpenBSDElf32x86(InputFile *f);
virtual ~PackOpenBSDElf32x86();
virtual const char *getFullName(const options_t *) const { return "i386-openbsd.elf"; }
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_ARMLE; }
virtual const char *getName() const { return "linux/armLE"; }
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 buildLoader(const Filter *);
virtual void updateLoader(OutputFile *);
virtual void defineSymbols(Filter const *);
};
class PackLinuxElf32armBe : public PackLinuxElf32Be
{
typedef PackLinuxElf32Be super;
public:
PackLinuxElf32armBe(InputFile *f);
virtual ~PackLinuxElf32armBe();
virtual int getFormat() const { return UPX_F_LINUX_ELF32_ARMBE; }
virtual const char *getName() const { return "linux/armBE"; }
virtual const char *getFullName(const options_t *) const { return "armeb-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 buildLoader(const Filter *);
virtual void updateLoader(OutputFile *);
virtual void defineSymbols(Filter const *);
};
#endif /*} already included */ #endif /*} already included */
+336 -188
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2001-2002 John F. Reiser Copyright (C) 2001-2007 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 <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/ */
@@ -37,22 +40,49 @@
#include "p_unix.h" #include "p_unix.h"
#include "p_lx_exc.h" #include "p_lx_exc.h"
#define PT_LOAD Elf_LE32_Phdr::PT_LOAD #define PT_LOAD Elf32_Phdr::PT_LOAD
#define PT_DYNAMIC Elf_LE32_Phdr::PT_DYNAMIC #define PT_DYNAMIC Elf32_Phdr::PT_DYNAMIC
#define DT_NULL Elf_LE32_Dyn::DT_NULL #if 0 // UNUSED
#define DT_NEEDED Elf_LE32_Dyn::DT_NEEDED #define DT_NULL Elf32_Dyn::DT_NULL
#define DT_STRTAB Elf_LE32_Dyn::DT_STRTAB #define DT_NEEDED Elf32_Dyn::DT_NEEDED
#define DT_STRSZ Elf_LE32_Dyn::DT_STRSZ #define DT_STRTAB Elf32_Dyn::DT_STRTAB
#define DT_STRSZ Elf32_Dyn::DT_STRSZ
#endif
/************************************************************************* /*************************************************************************
// 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
@@ -63,32 +93,53 @@ const int *PackLinuxI386::getCompressionMethods(int method, int level) const
const int *PackLinuxI386::getFilters() const const int *PackLinuxI386::getFilters() const
{ {
static const int filters[] = { static const int filters[] = {
#if 1
0x26, 0x24, 0x11, 0x14, 0x13, 0x16, 0x25, 0x15, 0x12,
#else
0x49, 0x46, 0x49, 0x46,
0x26, 0x24, 0x11, 0x14, 0x13, 0x16, 0x25, 0x15, 0x12,
#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 *const fo, OutputFile *fo,
void const *const proto, void const *proto,
unsigned const brka unsigned const brka
) )
{ {
cprElfHdr1 *const h1 = (cprElfHdr1 *)&elfout;
cprElfHdr2 *const h2 = (cprElfHdr2 *)&elfout; cprElfHdr2 *const h2 = (cprElfHdr2 *)&elfout;
memcpy(h2, proto, sizeof(*h2)); cprElfHdr3 *const h3 = (cprElfHdr3 *)&elfout;
memcpy(h3, proto, sizeof(*h3)); // reads beyond, but OK
assert(h2->ehdr.e_phoff == sizeof(Elf_LE32_Ehdr)); assert(h2->ehdr.e_phoff == sizeof(Elf32_Ehdr));
assert(h2->ehdr.e_shoff == 0); assert(h2->ehdr.e_shoff == 0);
assert(h2->ehdr.e_ehsize == sizeof(Elf_LE32_Ehdr)); assert(h2->ehdr.e_ehsize == sizeof(Elf32_Ehdr));
assert(h2->ehdr.e_phentsize == sizeof(Elf_LE32_Phdr)); assert(h2->ehdr.e_phentsize == sizeof(Elf32_Phdr));
assert(h2->ehdr.e_shnum == 0); assert(h2->ehdr.e_shnum == 0);
#if 0 //{ #if 0 //{
@@ -100,29 +151,26 @@ 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) { else if (ph.format==UPX_F_LINUX_ELFI_i386) {
assert(h2->ehdr.e_phnum==1); assert(h3->ehdr.e_phnum==3);
h2->ehdr.e_phnum = 2; memset(&h3->linfo, 0, sizeof(h3->linfo));
memset(&h2->linfo, 0, sizeof(h2->linfo)); fo->write(h3, sizeof(*h3));
fo->write(h2, sizeof(*h2));
} }
else { else {
assert(false); // unknown ph.format, PackUnix::generateElfHdr assert(false); // unknown ph.format, PackUnix::generateElfHdr
@@ -135,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
@@ -144,21 +201,82 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
overlay_offset = sizeof(elfout.ehdr) + overlay_offset = sizeof(elfout.ehdr) +
(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) ? elfout.phdr[2].p_memsz : 0) ; ((elfout.ehdr.e_phnum==3) ? (unsigned) elfout.phdr[2].p_memsz : 0) ;
unsigned nw = fo->getBytesWritten();
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);
elfout.phdr[0].p_filesz = fo->getBytesWritten(); #if 0 // {
// /usr/bin/strip from RedHat 8.0 (binutils-2.13.90.0.2-2)
// generates a 92-byte [only] output, because the "linking view"
// is empty. This code supplies a "linking view".
// However, 'strip' then generates _plausible_ junk that gets
// "Illegal instruction" because 'strip' changes p_hdr[1].p_align,
// .p_offset, and .p_vaddr incorrectly. So the "cure" is worse than
// the disease. It is obvious that a 92-byte file is bad,
// but it is not obvious that the changed .p_align is bad.
// Also, having a totally empty "linking view" is easier for 'strip'
// to fix: just detect that, and do nothing.
// So, we don't use this code for now [2003-01-11].
#define PAGE_MASK (~0<<12) // Supply a "linking view" that covers everything,
// so that 'strip' does not omit everything.
Elf_LE32_Shdr shdr;
// The section header string table.
char const shstrtab[] = "\0.\0.shstrtab";
unsigned eod = elfout.phdr[0].p_filesz;
elfout.ehdr.e_shoff = eod;
elfout.ehdr.e_shentsize = sizeof(shdr);
elfout.ehdr.e_shnum = 3;
elfout.ehdr.e_shstrndx = 2;
// An empty Elf32_Shdr for space as a null index.
memset(&shdr, 0, sizeof(shdr));
shdr.sh_type = Elf32_Shdr::SHT_NULL;
fo->write(&shdr, sizeof(shdr));
// Cover all the bits we need at runtime.
memset(&shdr, 0, sizeof(shdr));
shdr.sh_name = 1;
shdr.sh_type = Elf32_Shdr::SHT_PROGBITS;
shdr.sh_flags = Elf32_Shdr::SHF_ALLOC;
shdr.sh_addr = elfout.phdr[0].p_vaddr;
shdr.sh_offset = overlay_offset;
shdr.sh_size = eod - overlay_offset;
shdr.sh_addralign = 4096;
fo->write(&shdr, sizeof(shdr));
// A section header for the section header string table.
memset(&shdr, 0, sizeof(shdr));
shdr.sh_name = 3;
shdr.sh_type = Elf32_Shdr::SHT_STRTAB;
shdr.sh_offset = 3*sizeof(shdr) + eod;
shdr.sh_size = sizeof(shstrtab);
fo->write(&shdr, sizeof(shdr));
fo->write(shstrtab, sizeof(shstrtab));
#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
#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);
fo->rewrite(&elfout, sizeof(elfout.ehdr) + fo->rewrite(&elfout, overlay_offset);
elfout.ehdr.e_phnum * sizeof(elfout.phdr[0]) +
sizeof(l_info) );
} }
static unsigned static unsigned
@@ -170,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,
@@ -181,128 +304,106 @@ PackLinuxI386::buildLinuxLoader(
{ {
initLoader(proto, szproto); initLoader(proto, szproto);
unsigned fold_hdrlen = 0;
if (0 < szfold) {
cprElfHdr1 const *const hf = (cprElfHdr1 const *)fold; cprElfHdr1 const *const hf = (cprElfHdr1 const *)fold;
unsigned const 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);
struct b_info h; memset(&h, 0, sizeof(h)); if (0 == get_le32(fold_hdrlen + fold)) {
h.sz_unc = szfold - fold_hdrlen; // inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
h.b_method = (unsigned char) ph.method; fold_hdrlen = umax(0x80, fold_hdrlen);
h.b_ftid = (unsigned char) ph.filter; }
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];
int r = upx_compress(uncLoader, h.sz_unc, sizeof(h) + cprLoader, &h.sz_cpr,
NULL, ph.method, 10, NULL, NULL );
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) ? 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 );
addLoader("LEXEC000", 0); // // entry to stub
addLoader("LEXEC000", NULL);
if (ft->id) { if (ft->id) {
if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate
addLoader("LXUNF000", 0);
addLoader("LXUNF002", 0);
if (0x80==(ft->id & 0xF0)) {
if (256==n_mru) {
addLoader("MRUBYTE0", 0);
}
else if (n_mru) {
addLoader("LXMRU005", 0);
}
if (n_mru) {
addLoader("LXMRU006", 0);
}
else {
addLoader("LXMRU007", 0);
}
}
else if (0x40==(ft->id & 0xF0)) {
addLoader("LXUNF008", 0);
}
addLoader("LXUNF010", 0);
}
if (n_mru) { if (n_mru) {
addLoader("LEXEC009", 0); addLoader("LEXEC009", NULL);
} }
} }
addLoader("LEXEC010", 0); addLoader("LEXEC010", NULL);
addLoader(getDecompressor(), 0); linker->defineSymbol("filter_cto", ft->cto);
addLoader("LEXEC015", 0); linker->defineSymbol("filter_length",
(ft->id & 0xf) % 3 == 0 ? ft->calls :
ft->lastcall - ft->calls * 4);
addLoader(getDecompressorSections(), 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", 0);
}
}
else { // decompr, unfilter not separate
if (0x80==(ft->id & 0xF0)) { if (0x80==(ft->id & 0xF0)) {
addLoader("LEXEC110", 0); addLoader("LEXEC110", NULL);
if (n_mru) { if (n_mru) {
addLoader("LEXEC100", 0); addLoader("LEXEC100", NULL);
} }
// bug in APP: jmp and label must be in same .asx/.asy // bug in APP: jmp and label must be in same .asx/.asy
addLoader("LEXEC016", 0); addLoader("LEXEC016", NULL);
} }
} }
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)) { addLoader("LEXEC017", NULL);
if (0==n_mru) {
addLoader("LXMRU058", 0);
}
}
addLoader("LXUNF035", 0);
}
else { // decompr always unfilters
addLoader("LEXEC017", 0);
} }
} }
else {
addLoader("IDENTSTR", 0); addLoader("LEXEC017", NULL);
addLoader("LEXEC020", 0);
addLoader("FOLDEXEC", 0);
char *ptr_cto = (char *)const_cast<unsigned char *>(getLoader());
int sz_cto = getLoaderSize();
if (0x20==(ft->id & 0xF0) || 0x30==(ft->id & 0xF0)) { // push byte '?' ; cto8
patch_le16(ptr_cto, sz_cto, "\x6a?", 0x6a + (ft->cto << 8));
checkPatch(NULL, 0, 0, 0); // reset
} }
// PackHeader and overlay_offset at the end of the output file,
// after the compressed data.
return getLoaderSize(); addLoader("IDENTSTR", NULL);
addLoader("LEXEC020", NULL);
addLoader("FOLDEXEC", NULL);
if (M_IS_LZMA(ph.method)) {
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
acc_uint32e_t properties = // lc, lp, pb, dummy
(res->lit_context_bits << 0) |
(res->lit_pos_bits << 8) |
(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);
}
if (0x80==(ft->id & 0xF0)) {
int const mru = ft->n_mru ? 1+ ft->n_mru : 0;
if (mru && mru!=256) {
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.
@@ -312,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;
@@ -347,17 +458,18 @@ int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
return -1; return -1;
// now check the ELF header // now check the ELF header
if (!memcmp(buf+8, "FreeBSD", 7)) // branded if (!memcmp(buf+8, "FreeBSD", 7)) // branded
return 1; return 1;
if (ehdr->e_type != 2) // executable if (ehdr->e_type != Elf32_Ehdr::ET_EXEC
&& ehdr->e_type != Elf32_Ehdr::ET_DYN ) // executable
return 2; return 2;
if (ehdr->e_machine != 3) // Intel 80386 if (ehdr->e_machine != Elf32_Ehdr::EM_386) // Intel 80386
return 3; return 3;
if (ehdr->e_version != 1) // version if (ehdr->e_version != Elf32_Ehdr::EV_CURRENT) // version
return 4; return 4;
if (ehdr->e_phnum < 1) if (ehdr->e_phnum < 1)
return 5; return 5;
if (ehdr->e_phentsize != sizeof(Elf_LE32_Phdr)) if (ehdr->e_phentsize != sizeof(Elf32_Phdr))
return 6; return 6;
// check for Linux kernels // check for Linux kernels
@@ -378,19 +490,6 @@ int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
} }
off_t PackLinuxI386::getbrk(const Elf_LE32_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;
}
/************************************************************************* /*************************************************************************
// //
@@ -404,6 +503,7 @@ bool PackLinuxI386::canPack()
Elf_LE32_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);
@@ -411,12 +511,58 @@ 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->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_native16(&ehdr.e_phnum);
if (e_phnum<=(512/sizeof(Elf32_Phdr))) {
char buf2[512];
fi->seek(get_native32(&ehdr.e_phoff), SEEK_SET);
fi->readx(buf2, sizeof(buf2));
fi->seek(0, SEEK_SET);
Elf32_Phdr const *phdr = (Elf32_Phdr const *)buf2;
for (unsigned j=0; j < e_phnum; ++phdr, ++j) {
if (phdr->PT_NOTE == get_native32(&phdr->p_type)) {
unsigned const offset = get_native32(&phdr->p_offset);
struct Elf32_Note note; memset(&note, 0, sizeof(note));
fi->seek(offset, SEEK_SET);
fi->readx(&note, sizeof(note));
fi->seek(0, SEEK_SET);
if (4==get_native32(&note.descsz)
&& 1==get_native32(&note.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)
{ {
@@ -425,15 +571,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) {
else if (!memcmp(buf, "#!/", 3)) // #!/bin/sh return false; // so far, only Linux has runtime stub for shell
exetype = -1; }
else if (!memcmp(buf, "#! /", 4)) // #! /bin/sh else if (!memcmp(buf, "#!/", 3)) // #!/bin/sh
exetype = -1; exetype = -1;
else if (!memcmp(buf, "\xca\xfe\xba\xbe", 4)) // Java bytecode else if (!memcmp(buf, "#! /", 4)) // #! /bin/sh
exetype = -2; exetype = -1;
#endif else if (!memcmp(buf, "\xca\xfe\xba\xbe", 4)) // Java bytecode
exetype = -2;
}
return super::canPack(); return super::canPack();
} }
@@ -444,7 +592,7 @@ 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
+55 -18
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 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
@@ -21,8 +21,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 Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/ */
@@ -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 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/386"; }
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
@@ -75,7 +80,6 @@ protected:
// ELF util // ELF util
virtual int checkEhdr(const Elf_LE32_Ehdr *ehdr) const; virtual int checkEhdr(const Elf_LE32_Ehdr *ehdr) const;
virtual off_t getbrk(const Elf_LE32_Phdr *phdr, int e_phnum) const;
enum { enum {
UPX_ELF_MAGIC = 0x5850557f // "\x7fUPX" UPX_ELF_MAGIC = 0x5850557f // "\x7fUPX"
@@ -84,31 +88,64 @@ protected:
unsigned n_mru; unsigned n_mru;
struct cprElfHdr1 { struct cprElfHdr1 {
struct Elf_LE32_Ehdr ehdr; Elf_LE32_Ehdr ehdr;
struct Elf_LE32_Phdr phdr[1]; Elf_LE32_Phdr phdr[1];
struct PackUnix::l_info linfo; l_info linfo;
} }
__attribute_packed; __attribute_packed;
struct cprElfHdr2 { struct cprElfHdr2 {
struct Elf_LE32_Ehdr ehdr; Elf_LE32_Ehdr ehdr;
struct Elf_LE32_Phdr phdr[2]; Elf_LE32_Phdr phdr[2];
struct PackUnix::l_info linfo; l_info linfo;
} }
__attribute_packed; __attribute_packed;
struct cprElfHdr3 { struct cprElfHdr3 {
struct Elf_LE32_Ehdr ehdr; Elf_LE32_Ehdr ehdr;
struct Elf_LE32_Phdr phdr[3]; Elf_LE32_Phdr phdr[3];
struct PackUnix::l_info linfo; l_info linfo;
} }
__attribute_packed; __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/386"; }
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 */
+310
View File
@@ -0,0 +1,310 @@
/* p_lx_interp.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2007 John F. Reiser
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>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#include "conf.h"
#include "file.h"
#include "filter.h"
#include "linker.h"
#include "packer.h"
#include "p_elf.h"
#include "p_unix.h"
#include "p_lx_exc.h"
#include "p_lx_elf.h"
#include "p_lx_interp.h"
#define PT_LOAD Elf32_Phdr::PT_LOAD
#define PT_INTERP Elf32_Phdr::PT_INTERP
/*************************************************************************
//
**************************************************************************/
static const
#include "stub/i386-linux.elf.interp-entry.h"
static const
#include "stub/i386-linux.elf.interp-fold.h"
PackLinuxElf32x86interp::PackLinuxElf32x86interp(InputFile *f) :
super(f)
{
}
PackLinuxElf32x86interp::~PackLinuxElf32x86interp()
{
}
bool PackLinuxElf32x86interp::canPack()
{
if (opt->o_unix.make_ptinterp) {
return true;
}
if (!opt->o_unix.use_ptinterp) {
return false;
}
return super::canPack();
}
void PackLinuxElf32x86interp::pack1(OutputFile *fo, Filter &)
{
fi->seek(0, SEEK_SET);
fi->readx(&ehdri, sizeof(ehdri));
assert(ehdri.e_phoff == sizeof(Elf32_Ehdr)); // checked by canPack()
sz_phdrs = ehdri.e_phnum * ehdri.e_phentsize;
phdri = new Elf32_Phdr[(unsigned)ehdri.e_phnum];
fi->seek(ehdri.e_phoff, SEEK_SET);
fi->readx(phdri, sz_phdrs);
#define E Elf32_Ehdr
cprElfHdr3 h3;
memset(&h3, 0, sizeof(h3));
memcpy(h3.ehdr.e_ident, "\177ELF", 4);
h3.ehdr.e_ident[E::EI_CLASS] = E::ELFCLASS32;
h3.ehdr.e_ident[E::EI_DATA] = E::ELFDATA2LSB;
h3.ehdr.e_ident[E::EI_VERSION] = E::EV_CURRENT;
h3.ehdr.e_ident[E::EI_OSABI] = E::ELFOSABI_LINUX;
h3.ehdr.e_ident[E::EI_ABIVERSION] = E::EV_CURRENT;
h3.ehdr.e_type = E::ET_EXEC;
h3.ehdr.e_machine = E::EM_386;
h3.ehdr.e_version = 1;
h3.ehdr.e_phoff = sizeof(Elf32_Ehdr);
h3.ehdr.e_ehsize = sizeof(Elf32_Ehdr);
h3.ehdr.e_phentsize = sizeof(Elf32_Phdr);
h3.ehdr.e_phnum = 3;
h3.phdr[0].p_type = PT_LOAD;
h3.phdr[0].p_flags = Elf32_Phdr::PF_X | Elf32_Phdr::PF_R;
h3.phdr[0].p_align = 0x1000;
h3.phdr[1].p_type = PT_LOAD;
h3.phdr[1].p_flags = Elf32_Phdr::PF_W | Elf32_Phdr::PF_R;
h3.phdr[1].p_align = 1;
h3.phdr[2].p_type = PT_INTERP;
h3.phdr[2].p_offset = (char *)&h3.phdr[2].p_vaddr - (char *)&h3;
memcpy(&h3.phdr[2].p_vaddr, "/upxrun", h3.phdr[2].p_filesz = 8);
h3.phdr[2].p_align = 1;
if (opt->o_unix.make_ptinterp) { // unusual "once per release"
elfout = h3;
elfout.ehdr.e_phnum = 1;
fo->write(&elfout, elfout.ehdr.e_ehsize + elfout.ehdr.e_phentsize);
}
else { // usual case
generateElfHdr(fo, &h3, getbrk(phdri, ehdri.e_phnum));
}
#undef E
}
void PackLinuxElf32x86interp::pack2(OutputFile *fo, Filter &ft)
{
if (opt->o_unix.make_ptinterp) {
return; // ignore current input file!
}
super::pack2(fo, ft);
}
#undef PAGE_MASK
#define PAGE_MASK (~0u<<12)
void PackLinuxElf32x86interp::pack3(OutputFile *fo, Filter &/*ft*/)
{
unsigned base = getbase(phdri, ehdri.e_phnum);
unsigned sz = PAGE_MASK & (~PAGE_MASK + elfout.phdr[0].p_filesz);
if (base < (0x11000 + sz)) {
base = 0x11000 + sz;
}
if (opt->o_unix.make_ptinterp) {
base = 0x10000;
}
elfout.phdr[0].p_paddr = elfout.phdr[0].p_vaddr = base - sz;
if (opt->o_unix.make_ptinterp) {
initLoader(stub_i386_linux_elf_interp_entry, sizeof(stub_i386_linux_elf_interp_entry));
linker->addSection("FOLDEXEC", stub_i386_linux_elf_interp_fold, sizeof(stub_i386_linux_elf_interp_fold), 0);
addLoader("LXPTI000", NULL);
addLoader("LXPTI040", NULL);
ph.method = M_NRV2B_LE32; addLoader(getDecompressorSections(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI041", NULL);
ph.method = M_NRV2D_LE32; addLoader(getDecompressorSections(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI042", NULL);
ph.method = M_NRV2E_LE32; addLoader(getDecompressorSections(), NULL);
addLoader("LXPTI090", NULL);
//addLoader("LXPTI043", NULL);
//ph.method = M_CL1B_LE32; addLoader(getDecompressorSections(), NULL);
//addLoader("LXPTI090", NULL);
addLoader("LXPTI091", NULL);
addLoader("LXPTI140", NULL);
addLoader("LXUNF002,LXUNF008,LXUNF010", NULL);
addFilter32(0x46);
addLoader("LXUNF042,LXUNF035", NULL);
addLoader("LXUNF002,LXUNF008,LXUNF010", NULL);
addFilter32(0x49);
addLoader("LXUNF042,LXUNF035", NULL);
addLoader("LXPTI200", NULL);
addLoader("FOLDEXEC", NULL);
upx_byte const *p = getLoader();
lsize = getLoaderSize();
updateLoader(fo);
fo->write(p, lsize);
elfout.phdr[0].p_filesz = fo->getBytesWritten();
}
else {
updateLoader(fo);
}
}
void PackLinuxElf32x86interp::unpack(OutputFile *fo)
{
#define MAX_INTERP_HDR 512
char bufehdr[MAX_INTERP_HDR];
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *)bufehdr;
Elf32_Phdr const *phdr = (Elf32_Phdr *)(1+ehdr);
unsigned szb_info = sizeof(b_info);
{
fi->seek(0, SEEK_SET);
fi->readx(bufehdr, MAX_INTERP_HDR);
unsigned const e_entry = get_native32(&ehdr->e_entry);
if (e_entry < 0x401180) { /* old style, 8-byte b_info */
szb_info = 2*sizeof(unsigned);
}
}
fi->seek(overlay_offset, SEEK_SET);
p_info hbuf;
fi->readx(&hbuf, sizeof(hbuf));
unsigned orig_file_size = get_native32(&hbuf.p_filesize);
blocksize = get_native32(&hbuf.p_blocksize);
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
throwCantUnpack("file header corrupted");
ibuf.alloc(blocksize + OVERHEAD);
b_info bhdr; memset(&bhdr, 0, sizeof(bhdr));
fi->readx(&bhdr, szb_info);
ph.u_len = get_native32(&bhdr.sz_unc);
ph.c_len = get_native32(&bhdr.sz_cpr);
ph.filter_cto = bhdr.b_cto8;
// Uncompress Ehdr and Phdrs.
fi->readx(ibuf, ph.c_len);
decompress(ibuf, (upx_byte *)ehdr, false);
unsigned total_in = 0;
unsigned total_out = 0;
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
off_t ptload0hi=0, ptload1lo=0, ptload1sz=0;
// decompress PT_LOAD
bool first_PF_X = true;
fi->seek(- (off_t) (szb_info + ph.c_len), SEEK_CUR);
for (unsigned j=0; j < ehdr->e_phnum; ++phdr, ++j) {
if (PT_LOAD==phdr->p_type) {
if (0==ptload0hi) {
ptload0hi = phdr->p_filesz + phdr->p_offset;
}
else if (0==ptload1lo) {
ptload1lo = phdr->p_offset;
ptload1sz = phdr->p_filesz;
}
if (fo)
fo->seek(phdr->p_offset, SEEK_SET);
if (Elf32_Phdr::PF_X & phdr->p_flags) {
unpackExtent(phdr->p_filesz, fo, total_in, total_out,
c_adler, u_adler, first_PF_X, szb_info);
first_PF_X = false;
}
else {
unpackExtent(phdr->p_filesz, fo, total_in, total_out,
c_adler, u_adler, false, szb_info);
}
}
}
if (0!=ptload1sz && ptload0hi < ptload1lo) { // alignment hole?
if (fo)
fo->seek(ptload0hi, SEEK_SET);
unpackExtent(ptload1lo - ptload0hi, fo, total_in, total_out,
c_adler, u_adler, false, szb_info);
}
if (total_out != orig_file_size) { // non-PT_LOAD stuff
if (fo)
fo->seek(0, SEEK_END);
unpackExtent(orig_file_size - total_out, fo, total_in, total_out,
c_adler, u_adler, false, szb_info);
}
// check for end-of-file
fi->readx(&bhdr, szb_info);
unsigned const sz_unc = ph.u_len = get_native32(&bhdr.sz_unc);
if (sz_unc == 0) { // uncompressed size 0 -> EOF
// note: magic is always stored le32
unsigned const sz_cpr = get_le32(&bhdr.sz_cpr);
if (sz_cpr != UPX_MAGIC_LE32) // sz_cpr must be h->magic
throwCompressedDataViolation();
}
else { // extra bytes after end?
throwCompressedDataViolation();
}
// update header with totals
ph.c_len = total_in;
ph.u_len = total_out;
// all bytes must be written
if (total_out != orig_file_size)
throwEOFException();
// finally test the checksums
if (ph.c_adler != c_adler || ph.u_adler != u_adler)
throwChecksumError();
#undef MAX_INTERP_HDR
}
/*
vi:ts=4:et
*/
+68
View File
@@ -0,0 +1,68 @@
/* p_lx_interp.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2007 John F. Reiser
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>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#ifndef __UPX_P_LX_INTERP_H //{
#define __UPX_P_LX_INTERP_H
/*************************************************************************
// linux/interp386
**************************************************************************/
class PackLinuxElf32x86interp : public PackLinuxElf32x86
{
typedef PackLinuxElf32x86 super;
public:
PackLinuxElf32x86interp(InputFile *f);
virtual ~PackLinuxElf32x86interp();
virtual int getVersion() const { return 13; }
virtual int getFormat() const { return UPX_F_LINUX_ELFI_i386; }
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 void unpack(OutputFile *fo);
protected:
virtual void pack1(OutputFile *, Filter &); // generate executable header
virtual void pack2(OutputFile *, Filter &); // append compressed data
virtual void pack3(OutputFile *, Filter &); // build loader
};
#endif /*} already included */
/*
vi:ts=4:et
*/
-91
View File
@@ -1,91 +0,0 @@
/* p_lx_sep.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser
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 John F. Reiser
markus@oberhumer.com ml1050@cdata.tvnet.hu jreiser@BitWagon.com
*/
#include "conf.h"
#include "file.h"
#include "packer.h"
#include "p_elf.h"
#include "p_unix.h"
#include "p_lx_exc.h"
#include "p_lx_elf.h"
#include "p_lx_sep.h"
/*************************************************************************
//
**************************************************************************/
//#define SCRIPT_SIZE (opt->unix.SCRIPT_MAX + sizeof(l_info))
#define SCRIPT_SIZE (32 + sizeof(l_info))
const upx_byte *PackLinuxI386sep::getLoader() const
{
static char script[SCRIPT_SIZE];
memset(script, 0, sizeof(script));
char const *name = opt->unix.script_name;
if (0==name) {
name = "/usr/local/lib/upxX";
}
upx_snprintf(script, sizeof(script), "#!%s\n", name);
if (M_IS_NRV2B(ph.method)) {
script[strlen(script)-2] = 'b';
return (upx_byte const *)script;
}
if (M_IS_NRV2D(ph.method)) {
script[strlen(script)-2] = 'd';
return (upx_byte const *)script;
}
return NULL;
}
int PackLinuxI386sep::getLoaderSize() const
{
if (M_IS_NRV2B(ph.method))
return SCRIPT_SIZE;
if (M_IS_NRV2D(ph.method))
return SCRIPT_SIZE;
return 0;
}
int PackLinuxI386sep::getLoaderPrefixSize() const
{
return opt->unix.SCRIPT_MAX;
}
void PackLinuxI386sep::patchLoader()
{
patchLoaderChecksum();
}
/*
vi:ts=4:et
*/
-61
View File
@@ -1,61 +0,0 @@
/* p_lx_sep.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser
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 John F. Reiser
markus@oberhumer.com ml1050@cdata.tvnet.hu jreiser@BitWagon.com
*/
#ifndef __UPX_P_LX_SEP_H //{
#define __UPX_P_LX_SEP_H
/*************************************************************************
// linux/sep386
**************************************************************************/
class PackLinuxI386sep : public PackLinuxI386elf
{
typedef PackLinuxI386elf super;
public:
PackLinuxI386sep(InputFile *f) : super(f) { }
virtual int getFormat() const { return UPX_F_LINUX_SEP_i386; }
virtual const char *getName() const { return "linux/sep386"; }
protected:
virtual const upx_byte *getLoader() const;
virtual int getLoaderSize() const;
virtual int getLoaderPrefixSize() const;
virtual void patchLoader();
virtual void updateLoader(OutputFile *) {}
};
#endif /*} already included */
/*
vi:ts=4:et
*/
+47 -18
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser Copyright (C) 2000-2007 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 <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/ */
@@ -45,9 +48,9 @@
**************************************************************************/ **************************************************************************/
static const static const
#include "stub/l_lx_sh86.h" #include "stub/i386-linux.elf.shell-entry.h"
static const static const
#include "stub/fold_sh86.h" #include "stub/i386-linux.elf.shell-fold.h"
PackLinuxI386sh::PackLinuxI386sh(InputFile *f) : PackLinuxI386sh::PackLinuxI386sh(InputFile *f) :
@@ -59,12 +62,21 @@ PackLinuxI386sh::~PackLinuxI386sh()
{ {
} }
int static unsigned
umax(unsigned a, unsigned b)
{
if (a <= b) {
return b;
}
return a;
}
void
PackLinuxI386sh::buildLoader(Filter const *ft) PackLinuxI386sh::buildLoader(Filter const *ft)
{ {
unsigned const sz_fold = sizeof(linux_i386sh_fold); unsigned const sz_fold = sizeof(stub_i386_linux_elf_shell_fold);
MemBuffer buf(sz_fold); MemBuffer buf(sz_fold);
memcpy(buf, linux_i386sh_fold, sz_fold); memcpy(buf, stub_i386_linux_elf_shell_fold, sz_fold);
checkPatch(NULL, 0, 0, 0); // reset checkPatch(NULL, 0, 0, 0); // reset
patch_le32(buf,sz_fold,"UPX3",l_shname); patch_le32(buf,sz_fold,"UPX3",l_shname);
@@ -73,16 +85,22 @@ PackLinuxI386sh::buildLoader(Filter const *ft)
// get fresh filter // get fresh filter
Filter fold_ft = *ft; Filter fold_ft = *ft;
fold_ft.init(ft->id, ft->addvalue); fold_ft.init(ft->id, ft->addvalue);
int preferred_ctos[2] = {ft->cto, -1}; int preferred_ctos[2] = { ft->cto, -1 };
fold_ft.preferred_ctos = preferred_ctos; fold_ft.preferred_ctos = preferred_ctos;
// filter // filter
optimizeFilter(&fold_ft, buf, sz_fold); optimizeFilter(&fold_ft, buf, sz_fold);
bool success = fold_ft.filter(buf + sizeof(cprElfHdr2), sz_fold - sizeof(cprElfHdr2)); unsigned fold_hdrlen = sizeof(l_info) + sizeof(Elf32_Ehdr) +
sizeof(Elf32_Phdr) * get_native32(&((Elf32_Ehdr const *)(void *)buf)->e_phnum);
if (0 == get_le32(fold_hdrlen + buf)) {
// inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
fold_hdrlen = umax(0x80, fold_hdrlen);
}
bool success = fold_ft.filter(buf + fold_hdrlen, sz_fold - fold_hdrlen);
UNUSED(success); UNUSED(success);
return buildLinuxLoader( buildLinuxLoader(
linux_i386sh_loader, sizeof(linux_i386sh_loader), stub_i386_linux_elf_shell_entry, sizeof(stub_i386_linux_elf_shell_entry),
buf, sz_fold, ft ); buf, sz_fold, ft );
} }
@@ -92,11 +110,11 @@ void PackLinuxI386sh::patchLoader() { }
bool PackLinuxI386sh::getShellName(char *buf) bool PackLinuxI386sh::getShellName(char *buf)
{ {
exetype = -1; exetype = -1;
l_shname = strcspn(buf, " \t\n\v\f\r"); l_shname = (int) strcspn(buf, " \t\n\v\f\r");
buf[l_shname] = 0; buf[l_shname] = 0;
static char const *const shname[] = { // known shells that accept "-c" arg static char const *const shname[] = { // known shells that accept "-c" arg
"ash", "bash", "bsh", "csh", "ksh", "pdksh", "sh", "tcsh", "zsh", "ash", "bash", "bsh", "csh", "ksh", "pdksh", "sh", "tcsh", "zsh",
//"python", // FIXME: does python work ??? "python",
NULL NULL
}; };
const char *bname = strrchr(buf, '/'); const char *bname = strrchr(buf, '/');
@@ -104,7 +122,11 @@ bool PackLinuxI386sh::getShellName(char *buf)
return false; return false;
for (int j = 0; NULL != shname[j]; ++j) { for (int j = 0; NULL != shname[j]; ++j) {
if (0 == strcmp(shname[j], bname + 1)) { if (0 == strcmp(shname[j], bname + 1)) {
return super::canPack(); bool const s = super::canPack();
if (s) {
opt->o_unix.blocksize = blocksize = file_size;
}
return s;
} }
} }
return false; return false;
@@ -136,7 +158,14 @@ bool PackLinuxI386sh::canPack()
void void
PackLinuxI386sh::pack1(OutputFile *fo, Filter &) PackLinuxI386sh::pack1(OutputFile *fo, Filter &)
{ {
generateElfHdr(fo, linux_i386sh_fold, 0x08048000); generateElfHdr(fo, stub_i386_linux_elf_shell_fold, 0x08048000);
}
void
PackLinuxI386sh::pack3(OutputFile *fo, Filter &ft)
{
super::pack3(fo,ft);
elfout.phdr[0].p_filesz = fo->getBytesWritten();
} }
/* /*
+11 -6
View File
@@ -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-2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2002 Laszlo Molnar Copyright (C) 1996-2007 Laszlo Molnar
Copyright (C) 2000-2002 John F. Reiser Copyright (C) 2000-2007 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 <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/ */
@@ -44,10 +47,12 @@ public:
virtual int getVersion() const { return 13; } virtual int getVersion() const { return 13; }
virtual int getFormat() const { return UPX_F_LINUX_SH_i386; } virtual int getFormat() const { return UPX_F_LINUX_SH_i386; }
virtual const char *getName() const { return "linux/sh386"; } virtual const char *getName() const { return "linux/sh386"; }
virtual const char *getFullName(const options_t *) const { return "i386-linux.elf.shell"; }
virtual const int *getFilters() const { return NULL; } virtual const int *getFilters() const { return NULL; }
virtual int buildLoader(const Filter *); virtual void buildLoader(const Filter *);
virtual void pack1(OutputFile *fo, Filter &ft); virtual void pack1(OutputFile *fo, Filter &ft);
virtual void pack3(OutputFile *fo, Filter &ft);
virtual bool canPack(); virtual bool canPack();
// virtual void unpack(OutputFile *fo) { super::unpack(fo); } // virtual void unpack(OutputFile *fo) { super::unpack(fo); }
+832
View File
@@ -0,0 +1,832 @@
/* p_mach.cpp -- pack Mach Object executable
This file is part of the UPX executable compressor.
Copyright (C) 2004-2007 John Reiser
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.
John Reiser
jreiser@users.sourceforge.net
*/
#include "conf.h"
#include "file.h"
#include "filter.h"
#include "linker.h"
#include "packer.h"
#include "p_mach.h"
#include "ui.h"
static const
#include "stub/powerpc-darwin.macho-entry.h"
static const
#include "stub/powerpc-darwin.macho-fold.h"
static const
#include "stub/i386-darwin.macho-entry.h"
static const
#include "stub/i386-darwin.macho-fold.h"
template <class T>
PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned flavor,
unsigned count, unsigned size) :
super(f), my_cputype(cputype), my_thread_flavor(flavor),
my_thread_state_word_count(count), my_thread_command_size(size),
n_segment(0), rawmseg(NULL), msegcmd(NULL)
{
MachClass::compileTimeAssertions();
bele = N_BELE_CTP::getRTP<BeLePolicy>();
}
template <class T>
PackMachBase<T>::~PackMachBase()
{
delete [] rawmseg;
delete [] msegcmd;
}
template <class T>
const int *PackMachBase<T>::getCompressionMethods(int method, int level) const
{
// There really is no LE bias.
return Packer::getDefaultCompressionMethods_le32(method, level);
}
const int *PackMachPPC32::getFilters() const
{
static const int filters[] = { 0xd0, FT_END };
return filters;
}
int const *PackMachI386::getFilters() const
{
static const int filters[] = { 0x49, FT_END };
return filters;
}
Linker *PackMachPPC32::newLinker() const
{
return new ElfLinkerPpc32;
}
Linker *PackMachI386::newLinker() const
{
return new ElfLinkerX86;
}
template <class T>
void
PackMachBase<T>::addStubEntrySections(Filter const *)
{
addLoader("MACOS000", NULL);
//addLoader(getDecompressorSections(), NULL);
addLoader(
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
: NULL), NULL);
addLoader("ELFMAINY,IDENTSTR,+40,ELFMAINZ,FOLDEXEC", NULL);
}
void PackMachI386::addStubEntrySections(Filter const *ft)
{
int const n_mru = ft->n_mru; // FIXME: belongs to filter? packerf?
// entry to stub
addLoader("LEXEC000", NULL);
if (ft->id) {
{ // 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) {
addLoader("LEXEC009", NULL);
}
}
addLoader("LEXEC010", NULL);
addLoader(getDecompressorSections(), NULL);
addLoader("LEXEC015", NULL);
if (ft->id) {
{ // decompr, unfilter are separate
if (0x80!=(ft->id & 0xF0)) {
addLoader("LXUNF042", NULL);
}
}
addFilter32(ft->id);
{ // decompr, unfilter are separate
if (0x80==(ft->id & 0xF0)) {
if (0==n_mru) {
addLoader("LXMRU058", NULL);
}
}
addLoader("LXUNF035", NULL);
}
}
else {
addLoader("LEXEC017", NULL);
}
addLoader("IDENTSTR", NULL);
addLoader("LEXEC020", NULL);
addLoader("FOLDEXEC", NULL);
}
template <class T>
void PackMachBase<T>::defineSymbols(Filter const *)
{
// empty
}
template <class T>
void
PackMachBase<T>::buildMachLoader(
upx_byte const *const proto,
unsigned const szproto,
upx_byte const *const fold,
unsigned const szfold,
Filter const *ft
)
{
initLoader(proto, szproto);
struct b_info h; memset(&h, 0, sizeof(h));
unsigned fold_hdrlen = 0;
if (0 < szfold) {
h.sz_unc = (szfold < fold_hdrlen) ? 0 : (szfold - fold_hdrlen);
h.b_method = (unsigned char) ph.method;
h.b_ftid = (unsigned char) ph.filter;
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 = 0;
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.
linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + h.sz_cpr, 0);
delete [] cprLoader;
int const GAP = 128; // must match stub/l_mac_ppc.S
segcmdo.vmsize += h.sz_unc - h.sz_cpr + GAP + 64;
addStubEntrySections(ft);
defineSymbols(ft);
relocateLoader();
}
void
PackMachPPC32::buildLoader(const Filter *ft)
{
buildMachLoader(
stub_powerpc_darwin_macho_entry, sizeof(stub_powerpc_darwin_macho_entry),
stub_powerpc_darwin_macho_fold, sizeof(stub_powerpc_darwin_macho_fold), ft );
}
void
PackMachI386::buildLoader(const Filter *ft)
{
buildMachLoader(
stub_i386_darwin_macho_entry, sizeof(stub_i386_darwin_macho_entry),
stub_i386_darwin_macho_fold, sizeof(stub_i386_darwin_macho_fold), ft );
}
template <class T>
void PackMachBase<T>::patchLoader() { }
template <class T>
void PackMachBase<T>::updateLoader(OutputFile *) {}
template <class T>
void PackMachBase<T>::patchLoaderChecksum()
{
unsigned char *const ptr = getLoader();
l_info *const lp = &linfo;
// checksum for loader; also some PackHeader info
lp->l_checksum = 0;
lp->l_magic = UPX_MAGIC_LE32; // LE32 always
lp->l_lsize = (unsigned short) lsize;
lp->l_version = (unsigned char) ph.version;
lp->l_format = (unsigned char) ph.format;
// INFO: lp->l_checksum is currently unused
lp->l_checksum = upx_adler32(ptr, lsize);
}
template <class T>
int __acc_cdecl_qsort
PackMachBase<T>::compare_segment_command(void const *const aa, void const *const bb)
{
Mach_segment_command const *const a = (Mach_segment_command const *)aa;
Mach_segment_command const *const b = (Mach_segment_command const *)bb;
unsigned const xa = a->cmd - Mach_segment_command::LC_SEGMENT;
unsigned const xb = b->cmd - Mach_segment_command::LC_SEGMENT;
if (xa < xb) return -1; // LC_SEGMENT first
if (xa > xb) return 1;
if (a->vmaddr < b->vmaddr) return -1; // ascending by .vmaddr
if (a->vmaddr > b->vmaddr) return 1;
return 0;
}
void PackMachPPC32::pack4(OutputFile *fo, Filter &ft) // append PackHeader
{
// offset of p_info in compressed file
overlay_offset = sizeof(mhdro) + sizeof(segcmdo) + sizeof(threado) + sizeof(linfo);
super::pack4(fo, ft);
segcmdo.filesize = fo->getBytesWritten();
segcmdo.vmsize += segcmdo.filesize;
fo->seek(sizeof(mhdro), SEEK_SET);
fo->rewrite(&segcmdo, sizeof(segcmdo));
fo->rewrite(&threado, sizeof(threado));
fo->rewrite(&linfo, sizeof(linfo));
}
void PackMachI386::pack4(OutputFile *fo, Filter &ft) // append PackHeader
{
// offset of p_info in compressed file
overlay_offset = sizeof(mhdro) + sizeof(segcmdo) + sizeof(threado) + sizeof(linfo);
super::pack4(fo, ft);
segcmdo.filesize = fo->getBytesWritten();
segcmdo.vmsize += segcmdo.filesize;
fo->seek(sizeof(mhdro), SEEK_SET);
fo->rewrite(&segcmdo, sizeof(segcmdo));
fo->rewrite(&threado, sizeof(threado));
fo->rewrite(&linfo, sizeof(linfo));
}
void PackMachPPC32::pack3(OutputFile *fo, Filter &ft) // append loader
{
BE32 disp;
unsigned const zero = 0;
unsigned len = fo->getBytesWritten();
fo->write(&zero, 3& (0u-len));
len += (3& (0u-len)) + sizeof(disp);
disp = 4+ len - sz_mach_headers; // 4: sizeof(instruction)
fo->write(&disp, sizeof(disp));
threado.state.srr0 = len + segcmdo.vmaddr; /* entry address */
super::pack3(fo, ft);
}
void PackMachI386::pack3(OutputFile *fo, Filter &ft) // append loader
{
LE32 disp;
unsigned const zero = 0;
unsigned len = fo->getBytesWritten();
fo->write(&zero, 3& (0u-len));
len += (3& (0u-len));
disp = len - sz_mach_headers;
fo->write(&disp, sizeof(disp));
threado.state.eip = len + sizeof(disp) + segcmdo.vmaddr; /* entry address */
super::pack3(fo, ft);
}
// Determine length of gap between PT_LOAD phdri[k] and closest PT_LOAD
// which follows in the file (or end-of-file). Optimize for common case
// where the PT_LOAD are adjacent ascending by .p_offset. Assume no overlap.
template <class T>
unsigned PackMachBase<T>::find_SEGMENT_gap(
unsigned const k
)
{
if (Mach_segment_command::LC_SEGMENT!=msegcmd[k].cmd
|| 0==msegcmd[k].filesize ) {
return 0;
}
unsigned const hi = msegcmd[k].fileoff + msegcmd[k].filesize;
unsigned lo = ph.u_file_size;
unsigned j = k;
for (;;) { // circular search, optimize for adjacent ascending
++j;
if (n_segment==j) {
j = 0;
}
if (k==j) {
break;
}
if (Mach_segment_command::LC_SEGMENT==msegcmd[j].cmd
&& 0!=msegcmd[j].filesize ) {
unsigned const t = msegcmd[j].fileoff;
if ((t - hi) < (lo - hi)) {
lo = t;
if (hi==lo) {
break;
}
}
}
}
return lo - hi;
}
template <class T>
void PackMachBase<T>::pack4(OutputFile *fo, Filter &ft)
{
PackUnix::pack4(fo, ft); // FIXME super() does not work?
}
template <class T>
void PackMachBase<T>::pack3(OutputFile *fo, Filter &ft)
{
PackUnix::pack3(fo, ft); // FIXME super() does not work?
}
template <class T>
void PackMachBase<T>::pack2(OutputFile *fo, Filter &ft) // append compressed body
{
Extent x;
unsigned k;
// count passes, set ptload vars
uip->ui_total_passes = 0;
for (k = 0; k < n_segment; ++k) {
if (Mach_segment_command::LC_SEGMENT==msegcmd[k].cmd
&& 0!=msegcmd[k].filesize ) {
uip->ui_total_passes++;
if (find_SEGMENT_gap(k)) {
uip->ui_total_passes++;
}
}
}
// compress extents
unsigned total_in = 0;
unsigned total_out = 0;
unsigned hdr_u_len = mhdri.sizeofcmds;
uip->ui_pass = 0;
ft.addvalue = 0;
// Packer::compressWithFilters chooses a filter for us, and the stubs
// can handle only one filter, and most filters are for executable
// instructions. So filter only the largest executable segment.
unsigned exe_filesize_max = 0;
for (k = 0; k < n_segment; ++k)
if (Mach_segment_command::LC_SEGMENT==msegcmd[k].cmd
&& 0!=(Mach_segment_command::VM_PROT_EXECUTE & msegcmd[k].initprot)
&& exe_filesize_max < msegcmd[k].filesize) {
exe_filesize_max = msegcmd[k].filesize;
}
int nx = 0;
for (k = 0; k < n_segment; ++k)
if (Mach_segment_command::LC_SEGMENT==msegcmd[k].cmd
&& 0!=msegcmd[k].filesize ) {
x.offset = msegcmd[k].fileoff;
x.size = msegcmd[k].filesize;
if (0 == nx) { // 1st LC_SEGMENT must cover Mach_header at 0==fileoffset
unsigned const delta = mhdri.sizeofcmds;
x.offset += delta;
x.size -= delta;
}
bool const do_filter = (msegcmd[k].filesize==exe_filesize_max)
&& 0!=(Mach_segment_command::VM_PROT_EXECUTE & msegcmd[k].initprot);
packExtent(x, total_in, total_out,
(do_filter ? &ft : 0 ), fo, hdr_u_len );
if (do_filter) {
exe_filesize_max = 0;
}
hdr_u_len = 0;
++nx;
}
for (k = 0; k < n_segment; ++k) {
x.size = find_SEGMENT_gap(k);
if (x.size) {
x.offset = msegcmd[k].fileoff +msegcmd[k].filesize;
packExtent(x, total_in, total_out, 0, fo);
}
}
if ((off_t)total_in != file_size)
throwEOFException();
segcmdo.filesize = fo->getBytesWritten();
}
#undef PAGE_MASK
#undef PAGE_SIZE
#define PAGE_MASK (~0u<<12)
#define PAGE_SIZE -PAGE_MASK
void PackMachPPC32::pack1_setup_threado(OutputFile *const fo)
{
threado.cmd = Mach_segment_command::LC_UNIXTHREAD;
threado.cmdsize = sizeof(threado);
threado.flavor = my_thread_flavor;
threado.count = my_thread_state_word_count;
memset(&threado.state, 0, sizeof(threado.state));
fo->write(&threado, sizeof(threado));
}
void PackMachI386::pack1_setup_threado(OutputFile *const fo)
{
threado.cmd = Mach_segment_command::LC_UNIXTHREAD;
threado.cmdsize = sizeof(threado);
threado.flavor = my_thread_flavor;
threado.count = my_thread_state_word_count;
memset(&threado.state, 0, sizeof(threado.state));
fo->write(&threado, sizeof(threado));
}
template <class T>
void PackMachBase<T>::pack1(OutputFile *const fo, Filter &/*ft*/) // generate executable header
{
mhdro = mhdri;
mhdro.ncmds = 2;
mhdro.sizeofcmds = sizeof(segcmdo) + my_thread_command_size;
mhdro.flags = Mach_header::MH_NOUNDEFS;
fo->write(&mhdro, sizeof(mhdro));
segcmdo.cmd = Mach_segment_command::LC_SEGMENT;
segcmdo.cmdsize = sizeof(segcmdo);
strncpy((char *)&segcmdo.segname, "__TEXT", sizeof(segcmdo.segname));
segcmdo.vmaddr = PAGE_MASK & (~PAGE_MASK +
msegcmd[n_segment -1].vmsize + msegcmd[n_segment -1].vmaddr );
segcmdo.vmsize = 0; // adjust later
segcmdo.fileoff = 0;
segcmdo.filesize = 0; // adjust later
segcmdo.initprot = segcmdo.maxprot =
Mach_segment_command::VM_PROT_READ |
Mach_segment_command::VM_PROT_WRITE |
Mach_segment_command::VM_PROT_EXECUTE;
segcmdo.nsects = 0;
segcmdo.flags = 0;
fo->write(&segcmdo, sizeof(segcmdo));
pack1_setup_threado(fo);
sz_mach_headers = fo->getBytesWritten();
memset((char *)&linfo, 0, sizeof(linfo));
fo->write(&linfo, sizeof(linfo));
return;
}
template <class T>
void PackMachBase<T>::unpack(OutputFile *fo)
{
overlay_offset = sizeof(mhdro) + sizeof(segcmdo) +
my_thread_command_size + sizeof(linfo);
fi->seek(overlay_offset, SEEK_SET);
p_info hbuf;
fi->readx(&hbuf, sizeof(hbuf));
unsigned orig_file_size = get_native32(&hbuf.p_filesize);
blocksize = get_native32(&hbuf.p_blocksize);
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
throwCantUnpack("file header corrupted");
ibuf.alloc(blocksize + OVERHEAD);
b_info bhdr; memset(&bhdr, 0, sizeof(bhdr));
fi->readx(&bhdr, sizeof(bhdr));
ph.u_len = get_native32(&bhdr.sz_unc);
ph.c_len = get_native32(&bhdr.sz_cpr);
ph.method = bhdr.b_method;
ph.filter = bhdr.b_ftid;
ph.filter_cto = bhdr.b_cto8;
// Uncompress Macho headers
fi->readx(ibuf, ph.c_len);
Mach_header *const mhdr = (Mach_header *)new upx_byte[ph.u_len];
decompress(ibuf, (upx_byte *)mhdr, false);
unsigned const ncmds = mhdr->ncmds;
msegcmd = new Mach_segment_command[ncmds];
unsigned char *ptr = (unsigned char *)(1+mhdr);
for (unsigned j= 0; j < ncmds; ++j) {
msegcmd[j] = *(Mach_segment_command *)ptr;
ptr += (unsigned) ((Mach_segment_command *)ptr)->cmdsize;
}
// Put LC_SEGMENT together at the beginning, ascending by .vmaddr.
qsort(msegcmd, ncmds, sizeof(*msegcmd), compare_segment_command);
n_segment = 0;
for (unsigned j= 0; j < ncmds; ++j) {
n_segment += (Mach_segment_command::LC_SEGMENT==msegcmd[j].cmd);
}
unsigned total_in = 0;
unsigned total_out = 0;
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
Mach_segment_command const *sc = (Mach_segment_command const *)(1+ mhdr);
unsigned k;
fi->seek(- (off_t)(sizeof(bhdr) + ph.c_len), SEEK_CUR);
for (
k = 0;
k < ncmds;
(++k), (sc = (Mach_segment_command const *)(sc->cmdsize + (char const *)sc))
) {
if (Mach_segment_command::LC_SEGMENT==sc->cmd
&& 0!=sc->filesize ) {
unsigned filesize = sc->filesize;
unpackExtent(filesize, fo, total_in, total_out, c_adler, u_adler, false, sizeof(bhdr));
}
}
for (unsigned j = 0; j < ncmds; ++j) {
unsigned const size = find_SEGMENT_gap(j);
if (size) {
unsigned const where = msegcmd[k].fileoff +msegcmd[k].filesize;
if (fo)
fo->seek(where, SEEK_SET);
unpackExtent(size, fo, total_in, total_out,
c_adler, u_adler, false, sizeof(bhdr));
}
}
}
template <class T>
bool PackMachBase<T>::canPack()
{
fi->seek(0, SEEK_SET);
fi->readx(&mhdri, sizeof(mhdri));
if (Mach_header::MH_MAGIC !=mhdri.magic
|| my_cputype !=mhdri.cputype
|| Mach_header::MH_EXECUTE !=mhdri.filetype
)
return false;
rawmseg = (Mach_segment_command *)new char[mhdri.sizeofcmds];
fi->readx(rawmseg, mhdri.sizeofcmds);
msegcmd = new Mach_segment_command[mhdri.ncmds];
unsigned char *ptr = (unsigned char *)rawmseg;
for (unsigned j= 0; j < mhdri.ncmds; ++j) {
msegcmd[j] = *(Mach_segment_command *)ptr;
ptr += (unsigned) ((Mach_segment_command *)ptr)->cmdsize;
}
// Put LC_SEGMENT together at the beginning, ascending by .vmaddr.
qsort(msegcmd, mhdri.ncmds, sizeof(*msegcmd), compare_segment_command);
// Check that LC_SEGMENTs form one contiguous chunk of the file.
for (unsigned j= 0; j < mhdri.ncmds; ++j) {
if (Mach_segment_command::LC_SEGMENT==msegcmd[j].cmd) {
if (0xfff & (msegcmd[j].fileoff | msegcmd[j].vmaddr)) {
return false;
}
if (0 < j) {
unsigned const sz = ~0xfff
& (0xfff + msegcmd[j-1].filesize);
if ((sz + msegcmd[j-1].fileoff)!=msegcmd[j].fileoff) {
return false;
}
}
++n_segment;
sz_segment = msegcmd[j].filesize + msegcmd[j].fileoff - msegcmd[0].fileoff;
}
}
// info: currently the header is 36 (32+4) bytes before EOF
unsigned char buf[256];
fi->seek(-(off_t)sizeof(buf), SEEK_END);
fi->readx(buf, sizeof(buf));
checkAlreadyPacked(buf, sizeof(buf));
// set options
opt->o_unix.blocksize = file_size;
return 0 < n_segment;
}
template class PackMachBase<MachClass_BE32>;
template class PackMachBase<MachClass_LE32>;
PackMachFat::PackMachFat(InputFile *f) : super(f)
{
bele = &N_BELE_RTP::le_policy; // sham
}
PackMachFat::~PackMachFat()
{
}
const int *PackMachFat::getCompressionMethods(int /*method*/, int /*level*/) const
{
static const int m_nrv2e[] = { M_NRV2E_LE32, M_END };
return m_nrv2e; // sham
}
const int *PackMachFat::getFilters() const
{
static const int filters[] = { 0x49, FT_END };
return filters; // sham
}
void PackMachFat::pack(OutputFile *fo)
{
unsigned const in_size = this->file_size;
fo->write(&fat_head, sizeof(fat_head.fat) +
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
unsigned length = 0;
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
unsigned base = fo->unset_extent(); // actual length
base += ~(~0u<<fat_head.arch[j].align) & (0-base); // align up
fo->seek(base, SEEK_SET);
fo->set_extent(base, ~0u);
ph.u_file_size = fat_head.arch[j].size;
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
switch (fat_head.arch[j].cputype) {
case PackMachFat::CPU_TYPE_I386: {
PackMachI386 packer(fi);
packer.initPackHeader();
packer.canPack();
packer.updatePackHeader();
packer.pack(fo);
} break;
case PackMachFat::CPU_TYPE_POWERPC: {
PackMachPPC32 packer(fi);
packer.initPackHeader();
packer.canPack();
packer.updatePackHeader();
packer.pack(fo);
} break;
} // switch cputype
fat_head.arch[j].offset = base;
length = fo->unset_extent();
fat_head.arch[j].size = length - base;
}
ph.u_file_size = in_size;
fi->set_extent(0, in_size);
fo->seek(0, SEEK_SET);
fo->rewrite(&fat_head, sizeof(fat_head.fat) +
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
fo->set_extent(0, length);
}
void PackMachFat::unpack(OutputFile *fo)
{
fo->seek(0, SEEK_SET);
fo->write(&fat_head, sizeof(fat_head.fat) +
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
unsigned length;
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
unsigned base = fo->unset_extent(); // actual length
base += ~(~0u<<fat_head.arch[j].align) & (0-base); // align up
fo->seek(base, SEEK_SET);
fo->set_extent(base, ~0u);
ph.u_file_size = fat_head.arch[j].size;
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
switch (fat_head.arch[j].cputype) {
case PackMachFat::CPU_TYPE_I386: {
PackMachI386 packer(fi);
packer.initPackHeader();
packer.canUnpack();
packer.unpack(fo);
} break;
case PackMachFat::CPU_TYPE_POWERPC: {
PackMachPPC32 packer(fi);
packer.initPackHeader();
packer.canUnpack();
packer.unpack(fo);
} break;
} // switch cputype
fat_head.arch[j].offset = base;
length = fo->unset_extent();
fat_head.arch[j].size = length - base;
}
fo->unset_extent();
fo->seek(0, SEEK_SET);
fo->rewrite(&fat_head, sizeof(fat_head.fat) +
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
}
bool PackMachFat::canPack()
{
struct Mach_fat_arch *arch = &fat_head.arch[0];
fi->readx(&fat_head, sizeof(fat_head));
if (Mach_fat_header::FAT_MAGIC!=fat_head.fat.magic
|| N_FAT_ARCH < fat_head.fat.nfat_arch) {
return false;
}
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
switch (arch[j].cputype) {
default: return false;
case PackMachFat::CPU_TYPE_I386: {
PackMachI386 packer(fi);
if (!packer.canPack())
return false;
} break;
case PackMachFat::CPU_TYPE_POWERPC: {
PackMachPPC32 packer(fi);
if (!packer.canPack())
return false;
} break;
} // switch cputype
}
// info: currently the header is 36 (32+4) bytes before EOF
unsigned char buf[256];
fi->seek(-(off_t)sizeof(buf), SEEK_END);
fi->readx(buf, sizeof(buf));
checkAlreadyPacked(buf, sizeof(buf));
return true;
}
int PackMachFat::canUnpack()
{
struct Mach_fat_arch *arch = &fat_head.arch[0];
fi->readx(&fat_head, sizeof(fat_head));
if (Mach_fat_header::FAT_MAGIC!=fat_head.fat.magic
|| N_FAT_ARCH < fat_head.fat.nfat_arch) {
return false;
}
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size);
switch (arch[j].cputype) {
default: return false;
case PackMachFat::CPU_TYPE_I386: {
PackMachI386 packer(fi);
if (!packer.canUnpack())
return 0;
ph.format = packer.getFormat(); // FIXME: copy entire PackHeader
} break;
case PackMachFat::CPU_TYPE_POWERPC: {
PackMachPPC32 packer(fi);
if (!packer.canUnpack())
return 0;
ph.format = packer.getFormat(); // FIXME: copy entire PackHeader
} break;
} // switch cputype
}
return 1;
}
void PackMachFat::buildLoader(const Filter */*ft*/)
{
assert(false);
}
Linker* PackMachFat::newLinker() const
{
return new ElfLinkerX86; // sham
}
void PackMachFat::list()
{
assert(false);
}
/*
vi:ts=4:et
*/

Some files were not shown because too many files have changed in this diff Show More