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
determining code size
Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess
-
- Posts: 87
- Joined: Thu May 07, 2015 9:47 pm
- Has thanked: 3 times
- Been thanked: 15 times
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: determining code size
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
Giovanni
Re: determining code size
My go-to for function and global variable sizes is:
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).
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).
Who is online
Users browsing this forum: No registered users and 22 guests