Go to file
dependabot[bot] 7c2f768bf9 Bump cachix/install-nix-action from 22 to 25
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 22 to 25.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v22...v25)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-15 10:51:22 +01:00
.github Bump cachix/install-nix-action from 22 to 25 2024-01-15 10:51:22 +01:00
completions/zsh Fix #310, add zsh completion 2023-04-08 14:45:02 +08:00
m4 fix c++17 check 2022-10-09 14:30:03 +02:00
src feat: add --no-clobber-old-sections switch 2023-09-27 08:55:02 +01:00
tests Also respect a prefixed nm and strings too 2023-04-24 22:44:12 +02:00
.gitignore Add options to print, clear and set executable stack state 2023-01-28 23:27:34 +01:00
BUGS * Document other people's bugs ;-) 2005-09-29 08:59:45 +00:00
COPYING COPYING: change http to https 2023-06-07 23:02:42 +02:00
Makefile.am Fix #310, add zsh completion 2023-04-08 14:45:02 +08:00
README.md README: move release history to github release page 2022-07-16 08:48:47 +02:00
bootstrap.sh Use autoreconf to bootstrap the project 2012-07-10 18:16:24 -04:00
bors.toml bors: add configuration 2022-12-27 10:58:02 +01:00
configure.ac Also respect a prefixed nm and strings too 2023-04-24 22:44:12 +02:00
default.nix Add default.nix for compatibility 2020-11-26 22:02:07 +01:00
flake.lock bump nixpkgs 2022-12-27 10:16:02 +01:00
flake.nix switch back to upstream nixpkgs for windows build 2022-11-17 18:33:59 +01:00
patchelf.1 feat: add --no-clobber-old-sections switch 2023-09-27 08:55:02 +01:00
patchelf.nix switch back to upstream nixpkgs for windows build 2022-11-17 18:33:59 +01:00
patchelf.spec.in fix README -> README.me in some more places 2020-06-03 14:03:32 +02:00
version bump version 2023-04-23 13:30:30 +02:00

README.md

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-ld-linux.so.2 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 libfoo.so, has an RPATH /lib:/usr/lib:/foo/lib, and libfoo.so 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 entries):

    $ patchelf --remove-needed libfoo.so.1 my-program
    

    This option can be given multiple times.

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

    $ patchelf --add-needed libfoo.so.1 my-program
    

    This option can be give multiple times.

  • Replace a declared dependency on a dynamic library with another one (DT_NEEDED):

    $ patchelf --replace-needed liboriginal.so.1 libreplacement.so.1 my-program
    

    This option can be give multiple times.

  • Change SONAME of a dynamic library:

    $ patchelf --set-soname libnewname.so.3.4.5 path/to/libmylibrary.so.1.2.3
    

Compiling and Testing

Via Autotools

./bootstrap.sh
./configure
make
make check
sudo make install

Via Nix

You can build with Nix in several ways.

  1. Building via nix build will produce the result in ./result/bin/patchelf. If you would like to build patchelf with musl try nix build .#patchelf-musl

  2. You can launch a development environment with nix develop and follow the autotools steps above. If you would like to develop with musl try nix develop .#musl

Author

Copyright 2004-2019 Eelco Dolstra edolstra@gmail.com.

License

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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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 http://www.gnu.org/licenses/.