How to use upx

How to use upx

Compressing native executables with UPX

By Clement Escoffier

UPX is is an open-source, portable, high-performance executable packer initially created in 1996. It takes an executable as input and produces a compressed executable. Readers from a certain age may have already used UPX a long time ago when programs needed to be compressed to fit on a floppy disk. More than 20 years later, UPX is still rocking.

In Quarkus 2.6, we integrated UPX compression in the Quarkus build. So, Quarkus can automatically produce a compressed executable. This post explains how you can use this new feature. But, before going further, you need to understand that nothing comes for free. The compressed executable is smaller on disk, but its memory usage is higher. So make sure to read the «big warning» section before using it.

Getting you ready

Quarkus can compress your executable if you have installed UPX on your system or use an in-container build.

UPX is available on most operating systems. So, you should be able to download it from their release page. UPX is cross-platform. So you can compress a Linux 64 bits executable even from a macOS or Windows machine.

In this post, we will use the first approach. The Building a Native Executable page explains how to use in-container build.

Let’s get something to compress

First, we need an application. To keep things simple, let’s create a new application from https://code.quarkus.io/?a=upx-compression-demo&e=resteasy-reactive-jacksoncode.quarkus.io. This application uses RESTEasy Reactive and its Jackson support, but the compression works with any project, and we won’t even look at the code.

Before using UPX, we need to measure the disk space and memory usage of the non-compressed native executable. To do that, we need the native executable:

The resulting executable use

46 MB of disk space:

Now, let’s have a look at the memory consumption. Start the application using:

In another terminal, invoke the application using curl and gets its memory usage:

So, it takes 21 MB of RSS, basically the amount of RAM it uses.

Configuring the compression

To compress your executable, you need to configure the compression level. The compression goes from 1 to 10:

1 : faster compression

9 : better compression

10 : best compression (can be slow for big files)

Configure the level from the application.properties file:

That’s all you need to do to enable the compression.

Building the compressed native executable

Let’s regenerate the native executable. This time, because of the configured compression level, Quarkus will compress it:

As you can see, this time, it runs UPX to compress the native executable. If you check the size, you should get something around 15 MB:

So we went from 46 M to 15 M; this is a considerable gain, even if it still does not fit on a floppy disk.

The BIG warning

However, as said in the introduction, nothing comes for free. Earlier, we also measured the memory usage of the uncompressed executable (21 MB). Let’s compare with the compressed executable.

Run the application with:

And, in another terminal, run:

57 MB! So, it uses

2.7 times more RSS than the uncompressed executable. This overhead is because the compressed executable must unpack the program on startup and store it in memory. It can also increase the startup time, but this startup overhead is insignificant most of the time.

Summary

UPX lets you compress your native executables. In Quarkus 2.6, you only need to configure the compression level, and voilà, it compresses it for you.

However, do not think it all comes for free. While the gain on disk space is fantastic, do not ignore the RSS overhead.

UPX compression can benefit CLI tools or environments where disk space is a constrained resource. For long-running applications or microservices, the RSS overhead reduces the deployment density. So, if the storage is not a problem or if the density of deployment is crucial for you, better not compress your executable.

Synopsis

Abstract

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

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: You probably understand now why we call UPX the «ultimate» executable packer.

Commands

Compress This is the default operation, eg. upx yourfile.exe will compress the file specified on the command line.

Options

-q: be quiet, suppress warnings

—help: prints the help

COMPRESSION LEVELS & TUNING

UPX offers ten different compression levels from -1 to -9, and —best. The default compression level is -8 for files smaller than 512 KiB, and -7 otherwise. • Compression levels 1, 2 and 3 are pretty fast.

• Compression levels 4, 5 and 6 achieve a good time/ratio performance.

• Compression levels 7, 8 and 9 favor compression ratio over speed.

• Compression level —best may take a long time. Note that compression level —best can be somewhat slow for large files, but you definitely should use it when releasing a final version of your program.

• Try if —overlay=strip works.

• For win32/pe programs there’s —strip-relocs=0. See notes below.

Overlay Handling Options

Info: An «overlay» means auxiliary data attached after the logical end of an executable, and it often contains application specific data (this is a common practice to avoid an extra data file, though it would be better to use resource sections).

UPX handles overlays like many other executable packers do: it simply copies the overlay after the compressed image. This works with some files, but doesn’t work with others, depending on how an application actually accesses this overlayed data.

Environment

You can explicitly use the —no-env option to ignore the environment variable.

Notes For The Supported Executable Formats

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:

NOTES FOR BVMLINUZ/I386 Same as vmlinuz/i386.

NOTES FOR DOS/COM Obviously UPX won’t work with executables that want to read data from themselves (like some commandline utilities that ship with Win95/98/ME).

Compressed programs only work on a 286+.

Packed programs will be byte-identical to the original after uncompression.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR DOS/EXE dos/exe stands for all «normal» 16-bit DOS executables.

Obviously UPX won’t work with executables that want to read data from themselves (like some command line utilities that ship with Win95/98/ME).

Compressed programs only work on a 286+.

Extra options available for this executable format:

NOTES FOR DOS/SYS Compressed programs only work on a 286+.

Packed programs will be byte-identical to the original after uncompression.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR DJGPP2/COFF First of all, it is recommended to use UPX *instead* of strip. strip has the very bad habit of replacing your stub with its own (outdated) version. Additionally UPX corrects a bug/feature in strip v2.8.x: it will fix the 4 KiB alignment of the stub.

UPX includes the full functionality of stubify. This means it will automatically stubify your COFF files. Use the option —coff to disable this functionality (see below).

UPX automatically handles Allegro packfiles.

The DLM format (a rather exotic shared library extension) is not supported.

Packed programs will be byte-identical to the original after uncompression. All debug information and trailing garbage will be stripped, though.

Extra options available for this executable format:

NOTES FOR LINUX [general] Introduction General user’s overview General benefits: General drawbacks: General notes:

NOTES FOR LINUX/ELF386 Please read the general Linux description first.

Linux/elf386 is automatically selected for Linux ELF executables.

Packed programs will be byte-identical to the original after uncompression.

How it works: Specific drawbacks: Extra options available for this executable format:

NOTES FOR LINUX/SH386 Please read the general Linux description first.

Shell scripts where the underling shell accepts a »-c» argument can use the Linux/sh386 format. UPX decompresses the shell script into low memory, then maps the shell and passes the entire text of the script as an argument with a leading »-c». It does not use space in /tmp, and does not use /proc.

Linux/sh386 is automatically selected for shell scripts that use a known shell.

Packed programs will be byte-identical to the original after uncompression.

How it works: Specific drawbacks: Extra options available for this executable format:

NOTES FOR LINUX/386 Please read the general Linux description first.

The generic linux/386 format decompresses to /tmp and needs /proc file system support. It starts the decompressed program via the execve() syscall.

Linux/386 is only selected if the specialized linux/elf386 and linux/sh386 won’t recognize a file.

Packed programs will be byte-identical to the original after uncompression.

How it works: Specific drawbacks: Extra options available for this executable format:

NOTES FOR PS1/EXE This is the executable format used by the Sony PlayStation (PSone), a Mips R3000 based gaming console which is popular since the late ’90s. Support of this format is very similar to the Atari one, because of nostalgic feelings of one of the authors.

Packed programs will be byte-identical to the original after uncompression, until further notice.

Maximum uncompressed size:

Notes: Extra options available for this executable format:

NOTES FOR RTM32/PE and ARM/PE Same as win32/pe.

Extra options available for this executable format:

NOTES FOR VMLINUZ/386 The vmlinuz/386 and bvmlinuz/386 formats take a gzip-compressed bootable Linux kernel image («vmlinuz», «zImage», «bzImage»), gzip-decompress it and re-compress it with the UPX compression method.

vmlinuz/386 is completely unrelated to the other Linux executable formats, and it does not share any of their drawbacks.

Notes: Benefits: Drawbacks: Extra options available for this executable format:

DLLs and the LX format are not supported.

Extra options available for this executable format:

NOTES FOR WIN32/PE The PE support in UPX is quite stable now, but probably there are still some incompatibilities with some files.

Because of the way UPX (and other packers for this format) works, you can see increased memory usage of your compressed files because the whole program is loaded into memory at startup. If you start several instances of huge compressed programs you’re wasting memory because the common segments of the program won’t get shared across the instances. On the other hand if you’re compressing only smaller programs, or running only one instance of larger programs, then this penalty is smaller, but it’s still there.

If you’re running executables from network, then compressed programs will load faster, and require less bandwidth during execution.

DLLs are supported. But UPX compressed DLLs can not share common data and code when they got used by multiple applications. So compressing msvcrt.dll is a waste of memory, but compressing the dll plugins of a particular application may be a better idea.

Screensavers are supported, with the restriction that the filename must end with «.scr» (as screensavers are handled slightly different than normal exe files).

Extra options available for this executable format:

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.

Please report all bugs immediately to the authors.

Authors

Copyright

Copyright В© 1996-2010 Markus Franz Xaver Johannes Oberhumer

Copyright В© 1996-2010 Laszlo Molnar

Copyright В© 2000-2010 John F. Reiser

Copyright В© 2002-2010 Jens Medoch

This program may be used freely, and you are welcome to redistribute it under certain conditions.

How to use upx

UPX is a portable, extendable, high-performance executable packer for several different executable formats. It achieves an excellent compression ratio and offers *very* fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported, because of in-place decompression.

While you may use UPX freely for both non-commercial and commercial executables (for details see the file /usr/share/doc/upx-ucl/copyright), 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

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

You probably understand now why we call UPX the «ultimate» executable packer.

COMMANDS

Compress

Decompress

OPTIONS

—help: prints the help

—version: print the version of UPX

COMPRESSION LEVELS & TUNING

Note that compression level —best can be somewhat slow for large files, but you definitely should use it when releasing a final version of your program.

Quick info for achieving the best compression ratio:

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, depending on how an application actually accesses this overlayed data.

ENVIRONMENT

Under DOS/Windows you must use ‘#’ instead of ‘=’ when setting the environment variable because of a COMMAND.COM limitation.

You can explicitly use the —no-env option to ignore the environment variable.

NOTES FOR THE SUPPORTED EXECUTABLE FORMATS

NOTES FOR ATARI/TOS

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:

NOTES FOR BVMLINUZ/I386

NOTES FOR DOS/COM

Compressed programs only work on a 286+.

Packed programs will be byte-identical to the original after uncompression.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR DOS/EXE

Obviously UPX won’t work with executables that want to read data from themselves (like some command line utilities that ship with Win95/98/ME).

Compressed programs only work on a 286+.

Extra options available for this executable format:

NOTES FOR DOS/SYS

Packed programs will be byte-identical to the original after uncompression.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR DJGPP2/COFF

UPX includes the full functionality of stubify. This means it will automatically stubify your COFF files. Use the option —coff to disable this functionality (see below).

UPX automatically handles Allegro packfiles.

The DLM format (a rather exotic shared library extension) is not supported.

Packed programs will be byte-identical to the original after uncompression. All debug information and trailing garbage will be stripped, though.

Extra options available for this executable format:

NOTES FOR LINUX [general]

General user’s overview

NOTES FOR LINUX/ELF386

The linux/elf386 format decompresses directly into RAM, uses only one exec, does not use space in /tmp, and does not use /proc.

Linux/elf386 is automatically selected for Linux ELF executables.

Packed programs will be byte-identical to the original after uncompression.

Extra options available for this executable format:

NOTES FOR LINUX/SH386

Shell scripts where the underling shell accepts a «-c» argument can use the Linux/sh386 format. UPX decompresses the shell script into low memory, then maps the shell and passes the entire text of the script as an argument with a leading «-c». It does not use space in /tmp, and does not use /proc.

Linux/sh386 is automatically selected for shell scripts that use a known shell.

Packed programs will be byte-identical to the original after uncompression.

Extra options available for this executable format:

NOTES FOR LINUX/386

The generic linux/386 format decompresses to /tmp and needs /proc file system support. It starts the decompressed program via the execve() syscall.

Linux/386 is only selected if the specialized linux/elf386 and linux/sh386 won’t recognize a file.

Packed programs will be byte-identical to the original after uncompression.

Extra options available for this executable format:

NOTES FOR PS1/EXE

Packed programs will be byte-identical to the original after uncompression, until further notice.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR RTM32/PE and ARM/PE

NOTES FOR TMT/ADAM

Extra options available for this executable format:

NOTES FOR VMLINUZ/386

vmlinuz/386 is completely unrelated to the other Linux executable formats, and it does not share any of their drawbacks.

Extra options available for this executable format:

NOTES FOR WATCOM/LE

DLLs and the LX format are not supported.

Extra options available for this executable format:

NOTES FOR WIN32/PE

Because of the way UPX (and other packers for this format) works, you can see increased memory usage of your compressed files because the whole program is loaded into memory at startup. If you start several instances of huge compressed programs you’re wasting memory because the common segments of the program won’t get shared across the instances. On the other hand if you’re compressing only smaller programs, or running only one instance of larger programs, then this penalty is smaller, but it’s still there.

If you’re running executables from network, then compressed programs will load faster, and require less bandwidth during execution.

DLLs are supported. But UPX compressed DLLs can not share common data and code when they got used by multiple applications. So compressing msvcrt.dll is a waste of memory, but compressing the dll plugins of a particular application may be a better idea.

Screensavers are supported, with the restriction that the filename must end with «.scr» (as screensavers are handled slightly different than normal exe files).

Extra options available for this executable format:

DIAGNOSTICS

UPX ‘s diagnostics are intended to be self-explanatory.

compress or expand executable files

Examples (TL;DR)

Synopsis

upx [ command ] [ options ] filename.

Abstract

UPX is a portable, extendable, high-performance executable packer for several different executable formats. It achieves an excellent compression ratio and offers *very* fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported, because of in-place decompression.

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.

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:

You probably understand now why we call UPX the «ultimate» executable packer.

Commands

Compress

This is the default operation, eg. upx yourfile.exe will compress the file specified on the command line.

Decompress

Options

Compression Levels & Tuning

UPX offers ten different compression levels from -1 to -9, and —best. The default compression level is -8 for files smaller than 512 KiB, and -7 otherwise.

Note that compression level —best can be somewhat slow for large files, but you definitely should use it when releasing a final version of your program.

Quick info for achieving the best compression ratio:

Overlay Handling Options

Info: An “overlay” means auxiliary data attached after the logical end of an executable, and it often contains application specific data (this is a common practice to avoid an extra data file, though it would be better to use resource sections).

UPX handles overlays like many other executable packers do: it simply copies the overlay after the compressed image. This works with some files, but doesn’t work with others, depending on how an application actually accesses this overlayed data.

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:

Under DOS/Windows you must use ‘#’ instead of ‘=’ when setting the environment variable because of a COMMAND.COM limitation.

You can explicitly use the —no-env option to ignore the environment variable.

Notes for the Supported Executable Formats

Notes for Atari/TOS

This is the executable format used by the Atari ST/TT, a Motorola 68000 based personal computer which was popular in the late ’80s. Support of this format is only because of nostalgic feelings of one of the authors and serves no practical purpose :-). See 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:

Notes for Bvmlinuz/I386

Same as vmlinuz/i386.

Notes for Dos/Com

Obviously UPX won’t work with executables that want to read data from themselves (like some commandline utilities that ship with Win95/98/ME).

Compressed programs only work on a 286+.

Packed programs will be byte-identical to the original after uncompression.

Maximum uncompressed size:

Extra options available for this executable format:

Notes for Dos/Exe

dos/exe stands for all “normal” 16-bit DOS executables.

Obviously UPX won’t work with executables that want to read data from themselves (like some command line utilities that ship with Win95/98/ME).

Compressed programs only work on a 286+.

Extra options available for this executable format:

Notes for Dos/Sys

Compressed programs only work on a 286+.

Packed programs will be byte-identical to the original after uncompression.

Maximum uncompressed size:

Extra options available for this executable format:

Notes for Djgpp2/Coff

First of all, it is recommended to use UPX *instead* of strip. strip has the very bad habit of replacing your stub with its own (outdated) version. Additionally UPX corrects a bug/feature in strip v2.8.x: it will fix the 4 KiB alignment of the stub.

UPX includes the full functionality of stubify. This means it will automatically stubify your COFF files. Use the option —coff to disable this functionality (see below).

UPX automatically handles Allegro packfiles.

The DLM format (a rather exotic shared library extension) is not supported.

Packed programs will be byte-identical to the original after uncompression. All debug information and trailing garbage will be stripped, though.

Extra options available for this executable format:

NOTES FOR LINUX [general]

General user’s overview

Notes for Linux/Elf386

Please read the general Linux description first.

The linux/elf386 format decompresses directly into RAM, uses only one exec, does not use space in /tmp, and does not use /proc.

Linux/elf386 is automatically selected for Linux ELF executables.

Packed programs will be byte-identical to the original after uncompression.

Extra options available for this executable format:

Notes for Linux/Sh386

Please read the general Linux description first.

Shell scripts where the underling shell accepts a “-c” argument can use the Linux/sh386 format. UPX decompresses the shell script into low memory, then maps the shell and passes the entire text of the script as an argument with a leading “-c”. It does not use space in /tmp, and does not use /proc.

Linux/sh386 is automatically selected for shell scripts that use a known shell.

Packed programs will be byte-identical to the original after uncompression.

Extra options available for this executable format:

Notes for Linux/386

Please read the general Linux description first.

The generic linux/386 format decompresses to /tmp and needs /proc file system support. It starts the decompressed program via the execve() syscall.

Linux/386 is only selected if the specialized linux/elf386 and linux/sh386 won’t recognize a file.

Packed programs will be byte-identical to the original after uncompression.

Extra options available for this executable format:

Notes for Ps1/Exe

This is the executable format used by the Sony PlayStation (PSone), a Mips R3000 based gaming console which is popular since the late ’90s. Support of this format is very similar to the Atari one, because of nostalgic feelings of one of the authors.

Packed programs will be byte-identical to the original after uncompression, until further notice.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR RTM32/PE and ARM/PE

Same as win32/pe.

Notes for Tmt/Adam

Extra options available for this executable format:

Notes for Vmlinuz/386

The vmlinuz/386 and bvmlinuz/386 formats take a gzip-compressed bootable Linux kernel image (“vmlinuz”, “zImage”, “bzImage”), gzip-decompress it and re-compress it with the UPX compression method.

vmlinuz/386 is completely unrelated to the other Linux executable formats, and it does not share any of their drawbacks.

Extra options available for this executable format:

Notes for Watcom/Le

UPX has been successfully tested with the following extenders:
DOS4G, DOS4GW, PMODE/W, DOS32a, CauseWay.
The WDOS/X extender is partly supported (for details
see the file bugs Bugs).

DLLs and the LX format are not supported.

Extra options available for this executable format:

Notes for Win32/Pe

The PE support in UPX is quite stable now, but probably there are still some incompatibilities with some files.

Because of the way UPX (and other packers for this format) works, you can see increased memory usage of your compressed files because the whole program is loaded into memory at startup. If you start several instances of huge compressed programs you’re wasting memory because the common segments of the program won’t get shared across the instances. On the other hand if you’re compressing only smaller programs, or running only one instance of larger programs, then this penalty is smaller, but it’s still there.

If you’re running executables from network, then compressed programs will load faster, and require less bandwidth during execution.

DLLs are supported. But UPX compressed DLLs can not share common data and code when they got used by multiple applications. So compressing msvcrt.dll is a waste of memory, but compressing the dll plugins of a particular application may be a better idea.

Screensavers are supported, with the restriction that the filename must end with “.scr” (as screensavers are handled slightly different than normal exe files).

Extra options available for this executable format:

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.

Please report all bugs immediately to the authors.

Authors

Copyright

Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer

Copyright (C) 1996-2020 Laszlo Molnar

Copyright (C) 2000-2020 John F. Reiser

Copyright (C) 2002-2020 Jens Medoch

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.

How to use upx

UPX is a portable, extendable, high-performance executable packer for several different executable formats. It achieves an excellent compression ratio and offers *very* fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported, because of in-place decompression.

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 😉 ]

UPX comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE.

This is the first production quality release, and we plan that future 1.xx releases will be backward compatible with this version.

Please report all problems or suggestions to the authors. Thanks.

IMPORTANT NOTE: UPX inherits the security context of any files it handles.

This means that packing, unpacking, or even testing or listing a file requires the same security considerations as acutally executing the file.

Use UPX on trusted files only!

UPX is a versatile executable packer with the following features:

You probably understand now why we call UPX the «ultimate» executable packer.

This is the default operation, eg. upx yourfile.exe will compress the file specified on the command line.

-q: be quiet, suppress warnings

—help: prints the help

—version: print the version of UPX

COMPRESSION LEVELS & TUNING

UPX offers ten different compression levels from -1 to -9, and —best. The default compression level is -8 for files smaller than 512 KiB, and -7 otherwise.

Compression levels 1, 2 and 3 are pretty fast.

Compression levels 4, 5 and 6 achieve a good time/ratio performance.

Compression levels 7, 8 and 9 favor compression ratio over speed.

Compression level —best may take a long time.

Note that compression level —best can be somewhat slow for large files, but you definitely should use it when releasing a final version of your program.

Quick info for achieving the best compression ratio:

Try if —overlay=strip works.

For win32/pe programs there’s —strip-relocs=0. See notes below.

OVERLAY HANDLING OPTIONS

Info: An «overlay» means auxiliary data attached after the logical end of an executable, and it often contains application specific data (this is a common practice to avoid an extra data file, though it would be better to use resource sections).

UPX handles overlays like many other executable packers do: it simply copies the overlay after the compressed image. This works with some files, but doesn’t work with others, depending on how an application actually accesses this overlayed data.

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:

Under DOS/Windows you must use ‘#’ instead of ‘=’ when setting the environment variable because of a COMMAND.COM limitation.

You can explicitly use the —no-env option to ignore the environment variable.

NOTES FOR THE SUPPORTED EXECUTABLE FORMATS

NOTES FOR ATARI/TOS

This is the executable format used by the Atari ST/TT, a Motorola 68000 based personal computer which was popular in the late ’80s. Support of this format is only because of nostalgic feelings of one of the authors and serves no practical purpose :-). See 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:

NOTES FOR BVMLINUZ/I386

Same as vmlinuz/i386.

NOTES FOR DOS/COM

Obviously UPX won’t work with executables that want to read data from themselves (like some commandline utilities that ship with Win95/98/ME).

Compressed programs only work on a 286+.

Packed programs will be byte-identical to the original after uncompression.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR DOS/EXE

dos/exe stands for all «normal» 16-bit DOS executables.

Obviously UPX won’t work with executables that want to read data from themselves (like some command line utilities that ship with Win95/98/ME).

Compressed programs only work on a 286+.

Extra options available for this executable format:

NOTES FOR DOS/SYS

Compressed programs only work on a 286+.

Packed programs will be byte-identical to the original after uncompression.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR DJGPP2/COFF

First of all, it is recommended to use UPX *instead* of strip. strip has the very bad habit of replacing your stub with its own (outdated) version. Additionally UPX corrects a bug/feature in strip v2.8.x: it will fix the 4 KiB alignment of the stub.

UPX includes the full functionality of stubify. This means it will automatically stubify your COFF files. Use the option —coff to disable this functionality (see below).

UPX automatically handles Allegro packfiles.

The DLM format (a rather exotic shared library extension) is not supported.

Packed programs will be byte-identical to the original after uncompression. All debug information and trailing garbage will be stripped, though.

Extra options available for this executable format:

NOTES FOR LINUX [general]

General user’s overview

NOTES FOR LINUX/ELF386

Please read the general Linux description first.

The linux/elf386 format decompresses directly into RAM, uses only one exec, does not use space in /tmp, and does not use /proc.

Linux/elf386 is automatically selected for Linux ELF executables.

Packed programs will be byte-identical to the original after uncompression.

Extra options available for this executable format:

NOTES FOR LINUX/SH386

Please read the general Linux description first.

Shell scripts where the underling shell accepts a «-c» argument can use the Linux/sh386 format. UPX decompresses the shell script into low memory, then maps the shell and passes the entire text of the script as an argument with a leading «-c». It does not use space in /tmp, and does not use /proc.

Linux/sh386 is automatically selected for shell scripts that use a known shell.

Packed programs will be byte-identical to the original after uncompression.

Extra options available for this executable format:

NOTES FOR LINUX/386

Please read the general Linux description first.

The generic linux/386 format decompresses to /tmp and needs /proc file system support. It starts the decompressed program via the execve() syscall.

Linux/386 is only selected if the specialized linux/elf386 and linux/sh386 won’t recognize a file.

Packed programs will be byte-identical to the original after uncompression.

3 MiB emacs (which is less than 1 MiB when compressed :-).»>

Extra options available for this executable format:

NOTES FOR PS1/EXE

This is the executable format used by the Sony PlayStation (PSone), a Mips R3000 based gaming console which is popular since the late ’90s. Support of this format is very similar to the Atari one, because of nostalgic feelings of one of the authors.

Packed programs will be byte-identical to the original after uncompression, until further notice.

Maximum uncompressed size:

Extra options available for this executable format:

NOTES FOR RTM32/PE and ARM/PE

Same as win32/pe.

NOTES FOR TMT/ADAM

Extra options available for this executable format:

NOTES FOR VMLINUZ/386

The vmlinuz/386 and bvmlinuz/386 formats take a gzip-compressed bootable Linux kernel image («vmlinuz», «zImage», «bzImage»), gzip-decompress it and re-compress it with the UPX compression method.

vmlinuz/386 is completely unrelated to the other Linux executable formats, and it does not share any of their drawbacks.

Extra options available for this executable format:

NOTES FOR WATCOM/LE

UPX has been successfully tested with the following extenders: DOS4G, DOS4GW, PMODE/W, DOS32a, CauseWay. The WDOS/X extender is partly supported (for details see the file bugs BUGS).

DLLs and the LX format are not supported.

Extra options available for this executable format:

NOTES FOR WIN32/PE

The PE support in UPX is quite stable now, but probably there are still some incompatibilities with some files.

Because of the way UPX (and other packers for this format) works, you can see increased memory usage of your compressed files because the whole program is loaded into memory at startup. If you start several instances of huge compressed programs you’re wasting memory because the common segments of the program won’t get shared across the instances. On the other hand if you’re compressing only smaller programs, or running only one instance of larger programs, then this penalty is smaller, but it’s still there.

If you’re running executables from network, then compressed programs will load faster, and require less bandwidth during execution.

DLLs are supported. But UPX compressed DLLs can not share common data and code when they got used by multiple applications. So compressing msvcrt.dll is a waste of memory, but compressing the dll plugins of a particular application may be a better idea.

Screensavers are supported, with the restriction that the filename must end with «.scr» (as screensavers are handled slightly different than normal exe files).

Extra options available for this executable format:

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.

Please report all bugs immediately to the authors.

Copyright (C) 1996-2021 Markus Franz Xaver Johannes Oberhumer

Copyright (C) 1996-2021 Laszlo Molnar

Copyright (C) 2000-2021 John F. Reiser

Copyright (C) 2002-2021 Jens Medoch

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.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *