rentzsch/mach_override — pull request #17 by noahd (2014-05-15 14:59:35+00:00)
Title: Add support for relative call instructions in reentry island

Currently, the `fixupInstructions` function only relocates relative jump offsets and nothing else. This causes segfaults when calling the reentry islands of functions that contain relative *call* instructions in their first 5 bytes.

If you're looking for a concrete example, check out the `PKGSpaceGet*` functions in CoreGraphics (they're only used in WindowServer and aren't exported, FYI):
![pkgspacegetname](https://cloud.githubusercontent.com/assets/4801634/2985735/4c7a1dbc-dc3e-11e3-8536-10e7343eb712.png)

---------------

There are other types of instructions with relative offsets that also cause segfaults in reentry islands*, but I honestly don't feel adept enough at the moment to write a general solution, so I left it at that.

\* Compiling `test_mach_override.cp` with clang yields crashes, for instance. I'm assuming that happens because the nops in `localFunction()` get optimized away and the relative load instruction for `__FUNCTION__` is copied as-is.