<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 - LLD with LTO breaks ELF symbol versioning"
   href="https://bugs.llvm.org/show_bug.cgi?id=46420">46420</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD with LTO breaks ELF symbol versioning
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>ELF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>itay.bookstein@nextsilicon.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Minimal repro follows below.
My debugging seems to indicate that the call to sym->parseSymbolVersion() in
LinkerDriver::compileBitcodeFiles() causes the observed truncation. The method
does indeed truncate the symbol object's name as reported by Symbol::getName(),
but that seems to be the very intention of that method. Perhaps it is done too
early? Perhaps the code that builds the symbol table needs to take the
parsed-version-state into account? I'm not quite sure yet.

~itay@local:~> cat try.ll
target triple = "x86_64-unknown-linux-gnu"
module asm ".symver loc1,<a href="mailto:loc1@GLIBC_2.2.5">loc1@GLIBC_2.2.5</a>"
@loc1 = local_unnamed_addr global i8* null, align 8

~itay@local:~> cat build.sh
#!/bin/bash -eu

_DIR=/home/itay/Projects/llvm-project/Debug/bin

${_DIR}/llvm-as try.ll -o try.bc
${_DIR}/clang -fuse-ld=lld -nostdlib -nostartfiles -r try.bc -o
try_reloclink_nolto.o
${_DIR}/clang -fuse-ld=lld -nostdlib -nostartfiles -r try.bc -o
try_reloclink_lto.o -flto
file try_reloclink*
${_DIR}/llvm-nm try_reloclink*

~itay@local:~> ./build.sh
try_reloclink_lto.o:   ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV),
not stripped
try_reloclink_nolto.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV),
not stripped

try_reloclink_lto.o:
0000000000000000 B loc1
0000000000000000 B loc1

try_reloclink_nolto.o:
0000000000000000 B loc1
0000000000000000 B <a href="mailto:loc1@GLIBC_2.2.5">loc1@GLIBC_2.2.5</a></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>