Skip to main content

Mach-O header analysis and editing

Project description

macholib can be used to analyze and edit Mach-O headers, the executable format used by Mac OS X.

It’s typically used as a dependency analysis tool, and also to rewrite dylib references in Mach-O headers to be @executable_path relative.

Though this tool targets a platform specific file format, it is pure python code that is platform and endian independent.

Release history

macholib 1.5

macholib 1.5 is a minor feature release

  • No longer use 2to3 to provide Python 3 support

    As a side-effect of this macholib no longer supports Python 2.5 and earlier.

  • Adds suppport for some new macho load commands

  • Fix for py3k problem in

    Patch by Guanqun Lu.

  • Fix for some issues in

    Patch by Nam Nguyen

  • Issue #10: Fix for LC_DATA_IN_CODE linker commands, without this fix py2app cannot build application bundles when the source binaries have been compiled with Xcode 4.5.

  • Issue #6: Fix for LC_ENCRYPTION_INFO linker commands

  • Use the mach header information to print the cpu type of a binary, instead of trying to deduce that from pointer width and endianness.

    Changed the code because of issue #6, in which a user tries to dump a iOS binary which results in bogus output in the previous releases.

  • The mapping macholib.macho_dump.ARCH_MAP is undocumented and no longer used by macholib itself. It will be removed in the next release.

  • The command-line tools macho_find, macho_dump and macho_standalone are deprecated. Use “python -mmacholib” instead. That is:

    $ python -mmacholib dump /usr/bin/grep
    $ python -mmacholib find ~
    $ python -mmacholib standalone

    This makes it clearer which version of the tools are used.

macholib 1.4.3

macholib 1.4.3 is a minor feature release

  • Added strings for ‘x86_64’ and ‘ppc64’ to macholib.mach_o.CPU_TYPE_NAMES.

  • macho_find and macho_dump were broken in the 1.4.2 release

  • added ‘macholib.util.NOT_SYSTEM_FILES’, a list of files that aren’t system path’s even though they are located in system locations.

    Needed to work around a bug in PySide (see issue #32 in the py2app tracker)

macholib 1.4.2

macholib 1.4.2 is a minor bugfix release

  • The support for new load commands that was added in 1.4.1 contained a typo that caused problems on OSX 10.7 (Lion).

macholib 1.4.1

macholib 1.4.1 is a minor feature release


  • Add support for a number of new MachO load commands that were added during the lifetime of OSX 10.6: LC_LOAD_UPWARD_DYLIB, LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS and LC_FUNCTION_STARTS.

macholib 1.4

macholib 1.4 is a feature release


  • Documentation is now generated using sphinx and can be viewed at <>.

  • The repository has moved to bitbucket

  • There now is a testsuite

  • Private functionality inside modules was renamed to a name starting with an underscore.


    if this change affects your code you are relying on undefined implementation features, please stop using private functions.

  • The basic packable types in macholib.ptypes were renamed to better represent the corresponding C type. The table below lists the old an new names (the old names are still available, but are deprecated and will be removed in a future release).

    Old name New name
    p_byte p_int8
    p_ubyte p_uint8
    p_short p_int16
    p_ushort p_uint16
    p_int p_int32
    p_uint p_uint32
    p_long p_int32
    p_ulong p_uint32
    p_longlong p_int64
    p_ulonglong p_uint64

    Macholib.ptypes.p_ptr is no longer present as it had an unclear definition and isn’t actually used in the codebase.

Bug fixes:

  • The semantics of dyld.dyld_default_search were changed a bit, it now first searches the framework path (if appropriate) and then the linker path, irrespective of the value of the DYLD_FALLBACK* environment variables.

    Previous versions would change the search order when those variables was set, which is odd and doesn’t correspond with the documented behaviour of the system dyld.

  • It is once again possible to install using python2.5

  • The source distribution includes all files, this was broken due to the switch to mercurial (which confused setuptools)

macholib 1.3

macholib 1.3 is a feature release.


  • Experimental Python 3.x support

    This version contains lightly tested support for Python 3.

macholib 1.2.2

macholib 1.2.2 is a bugfix release.

Bug fixes:

  • Macholib should work better with 64-bit code (patch by Marc-Antoine Parent)

Project details

Release history Release notifications

History Node


History Node


History Node


History Node


History Node


This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
macholib-1.5.tar.gz (439.0 kB) Copy SHA256 hash SHA256 Source None Oct 22, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page