8815 mega_sas: variable set but not used
[unleashed.git] / usr / src / man / man1 / lari.1
blob39e4ff3531a721e6cccb24a387b7853a736d650d
1 '\" te
2 .\"  Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH LARI 1 "Nov 28, 2007"
7 .SH NAME
8 lari \- link analysis of runtime interfaces
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBlari\fR [\fB-bCDsVv\fR] [\fB-a\fR | \fB-i\fR | \fB-o\fR] \fIfile\fR | \fIdirectory\fR...
13 .fi
15 .LP
16 .nf
17 \fBlari\fR [\fB-CDosv\fR] [\fB-m\fR [\fB-d\fR \fImapdir\fR]] \fIfile\fR
18 .fi
20 .SH DESCRIPTION
21 .sp
22 .LP
23 The \fBlari\fR utility analyzes the interface requirements of dynamic \fBELF\fR
24 objects. Two basic modes of operation are available. The first mode displays
25 runtime interface information. The second mode generates interface definitions.
26 .sp
27 .LP
28 Dynamic objects offer symbolic definitions that represent the interface that
29 the object provides for external consumers. At runtime, bindings are
30 established from the symbolic references of one object to the symbolic
31 definitions of another object. \fBlari\fR analyzes both the interface
32 definitions and runtime bindings of the specified objects.
33 .sp
34 .LP
35 When displaying runtime interface information, \fBlari\fR can analyze a number
36 of files and/or directories. \fBlari\fR analyzes each \fIfile\fR that is
37 specified on the command line. \fBlari\fR recursively descends into each
38 \fIdirectory\fR that is specified on the command line, processing each file
39 that is found.
40 .sp
41 .LP
42 When generating interface definitions, \fBlari\fR can only process a single
43 \fIfile\fR specified on the command line.
44 .sp
45 .LP
46 Without the \fB-D\fR option, \fBlari\fR processes files as dynamic \fBELF\fR
47 objects by using \fBldd\fR(1). This processing uses the following options:
48 .sp
49 .in +2
50 .nf
51 \fB-r\fR and \fB-e\fR \fBLD_DEBUG=files,bindings,detail\fR
52 .fi
53 .in -2
54 .sp
56 .sp
57 .LP
58 These options provide information on all bindings that are established as part
59 of loading the object. Notice that by using \fBldd\fR, the specified object is
60 not executed, and hence no user controlled loading of objects, by
61 \fBdlopen\fR(3C) for example, occurs. To capture all binding information from
62 an executing process, the following environment variables can be passed
63 directly to the runtime linker, \fBld.so.1\fR(1):
64 .sp
65 .in +2
66 .nf
67 \fBLD_DEBUG=files,bindings,detail LD_DEBUG_OUTPUT=lari.dbg \
68 LD_BIND_NOW=yes\fR
69 .fi
70 .in -2
71 .sp
73 .sp
74 .LP
75 The resulting debug output, \fBlari.dbg.\fIpid\fR\fR, can be processed by
76 \fBlari\fR using the \fB-D\fR option. \fBNote:\fR \fBlari\fR attempts to
77 analyze each object that has been processed using the path name defined in the
78 debug output. Each object must therefore be accessible to \fBlari\fR for a
79 complete, accurate analysis to be provided. The debug output file must be
80 generated in the \fBC\fR locale.
81 .sp
82 .LP
83 When displaying interface information, \fBlari\fR analyzes the interfaces of
84 the processed dynamic objects and, by default, displays any interesting
85 information. See \fBInteresting Information\fR under EXTENDED DESCRIPTION. The
86 information that is displayed is also suitable for piping to other tools. This
87 capability can aid developers in analyzing process bindings or debugging
88 complex binding scenarios.
89 .sp
90 .LP
91 The generation of interface definitions by \fBlari\fR can be used to refine the
92 interface requirements of the dynamic objects that are processed. When creating
93 a dynamic object, you should define an explicit, versioned interface. This
94 definition controls the symbol definitions that are available to external
95 users. In addition, this definition frequently reduces the overall runtime
96 execution cost of the object. Interface definitions can be assigned to an
97 object during its creation by the link-editor using the \fB-M\fR option and the
98 associated \fImapfile\fR directives. See the \fILinker and Libraries Guide\fR
99 for more details on using \fImapfiles\fR to version objects. An initial version
100 of these \fImapfiles\fR can be created by \fBlari\fR.
101 .SH OPTIONS
104 The following options are supported.
106 .ne 2
108 \fB\fB-a\fR\fR
110 .RS 13n
111 Displays all interface information for the objects analyzed. \fBNote:\fR The
112 output from this option can be substantial, but is often useful for piping to
113 other analysis tools.
117 .ne 2
119 \fB\fB-b\fR\fR
121 .RS 13n
122 Limits the interface information to those symbols that have been explicitly
123 bound to. \fBNote:\fR Symbols defined as protected might have been bound to
124 from within the defining object. This binding is satisfied at link-edit time
125 and is therefore not visible to the runtime environment. Protected symbols are
126 displayed with this option.
130 .ne 2
132 \fB\fB-C\fR\fR
134 .RS 13n
135 Demangles C++ symbol names. This option is useful for augmenting runtime
136 interface information. When generating interface definitions, demangled names
137 are added to the \fImapfiles\fR as comments.
141 .ne 2
143 \fB\fB-d\fR \fImapdir\fR\fR
145 .RS 13n
146 Defines the directory, \fImapdir\fR, in which \fImapfiles\fR are created. By
147 default, the current working directory is used.
151 .ne 2
153 \fB\fB-D\fR\fR
155 .RS 13n
156 Interprets any input \fIfiles\fR as debugging information rather than as
157 dynamic objects.
161 .ne 2
163 \fB\fB-i\fR\fR
165 .RS 13n
166 Displays interesting interface binding information. This mode is the default if
167 no other output controlling option is supplied. See \fBInteresting
168 Information\fR under EXTENDED DESCRIPTION.
172 .ne 2
174 \fB\fB-m\fR\fR
176 .RS 13n
177 Creates \fImapfiles\fR for each dynamic object that is processed. These
178 \fImapfiles\fR reflect the interface requirements of each object as required by
179 the input file being processed.
183 .ne 2
185 \fB\fB-o\fR\fR
187 .RS 13n
188 Limits the interface information to those symbols that are deemed an overhead.
189 When creating \fImapfiles\fR, any overhead symbols are itemized as local
190 symbols. See \fBOverhead Information\fR under EXTENDED DESCRIPTION.
194 .ne 2
196 \fB\fB-s\fR\fR
198 .RS 13n
199 Saves the bindings information produced from \fBldd\fR(1) for further analysis.
200 See FILES.
204 .ne 2
206 \fB\fB-V\fR\fR
208 .RS 13n
209 Appends interesting symbol visibilities. Symbols that are defined as
210 \fBsingleton\fR or are defined \fBprotected\fR are identified with this option.
214 .ne 2
216 \fB\fB-v\fR\fR
218 .RS 13n
219 Ignores any objects that are already versioned. Versioned objects have had
220 their interfaces defined, but can contribute to the interface information
221 displayed. For example, a versioned shared object might reveal overhead symbols
222 for a particular process. Shared objects are frequently designed for use by
223 multiple processes, and thus the interfaces these objects provide can extend
224 beyond the requirements of any one process. The \fB-v\fR option therefore, can
225 reduce noise when displaying interface information.
230 The runtime interface information produced from \fBlari\fR has the following
231 format:
233 .in +2
235 [information]: \fIsymbol-name\fR [demangled-name]: \fIobject-name\fR
237 .in -2
242 Each line describes the interface symbol, \fBsymbol-name\fR, together with the
243 object, \fBobject-name\fR, in which the symbol is defined. If the symbol
244 represents a function, the symbol name is followed by \fB()\fR. If the symbol
245 represents a data object, the symbol name is followed by the symbols size,
246 enclosed within \fB[]\fR. If the \fB-C\fR option is used, the symbol name is
247 accompanied by the symbols demangled name, \fBdemangled-name\fR. The
248 information field provides one or more of the following tokens that describe
249 the symbol's use:
251 .ne 2
253 \fB\fIcnt\fR:\fIbnd\fR\fR
255 .RS 11n
256 Two decimal values indicate the symbol count, \fBcnt\fR, and the number of
257 bindings to this object, \fBbnd\fR. The symbol count is the number of
258 occurrences of this symbol definition that have been found in the objects that
259 are analyzed. A count that is greater than \fB1\fR indicates multiple instances
260 of a symbol definition. The number of bindings indicate the number of objects
261 that have been bound to this symbol definition by the runtime linker.
265 .ne 2
267 \fB\fBE\fR\fR
269 .RS 11n
270 This symbol definition has been bound to from an external object.
274 .ne 2
276 \fB\fBS\fR\fR
278 .RS 11n
279 This symbol definition has been bound to from the same object.
283 .ne 2
285 \fB\fBD\fR\fR
287 .RS 11n
288 This symbol definition has been directly bound to.
292 .ne 2
294 \fB\fBI\fR\fR
296 .RS 11n
297 This symbol definition provides for an interposer.  An object that explicitly
298 identifies itself as an interposor defines all global symbols as interposers.
299 See the \fB-z\fR \fBinterpose\fR option of \fBld\fR(1), and the
300 \fBLD_PRELOAD\fR variable of \fBld.so.1\fR(1). Individual symbols within a
301 dynamic executable can be defined as interposers by using the \fBINTERPOSE\fR
302 \fBmapfile\fR directive.
306 .ne 2
308 \fB\fBC\fR\fR
310 .RS 11n
311 This symbol definition is the reference data of a copy-relocation.
315 .ne 2
317 \fB\fBF\fR\fR
319 .RS 11n
320 This symbol definition resides in a filtee.
324 .ne 2
326 \fB\fBP\fR\fR
328 .RS 11n
329 This symbol is defined as protected. This symbol might have an internal binding
330 from the object in which the symbol is declared. Any internal bindings with
331 this attribute can not be interposed upon by another symbol definition.
335 .ne 2
337 \fB\fBA\fR\fR
339 .RS 11n
340 This symbol definition is the address of a procedure linkage table entry within
341 a dynamic executable.
345 .ne 2
347 \fB\fBU\fR\fR
349 .RS 11n
350 This symbol lookup originated from a user request, for example,
351 \fBdlsym\fR(3C).
355 .ne 2
357 \fB\fBR\fR\fR
359 .RS 11n
360 This symbol definition is acting as a filter, and provides for redirection to a
361 filtee.
365 .ne 2
367 \fB\fBr\fR\fR
369 .RS 11n
370 A binding to this symbol was rejected at some point during a symbol search. A
371 rejection can occur when a direct binding request finds a symbol that has been
372 tagged to prevent direct binding. In this scenario, the symbol search is
373 repeated using a default search model. The binding can still resolve to the
374 original, rejected symbol. A rejection can also occur when a non-default symbol
375 search finds a symbol identified as a \fBsingleton\fR. Again, the symbol search
376 is repeated using a default search model.
380 .ne 2
382 \fB\fBN\fR\fR
384 .RS 11n
385 This symbol definition explicitly prohibits directly binding to the definition.
390 See the \fILinker and Libraries Guide\fR for more details of these symbol
391 classifications.
392 .SH EXTENDED DESCRIPTION
393 .SS "Interesting Information"
396 By default, or specifically using the \fB-i\fR option, \fBlari\fR filters any
397 runtime interface information to present interesting events. This filtering is
398 carried out mainly to reduce the amount of information that can be generated
399 from large applications. In addition, this information is intended to be the
400 focus in debugging complex binding scenarios, and often highlights problem
401 areas. However, classifying what information is interesting for any particular
402 application is an inexact science. You are still free to use the \fB-a\fR
403 option and to search the binding information for events that are unique to the
404 application being investigated.
407 When an interesting symbol definition is discovered, all other definitions of
408 the same symbol are output.
411 The focus of interesting interface information is the existence of multiple
412 definitions of a symbol. In this case, one symbol typically interposes on one
413 or more other symbol definitions. This interposition is seen when the binding
414 count, \fBbnd\fR, of one definition is non-zero, while the binding count of all
415 other definitions is zero. Interposition that results from the compilation
416 environment, or the linking environment, is not characterized as interesting.
417 Examples of these interposition occurrences include copy relocations
418 (\fB[C]\fR) and the binding to procedure linkage addresses (\fB[A]\fR).
421 Interposition is often desirable. The intent is to overload, or replace, the
422 symbolic definition from a shared object. Interpositioning objects can be
423 explicitly tagged (\fB[I]\fR), using the \fB-z interpose\fR option of
424 \fBld\fR(1). These objects can safely interpose on symbols, no matter what
425 order the objects are loaded in a process. However, be cautious when
426 non-explicit interposition is employed, as this interposition is a consequence
427 of the load-order of the objects that make up the process.
430 User-created, multiply-defined symbols are output from \fBlari\fR as
431 interesting. In this example, two definitions of \fBinterpose1()\fR exist, but
432 only the definition in \fBmain\fR is referenced:
434 .in +2
436 [2:1E]: interpose1(): ./main
437 [2:0]: interpose1(): ./libA.so
439 .in -2
444 Interposition can also be an undesirable and surprising event, caused by an
445 unexpected symbol name clash. A symptom of this interposition might be that a
446 function is never called although you know a reference to the function exists.
447 This scenario can be identified as a multiply defined symbol, as covered in the
448 previous example. However, a more surprising scenario is often encountered when
449 an object both defines and references a specific symbol.
452 An example of this scenario is if two dynamic objects define and reference the
453 same function, \fBinterpose2()\fR. Any reference to this symbol binds to the
454 first dynamic object loaded with the process. In this case, the definition of
455 \fBinterpose2()\fR in object \fBlibA.so\fR interposes on, and hides, the
456 definition of \fBinterpose2()\fR in object \fBlibB.so\fR. The output from
457 \fBlari\fR might be:
459 .in +2
461 [2:2ES]: interpose2(): ./libA.so
462 [2:0]: interpose2(): ./libB.so
464 .in -2
469 Multiply defined symbols can also be bound to separately. Separate bindings can
470 be the case when direct bindings are in effect (\fB[D]\fR), or because a symbol
471 has protected visibility (\fB[P]\fR). Although separate bindings can be
472 explicitly established, instances can exist that are unexpected and surprising.
473 Directly bound symbols, and symbols with protected visibility, are output as
474 interesting information.
475 .SS "Overhead Information"
478 When using the \fB-o\fR option, \fBlari\fR displays symbol definitions that
479 might be considered overhead.
482 Global symbols that are not referenced are considered an overhead. The symbol
483 information that is provided within the object unnecessarily adds to the size
484 of the object's text segment. In addition, the symbol information can increase
485 the processing required to search for other symbolic references within the
486 object at runtime.
489 Global symbols that are only referenced from the same object have the same
490 characteristics. The runtime search for a symbolic reference, that results in
491 binding to the same object that made the reference, is an additional overhead.
494 Both of these symbol definitions are candidates for reduction to local scope by
495 defining the object's interface. Interface definitions can be assigned to a
496 file during its creation by the link-editor using the \fB-M\fR option and the
497 associated \fImapfile\fR directives. See the \fILinker and Libraries Guide\fR
498 for more details on \fImapfiles\fR. Use \fBlari\fR with the \fB-m\fR option to
499 create initial versions of these \fImapfiles\fR.
502 If \fBlari\fR is used to generate \fImapfiles\fR, versioned shared objects will
503 have \fImapfiles\fR created indicating that their overhead symbols should be
504 reduced to locals. This model allows \fBlari\fR to generate \fImapfiles\fR for
505 comparison with existing interface definitions. Use the \fB-v\fR option to
506 ignore versioned shared objects when creating \fImapfiles\fR.
509 Copy-relocations are also viewed as an overhead and generally should be
510 avoided. The size of the copied data is a definition of its interface. This
511 definition restricts the ability to change the data size in newer versions of
512 the shared object in which the data is defined. This restriction, plus the cost
513 of processing a copy relocation, can be avoided by referencing data using a
514 functional interface. The output from \fBlari\fR for a copy relocation might
517 .in +2
519 [2:1EC]: __iob[0x140]: ./main
520 [2:0]: __iob[0x140]: ./libA.so.1
522 .in -2
527 Notice that a number of small copy relocations, such as \fB__iob\fR used in the
528 previous example, exist because of historic programming interactions with
529 system libraries.
532 Another example of overhead information is the binding of a dynamic object to
533 the procedure linkage table entry of a dynamic executable. If a dynamic
534 executable references an external function, a procedure linkage table entry is
535 created. This structure allows the reference binding to be deferred until the
536 function call is actually made. If a dynamic object takes the address of the
537 same referenced function, the dynamic object binds to the dynamic executables
538 procedure linkage table entry. An example of this type of event reveals the
539 following:
541 .in +2
543 [2:1EA]: foo(): ./main
544 [2:1E]: foo(): ./libA.so
546 .in -2
551 A small number of bindings of this type are typically not cause for concern.
552 However, a large number of these bindings, perhaps from a jump-table
553 programming technique, can contribute to start up overhead. Address relocation
554 bindings of this type require relocation processing at application start up,
555 rather than the deferred relocation processing used when calling functions
556 directly. Use of this address also requires an indirection at runtime.
557 .SH EXAMPLES
559 \fBExample 1 \fRAnalyzing a case of multiple bindings
562 The following example shows the analysis of a process in which multiple symbol
563 definitions exist. The shared objects \fBlibX.so\fR and \fBlibY.so\fR both call
564 the function \fBinterpose()\fR. This function exists in both the application
565 \fBmain\fR, and the shared object \fBlibA.so\fR. Because of interposition, both
566 references bind to the definition of \fBinterpose()\fR in \fBmain\fR.
570 The shared objects \fBlibX.so\fR and \fBlibY.so\fR also both call the function
571 \fBfoo()\fR. This function exists in the application \fBmain\fR, and the shared
572 objects \fBlibA.so\fR, \fBlibX.so\fR, and \fBlibY.so\fR. Because both
573 \fBlibX.so\fR and \fBlibY.so\fR were built with direct bindings enabled, each
574 object binds to its own definition.
577 .in +2
579 example% \fBlari ./main\fR
580 [3:0]: foo(): ./libA.so
581 [3:1SD]: foo(): ./libX.so
582 [3:1SD]: foo(): ./libY.so
583 [2:0]: interpose(): ./libA.so
584 [2:2EP]: interpose(): ./main
586 .in -2
591 To analyze binding information more thoroughly, the bindings data can be saved
592 for further inspection. For example, the previous output indicates that the
593 function \fBinterpose()\fR was called from two objects external to \fBmain\fR.
594 Inspection of the binding output reveals where the references to this function
595 originated.
598 .in +2
600 example% \fBlari -s ./main\fR
601 lari: ./main: bindings information saved as: /usr/tmp/lari.dbg.main
602 \&.....
603 example% \fBfgrep foo /usr/tmp/lari.dbg.main\fR
604 binding file=./libX.so to file=./main: symbol `interpose'
605 binding file=./libY.so to file=./main: symbol `interpose'
607 .in -2
612 \fBNote:\fR The bindings output is typically more extensive than shown here, as
613 the output is accompanied with process identifier, address and other bindings
614 information.
617 \fBExample 2 \fRGenerating an interface definition
620 The following example creates interface definitions for an application and its
621 dependency, while ignoring any versioned system libraries. The application
622 \fBmain\fR makes reference to the interfaces \fBone()\fR, \fBtwo()\fR, and
623 \fBthree()\fR in \fBfoo.so\fR:
626 .in +2
628 example% \fBlari -omv ./main\fR
629 example% \fBcat mapfile-foo.so\fR
631 # Interface Definition mapfile for:
632 #       Dynamic Object: ./foo.so
633 #       Process:        ./main
636 foo.so {
637         global:
638                 one;
639                 three;
640                 two;
641         local:
642                 _one;
643                 _three;
644                 _two;
645                 *;
648 .in -2
651 .SH FILES
653 .ne 2
655 \fB\fB$TMPDIR/lari.dbg.\fIfile\fR\fR\fR
657 .RS 25n
658 Binding output produced by \fBldd\fR(1).
661 .SH ATTRIBUTES
664 See \fBattributes\fR(5) for descriptions of the following attributes:
669 box;
670 c | c
671 l | l .
672 ATTRIBUTE TYPE  ATTRIBUTE VALUE
674 Interface Stability     See below.
679 The human readable output is Uncommitted. The options are Committed.
680 .SH SEE ALSO
683 \fBld\fR(1), \fBldd\fR(1), \fBld.so.1\fR(1), \fBdlopen\fR(3C), \fBdlsym\fR(3C),
684 \fBattributes\fR(5)
687 \fILinker and Libraries Guide\fR