[lld] r293674 - Port r293519 and r293529.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 10:38:56 PST 2017

Author: pcc
Date: Tue Jan 31 12:38:56 2017
New Revision: 293674

URL: http://llvm.org/viewvc/llvm-project?rev=293674&view=rev
Port r293519 and r293529.

    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

    Add missing aarch64 requirement.


Modified: lld/branches/release_40/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/ELF/Writer.cpp?rev=293674&r1=293673&r2=293674&view=diff
--- lld/branches/release_40/ELF/Writer.cpp (original)
+++ lld/branches/release_40/ELF/Writer.cpp Tue Jan 31 12:38:56 2017
@@ -1462,7 +1462,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/branches/release_40/test/ELF/aarch64-relro.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/test/ELF/aarch64-relro.s?rev=293674&view=auto
--- lld/branches/release_40/test/ELF/aarch64-relro.s (added)
+++ lld/branches/release_40/test/ELF/aarch64-relro.s Tue Jan 31 12:38:56 2017
@@ -0,0 +1,14 @@
+# REQUIRES: aarch64
+# 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

More information about the llvm-commits mailing list