<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Undefined symbol with CFI and __attribute__((__used__))"
   href="https://bugs.llvm.org/show_bug.cgi?id=49251">49251</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Undefined symbol with CFI and __attribute__((__used__))
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>tejohnson@google.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>samitolvanen@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, i@maskray.me, llvm-bugs@lists.llvm.org, ndesaulniers@google.com, peter@pcc.me.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Commit rG3c4c205060c9 ("[WPD][lld] Test handling of vtable definition from
shared libraries") breaks my Linux kernel build with ThinLTO and CFI, because
the compiler now generates an undefined symbol in a kernel module for a static
function with  __attribute__((__used__)).

A stand-alone reproducer:

$ cat test.c
static __attribute__((__used__)) f1() {}
f2() {}

$ clang -flto=thin -fsanitize=cfi -fvisibility=default -O2 -c -o test.o test.c
...
$ ld.lld -r -o test.lto.o test.o
$ readelf --symbols test.lto.o | grep f1
     9: 0000000000000000     1 FUNC    GLOBAL HIDDEN     4
f1$0c315d2ea609b3d583650e385e8cf855
    11: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND f1

Before this commit, the undefined symbol wasn't generated:

$ readelf --symbols test.lto.o | grep f1
     9: 0000000000000000     1 FUNC    GLOBAL HIDDEN     4
f1$0c315d2ea609b3d583650e385e8cf855</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>