OS Manuals

/usr/bin/patchelf

Small utility to modify the dynamic linker and RPATH of ELF executables

From patchelf 0.19.3-r0 (os), captured 2026-11-05 by running patchelf --help (exit 0) · terse output. permalink

syntax: /usr/bin/patchelf
  [--set-interpreter FILENAME]
  [--page-size SIZE]
  [--print-interpreter]
  [--print-os-abi]		Prints 'EI_OSABI' field of ELF header
  [--set-os-abi ABI]		Sets 'EI_OSABI' field of ELF header to ABI.
  [--print-soname]		Prints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist
  [--set-soname SONAME]		Sets 'DT_SONAME' entry to SONAME.
  [--set-rpath RPATH]
  [--add-rpath RPATH]
  [--remove-rpath]
  [--shrink-rpath]
  [--allowed-rpath-prefixes PREFIXES]		With '--shrink-rpath', reject rpath entries not starting with the allowed prefix
  [--print-rpath]
  [--force-rpath]
  [--add-needed LIBRARY]
  [--remove-needed LIBRARY]
  [--replace-needed LIBRARY NEW_LIBRARY]
  [--print-needed]
  [--no-default-lib]
  [--no-sort]		Do not sort program+section headers; useful for debugging patchelf.
  [--clear-symbol-version SYMBOL]
  [--add-debug-tag]
  [--build-resolution-cache]
  [--print-execstack]		Prints whether the object requests an executable stack
  [--clear-execstack]
  [--set-execstack]
  [--rename-dynamic-symbols NAME_MAP_FILE]	Renames dynamic symbols. The map file should contain two symbols (old_name new_name) per line
  [--no-clobber-old-sections]		Do not clobber old section values - only use when the binary expects to find section info at the old location.
  [--output FILE]
  [--debug]
  [--version]
  FILENAME...
Options (30)
OptionDescriptionSource
--page-size SIZEUses the given page size instead of the default.man
--set-interpreter INTERPRETERChange the dynamic loader ("ELF interpreter") of executable given to INTERPRETER.man
--print-interpreterPrints the ELF interpreter of the executable.man
--print-os-abiPrints the OS ABI of the executable (EI_OSABI field of an ELF file).man
--set-os-abi ABIChanges the OS ABI of the executable (EI_OSABI field of an ELF file).man
--print-sonamePrints DT_SONAME entry of .dynamic section.man
--set-soname SONAMESets DT_SONAME entry of a library to SONAME.man
--set-rpath RUNPATHChange the DT_RUNPATH of the executable or library to RUNPATH.man
--add-rpath RUNPATHAdd RUNPATH to the existing DT_RUNPATH of the executable or library.man
--remove-rpathRemoves the DT_RPATH or DT_RUNPATH entry of the executable or library.man
--shrink-rpathRemove from the DT_RUNPATH or DT_RPATH all directories that do not contain a library referenced by DT_NEEDED fields of the executable or library.man
--allowed-rpath-prefixes PREFIXESCombined with the "--shrink-rpath" option, this can be used for further rpath tuning.man
--print-rpathPrints the DT_RUNPATH or DT_RPATH for an executable or library.man
--force-rpathForces the use of the obsolete DT_RPATH in the file instead of DT_RUNPATH.man
--add-needed LIBRARYAdds a declared dependency on a dynamic library (DT_NEEDED).man
--replace-needed LIB_ORIGReplaces a declared dependency on a dynamic library with another one (DT_NEEDED).man
--remove-needed LIBRARYRemoves a declared dependency on LIBRARY (DT_NEEDED entry).man
--print-neededPrints all DT_NEEDED entries of the executable.man
--no-default-libMarks the object so that the search for dependencies of this object will ignore any default library search paths.man
--build-resolution-cacheResolves each DT_NEEDED dependency against the object's run path at patch time and records the result in a .note.nixos.ldcache note, so that a loader which understands the note can skip the run-path…man
--no-sortDo not sort program headers or section headers.man
--add-debug-tagAdds DT_DEBUG tag to the .dynamic section if not yet present in an ELF object.man
--print-execstackPrints the state of the executable flag of the GNU_STACK program header, if present.man
--clear-execstackClears the executable flag of the GNU_STACK program header, or adds a new header.man
--set-execstackSets the executable flag of the GNU_STACK program header, or adds a new header.man
--rename-dynamic-symbols NAME_MAP_FILERenames dynamic symbols.man
--no-clobber-old-sectionsDo not clobber old section values.man
--output FILESet the output file name.man
--debugPrints details of the changes made to the input file.man
--versionShows the version of patchelf.man
Examples (1) from the manual page, untested

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.