[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
Tue Jan 3 19:09:16 PST 2017
pcc updated this revision to Diff 82992.
pcc added a comment.
- Add a note about FreeBSD
https://reviews.llvm.org/D28267
Files:
lld/ELF/Writer.cpp
lld/test/ELF/basic-mips.s
lld/test/ELF/basic-ppc.s
Index: lld/test/ELF/basic-ppc.s
===================================================================
--- lld/test/ELF/basic-ppc.s
+++ lld/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/test/ELF/basic-mips.s
===================================================================
--- lld/test/ELF/basic-mips.s
+++ lld/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: ]
Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -1447,8 +1447,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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28267.82992.patch
Type: text/x-patch
Size: 1632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170104/d09bd4e1/attachment.bin>
More information about the llvm-commits
mailing list