Commit 3d513faa authored by Alex Brainman's avatar Alex Brainman

runtime: do not mark os memory as executable on windows

Resubmit 3c2cddfbdaec now that windows callbacks
are not generated during runtime.

Fixes #5494

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/10487043
parent 05cf6fe0
...@@ -13,7 +13,7 @@ enum { ...@@ -13,7 +13,7 @@ enum {
MEM_RESERVE = 0x2000, MEM_RESERVE = 0x2000,
MEM_RELEASE = 0x8000, MEM_RELEASE = 0x8000,
PAGE_EXECUTE_READWRITE = 0x40, PAGE_READWRITE = 0x0004,
}; };
#pragma dynimport runtime·VirtualAlloc VirtualAlloc "kernel32.dll" #pragma dynimport runtime·VirtualAlloc VirtualAlloc "kernel32.dll"
...@@ -25,7 +25,7 @@ void* ...@@ -25,7 +25,7 @@ void*
runtime·SysAlloc(uintptr n) runtime·SysAlloc(uintptr n)
{ {
mstats.sys += n; mstats.sys += n;
return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)(MEM_COMMIT|MEM_RESERVE), (uintptr)PAGE_EXECUTE_READWRITE); return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)(MEM_COMMIT|MEM_RESERVE), (uintptr)PAGE_READWRITE);
} }
void void
...@@ -51,12 +51,12 @@ runtime·SysReserve(void *v, uintptr n) ...@@ -51,12 +51,12 @@ runtime·SysReserve(void *v, uintptr n)
{ {
// v is just a hint. // v is just a hint.
// First try at v. // First try at v.
v = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_EXECUTE_READWRITE); v = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_READWRITE);
if(v != nil) if(v != nil)
return v; return v;
// Next let the kernel choose the address. // Next let the kernel choose the address.
return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_EXECUTE_READWRITE); return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_READWRITE);
} }
void void
...@@ -65,7 +65,7 @@ runtime·SysMap(void *v, uintptr n) ...@@ -65,7 +65,7 @@ runtime·SysMap(void *v, uintptr n)
void *p; void *p;
mstats.sys += n; mstats.sys += n;
p = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_COMMIT, (uintptr)PAGE_EXECUTE_READWRITE); p = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_COMMIT, (uintptr)PAGE_READWRITE);
if(p != v) if(p != v)
runtime·throw("runtime: cannot map pages in arena address space"); runtime·throw("runtime: cannot map pages in arena address space");
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment