patchelf is a utility for modifying the dynamic linker and RPATH of ELF executables.
The tool solves the problem of needing to change how compiled binaries locate their dependencies at runtime. ELF executables on Unix-like systems contain metadata specifying which dynamic linker to use and where to search for shared libraries. patchelf allows you to rewrite these settings after compilation, without needing to recompile the original source code. This is particularly useful when you have pre-built binaries that were compiled against a different environment or glibc version than your target system, or when you need to redirect library lookups to custom locations.
patchelf is well-suited for packaging systems, containerization workflows, and scenarios where you need to make binaries portable across different Linux distributions or system configurations. It is especially valuable in the Nix ecosystem, where reproducible builds and precise dependency management are central concerns. The tool works at the binary level, making it applicable to any ELF executable regardless of the language it was written in. If you are working with pre-compiled binaries that cannot be easily rebuilt, or if you need fine-grained control over runtime library resolution, patchelf provides a straightforward way to achieve this without source code access.
The project maintains steady development activity with regular commits addressing bug fixes and improvements. The codebase receives ongoing attention to handle edge cases and compatibility issues across different ELF variants and architectures. The maintainers respond to issues and incorporate contributions that expand the tool's reliability in real-world packaging scenarios.