Correctly use ffi_closure_alloc(), fixing mmap permissions error
This restores the reverted-commit
ed8634d:
Author: Dan Winship <danw@gnome.org>
Date: Mon Apr 5 14:05:52 2010 -0400
g_callable_info_prepare_closure: handle mmap permissions error
When SELinux or similar is active, a process may not be able to mmap()
a segment that is both writable and executable, which would causing
g_callable_info_prepare_closure() to fail. Libffi has a workaround for
this problem though (it maps the same non-anonymous region twice, once
writable and once executable, and returns two separate pointers to
it), so use that.
But with an added fix, when using ffi_closure_alloc(), we need to use
ffi_prep_closure_loc() so we can pass in the executable address of the
trampoline separately from the writable address, rather than the
deprecated ffi_prep_closure().
https://bugzilla.gnome.org/show_bug.cgi?id=615105