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
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);
}
}
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);
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,
#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
}