<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 assertion failure linking FreeBSD base system after r265293"
   href="https://llvm.org/bugs/show_bug.cgi?id=27228">27228</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lld assertion failure linking FreeBSD base system after r265293
          </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>All Bugs
          </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>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This assertion fails:

(lldb) frame sel 4
frame #4: 0x00000000005b1a74 ld`SymbolBody(this=0x00000008068ea140,
K=SharedKind, Name=StringRef at 0x00007fffffffc798, Binding='\0',
StOther='\0', Type='\0') + 276 at Symbols.h:134
   131        : SymbolKind(K), MustBeInDynSym(false),
NeedsCopyOrPltAddr(false),
   132          Type(Type), Binding(Binding), StOther(StOther),
   133          Name({Name.data(), Name.size()}) {
-> 134      assert(!isLocal());
   135      IsUsedInRegularObj =
   136          K != SharedKind && K != LazyKind && K != DefinedBitcodeKind;
   137    }

The failing symbol is:

(lldb) p Name
(lld::elf::SymbolBody::Str) $1 = (S = "__start_set_kvm_arch", Len = 20)

This is a synthetic symbol generated for section start and stop (for use by
e.g. linker sets), for the "set_kvm_arch" section in a .so that we're linking
against.

It looks like the issue is getSymbolBinding returns only STB_LOCAL for
synthetic symbols:

template <class ELFT>
uint8_t SymbolTableSection<ELFT>::getSymbolBinding(SymbolBody *Body) {
  uint8_t Visibility = Body->getVisibility();
  if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)
    return STB_LOCAL;
  if (isa<DefinedSynthetic<ELFT>>(Body))
    return STB_LOCAL;
  return Body->Binding;
}</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>