<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 - SHN_ABS symbols cause --gc-sections to crash"
   href="https://bugs.llvm.org/show_bug.cgi?id=33239">33239</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SHN_ABS symbols cause --gc-sections to crash
          </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>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>smeenai@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>compnerd@compnerd.org, grimar@accesssoftek.com, llvm-bugs@lists.llvm.org, rafael.espindola@gmail.com, ruiu@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>% touch empty.bin
% ld.lld -m elf_x86_64 -b binary --relocatable -o empty.o empty.bin
% ld.lld -shared --gc-sections -o libempty.so empty.o
ld.lld: ../../../include/llvm/Support/Casting.h:104: static bool
llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To =
lld::elf::InputSectionBase; From = lld::elf::SectionBase]: Assertion `Val &&
"isa<> used on a null pointer"' failed.

The assertion is triggered via the cast in [1]. The symbol for which it fails
is _binary_empty_bin_size, which is absolute and has a null Section.

I'm using the first ld.lld command because it was how I came across the issue;
I believe it would generalize to any SHN_ABS symbol, however. I'm not sure if
there are scenarios in which a non-absolute symbol would trigger the assertion.

[1]
<a href="https://reviews.llvm.org/diffusion/L/browse/lld/trunk/ELF/MarkLive.cpp;304274$223?color=1">https://reviews.llvm.org/diffusion/L/browse/lld/trunk/ELF/MarkLive.cpp;304274$223?color=1</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>