next up previous
Next: Dynamic loading under Up: ELF under Linux Previous: Linking with a

Loading additional shared libraries

On an ELF system, to execute an ELF executable, the kernel passes the control to the dynamic linker which is ld-linux.so.1 in case of Linux. The absolute pathname /lib/ld-linux.so.1 is stored in the binary. If the dynamic linker is not present, no ELF executables will run.

The dynamic linker performs the following actions to finish the process image for the program:

The environmental varialble LD_PRELOAD cab be set to a shared library filename or a string of filenames separated by a colon ':'. The dynamic linker will map them into the address space after the dynamic executable and before any other required shared libraries. For example:

# LD_PRELOAD=./mylibc.so myprog

Here ./mylibc.so will be mapped in first for the executable myprog. Since the dynamic linker always uses the first occurrence of the required symbol for the symbol search, one can use LD_PRELOAD to override functions in the standard shared library. This feature is useful for programmers to experiment with a new implementation of a function in a shared library without rebulding the whole shared library.



J.H.M.Dassen
Tue Aug 1 14:18:10 MDT 1995