summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2016-11-05 04:22:15 +0000
committerAlina Sbirlea <asbirlea@google.com>2016-11-05 04:22:15 +0000
commitf802c3f97527b843f118e1ce91a9281483f72448 (patch)
treed1e037fd84740bb5fa9017c76cecb8acf32743c6 /llvm/lib/Support/Unix
parenta2f12e0a7511ef0c1979a5b9258a1a0101ba4eb0 (diff)
downloadbcm5719-llvm-f802c3f97527b843f118e1ce91a9281483f72448.tar.gz
bcm5719-llvm-f802c3f97527b843f118e1ce91a9281483f72448.zip
Correct mprotect page boundries to round up end page. Fixes PR30905.
Summary: Update the boundries for mprotect. Patch by Andrew Adams. Fixes PR30905. Reviewers: loladiro, andrew.w.kaylor, chandlerc Subscribers: abadams, llvm-commits Differential Revision: https://reviews.llvm.org/D26312 llvm-svn: 286032
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/Memory.inc5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc
index 6bbaf509d81..edbc7938f0c 100644
--- a/llvm/lib/Support/Unix/Memory.inc
+++ b/llvm/lib/Support/Unix/Memory.inc
@@ -153,7 +153,10 @@ Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
int Protect = getPosixProtectionFlags(Flags);
- int Result = ::mprotect((void*)((uintptr_t)M.Address & ~(PageSize-1)), PageSize*((M.Size+PageSize-1)/PageSize), Protect);
+ uintptr_t Start = alignAddr((uint8_t *)M.Address - PageSize + 1, PageSize);
+ uintptr_t End = alignAddr((uint8_t *)M.Address + M.Size, PageSize);
+ int Result = ::mprotect((void *)Start, End - Start, Protect);
+
if (Result != 0)
return std::error_code(errno, std::generic_category());
OpenPOWER on IntegriCloud