Search code examples
iosxcode4.3xcodebuild

How can I tell if a iPhone binary has been compiled as a Position Independent Executable


I have an automated build process which compiles a iPhone app using a combination of xcodebuild and xcrun. When the build calls xcodebuild it passes in a xcconfig file which overrides certain settings.

IPHONEOS_DEPLOYMENT_TARGET = 4.3

ARCHS = armv7

VALID_ARCHS = armv7

LD_NO_PIE = NO

In theory this should ensure that the binary output from the build is a Position Independent Executable. Is there any way to examine the Binary to see if this is actually the case?


Solution

  • With "otool -vh" you can see the "PIE" flag:

    $ otool -vh YourApp
    YourApp:
    Mach header
          magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
       MH_MAGIC     ARM         V7  0x00     EXECUTE    28       3532   NOUNDEFS DYLDLINK TWOLEVEL PIE