<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 - LLD executable segfaults with ld.bfd linker script"
   href="https://bugs.llvm.org/show_bug.cgi?id=49846">49846</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD executable segfaults with ld.bfd linker script
          </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>ELF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bharathi.seshadri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24720" name="attach_24720" title="Linker script">attachment 24720</a> <a href="attachment.cgi?id=24720&action=edit" title="Linker script">[details]</a></span>
Linker script

bash-4.4$ ld --verbose > main.link 
(Trim header and footer of  main.link. See attached)

bash-4.4$ clang hello.c -fuse-ld=lld -Wl,-T -Wl,main.link -o hello
bash-4.4$ ./hello
Segmentation fault

bash-4.4$ clang --version
clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
3c19b4f34d6a2a2fb628a3db9225a5167e363234)

The issue can be worked around by passing -Wl,--no-rosegment

This issue was previously fixed in 2017
(<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - LLD produced executable with ld.bfd internal ldscript segfaults."
   href="show_bug.cgi?id=35265">https://bugs.llvm.org/show_bug.cgi?id=35265</a>), but it appears to have regressed
again at some point between llvm 9.0 and llvm 11.</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>