title: Different offset in libc's backtrace_symbols() and libunwind's unw_get_proc_name()
body: <p>I make a stack trace at some point in my program. Once with <em>libc</em>'s <code>backtrace_symbols()</code> function and once with <code>unw_get_proc_name()</code> from <em>libunwind</em>.</p>
  
  <p><strong>backtrace_symbols() output:</strong></p>
  
  <pre><code>/home/jj/test/mylib.so(+0x97004)[0x7f6b47ce9004]
  </code></pre>
  
  <p><strong>unw_get_proc_name() output:</strong></p>
  
  <pre><code>ip: 0x7f6b47ce9004, offset: 0x458e4
  </code></pre>
  
  <p>Here you see that the <em>instruction pointer</em> address (0x7f6b47ce9004) is the same and correct. The function offset <code>0x97004</code> from <em>backtrace_symbols()</em> is also correct but <strong>not</strong> the one I get from <em>unw_get_proc_name()</em> (<code>0x458e4</code>).</p>
  
  <p>Does somebody have a clue what's going on here and what might cause this difference in offsets?</p>
  
  <p>Both methods use a similar code like the following examples:</p>
  
  <p><strong>backtrace():</strong></p>
  
  <pre><code>void *array[10];
  size_t size;
  
  size = backtrace(array, 10);
  backtrace_symbols_fd(array, size, STDERR_FILENO);
  </code></pre>
  
  <p><strong>libunwind:</strong></p>
  
  <pre><code>unw_cursor_t    cursor;
  unw_context_t   context;
  
  unw_getcontext(&amp;context);
  unw_init_local(&amp;cursor, &amp;context);
  
  while (unw_step(&amp;cursor) &gt; 0) {
      unw_word_t  offset, pc; 
      char        fname[64];
  
      unw_get_reg(&amp;cursor, UNW_REG_IP, &amp;pc);
  
      fname[0] = '\0';
      (void) unw_get_proc_name(&amp;cursor, fname, sizeof(fname), &amp;offset);
  
      printf ("%p : (%s+0x%x) [%p]\n", pc, fname, offset, pc);
  }
  </code></pre>