From the components used in the previous example, a directly bound object, W.so.2, can be produced.
$ cc -o W.so.2 -G -Kpic W.c -R. -Bdirect w.so.1 $ cc -o prog2 -R. main.c W.so.2 X.so.1
The direct binding information is maintained in a symbol information section, .SUNW_syminfo, within W.so.2. This section can be viewed with elfdump(1).
$ elfdump -y W.so.2  DB <self> a  DBL  w.so.1 b
The letters “DB” indicates a direct binding has been recorded for the associated symbol. The function a() has been bound to the containing object W.so.2. The function b() has been bound directly to the dependency w.so.1. The letter “L” indicates that the dependency w.so.1 should also be lazily loaded.
The direct bindings that are established for W.so.2 can be observed using the LD_DEBUG environment variable. The detail token adds additional information to the binding diagnostics. For W.so.2, this token indicates the direct nature of the binding. The detail token also provides additional information about the binding addresses. For simplification, this address information has been omitted from the output generated from the following examples.
$ LD_DEBUG=symbols,bindings,detail prog2 .... 18452: symbol=a; lookup in file=./W.so.2 [ ELF ] 18452: binding file=./W.so.2 to file=./W.so.2: symbol 'a' (direct) 18452: symbol=b; lookup in file=./w.so.1 [ ELF ] 18452: binding file=./W.so.2 to file=./w.so.1: symbol 'b' (direct)
The lari(1) utility can also reveal the direct binding information.
$ lari prog2 [2:2ESD]: a(): ./W.so.2 [2:0]: a(): ./X.so.1 [2:2ED]: b(): ./w.so.1 [2:0]: b(): ./x.so.1
The letter “D” indicates that the function a() defined by W.so.2 has been bound to directly. Similarly, the function b() defined in w.so.1 has been bound to directly.
Unlike –B symbolic bindings, a –B direct binding is left for resolution at runtime. Therefore, this binding can be overridden by explicit interposition, or disabled by setting the environment variable LD_NODIRECT to a non-null value.
Symbolic bindings have often been employed to reduce the runtime relocation overhead incurred when loading complex objects. Direct bindings can be used to establish exactly the same symbol bindings. However, a runtime relocation is still required to create each direct binding. Direct bindings require more overhead than symbolic bindings, but provide for greater flexibility.