title: How exactly does gperftools CPU profiler start?
body: <p><a href="http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html">gperftools documentation</a> says that <code>libprofiler</code> should be linked into a target program:</p>
  
  <pre><code>$ gcc myprogram.c -lprofiler
  </code></pre>
  
  <p>(without changing a code of the program).</p>
  
  <p>And then program should be run with a specific environment variable:</p>
  
  <pre><code>CPUPROFILE=/tmp/profiler_output ./a.out
  </code></pre>
  
  <p><strong>The question is:</strong> how does <code>libprofile</code> have a chance to start and finish a profiler when it is merely loaded, but its functions are not called?</p>
  
  <p>There is no constructor function in that library (<a href="http://code.google.com/p/gperftools/source/search?q=%22__attribute__%28%28constructor%29%29%22&amp;origq=%22__attribute__%28%28constructor%29%29%22&amp;btnG=Search%20Trunk">proof</a>).
  <a href="http://code.google.com/p/gperftools/source/search?q=%22CPUPROFILE%22&amp;origq=%22CPUPROFILE%22&amp;btnG=Search%20Trunk">All occasions of "CPUPROFILE"</a> in library code do not refer to any place where profiler is started.</p>
  
  <p>I am out of ideas, where to look next?</p>