Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Mac OS Runtime Architectures /
Chapter 1 - CFM-Based Runtime Architecture


Preparing a Closure

When the Code Fragment Manager is called to prepare a fragment, it prepares the closure associated with the fragment to ensure that the fragment can access all its imported symbols during execution. This preparation process involves the following steps:

  1. Determine the closure associated with the root fragment (an application or a plug-in, for example). The Code Fragment Manager does the following to determine the closure:

  2. Instantiate (or locate, if already present) code and data sections for each connection in the closure. This procedure assigns actual addresses to the sections and, consequently, assigns addresses to all exported symbols.
  3. Resolve all imported symbols. For every imported symbol required by the new connections in the closure, the Code Fragment Manager finds the corresponding exported symbol address and stores it in an internal lookup table.
  4. Do relocations. Using the lookup table compiled in step 3 and the section addresses determined in step 2, the Code Fragment Manager replaces all references to imported symbols (and any other pointer-based symbol references) in the closure with actual addresses. See Chapter 2, "Indirect Addressing in the CFM-Based Architecture," and the section "Relocations," beginning on page 8-21, for more details.
  5. Execute initialization functions (if any exist).
  6. Return the closure ID and main symbol to the caller.

IMPORTANT
These steps apply for any fragment the Code Fragment Manager is called to prepare (including plug-ins ).
In general, if the Code Fragment Manager cannot complete any step, then the preparation fails and an error is returned. The only special case is when certain libraries or symbols have been declared weak. A weak library or symbol is one that is marked as being optional; the preparation process can continue even if the library or symbol is not available. However, once a weak library or symbol is determined to be present, it is handled normally for the rest of the preparation process. For example, if a weak library is available but cannot be prepared properly for some reason, the whole closure preparation fails. See "Weak Libraries and Symbols," beginning on page 3-11, for more information.

Note
A weak library is determined to be present or not present in step 1 of the preparation process. Weak symbols are determined in step 3.

Subtopics
Searching for Import Libraries
Checking for Compatible Import Libraries

Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997