Showing posts from July, 2011

Packing executables

One of the biggest challenges with embedding platforms is the limitation related to file sizes. Here is the hint how to make executables smaller - strip them and pack them:

strip is a tool from GNU binutils, it discards symbols. Usually the platform toolchain has one.upx is an excellent executable packer. Can be downloaded as binary or sources from the UPX site.
As an example, I'll show you the packing of Python 2.6.7 binary:

$ ls -s --block-size=KB python
6493kB python
$ strip -s python
$ ls -s --block-size=KB python
1696kB python
$ upx --best python
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2010
UPX 3.05        Markus Oberhumer, Laszlo Molnar & John Reiser   Apr 27th 2010

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
   1692400 ->    608896   35.98%  linux/ElfAMD   python

Packed 1 file.
$ ls -s --block-size=KB python
611kB python

So, we've got 10:1 …