[PATCH] D64906: [ELF][PPC] Allow PT_LOAD to have overlapping p_offset ranges

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 19:50:22 PDT 2019


MaskRay added a comment.

In D64906#1711802 <https://reviews.llvm.org/D64906#1711802>, @troyj wrote:

> >   p->p_memsz = alignTo(p->p_offset + p->p_memsz, config->commonPageSize) - p->p_offset;
>
> I think the whole rounding step is questionable, not simply this change to it.  As far as I can tell from researching this, the rounding down that occurs is for the starting address to place RELRO on a page boundary.  The size of RELRO does not get rounded down, so rounding it up here by any amount risks making more data read-only than is necessary, which can lead to seg faults.




  p->p_memsz = alignTo(p->p_offset + p->p_memsz, config->commonPageSize) -
               p->p_offset;

is necessary. In GNU ld, the last page of RELRO may not be protected as documented. To make that page protected on all of glibc/musl/FreeBSD libc, the change like https://reviews.llvm.org/D28267 is needed. Please also read https://reviews.llvm.org/D64906#1592854

If you cannot use -z norelro, you may try -z separate-code or -z separate-loadable-segments (D67481 <https://reviews.llvm.org/D67481>)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64906





More information about the llvm-commits mailing list