Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

NixOS/patchelf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PatchELF is a simple utility for modifying existing ELF executables andlibraries. 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 theRPATH of executables and libraries:

    $patchelf --set-rpath /opt/my-libs/lib:/other-libs my-program
  • Shrink theRPATH of executables and libraries:

    $patchelf --shrink-rpath my-program

    This removes from theRPATH all directories that do not contain alibrary referenced byDT_NEEDED fields of the executable or library.For instance, if an executable references one librarylibfoo.so, hasan RPATH/lib:/usr/lib:/foo/lib, andlibfoo.so can only be foundin/foo/lib, then the newRPATH will be/foo/lib.

    In addition, the--allowed-rpath-prefixes option can be used forfurther rpath tuning. For instance, if an executable has anRPATH/tmp/build-foo/.libs:/foo/lib, it is probably desirable to keepthe/foo/lib reference instead of the/tmp entry. To accomplishthat, use:

    $patchelf --shrink-rpath --allowed-rpath-prefixes /usr/lib:/foo/lib my-program
  • Remove declared dependencies on dynamic libraries (DT_NEEDEDentries):

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

  • ChangeSONAME of a dynamic library:

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

Compiling and Testing

./bootstrap.sh./configuremakemake checksudo make install

ViaCMake (andNinja)

mkdir buildcd buildcmake .. -GNinjaninja allsudo ninja install

ViaMeson (andNinja)

mkdir buildmeson configure buildcd buildninja allsudo ninja install

Via Nix

You can build with Nix in several ways.

  1. Building vianix build will produce the result in./result/bin/patchelf. If you would like to buildpatchelf withmusl trynix build .#patchelf-musl

  2. You can launch a development environment withnix develop and follow the autotools steps above. If you would like to develop withmusl trynix develop .#musl

Help and resources

Author

Copyright 2004-2019 Eelco Dolstraedolstra@gmail.com.

License

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

This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.

You should have received a copy of the GNU General Public Licensealong with this program. If not, seehttp://www.gnu.org/licenses/.

About

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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors86


[8]ページ先頭

©2009-2025 Movatter.jp