upx.doc:
NAME
upx - compress or expand executable files
SYNOPSIS
upx [ *command* ] [ *options* ] *filename*...
ABSTRACT
The Ultimate Packer for eXecutables
Copyright (c) 1996-2001 Markus Oberhumer & Laszlo
Molnar
http://wildsau.idv.uni-linz.ac.at/mfx/upx.html
http://up
0;.sourceforge.net
UPX is a portable, extendable, high-performance executable packer
for
several different executable formats. It achieves an excellent
compression ratio and offers **very** fast decompression. Your
executables suffer no memory overhead or other drawbacks for most of th
e
formats supported.
While you may use UPX freely for both non-commercial and commercial
executables (for details see the file LICENSE), we would highly
appreciate if you credit UPX and ourselves in the documentation,
possibly including a reference to the UPX home page. Thanks.
[ Using UPX in non-OpenSource applications without proper credits is
considered not politically correct ;-) ]
DISCLAIMER
UPX comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE.
Having said that, we think that UPX is quite stable now. Indeed we have
compressed lots of files without any problems. Also, the current version
has undergone several months of beta testing - actually it's almost 2
years since our first public beta.
This is the first production quality release, and we plan that future
1.xx releases will be backward compatible with this version.
Please report all problems or suggestions to the authors. Thanks.
DESCRIPTION
UPX is a versatile executable packer with the following features:
- excellent compression ratio: compresses better than zip/gzip,
use UPX to decrease the size of your distribution !
- very fast decompression: about 10 MB/sec even on my old Pentium
133
- no memory overhead for your compressed executables for most of the
supported formats
- safe: you can list, test and unpack your executables
Also, a checksum of both the compressed and uncompressed file is
maintained internally.
- universal: UPX can pack a number of executable formats:
* dos/exe
* dos/sys
* dos/com
* djgpp2/coff
* watcom/le (supporting DOS4G, PMODE/W, DOS32a and CauseWay)
* win32/pe
* rtm32/pe
* tmt/adam
* linux/386
* atari/tos
- portable: UPX is written in portable endian-neutral C++
- extendable: because of the class layout it's very easy to suppo
rt
new executable formats or add new compression algorithms
- free: UPX can be distributed and used freely. And from version 0.
7;9
the full source code of UPX is released under the GNU General Public
License (GPL) !
You probably understand now why we call UPX the "*ultimate*" ex
ecutable
packer.
COMMANDS
Compress
This is the default operation, eg. upx yourfile.exe will compress
the
file specified on the command line.
Decompress
All UPX supported file formats can be unpacked using the -d switch, eg.
upx -d yourfile.exe will uncompress the file you've just compr
essed.
Test
The -t command tests the integrity of the compressed and uncompressed
data, eg. upx -t yourfile.exe check whether your file can be safel
y
decompressed. Note, that this command doesn't check the whole file, only
the part that will be uncompressed during program execution. This means
that you should not use this command instead of a virus checker.
List
The -l command prints out some information about the compressed files
specified on the command line as parameters, eg upx -l yourfile.ex
e
shows the compressed / uncompressed size and the compression ratio of
*yourfile.exe*.
OPTIONS
-q: be quiet, suppress warnings
-q -q (or -qq): be very quiet, suppress errors
-q -q -q (or -qqq): produce no output at all
--help: prints the help
--version: print the version of UPX
[ ...to be written... - type `upx --help' for now ]
COMPRESSION LEVELS & TUNING
UPX offers ten different compression levels from -1 to -9, and --bes
t.
The default compression level is -8 for files smaller than 512 kB, and
-7 otherwise.
* Compression levels 1, 2 and 3 are pretty fast.
* Compression levels 4, 5 and 6 achieve a good time/ratio performance.
* Compression levels 7, 8 and 9 favor compression ratio over speed.
* Compression level --best may take a long time.
Note that compression level -9 can be somewhat slow for large files, but
you definitely should use it when releasing a final version of your
program.
Since UPX 0.70 there is also an extra compression level --best
which
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 even better compression:
* Try if --overlay=strip works.
* For win32/pe programs there's --strip-relocs=0. See notes below.
OVERLAY HANDLING OPTIONS
UPX handles overlays like many other executable packers do: it simply
copies the overlay after the compressed image. This works with some
files, but doesn't work with others.
Since version 0.90 UPX defaults to --overlay=copy for all ex
;ecutable
formats.
--overlay=copy Copy any extra data attached to the file. [DEFAULT]
--overlay=strip Strip any overlay from the program instead of
copying it. Be warned, this may make the compressed
program crash or otherwise unusable.
--overlay=skip Refuse to compress any program which has an overlay.
ENVIRONMENT
The environment variable UPX can hold a set of default options for UPX.
These options are interpreted first and can be overwritten by explicit
command line parameters. For example:
for DOS/Windows: set UPX=-9 --compress-icons#1
for sh/ksh/zsh: UPX="-9 --compress-icons=1"; exp
ort UPX
for csh/tcsh: setenv UPX "-9 --compress-icons=1"
Under DOS/Windows you must use '#' instead of '=' when setti
ng the
environment variable because of a COMMAND.COM limitation.
Not all of the options are valid in the environment variable - UPX will
tell you.
You can use the --no-env option to turn this support off.
NOTES FOR THE SUPPORTED EXECUTABLE FORMATS
NOTES FOR ATARI/TOS
This is the executable format used by the Atari ST/TT, a 6800
48; based
personal computer which was popular in the late '80s. See
http://www.freemint
.de for more info.
Packed programs will be byte-identical to the original after
uncompression. All debug information will be stripped, though.
Extra options available for this executable format:
(none)
NOTES FOR DOS/COM
Obviously UPX won't work with executables that want to read data fr
om
themselves (like some commandline utilities that ship with Win95/98)
.
Compressed programs only work on a 286+.
Packed programs will be byte-identical to the original after
uncompression.
Maximum uncompressed size: ~65100 bytes.
Extra options available for this executable format:
--8086 Create an executable that works on any 80
86 CPU.
NOTES FOR DOS/EXE
dos/exe stands for all "normal" 16-bit DOS executables
.
Obviously UPX won't work with executables that want to read data fr
om
themselves (like some command line utilities that ship with Win95/98
).
Compressed programs only work on a 286+.
Extra options available for this executable format:
--8086 Create an executable that works on any 80
86 CPU.
--no-reloc Use no relocation records in the exe header.
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+.
Packed programs will be byte-identical to the original after
uncompression.
Maximum uncompressed size: ~65350 bytes.
Extra options available for this executable format:
--8086 Create an executable that works on any 80
86 CPU.
NOTES FOR DJGPP2/COFF
First of all, it is recommended to use UPX *instead* of strip. strip has
the very bad habit of replacing your stub with its own (outdated)
version. Additionally UPX corrects a bug/feature in strip v2.8.x: it
will fix the 4 KByte aligment of the stub.
UPX includes the full functionality of stubify. This means it will
automatically stubify your COFF files. Use the option --coff to disable
this behaviour (see below).
UPX automatically handles Allegro packfiles.
The DLM format (a rather exotic shared library extension) is not
supported.
Packed programs will be byte-identical to the original after
uncompression. All debug information and trailing garbage will be
stripped, though.
BTW, UPX is the successor of the DJP executable packer.
Extra options available for this executable format:
--coff Produce COFF output instead of EXE. By default
UPX keeps your current stub.
NOTES FOR LINUX/386
How it works:
Because Linux is a real operating system, the in-place in-memory
decompression scheme used in the other executable formats doesn't
work here.
Instead we must use temporary decompression to disk. Interestingly -
because of the good memory management of the Linux kernel - this
often does not introduce a noticable delay, and in fact there
will be no disk access at all if you have enough free memory as
the entire process takes places within the filesystem buffers.
A compressed executable consists of the UPX stub and an overlay
which contains the original program in a compressed form.
The UPX stub is a statically linked ELF executable and does
the following at program startup:
1) decompress the overlay to a temporary location in /tmp
2) open the temporary file for reading
3) try to delete the temporary file and start (execve)
the uncompressed program in /tmp using /proc/<pid>/fd/X as
attained by step 2)
4) if that fails, fork off a subprocess to clean up and
start the program in /tmp in the meantime
The UPX stub is about 1700 bytes long, partly written in assem
bler
and only uses kernel syscalls. It is not linked against any libc.
Benefits:
- UPX can compress all executables, be it AOUT, ELF, libc4, libc5,
libc6, Shell/Perl/Python/... scripts, standalone Java .class
binaries, or whatever...
All scripts and programs will work just as before.
- Compressed programs are completely self-contained. No need for
any external program.
- UPX keeps your original program untouched. This means that
after decompression you will have a byte-identical version,
and you can use UPX as a file compressor just like gzip.
[ Note that UPX maintains a checksum of the file internally,
so it is indeed a reliable alternative. ]
- As the stub only uses syscalls and isn't linked against libc it
should run under any Linux configuration that can run ELF
binaries and has working /proc support.
- For the same reason compressed executables should run under
FreeBSD and other systems which can run Linux binaries.
[ Please send feedback on this topic ]
Drawbacks:
- You need additional free disk space for the uncompressed program
in your /tmp directory. This program is deleted immediately after
decompression, but you still need it for the full execution time
of the program.
- You must have /proc filesystem support as the stub wants to open
/proc/<pid>/exe and needs /proc/<pid>/fd/X. This al
so means that you
cannot compress programs that are used during the boot sequence
before /proc is mounted.
- `ldd' and `size' won't show anything useful because all they
see is the statically linked stub (since version 0.82 the section
headers are stripped from the UPX stub and `size' doesn't even
recognize the file format any longer - looks like a binutils bug).
- Utilities like `top' will display numerical values in the process
name field. This is because Linux computes the process name from
the first argument of the last execve syscall (which is typically
something like /proc/<pid>/fd/3).
- To reduce memory requirements during uncompression UPX splits the
original file into blocks, so the compression ratio is a little bit
worse than with the other executable formats (but still quite nice)
.
[ Advise from kernel experts which can tell me more about the
execve memory semantics is welcome. Maybe this shortcoming
could be removed. ]
- Because of temporary decompression to disk the decompression speed
is not as fast as with the other executable formats. Still, I can s
ee
no noticable delay when starting programs like my ~3 MB emacs (which
is less than 1 MB when compressed :-).
Notes:
- As UPX leaves your original program untouched it is advantageous
to strip it before compression.
- It is not advisable to compress programs which usually have many
instances running (like `make') because the common segments of
compressed programs won't be shared any longer between different
processes.
- If you compress a script you will lose platform independence -
this could be a problem if you are using NFS mounted disks.
- Compression of suid, guid and sticky-bit programs is rejected
because of possible security implications.
- For the same reason there is no sense in making any compressed
program suid.
- Obviously UPX won't work with executables that want to read dat
a
from themselves. E.g., this might be a problem for Perl scripts
which access their __DATA__ lines.
- In case of internal errors the stub will abort with exitcode 12
7.
Typical reasons for this to happen are that the program has somehow
been modified after compression, you have run out of disk space
or your /proc filesystem is not yet mounted.
Running `strace -o strace.log compressed_exe' will tell you mor
e.
Extra options available for this executable format:
(none)
NOTES FOR RTM32/PE
Same as win32/pe.
NOTES FOR TMT/ADAM
This format is used by the TMT Pascal compiler - see
http://www.tmt.com/
.
Extra options available for this executable format:
(none)
NOTES FOR WATCOM/LE
UPX has been successfully tested with the following extenders: DOS4G,
DOS4GW, PMODE/W, DOS32a, CauseWay. The WDOS/X extender is partly
supported (for details see the file bugs BUGS).
Yes, you can use your compressed executables with DOS4GW.
The LX format is not yet supported.
DLLs are not supported.
Extra options available for this executable format:
--le Produce an unbound LE output instead of
keeping the current stub.
NOTES FOR WIN32/PE
The PE support in UPX is quite stable now, but definitely there are
still some incompabilities with some files.
Because of the way UPX (and other packers for this format) works, you
can see increased memory usage of your compressed files. If you start
several instances of huge compressed programs you're wasting memory
because the common segements of the program won't get shared across the
instances. On the other hand if you're compressing only smaller
programs, or running only one instance of larger programs, then this
penalty is smaller, but it's still there.
If you're running executables from network, then compressed program
s
will load faster, and require less bandwidth during execution.
DLLs are supported.
Extra options available for this executable format:
--compress-exports=0 Don't compress the export section.
Use this if you plan to run the compressed
program under Wine.
--compress-exports=1 Compress the export section. [DEFAULT]
Compression of the export section can improve the
compression ratio quite a bit but may not work
with all programs (like winword.exe).
UPX never compresses the export section of a DLL
regardless of this option.
--compress-icons=0 Don't compress any icons.
--compress-icons=1 Compress all but the first icon.
--compress-icons=2 Compress all icons which are not in the
first icon directory. [DEFAULT]
--compress-resources=0 Don't compress any resources at all.
--force Force compression even when there is an
unexpected value in a header field.
Use with care.
--strip-relocs=0 Don't strip relocation records.
--strip-relocs=1 Strip relocation records. [DEFAULT]
This option only works on executables with base
address greater or equal to 0x4000
;00. Usually the
compressed files becomes smaller, but some files
may become larger. Note that the resulting file will
not work under Win32s.
UPX never strips relocations from a DLL
regardless of this option.
DIAGNOSTICS
Exit status is normally 0; if an error occurs, exit status is
1. If a
warning occurs, exit status is 2.
UPX's diagnostics are intended to be self-explanatory.
BUGS
Please report all bugs immediately to the authors.
AUTHORS
Markus F.X.J. Oberhumer <markus@oberhumer.com>
http://www.oberh
umer.com
Laszlo Molnar <ml1050@cdata.tvnet.hu>
COPYRIGHT
Copyright (C) 1996-2001 Markus Franz Xaver Johannes
Oberhumer
Copyright (C) 1996-2001 Laszlo Molnar
This program may be used freely, and you are welcome to redistribute it
under certain conditions.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the UPX License
Agreement for more details.
You should have received a copy of the UPX License Agreement along with
this program; see the file LICENSE. If not, visit the UPX home page.
Readme.txt:
UPX GUI 2001 by ReaL|sTy
---------------------------------------------------------
---------------------------------------------------------
ooooo ooo ooooooooo. ooooooo
`888' `8' `888 `Y88. `8888 d8'
888 8 888 .d88' Y888..8P
888 8 888ooo88P' `8888'
888 8 888 .8PY888.
`88. .8' 888 d8' `888b
`YbodP' o888o o888o o88888o
The Ultimate Packer for eXecutables
Copyright (c) 1996-2001 Markus Oberhumer & Las
zlo Molnar
http://wildsau.idv.uni-linz.ac.at/mfx/upx.html
http://up
x.sourceforge.net
WELCOME
=======
Welcome to UPX 1.0, the first production release after almost two years
of beta testing.
Please don't forget to read the new LICENSE - UPX is now distributed
under the GNU General Public License (GPL) with special exceptions
allowing the distribution of all compressed executables, including
commercial programs.
INTRODUCTION
============
UPX is an advanced executable file compressor. UPX will typically
reduce the file size of programs and DLLs by around 50%-70%, thus
reducing disk space, network load times, download times and
other distribution and storage costs.
Programs and libraries compressed by UPX are completely self-contained
and run exactly as before, with no runtime or memory penalty for most
of the supported formats.
UPX supports a number of different executable formats, including
Win95/98/ME/NT/2000 programs and DLLs, DOS programs, and Lin
ux executables.
UPX is free software distributed under the term of the GNU General
Public License. Full source code is available.
UPX may be distributed and used freely, even with commercial applications.
See the UPX License Agreement for details.
UPX is rated number one in the well known Archive Comparison Test. Visit
http://web.act.by.net/<
/a>~act/act-exepack.html
UPX aims to be Commercial Quality Freeware.
COPYRIGHT
=========
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Ober
humer
Copyright (C) 1996-2001 Laszlo Molnar
Share and enjoy,
Markus & Laszlo
Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu
upx.html:
<HTML>
<HEAD>
<TITLE>upx - compress or expand executable files</TIT
LE>
<LINK REV="made" HREF="mailto:perl@packages.debian.org">
</HEAD>
<BODY>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<!--
<UL>
<LI><A HREF="#name">NAME</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI
2;
<LI><A HREF="#abstract">ABSTRACT</A></LI
2;
<LI><A HREF="#disclaimer">DISCLAIMER</A></L
I>
<LI><A HREF="#description">DESCRIPTION</A><
/LI>
<LI><A HREF="#commands">COMMANDS</A></LI
2;
<UL>
<LI><A HREF="#compress">Compress</A></LI
62;
<LI><A HREF="#decompress">Decompress</A></
LI>
<LI><A HREF="#test">Test</A></LI>
<LI><A HREF="#list">List</A></LI>
</UL>
<LI><A HREF="#options">OPTIONS</A></LI>
<LI><A HREF="#compression levels & tuning">COMPRESSION
LEVELS & TUNING</A></LI>
<LI><A HREF="#overlay handling options">OVERLAY HANDLIN
G OPTIONS</A></LI>
<LI><A HREF="#environment">ENVIRONMENT</A><
/LI>
<LI><A HREF="#notes for the supported executable formats
34;>NOTES FOR THE SUPPORTED EXECUTABLE FORMATS</A></LI>
<UL>
<LI><A HREF="#notes for atari/tos">NOTES FOR ATARI/TOS
</A></LI>
<LI><A HREF="#notes for dos/com">NOTES FOR DOS/COM<
;/A></LI>
<LI><A HREF="#notes for dos/exe">NOTES FOR DOS/EX
E</A></LI>
<LI><A HREF="#notes for dos/sys">NOTES FOR DOS/SYS<
;/A></LI>
<LI><A HREF="#notes for djgpp2/coff">NOTES FOR DJGPP2/
COFF</A></LI>
<LI><A HREF="#notes for linux/386">NOTES FOR LINU
X/386</A></LI>
<LI><A HREF="#notes for rtm32/pe">NOTES FOR RTM32/PE
60;/A></LI>
<LI><A HREF="#notes for tmt/adam">NOTES FOR TMT/ADAM
60;/A></LI>
<LI><A HREF="#notes for watcom/le">NOTES FOR WATCOM/LE
</A></LI>
<LI><A HREF="#notes for win32/pe">NOTES FOR WIN32/PE
60;/A></LI>
</UL>
<LI><A HREF="#diagnostics">DIAGNOSTICS</A><
/LI>
<LI><A HREF="#bugs">BUGS</A></LI>
<LI><A HREF="#authors">AUTHORS</A></LI>
<LI><A HREF="#copyright">COPYRIGHT</A></LI&
#62;
</UL>
-->
<!-- INDEX END -->
<P>
<H1><A NAME="name">NAME</A></H1>
<P>upx - compress or expand executable files</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H
49;>
<P><STRONG>upx</STRONG> [ <EM>command&
#60;/EM> ] [ <EM>options</EM> ] <EM>f
ilename</EM>...</P>
<P>
<HR>
<H1><A NAME="abstract">ABSTRACT</A></H
49;>
<PRE>
The Ultimate Packer for eXecutables
Copyright (c) 1996-2001 Markus Oberhumer & Laszlo
Molnar
<A HREF="http://wildsau.idv.uni-linz.ac.at/mfx/upx.html"
>
http
://wildsau.idv.uni-linz.ac.at/mfx/upx.html</A>
<A HREF="
http
://upx.sourceforge.net">
http://upx.sourceforge.net</A></PRE>
<P><STRONG>UPX</STRONG> is a portable, extendable,
high-performance executable packer for
several different executable formats. It achieves an excellent compres
sion
ratio and offers <EM>*very*</EM> fast decompression. Your ex
;ecutables suffer
no memory overhead or other drawbacks for most of the formats supported.</P&
#62;
<P>While you may use UPX freely for both non-commercial and commercial
executables (for details see the file LICENSE), we would highly
appreciate if you credit UPX and ourselves in the documentation,
possibly including a reference to the UPX home page. Thanks.</P>
<P>[ Using UPX in non-OpenSource applications without proper credits
is considered not politically correct ;-) ]</P>
<P>
<HR>
<H1><A NAME="disclaimer">DISCLAIMER</A><
/H1>
<P>UPX comes with ABSOLUTELY NO WARRANTY; for details see the file LICEN
SE.</P>
<P>Having said that, we think that UPX is quite stable now. Indeed we
have compressed lots of files without any problems. Also, the
current version has undergone several months of beta testing -
actually it's almost 2 years since our first public beta.</P>
<P>This is the first production quality release, and we plan that future
1.xx
releases will be backward compatible with this version.</P>
<P>Please report all problems or suggestions to the authors. Thanks.<
;/P>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A>
0;/H1>
<P><STRONG>UPX</STRONG> is a versatile executable p
acker with the following features:</P>
<PRE>
- excellent compression ratio: compresses better than zip/gzip,
use UPX to decrease the size of your distribution !</PRE>
<PRE>
- very fast decompression: about 10 MB/sec even on my old Pentium 1
;33</PRE>
<PRE>
- no memory overhead for your compressed executables for most of the
supported formats</PRE>
<PRE>
- safe: you can list, test and unpack your executables
Also, a checksum of both the compressed and uncompressed file is
maintained internally.</PRE>
<PRE>
- universal: UPX can pack a number of executable formats:
* dos/exe
* dos/sys
* dos/com
* djgpp2/coff
* watcom/le (supporting DOS4G, PMODE/W, DOS32a and CauseWay)
* win32/pe
* rtm32/pe
* tmt/adam
* linux/386
* atari/tos</PRE>
<PRE>
- portable: UPX is written in portable endian-neutral C++</PRE>
<PRE>
- extendable: because of the class layout it's very easy to support
new executable formats or add new compression algorithms</PRE>
;
<PRE>
- free: UPX can be distributed and used freely. And from version 0.9
57;
the full source code of UPX is released under the GNU General Public
License (GPL) !</PRE>
<P>You probably understand now why we call UPX the ``<EM>ultimat
e</EM>''
executable packer.</P>
<P>
<HR>
<H1><A NAME="commands">COMMANDS</A></H
49;>
<P>
<H2><A NAME="compress">Compress</A></H2>
<P>This is the default operation, eg. <STRONG>upx yourfile.
exe</STRONG> will compress the file
specified on the command line.</P>
<P>
<H2><A NAME="decompress">Decompress</A></H2&
#62;
<P>All UPX supported file formats can be unpacked using the <STRONG&
#62;-d</STRONG> switch, eg.
<STRONG>upx -d yourfile.exe</STRONG> will uncompress t
he file you've just compressed.</P>
<P>
<H2><A NAME="test">Test</A></H2>
<P>The <STRONG>-t</STRONG> command tests the integrity o
f the compressed and uncompressed
data, eg. <STRONG>upx -t yourfile.exe</STRONG> check w
hether your file can be safely
decompressed. Note, that this command doesn't check the whole file, only
the part that will be uncompressed during program execution. This means
that you should not use this command instead of a virus checker.</P>
<P>
<H2><A NAME="list">List</A></H2>
<P>The <STRONG>-l</STRONG> command prints out some infor
mation about the compressed files
specified on the command line as parameters, eg <STRONG>upx -l your
file.exe</STRONG>
shows the compressed / uncompressed size and the compression ratio of
<EM>yourfile.exe</EM>.</P>
<P>
<HR>
<H1><A NAME="options">OPTIONS</A></H1
;>
<P><STRONG>-q</STRONG>: be quiet, suppress warnings<
/P>
<P><STRONG>-q -q</STRONG> (or <STRONG>-qq</S
TRONG>): be very quiet, suppress errors</P>
<P><STRONG>-q -q -q</STRONG> (or <STRONG>-qqq
0;/STRONG>): produce no output at all</P>
<P><STRONG>--help</STRONG>: prints the help</P>
<P><STRONG>--version</STRONG>: print the version of UPX&
#60;/P>
<P>[ ...to be written... - type `<STRONG>upx --help</ST
RONG>' for now ]</P>
<P>
<HR>
<H1><A NAME="compression levels & tuning">COMPRESSIO
N LEVELS & TUNING</A></H1>
<P><STRONG>UPX</STRONG> offers ten different compression
levels from <STRONG>-1</STRONG> to <STRONG>-9
60;/STRONG>,
and <STRONG>--best</STRONG>. The default compression level is &
#60;STRONG>-8</STRONG> for files
smaller than 512 kB, and <STRONG>-7</STRONG> otherwise.<
/P>
<UL>
<LI>
Compression levels 1, 2 and 3 are pretty fast.
<P></P>
<LI>
Compression levels 4, 5 and 6 achieve a good time/ratio performance.
<P></P>
<LI>
Compression levels 7, 8 and 9 favor compression ratio over speed.
<P></P>
<LI>
Compression level <STRONG>--best</STRONG> may take a long time.
<P></P></UL>
<P>Note that compression level <STRONG>-9</STRONG> c
an be somewhat slow for large
files, but you definitely should use it when releasing a final version
of your program.</P>
<P>Since UPX 0.70 there is also an extra compression level
<STRONG>--best</STRONG> which
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.</P>
<P>Tips for even better compression:</P>
<UL>
<LI>
Try if <STRONG>--overlay=strip</STRONG> works.
<P></P>
<LI>
For win32/pe programs there's <STRONG>--strip-relocs=0</STRO
NG>. See notes below.
<P></P></UL>
<P>
<HR>
<H1><A NAME="overlay handling options">OVERLAY HANDL
ING OPTIONS</A></H1>
<P><STRONG>UPX</STRONG> handles overlays like many other
executable packers do: it simply
copies the overlay after the compressed image. This works with some
files, but doesn't work with others.</P>
<P>Since version 0.90 UPX defaults to <STRONG>--over
lay=copy</STRONG> for
all executable formats.</P>
<PRE>
--overlay=copy Copy any extra data attached to the file. [DEFAULT]<
;/PRE>
<PRE>
--overlay=strip Strip any overlay from the program instead of
copying it. Be warned, this may make the compressed
program crash or otherwise unusable.</PRE>
<PRE>
--overlay=skip Refuse to compress any program which has an overlay.</PR
E>
<P>
<HR>
<H1><A NAME="environment">ENVIRONMENT</A>
0;/H1>
<P>The environment variable <STRONG>UPX</STRONG> can hol
d a set of default
options for UPX. These options are interpreted first and
can be overwritten by explicit command line parameters.
For example:</P>
<PRE>
for DOS/Windows: set UPX=-9 --compress-icons#1
for sh/ksh/zsh: UPX="-9 --compress-icons=1"; expor
t UPX
for csh/tcsh: setenv UPX "-9 --compress-icons=1"<
/PRE>
<P>Under DOS/Windows you must use '#' instead of '=' whe
n setting the
environment variable because of a COMMAND.COM limitation.</P>
<P>Not all of the options are valid in the environment variable -
UPX will tell you.</P>
<P>You can use the <STRONG>--no-env</STRONG> option to t
urn this support off.</P>
<P>
<HR>
<H1><A NAME="notes for the supported executable formats
">NOTES FOR THE SUPPORTED EXECUTABLE FORMATS</A></H1>
;
<P>
<H2><A NAME="notes for atari/tos">NOTES FOR ATARI/TOS
0;/A></H2>
<P>This is the executable format used by the Atari ST/TT, a 680
00 based
personal computer which was popular in the late '80s.
See <A HREF="
ht
tp://www.freemint.de">
http://www.freemint.de</A> for more info.</P>
<P>Packed programs will be byte-identical to the original after uncompre
ssion.
All debug information will be stripped, though.</P>
<P>Extra options available for this executable format:</P&
#62;
<PRE>
(none)</PRE>
<P>
<H2><A NAME="notes for dos/com">NOTES FOR DOS/COM</A
></H2>
<P>Obviously UPX won't work with executables that want to read
data from
themselves (like some commandline utilities that ship with Win95/98).
0;/P>
<P>Compressed programs only work on a 286+.</P>
<P>Packed programs will be byte-identical to the original after uncompre
ssion.</P>
<P>Maximum uncompressed size: ~65100 bytes.</P>
<P>Extra options available for this executable format:</P&
#62;
<PRE>
--8086 Create an executable that works on any 8086 C
PU.</PRE>
<P>
<H2><A NAME="notes for dos/exe">NOTES FOR DOS/EXE
60;/A></H2>
<P>dos/exe stands for all ``normal'' 16-bit DOS ex
ecutables.</P>
<P>Obviously UPX won't work with executables that want to read
data from
themselves (like some command line utilities that ship with Win95/98).
60;/P>
<P>Compressed programs only work on a 286+.</P>
<P>Extra options available for this executable format:</P&
#62;
<PRE>
--8086 Create an executable that works on any 8086 C
PU.</PRE>
<PRE>
--no-reloc Use no relocation records in the exe header.</PRE
>
<P>
<H2><A NAME="notes for dos/sys">NOTES FOR DOS/SYS</A
></H2>
<P>You can only compress plain sys files, sys/exe (two in one)
combos are not supported.</P>
<P>Compressed programs only work on a 286+.</P>
<P>Packed programs will be byte-identical to the original after uncompre
ssion.</P>
<P>Maximum uncompressed size: ~65350 bytes.</P>
<P>Extra options available for this executable format:</P&
#62;
<PRE>
--8086 Create an executable that works on any 8086 C
PU.</PRE>
<P>
<H2><A NAME="notes for djgpp2/coff">NOTES FOR DJGPP2/COF
F</A></H2>
<P>First of all, it is recommended to use UPX *instead* of <STRONG
62;strip</STRONG>. strip has
the very bad habit of replacing your stub with its own (outdated) version.
Additionally UPX corrects a bug/feature in strip v2.8.x: it
will fix the 4 KByte aligment of the stub.</P>
<P>UPX includes the full functionality of stubify. This means it will
automatically stubify your COFF files. Use the option <STRONG>--coff<
;/STRONG> to
disable this behaviour (see below).</P>
<P>UPX automatically handles Allegro packfiles.</P>
<P>The DLM format (a rather exotic shared library extension) i
s not supported.</P>
<P>Packed programs will be byte-identical to the original after uncompre
ssion.
All debug information and trailing garbage will be stripped, though.</P>
<P>BTW, UPX is the successor of the DJP executable packer.</P
62;
<P>Extra options available for this executable format:</P&
#62;
<PRE>
--coff Produce COFF output instead of EXE. By default
UPX keeps your current stub.</PRE>
<P>
<H2><A NAME="notes for linux/386">NOTES FOR LINUX/3
86</A></H2>
<P>How it works:</P>
<PRE>
Because Linux is a real operating system, the in-place in-memory
decompression scheme used in the other executable formats doesn't
work here.</PRE>
<PRE>
Instead we must use temporary decompression to disk. Interestingly -
because of the good memory management of the Linux kernel - this
often does not introduce a noticable delay, and in fact there
will be no disk access at all if you have enough free memory as
the entire process takes places within the filesystem buffers.</PRE>
<PRE>
A compressed executable consists of the UPX stub and an overlay
which contains the original program in a compressed form.</PRE>
<PRE>
The UPX stub is a statically linked ELF executable and does
the following at program startup:</PRE>
<PRE>
1) decompress the overlay to a temporary location in /tmp
2) open the temporary file for reading
3) try to delete the temporary file and start (execve)
the uncompressed program in /tmp using /proc/<pid>/fd/X as
attained by step 2)
4) if that fails, fork off a subprocess to clean up and
start the program in /tmp in the meantime</PRE>
<PRE>
The UPX stub is about 1700 bytes long, partly written in assembler
and only uses kernel syscalls. It is not linked against any libc.</PRE>
;
<P>Benefits:</P>
<PRE>
- UPX can compress all executables, be it AOUT, ELF, libc4, libc5,
libc6, Shell/Perl/Python/... scripts, standalone Java .class
binaries, or whatever...
All scripts and programs will work just as before.</PRE>
<PRE>
- Compressed programs are completely self-contained. No need for
any external program.</PRE>
<PRE>
- UPX keeps your original program untouched. This means that
after decompression you will have a byte-identical version,
and you can use UPX as a file compressor just like gzip.
[ Note that UPX maintains a checksum of the file internally,
so it is indeed a reliable alternative. ]</PRE>
<PRE>
- As the stub only uses syscalls and isn't linked against libc it
should run under any Linux configuration that can run ELF
binaries and has working /proc support.</PRE>
<PRE>
- For the same reason compressed executables should run under
FreeBSD and other systems which can run Linux binaries.
[ Please send feedback on this topic ]</PRE>
<P>Drawbacks:</P>
<PRE>
- You need additional free disk space for the uncompressed program
in your /tmp directory. This program is deleted immediately after
decompression, but you still need it for the full execution time
of the program.</PRE>
<PRE>
- You must have /proc filesystem support as the stub wants to open
/proc/<pid>/exe and needs /proc/<pid>/fd/X. This also means
that you
cannot compress programs that are used during the boot sequence
before /proc is mounted.</PRE>
<PRE>
- `ldd' and `size' won't show anything useful because all they
see is the statically linked stub (since version 0.82 the section
headers are stripped from the UPX stub and `size' doesn't even
recognize the file format any longer - looks like a binutils bug).</PRE&
#62;
<PRE>
- Utilities like `top' will display numerical values in the process
name field. This is because Linux computes the process name from
the first argument of the last execve syscall (which is typically
something like /proc/<pid>/fd/3).</PRE>
<PRE>
- To reduce memory requirements during uncompression UPX splits the
original file into blocks, so the compression ratio is a little bit
worse than with the other executable formats (but still quite nice).
[ Advise from kernel experts which can tell me more about the
execve memory semantics is welcome. Maybe this shortcoming
could be removed. ]</PRE>
<PRE>
- Because of temporary decompression to disk the decompression speed
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
is less than 1 MB when compressed :-).</PRE>
<P>Notes:</P>
<PRE>
- As UPX leaves your original program untouched it is advantageous
to strip it before compression.</PRE>
<PRE>
- It is not advisable to compress programs which usually have many
instances running (like `make') because the common segments of
compressed programs won't be shared any longer between different
processes.</PRE>
<PRE>
- If you compress a script you will lose platform independence -
this could be a problem if you are using NFS mounted disks.</PRE>
<PRE>
- Compression of suid, guid and sticky-bit programs is rejected
because of possible security implications.</PRE>
<PRE>
- For the same reason there is no sense in making any compressed
program suid.</PRE>
<PRE>
- Obviously UPX won't work with executables that want to read data
from themselves. E.g., this might be a problem for Perl scripts
which access their __DATA__ lines.</PRE>
<PRE>
- In case of internal errors the stub will abort with exitcode 127.
Typical reasons for this to happen are that the program has somehow
been modified after compression, you have run out of disk space
or your /proc filesystem is not yet mounted.
Running `strace -o strace.log compressed_exe' will tell you more.
60;/PRE>
<P>Extra options available for this executable format:</P&
#62;
<PRE>
(none)</PRE>
<P>
<H2><A NAME="notes for rtm32/pe">NOTES FOR RTM32/PE<
/A></H2>
<P>Same as win32/pe.</P>
<P>
<H2><A NAME="notes for tmt/adam">NOTES FOR TMT/ADAM<
/A></H2>
<P>This format is used by the TMT Pascal compiler - see <A HREF="
;
http://www.tmt.com/
34;>
http://www.tmt.com
/</A> .</P>
<P>Extra options available for this executable format:</P&
#62;
<PRE>
(none)</PRE>
<P>
<H2><A NAME="notes for watcom/le">NOTES FOR WATCOM/LE
0;/A></H2>
<P>UPX has been successfully tested with the following extenders:
DOS4G, DOS4GW, PMODE/W, DOS32a, CauseWay.
The WDOS/X extender is partly supported (for details
see the file bugs BUGS).</P>
<P>Yes, you can use your compressed executables with DOS4GW.</P
>
<P>The LX format is not yet supported.</P>
<P>DLLs are not supported.</P>
<P>Extra options available for this executable format:</P&
#62;
<PRE>
--le Produce an unbound LE output instead of
keeping the current stub.</PRE>
<P>
<H2><A NAME="notes for win32/pe">NOTES FOR WIN32/PE<
/A></H2>
<P>The PE support in UPX is quite stable now, but definitely there are
still some incompabilities with some files.</P>
<P>Because of the way UPX (and other packers for this format) works, you
can see increased memory usage of your compressed files. If you start
several instances of huge compressed programs you're wasting memory
because the common segements of the program won't get shared
across the instances.
On the other hand if you're compressing only smaller programs, or
running only one instance of larger programs, then this penalty is
smaller, but it's still there.</P>
<P>If you're running executables from network, then compressed
programs
will load faster, and require less bandwidth during execution.</P>
<P>DLLs are supported.</P>
<P>Extra options available for this executable format:</P&
#62;
<PRE>
--compress-exports=0 Don't compress the export section.
Use this if you plan to run the compressed
program under Wine.
--compress-exports=1 Compress the export section. [DEFAULT]
Compression of the export section can improve the
compression ratio quite a bit but may not work
with all programs (like winword.exe).
UPX never compresses the export section of a DLL
regardless of this option.</PRE>
<PRE>
--compress-icons=0 Don't compress any icons.
--compress-icons=1 Compress all but the first icon.
--compress-icons=2 Compress all icons which are not in the
first icon directory. [DEFAULT]</PRE>
<PRE>
--compress-resources=0 Don't compress any resources at all.</PRE&
#62;
<PRE>
--force Force compression even when there is an
unexpected value in a header field.
Use with care.</PRE>
<PRE>
--strip-relocs=0 Don't strip relocation records.
--strip-relocs=1 Strip relocation records. [DEFAULT]
This option only works on executables with base
address greater or equal to 0x4000
8;0. Usually the
compressed files becomes smaller, but some files
may become larger. Note that the resulting file will
not work under Win32s.
UPX never strips relocations from a DLL
regardless of this option.</PRE>
<P>
<HR>
<H1><A NAME="diagnostics">DIAGNOSTICS</A>
0;/H1>
<P>Exit status is normally 0; if an error occurs, exit sta
tus
is 1. If a warning occurs, exit status is 2.</P>
<P><STRONG>UPX</STRONG>'s diagnostics are intended t
o be self-explanatory.</P>
<P>
<HR>
<H1><A NAME="bugs">BUGS</A></H1>
<P>Please report all bugs immediately to the authors.</P>
<P>
<HR>
<H1><A NAME="authors">AUTHORS</A></H1
;>
<PRE>
Markus F.X.J. Oberhumer <markus@oberhumer.com>
<A HREF="
htt
p://www.oberhumer.com">
http://www.oberhumer.com</A></PRE>
<PRE>
Laszlo Molnar <ml1050@cdata.tvnet.hu></PRE>
<P>
<HR>
<H1><A NAME="copyright">COPYRIGHT</A></H
1>
<P>Copyright (C) 1996-2001 Markus Franz Xaver Jo
hannes Oberhumer</P>
<P>Copyright (C) 1996-2001 Laszlo Molnar</P&
#62;
<P>This program may be used freely, and you are welcome to
redistribute it under certain conditions.</P>
<P>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
UPX License Agreement for more details.</P>
<P>You should have received a copy of the UPX License Agreement along
with this program; see the file LICENSE. If not, visit the UPX home page.</P
>
</BODY>
</HTML>