Creating Fat Binary ProgramsThere 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
- You would like to build an application that runs on both PowerPC-based and 68K-based machines. Fat programs of this type contain PowerPC code and either CFM-68K or classic 68K code.
- You are building a shared library, and you would like to have one library file that runs on both PowerPC and 68K-based machines. Fat programs of this type contain PowerPC code and CFM-68K 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'0resource and knows to execute the PowerPC fragment in the data fork of the file. The PowerPC Process Manager simply ignores the
resources in the resource fork. If the application is launched on a 68K-based Macintosh computer, the Process Manager ignores the
'cfrg'0resource 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
As described in "The Code Fragment Resource," beginning on page 1-20, the
- 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.
'cfrg'0resource 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'0resource 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'0resource array that points to both containers. If you launch your application on a 68K Macintosh, the 68K Process Manager reads the
'cfrg'0resource 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'0resource 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'0resource pointing to their locations. In this way, you can ship a single library file that supports both CFM-68K and PowerPC runtime applications.
© Apple Computer, Inc.
11 MARCH 1997