[LLVMdev] How will OrcJIT guarantee thread-safety when a function is asked to be re generated?

Stephen Checkoway s at pahtak.org
Fri Mar 20 14:48:48 PDT 2015


On Mar 17, 2015, at 12:13 PM, David Blaikie <dblaikie at gmail.com> wrote:

> I think on MacOS, the way page permissions work, this would be impossible - once a memory page is marked executable, it's no longer writable and can't be set back - you need a new page

I couldn't reproduce that behavior. I just wrote a small program to

1. mmap one page read/write,
2. write mov eax, 0x12345678; ret to it,
3. mprotect it to read/exec,
4. call the instructions and print the result,
5. mprotect it to read/write,
6. change 0x12345678 to 0x55aa,
7. mprotect it to read/exec, and
8. call the instructions and print the result.

steve$ ./a.out
0x12345678
0x55aa

I just tested this on OS X 10.9.5 and 10.10.1.

-- 
Stephen Checkoway



-------------- next part --------------
A non-text attachment was scrubbed...
Name: a.c
Type: application/octet-stream
Size: 806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150320/170eceb4/attachment.obj>
-------------- next part --------------



More information about the llvm-dev mailing list