I'm producing a hex file to run on an ARM processor which I want to keep below 32K. It's currently a lot larger than that and I wondered if someone might have some advice on what's the best approach to slim it down?
Here's what I've done so far
- So I've run 'size' on it to determine how big the hex file is.
- Then 'size' again to see how big each of the object files are that link to create the hex files. It seems the majority of the size comes from external libraries.
- Then I used 'readelf' to see which functions take up the most memory.
- I searched through the code to see if I could eliminate calls to those functions.
Here's where I get stuck, there's some functions which I don't call directly (e.g. _vfprintf) and I can't find what calls it so I can remove the call (as I think I don't need it).
So what are the next steps?
Response to answers:
- As I can see there are functions being called which take up a lot of memory. I cannot however find what is calling it.
- I want to omit those functions (if possible) but I can't find what's calling them! Could be called from any number of library functions I guess.
- The linker is working as desired, I think, it only includes the relevant library files. How do you know if only the relevant functions are being included? Can you set a flag or something for that?
- I'm using GCC