<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 --- - Error "invalid section index: xxx" when linking FreeBSD kernel."
   href="https://llvm.org/bugs/show_bug.cgi?id=28868">28868</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Error "invalid section index: xxx" when linking FreeBSD kernel.
          </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>grimar@accesssoftek.com
          </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>Created <span class=""><a href="attachment.cgi?id=16888" name="attach_16888" title="hpt27xx_lib.o">attachment 16888</a> <a href="attachment.cgi?id=16888&action=edit" title="hpt27xx_lib.o">[details]</a></span>
hpt27xx_lib.o

I found that when tried to link kernel.
Minimal reproduce is:
-flavor gnu -o kernel.debug hpt27xx_lib.o
File is attached.

Problem is that file contains symbols which combines STT_SECTION and 
are associated with a SHT_RELA/SHT_STRTAB/SHT_SYMTAB sections.
And we do not create section for those and that triggers this error.

For example:
  Section {
    Index: 2
    Name: .rela.text (27)
    Type: SHT_RELA (0x4)
    Flags [ (0x0)
    ]
    Address: 0x0
    Offset: 0x9C138
    Size: 220176
    Link: 14
    Info: 1
    AddressAlignment: 8
    EntrySize: 24
  }

  Symbol {
    Name:  (0)
    Value: 0x0
    Size: 0
    Binding: Local (0x0)
    Type: Section (0x3)
    Other: 0
    Section: .rela.text (0x2)
  }

There are in total 7 symbols affected in this file assotiated with one of next
sections:
.rela.text, .rela.rodata, .rela.data, .rela.eh_frame, .shstrtab, .symtab,
.strtab</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>