I'm reversing few iOS Mach-O application executables these days and all of them use Position-independent code (PIC; the MH_PIC flag is set). I've been expecting a large number of relocation entries (just like with Windows PE or Android ELF) but all the executables contain zero relocations (well, at least the __text section I'm interested in).

The oficial docs say that this is because the segments are always located at a constant offset from each other and that makes sense to me.

However, can I take this for granted? Do all typical iOS applications contain no relocations because all the code and data are usually located in one binary (i. e., dynamic libraries are usually not used)?

1 Answer 1


The Mach-O format does support relocations but they appear rarely outside of the object files; usually linker does pretty good job using PIC addressing inside the final linked module. As for imports from other libraries on iOS, they don't use relocations anymore but special tables handled by the dynamic loader (dyld). I've described how they work previously. For even more gruesome details see dyld sources and inspect actual binaries.

  • (Thank for fast response, I upvoted your answer but it is not shown for some reason related to reputation or whatever...)
    – MazeGen
    May 2, 2017 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.