Page 1 of 1
determining code size
Posted: Fri Sep 04, 2020 1:35 pm
by geoffrey.brown
The standard build optimizes code size by compiling functions into separate sections and then keeping only those parts of the binary that are actually used. This works great but I have a small technical problem -- is there a convenient way to to determine the contribution to code size of various modules ?
Geoffrey
Re: determining code size
Posted: Fri Sep 04, 2020 3:58 pm
by Giovanni
You could make a customized linker script that loads modules into separate sections, at least the module you are measuring, I think it is possible. You should also disable GC, LTO and functions alignment for the estimation to make sense.
Giovanni
Re: determining code size
Posted: Fri Sep 04, 2020 11:48 pm
by psyco
My go-to for function and global variable sizes is:
Code: Select all
arm-none-eabi-nm --print-size --size-sort build/ch.elf
If you use C++, add a -C for demangling. By default, the second column is size.
If your modules have a prefix to all functions, it should just be a bit of post-processing to get the numbers. Do note LTO can screw around with things (mainly combining functions).