Dynamic Linker
Vital for the loading process, and can help reverse a program.
Provide information about the loaded libraries.
Help to debug the linking process.
Force linking with custom libraries.
And many others.
Communication is achieved through environmental variables.
In the format LD_*.
Setting a variable, or setting a variable with a specific value, activates Linker features.
LD_LIBRARY_PATH
A list of directories in which to search for ELF libraries at execution time.
The items in the list are separated by either colons or semicolons.
A zero-length directory name indicates the current working directory.
Activating: LD_LIBRARY_PATH=libs ./progname
.
Linker will look into ./libs while loading libraries for the program.
Allows having a different set of libraries for the program (E.g., debug versions).
LD_BIND_NOW
This causes the dynamic linker to resolve all symbols at program startup instead of deferring function call resolution to the point when they are first referenced.
Especially useful for debugging as all symbols point to their correct location.
Activated by setting the variable: LD_BIND_NOW=1 progname
.
LD_DEBUG
Output verbose debugging information about the dynamic linking.
Allows tracing the operation of the linker.
Debug where libraries are loading from.
Determine if libraries are being loaded and which symbols trigger the event.
Determine the search path used in looking for libraries.
The content of this variable is one of more of the following categories, separated by colons/commas, and spaces:
help, all, bindings, files, reloc, scopes, statistics, symbols, unused, version.
Use: LD_DEBUG=option programname
LD_PRELOAD
A list of additional, user-specified, ELF shared objects to be loaded before all others.
This feature can be used to selectively override functions in other shared objects.
Symbols present in the provided ELF Shared objects are used instead of the original.
Only the functions available in the shared object will be overwritten.
Use: LD_PRELOAD=./liboverride.so progname
Useful to provide custom implementations of any function in the program.
Custom implementation can call the original implementation through manual symbol loading.
Last updated