<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 - Static PIE executables segfault on initialization"
   href="https://bugs.llvm.org/show_bug.cgi?id=47240">47240</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Static PIE executables segfault on initialization
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>victor@westerhu.is
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When building a static PIE executable using LLD, the executable segfaults
before invoking main(). Using a debugger, I've traced the error back to the
glibc function apply_irel() in csu/libc_start.c. The same executable built
using ld.bfd works fine. A difference I've noticed between the two executables,
is that ld.bfd places ifunc relocations in a .rela.plt section, while ld.lld
places them in in the .rela.dyn section.

Even an empty program (int main(int argc, char** argv){}) gives these results,
so it seems to have nothing to do with the particulars of the software I was
compiling. The same results happen when using ld.lld as the linker for GCC.

I've tested it on Debian testing and Ubuntu 20.04 (tried LLD 10.0.1, 11.0.0,
and 12.0.0 on both) and Arch Linux (LLD 10.0.1). I've only tried x86_64,
because I don't have access to other hardware.</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>