[PATCH] D67481: [ELF] Add -z separate-segments to complement separate-code and noseparate-code

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 01:16:17 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: grimar, jakehehrlich, mcgrathr, peter.smith, phosek, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

D64906 <https://reviews.llvm.org/D64906> allows PT_LOAD to have overlapping p_offset ranges. In the
default R RX RW RW layout + -z noseparate-code case, we do not tail pad
segments when transiting to another segment. This can save at most
3*maxPageSize bytes.

a) Before D64906 <https://reviews.llvm.org/D64906>, we tail pad R, RX and the first RW.
b) With -z separate-code, we tail pad R and RX, but not the first RW (RELRO).

In some cases, b) saves one file page. In some cases, b) wastes one
virtual memory page. The waste is a concern on Fuchsia. Because it uses
compressed binaries, it doesn't benefit from the saved file page.

This patch adds -z separate-segments to restore the behavior before
D64906 <https://reviews.llvm.org/D64906>. It can affect section addresses and can thus be used as a
debugging mechanism (see PR43214 and ld.so partition bug in
crbug.com/998712).


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D67481

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Writer.cpp
  test/ELF/fill-trap.s
  test/ELF/separate-segments.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67481.219854.patch
Type: text/x-patch
Size: 7624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190912/823ea722/attachment.bin>


More information about the llvm-commits mailing list