Important: The information in this document is obsolete and should not be used for new development.
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:
- 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:
- Finds compatible versions of all the import libraries the root fragment requires. Note that some import libraries may themselves depend on other import libraries.
- Brings into memory any fragments that do not currently have connections to them.
- Assigns connection IDs to any new connections and assigns a closure ID to the new closure.
See "Searching for Import Libraries," beginning on page 1-16, for information about the library search procedure and "Checking for Compatible Import Libraries," beginning on page 1-19, for information about how the Code Fragment Manager checks version compatibility.
- 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.
- 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.
- 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.
- Execute initialization functions (if any exist).
- Return the closure ID and main symbol to the caller.
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.
- IMPORTANT
- These steps apply for any fragment the Code Fragment Manager is called to prepare (including plug-ins ).
- 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