• Stars
    star
    2,931
  • Rank 14,793 (Top 0.4 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 12 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

nixpkgs

Nix Packages collection & NixOS
Nix
13,126
star
2

nix

Nix, the purely functional package manager
C++
9,002
star
3

nixops

NixOps is a tool for deploying to NixOS machines in a network or cloud.
Python
1,464
star
4

nixos-hardware

A collection of NixOS modules covering hardware quirks.
Nix
1,461
star
5

nix.dev

Official documentation for getting things done with Nix.
Python
1,458
star
6

hydra

Hydra, the Nix-based continuous build system
Perl
893
star
7

mobile-nixos

C
668
star
8

rfcs

The Nix community RFCs
396
star
9

nixos-search

Search NixOS packages and options
Elm
364
star
10

templates

Flake templates
Nix
363
star
11

cabal2nix

Generate Nix build instructions from a Cabal file
Haskell
336
star
12

nix-pills

Nix
278
star
13

nix-mode

An Emacs major mode for editing Nix expressions.
Emacs Lisp
276
star
14

nixos-homepage

Sources for nixos.org
Astro
268
star
15

ofborg

@ofborg tooling automation https://monitoring.ofborg.org/dashboard/db/ofborg
Rust
221
star
16

nixos-weekly

NixOS Weekly Newsletter
HTML
213
star
17

nixos-artwork

Nix related artwork
Nix
194
star
18

nix-book

Nix documentation – centralized community online learning resource for Nix
183
star
19

nixos-org-configurations

NixOS configurations for nixos.org and its servers
Nix
173
star
20

nixos

OBSOLETE (go to NixOS/nixpkgs) - NixOS, a Linux distribution based on the Nix package manager - OBSOLETE (go to NixOS/nixpkgs)
Shell
169
star
21

nixpkgs-channels

DEPRECATED! Use NixOS/nixpkgs repository instead.
Nix
168
star
22

docker

DEPRECATED! Dockerfiles to package Nix in a minimal docker container
Dockerfile
147
star
23

nix-idea

Nix plugin for the IntelliJ IDEA IDE
Java
142
star
24

bundlers

Nix
88
star
25

flake-registry

Global registry of Nix flakes
Shell
76
star
26

aarch64-build-box

Config for the Community aarch64 NixOS box [maintainer=@grahamc]
Nix
62
star
27

npm2nix

Generate nix expressions to build npm packages
CoffeeScript
57
star
28

nixops-aws

Python
52
star
29

nixops-hetzner

Python
45
star
30

equinix-metal-builders

iPXE image for Nix builders on Equinix Metal's Spot market.
Nix
39
star
31

nixpart

NixOS storage manager/partitioner
Python
38
star
32

foundation

This is the home of the NixOS Foundation
33
star
33

nixos-channel-scripts

Perl
32
star
34

mvn2nix-maven-plugin

Generate project-info.json for use with nix's Maven repository generation functions
Java
31
star
35

security

Rust
30
star
36

nixpkgs-merge-bot

Allows package maintainers to merge in nixpkgs
Python
30
star
37

language-nix

Data types and useful functions to represent and manipulate the Nix language. | Source has moved to https://github.com/nixos/cabal2nix
Haskell
30
star
38

hydra-provisioner

On-demand provisioning tool for Hydra
Python
29
star
39

amis

Temporary home for the soon to be official NixOS AMIs
Python
21
star
40

release-wiki

19
star
41

distribution-nixpkgs

Haskell types and functions to represent, query, and manipulate the Nixpkgs distribution. | Source has moved to https://github.com/nixos/cabal2nix
Haskell
17
star
42

mobile-nixos-website

Nix
14
star
43

reproducible.nixos.org

HTML
14
star
44

calamares-nixos-extensions

NixOS calamares [maintainer=@vlinkz]
Python
13
star
45

hackage-db

provide access to the Hackage database via Data.Map | Source has moved to https://github.com/nixos/cabal2nix
Haskell
13
star
46

snapd-nix-base

The Nix base snap for distributing Nix-built software via the Snap store.
Nix
12
star
47

nixos-metrics

Rust
12
star
48

nix-eclipse

Nix Eclipse plugin
Java
12
star
49

nixos-common-styles

Common styles for NixOS related web sites.
Less
11
star
50

rfc-steering-committee

Workflows and notes from Nix steering committee
Python
11
star
51

darwin-stubs

Text API (TAPI) files to support a pure build environment on macOS in nixpkgs.
Shell
11
star
52

moderation

The home of the moderation team
11
star
53

jailbreak-cabal

Strip version restrictions from build dependencies in Cabal files.
Haskell
9
star
54

nixops-dashboard

NixOps Dashboard
9
star
55

nixos-summer

HTML
8
star
56

nixos-status

The website showing an overview status of NixOS infra and CI.
JavaScript
8
star
57

nixpkgs-check-by-name

Tool to check Nixpkgs' pkgs/by-name directory
Rust
8
star
58

nixos-planet

XSLT
7
star
59

ofborg-viewer

Nix
5
star
60

20th-nix

20 years of Nix
HTML
5
star
61

nixos-wiki-infra

This project contains everything to setup yourself a mirror of https://nixos.wiki/
Nix
5
star
62

.github

org-level github configuration
4
star
63

hydra-ant-logger

Java
4
star
64

whats-new-in-nix

Shell
4
star
65

package-list

Deprecated, use upload-nixos-package-list-to-hackage.sh instead. Generate the list of available Haskell packages for Hackage.
Haskell
3
star
66

rfc39

Implementation of NixOS RFC #39.
Nix
3
star
67

rfc39-record

2
star
68

teams-collaboration

1
star