[PATCH] D28267: ELF: Round p_memsz of the PT_GNU_RELRO program header up to the page size.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 4 11:07:13 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290986: ELF: Round p_memsz of the PT_GNU_RELRO program header up to the page size. (authored by pcc).
Changed prior to commit:
https://reviews.llvm.org/D28267?vs=82992&id=83088#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28267
Files:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/basic-mips.s
lld/trunk/test/ELF/basic-ppc.s
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1444,8 +1444,13 @@
}
if (P.p_type == PT_LOAD)
P.p_align = Config->MaxPageSize;
- else if (P.p_type == PT_GNU_RELRO)
+ else if (P.p_type == PT_GNU_RELRO) {
P.p_align = 1;
+ // 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);
+ }
// The TLS pointer goes after PT_TLS. At least glibc will align it,
// so round up the size to make sure the offsets are correct.
Index: lld/trunk/test/ELF/basic-ppc.s
===================================================================
--- lld/trunk/test/ELF/basic-ppc.s
+++ lld/trunk/test/ELF/basic-ppc.s
@@ -295,7 +295,7 @@
// CHECK-NEXT: VirtualAddress: 0x2000
// CHECK-NEXT: PhysicalAddress: 0x2000
// CHECK-NEXT: FileSize: 48
-// CHECK-NEXT: MemSize: 48
+// CHECK-NEXT: MemSize: 4096
// CHECK-NEXT: Flags [ (0x4)
// CHECK-NEXT: PF_R (0x4)
// CHECK-NEXT: ]
Index: lld/trunk/test/ELF/basic-mips.s
===================================================================
--- lld/trunk/test/ELF/basic-mips.s
+++ lld/trunk/test/ELF/basic-mips.s
@@ -297,7 +297,7 @@
# CHECK-NEXT: VirtualAddress: 0x30000
# CHECK-NEXT: PhysicalAddress: 0x30000
# CHECK-NEXT: FileSize: 8
-# CHECK-NEXT: MemSize: 8
+# CHECK-NEXT: MemSize: 65536
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28267.83088.patch
Type: text/x-patch
Size: 1686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170104/daf0bb8b/attachment.bin>
More information about the llvm-commits
mailing list