diff options
Diffstat (limited to 'rts/Linker.c')
-rw-r--r-- | rts/Linker.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/rts/Linker.c b/rts/Linker.c index eebde2a799..c84cfe27ba 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -1021,7 +1021,38 @@ resolveSymbolAddr (pathchar* buffer, int size, #endif /* OBJFORMAT_PEi386 */ } -#if RTS_LINKER_USE_MMAP +#if defined(mingw32_HOST_OS) + +// +// Returns NULL on failure. +// +void * +mmapAnonForLinker (size_t bytes) +{ + return VirtualAlloc(NULL, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); +} + +void +munmapForLinker (void *addr, size_t bytes, const char *caller) +{ + if (VirtualFree(addr, 0, MEM_RELEASE) == 0) { + sysErrorBelch("munmapForLinker: %s: Failed to unmap %zd bytes at %p", + caller, bytes, addr); + } +} + +void +mmapForLinkerMarkExecutable(void *start, size_t len) +{ + DWORD old; + if (VirtualProtect(start, len, PAGE_EXECUTE_READ, &old) == 0) { + sysErrorBelch("mmapForLinkerMarkExecutable: failed to protect %zd bytes at %p", + len, start); + ASSERT(false); + } +} + +#elif RTS_LINKER_USE_MMAP // // Returns NULL on failure. // |