user_namespaces.7: Minor wording improvement
[man-pages.git] / man1 / ldd.1
blob8bb1410d54986addf60729482ffc9e52e8343151
1 .\" Copyright 1995-2000 David Engel (david@ods.com)
2 .\" Copyright 1995 Rickard E. Faith (faith@cs.unc.edu)
3 .\" Copyright 2000 Ben Collins (bcollins@debian.org)
4 .\"    Redone for GLibc 2.2
5 .\" Copyright 2000 Jakub Jelinek (jakub@redhat.com)
6 .\"    Corrected.
7 .\" and Copyright (C) 2012, 2016, Michael Kerrisk <mtk.manpages@gmail.com>
8 .\"
9 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
10 .\" Do not restrict distribution.
11 .\" May be distributed under the GNU General Public License
12 .\" %%%LICENSE_END
13 .\"
14 .TH LDD 1 2021-03-22 "" "Linux Programmer's Manual"
15 .SH NAME
16 ldd \- print shared object dependencies
17 .SH SYNOPSIS
18 .nf
19 .BR ldd " [\fIoption\fP]... \fIfile\fP..."
20 .fi
21 .SH DESCRIPTION
22 .B ldd
23 prints the shared objects (shared libraries) required by each program or
24 shared object specified on the command line.
25 An example of its use and output
26 is the following:
27 .PP
28 .in +4n
29 .EX
30 $ \fBldd /bin/ls\fP
31     linux\-vdso.so.1 (0x00007ffcc3563000)
32     libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f87e5459000)
33     libcap.so.2 => /lib64/libcap.so.2 (0x00007f87e5254000)
34     libc.so.6 => /lib64/libc.so.6 (0x00007f87e4e92000)
35     libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f87e4c22000)
36     libdl.so.2 => /lib64/libdl.so.2 (0x00007f87e4a1e000)
37     /lib64/ld\-linux\-x86\-64.so.2 (0x00005574bf12e000)
38     libattr.so.1 => /lib64/libattr.so.1 (0x00007f87e4817000)
39     libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f87e45fa000)
40 .EE
41 .in
42 .PP
43 In the usual case,
44 .B ldd
45 invokes the standard dynamic linker (see
46 .BR ld.so (8))
47 with the
48 .B LD_TRACE_LOADED_OBJECTS
49 environment variable set to 1.
50 This causes the dynamic linker to inspect the program's dynamic dependencies,
51 and find (according to the rules described in
52 .BR ld.so (8))
53 and load the objects that satisfy those dependencies.
54 For each dependency,
55 .B ldd
56 displays the location of the matching object
57 and the (hexadecimal) address at which it is loaded.
58 (The
59 .I linux\-vdso
60 and
61 .I ld\-linux
62 shared dependencies are special; see
63 .BR vdso (7)
64 and
65 .BR ld.so (8).)
66 .\"
67 .SS Security
68 Be aware that in some circumstances
69 (e.g., where the program specifies an ELF interpreter other than
70 .IR ld\-linux.so ),
71 .\" The circumstances are where the program has an interpreter
72 .\" other than ld-linux.so. In this case, ldd tries to execute the
73 .\" program directly with LD_TRACE_LOADED_OBJECTS=1, with the
74 .\" result that the program interpreter gets control, and can do
75 .\" what it likes, or pass control to the program itself.
76 .\" Much more detail at
77 .\" http://www.catonmat.net/blog/ldd-arbitrary-code-execution/
78 some versions of
79 .B ldd
80 may attempt to obtain the dependency information
81 by attempting to directly execute the program,
82 which may lead to the execution of whatever code is defined
83 in the program's ELF interpreter,
84 and perhaps to execution of the program itself.
85 .\" Mainline glibc's ldd allows this possibility (the line
86 .\"      try_trace "$file"
87 .\" in glibc 2.15, for example), but many distro versions of
88 .\" ldd seem to remove that code path from the script.
89 (In glibc versions before 2.27,
90 .\" glibc commit eedca9772e99c72ab4c3c34e43cc764250aa3e3c
91 the upstream
92 .B ldd
93 implementation did this for example,
94 although most distributions provided a modified version that did not.)
95 .PP
96 Thus, you should
97 .I never
98 employ
99 .B ldd
100 on an untrusted executable,
101 since this may result in the execution of arbitrary code.
102 A safer alternative when dealing with untrusted executables is:
104 .in +4n
106 $ \fBobjdump \-p /path/to/program | grep NEEDED\fP
110 Note, however, that this alternative shows only the direct dependencies
111 of the executable, while
112 .B ldd
113 shows the entire dependency tree of the executable.
114 .SH OPTIONS
116 .B \-\-version
117 Print the version number of
118 .BR ldd .
120 .BR \-v ", " \-\-verbose
121 Print all information, including, for example,
122 symbol versioning information.
124 .BR \-u ", " \-\-unused
125 Print unused direct dependencies.
126 (Since glibc 2.3.4.)
128 .BR \-d ", " \-\-data\-relocs
129 Perform relocations and report any missing objects (ELF only).
131 .BR \-r ", " \-\-function\-relocs
132 Perform relocations for both data objects and functions, and
133 report any missing objects or functions (ELF only).
135 .B \-\-help
136 Usage information.
137 .\" .SH NOTES
138 .\" The standard version of
139 .\" .B ldd
140 .\" comes with glibc2.
141 .\" Libc5 came with an older version, still present
142 .\" on some systems.
143 .\" The long options are not supported by the libc5 version.
144 .\" On the other hand, the glibc2 version does not support
145 .\" .B \-V
146 .\" and only has the equivalent
147 .\" .BR \-\-version .
148 .\" .LP
149 .\" The libc5 version of this program will use the name of a library given
150 .\" on the command line as-is when it contains a \(aq/\(aq; otherwise it
151 .\" searches for the library in the standard locations.
152 .\" To run it
153 .\" on a shared library in the current directory, prefix the name with "./".
154 .SH BUGS
155 .B ldd
156 does not work on a.out shared libraries.
158 .B ldd
159 does not work with some extremely old a.out programs which were
160 built before
161 .B ldd
162 support was added to the compiler releases.
163 If you use
164 .B ldd
165 on one of these programs, the program will attempt to run with
166 .I argc
167 = 0 and the results will be unpredictable.
168 .\" .SH AUTHOR
169 .\" David Engel.
170 .\" Roland McGrath and Ulrich Drepper.
171 .SH SEE ALSO
172 .BR pldd (1),
173 .BR sprof (1),
174 .BR ld.so (8),
175 .BR ldconfig (8)