summaryrefslogtreecommitdiff
path: root/patchelf.1
blob: dc9ab5f6420202e7a5e2fbb7370b2a2131313223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
.\" Process this file with
.\" groff -man -Tascii foo.1
.\"
.TH PATCHELF 1 "JUNE 2010" PATCHELF "User Manuals"
.SH NAME
patchelf - Modify ELF files

.SH SYNOPSIS
.B patchelf
.I OPTION
.B
.I FILE
.SM ...
.B

.SH DESCRIPTION

PatchELF is a simple utility for modifying existing ELF executables
and libraries.  It can change the dynamic loader ("ELF interpreter")
of executables and change the RPATH of executables and libraries.

.SH OPTIONS

The single option given operates on each FILE, editing in place.

Any option taking a string argument can also take a file by prefixing the
argument with the @ symbol. See EXAMPLES

.IP "--page-size SIZE"
Uses the given page size instead of the default.

.IP "--set-interpreter INTERPRETER"
Change the dynamic loader ("ELF interpreter") of executable given to
INTERPRETER.

.IP --print-interpreter
Prints the ELF interpreter of the executable.

.IP --print-soname
Prints DT_SONAME entry of .dynamic section.
Raises an error if DT_SONAME doesn't exist.

.IP "--set-soname SONAME"
Sets DT_SONAME entry of a library to SONAME.

.IP "--set-rpath RUNPATH"
Change the DT_RUNPATH of the executable or library to RUNPATH.

.IP "--add-rpath RUNPATH"
Add RUNPATH to the existing DT_RUNPATH of the executable or library.

.IP --remove-rpath
Removes the DT_RPATH or DT_RUNPATH entry of the executable or library.

.IP --shrink-rpath
Remove from the DT_RUNPATH or DT_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".

.IP "--allowed-rpath-prefixes PREFIXES"
Combined with the "--shrink-rpath" option, this 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.

.IP --print-rpath
Prints the DT_RUNPATH or DT_RPATH for an executable or library.

.IP --force-rpath
Forces the use of the obsolete DT_RPATH in the file instead of
DT_RUNPATH. By default DT_RPATH is converted to DT_RUNPATH.

.IP "--add-needed LIBRARY"
Adds a declared dependency on a dynamic library (DT_NEEDED).
This option can be given multiple times.

.IP "--replace-needed LIB_ORIG LIB_NEW"
Replaces a declared dependency on a dynamic library with another one (DT_NEEDED).
This option can be given multiple times.

.IP "--remove-needed LIBRARY"
Removes a declared dependency on LIBRARY (DT_NEEDED entry). This
option can be given multiple times.

.IP "--no-default-lib"
Marks the object so that the search for dependencies of this object will ignore any
default library search paths.

.IP "--output FILE"
Set the output file name.  If not specified, the input will be modified in place.

.IP --debug
Prints details of the changes made to the input file.

.IP --version
Shows the version of patchelf.

.SH EXAMPLES

To use the contents on an external file as a parameter:

.RS
$ patchelf a.out --add-rpath @/tmp/generated-rpath.bin
.RE

To change the RPATH of a binary. Note that
.BR $ORIGIN
is a special symbol used by the loader, so must be quoted.

.RS
patchelf --set-rpath '$ORIGIN/../lib64' a.out
.RE


.SH AUTHOR
Eelco Dolstra <e.dolstra@tudelft.nl>

.SH "SEE ALSO"
.BR elf (5),
.BR ld.so (8)