xref: /titanic_51/usr/src/tools/depcheck/DependencyCheck.txt (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate
2*7c478bd9Sstevel@tonic-gateCDDL HEADER START
3*7c478bd9Sstevel@tonic-gate
4*7c478bd9Sstevel@tonic-gateThe contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gateCommon Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate(the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gatewith the License.
8*7c478bd9Sstevel@tonic-gate
9*7c478bd9Sstevel@tonic-gateYou can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gateor http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gateSee the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gateand limitations under the License.
13*7c478bd9Sstevel@tonic-gate
14*7c478bd9Sstevel@tonic-gateWhen distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gatefile and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gateIf applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gatefields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gateinformation: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate
20*7c478bd9Sstevel@tonic-gateCDDL HEADER END
21*7c478bd9Sstevel@tonic-gate
22*7c478bd9Sstevel@tonic-gateCopyright 2000 Sun Microsystems, Inc.  All rights reserved.
23*7c478bd9Sstevel@tonic-gateUse is subject to license terms.
24*7c478bd9Sstevel@tonic-gate
25*7c478bd9Sstevel@tonic-gateident	"%Z%%M%	%I%	%E% SMI"
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gateWhat does this tool do for you?
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gateThis tool statically analyzes executable files and tries to figure out
30*7c478bd9Sstevel@tonic-gatedependencies on libraries and other executable files.  It is important to
31*7c478bd9Sstevel@tonic-gaterecognize that the output of this tool may not be the definitive dependency
32*7c478bd9Sstevel@tonic-gatelist, but the output should give you pointers on possible dependencies.
33*7c478bd9Sstevel@tonic-gate
34*7c478bd9Sstevel@tonic-gateFor more information on how this tool works, see "How does this tool work?"
35*7c478bd9Sstevel@tonic-gatebelow.
36*7c478bd9Sstevel@tonic-gate
37*7c478bd9Sstevel@tonic-gate
38*7c478bd9Sstevel@tonic-gate
39*7c478bd9Sstevel@tonic-gateThis set of tools contains 7 files:
40*7c478bd9Sstevel@tonic-gate
41*7c478bd9Sstevel@tonic-gate	1. DependencyCheck.txt - the file you are currently reading
42*7c478bd9Sstevel@tonic-gate	2. make_pkg_db - generate database to reflect the software installed
43*7c478bd9Sstevel@tonic-gate	3. SampleLinks - sample link resolution file for
44*7c478bd9Sstevel@tonic-gate		/var/sadm/install/contents(see notes on make_pkg_db)
45*7c478bd9Sstevel@tonic-gate	4. SamplePkgLinks - sample link resolution file for
46*7c478bd9Sstevel@tonic-gate		a package pool (see notes on make_pkg_db)
47*7c478bd9Sstevel@tonic-gate	5. get_depend_info - analyze executables, requires database files
48*7c478bd9Sstevel@tonic-gate	6. make_pkg_db.txt - text formatted man page
49*7c478bd9Sstevel@tonic-gate	7. get_depend_info.txt - text formatted man page
50*7c478bd9Sstevel@tonic-gate
51*7c478bd9Sstevel@tonic-gate
52*7c478bd9Sstevel@tonic-gate
53*7c478bd9Sstevel@tonic-gate
54*7c478bd9Sstevel@tonic-gateHow to use this tool:
55*7c478bd9Sstevel@tonic-gate
56*7c478bd9Sstevel@tonic-gate	a. run make_pkg_db with the -dbdir argument
57*7c478bd9Sstevel@tonic-gate	b. read the README notes on make_pkg_db and decide if you
58*7c478bd9Sstevel@tonic-gate	   want to resolve the symbolic links
59*7c478bd9Sstevel@tonic-gate	c. run the get_depend_info tool and specify the directory with
60*7c478bd9Sstevel@tonic-gate	   the package database files
61*7c478bd9Sstevel@tonic-gate
62*7c478bd9Sstevel@tonic-gate
63*7c478bd9Sstevel@tonic-gate
64*7c478bd9Sstevel@tonic-gateHow does this tool work?
65*7c478bd9Sstevel@tonic-gate
66*7c478bd9Sstevel@tonic-gateAt a high level, this tool uses /usr/bin/ldd and /usr/bin/strings to figure
67*7c478bd9Sstevel@tonic-gateout what an executable file depends upon.  Since this is a static analysis
68*7c478bd9Sstevel@tonic-gatethere is no way to know if the dependencies identified will actually be
69*7c478bd9Sstevel@tonic-gateexecuted.
70*7c478bd9Sstevel@tonic-gate
71*7c478bd9Sstevel@tonic-gateThe strings command will not be run on binaries if the user specifies the
72*7c478bd9Sstevel@tonic-gate-cons option for get_depend_info.
73*7c478bd9Sstevel@tonic-gate
74*7c478bd9Sstevel@tonic-gateThis tool cannot resolve variable substitions.  For example if a shell script
75*7c478bd9Sstevel@tonic-gateset "$MYPATH" to "/usr/sbin" and then executes "$MYPATH/df", this tool will
76*7c478bd9Sstevel@tonic-gatenot be able to resolve that the shell script will execute "/usr/sbin/df".
77*7c478bd9Sstevel@tonic-gate
78*7c478bd9Sstevel@tonic-gateThe only way to conclusively know all the dependencies is to do a runtime
79*7c478bd9Sstevel@tonic-gateanalysis. Furthermore, to get the complete set of dependencies, you would need
80*7c478bd9Sstevel@tonic-gateto run all permutations of the executable being analyzed.  Clearly a definitive
81*7c478bd9Sstevel@tonic-gatedependency check would be a tremendous amount of work and outside the scope
82*7c478bd9Sstevel@tonic-gateof this tool.
83*7c478bd9Sstevel@tonic-gate
84*7c478bd9Sstevel@tonic-gateThis tool divides executables into three broad groups - kernel modules,
85*7c478bd9Sstevel@tonic-gatebinaries and shell scripts.
86*7c478bd9Sstevel@tonic-gate
87*7c478bd9Sstevel@tonic-gateFor all three types of files, all the output is verified against the entries
88*7c478bd9Sstevel@tonic-gatein database generated by make_pkg_db.  This technique allows the tool to verify
89*7c478bd9Sstevel@tonic-gatethat a dependency was part of the Solaris installation and determine which
90*7c478bd9Sstevel@tonic-gatepackage a given dependency came from.
91*7c478bd9Sstevel@tonic-gate
92*7c478bd9Sstevel@tonic-gate
93*7c478bd9Sstevel@tonic-gate
94*7c478bd9Sstevel@tonic-gateA.  Dependency Checks on Kernel Modules
95*7c478bd9Sstevel@tonic-gate
96*7c478bd9Sstevel@tonic-gateKernel modules are identified by having a "/kernel/" somewhere in their
97*7c478bd9Sstevel@tonic-gatepath.  If an input is identified as a kernel module, then an ldd is run on
98*7c478bd9Sstevel@tonic-gatethat module.  If the ldd returns output, then the tool parses that output
99*7c478bd9Sstevel@tonic-gateto see if it can find the library in /kernel or in /usr/kernel.  For example,
100*7c478bd9Sstevel@tonic-gateif the tool runs on /kernel/drv/mydrv, the ldd will return something like
101*7c478bd9Sstevel@tonic-gate"misc/mylib".  The tool will look for "mylib"in /kernel/misc/mylib or
102*7c478bd9Sstevel@tonic-gate/usr/kernel/misc/mylib.
103*7c478bd9Sstevel@tonic-gate
104*7c478bd9Sstevel@tonic-gateIf the ldd returns nothing, then a "strings" command is run on the kernel
105*7c478bd9Sstevel@tonic-gatemodule.  Again, the output of the strings is compared against /kernel and
106*7c478bd9Sstevel@tonic-gate/usr/kernel to see if there is a match.  This method was designed to catch
107*7c478bd9Sstevel@tonic-gatethe "_depends_on" string embedded in some kernel modules.
108*7c478bd9Sstevel@tonic-gate
109*7c478bd9Sstevel@tonic-gateNote, if the ldd succeeds, then a strings will not run on the kernel module.
110*7c478bd9Sstevel@tonic-gate
111*7c478bd9Sstevel@tonic-gate
112*7c478bd9Sstevel@tonic-gateB. Binary files
113*7c478bd9Sstevel@tonic-gate
114*7c478bd9Sstevel@tonic-gateBinary files have both the ldd and strings command run on them.  The output of
115*7c478bd9Sstevel@tonic-gateboth programs is parsed and checked against the contents of the database
116*7c478bd9Sstevel@tonic-gategenerated by make_pkg_db.
117*7c478bd9Sstevel@tonic-gate
118*7c478bd9Sstevel@tonic-gateIf the user specifies the -cons option on get_depend_info, then the strings
119*7c478bd9Sstevel@tonic-gateanalysis will not be done.  This is a more conservative approach which only
120*7c478bd9Sstevel@tonic-gateuses ldd and therefore has realiable output.
121*7c478bd9Sstevel@tonic-gate
122*7c478bd9Sstevel@tonic-gate
123*7c478bd9Sstevel@tonic-gateC. Shell scripts
124*7c478bd9Sstevel@tonic-gate
125*7c478bd9Sstevel@tonic-gateShell scripts are parsed to remove comments and break the script into tokens
126*7c478bd9Sstevel@tonic-gateof the file.  All the tokens in the file are cross-checked against the database
127*7c478bd9Sstevel@tonic-gategenerated by make_pkg_db to determine if a dependency exists.
128*7c478bd9Sstevel@tonic-gate
129*7c478bd9Sstevel@tonic-gate
130