replace stgMallocBytesRWX() with our own allocator
authorSimon Marlow <simonmar@microsoft.com>
Tue, 30 May 2006 10:02:11 +0000 (10:02 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Tue, 30 May 2006 10:02:11 +0000 (10:02 +0000)
commite3c55aebd4f9ce7a5b4390d4726612865fd207f2
tree87a1e86bc77f2c1d8d4dba8757e14fce324fe736
parent6b36d8ad3bfd1890583f3bcab96559f05bff332b
replace stgMallocBytesRWX() with our own allocator

See bug #738

Allocating executable memory is getting more difficult these days.  In
particular, the default SELinux policy on Fedora Core 5 disallows
making the heap (i.e. malloc()'d memory) executable, although it does
apparently allow mmap()'ing anonymous executable memory by default.

Previously, stgMallocBytesRWX() used malloc() underneath, and then
tried to make the page holding the memory executable.  This was rather
hacky and fails with Fedora Core 5.

This patch adds a mini-allocator for executable memory, based on the
block allocator.  We grab page-sized blocks and make them executable,
then allocate small objects from the page.  There's a simple free
function, that will free whole pages back to the system when they are
empty.
includes/Block.h
includes/Storage.h
rts/Adjustor.c
rts/Linker.c
rts/OSMem.h [new file with mode: 0644]
rts/RtsUtils.c
rts/RtsUtils.h
rts/Storage.c
rts/posix/OSMem.c [new file with mode: 0644]
rts/win32/OSMem.c [new file with mode: 0644]