<p>I want to be able to get an estimate of how much code &amp; static data is used by my C++ program?</p>

<p>Is there a way to find this out by looking at the executable or object files?  Or perhaps something I can do at runtime?</p>

<p>Will objdump &amp; readelf help?</p>

[{'answer_id': 35508, 'author': 'C. K. Young', 'author_id': 13, 'author_profile': 'https://Stackoverflow.com/users/13', 'pm_score': 1, 'selected': False, 'text': '<p><code>readelf</code> will indeed help. You can use the <code>-S</code> option; that will show the sizes of all sections. <code>.text</code> is (the bulk of) your executable code. <code>.data</code> and <code>.rodata</code> is your static data. There are other sections too, some of which are used at runtime, others only at link time.</p>\n'}, {'answer_id': 35738, 'author': 'Mark Harrison', 'author_id': 116, 'author_profile': 'https://Stackoverflow.com/users/116', 'pm_score': 4, 'selected': True, 'text': '<p>"size" is the traditional tool.  "readelf" has a lot of options.</p>\n\n<pre><code>$ size /bin/sh\n   text    data     bss     dec     hex filename\n 712739   37524   21832  772095   bc7ff /bin/sh\n</code></pre>\n'}, {'answer_id': 47033, 'author': 'DGentry', 'author_id': 4761, 'author_profile': 'https://Stackoverflow.com/users/4761', 'pm_score': 2, 'selected': False, 'text': '<p>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:</p>\n\n<pre><code>$ nm --size-sort /usr/bin/fld | tail -10\n000000ae T FontLoadFontx\n000000b0 T CodingByRegistry\n000000b1 t ShmFont\n000000ec t FontLoadw\n000000ef T LoadFontFile\n000000f6 T FontLoadDFontx\n00000108 D fSRegs\n00000170 T FontLoadMinix\n000001e7 T main\n00000508 T FontLoadBdf\n</code></pre>\n'}, {'answer_id': 106984, 'author': 'jfm3', 'author_id': 11138, 'author_profile': 'https://Stackoverflow.com/users/11138', 'pm_score': 1, 'selected': False, 'text': '<pre>\nsize -A\n</pre>\n'}]
['https://Stackoverflow.com/questions/35485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1841/']