Linker and Libraries Guide

Direct Binding

When creating an object using the link-editor's -Bdirect option, the relationship between the referenced symbol and the dependency that provided the definition is recorded in the object. The runtime linker uses this information to search directly for the symbol in the associated object, rather than carry out the default symbol search model.


Note -

The use of -Bdirect also enables lazy loading, which is equivalent to adding the option -zlazyload to the front of the link-edit command line (see "Lazy Loading of Dynamic Dependencies").


This direct binding model can significantly reduce the symbol lookup overhead within a dynamic process that has many symbolic relocations and many dependencies. This model also allows multiple symbols of the same name to be located from different objects that have been directly bound to.

However, direct bindings can circumvent the traditional use of interposition symbols because they bypasses the default search model. The default model ensures that all references to a symbol bind to one definition.

Interposition can still be achieved in a direct binding environment, on a per-object basis, if an object is identified as an interposer. Any object loaded using the environment variable LD_PRELOAD (see "Loading Additional Objects"), or created with the link-editor's -zinterpose option, is identified as an interposer. When the runtime linker searches for a directly bound symbol, it first looks in any object identified as an interposer before it looks in the object that supplies the symbol definition.


Note -

Direct bindings can be disabled at runtime by setting the environment variable LD_NODIRECT to a non-null value.