[PATCH] D28267: ELF: Round p_memsz of the PT_GNU_RELRO program header up to the page size.
Ed Maste via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 3 19:00:57 PST 2017
emaste added inline comments.
================
Comment at: lld/ELF/Writer.cpp:1452-1453
P.p_align = 1;
+ // The glibc dynamic loader rounds the size down, so we need to round up
+ // to protect the last page.
+ P.p_memsz = alignTo(P.p_memsz, Config->MaxPageSize);
----------------
For reference the FreeBSD rtld algorithm is:
```
obj->relro_page = obj->relocbase + trunc_page(ph->p_vaddr);
obj->relro_size = round_page(ph->p_memsz);
```
https://svnweb.freebsd.org/base/head/libexec/rtld-elf/rtld.c?annotate=310422#l1334
https://reviews.llvm.org/D28267
More information about the llvm-commits
mailing list