<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 FIXED - lld has different section attribute merging vs ld.bfd"
   href="https://bugs.llvm.org/show_bug.cgi?id=30415">bug 30415</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;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>FIXED
           </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 FIXED - lld has different section attribute merging vs ld.bfd"
   href="https://bugs.llvm.org/show_bug.cgi?id=30415#c8">Comment # 8</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - lld has different section attribute merging vs ld.bfd"
   href="https://bugs.llvm.org/show_bug.cgi?id=30415">bug 30415</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>lld doesn't create one single RWX PT_LOAD now. Closing because the issue has
been fixed for a while.

# I test on a Linux machine, but the FreeBSD case is similar.
% clang -fuse-ld=lld -m32 a.c a.x -o a  # 5008 bytes

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x00140 0x00140 R   0x4
  INTERP         0x000174 0x08048174 0x08048174 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x00730 0x00730 R E 0x1000
  LOAD           0x000730 0x08048730 0x08048730 0x000d8 0x000d8 RW  0x1000
  LOAD           0x000808 0x08048808 0x08048808 0x00020 0x00021 RW  0x1000
  DYNAMIC        0x000738 0x08048738 0x08048738 0x000c8 0x000c8 RW  0x4
  GNU_RELRO      0x000730 0x08048730 0x08048730 0x000d8 0x01000 R   0x1
  GNU_EH_FRAME   0x000378 0x08048378 0x08048378 0x00044 0x00044 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0
  NOTE           0x000188 0x08048188 0x08048188 0x00020 0x00020 R   0x4

After D64903 and D64906 are merged, the non-linker script case will look
similar to this layout.

% clang -fuse-ld=bfd -m32 a.c a.x -o a.bfd  # 7148 bytes
% readelf -l a.bfd
...
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x00120 0x00120 R   0x4
  INTERP         0x000154 0x08048154 0x08048154 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x005dc 0x005dc R E 0x1000
  LOAD           0x000f04 0x08049f04 0x08049f04 0x00118 0x0011c RW  0x1000
  DYNAMIC        0x000f0c 0x08049f0c 0x08049f0c 0x000f0 0x000f0 RW  0x4
  NOTE           0x000168 0x08048168 0x08048168 0x00020 0x00020 R   0x4
  GNU_EH_FRAME   0x0004c8 0x080484c8 0x080484c8 0x00034 0x00034 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x000f04 0x08049f04 0x08049f04 0x000fc 0x000fc R   0x1

<span class="quote">> Note that given that we already support putting ro and rx together because of linker scripts, supporting the original feature might not be a big problem.</span >

After <a href="https://reviews.llvm.org/rLLD281978">https://reviews.llvm.org/rLLD281978</a>, we place R and RX sections in the RX
PT_LOAD (`singleRoRx = true;` in ScriptParser.cpp). I actually want to flip
this, to improve consistency with the non-linker script case, and to fix issues
like <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - option --no-rosegment always group RO with X sections."
   href="show_bug.cgi?id=38784">https://bugs.llvm.org/show_bug.cgi?id=38784</a>

People who want separate R PT_LOAD and RX PT_LOAD in linker script cases can
enable --no-rosegment.</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>