<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - extern "C" linkage ignored for a static function"
   href="http://llvm.org/bugs/show_bug.cgi?id=15744">15744</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>extern "C" linkage ignored for a static function
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jbeich@tormail.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>A static function may be called unmangled by asm() within another function
or from a function defined entirely within asm(). The latter is what
firefox does on i386 linux and bsd e.g.,
<a href="https://mxr.mozilla.org/mozilla-central/source/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp#85">https://mxr.mozilla.org/mozilla-central/source/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp#85</a>
<a href="https://mxr.mozilla.org/mozilla-central/source/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp#121">https://mxr.mozilla.org/mozilla-central/source/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp#121</a>

  // a simple testcase
  extern "C"
  {
    __attribute__((__used__))
    static void
    foo(void)
    {
    }
  }

  asm("call foo");

$ clang++33 -c test.cc
$ objdump -t test.o | fgrep foo
0000000000000010 l     F .text  0000000000000006 _Z3foov
0000000000000000         *UND*  0000000000000000 foo

$ clang++32 -c test.cc
$ objdump -t test.o | fgrep foo
0000000000000010 l     F .text  0000000000000001 foo

$ g++48 -c test.cc
$ objdump -t test.o | fgrep foo
0000000000000000 l     F .text  0000000000000006 foo</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>