Direct binding is a feature of the
linker
Linker or linkers may refer to:
Computing
* Linker (computing), a computer program that takes one or more object files generated by a compiler or generated by an assembler and links them with libraries, generating an executable program or shar ...
and
dynamic linker
In computing, a dynamic linker is the part of an operating system that loads and links the shared libraries needed by an executable when it is executed (at " run time"), by copying the content of libraries from persistent storage to RAM, filli ...
on
Solaris and
OpenSolaris
OpenSolaris () is a discontinued open-source computer operating system based on Solaris and created by Sun Microsystems. It was also, perhaps confusingly, the name of a project initiated by Sun to build a developer and user community around t ...
. 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
In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier (or symbols), constants, procedures and functions in a program's source code is associated with inf ...
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
An elf () is a type of humanoid supernatural being in Germanic mythology and folklore. Elves appear especially in North Germanic mythology. They are subsequently mentioned in Snorri Sturluson's Icelandic Prose Edda. He distinguishes "ligh ...
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.
References
Library Bindings - let's be a little bit more precise shall we
External links
Work on a direct binding implementation for Gentoo Linux
OpenSolaris
{{Unix-stub