xref: /illumos-gate/usr/src/tools/find_elf/find_elf.1onbld (revision a4955f4fa65e38d70c07d38e657a9aff43fa155f)
1.\" Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2.\"
3.\" CDDL HEADER START
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
9.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10.\" or http://www.opensolaris.org/os/licensing.
11.\" See the License for the specific language governing permissions
12.\" and limitations under the License.
13.\"
14.\" When distributing Covered Code, include this CDDL HEADER in each
15.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16.\" If applicable, add the following below this CDDL HEADER, with the
17.\" fields enclosed by brackets "[]" replaced with your own identifying
18.\" information: Portions Copyright [yyyy] [name of copyright owner]
19.\"
20.\" CDDL HEADER END
21.\"
22.\" Copyright 2022 Jason King
23.\"
24.Dd September  6, 2022
25.Dt FIND_ELF 1ONBLD
26.Os
27.Sh NAME
28.Nm find_elf
29.Nd Locate ELF objects
30.Sh SYNOPSIS
31.Nm
32.Op Fl afhnrs
33.Ar path
34.Sh DESCRIPTION
35The
36.Nm
37command descends a directory hierarchy and produces one line
38of output on stdout for each ELF object found.
39.Sh OPTIONS
40The following options are supported:
41.Bl -tag -width Fl
42.It Fl a
43Disable alias processing.
44Symbolic links are treated as independent
45files, each such link results in a separate
46.Sy OBJECT
47output line, and
48.Sy ALIAS
49lines are not issued.
50.It Fl f
51Fast Mode.
52When reading directories, the file name and modes are
53used to eliminate files from consideration and speed up the search:
54Directories with names that start with a
55.Ql \&.
56character are skipped.
57Executables must have the execute bit set, and
58shared objects must end with a
59.Ql .so
60extension.
61Files that do not meet these requirements are silently eliminated from
62consideration without further analysis.
63.It Fl h
64Show usage message.
65.It Fl n
66Do not treat well known hard-linked binaries as special.
67Certain well known binaries
68.Po
69currently
70.Pa alias
71and
72.Pa isaexec
73.Pc
74are hard linked to many other names in a proto directory tree.
75.Pp
76By default,
77.Nm
78will use these well known names as the initial name and all other hard links
79to those binaries are treated as aliases.
80Disabling this behavior with the
81.Fl n
82option will choose the first name encountered during directory traversal as
83the name, and all other hard links to the binary as aliases.
84.It Fl r
85Report file names as relative paths, relative to the given file or directory,
86instead of fully qualified.
87.It Fl s
88Only report shared objects.
89.El
90.Sh OUTPUT
91.Nm
92produces a series of
93.Sy PREFIX ,
94.Sy OBJECT ,
95and
96.Sy ALIAS
97lines, which collectively describe the ELF objects located.
98Whitespace is used within each
99line to delimit the various fields of information provided.
100.Pp
101If the
102.Fl r
103option is used to specify that file names be reported
104as relative paths, a
105.Sy PREFIX
106line is output to provide the base path from
107which the relative names should be interpreted.
108There can only be one
109.Sy PREFIX
110line, and it is output first, before any
111.Sy OBJECT
112or
113.Sy ALIAS
114lines.
115.Bd -literal -offset indent
116PREFIX path
117.Ed
118.Pp
119For each object found, an
120.Sy OBJECT
121line is produced to describe it:
122.Bd -literal -offset indent
123OBJECT [32 | 64] [DYN | EXEC | REL] [VERDEF | NOVERDEF] object-path
124.Ed
125.Pp
126The first field provides the ELF class of the object, and will be
127either 32 or 64.
128The second field provides the type of object, either
129a shared object
130.Ql DYN ,
131an executable
132.Ql EXEC ,
133or a relocatable object
134.Ql REL .
135The third field will be
136.Ql VERDEF
137if the object contains ELF version definitions, and
138.Ql NOVERDEF
139if the object is not versioned.
140The final field gives the path to the object.
141.Pp
142Under Unix, a file can have multiple names.
143In the context of ELF objects, this often happens for one of two reasons:
144.Bl -bullet -offset indent
145.It
146Compilation symlinks, used to provide a non-versioned name for a shared object.
147.It
148Symlinks such as
149.Ql 32
150and
151.Ql 64
152used to provide alternative non-machine specific paths to objects.
153.El
154.Pp
155When
156.Nm
157identifies an object via such an aliased name, it issues an
158.Sy ALIAS
159line mapping it to the main name for the object:
160.Bd -literal -offset indent
161ALIAS object-path alias-path
162.Ed
163.Pp
164The
165.Fl a
166option alters the handling of aliased names.
167When
168.Fl a
169is specified, each file results in a separate
170.Sy OBJECT
171line, as if they were
172independent files rather than the same file with different names.
173.Sh EXAMPLES
174Assume the following hierarchy of files exist under
175.Pa /usr/lib/foo :
176.Bd -literal -offset indent
177% /bin/ls -alRF /usr/lib/foo
178/usr/lib/foo:
179total 111
180drwxr-xr-x  3 root root    7 Jul 16 17:35 ./
181drwxr-xr-x 34 root root   42 Jul 16 17:34 ../
182lrwxrwxrwx  1 root bin     1 Jul 16 17:34 32 -> ./
183lrwxrwxrwx  1 root bin     5 Jul 16 17:34 64 -> amd64/
184drwxr-xr-x  2 root bin     4 Jul 16 17:35 amd64/
185lrwxrwxrwx  1 root bin    11 Jul 16 17:35 libfoo.so -> libfoo.so.1*
186-rwxr-xr-x  1 root bin 49132 Jul 16 17:35 libfoo.so.1*
187
188/usr/lib/foo/amd64:
189total 150
190drwxr-xr-x  2 root root   4 Jul 16 17:35 ./
191drwxr-xr-x  3 root root   7 Jul 16 17:35 ../
192lrwxrwxrwx  1 root bin    11 Jul 16 17:35 libfoo.so -> libfoo.so.1*
193-rwxr-xr-x  1 root bin 72536 Jul 16 17:35 libfoo.so.1*
194.Ed
195.Pp
196This hierarchy contains compilation symlinks
197.Po
198.Pa libfoo.so
199.Pc
200and path alias symlinks
201.Po
20232, 64
203.Pc ,
204as discussed in
205.Sx OUTPUT .
206.Pp
207.Nm
208produces the following output for the above hierarchy:
209.Bd -literal -offset indent
210% find_elf -r /usr/lib/foo
211PREFIX /usr/lib/foo
212OBJECT 64 DYN  VERDEF  amd64/libfoo.so.1
213ALIAS                  amd64/libfoo.so.1  64/libfoo.so
214ALIAS                  amd64/libfoo.so.1  64/libfoo.so.1
215ALIAS                  amd64/libfoo.so.1  amd64/libfoo.so
216OBJECT 32 DYN  VERDEF  libfoo.so.1
217ALIAS                  libfoo.so.1        32/libfoo.so
218ALIAS                  libfoo.so.1        32/libfoo.so.1
219ALIAS                  libfoo.so.1        libfoo.so
220.Ed
221.Pp
222Contrast this with the output when
223.Fl a
224is used to treat each name as an independent file:
225.Bd -literal -offset indent
226% find_elf -ar /usr/lib/foo
227PREFIX /usr/lib/foo
228OBJECT 32 DYN  VERDEF  32/libfoo.so
229OBJECT 32 DYN  VERDEF  32/libfoo.so.1
230OBJECT 64 DYN  VERDEF  64/libfoo.so
231OBJECT 64 DYN  VERDEF  64/libfoo.so.1
232OBJECT 64 DYN  VERDEF  amd64/libfoo.so.1
233OBJECT 64 DYN  VERDEF  amd64/libfoo.so
234OBJECT 32 DYN  VERDEF  libfoo.so.1
235OBJECT 32 DYN  VERDEF  libfoo.so
236.Ed
237.Pp
238When
239.Nm
240is used to process an alias for which no target object is given,
241there will be no output.
242For example, using
243.Pa /lib/libc.so ,
244which is a compilation symlink for
245.Pa /lib/libc.so.1 :
246.Bd -literal -offset indent
247% find_elf /lib/libc.so
248.Ed
249.Pp
250In such situations, the
251.Fl a
252option can be used to produce the desired output:
253.Bd -literal -offset indent
254% find_elf -a /lib/libc.so
255OBJECT 32 DYN  VERDEF   /lib/libc.so
256.Ed
257.Sh SEE ALSO
258.Xr elfdump 1 ,
259.Xr ld 1 ,
260.Xr ldd 1 ,
261.Xr pvs 1 ,
262.Xr check_rtime 1ONBLD ,
263.Xr interface_check 1ONBLD ,
264.Xr interface_cmp 1ONBLD
265