$linuxjunkies
>

dynamic linker

also: ld.so, runtime linker, ELF interpreter

A runtime program that loads shared libraries into memory and resolves symbol references when an executable starts. It enables programs to use code from external libraries rather than embedding everything statically.

The dynamic linker is a special program invoked by the kernel when executing a dynamically linked binary. On Linux systems, it is typically /lib64/ld-linux-x86-64.so.2 (or equivalent for other architectures). Its primary job is to locate and load shared libraries (.so files) that the program depends on, then resolve all symbolic references so the program can run.

When you compile a program with gcc -o myapp myapp.c, the resulting binary contains references to external functions and variables, but not the actual code. The dynamic linker reads the binary's metadata, finds the required libraries, loads them into memory, and patches function calls with their real addresses—a process called relocation.

Example: A program calls printf() from the C standard library. The dynamic linker finds libc.so.6, loads it, and updates the program's reference so printf() points to the actual function in memory. This allows multiple programs to share one copy of the library, saving disk space and memory.

Related terms