This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question about libffi closure
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jeff Sturm <jsturm at one-point dot com>
- Cc: Andreas Jaeger <aj at suse dot de>, Andrew Haley <aph at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Wed, 19 Nov 2003 22:29:39 +0100
- Subject: Re: Question about libffi closure
- References: <u84qx0gl4i.fsf@gromit.moeb> <Pine.LNX.4.44.0311191539180.4349-100000@ops2.one-point.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Nov 19, 2003 at 03:40:32PM -0500, Jeff Sturm wrote:
> On Wed, 19 Nov 2003, Andreas Jaeger wrote:
> > So, how shall we fix the testsuite?
> >
> > Should we do instead of:
> >
> > static ffi_closure cl;
> > ffi_closure *pcl = &cl;
> >
> > use:
> > ffi_closure *pcl;
> >
> > pcl = mmap (NULL, sizeof(ffi_closure), PROT_READ|PROT_EXEC,
> > MAP_PRIVATE|MAP_ANONYMOUS, fd, 0);
>
> mprotect might be easier, and can be preprocessed out wherever it isn't
> supported.
mmap with PROT_EXEC is certainly preferrable, unless you call mprotect
on something you've allocated with mmap yourself.
You can very easily write various methods of allocating
executable chunk of memory depending on preprocessor macros,
using mprotect wouldn't make this much easier.
Jakub