Registered a URL and setup a forum as the IPCam stuff really needed its own site vs my irregular blog posts about IPCam hacking at

Author Topic: elf compressed files tip  (Read 7712 times)

  • No avatar
  • *****
February 07, 2011, 04:19:44 pm
As our flash is only 2M (4M on some devices), we have quite limited space.
The kernel is roughly 1.1M in size, so we have approximately 900kb free to play with on the smaller sized flash units.

What to do?

Compress things!

Post compile we can compress our elf files using the handy fltheader tools

Code: [Select]
No/Too many files provided
usage: flthdr [options] flat-file
       Allows you to change an existing flat file

       -p      : print current settings
       -z      : compressed flat file
       -Z      : un-compressed flat file
       -r      : ram load
       -R      : do not RAM load
       -s size : stack size
       -o file : output-file
                 (default is to modify input file)

Lets have a look at how compression can help with an example

Code: [Select]
# ls -alh ftpd
-rwxr-xr-x 1 root root 109K Feb  7 22:52 ftpd
# file ftpd
ftpd: BFLT executable - version 4 ram

Above, you can see our ftp daemon is 109kb.    If we use the file command to check the filetype, you'll note its not compressed.

Lets see what compression does for us

Code: [Select]
#flthdr -z ftpd
compressing file ...

If we check the filetype, you'll see that its now reported compressed

Code: [Select]
#file ftpd
ftpd: BFLT executable - version 4 ram gzip

So what does that give us?

Code: [Select]
# ls -alh ftpd
-rwxr-xr-x 1 root root 58K Feb  7 22:54 ftpd

Nice, a 51kb reduction in size!
« Last Edit: February 07, 2011, 04:23:13 pm by admin »