World Library  
Flag as Inappropriate
Email this Article

Mach-O

 

Mach-O

Mach-O
Mac OS X Executable Binary icon
Filename extension none, .o, .dylib, .bundle
Uniform Type Identifier (UTI) com.apple.mach-o-binary
Developed by Carnegie Mellon University/Apple Inc.
Type of format Binary, executable, object, shared libraries, core dump
Container for ARM, SPARC, PA-RISC, PowerPC and x86 executable code, memory image dumps

Mach-O, short for Mach object file format, is a file format for executables, object code, shared libraries, dynamically-loaded code, and core dumps. A replacement for the a.out format, Mach-O offers more extensibility and faster access to information in the symbol table.

Mach-O is used by most systems based on the Mach kernel. NeXTSTEP, OS X, and iOS are examples of systems that have used this format for native executables, libraries and object code.

Contents

  • Mach-O file layout 1
  • Multi-architecture binaries 2
  • Minimum Mac OS X version 3
  • Other implementations 4
  • See also 5
  • References 6
  • External links 7

Mach-O file layout

Each Mach-O file is made up of one Mach-O header, followed by a series of load commands, followed by one or more segments, each of which contains between 0 and 255 sections. Mach-O uses the REL relocation format to handle references to symbols. When looking up symbols Mach-O uses a two-level namespace that encodes each symbol into an 'object/symbol name' pair that is then linearly searched for by first the object and then the symbol name.[1]

The basic structure—a list of variable-length "load commands" that reference pages of data elsewhere in the file[2]—was also used in the executable file format for Accent. The Accent file format was in turn, based on an idea from Spice Lisp.

Multi-architecture binaries

Under NeXTSTEP, OPENSTEP, OS X, and iOS, multiple Mach-O files can be combined in a multi-architecture binary. This allows a single binary file to contain code to support multiple instruction set architectures. For example, a multi-architecture binary for iOS can have 6 instruction set architectures, namely ARMv6 (for iPhone, 3G and 1st / 2nd generation iPod touch), ARMv7 (for iPhone 3GS, 4, 4S, iPad, 2, 3rd generation and 3rd - 5th generation iPod touch), ARMv7s (for iPhone 5 and iPad (4th generation)), ARMv8 (for iPhone 5S), x86 (for iPhone simulator on 32-bit machines) and x86_64 (64-bit simulator)

Minimum Mac OS X version

With the introduction of Apple's Mac OS X 10.6 platform the Mach-O file has undergone a significant modification that causes binaries compiled on a computer running 10.6 or later to be (by default) executable only on computers running OS X 10.6 or later. The difference stems from load commands that Mac OS X's dynamic linker, in previous Mac OS X versions, does not understand. Another significant change to the Mach-O format is the change in how the Link Edit tables (found in the __LINKEDIT section) function. In 10.6 these new Link Edit tables are compressed by removing unused and unneeded bits of information, however Mac OS X 10.5 and earlier cannot read this new Link Edit table format. To make backwards-compatible executables, the linker flag "-mmacosx-version-min=" can be used.

Other implementations

Some versions of NetBSD have had Mach-O support added as part of an implementation of binary compatibility, which allowed some Mac OS 10.3 binaries to be executed.[3][4]

For Linux, a Mach-O loader was written by Shinichiro Hamaji[5] that can load 10.6 binaries. As a more extensive solution based on this loader, The Darling Project aims at providing a complete environment allowing to run OS X applications on Linux.

See also

References

  1. ^ "OS X ABI Mach-O File Format Reference". Apple Inc. 
  2. ^ Avadis Tevanian, Jr.; Richard F. Rashid; Michael W. Young; David B. Golub; Mary R. Thompson; William Bolosky; Richard Sanzi. "A Unix Interface for Shared Memory and Memory Mapped Files Under Mach". p. 8. 
  3. ^ Emmanuel Dreyfus (June 20, 2006). ] for NetBSD/powerpc and NetBSD/i386."sic"Mach and Darwin binary compatiblity [. Retrieved October 18, 2013. 
  4. ^ Emmanuel Dreyfus (September 2004), Mac OS X binary compatibility on NetBSD: challenges and implementation (PDF) 
  5. ^ Shinichiro Hamaji, Mach-O loader for Linux - I wrote... 

External links

  • OS X ABI Mach-O File Format Reference (Apple Inc.)
  •  – Darwin and Mac OS X File Formats Manual
  • Mach Object Files (NEXTSTEP documentation)
  • Mach-O Dynamic Library Reference
  • MachOView
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.