Giter Site home page Giter Site logo

bluepeople1 / patchelf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nixos/patchelf

0.0 1.0 0.0 954 KB

A small utility to modify the dynamic linker and RPATH of ELF executables

License: GNU General Public License v3.0

Shell 10.18% C++ 27.97% C 50.95% Assembly 0.27% Nix 1.40% Makefile 1.78% M4 6.06% Roff 1.39%

patchelf's Introduction

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 [email protected].

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/.

patchelf's People

Contributors

edolstra avatar mic92 avatar domenkozar avatar brenoguim avatar cgzones avatar darealshinji avatar vdanjean avatar blitz avatar neheb avatar fzakaria avatar bors[bot] avatar derdakon avatar dependabot[bot] avatar fsateler avatar bo98 avatar dmsck avatar dezgeg avatar rmnull avatar satmandu avatar opanait-wr avatar klemensn avatar iv-m avatar andrewla avatar njsmith avatar rpurdie avatar xavierabellan avatar mayeut avatar am813nt avatar abathur avatar ttuegel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.