<html>
    <head>
      <base href="https://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 --- - LLD fails to link object file with version-extended symbol"
   href="https://llvm.org/bugs/show_bug.cgi?id=31495">31495</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD fails to link object file with version-extended symbol
          </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>FreeBSD
          </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>emaste@freebsd.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>23214
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>FreeBSD's "pkg" package management tool is currently building an object file
that depends on a compatibility symbol. I think this needs to be addressed in
pkg itself, but GNU ld is able to link such an object.

LLD reports:

% ld.lld $(cat response.txt)                                
/tank/emaste/src/llvm/build-nodebug/bin/ld.lld: error:
wrkdirs/usr/ports/ports-mgmt/pkg/work/pkg-1.7.2/libpkg/.libs/libpkg.lax/libbsd_compat.a/libbsd_compat_la-basename.o:
symbol <a href="mailto:basename@FBSD_1.0">basename@FBSD_1.0</a> has undefined version FBSD_1.0
/tank/emaste/src/llvm/build-nodebug/bin/ld.lld: error:
wrkdirs/usr/ports/ports-mgmt/pkg/work/pkg-1.7.2/libpkg/.libs/libpkg.lax/libbsd_compat.a/libbsd_compat_la-dirname.o:
symbol <a href="mailto:dirname@FBSD_1.0">dirname@FBSD_1.0</a> has undefined version FBSD_1.0

ld.bfd has no complaints:
% ld.bfd $(cat response.txt)


The offending symbol is <a href="mailto:basename@FBSD_1.0">basename@FBSD_1.0</a>:

% readelf -s libbsd_compat_la-basename.o

Symbol table '.symtab' contains 5 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS basename.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    2 
     3: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND <a href="mailto:basename@FBSD_1.0">basename@FBSD_1.0</a>
     4: 0000000000000000    10 FUNC    GLOBAL DEFAULT    2 bsd_basename

And indeed, a .o file has no symver information:

% readelf -V libbsd_compat_la-basename.o

No version information found in this file.

I suspect we should accept version-extended symbols from object files.
Reprodcer available at
<a href="https://people.freebsd.org/~emaste/lld/object-sym-version.cpio">https://people.freebsd.org/~emaste/lld/object-sym-version.cpio</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>