title: How to use __func__ with inline assembly
body: <p>I'm trying to add meta-data to an ELF executable by storing strings in a special section (<code>__dlog</code>). The current approach uses (abuses?) inline assembly to store the strings and nearly works as desired.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define DLOG(proto...) \
          __asm__(".pushsection __dlog, \"S\", @note\n\t" \
                  ".asciz \"" __FILE__ ":function_name_here:" #proto "\"\n\t" \
                  ".popsection\n\t" )
  
  int
  foo(int bar)
  {
      int baz = bar / 2;
      DLOG(int baz);
      return baz;
  }
  
  int
  main(int argc, char *argv[])
  {
      foo(argc);
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>But ideally, the macro should automatically include the function name as a part of the string by taking advantage of the <code>__func__</code> identifier. The end result should be the string</p>
  
  <pre><code>file.c:foo:int baz\0
  </code></pre>
  
  <p>in a section called <code>__dlog</code>. But since <code>__func__</code> is not a string literal, gcc complains with this code</p>
  
  <pre><code>".asciz \"" __FILE__ ":" __func__ ":" #proto "\"\n\t"
  </code></pre>
  
  <p>Is there anyway to get the contents of <code>__func__</code> added to the string? Bonus points if the solution doesn't require custom build options or post-processing steps. Compiler is gcc 4.4 and 4.5.</p>