[lld] r290986 - ELF: Round p_memsz of the PT_GNU_RELRO program header up to the page size.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 27 10:36:55 PST 2017
Ed Maste via llvm-commits <llvm-commits at lists.llvm.org> writes:
> On 4 January 2017 at 13:56, Peter Collingbourne via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>> Author: pcc
>> Date: Wed Jan 4 12:56:15 2017
>> New Revision: 290986
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=290986&view=rev
>> Log:
>> ELF: Round p_memsz of the PT_GNU_RELRO program header up to the page size.
>
> It turns out this introduces a bug on FreeBSD/arm64. The PT_GNU_RELRO
> header is rounded up to DefaultMaxPageSize of 64K, but with 4K pages
> we mprotect() several pages beyond the last segment, leading to a
> segfault when an allocation that happened in that region is changed to
> RO.
>
> We need to at least avoid applying this rounding when outputting
> objects for FreeBSD, but this same issue will apply anywhere the
> target supports multiple page sizes. Anyone know what page size(s)
> Linux/arm64 distros use?
Can you expand a bit on how this crashes? The first section after
PT_GNU_RELRO is also aligned to MaxPageSize:
if (Sec->PageAlign)
Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize);
So there should be no rw allocation in the area. What am I missing?
Cheers,
Rafael
More information about the llvm-commits
mailing list