Optimizing the runtime linker
The runtime linker supports the following features that you can use to optimize the way it resolves and relocates symbols:
The term "lazy" in all of them can cause confusion, so let's compare them briefly before looking at them in detail:
- Lazy binding is the process by which symbol resolution is deferred until a symbol is actually used.
- RTLD_LAZY indicates to the runtime linker that an a loaded object might have unresolved symbols that it shouldn't worry about resolving. It's up to the developer to load the objects that define the symbols before calling any functions that use the symbols.
- Lazy loading modifies the lookup scope and avoids loading objects (or even looking them up) before the linker needs to search them for a symbol.
RTLD_LAZY doesn't imply anything about whether dependencies will be loaded; it says where a symbol will be looked up. It allows the looking up of symbols that are subsequently opened with the RTLD_GLOBAL flag, when looking up a symbol in an RTLD_LAZY-opened object and its resolution scope fails. The term "resolution scope" is intentional since we don't know what it is by just looking at RTLD_LAZY; it differs depending on whether you specify RTLD_WORLD, RTLD_LAZYLOAD, or both.
Last modified: 2013-12-21