Contents

Introduction

Explains the use of the OS X runtime architecture, including program types, loading and executing code, and using libraries and plug-ins.

Who Should Read This Document

If you write development tools for OS X, you need to understand the information presented in this document.

This document is also useful for developers of shared libraries and frameworks, and for developers of applications that need to load code at runtime.

Organization of This Document

This document contains the following articles:

Building Mach-O Files describes how Mac apps are built and describes the types of programs you can develop.

Executing Mach-O Files provides an overview of the OS X dynamic loading process.

Loading Code at Runtime describes how to use shared libraries and frameworks and how to load plug-ins at runtime.

Indirect Addressing explains how a Mach-O file refers to symbols defined in another Mach-O file.

Position-Independent Code discusses the method by which the dynamic linker loads a region of code at a non-fixed virtual memory address.

x86-64 Code Model describes differences in the OS X x86-64 user-space code model from the System V x86-64 code model.

This document also contains a revision history and an index.

See Also

You can access full reference documentation for the standard command-line development tools using the man tool on the command line, or by choosing Open Man Page from the Xcode Help menu.

This document provides information on the Mach-O runtime architecture. It does not address the following:

Descriptions of the data structures that make up a Mach-O file. You can find this information in <!--a target="_self" -->OS X ABI Mach-O File Format Reference<!--/a--> .

If you are loading code at runtime but cannot or do not wish to use the CFBundle opaque type or the NSBundle class, you should refer to <!--a target="_self" -->OS X ABI Dynamic Loader Reference<!--/a--> .

The GCC C++ application binary interface—the specification of C++ class member layout, function/method name mangling, and related C++ issues. This information is documented for GCC 3.0 and later at http://www.codesourcery.com/cxx-abi/abi.html .

The GCC Objective-C data structures and dynamic runtime functions. For this information, see The Objective-C Programming Language .

The runtime environment of the OS X kernel, Darwin. See Mac Technology Overview for more information.

Source code from the Darwin project can be downloaded from http://developer.apple.com/darwin/ .

You might also find the following books useful in conjunction with this document:

Mac OS Runtime Architectures , Apple Computer, Inc. Available at http://developer.apple.com/tools/mpw-tools/books.html . Documents the classic 68K segment loader architecture, as well as the Code Fragment Manager Preferred Executable executable format used with classic PowerPC applications and with many Carbon applications.

Linkers and Loaders , John R. Levine, Morgan Kaufmann, 2000, ISBN 1-55860-496-0. Describes the workings and operation of standard linkers from the earliest program loaders to the present dynamic link editors. Among the contents of this book are discussions of the classic BSD a.out format, the Executable and Linking Format (ELF) preferred by many current operating systems, the IBM System/360 linker output format, and the Microsoft Portable Executable (PE) format.

System V Application Binary Interface AMD64 Architecture Processor Supplement . Found at http://www.x86-64.org/documentation , this document describes the System V x86-64 environment, on which the OS X x86-64 environment is based.

Next

Copyright © 2003, 2009 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2009-02-04