title: How to find global static initializations
body: <p>I just read this excellent article: <a href="http://neugierig.org/software/chromium/notes/2011/08/static-initializers.html" rel="nofollow noreferrer">http://neugierig.org/software/chromium/notes/2011/08/static-initializers.html</a>
  and then I tried: <a href="https://gcc.gnu.org/onlinedocs/gccint/Initialization.html" rel="nofollow noreferrer">https://gcc.gnu.org/onlinedocs/gccint/Initialization.html</a></p>
  
  <p>What it says about finding initializers does not work for me though. The <code>.ctors</code> section is not available, but I could find <code>.init_array</code> (see also <a href="https://stackoverflow.com/questions/16569495/cant-find-dtors-and-ctors-in-binary">Can&#39;t find .dtors and .ctors in binary</a>). But how do I interpret the output? I mean, summing up the size of the pages can also be handled by the <code>size</code> command and its <code>.bss</code> column - or am I missing something?</p>
  
  <p>Furthermore, <code>nm</code> does not report any <code>*_GLOBAL__I_*</code> symbols, only <code>*_GLOBAL__N_*</code> functions, and - more interesting - <code>_GLOBAL__sub_I_somefile.cpp</code> entries. The latter probably indicates files with global initialization. But can I somehow get a list of constructors that are being run? Ideally, a tool would give me a list of</p>
  
  <pre><code>Foo::Foo in file1.cpp:12
  Bar::Bar in file2.cpp:45
  ...
  </code></pre>
  
  <p>(assuming I have debug symbols available). Is there such a tool? If not, how could one write it? Does the <code>.init_array</code> section contain pointers to code which could be translated via some DWARF magic to the above?</p>