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"
8 lari \- link analysis of runtime interfaces
12 \fBlari\fR [\fB-bCDsVv\fR] [\fB-a\fR | \fB-i\fR | \fB-o\fR] \fIfile\fR | \fIdirectory\fR...
17 \fBlari\fR [\fB-CDosv\fR] [\fB-m\fR [\fB-d\fR \fImapdir\fR]] \fIfile\fR
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.
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.
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
42 When generating interface definitions, \fBlari\fR can only process a single
43 \fIfile\fR specified on the command line.
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:
51 \fB-r\fR and \fB-e\fR \fBLD_DEBUG=files,bindings,detail\fR
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):
67 \fBLD_DEBUG=files,bindings,detail LD_DEBUG_OUTPUT=lari.dbg \
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.
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.
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.
104 The following options are supported.
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.
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.
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.
143 \fB\fB-d\fR \fImapdir\fR\fR
146 Defines the directory, \fImapdir\fR, in which \fImapfiles\fR are created. By
147 default, the current working directory is used.
156 Interprets any input \fIfiles\fR as debugging information rather than as
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.
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.
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.
199 Saves the bindings information produced from \fBldd\fR(1) for further analysis.
209 Appends interesting symbol visibilities. Symbols that are defined as
210 \fBsingleton\fR or are defined \fBprotected\fR are identified with this option.
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
235 [information]: \fIsymbol-name\fR [demangled-name]: \fIobject-name\fR
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
253 \fB\fIcnt\fR:\fIbnd\fR\fR
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.
270 This symbol definition has been bound to from an external object.
279 This symbol definition has been bound to from the same object.
288 This symbol definition has been directly bound to.
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.
311 This symbol definition is the reference data of a copy-relocation.
320 This symbol definition resides in a filtee.
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.
340 This symbol definition is the address of a procedure linkage table entry within
341 a dynamic executable.
350 This symbol lookup originated from a user request, for example,
360 This symbol definition is acting as a filter, and provides for redirection to a
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.
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
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:
436 [2:1E]: interpose1(): ./main
437 [2:0]: interpose1(): ./libA.so
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
461 [2:2ES]: interpose2(): ./libA.so
462 [2:0]: interpose2(): ./libB.so
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
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
519 [2:1EC]: __iob[0x140]: ./main
520 [2:0]: __iob[0x140]: ./libA.so.1
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
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
543 [2:1EA]: foo(): ./main
544 [2:1E]: foo(): ./libA.so
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.
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.
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
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
600 example% \fBlari -s ./main\fR
601 lari: ./main: bindings information saved as: /usr/tmp/lari.dbg.main
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'
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
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:
628 example% \fBlari -omv ./main\fR
629 example% \fBcat mapfile-foo.so\fR
631 # Interface Definition mapfile for:
632 # Dynamic Object: ./foo.so
655 \fB\fB$TMPDIR/lari.dbg.\fIfile\fR\fR\fR
658 Binding output produced by \fBldd\fR(1).
664 See \fBattributes\fR(5) for descriptions of the following attributes:
672 ATTRIBUTE TYPE ATTRIBUTE VALUE
674 Interface Stability See below.
679 The human readable output is Uncommitted. The options are Committed.
683 \fBld\fR(1), \fBldd\fR(1), \fBld.so.1\fR(1), \fBdlopen\fR(3C), \fBdlsym\fR(3C),
687 \fILinker and Libraries Guide\fR