This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Protection errors on Mac OS X 10.6 (Snow Leopard)


Abdulaziz Ghuloum wrote:
> 
> On Sep 7, 2009, at 11:49 AM, Andrew Haley wrote:
> 
> Hmm.  The documentation about FFI_MMAP_EXEC_WRIT says:
> 
> /* This macro indicates it may be forbidden to map anonymous memory
>    with both write and execute permission. [...]
> 
> This is not the situation under Snow Leopard.  Here, you *can*
> map anonymous memory with both write and execute permissions.
> It's just that you have to mmap it with the correct PROT flags
> (or mmap it first and mprotect it later).  So, you cannot use
> malloc (since the protection on malloced memory is READ|WRITE)
> but you can use mmap without needing to do all of:
> 
>                                       [...] Code compiled when this
>    option is defined will attempt to map such pages once, but if it
>    fails, it falls back to creating a temporary file in a writable and
>    executable filesystem and mapping pages from it into separate
>    locations in the virtual memory space, one location writable and
>    another executable. */

Sure, its overkill, but it'll still work.

>> Go into closures.c, find the definition of FFI_MMAP_EXEC_WRIT for
>> your system, and set it accordingly.
> 
> I can do that on my computer, yes.  But what about people who
> use my program that depends on libffi?  I cannot expect them to
> have to patch and recompile libffi just to use my program, right?

Try it.  If it works, we can check it in.  The alternative is to write
a bunch of special case code for Snow Leopard.  I'm happy either
way; your call.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]