Skip to content
  • Simon Marlow's avatar
    replace stgMallocBytesRWX() with our own allocator · e3c55aeb
    Simon Marlow authored
    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.
    e3c55aeb