From e3bb6e11c3b8bf1141499577c51259a53a54e340 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 3 Jul 2013 04:23:36 +0200 Subject: [PATCH] v8: reapply floating patches --- deps/v8/src/platform-posix.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/deps/v8/src/platform-posix.cc b/deps/v8/src/platform-posix.cc index 9d3d7695f09..3aa8587cf4b 100644 --- a/deps/v8/src/platform-posix.cc +++ b/deps/v8/src/platform-posix.cc @@ -123,11 +123,26 @@ void* OS::GetRandomMmapAddr() { raw_addr &= V8_UINT64_C(0x3ffffffff000); #else uint32_t raw_addr = V8::RandomPrivate(isolate); + + raw_addr &= 0x3ffff000; + +# ifdef __sun + // For our Solaris/illumos mmap hint, we pick a random address in the bottom + // half of the top half of the address space (that is, the third quarter). + // Because we do not MAP_FIXED, this will be treated only as a hint -- the + // system will not fail to mmap() because something else happens to already + // be mapped at our random address. We deliberately set the hint high enough + // to get well above the system's break (that is, the heap); Solaris and + // illumos will try the hint and if that fails allocate as if there were + // no hint at all. The high hint prevents the break from getting hemmed in + // at low values, ceding half of the address space to the system heap. + raw_addr += 0x80000000; +# else // The range 0x20000000 - 0x60000000 is relatively unpopulated across a // variety of ASLR modes (PAE kernel, NX compat mode, etc) and on macos // 10.6 and 10.7. - raw_addr &= 0x3ffff000; raw_addr += 0x20000000; +# endif #endif return reinterpret_cast(raw_addr); }