[PATCH] D36256: [ELF] Don't output headers into a segment if there's no space for them

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 17:59:33 PDT 2017


phosek created this revision.
phosek added a project: lld.
Herald added a subscriber: emaste.

Currently, LLD checks whether there's enough space for headers by
checking if headers fit below the address of the first allocated
section. However, that's always thue if the binary doesn't start
at zero which means that LLD always emits a segment for headers,
even if no other sections belong to that segment.

This is a problem in cases when linker script is being used with a
non-zero start address when we don't want to make the headers visible
by not leaving enough space for them. This pattern is common in
embedded programming but doesn't work in LLD.

This patch changes the behavior of LLD in case when linker script
is being to match the behavior of BFD ld and gold, which is to only
place headers into a segment when they're covered by some output
section.


Repository:
  rL LLVM

https://reviews.llvm.org/D36256

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/at-addr.s
  test/ELF/linkerscript/at.s
  test/ELF/linkerscript/header-addr.s
  test/ELF/linkerscript/phdr-check.s
  test/ELF/linkerscript/segment-headers.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36256.109468.patch
Type: text/x-patch
Size: 7216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170803/4de0b721/attachment.bin>


More information about the llvm-commits mailing list