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
flthdr
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
# 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
#flthdr -z ftpd
compressing file ...
If we check the filetype, you'll see that its now reported compressed
#file ftpd
ftpd: BFLT executable - version 4 ram gzip
So what does that give us?
# ls -alh ftpd
-rwxr-xr-x 1 root root 58K Feb 7 22:54 ftpd
Nice, a 51kb reduction in size!