Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: Mac OS Runtime Architectures /
Chapter 7 - Fat Binary Programs


Creating Fat Binary Programs

There are two primary reasons for building fat programs:

It is very easy to build a fat application to run PowerPC code and classic 68K code, because you can place the PowerPC code in the data fork of an application file, and the classic 68K code can be placed in 'CODE' resources in the resource fork of the same file. If the application is launched on a PowerPC-based Macintosh computer, the Process Manager recognizes the 'cfrg'0 resource and knows to execute the PowerPC fragment in the data fork of the file. The PowerPC Process Manager simply ignores the 'CODE' resources in the resource fork. If the application is launched on a 68K-based Macintosh computer, the Process Manager ignores the 'cfrg'0 resource and executes the 'CODE' resources in the resource fork.

To create a fat application that contains both PowerPC code and CFM-68K code is slightly more complicated, because both PowerPC and CFM-68K runtime fragments require a 'cfrg'0 resource.

IMPORTANT
If you want to run CFM-based code on both PowerPC-based and 68K-based Macintosh computers, you must build the fragment as a fat program.
As described in "The Code Fragment Resource," beginning on page 1-20, the 'cfrg'0 resource is an array that identifies, among other things, the instruction set, type, and name of the fragment. It also identifies the location of the PEF container for the fragment. As an array, the 'cfrg'0 resource can point to multiple containers.

A fat application for both PowerPC and CFM-68K runtime architectures contains code for each instruction set and a 'cfrg'0 resource array that points to both containers. If you launch your application on a 68K Macintosh, the 68K Process Manager reads the 'cfrg'0 resource and launches the CFM-68K runtime version of the application. If you launch your application on a PowerPC-based Macintosh, the PowerPC Process Manager reads the 'cfrg'0 resource and launches the PowerPC version of the application.

You can also create a fat shared library containing both a CFM-68K runtime library and a PowerPC runtime library. Both the PowerPC and CFM-68K fragments are stored in the data fork, with the 'cfrg'0 resource pointing to their locations. In this way, you can ship a single library file that supports both CFM-68K and PowerPC runtime applications.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2003 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice