[lld] r293519 - ELF: Align RELRO to the target page size rather than the max page size.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 10:32:25 PST 2017


ruiu: OK to backport this to the 4.0 branch?

Peter

On Mon, Jan 30, 2017 at 10:20 AM, Peter Collingbourne via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: pcc
> Date: Mon Jan 30 12:20:07 2017
> New Revision: 293519
>
> URL: http://llvm.org/viewvc/llvm-project?rev=293519&view=rev
> Log:
> ELF: Align RELRO to the target page size rather than the max page size.
>
> If no bss sections appear after the relro segment, the loader will round
> the r/w segment size to the target's page size. Align the relro size in the
> same way to ensure that it does not extend past the end of the program's
> own memory region.
>
> Differential Revision: https://reviews.llvm.org/D29242
>
> Added:
>     lld/trunk/test/ELF/aarch64-relro.s
> Modified:
>     lld/trunk/ELF/Writer.cpp
>
> Modified: lld/trunk/ELF/Writer.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.
> cpp?rev=293519&r1=293518&r2=293519&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/Writer.cpp (original)
> +++ lld/trunk/ELF/Writer.cpp Mon Jan 30 12:20:07 2017
> @@ -1498,7 +1498,7 @@ template <class ELFT> void Writer<ELFT>:
>        // The glibc dynamic loader rounds the size down, so we need to
> round up
>        // to protect the last page. This is a no-op on FreeBSD which always
>        // rounds up.
> -      P.p_memsz = alignTo(P.p_memsz, Config->MaxPageSize);
> +      P.p_memsz = alignTo(P.p_memsz, Target->PageSize);
>      }
>
>      // The TLS pointer goes after PT_TLS. At least glibc will align it,
>
> Added: lld/trunk/test/ELF/aarch64-relro.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> aarch64-relro.s?rev=293519&view=auto
> ============================================================
> ==================
> --- lld/trunk/test/ELF/aarch64-relro.s (added)
> +++ lld/trunk/test/ELF/aarch64-relro.s Mon Jan 30 12:20:07 2017
> @@ -0,0 +1,13 @@
> +# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %t
> +# RUN: ld.lld %t -o %t2
> +# RUN: llvm-readobj -program-headers %t2 | FileCheck %s
> +
> +# CHECK:      Type: PT_GNU_RELRO
> +# CHECK-NEXT: Offset:
> +# CHECK-NEXT: VirtualAddress:
> +# CHECK-NEXT: PhysicalAddress:
> +# CHECK-NEXT: FileSize:
> +# CHECK-NEXT: MemSize: 4096
> +
> +.section .data.rel.ro,"aw",%progbits
> +.byte 1
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>



-- 
-- 
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170130/6dea09f1/attachment.html>


More information about the llvm-commits mailing list