Page 1 of 1

UPX 'compressor' utility

Posted: Wed 29 Apr 2020, 15:57
by Mike Walsh
Hi, all.

UPX - Ultimate 'Packer' for eXecutables

Just wanted to share this one with y'all. Forum member Makoto mentioned it to me during the last 24 hours, and I've already used it to trim down one of John Van Sickle's static ffmpeg builds by somewhere in the region of nearly 70%.....from around 46MB to a hair under 14MB.

Quite a saving, huh?

Given that many Puppians still run pretty old hardware, and need to keep an eye on space/general 'size' of things, I thought this was worth making public.

Do be aware that there are 32-bit and 64-bit tarballs of this - only around 400kb or so when unpacked - so make sure to download the right one for your Pup's architecture.

It's command-line only, but it's a doddle to use. You can put the statically-linked upx binary anywhere you want, and run it with the following code:-

Code: Select all

/path/to/upx /path/to/binary_to_be_compressed
It compresses your executable binary 'in-situ', so no need to move it somewhere else while you work on it.....though I'd advise making a copy of the original, just in case.....

Hope some of you find this useful.


Mike. :wink:

Posted: Wed 29 Apr 2020, 17:58
by Makoto
I should probably add... just to be safe, don't use UPX on anything critical (anything important and necessary for the system to run, for example). It's probably a good idea not to use it on drivers or libfiles unless you know what you're doing.

Not all binaries may work after being compressed, so as Mike mentions, work on and test a copy of the binary in the same directory. You can decompress anything you've compressed with the -d flag, though:

Code: Select all

upx -d binaryfilename
UPX also has multiple levels of compression:

Code: Select all

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.
(source: upx.doc)