Where Is All That FLASH Space Going?

How can I generate a map of what's in FLASH with enough information to enable me to determine which sections of code are taking up the most space? I have an application that has to fit into the 32K FLASH of a ProMini, but currently compiles to 37.5K. Even being able to get the size of individual classes, or source modules would suffice.

Regards,
Ray L.

That is a good question about generating a strorage allocation map. However, it is not only program code. If you are using PROGMEM or the F() macro for strings etc., these eat up the flash memory also.

Maybe you can get something useful from avr-objdump with the mentioned -h -S options?

6v6gt:
However, it is not only program code. If you are using PROGMEM or the F() macro for strings etc., these eat up the flash memory also.

Strings will eat flash irrespective of whether or not they are marked as PROGMEM, since it only controls whether data is copied from flash into RAM or not.

Ok. I stand corrected there. The bootloader also. But you may be able to dispense with that.

I took a more brute-force approach - I commented out all references to the largest modules, and re-compiled. The biggest offender, by far, was, not surprisingly, the WiFi code. I am now in the process of moving all of that onto the 8266 itself, which will free up about 15K on the ProMini - more than enough.

It does seem like there must be a way to get an ordered map of FLASH with labels for each data item, function, etc. But from what I saw playing with obj-dump, the names are, largely, the mangled names, which are not very helpful. If I could get a nice ordered map, I could easily write a Perl script to parse it and compile suitable statistics, like size/function, size/class, etc.

Regards,
Ray L.

You could play with the linker options, and get it to give you a map file. -Wl,-Map=output.map works for me. There's a ton of stuff. Maybe something you could use.

Jimmus:
You could play with the linker options, and get it to give you a map file. -Wl,-Map=output.map works for me. There’s a ton of stuff. Maybe something you could use.

Thanks! I’ll give that a try.
Regards,
Ray L.

RayLivingston:
But from what I saw playing with obj-dump, the names are, largely, the mangled names, which are not very helpful.

Try objdump's -C option to demangle the names.

avr-nm --demangle --print-size --size-sort *.elf