[llvm-bugs] [Bug 30415] lld has different section attribute merging vs ld.bfd

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 25 22:24:07 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=30415

Fangrui Song <i at maskray.me> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |i at maskray.me

--- Comment #8 from Fangrui Song <i at maskray.me> ---
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

> 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.

After https://reviews.llvm.org/rLLD281978, 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 https://bugs.llvm.org/show_bug.cgi?id=38784

People who want separate R PT_LOAD and RX PT_LOAD in linker script cases can
enable --no-rosegment.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190726/82bfbef6/attachment.html>


More information about the llvm-bugs mailing list