<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:i@maskray.me" title="Fangrui Song <i@maskray.me>"> <span class="fn">Fangrui Song</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - LLD executable segfaults with ld.bfd linker script"
   href="https://bugs.llvm.org/show_bug.cgi?id=49846">bug 49846</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>i@maskray.me
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - LLD executable segfaults with ld.bfd linker script"
   href="https://bugs.llvm.org/show_bug.cgi?id=49846#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - LLD executable segfaults with ld.bfd linker script"
   href="https://bugs.llvm.org/show_bug.cgi?id=49846">bug 49846</a>
              from <span class="vcard"><a class="email" href="mailto:i@maskray.me" title="Fangrui Song <i@maskray.me>"> <span class="fn">Fangrui Song</span></a>
</span></b>
        <pre>With traditional -z noseparate-code, GNU ld defaults to a RX/R/RW program
header layout. With -z separate-code (default on Linux/x86 from binutils 2.31
onwards), GNU ld defaults to a R/RX/R/RW program header layout.

I think your script is a -z noseparate-code layout.

LLD defaults to R/RX/RW(RELRO)/RW(non-RELRO). With --rosegment, LLD uses
RX/RW(RELRO)/RW(non-RELRO).

GNU ld's -z noseparate-code layout is not compatible with LLD --rosegment
because there is no maxpagesize alignment between text and rodata like:

  . = SEGMENT_START("rodata-segment", ALIGN(CONSTANT (MAXPAGESIZE)) + (. &
(CONSTANT (MAXPAGESIZE) - 1)));

So the two PT_LOAD (RX) PT_LOAD (R) will actually overlap at runtime and the
executable segment will be remapped as readonly and the program will crash.

If you feed a ld.bfd -z separate-code linker script into ld.lld --rosegment, it
should work.</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>