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: