patchelf for udocker

License: GPL-3.0

Language: C

PatchELF is a simple utility for modifying existing ELF executables and
libraries.  In particular, it can do the following:

* Change the dynamic loader ("ELF interpreter") of executables:

  $ patchelf --set-interpreter /lib/ my-program

* Change the RPATH of executables and libraries:

  $ patchelf --set-rpath /opt/my-libs/lib:/other-libs my-program

* Shrink the RPATH of executables and libraries:

  $ patchelf --shrink-rpath my-program

  This removes from the RPATH all directories that do not contain a
  library referenced by DT_NEEDED fields of the executable or library.
  For instance, if an executable references one library, has
  an RPATH "/lib:/usr/lib:/foo/lib", and can only be found
  in /foo/lib, then the new RPATH will be "/foo/lib".

  In addition, the '--allowed-rpath-prefixes' option can be used for
  further rpath tuning. For instance, if an executable has an RPATH
  "/tmp/build-foo/.libs:/foo/lib", it is probably desirable to keep
  the "/foo/lib" reference instead of the "/tmp" entry. To accomplish
  that, use:

  $ patchelf --shrink-rpath --allowed-rpath-prefixes /usr/lib:/foo/lib my-program

* Remove declared dependencies on dynamic libraries (DT_NEEDED

  $ patchelf --remove-needed my-program

  This option can be given multiple times.

* Add a declared dependency on a dynamic library (DT_NEEDED):

  $ patchelf --add-needed my-program

  This option can be give multiple times.

* Replace a declared dependency on a dynamic library with another one

  $ patchelf --replace-needed my-program

  This option can be give multiple times.

* Change SONAME of a dynamic library:

  $ patchelf --set-soname path/to/


You can download a pre-compiled binary from the releases or compile it by yourself:

  sudo make install


Copyright 2004-2019 Eelco Dolstra <>.


This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <>.



The `strip' command from binutils generated broken executables when
applied to the output of patchelf (if `--set-rpath' or
`--set-interpreter' with a larger path than the original is used).
This appears to be a bug in binutils


0.10 (March 28, 2019):

* Many bug fixes. Please refer to the Git commit log:

  This release has contributions from Adam Trhoň, Benjamin Hipple,
  Bernardo Ramos, Bjørn Forsman, Domen Kožar, Eelco Dolstra, Ezra
  Cooper, Felipe Sateler, Jakub Wilk, James Le Cuirot, Karl Millar,
  Linus Heckemann, Nathaniel J. Smith, Richard Purdie, Stanislav
  Markevich and Tuomas Tynkkynen.

0.9 (February 29, 2016):

* Lots of new features. Please refer to the Git commit log:

  This release has contributions from Aaron D. Marasco, Adrien
  Devresse, Alexandre Pretyman, Changli Gao, Chingis Dugarzhapov,
  darealshinji, David Sveningsson, Eelco Dolstra, Felipe Sateler,
  Jeremy Sanders, Jonas Kuemmerlin, Thomas Tuegel, Tuomas Tynkkynen,
  Vincent Danjean and Vladimír Čunát.

0.8 (January 15, 2014):

* Fix a segfault caused by certain illegal entries in symbol tables.

0.7 (January 7, 2014):

* Rewrite section indices in symbol tables. This for instance allows
  gdb to show proper backtraces.

* Added `--remove-needed' option.

0.6 (November 7, 2011):

* Hacky support for executables created by the Gold linker.

* Support segments with an alignment of 0 (contributed by Zack

* Added a manual page (contributed by Jeremy Sanders

0.5 (November 4, 2009):

* Various bugfixes.

* `--force-rpath' now deletes the DT_RUNPATH if it is present.

0.4 (June 4, 2008):

* Support for growing the RPATH on dynamic libraries.

* IA-64 support (not tested) and related 64-bit fixes.

* FreeBSD support.

* `--set-rpath', `--shrink-rpath' and `--print-rpath' now prefer
  DT_RUNPATH over DT_RPATH, which is obsolete.  When updating, if both
  are present, both are updated.  If only DT_RPATH is present, it is
  converted to DT_RUNPATH unless `--force-rpath' is specified.  If
  neither is present, a DT_RUNPATH is added unless `--force-rpath' is
  specified, in which case a DT_RPATH is added.

0.3 (May 24, 2007):

* Support for 64-bit ELF binaries (such as on x86_64-linux).

* Support for big-endian ELF binaries (such as on powerpc-linux).

* Various bugfixes.

0.2 (January 15, 2007):

* Provides a hack to get certain programs (such as the
  Belastingaangifte 2005) to work.

0.1 (October 11, 2005):

* Initial release.

Project Statistics

Sourcerank 3
Repository Size 467 KB
Stars 0
Forks 0
Watchers 1
Open issues 0
Dependencies 0
Contributors 29
Tags 10
Last updated
Last pushed

Top Contributors See all

Eelco Dolstra darealshinji Vincent Danjean :zap: Felipe Sateler Domen Kožar Tuomas Tynkkynen Nathaniel J. Smith Thomas Tuegel David Sveningsson Karl Millar ezquat Changli Gao Richard Purdie James Le Cuirot Vladimír Čunát Benjamin Hipple Jeremy Sanders Jonas Kümmerlin Devresse Adrien

Recent Tags See all

0.10 March 28, 2019
0.9 February 29, 2016
0.8 January 14, 2014
0.7 January 07, 2014
0.6 December 06, 2011
0.5 November 04, 2009
0.4 June 04, 2008
0.3 May 24, 2007
0.2 January 15, 2007
0.1 October 11, 2005

Something wrong with this page? Make a suggestion

Last synced: 2019-10-24 09:00:06 UTC

Login to resync this repository