![]() |
![]() |
| |||||||||||
Appendix CEstablishing Dependencies with Dynamic String TokensA dynamic object can establish dependencies explicitly or through filters. Each of these mechanisms can be augmented with a runpath, which directs the runtime linker to search for and load the required dependency. String names used to record filters, dependencies and runpath information can be augmented with the reserved dynamic string tokens:
The following sections provide examples of how each of these tokens may be employed. Instruction Set Specific Shared ObjectsThe dynamic token $ISALIST is expanded at runtime to reflect the native instruction sets executable on this platform, as displayed by the utility isalist(1). This token is available for filters or runpath definitions. Any string name that incorporates the $ISALIST token is effectively duplicated into multiple strings. Each string is assigned one of the available instruction sets. The following example shows how the auxiliary filter libfoo.so.1 can be designed to access an instruction set specific filtee libbar.so.1.
Or alternatively the runpath can be used.
In either case the runtime linker uses the platform available instruction list to construct multiple search paths. For example, the following application is dependent on libfoo.so.1 and executed on a SUNW,Ultra-2:
Or an application with similar dependencies is executed on an MMX configured Pentium Pro:
Reducing Filtee SearchesThe use of $ISALIST within a filter enables one or more filtees to provide implementations of interfaces defined within the filter. Any interface defined in a filter can result in an exhaustive search of all potential filtees in an attempt to locate the required interface. If filtees are being employed to provide performance critical functions, this exhaustive filtee searching can be counterproductive. A filtee can be built with the link-editor's -z endfiltee option to indicate that it is the last of the available filtees. This option terminates any further filtee searching for that filter. From the previous SPARC example, if the sparcv9 filtee existed, and was tagged with -z endfiltee, the filtee searches would be:
System Specific Shared ObjectsThe dynamic tokens $OSNAME, $OSREL and $PLATFORM are expanded at runtime to provide system specific information. These tokens are available for filters, runpath, or dependency definitions. $OSNAME expands to reflect the name of the operating system, as displayed by the utility uname(1) with the -s option. $OSREL expands to reflect the operating system release level, as displayed by uname -r. $PLATFORM expands to reflect the underlying hardware implementation, as displayed by uname -i. The following example shows how the auxiliary filter libfoo.so.1 can be designed to access a platform specific filtee libbar.so.1.
This mechanism is used in the Solaris operating environment to provide platform specific extensions to the shared object /usr/lib/libc.so.1. Locating Associated DependenciesTypically, an unbundled product is designed to be installed in a standalone, unique location. This product is composed of binaries, shared object dependencies, and associated configuration files. For example, the unbundled product ABC might have the layout shown in the following figure. Figure C-1 Unbundled Dependencies ![]() Assume that the product is designed for installation under /opt. Normally, you would augment the PATH with /opt/ABC/bin to locate the product's binaries. Each binary locates their dependencies using a hard-coded runpath within the binary. For the application abc, this runpath would be:
and similarly for the dependency libA.so.1 this would be:
This dependency representation works until the product is installed in some directory other than the recommended default. The dynamic token $ORIGIN expands to the directory in which an object originated. This token is available for filters, runpath, or dependency definitions. Use this technology to redefine the unbundled application to locate its dependencies in terms of $ORIGIN:
and the dependency libA.so.1 can also be defined in terms of $ORIGIN:
If this product is now installed under /usr/local/ABC and the user's PATH is augmented with /usr/local/ABC/bin, invocation of the application abc result in a pathname lookup for its dependencies as follows:
| |||||||||||
| |||||||||||