[PATCH] D64854: [ELF] Delete redundant pageAlign of the first section after PT_GNU_RELRO after D58892

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 01:53:19 PDT 2019


ruiu added a comment.

In D64854#1588988 <https://reviews.llvm.org/D64854#1588988>, @MaskRay wrote:

> In D64854#1588981 <https://reviews.llvm.org/D64854#1588981>, @ruiu wrote:
>
> > Could you explain what `ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1))` means? It looks like it aligns to the next multiple of MAXPAGESIZE (plus `(. & (CONSTANT (MAXPAGESIZE) - 1))`), so doesn't it consume a MAXPAGESIZE?
>
>
> Say, the end address of the last segment is 0x4001d8. The PT_LOAD covers the address range [0x400000, 0x4001d8) (at runtime, the end address will rounded up). Currently we set the address of the new segment to the next multiple of max-page-size: 0x600000. Due to the rule: p_offset/p_vaddr must be equal modulo maxpagesize, we have to set its p_offset to 0x600000.
>
> However, if we set the address of the new segment  to 0x6001d8, its p_offset can be kept as 0x4001d8. This saves 0x600000-0x4001d8 bytes. The PT_LOAD may cover [0x6001d8, 0x6002d8). At runtime, it will become [0x600000, 0x601000) if the actual page size is 0x1000. The address range [0x600000, 0x6002d8) (with file offsets: [0x400000,0x4002d8)) is **shared with** the previous PT_LOAD segment.
>
> In the BFD -z separate-code case (similar to our default case), they don't want code to be shared with adjacent PT_LOAD segments. So it is probably not desired to apply this trick to R-X. If, however, --no-segment is specified, we can apply the trick to R-X.


Thanks for the explanation. That optimization makes sense itself, but I'm not sure how often you want to use `--no-rosegment`. Is that frequently used?


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64854/new/

https://reviews.llvm.org/D64854





More information about the llvm-commits mailing list