readv.2, pipe.7: Make text on pipe writes more general to avoid a confusion in writev(2)
[man-pages.git] / man1 / ldd.1
blobed1ab3c0549e71cd4c1af68eaf183ff9cc73c864
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 (using
27 .BR sed (1)
28 to trim leading white space for readability in this page)
29 is the following:
30 .PP
31 .in +4n
32 .EX
33 $ \fBldd /bin/ls | sed \(aqs/^ */    /\(aq\fP
34     linux\-vdso.so.1 (0x00007ffcc3563000)
35     libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f87e5459000)
36     libcap.so.2 => /lib64/libcap.so.2 (0x00007f87e5254000)
37     libc.so.6 => /lib64/libc.so.6 (0x00007f87e4e92000)
38     libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f87e4c22000)
39     libdl.so.2 => /lib64/libdl.so.2 (0x00007f87e4a1e000)
40     /lib64/ld\-linux\-x86\-64.so.2 (0x00005574bf12e000)
41     libattr.so.1 => /lib64/libattr.so.1 (0x00007f87e4817000)
42     libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f87e45fa000)
43 .EE
44 .in
45 .PP
46 In the usual case,
47 .B ldd
48 invokes the standard dynamic linker (see
49 .BR ld.so (8))
50 with the
51 .B LD_TRACE_LOADED_OBJECTS
52 environment variable set to 1.
53 This causes the dynamic linker to inspect the program's dynamic dependencies,
54 and find (according to the rules described in
55 .BR ld.so (8))
56 and load the objects that satisfy those dependencies.
57 For each dependency,
58 .B ldd
59 displays the location of the matching object
60 and the (hexadecimal) address at which it is loaded.
61 (The
62 .I linux\-vdso
63 and
64 .I ld\-linux
65 shared dependencies are special; see
66 .BR vdso (7)
67 and
68 .BR ld.so (8).)
69 .\"
70 .SS Security
71 Be aware that in some circumstances
72 (e.g., where the program specifies an ELF interpreter other than
73 .IR ld\-linux.so ),
74 .\" The circumstances are where the program has an interpreter
75 .\" other than ld-linux.so. In this case, ldd tries to execute the
76 .\" program directly with LD_TRACE_LOADED_OBJECTS=1, with the
77 .\" result that the program interpreter gets control, and can do
78 .\" what it likes, or pass control to the program itself.
79 .\" Much more detail at
80 .\" http://www.catonmat.net/blog/ldd-arbitrary-code-execution/
81 some versions of
82 .B ldd
83 may attempt to obtain the dependency information
84 by attempting to directly execute the program,
85 which may lead to the execution of whatever code is defined
86 in the program's ELF interpreter,
87 and perhaps to execution of the program itself.
88 .\" Mainline glibc's ldd allows this possibility (the line
89 .\"      try_trace "$file"
90 .\" in glibc 2.15, for example), but many distro versions of
91 .\" ldd seem to remove that code path from the script.
92 (In glibc versions before 2.27,
93 .\" glibc commit eedca9772e99c72ab4c3c34e43cc764250aa3e3c
94 the upstream
95 .B ldd
96 implementation did this for example,
97 although most distributions provided a modified version that did not.)
98 .PP
99 Thus, you should
100 .I never
101 employ
102 .B ldd
103 on an untrusted executable,
104 since this may result in the execution of arbitrary code.
105 A safer alternative when dealing with untrusted executables is:
107 .in +4n
109 $ \fBobjdump \-p /path/to/program | grep NEEDED\fP
113 Note, however, that this alternative shows only the direct dependencies
114 of the executable, while
115 .B ldd
116 shows the entire dependency tree of the executable.
117 .SH OPTIONS
119 .B \-\-version
120 Print the version number of
121 .BR ldd .
123 .BR \-v ", " \-\-verbose
124 Print all information, including, for example,
125 symbol versioning information.
127 .BR \-u ", " \-\-unused
128 Print unused direct dependencies.
129 (Since glibc 2.3.4.)
131 .BR \-d ", " \-\-data\-relocs
132 Perform relocations and report any missing objects (ELF only).
134 .BR \-r ", " \-\-function\-relocs
135 Perform relocations for both data objects and functions, and
136 report any missing objects or functions (ELF only).
138 .B \-\-help
139 Usage information.
140 .\" .SH NOTES
141 .\" The standard version of
142 .\" .B ldd
143 .\" comes with glibc2.
144 .\" Libc5 came with an older version, still present
145 .\" on some systems.
146 .\" The long options are not supported by the libc5 version.
147 .\" On the other hand, the glibc2 version does not support
148 .\" .B \-V
149 .\" and only has the equivalent
150 .\" .BR \-\-version .
151 .\" .LP
152 .\" The libc5 version of this program will use the name of a library given
153 .\" on the command line as-is when it contains a \(aq/\(aq; otherwise it
154 .\" searches for the library in the standard locations.
155 .\" To run it
156 .\" on a shared library in the current directory, prefix the name with "./".
157 .SH BUGS
158 .B ldd
159 does not work on a.out shared libraries.
161 .B ldd
162 does not work with some extremely old a.out programs which were
163 built before
164 .B ldd
165 support was added to the compiler releases.
166 If you use
167 .B ldd
168 on one of these programs, the program will attempt to run with
169 .I argc
170 = 0 and the results will be unpredictable.
171 .\" .SH AUTHOR
172 .\" David Engel.
173 .\" Roland McGrath and Ulrich Drepper.
174 .SH SEE ALSO
175 .BR pldd (1),
176 .BR sprof (1),
177 .BR ld.so (8),
178 .BR ldconfig (8)