<div dir="ltr">Hi Will,<div><br><div>ld.gold and ld.bfd seem handle PHDR and INTERP as executable segments. That's why they use only one page for PHDR, INTERP and the first executable page.<div><br></div><div>lld on the other hand handles them as non-executable segments, as they are not really executable code. I think what lld does is more desirable.</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 22, 2017 at 2:01 PM, Will Song via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
<br>
The lld linker appears to generate extra ELF program headers and thus<br>
causes file sizes to be significantly larger than what would get with<br>
ld.gold or ld.bfd.<br>
<br>
# readelf -l test.bfd<br>
<br>
Elf file type is EXEC (Executable file)<br>
Entry point 0x4000b0<br>
There are 2 program headers, starting at offset 64<br>
<br>
Program Headers:<br>
  Type           Offset             VirtAddr           PhysAddr<br>
                 FileSiz            MemSiz              Flags  Align<br>
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000<br>
                 0x00000000000000c0 0x00000000000000c0  R E    0x200000<br>
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000<br>
                 0x0000000000000000 0x0000000000000000  RW     0x10<br>
<br>
 Section to Segment mapping:<br>
  Segment Sections...<br>
   00     .text<br>
   01<br>
# readelf -l test.gold<br>
<br>
Elf file type is EXEC (Executable file)<br>
Entry point 0x4000b0<br>
There are 2 program headers, starting at offset 64<br>
<br>
Program Headers:<br>
  Type           Offset             VirtAddr           PhysAddr<br>
                 FileSiz            MemSiz              Flags  Align<br>
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000<br>
                 0x00000000000000c0 0x00000000000000c0  R E    0x1000<br>
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000<br>
                 0x0000000000000000 0x0000000000000000  RW     0x10<br>
<br>
 Section to Segment mapping:<br>
  Segment Sections...<br>
   00     .text<br>
   01<br>
# readelf -l test.lld<br>
<br>
Elf file type is EXEC (Executable file)<br>
Entry point 0x201000<br>
There are 4 program headers, starting at offset 64<br>
<br>
Program Headers:<br>
  Type           Offset             VirtAddr           PhysAddr<br>
                 FileSiz            MemSiz              Flags  Align<br>
  PHDR           0x0000000000000040 0x0000000000200040 0x0000000000200040<br>
                 0x00000000000000e0 0x00000000000000e0  R      0x8<br>
  LOAD           0x0000000000000000 0x0000000000200000 0x0000000000200000<br>
                 0x0000000000000120 0x0000000000000120  R      0x1000<br>
  LOAD           0x0000000000001000 0x0000000000201000 0x0000000000201000<br>
                 0x0000000000000010 0x0000000000000010  R E    0x1000<br>
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000<br>
                 0x0000000000000000 0x0000000000000000  RW     0x0<br>
<br>
 Section to Segment mapping:<br>
  Segment Sections...<br>
   00<br>
   01<br>
   02     .text<br>
   03<br>
<br>
Now obviously disk space is relatively cheap these days but if it could<br>
be avoided, can we avoid generating these unused memory mappings unless<br>
a PT_INTERP section is going to be generated? I could also be<br>
misunderstanding things, and it might be normal to map the program's<br>
program headers into memory (and thus the entire ELF header).<br>
<br>
Thanks.<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>