I was hacking on my AtTiny13 this afternoon, having some trouble getting my .hex file small enough to flash. I looked around to find some details about reducing the final binary size so I could get my .hex down a couple lines, and finally figured out the following (which reduced my .hex by about 0.6k, or 16 lines).
When you link together the .o files that you compiled the first time around, a bunch of trash comes along. Especially for me I was using a software OWI (One Wire Interface) lib for only 1 or 2 of its functions, but all the other crap comes along for the ride. I needed to tell avr-gcc to not include those instructions since they were never actually getting called.
The magic happens with the ‘-Wl,–relax,–gc-sections‘ options added to avr-gcc when it is linking (stick it in your Makefile at the EDLFLAGS line perhaps).
Add in ‘-ffunction-sections -fdata-sections‘ to avr-gcc when it is compiling the object files (CPPFLAGS line), and you will probably (hopefully?) see a reduction in code size if you have some unused functions.
I’m no GCC expert, but it looks like the -fdata-sections and -ffunction-sections will cut up the data and functions into seperate sections. By using the linker options above you are telling the linker to only link sections that are referenced, and you ignore the rest. A quick search for these options will give you much more detail as to what actually happens if you are interested.