Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

Macintosh C/C++ ABI Overview


Introduction

An ABI is an "application binary interface" and describes binary-level conventions for applications running on a particular system. An ABI establishes conventions for such things as register usage, parameter passing, and layout of data. Typically, these conventions are embodied in development tools, particularly compilers. Assembly-level programmers must be aware explicitly of these conventions, especially if they wish to interface their assembly code with code produced by a compiler.

The primary goals of an ABI are:

  1. To establish machine-level runtime conventions for a processor family.
  2. To ensure object code compatibility between compilers for a platform.

While it is possible for programs to depart from the conventions of an ABI, particularly within isolated sections of a program (such as sections of hand-crafted assembly code), conformance to the ABI is often required to make use of system-level code and code produced by other compilers. To the extent that a program is monolithic and is built with the same set of tools conformance to the ABI is only an issue when the program interfaces with the system. To the extent that a program is made up of (or accesses) components which may have been built with other tools conformance to the ABI is more critical.

The C++ language poses special ABI problems. While the C language relies on a few well-established ABI conventions, the object-oriented features of C++ require new runtime architecture and conventions, such as v-tables and name-mangling. While some of these conventions have a common precedent in their implementation in AT&T's CFront, the evolution of the language and the proliferation of compilers has resulted in the availability of many compilers whose binaries are not compatible. While the orginal Annotated C++ Reference Manual suggested how to address some of the ABI issues, many were left as implementation-dependent details. The subsequent evolution of the C++ language has presented further avenues for divergence in compiler runtime conventions. Given the emergence of interoperable components on the Macintosh, it is increasingly important to establish an ABI for C++ for the Macintosh.

The foundation level of the Macintosh ABI is documented in the book "Macintosh Runtime Architectures" (to be available in fall '96) which covers various basic conventions such as register usage and parameter passing conventions. What we are calling the "Macintosh C/C++ ABI" covers some special cases of low-level conventions, general conventions for languages such as C and C++, and conventions for C++ specific constructs which get exposed at the ABI level.

The Macintosh C/C++ ABI Specification (Version 1.3)

The current draft of the Macintosh C/C++ ABI Specification is a work-in-progress for a variety of reasons:

  1. This is the first complete draft of the Macintosh C/C++ ABI.
  2. The C++ language is still evolving. While the language is nearing standardization, the conventions for implementing various language features have not yet been standardized.
  3. The ABI specification identifies issues which have not been resolved. Many sections of the ABI contain a sub-section of open issues.
  4. The ABI should not be immutable. If there is something wrong or sub-optimal about the current ABI specification please let us know. Even once the standard is complete and has been widely adopted, potential improvements should be discussed.

Topics Covered (and to be Covered) by the ABI Specification

  1. The PowerPC ABI
  2. Structure Alignment and Bit Field Layout
  3. Name Mangling
  4. Class Object and V-Table Layout
  5. RTTI
  6. Exception Handling
  7. Special C++ Calling Conventions

Feedback

Please feel free to discuss any issues in the ABI with us and to identify any potential problem areas.

You may reach us at:

forsman@apple.com

Or you may email us directly.

 
Back to MPW Home Page
Back to MPW Home Page