Chromium Code Reviews| Index: src/platform-linux.cc |
| =================================================================== |
| --- src/platform-linux.cc (revision 8619) |
| +++ src/platform-linux.cc (working copy) |
| @@ -370,13 +370,16 @@ |
| // TODO(805): Port randomization of allocated executable memory to Linux. |
| const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); |
| int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| - void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
| + void* mbase = mmap(NULL, msize + Page::kPageSize, prot, |
|
Vyacheslav Egorov (Chromium)
2011/07/12 23:23:29
V8 uses "one argument per line" convention.
Cris Neckar
2011/07/14 17:32:28
Done.
|
| + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
| if (mbase == MAP_FAILED) { |
| LOG(i::Isolate::Current(), |
| StringEvent("OS::Allocate", "mmap failed")); |
| return NULL; |
| } |
| *allocated = msize; |
| + mprotect(mbase, Page::kPageSize, PROT_NONE); |
| + mbase += Page::kPageSize; |
|
Vyacheslav Egorov (Chromium)
2011/07/12 23:23:29
I am a bit concerned that we are spreading (and du
Cris Neckar
2011/07/14 17:32:28
Done.
|
| UpdateAllocatedSpaceLimits(mbase, msize); |
| return mbase; |
| } |
| @@ -384,7 +387,7 @@ |
| void OS::Free(void* address, const size_t size) { |
| // TODO(1240712): munmap has a return value which is ignored here. |
| - int result = munmap(address, size); |
| + int result = munmap(address - Page::kPageSize, size + Page::kPageSize); |
| USE(result); |
| ASSERT(result == 0); |
| } |