Recent Posts

The Basics of Mach-O files



THe primary executable file format in MacOS is the Mach-O file format. Almost every program that runs on a Mac computer is a Mach-O file, including applications that are downloaded from the App Store. Today we will learn how these files are organized.

Like so many other file formats, Mach-O files start with a header. This header contains different information about the file, including the type of processor, the number of Load Commands, and the total size of the Load Commands. The format of this header is typical, except for one fact: The byte order matches the byte order of the processor. That means, that the integers are little-endian on Intel processors and big-endian on PowerPC processors. That includes the magic number as well. The structure of the header for 32-bit architectures in C-Syntax is:

MacOS Universal Binaries



Apple made a daring move a few years ago: they changed their laptops and computers from Intel x86_64 processors to ARM Processors. Processor architecture changes are difficult to make; Every program that has to run on the computer must be recompiled for the new architecture. This process is enough work for just the first-party programs, but third-party developers are notoriously slow. It can take a long time before third-party programs work on the new architecture. And users hate it, when their programs no longer work after a simple computer upgrade.

But Apple has made this move before. Apple used to equip their computers with PowerPC processors, but from 2005 to 2006 they switched them to Intel processors. Because of this, Apple has a few tricks up their sleeves this time. One of them is "Universal Binaries", binaries, that can run on more than one architecture. Most binaries can only run on one architecture, so these are impressive. Let's see how they work.

Select a language:

Switch to English LanguageSwitch to German Language