From 01c39159f30d7b4746a64918e5bc66589154fd50 Mon Sep 17 00:00:00 2001 From: "machenbach@chromium.org" Date: Thu, 18 Jul 2013 12:18:35 +0000 Subject: [PATCH] Fix NaCl regression caused by pepper revision 28. Patch from bradchen@chromium.org. Prevents use of PROT_EXEC for NaCl builds R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/19729003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15744 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/deoptimizer.cc | 6 ++++++ src/platform-linux.cc | 12 ++++++++++++ src/platform-posix.cc | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc index 5f59fd9..4284950 100644 --- a/src/deoptimizer.cc +++ b/src/deoptimizer.cc @@ -43,7 +43,13 @@ namespace internal { static MemoryChunk* AllocateCodeChunk(MemoryAllocator* allocator) { return allocator->AllocateChunk(Deoptimizer::GetMaxDeoptTableSize(), OS::CommitPageSize(), +#if defined(__native_client__) + // The Native Client port of V8 uses an interpreter, + // so code pages don't need PROT_EXEC. + NOT_EXECUTABLE, +#else EXECUTABLE, +#endif NULL); } diff --git a/src/platform-linux.cc b/src/platform-linux.cc index ace4056..613d243 100644 --- a/src/platform-linux.cc +++ b/src/platform-linux.cc @@ -594,7 +594,13 @@ void OS::SignalCodeMovingGC() { } void* addr = mmap(OS::GetRandomMmapAddr(), size, +#if defined(__native_client__) + // The Native Client port of V8 uses an interpreter, + // so code pages don't need PROT_EXEC. + PROT_READ, +#else PROT_READ | PROT_EXEC, +#endif MAP_PRIVATE, fileno(f), 0); @@ -717,7 +723,13 @@ void* VirtualMemory::ReserveRegion(size_t size) { bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { +#if defined(__native_client__) + // The Native Client port of V8 uses an interpreter, + // so code pages don't need PROT_EXEC. + int prot = PROT_READ | PROT_WRITE; +#else int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); +#endif if (MAP_FAILED == mmap(base, size, prot, diff --git a/src/platform-posix.cc b/src/platform-posix.cc index bd8a33f..9d3d769 100644 --- a/src/platform-posix.cc +++ b/src/platform-posix.cc @@ -84,7 +84,13 @@ intptr_t OS::CommitPageSize() { #ifndef __CYGWIN__ // Get rid of writable permission on code allocations. void OS::ProtectCode(void* address, const size_t size) { +#if defined(__native_client__) + // The Native Client port of V8 uses an interpreter, so + // code pages don't need PROT_EXEC. + mprotect(address, size, PROT_READ); +#else mprotect(address, size, PROT_READ | PROT_EXEC); +#endif } -- 2.7.4