The GNU size utility which is part of the GNU build tools shows code and data size for archive or object files. It is usually used as a post-build step in Eclipse CDT to show text, data and bss at the end of the build:
Usually the ‘size’ utility is used to show information about the binary in an Eclipse CDT post-build action:
The Eclipse based NXP MCUXpresso IDE has the ‘Image Info’ plugin which gives detailed information about what is used by the linked ELF/Dwarf file:
The above view and information is what is used in the linked application. Still it can be very useful to get size information for all the linked object files.
:info: Keep in mind that the linker will ‘strip’ any unused function, variable or constant for the final image, so the size information for each object file is the worst case.
To list the size information in a post-build, I could list the desired object files as argument to the post-build action. A very useful trick is to use the $(OBJS) macro which holds all the object files. That Macro is defined in the make files:
So I can use that macro in the post-build action for the ‘size’ command, shown below for the case of the MCUXpresso IDE:
That way I get the details for each object file too:
And there is yet another useful trick if you need a listing of the application: add the following as post-build command (thanks for commenting on this, Konstantin!):
arm-none-eabi-objdump -S “${BuildArtifactFileName}” > “${BuildArtifactFileBaseName}.lst”
Happy Sizing 🙂
Hello !
I’ll add a little from myself.
Sometimes it is useful to get a listing of the program.
Can add Post-build steps
arm-none-eabi-objdump -S “${BuildArtifactFileName}” > “${BuildArtifactFileBaseName}.lst”
LikeLike
I did not think about this, good idea (added now, thanks!)
LikeLike
Handy hints thank you gentlemen!
I also add this:
touch “${ProjDirPath}/../Sources/lib/version.c”
This forces version.c to rebuild next time, because it contains
char const gCompileTime[] = __DATE__ ” ” __TIME__;
which is handy for tracking the actual build time. This is the minimum work the build process has to do each time.
And
time
so I know when the build has finished, to save me accidentally rebuilding and wasting time (when I forget if I have built or not).
LikeLike
neat idea! Windows users might consider the touch solution proposed in https://superuser.com/questions/10426/windows-equivalent-of-the-linux-command-touch/764716
LikeLike
Actually, this is in Windows (10)- and touch just worked. Not sure how, but I didn’t have to do anything special! Better check that out…
SOLVED: It looks like WinAVR includes it:
C:\Users\FightingFush>where touch
C:\WinAVR-20100110\utils\bin\touch.exe
Nice trick….
LikeLike