Direct binding


Direct binding is a feature of the linker and dynamic linker on Solaris and OpenSolaris. It provides a method to allow libraries to directly bind symbols to other libraries, rather than weakly bind to them and leave the dynamic linker to figure out which library contains the symbol.

Theory

When linking a shared library or dynamic linked executable, the linker normally populates the symbol table for that library with all required symbols. It adds symbols in the current object with their offset, and leaves undefined symbols in the object unresolved. Unresolved symbols must still be known at link time, but the linker is passed shared libraries to link with and, when it finds a symbol in another library, it places a note in the output library indicating that it depends on these other shared libraries.
This kind of weak linking forces the dynamic linker to resolve which library contains which symbol when the executable is run. The dynamic linker on Linux, for example, reads through the DT_NEEDED section of an ELF object and loads needed libraries; but isn't told where required symbols are. For this, it must iterate through each unresolved symbol in the object, and for each of these, iterate through each loaded library, checking until it finds a matching symbol. This can be time consuming.
Direct linking works around this problem by storing an equivalent list of pointers to DT_NEEDED entries in a separate ELF section. Each pointer corresponds to a symbol in the object; thus, these pointers create a relation between a symbol and a DT_NEEDED entry. This allows the linker to locate the library specified by a particular DT_NEEDED entry and check only its symbol table for each symbol, rather than iterate through potentially every library for every symbol.