title: Local labels in GNU assembler; gdb printing backtrace as though labels are functions
body: <p>Two pieces of example code; first some C++ code calling into assembly:</p>
  
  <pre><code>/* test1.cc */
  #include &lt;stdio.h&gt;
  
  extern "C" void blah();
  extern "C" void stuff() {
    printf( "This is a test\n" );
  }
  
  int main( int argc, char *argv[] ) {
    blah();
  
    return 0;
  }
  </code></pre>
  
  <p>... then the assembly:</p>
  
  <pre><code>.file "test2.s"
  .text
  .globl blah, stuff
  .type blah,@function
  .type stuff,@function
  .align 16
  
  blah:
    /* normal function preamble */
    pushl %ebp
    movl %esp, %ebp
  
  label1:
    call stuff
  
    leave
    retn
  </code></pre>
  
  <p>Built with:</p>
  
  <pre><code>as -g --32 test2.s -o test2.o
  clang++ -m32 -g test1.cc -c
  clang++ -m32 -g test*.o -o test
  </code></pre>
  
  <p>Run it under gdb, set a breakpoint on stuff(), then look at the backtrace:</p>
  
  <pre><code>gdb test
  (gdb) break stuff
  (gdb) run
  (gdb) back
       #0  stuff () at test1.cc:5
  ---&gt; #1  0x08048458 in label1 () at test2.s:12
  ---&gt; #2  0xffffc998 in ?? ()
       #3  0x0804843e in main (argc=1, argv=0xffffca44) at test1.cc:9
  </code></pre>
  
  <p>After sifting through [<em>edit</em> an older copy of] the GNU assembler documentation, I tried labels prefixed with <code>L</code> &amp; postfixed with <code>$</code> to see if it would prevent the labels from being exported, but it didn't work.</p>
  
  <p>If I make the labels numeric the backtrace looks normal, but I'm not overly fond of the notion of using numeric labels.</p>
  
  <p>Could someone point me in the right direction, please?</p>