I want to be able to get an estimate of how much code & static data is used by my C++ program?
Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime?
Will objdump & readelf help?
From stackoverflow
hyperlogic
-
readelfwill indeed help. You can use the-Soption; that will show the sizes of all sections..textis (the bulk of) your executable code..dataand.rodatais your static data. There are other sections too, some of which are used at runtime, others only at link time.From Chris Jester-Young -
"size" is the traditional tool. "readelf" has a lot of options.
$ size /bin/sh text data bss dec hex filename 712739 37524 21832 772095 bc7ff /bin/shFrom Mark Harrison -
If you want to take the next step of identifying the functions and data structures to focus on for footprint reduction, the --size-sort argument to nm can show you:
$ nm --size-sort /usr/bin/fld | tail -10 000000ae T FontLoadFontx 000000b0 T CodingByRegistry 000000b1 t ShmFont 000000ec t FontLoadw 000000ef T LoadFontFile 000000f6 T FontLoadDFontx 00000108 D fSRegs 00000170 T FontLoadMinix 000001e7 T main 00000508 T FontLoadBdfFrom DGentry -
size -A
From jfm3
0 comments:
Post a Comment