title: Get linux executable load address (__builtin_return_address and addr2line)
body: <p>I'm writing some code that stores a backtrace for each memory allocation. I'm then writing a list of these to a file for offline analysis. In win32 I use <code>_AddressOfReturnAddress</code> and then manually create the backtrace. Since the address is random for each run I use <code>GetModuleInformation</code> and <code>lpBaseOfDll</code> to get the base address. This works great on x86 without FPO, which is good enough for me. I then load the PDB using win32 API to translate the address to function name.</p>
  
  <p>How would I do this on linux? My current approach is to use <code>__builtin_return_address(x)</code> and <code>addr2line</code> offline to get the same result. The problem is that the addresses are randomized each run, so <code>addr2line</code> doesn't understand them. <code>__executable_start</code> didn't work as it returns the same value each run. Is there any way to get the base address of my executable in runtime?</p>
  
  <p>One run gives me this:</p>
  
  <pre><code>__executable_start: 0x8048000
  backtrace:
  0x9cce628
  0x9cce2b8
  0x9cce260
  0x9cce1f8
  0x9cce138
  0x9cce0c8
  0x9cce060
  0x9cce008
  </code></pre>
  
  <p>And the next:</p>
  
  <pre><code>__executable_start: 0x8048000
  backtrace:
  0x8db6628
  0x8db62b8
  0x8db6260
  0x8db61f8
  0x8db6138
  0x8db60c8
  0x8db6060
  0x8db6008
  </code></pre>
  
  <p>And so on.</p>