$linuxjunkies
>

symbol versioning

also: versioned symbols, ELF symbol versioning, GNU symbol versioning

A mechanism that allows multiple versions of the same symbol (function or variable) to coexist in a shared library, enabling backward compatibility when library APIs change.

Symbol versioning is a feature of ELF (Executable and Linkable Format) binaries that permits a shared library to provide multiple implementations of the same symbol name. When a symbol is versioned, the linker and loader can distinguish between different versions and bind executables to the correct implementation based on what was available when they were compiled.

This solves a critical compatibility problem: if a library function's behavior changes, older compiled programs expecting the old behavior can still use the old version while new programs use the new version. For example, glibc extensively uses symbol versioning—a program compiled against glibc 2.17 can call glibc_2.17::malloc() while a newer program calls glibc_2.31::malloc(), and both work correctly on a system with the latest glibc installed.

Symbol versions are defined in a linker script and can be inspected with tools like nm -D or readelf -s, which show the version suffix (e.g., GLIBC_2.2.5) attached to symbols in shared libraries.

Related terms