Ticket #7722 (closed feature request: fixed)
iOS patch no 11: Fix quirk with runtime loader
|Reported by:||StephenBlackheath||Owned by:|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||Blocked By:|
On iOS, due to a quirk, we must put references to external symbols into the data segment. If, for example, we have a declaration like this:
foreign import ccall unsafe "static stdlib.h &free" c_free_finalizer :: FunPtr (Ptr Word8 -> IO ())
...then it tries to resolve the address of 'free' at runtime. The loader then attempts to write that address into the text segment. On iOS, modifying the text segment is not allowed, and so a runtime exception is thrown.
We work around this issue by fetching the reference to the external symbol from the data segment.