author | Matthew Ahrens <Matthew.Ahrens@Sun.COM> |
Sat, 18 Apr 2009 13:41:47 -0700 | |
changeset 9396 | f41cf682d0d3 |
parent 9203 | 3ebffd0a1b10 |
child 9663 | ace9a2ac3683 |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/perl5/bin/perl -w |
2 |
# |
|
3 |
# CDDL HEADER START |
|
4 |
# |
|
5 |
# The contents of this file are subject to the terms of the |
|
1303 | 6 |
# Common Development and Distribution License (the "License"). |
7 |
# You may not use this file except in compliance with the License. |
|
0 | 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 |
# |
|
1303 | 22 |
|
0 | 23 |
# |
8629
6a34e2627e5d
6791534 MMS move to use Postgres 8.3
David Major <David.Major@Sun.COM>
parents:
8299
diff
changeset
|
24 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
0 | 25 |
# Use is subject to license terms. |
26 |
# |
|
27 |
# |
|
1303 | 28 |
|
29 |
# |
|
0 | 30 |
# Check ELF information. |
31 |
# |
|
32 |
# This script descends a directory hierarchy inspecting ELF dynamic executables |
|
33 |
# and shared objects. The general theme is to verify that common Makefile rules |
|
34 |
# have been used to build these objects. Typical failures occur when Makefile |
|
35 |
# rules are re-invented rather than being inherited from "cmd/lib" Makefiles. |
|
36 |
# |
|
37 |
# As always, a number of components don't follow the rules, and these are |
|
38 |
# excluded to reduce this scripts output. Pathnames used for this exclusion |
|
39 |
# assume this script is being run over a "proto" area. The -a (all) option |
|
40 |
# skips any exclusions. |
|
41 |
# |
|
42 |
# By default any file that has conditions that should be reported is first |
|
43 |
# listed and then each condition follows. The -o (one-line) option produces a |
|
44 |
# more terse output which is better for sorting/diffing with "nightly". |
|
45 |
# |
|
46 |
# NOTE: missing dependencies, symbols or versions are reported by running the |
|
47 |
# file through ldd(1). As objects within a proto area are built to exist in a |
|
48 |
# base system, standard use of ldd(1) will bind any objects to dependencies |
|
49 |
# that exist in the base system. It is frequently the case that newer objects |
|
50 |
# exist in the proto area that are required to satisfy other objects |
|
51 |
# dependencies, and without using these newer objects an ldd(1) will produce |
|
52 |
# misleading error messages. To compensate for this, the -d option (or the |
|
53 |
# existence of the CODEMSG_WS/ROOT environment variables) cause the creation of |
|
54 |
# alternative dependency mappings via crle(1) configuration files that establish |
|
55 |
# any proto shared objects as alternatives to their base system location. Thus |
|
56 |
# ldd(1) can be executed against these configuration files so that objects in a |
|
57 |
# proto area bind to their dependencies in the same proto area. |
|
58 |
||
59 |
||
60 |
# Define all global variables (required for strict) |
|
5905 | 61 |
use vars qw($SkipDirs $SkipFiles $SkipTextrelFiles $SkipDirectBindFiles); |
9114
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
62 |
use vars qw($SkipUndefFiles $SkipUnusedDeps); |
3967
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
63 |
use vars qw($SkipStabFiles $SkipNoExStkFiles $SkipCrleConf); |
9114
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
64 |
use vars qw($SkipUnusedSearchPath $SkipUnrefObject $SkipUnusedObject); |
6568 | 65 |
use vars qw($Prog $Mach $Isalist $Env $Ena64 $Tmpdir $Error $Gnuc); |
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
66 |
use vars qw($UnusedPaths $LddNoU $Crle32 $Crle64 $Conf32 $Conf64); |
5905 | 67 |
use vars qw($SkipDirectBindDirs $SkipInterps $SkipSymSort $OldDeps %opt); |
0 | 68 |
|
69 |
use strict; |
|
70 |
||
71 |
||
72 |
# Define any directories we should skip completely. |
|
73 |
$SkipDirs = qr{ |
|
74 |
usr/lib/devfsadm | # 4382889 |
|
75 |
usr/lib/libc | # optimized libc |
|
76 |
usr/lib/rcm | # 4426119 |
|
77 |
usr/perl5 | # alan's taking care of these :-) |
|
78 |
usr/src # no need to look at shipped source |
|
79 |
}x; |
|
80 |
||
81 |
# Define any files we should skip completely. |
|
82 |
$SkipFiles = qr{ ^(?: |
|
83 |
lddstub | # lddstub has no dependencies |
|
84 |
geniconvtbl\.so | # 4384329 |
|
85 |
libssagent\.so\.1 | # 4328854 |
|
86 |
libpsvcplugin_psr\.so\.1 | # 4385799 |
|
87 |
libpsvcpolicy_psr\.so\.1 | # " " |
|
88 |
libpsvcpolicy\.so\.1 | # " " |
|
89 |
picl_slm\.so | # " " |
|
2152
5cf8af99c0b3
6436340 check_rtime should be updated in anticipation of the IPP listener migration to ON
jacobs
parents:
2139
diff
changeset
|
90 |
mod_ipp\.so | # Apache loadable module |
6429 | 91 |
fptest | # USIII specific extns. cause ldd noise on USII bld. m/c |
0 | 92 |
grub |
93 |
)$ |
|
94 |
}x; |
|
95 |
||
96 |
# Define any files that are allowed text relocations. |
|
97 |
$SkipTextrelFiles = qr{ ^(?: |
|
98 |
unix | # kernel models are non-pic |
|
99 |
mdb # relocations against __RTC (dbx) |
|
100 |
)$ |
|
101 |
}x; |
|
102 |
||
5905 | 103 |
# Define any directories or files that are allowed to have no direct bound |
104 |
# symbols |
|
105 |
$SkipDirectBindDirs = qr{ |
|
106 |
usr/ucb |
|
107 |
}x; |
|
108 |
||
109 |
$SkipDirectBindFiles = qr{ ^(?: |
|
110 |
unix | |
|
111 |
sbcp | |
|
112 |
libproc.so.1 | |
|
113 |
libnisdb.so.2 |
|
114 |
)$ |
|
115 |
}x; |
|
116 |
||
0 | 117 |
# Define any files that are allowed undefined references. |
118 |
||
119 |
$SkipUndefFiles = qr{ ^(?: |
|
120 |
libsvm\.so\.1 | # libspmicommon.so.1 lacking |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
121 |
libnisdb\.so\.2 # C++ |
0 | 122 |
)$ |
123 |
}x; |
|
124 |
||
125 |
# Define any files that have unused dependencies. |
|
9114
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
126 |
$SkipUnusedDeps = qr{ |
0 | 127 |
lib/picl/plugins/ | # require devtree dependencies |
128 |
/lib/libp # profile libc makes libm an unused |
|
129 |
}x; # dependency of standard libc |
|
130 |
||
9114
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
131 |
# Define any objects that always look unused. |
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
132 |
$SkipUnusedObject = qr{ |
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
133 |
/libm_hwcap[0-9]+\.so\.2 # libm.so.2 dependency |
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
134 |
}x; |
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
135 |
|
0 | 136 |
# Define any files that should contain debugging information. |
137 |
$SkipStabFiles = qr{ ^(?: |
|
138 |
unix |
|
139 |
)$ |
|
140 |
}x; |
|
141 |
||
142 |
# Define any files that don't require a non-executable stack definition. |
|
143 |
$SkipNoExStkFiles = qr{ ^(?: |
|
144 |
forth | |
|
145 |
unix | |
|
146 |
multiboot |
|
147 |
)$ |
|
148 |
}x; |
|
149 |
||
3967
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
150 |
# Identify any files that should be skipped when building a crle(1) |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
151 |
# configuration file. As the hwcap libraries can be loop-back mounted onto |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
152 |
# libc, these can confuse crle(1) because of their identical dev/inode. |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
153 |
$SkipCrleConf = qr{ |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
154 |
lib/libc/libc_hwcap |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
155 |
}x; |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
156 |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
157 |
# Skip "unused search path=" ldd(1) diagnostics. |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
158 |
$SkipUnusedSearchPath = qr{ |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
159 |
/usr/lib/fs/autofs.*\ from\ .automountd | # dlopen() |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
160 |
/etc/ppp/plugins.*\ from\ .*pppd | # dlopen() |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
161 |
/usr/lib/inet/ppp.*\ from\ .*pppd | # dlopen() |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
162 |
/usr/sfw/lib.*\ from\ .*libipsecutil.so.1 | # dlopen() |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
163 |
/usr/platform/.*rsmlib.*\ from\ .*librsm.so.2 | # dlopen() |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
164 |
\$ORIGIN.*\ from\ .*fcode.so | # dlopen() |
8299
e8ce4b4666df
6721172 zpool create does not detect device in use from a VxVM 5.0 disk group (fix check_rtime)
Jiri Cervenka <Jiri.Cervenka@Sun.COM>
parents:
7836
diff
changeset
|
165 |
/opt/VRTSvxvm/lib.*\ from\ .*libdiskmgt\.so\.1 | # dlopen() |
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
166 |
/usr/platform/.*\ from\ .*/usr/platform | # picl |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
167 |
/usr/lib/picl/.*\ from\ .*/usr/platform | # picl |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
168 |
/usr/platform/.*\ from\ .*/usr/lib/picl | # picl |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
169 |
/usr/lib/smbsrv.*\ from\ .*libsmb\.so\.1 | # future needs |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
170 |
/usr/lib/mps/secv1.*\ from\ .*libnss3\.so | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
171 |
/usr/lib/mps.*\ from\ .*libnss3\.so | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
172 |
/usr/sfw/lib.*\ from\ .*libdbus-1\.so\.3 | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
173 |
/usr/sfw/lib.*\ from\ .*libdbus-glib-1\.so\.2 | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
174 |
/usr/sfw/lib.*\ from\ .*libglib-2\.0\.so\.0 | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
175 |
/usr/X11/lib.*\ from\ .*libglib-2\.0\.so\.0 | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
176 |
/usr/sfw/lib.*\ from\ .*libgobject-2\.0\.so\.0 | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
177 |
/usr/X11/lib.*\ from\ .*libgobject-2\.0\.so\.0 | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
178 |
/usr/sfw/lib.*\ from\ .*libcrypto\.so\.0\.9\.8 | # non-OSNet |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
179 |
/usr/sfw/lib.*\ from\ .*libnetsnmp\.so\.5 | # non-OSNet |
6766
0251158c6e95
6686343 ldd(1) - unused search path diagnosis should be enabled
rie
parents:
6568
diff
changeset
|
180 |
/usr/sfw/lib.*\ from\ .*libgcc_s\.so\.1 | # non-OSNet |
8629
6a34e2627e5d
6791534 MMS move to use Postgres 8.3
David Major <David.Major@Sun.COM>
parents:
8299
diff
changeset
|
181 |
/usr.*\ from\ .*tst\.gcc\.exe | # gcc built |
8703
31fdbd3401a3
6797324 mm should exit right away when disabled
David Major <David.Major@Sun.COM>
parents:
8629
diff
changeset
|
182 |
/usr/postgres/8.3/lib.*\ from\ .*libpq\.so\.5 | # non-OSNET |
31fdbd3401a3
6797324 mm should exit right away when disabled
David Major <David.Major@Sun.COM>
parents:
8629
diff
changeset
|
183 |
/usr/sfw/lib.*\ from\ .*libpq\.so\.5 # non-OSNET |
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
184 |
}x; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
185 |
|
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
186 |
# Skip "unreferenced object=" ldd(1) diagnostics. |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
187 |
$SkipUnrefObject = qr{ |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
188 |
/libmapmalloc\.so\.1;\ unused\ dependency\ of | # interposer |
6568 | 189 |
/libstdc\+\+\.so\.6;\ unused\ dependency\ of | # gcc build |
190 |
/libm\.so\.2.*\ of\ .*libstdc\+\+\.so\.6 | # gcc build |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
191 |
/lib.*\ of\ .*/lib/picl/plugins/ | # picl |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
192 |
/lib.*\ of\ .*libcimapi\.so | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
193 |
/lib.*\ of\ .*libjvm\.so | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
194 |
/lib.*\ of\ .*libnetsnmp\.so\.5 | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
195 |
/lib.*\ of\ .*libnetsnmpagent\.so\.5 | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
196 |
/lib.*\ of\ .*libnetsnmpmibs\.so\.5 | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
197 |
/lib.*\ of\ .*libnetsnmphelpers\.so\.5 | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
198 |
/lib.*\ of\ .*libnspr4\.so | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
199 |
/lib.*\ of\ .*libsoftokn3\.so | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
200 |
/lib.*\ of\ .*libspmicommon\.so\.1 | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
201 |
/lib.*\ of\ .*libspmocommon\.so\.1 | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
202 |
/lib.*\ of\ .*libssl3\.so | # non-OSNET |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
203 |
/lib.*\ of\ .*libxml2\.so\.2 | # non-OSNET |
7331
c2a8bb9be83c
PSARC 2007/420 SMMS
Allan Matthews <Allan.Matthews@Sun.COM>
parents:
6766
diff
changeset
|
204 |
/lib.*\ of\ .*libxslt\.so\.1 | # non-OSNET |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9203
diff
changeset
|
205 |
/lib.*\ of\ .*libpq\.so\.4 | # non-OSNET |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9203
diff
changeset
|
206 |
/lib.*\ of\ .*libpython2\.4\.so\.1\.0 # non-OSNET |
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
207 |
}x; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
208 |
|
0 | 209 |
# Define any files that should only have unused (ldd -u) processing. |
210 |
$UnusedPaths = qr{ |
|
211 |
ucb/shutdown # libucb interposes on libc and makes |
|
212 |
# dependencies on libc seem unnecessary |
|
213 |
}x; |
|
214 |
||
215 |
# Define interpreters we should ignore. |
|
216 |
$SkipInterps = qr{ |
|
217 |
misc/krtld | |
|
218 |
misc/amd64/krtld | |
|
219 |
misc/sparcv9/krtld |
|
220 |
}x; |
|
221 |
||
222 |
# Catch libintl and libw, although ld(1) will bind to these and thus determine |
|
223 |
# they're needed, their content was moved into libc as of on297 build 7. |
|
224 |
# libthread and libpthread were completely moved into libc as of on10 build 53. |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
225 |
# libdl was moved into libc as of on10 build 49. librt and libaio were moved |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
226 |
# into libc as of Nevada build 44. |
0 | 227 |
$OldDeps = qr{ ^(?: |
228 |
libintl\.so\.1 | |
|
229 |
libw\.so\.1 | |
|
230 |
libthread\.so\.1 | |
|
231 |
libpthread\.so\.1 | |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
232 |
libdl\.so\.1 | |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
233 |
librt\.so\.1 | |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
234 |
libaio\.so\.1 |
0 | 235 |
)$ |
236 |
}x; |
|
237 |
||
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
238 |
# Files for which we skip checking of duplicate addresses in the |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
239 |
# symbol sort sections. Such exceptions should be rare --- most code will |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
240 |
# not have duplicate addresses, since it takes assember or a "#pragma weak" |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
241 |
# to do such aliasing in C. C++ is different: The compiler generates aliases |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
242 |
# for implementation reasons, and the mangled names used to encode argument |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
243 |
# and return value types are difficult to handle well in mapfiles. |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
244 |
# Furthermore, the Sun compiler and gcc use different and incompatible |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
245 |
# name mangling conventions. Since ON must be buildable by either, we |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
246 |
# would have to maintain two sets of mapfiles for each such object. |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
247 |
# C++ use is rare in ON, so this is not worth pursuing. |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
248 |
# |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
249 |
$SkipSymSort = qr{ ^.*(?: |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
250 |
opt/SUNWdtrt/tst/common/pid/tst.weak2.exe | # DTrace test |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
251 |
lib/amd64/libnsl\.so\.1 | # C++ |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
252 |
lib/sparcv9/libnsl\.so\.1 | # C++ |
4306
8c27001b19c8
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections (fix gcc build)
ab196087
parents:
4297
diff
changeset
|
253 |
lib/sparcv9/libfru\.so\.1 | # C++ |
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
254 |
usr/lib/sgml/nsgmls | # C++ |
9203 | 255 |
usr/lib/lms | # C++ |
7836
4e95154b5b7a
6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
7744
diff
changeset
|
256 |
ld\.so\.1 | # libc_pic.a user |
4e95154b5b7a
6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
7744
diff
changeset
|
257 |
lib/libsun_fc\.so\.1 | # C++ |
4e95154b5b7a
6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
7744
diff
changeset
|
258 |
lib/amd64/libsun_fc\.so\.1 | # C++ |
4e95154b5b7a
6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
7744
diff
changeset
|
259 |
lib/sparcv9/libsun_fc\.so\.1 # C++ |
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
260 |
)$ |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
261 |
}x; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
262 |
|
0 | 263 |
use Getopt::Std; |
264 |
||
265 |
# ----------------------------------------------------------------------------- |
|
266 |
||
267 |
# Reliably compare two OS revisions. Arguments are <ver1> <op> <ver2>. |
|
268 |
# <op> is the string form of a normal numeric comparison operator. |
|
269 |
sub cmp_os_ver { |
|
270 |
my @ver1 = split(/\./, $_[0]); |
|
271 |
my $op = $_[1]; |
|
272 |
my @ver2 = split(/\./, $_[2]); |
|
273 |
||
274 |
push @ver2, ("0") x $#ver1 - $#ver2; |
|
275 |
push @ver1, ("0") x $#ver2 - $#ver1; |
|
276 |
||
277 |
my $diff = 0; |
|
278 |
while (@ver1 || @ver2) { |
|
279 |
if (($diff = shift(@ver1) - shift(@ver2)) != 0) { |
|
280 |
last; |
|
281 |
} |
|
282 |
} |
|
283 |
return (eval "$diff $op 0" ? 1 : 0); |
|
284 |
} |
|
285 |
||
1771
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
286 |
# This script relies on ldd returning output reflecting only the binary |
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
287 |
# contents. But if LD_PRELOAD* environment variables are present, libraries |
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
288 |
# named by them will also appear in the output, disrupting our analysis. |
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
289 |
# So, before we get too far, scrub the environment. |
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
290 |
|
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
291 |
delete($ENV{LD_PRELOAD}); |
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
292 |
delete($ENV{LD_PRELOAD_32}); |
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
293 |
delete($ENV{LD_PRELOAD_64}); |
269c1351dec2
6410293 check_rtime should unset LD_PRELOAD* variables
sommerfe
parents:
1706
diff
changeset
|
294 |
|
0 | 295 |
# Establish a program name for any error diagnostics. |
296 |
chomp($Prog = `basename $0`); |
|
297 |
||
298 |
# Determine what machinery is available. |
|
299 |
$Mach = `uname -p`; |
|
300 |
$Isalist = `isalist`; |
|
301 |
$Env = ""; |
|
302 |
if ($Mach =~ /sparc/) { |
|
303 |
if ($Isalist =~ /sparcv9/) { |
|
304 |
$Ena64 = "ok"; |
|
305 |
} |
|
306 |
} elsif ($Mach =~ /i386/) { |
|
307 |
if ($Isalist =~ /amd64/) { |
|
308 |
$Ena64 = "ok"; |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
# Check that we have arguments. |
|
8744
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
313 |
if ((getopts('ad:imosv', \%opt) == 0) || ($#ARGV == -1)) { |
0 | 314 |
print "usage: $Prog [-a] [-d depdir] [-m] [-o] [-s] file | dir, ...\n"; |
315 |
print "\t[-a]\t\tprocess all files (ignore any exception lists)\n"; |
|
316 |
print "\t[-d dir]\testablish dependencies from under directory\n"; |
|
317 |
print "\t[-i]\t\tproduce dynamic table entry information\n"; |
|
318 |
print "\t[-m]\t\tprocess mcs(1) comments\n"; |
|
319 |
print "\t[-o]\t\tproduce one-liner output (prefixed with pathname)\n"; |
|
320 |
print "\t[-s]\t\tprocess .stab and .symtab entries\n"; |
|
8744
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
321 |
print "\t[-v]\t\tprocess version definition entries\n"; |
0 | 322 |
exit 1; |
323 |
} else { |
|
324 |
my($Proto); |
|
325 |
||
326 |
if ($opt{d}) { |
|
327 |
# User specified dependency directory - make sure it exists. |
|
328 |
if (! -d $opt{d}) { |
|
329 |
print "$Prog: $opt{d} is not a directory\n"; |
|
330 |
exit 1; |
|
331 |
} |
|
332 |
$Proto = $opt{d}; |
|
333 |
||
334 |
} elsif ($ENV{CODEMGR_WS}) { |
|
335 |
my($Root); |
|
336 |
||
337 |
# Without a user specified dependency directory see if we're |
|
338 |
# part of a codemanager workspace and if a proto area exists. |
|
339 |
if (($Root = $ENV{ROOT}) && (-d $Root)) { |
|
340 |
$Proto = $Root; |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
if (!($Tmpdir = $ENV{TMPDIR}) || (! -d $Tmpdir)) { |
|
345 |
$Tmpdir = "/tmp"; |
|
346 |
} |
|
347 |
||
6568 | 348 |
# Determine whether this is a __GNUC build. If so, unused search path |
349 |
# processing is disabled. |
|
350 |
if (defined $ENV{__GNUC}) { |
|
351 |
$Gnuc = 1; |
|
352 |
} else { |
|
353 |
$Gnuc = 0; |
|
354 |
} |
|
355 |
||
0 | 356 |
# Look for dependencies under $Proto. |
357 |
if ($Proto) { |
|
358 |
# To support alternative dependency mapping we'll need ldd(1)'s |
|
359 |
# -e option. This is relatively new (s81_30), so make sure |
|
3967
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
360 |
# ldd(1) is capable before gathering any dependency information. |
0 | 361 |
if (system('ldd -e /usr/lib/lddstub 2> /dev/null')) { |
362 |
print "ldd: does not support -e, unable to "; |
|
363 |
print "create alternative dependency mappingings.\n"; |
|
364 |
print "ldd: option added under 4390308 (s81_30).\n\n"; |
|
365 |
} else { |
|
366 |
# Gather dependencies and construct a alternative |
|
367 |
# dependency mapping via a crle(1) configuration file. |
|
368 |
GetDeps($Proto, "/"); |
|
369 |
GenConf(); |
|
370 |
} |
|
371 |
} |
|
372 |
||
373 |
# To support unreferenced dependency detection we'll need ldd(1)'s -U |
|
374 |
# option. This is relatively new (4638070), and if not available we |
|
375 |
# can still fall back to -u. Even with this option, don't use -U with |
|
376 |
# releases prior to 5.10 as the cleanup for -U use only got integrated |
|
377 |
# into 5.10 under 4642023. Note, that nightly doesn't typically set a |
|
378 |
# RELEASE from the standard <env> files. Users who wish to disable use |
|
379 |
# of ldd(1)'s -U should set (or uncomment) RELEASE in their <env> file |
|
380 |
# if using nightly, or otherwise establish it in their environment. |
|
381 |
if (system('ldd -U /usr/lib/lddstub 2> /dev/null')) { |
|
382 |
$LddNoU = 1; |
|
383 |
} else { |
|
384 |
my($Release); |
|
385 |
||
386 |
if (($Release = $ENV{RELEASE}) && |
|
387 |
(cmp_os_ver($Release, "<", "5.10"))) { |
|
388 |
$LddNoU = 1; |
|
389 |
} else { |
|
390 |
$LddNoU = 0; |
|
391 |
} |
|
392 |
} |
|
393 |
||
394 |
# For each argument determine if we're dealing with a file or directory. |
|
395 |
foreach my $Arg (@ARGV) { |
|
396 |
# Ignore symbolic links. |
|
397 |
if (-l $Arg) { |
|
398 |
next; |
|
399 |
} |
|
400 |
||
401 |
if (!stat($Arg)) { |
|
402 |
next; |
|
403 |
} |
|
404 |
||
405 |
# Process simple files. |
|
406 |
if (-f _) { |
|
407 |
my($RelPath) = $Arg; |
|
408 |
my($File) = $Arg; |
|
409 |
my($Secure) = 0; |
|
410 |
||
411 |
$RelPath =~ s!^.*/!./!; |
|
412 |
$File =~ s!^.*/!!; |
|
413 |
||
414 |
if (-u _ || -g _) { |
|
415 |
$Secure = 1; |
|
416 |
} |
|
417 |
||
418 |
ProcFile($Arg, $RelPath, $File, $Secure); |
|
419 |
next; |
|
420 |
} |
|
421 |
# Process directories. |
|
422 |
if (-d _) { |
|
423 |
ProcDir($Arg, "."); |
|
424 |
next; |
|
425 |
} |
|
426 |
||
427 |
print "$Arg is not a file or directory\n"; |
|
428 |
$Error = 1; |
|
429 |
} |
|
430 |
||
431 |
# Cleanup |
|
432 |
CleanUp(); |
|
433 |
} |
|
434 |
||
435 |
$Error = 0; |
|
436 |
||
3967
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
437 |
# Clean up any temporary files. |
0 | 438 |
sub CleanUp { |
439 |
if ($Crle64) { |
|
440 |
unlink $Crle64; |
|
441 |
} |
|
442 |
if ($Conf64) { |
|
443 |
unlink $Conf64; |
|
444 |
} |
|
445 |
if ($Crle32) { |
|
446 |
unlink $Crle32; |
|
447 |
} |
|
448 |
if ($Conf32) { |
|
449 |
unlink $Conf32; |
|
450 |
} |
|
451 |
} |
|
452 |
||
453 |
# Create an output message, either a one-liner (under -o) or preceded by the |
|
454 |
# files relative pathname as a title. |
|
455 |
sub OutMsg { |
|
456 |
my($Ttl, $Path, $Msg) = @_; |
|
457 |
||
458 |
if ($opt{o}) { |
|
459 |
$Msg =~ s/^[ \t]*//; |
|
460 |
print "$Path: $Msg\n"; |
|
461 |
} else { |
|
462 |
if ($Ttl eq 0) { |
|
463 |
print "==== $Path ====\n"; |
|
464 |
} |
|
465 |
print "$Msg\n"; |
|
466 |
} |
|
467 |
} |
|
468 |
||
469 |
# Determine whether this a ELF dynamic object and if so investigate its runtime |
|
470 |
# attributes. |
|
471 |
sub ProcFile { |
|
472 |
my($FullPath, $RelPath, $File, $Secure) = @_; |
|
473 |
my(@Elf, @Ldd, $Dyn, $Intp, $Dll, $Ttl, $Sym, $Interp, $Stack); |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
474 |
my($Sun, $Relsz, $Pltsz, $Tex, $Stab, $Strip, $Lddopt, $SymSort); |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
475 |
my($Val, $Header, $SkipLdd, $IsX86, $RWX, $UnDep); |
8744
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
476 |
my($HasDirectBinding, $HasVerdef); |
0 | 477 |
|
478 |
# Ignore symbolic links. |
|
479 |
if (-l $FullPath) { |
|
480 |
return; |
|
481 |
} |
|
482 |
||
483 |
$Ttl = 0; |
|
484 |
@Ldd = 0; |
|
485 |
||
486 |
# Determine whether we have access to inspect the file. |
|
487 |
if (!(-r $FullPath)) { |
|
488 |
OutMsg($Ttl++, $RelPath, |
|
489 |
"\tunable to inspect file: permission denied"); |
|
490 |
return; |
|
491 |
} |
|
492 |
||
493 |
# Determine if this is a file we don't care about. |
|
494 |
if (!$opt{a}) { |
|
495 |
if ($File =~ $SkipFiles) { |
|
496 |
return; |
|
497 |
} |
|
498 |
} |
|
499 |
||
500 |
# Determine whether we have a executable (static or dynamic) or a |
|
501 |
# shared object. |
|
8744
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
502 |
@Elf = split(/\n/, `elfdump -epdicyv $FullPath 2>&1`); |
0 | 503 |
|
504 |
$Dyn = $Intp = $Dll = $Stack = $IsX86 = $RWX = 0; |
|
505 |
$Interp = 1; |
|
506 |
$Header = 'None'; |
|
507 |
foreach my $Line (@Elf) { |
|
508 |
# If we have an invalid file type (which we can tell from the |
|
509 |
# first line), or we're processing an archive, bail. |
|
510 |
if ($Header eq 'None') { |
|
511 |
if (($Line =~ /invalid file/) || |
|
512 |
($Line =~ /$FullPath(.*):/)) { |
|
513 |
return; |
|
514 |
} |
|
515 |
} |
|
516 |
||
517 |
if ($Line =~ /^ELF Header/) { |
|
518 |
$Header = 'Ehdr'; |
|
519 |
||
520 |
} elsif ($Line =~ /^Program Header/) { |
|
521 |
$Header = 'Phdr'; |
|
522 |
$RWX = 0; |
|
523 |
||
524 |
} elsif ($Line =~ /^Interpreter/) { |
|
525 |
$Header = 'Intp'; |
|
526 |
||
527 |
} elsif ($Line =~ /^Dynamic Section/) { |
|
528 |
# A dynamic section indicates we're a dynamic object |
|
529 |
# (this makes sure we don't check static executables). |
|
530 |
$Dyn = 1; |
|
531 |
||
532 |
} elsif (($Header eq 'Ehdr') && ($Line =~ /e_type:/)) { |
|
533 |
# The e_type field indicates whether this file is a |
|
534 |
# shared object (ET_DYN) or an executable (ET_EXEC). |
|
535 |
if ($Line =~ /ET_DYN/) { |
|
536 |
$Dll = 1; |
|
537 |
} elsif ($Line !~ /ET_EXEC/) { |
|
538 |
return; |
|
539 |
} |
|
540 |
} elsif (($Header eq 'Ehdr') && ($Line =~ /ei_class:/)) { |
|
541 |
# If we encounter a 64-bit object, but we're not running |
|
542 |
# on a 64-bit system, suppress calling ldd(1). |
|
543 |
if (($Line =~ /ELFCLASS64/) && !$Ena64) { |
|
544 |
$SkipLdd = 1; |
|
545 |
} |
|
546 |
} elsif (($Header eq 'Ehdr') && ($Line =~ /e_machine:/)) { |
|
547 |
# If it's a X86 object, we need to enforce RW- data. |
|
548 |
if (($Line =~ /(EM_AMD64|EM_386)/)) { |
|
549 |
$IsX86 = 1; |
|
550 |
} |
|
551 |
} elsif (($Header eq 'Phdr') && |
|
552 |
($Line =~ /\[ PF_X PF_W PF_R \]/)) { |
|
553 |
# RWX segment seen. |
|
554 |
$RWX = 1; |
|
555 |
||
556 |
} elsif (($Header eq 'Phdr') && |
|
557 |
($Line =~ /\[ PT_LOAD \]/ && $RWX && $IsX86)) { |
|
558 |
# Seen an RWX PT_LOAD segment. |
|
559 |
if ($File !~ $SkipNoExStkFiles) { |
|
560 |
OutMsg($Ttl++, $RelPath, |
|
561 |
"\tapplication requires non-executable " . |
|
562 |
"data\t<no -Mmapfile_noexdata?>"); |
|
563 |
} |
|
564 |
||
565 |
} elsif (($Header eq 'Phdr') && |
|
566 |
($Line =~ /\[ PT_SUNWSTACK \]/)) { |
|
567 |
# This object defines a non-executable stack. |
|
568 |
$Stack = 1; |
|
569 |
||
570 |
} elsif (($Header eq 'Intp') && !$opt{a} && |
|
571 |
($Line =~ $SkipInterps)) { |
|
572 |
# This object defines an interpretor we should skip. |
|
573 |
$Interp = 0; |
|
574 |
} |
|
575 |
} |
|
576 |
||
577 |
# Determine whether this ELF executable or shared object has a |
|
578 |
# conforming mcs(1) comment section. If the correct $(POST_PROCESS) |
|
579 |
# macros are used, only a 3 or 4 line .comment section should exist |
|
580 |
# containing one or two "@(#)SunOS" identifying comments (one comment |
|
581 |
# for a non-debug build, and two for a debug build). The results of |
|
582 |
# the following split should be three or four lines, the last empty |
|
583 |
# line being discarded by the split. |
|
584 |
if ($opt{m}) { |
|
585 |
my(@Mcs, $Con, $Dev); |
|
586 |
||
587 |
@Mcs = split(/\n/, `mcs -p $FullPath 2>&1`); |
|
588 |
||
589 |
$Con = $Dev = $Val = 0; |
|
590 |
foreach my $Line (@Mcs) { |
|
591 |
$Val++; |
|
592 |
||
593 |
if (($Val == 3) && ($Line !~ /^@\(#\)SunOS/)) { |
|
594 |
$Con = 1; |
|
595 |
last; |
|
596 |
} |
|
597 |
if (($Val == 4) && ($Line =~ /^@\(#\)SunOS/)) { |
|
598 |
$Dev = 1; |
|
599 |
next; |
|
600 |
} |
|
601 |
if (($Dev == 0) && ($Val == 4)) { |
|
602 |
$Con = 1; |
|
603 |
last; |
|
604 |
} |
|
605 |
if (($Dev == 1) && ($Val == 5)) { |
|
606 |
$Con = 1; |
|
607 |
last; |
|
608 |
} |
|
609 |
} |
|
610 |
if ($opt{m} && ($Con == 1)) { |
|
611 |
OutMsg($Ttl++, $RelPath, |
|
612 |
"\tnon-conforming mcs(1) comment\t<no \$(POST_PROCESS)?>"); |
|
613 |
} |
|
614 |
} |
|
615 |
||
616 |
# Applications should contain a non-executable stack definition. |
|
617 |
if (($Dll == 0) && ($Stack == 0)) { |
|
618 |
if (!$opt{a}) { |
|
619 |
if ($File =~ $SkipNoExStkFiles) { |
|
620 |
goto DYN; |
|
621 |
} |
|
622 |
} |
|
623 |
OutMsg($Ttl++, $RelPath, |
|
624 |
"\tapplication requires non-executable stack\t<no -Mmapfile_noexstk?>"); |
|
625 |
} |
|
626 |
||
627 |
DYN: |
|
628 |
# Having caught any static executables in the mcs(1) check and non- |
|
629 |
# executable stack definition check, continue with dynamic objects |
|
630 |
# from now on. |
|
631 |
if ($Dyn eq 0) { |
|
632 |
return; |
|
633 |
} |
|
634 |
||
635 |
# Only use ldd unless we've encountered an interpreter that should |
|
3967
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
636 |
# be skipped. |
0 | 637 |
if (!$SkipLdd && $Interp) { |
4297
ada3277692df
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections (fix build noise)
ab196087
parents:
4292
diff
changeset
|
638 |
my $LDDFullPath = $FullPath; |
ada3277692df
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections (fix build noise)
ab196087
parents:
4292
diff
changeset
|
639 |
|
0 | 640 |
if ($Secure) { |
641 |
# The execution of a secure application over an nfs file |
|
642 |
# system mounted nosuid will result in warning messages |
|
643 |
# being sent to /var/adm/messages. As this type of |
|
644 |
# environment can occur with root builds, move the file |
|
645 |
# being investigated to a safe place first. In addition |
|
646 |
# remove its secure permission so that it can be |
|
647 |
# influenced by any alternative dependency mappings. |
|
648 |
||
649 |
my($TmpPath) = "$Tmpdir/$File"; |
|
650 |
||
4297
ada3277692df
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections (fix build noise)
ab196087
parents:
4292
diff
changeset
|
651 |
system('cp', $LDDFullPath, $TmpPath); |
0 | 652 |
chmod 0777, $TmpPath; |
4297
ada3277692df
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections (fix build noise)
ab196087
parents:
4292
diff
changeset
|
653 |
$LDDFullPath = $TmpPath; |
0 | 654 |
} |
655 |
||
656 |
# Use ldd(1) to determine the objects relocatability and use. |
|
657 |
# By default look for all unreferenced dependencies. However, |
|
658 |
# some objects have legitimate dependencies that they do not |
|
659 |
# reference. |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
660 |
if ($LddNoU || ($RelPath =~ $UnusedPaths)) { |
0 | 661 |
$Lddopt = "-ru"; |
662 |
} else { |
|
663 |
$Lddopt = "-rU"; |
|
664 |
} |
|
4297
ada3277692df
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections (fix build noise)
ab196087
parents:
4292
diff
changeset
|
665 |
@Ldd = split(/\n/, `ldd $Lddopt $Env $LDDFullPath 2>&1`); |
0 | 666 |
if ($Secure) { |
4297
ada3277692df
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections (fix build noise)
ab196087
parents:
4292
diff
changeset
|
667 |
unlink $LDDFullPath; |
0 | 668 |
} |
669 |
} |
|
670 |
||
671 |
$Val = 0; |
|
672 |
$Sym = 5; |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
673 |
$UnDep = 1; |
0 | 674 |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
675 |
foreach my $Line (@Ldd) { |
0 | 676 |
|
677 |
if ($Val == 0) { |
|
678 |
$Val = 1; |
|
679 |
# Make sure ldd(1) worked. One possible failure is that |
|
680 |
# this is an old ldd(1) prior to -e addition (4390308). |
|
681 |
if ($Line =~ /usage:/) { |
|
682 |
$Line =~ s/$/\t<old ldd(1)?>/; |
|
683 |
OutMsg($Ttl++, $RelPath, $Line); |
|
684 |
last; |
|
685 |
} elsif ($Line =~ /execution failed/) { |
|
686 |
OutMsg($Ttl++, $RelPath, $Line); |
|
687 |
last; |
|
688 |
} |
|
689 |
||
690 |
# It's possible this binary can't be executed, ie. we've |
|
691 |
# found a sparc binary while running on an intel system, |
|
692 |
# or a sparcv9 binary on a sparcv7/8 system. |
|
693 |
if ($Line =~ /wrong class/) { |
|
694 |
OutMsg($Ttl++, $RelPath, |
|
695 |
"\thas wrong class or data encoding"); |
|
696 |
next; |
|
697 |
} |
|
698 |
||
699 |
# Historically, ldd(1) likes executable objects to have |
|
700 |
# their execute bit set. Note that this test isn't |
|
701 |
# applied unless the -a option is in effect, as any |
|
702 |
# non-executable files are skipped by default to reduce |
|
703 |
# the cost of running this script. |
|
704 |
if ($Line =~ /not executable/) { |
|
705 |
OutMsg($Ttl++, $RelPath, |
|
706 |
"\tis not executable"); |
|
707 |
next; |
|
708 |
} |
|
709 |
} |
|
710 |
||
711 |
# Look for "file" or "versions" that aren't found. Note that |
|
712 |
# these lines will occur before we find any symbol referencing |
|
713 |
# errors. |
|
714 |
if (($Sym == 5) && ($Line =~ /not found\)/)) { |
|
715 |
if ($Line =~ /file not found\)/) { |
|
716 |
$Line =~ s/$/\t<no -zdefs?>/; |
|
717 |
} |
|
718 |
OutMsg($Ttl++, $RelPath, $Line); |
|
719 |
next; |
|
720 |
} |
|
721 |
# Look for relocations whose symbols can't be found. Note, we |
|
722 |
# only print out the first 5 relocations for any file as this |
|
723 |
# output can be excessive. |
|
724 |
if ($Sym && ($Line =~ /symbol not found/)) { |
|
725 |
# Determine if this file is allowed undefined |
|
726 |
# references. |
|
727 |
if ($Sym == 5) { |
|
728 |
if (!$opt{a}) { |
|
729 |
if ($File =~ $SkipUndefFiles) { |
|
730 |
$Sym = 0; |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
731 |
next; |
0 | 732 |
} |
733 |
} |
|
734 |
} |
|
735 |
if ($Sym-- == 1) { |
|
736 |
if (!$opt{o}) { |
|
737 |
OutMsg($Ttl++, $RelPath, |
|
738 |
"\tcontinued ..."); |
|
739 |
} |
|
740 |
next; |
|
741 |
} |
|
742 |
# Just print the symbol name. |
|
743 |
$Line =~ s/$/\t<no -zdefs?>/; |
|
744 |
OutMsg($Ttl++, $RelPath, $Line); |
|
745 |
next; |
|
746 |
} |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
747 |
# Look for any unused search paths. |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
748 |
if ($Line =~ /unused search path=/) { |
6568 | 749 |
# Note, skip this comparison for __GNUC builds, as the |
750 |
# gnu compilers insert numerous unused search paths. |
|
751 |
if ($Gnuc == 1) { |
|
752 |
next; |
|
753 |
} |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
754 |
if (!$opt{a}) { |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
755 |
if ($Line =~ $SkipUnusedSearchPath) { |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
756 |
next; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
757 |
} |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
758 |
} |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
759 |
if ($Secure) { |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
760 |
$Line =~ s!$Tmpdir/!!; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
761 |
} |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
762 |
$Line =~ s/^[ \t]*(.*)/\t$1\t<remove search path?>/; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
763 |
OutMsg($Ttl++, $RelPath, $Line); |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
764 |
next; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
765 |
} |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
766 |
# Look for unreferenced dependencies. Note, if any unreferenced |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
767 |
# objects are ignored, then set $UnDep so as to suppress any |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
768 |
# associated unused-object messages. |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
769 |
if ($Line =~ /unreferenced object=/) { |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
770 |
if (!$opt{a}) { |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
771 |
if ($Line =~ $SkipUnrefObject) { |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
772 |
$UnDep = 0; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
773 |
next; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
774 |
} |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
775 |
} |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
776 |
if ($Secure) { |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
777 |
$Line =~ s!$Tmpdir/!!; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
778 |
} |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
779 |
$Line =~ s/^[ \t]*(.*)/\t$1\t<remove lib or -zignore?>/; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
780 |
OutMsg($Ttl++, $RelPath, $Line); |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
781 |
next; |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
782 |
} |
0 | 783 |
# Look for any unused dependencies. |
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
784 |
if ($UnDep && ($Line =~ /unused/)) { |
0 | 785 |
if (!$opt{a}) { |
9114
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
786 |
if ($RelPath =~ $SkipUnusedDeps) { |
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
787 |
next; |
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
788 |
} |
d9426e17bfd0
6816972 check_rtime should not report libm_hwcap1.so.2 errors
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
8744
diff
changeset
|
789 |
if ($Line =~ $SkipUnusedObject) { |
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
790 |
next; |
0 | 791 |
} |
792 |
} |
|
793 |
if ($Secure) { |
|
794 |
$Line =~ s!$Tmpdir/!!; |
|
795 |
} |
|
796 |
$Line =~ s/^[ \t]*(.*)/\t$1\t<remove lib or -zignore?>/; |
|
797 |
OutMsg($Ttl++, $RelPath, $Line); |
|
798 |
next; |
|
799 |
} |
|
800 |
} |
|
801 |
||
802 |
# Reuse the elfdump(1) data to investigate additional dynamic linking |
|
803 |
# information. |
|
804 |
||
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
805 |
$Sun = $Relsz = $Pltsz = $Dyn = $Stab = $SymSort = 0; |
0 | 806 |
$Tex = $Strip = 1; |
5905 | 807 |
$HasDirectBinding = 0; |
8744
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
808 |
$HasVerdef = 0; |
0 | 809 |
|
810 |
$Header = 'None'; |
|
811 |
ELF: foreach my $Line (@Elf) { |
|
812 |
# We're only interested in the section headers and the dynamic |
|
813 |
# section. |
|
814 |
if ($Line =~ /^Section Header/) { |
|
815 |
$Header = 'Shdr'; |
|
816 |
||
817 |
if (($Sun == 0) && ($Line =~ /\.SUNW_reloc/)) { |
|
818 |
# This object has a combined relocation section. |
|
819 |
$Sun = 1; |
|
820 |
||
821 |
} elsif (($Stab == 0) && ($Line =~ /\.stab/)) { |
|
822 |
# This object contain .stabs sections |
|
823 |
$Stab = 1; |
|
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
824 |
} elsif (($SymSort == 0) && |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
825 |
($Line =~ /\.SUNW_dyn(sym)|(tls)sort/)) { |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
826 |
# This object contains a symbol sort section |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
827 |
$SymSort = 1; |
0 | 828 |
} |
829 |
||
830 |
if (($Strip == 1) && ($Line =~ /\.symtab/)) { |
|
831 |
# This object contains a complete symbol table. |
|
832 |
$Strip = 0; |
|
833 |
} |
|
834 |
next; |
|
835 |
||
836 |
} elsif ($Line =~ /^Dynamic Section/) { |
|
837 |
$Header = 'Dyn'; |
|
838 |
next; |
|
5905 | 839 |
} elsif ($Line =~ /^Syminfo Section/) { |
840 |
$Header = 'Syminfo'; |
|
841 |
next; |
|
8744
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
842 |
} elsif ($Line =~ /^Version Definition Section/) { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
843 |
$HasVerdef = 1; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
844 |
next; |
5905 | 845 |
} elsif (($Header ne 'Dyn') && ($Header ne 'Syminfo')) { |
846 |
next; |
|
847 |
} |
|
848 |
||
849 |
# Look into the Syminfo section. |
|
850 |
# Does this object have at least one Directly Bound symbol? |
|
851 |
if (($Header eq 'Syminfo')) { |
|
852 |
my(@Symword); |
|
853 |
||
854 |
if ($HasDirectBinding == 1) { |
|
855 |
next; |
|
856 |
} |
|
857 |
||
858 |
@Symword = split(' ', $Line); |
|
859 |
||
860 |
if (!defined($Symword[1])) { |
|
861 |
next; |
|
862 |
} |
|
863 |
if ($Symword[1] =~ /B/) { |
|
864 |
$HasDirectBinding = 1; |
|
865 |
} |
|
0 | 866 |
next; |
867 |
} |
|
868 |
||
869 |
# Does this object contain text relocations. |
|
870 |
if ($Tex && ($Line =~ /TEXTREL/)) { |
|
871 |
# Determine if this file is allowed text relocations. |
|
872 |
if (!$opt{a}) { |
|
873 |
if ($File =~ $SkipTextrelFiles) { |
|
874 |
$Tex = 0; |
|
875 |
next ELF; |
|
876 |
} |
|
877 |
} |
|
878 |
OutMsg($Ttl++, $RelPath, |
|
879 |
"\tTEXTREL .dynamic tag\t\t\t<no -Kpic?>"); |
|
880 |
$Tex = 0; |
|
881 |
next; |
|
882 |
} |
|
883 |
||
884 |
# Does this file have any relocation sections (there are a few |
|
885 |
# psr libraries with no relocations at all, thus a .SUNW_reloc |
|
886 |
# section won't exist either). |
|
887 |
if (($Relsz == 0) && ($Line =~ / RELA?SZ/)) { |
|
888 |
$Relsz = hex((split(' ', $Line))[2]); |
|
889 |
next; |
|
890 |
} |
|
891 |
||
892 |
# Does this file have any plt relocations. If the plt size is |
|
893 |
# equivalent to the total relocation size then we don't have |
|
894 |
# any relocations suitable for combining into a .SUNW_reloc |
|
895 |
# section. |
|
896 |
if (($Pltsz == 0) && ($Line =~ / PLTRELSZ/)) { |
|
897 |
$Pltsz = hex((split(' ', $Line))[2]); |
|
898 |
next; |
|
899 |
} |
|
900 |
||
901 |
# Does this object have any dependencies. |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
902 |
if ($Line =~ /NEEDED/) { |
0 | 903 |
my($Need) = (split(' ', $Line))[3]; |
904 |
||
905 |
if ($Need =~ $OldDeps) { |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
906 |
# Catch any old (unnecessary) dependencies. |
0 | 907 |
OutMsg($Ttl++, $RelPath, |
908 |
"\tNEEDED=$Need\t<dependency no longer necessary>"); |
|
6543
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
909 |
} elsif ($opt{i}) { |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
910 |
# Under the -i (information) option print out |
465433824d87
6683064 check_rtime could do with some spring cleaning
rie
parents:
6429
diff
changeset
|
911 |
# any useful dynamic entries. |
0 | 912 |
OutMsg($Ttl++, $RelPath, "\tNEEDED=$Need"); |
913 |
} |
|
914 |
next; |
|
915 |
} |
|
916 |
||
5905 | 917 |
# Is this object built with -B direct flag on? |
918 |
if ($Line =~ / DIRECT /) { |
|
919 |
$HasDirectBinding = 1; |
|
920 |
} |
|
921 |
||
0 | 922 |
# Does this object specify a runpath. |
923 |
if ($opt{i} && ($Line =~ /RPATH/)) { |
|
924 |
my($Rpath) = (split(' ', $Line))[3]; |
|
925 |
OutMsg($Ttl++, $RelPath, "\tRPATH=$Rpath"); |
|
926 |
next; |
|
927 |
} |
|
928 |
} |
|
929 |
||
930 |
# A shared object, that contains non-plt relocations, should have a |
|
931 |
# combined relocation section indicating it was built with -z combreloc. |
|
932 |
if ($Dll && $Relsz && ($Relsz != $Pltsz) && ($Sun == 0)) { |
|
933 |
OutMsg($Ttl++, $RelPath, |
|
934 |
"\tSUNW_reloc section missing\t\t<no -zcombreloc?>"); |
|
935 |
} |
|
936 |
||
937 |
# No objects released to a customer should have any .stabs sections |
|
938 |
# remaining, they should be stripped. |
|
939 |
if ($opt{s} && $Stab) { |
|
940 |
if (!$opt{a}) { |
|
941 |
if ($File =~ $SkipStabFiles) { |
|
942 |
goto DONESTAB; |
|
943 |
} |
|
944 |
} |
|
945 |
OutMsg($Ttl++, $RelPath, |
|
524 | 946 |
"\tdebugging sections should be deleted\t<no strip -x?>"); |
0 | 947 |
} |
948 |
||
5905 | 949 |
# Identify an object that is not built with either -B direct or |
950 |
# -z direct. |
|
951 |
if (($RelPath =~ $SkipDirectBindDirs) || |
|
952 |
($File =~ $SkipDirectBindFiles)) { |
|
953 |
goto DONESTAB; |
|
954 |
} |
|
955 |
if ($Relsz && ($HasDirectBinding == 0)) { |
|
956 |
OutMsg($Ttl++, $RelPath, |
|
957 |
"\tobject has no direct bindings\t<no -B direct or -z direct?>"); |
|
958 |
} |
|
959 |
||
0 | 960 |
DONESTAB: |
961 |
||
524 | 962 |
# All objects should have a full symbol table to provide complete |
0 | 963 |
# debugging stack traces. |
524 | 964 |
if ($Strip) { |
0 | 965 |
OutMsg($Ttl++, $RelPath, |
966 |
"\tsymbol table should not be stripped\t<remove -s?>"); |
|
967 |
} |
|
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
968 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
969 |
# If there are symbol sort sections in this object, report on |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
970 |
# any that have duplicate addresses. |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
971 |
ProcSymSort($FullPath, $RelPath, \$Ttl) if $SymSort; |
8744
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
972 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
973 |
# If -v was specified, and the object has a version definition |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
974 |
# section, generate output showing each public symbol and the |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
975 |
# version it belongs to. |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
976 |
ProcVerdef($FullPath, $RelPath, \$Ttl) if $HasVerdef && $opt{v}; |
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
977 |
} |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
978 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
979 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
980 |
## ProcSymSortOutMsg(RefTtl, RelPath, secname, addr, names...) |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
981 |
# |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
982 |
# Call OutMsg for a duplicate address error in a symbol sort |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
983 |
# section |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
984 |
# |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
985 |
sub ProcSymSortOutMsg { |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
986 |
my($RefTtl, $RelPath, $secname, $addr, @names) = @_; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
987 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
988 |
OutMsg($$RefTtl++, $RelPath, |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
989 |
"$secname: duplicate $addr: ". join(', ', @names)); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
990 |
} |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
991 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
992 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
993 |
## ProcSymSort(FullPath, RelPath) |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
994 |
# |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
995 |
# Examine the symbol sort sections for the given object and report |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
996 |
# on any duplicate addresses found. Ideally, mapfile directives |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
997 |
# should be used when building objects that have multiple symbols |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
998 |
# with the same address so that only one of them appears in the sort |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
999 |
# section. This saves space, reduces user confusion, and ensures that |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1000 |
# libproc and debuggers always display public names instead of symbols |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1001 |
# that are merely implementation details. |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1002 |
# |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1003 |
sub ProcSymSort { |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1004 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1005 |
my($FullPath, $RelPath, $RefTtl) = @_; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1006 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1007 |
# If this object is exempt from checking, return quietly |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1008 |
return if ($FullPath =~ $SkipSymSort); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1009 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1010 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1011 |
open(SORT, "elfdump -S $FullPath|") || |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1012 |
die "$Prog: Unable to execute elfdump (symbol sort sections)\n"; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1013 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1014 |
my $line; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1015 |
my $last_addr; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1016 |
my @dups = (); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1017 |
my $secname; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1018 |
while ($line = <SORT>) { |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1019 |
chomp $line; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1020 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1021 |
next if ($line eq ''); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1022 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1023 |
# If this is a header line, pick up the section name |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1024 |
if ($line =~ /^Symbol Sort Section:\s+([^\s]+)\s+/) { |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1025 |
$secname = $1; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1026 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1027 |
# Every new section is followed by a column header line |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1028 |
$line = <SORT>; # Toss header line |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1029 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1030 |
# Flush anything left from previous section |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1031 |
ProcSymSortOutMsg($RefTtl, $RelPath, $secname, |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1032 |
$last_addr, @dups) if (scalar(@dups) > 1); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1033 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1034 |
# Reset variables for new sort section |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1035 |
$last_addr = ''; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1036 |
@dups = (); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1037 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1038 |
next; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1039 |
} |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1040 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1041 |
# Process symbol line |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1042 |
my @fields = split /\s+/, $line; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1043 |
my $new_addr = $fields[2]; |
7744
c39a337d4553
6752728 link-editor can enter UNDEF symbols in symbol sort sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7331
diff
changeset
|
1044 |
my $new_type = $fields[8]; |
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1045 |
my $new_name = $fields[9]; |
4388
7a8ef1852d04
6565305 check_rtime should ignore DTrace USDT symbols in sort section test
ab196087
parents:
4306
diff
changeset
|
1046 |
|
7744
c39a337d4553
6752728 link-editor can enter UNDEF symbols in symbol sort sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7331
diff
changeset
|
1047 |
if ($new_type eq 'UNDEF') { |
c39a337d4553
6752728 link-editor can enter UNDEF symbols in symbol sort sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7331
diff
changeset
|
1048 |
OutMsg($RefTtl++, $RelPath, |
c39a337d4553
6752728 link-editor can enter UNDEF symbols in symbol sort sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7331
diff
changeset
|
1049 |
"$secname: unexpected UNDEF symbol " . |
c39a337d4553
6752728 link-editor can enter UNDEF symbols in symbol sort sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7331
diff
changeset
|
1050 |
"(link-editor error): $new_name"); |
c39a337d4553
6752728 link-editor can enter UNDEF symbols in symbol sort sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7331
diff
changeset
|
1051 |
next; |
c39a337d4553
6752728 link-editor can enter UNDEF symbols in symbol sort sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7331
diff
changeset
|
1052 |
} |
c39a337d4553
6752728 link-editor can enter UNDEF symbols in symbol sort sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7331
diff
changeset
|
1053 |
|
6239
88a5439d4722
6565300 ld should exclude hidden USDT provider probe symbols from symbol sort sections
ab196087
parents:
5905
diff
changeset
|
1054 |
if ($new_addr eq $last_addr) { |
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1055 |
push @dups, $new_name; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1056 |
} else { |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1057 |
ProcSymSortOutMsg($RefTtl, $RelPath, $secname, |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1058 |
$last_addr, @dups) if (scalar(@dups) > 1); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1059 |
@dups = ( $new_name ); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1060 |
$last_addr = $new_addr; |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1061 |
} |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1062 |
} |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1063 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1064 |
ProcSymSortOutMsg($RefTtl, $RelPath, $secname, $last_addr, @dups) |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1065 |
if (scalar(@dups) > 1); |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1066 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
3967
diff
changeset
|
1067 |
close SORT; |
0 | 1068 |
} |
1069 |
||
1070 |
||
8744
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1071 |
## ProcVerdef(FullPath, RelPath) |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1072 |
# |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1073 |
# Examine the version definition section for the given object and report |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1074 |
# each public symbol along with the version it belongs to. |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1075 |
# |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1076 |
sub ProcVerdef { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1077 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1078 |
my($FullPath, $RelPath, $RefTtl) = @_; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1079 |
my $line; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1080 |
my $cur_ver = ''; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1081 |
my $tab = $opt{o} ? '' : "\t"; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1082 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1083 |
# pvs -dov provides information about the versioning hierarchy |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1084 |
# in the file. Lines are of the format: |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1085 |
# path - version[XXX]; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1086 |
# where [XXX] indicates optional information, such as flags |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1087 |
# or inherited versions. |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1088 |
# |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1089 |
# Private versions are allowed to change freely, so ignore them. |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1090 |
open(PVS, "pvs -dov $FullPath|") || |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1091 |
die "$Prog: Unable to execute pvs (version definition section)\n"; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1092 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1093 |
while ($line = <PVS>) { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1094 |
chomp $line; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1095 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1096 |
if ($line =~ /^[^\s]+\s+-\s+([^;]+)/) { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1097 |
my $ver = $1; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1098 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1099 |
next if $ver =~ /private/i; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1100 |
OutMsg($$RefTtl++, $RelPath, "${tab}VERDEF=$ver"); |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1101 |
} |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1102 |
} |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1103 |
close PVS; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1104 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1105 |
# pvs -dos lists the symbols assigned to each version definition. |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1106 |
# Lines are of the format: |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1107 |
# path - version: symbol; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1108 |
# path - version: symbol (size); |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1109 |
# where the (size) is added to data items, but not for functions. |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1110 |
# We strip off the size, if present. |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1111 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1112 |
open(PVS, "pvs -dos $FullPath|") || |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1113 |
die "$Prog: Unable to execute pvs (version definition section)\n"; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1114 |
while ($line = <PVS>) { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1115 |
chomp $line; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1116 |
if ($line =~ /^[^\s]+\s+-\s+([^:]+):\s*([^\s;]+)/) { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1117 |
my $ver = $1; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1118 |
my $sym = $2; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1119 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1120 |
next if $ver =~ /private/i; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1121 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1122 |
if ($opt{o}) { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1123 |
OutMsg($$RefTtl++, $RelPath, |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1124 |
"VERSION=$ver, SYMBOL=$sym"); |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1125 |
} else { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1126 |
if ($cur_ver ne $ver) { |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1127 |
OutMsg($$RefTtl++, $RelPath, "\tVERSION=$ver"); |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1128 |
$cur_ver = $ver; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1129 |
} |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1130 |
OutMsg($$RefTtl++, $RelPath, "\t\tSYMBOL=$sym"); |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1131 |
} |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1132 |
} |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1133 |
} |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1134 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1135 |
close PVS; |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1136 |
} |
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1137 |
|
03d5725cda56
6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8703
diff
changeset
|
1138 |
|
0 | 1139 |
sub ProcDir { |
1140 |
my($FullDir, $RelDir) = @_; |
|
1141 |
my($NewFull, $NewRel); |
|
1142 |
||
1143 |
# Determine if this is a directory we don't care about. |
|
1144 |
if (!$opt{a}) { |
|
1145 |
if ($RelDir =~ $SkipDirs) { |
|
1146 |
return; |
|
1147 |
} |
|
1148 |
} |
|
1149 |
||
1150 |
# Open the directory and read each entry, omit files starting with "." |
|
1151 |
if (opendir(DIR, $FullDir)) { |
|
1152 |
foreach my $Entry (readdir(DIR)) { |
|
1153 |
if ($Entry =~ /^\./) { |
|
1154 |
next; |
|
1155 |
} |
|
1156 |
$NewFull = "$FullDir/$Entry"; |
|
1157 |
||
1158 |
# Ignore symlinks. |
|
1159 |
if (-l $NewFull) { |
|
1160 |
next; |
|
1161 |
} |
|
1162 |
if (!stat($NewFull)) { |
|
1163 |
next; |
|
1164 |
} |
|
1165 |
$NewRel = "$RelDir/$Entry"; |
|
1166 |
||
1167 |
# Descend into and process any directories. |
|
1168 |
if (-d _) { |
|
1169 |
ProcDir($NewFull, $NewRel); |
|
1170 |
next; |
|
1171 |
} |
|
1172 |
||
1173 |
# Typically dynamic objects are executable, so we can |
|
1174 |
# reduce the overall cost of this script (a lot!) by |
|
1175 |
# screening out non-executables here, rather than pass |
|
1176 |
# them to file(1) later. However, it has been known |
|
1177 |
# for shared objects to be mistakenly left non- |
|
1178 |
# executable, so with -a let all files through so that |
|
1179 |
# this requirement can be verified (see ProcFile()). |
|
1180 |
if (!$opt{a}) { |
|
1181 |
if (! -x _) { |
|
1182 |
next; |
|
1183 |
} |
|
1184 |
} |
|
1185 |
||
1186 |
# Process any standard files. |
|
1187 |
if (-f _) { |
|
1188 |
my($Secure) = 0; |
|
1189 |
||
1190 |
if (-u _ || -g _) { |
|
1191 |
$Secure = 1; |
|
1192 |
} |
|
1193 |
||
1194 |
ProcFile($NewFull, $NewRel, $Entry, $Secure); |
|
1195 |
next; |
|
1196 |
} |
|
1197 |
||
1198 |
} |
|
1199 |
closedir(DIR); |
|
1200 |
} |
|
1201 |
} |
|
1202 |
||
1203 |
# Create a crle(1) script for any 64-bit dependencies we locate. A runtime |
|
1204 |
# configuration file will be generated to establish alternative dependency |
|
1205 |
# mappings for all these dependencies. |
|
1206 |
||
1207 |
sub Entercrle64 { |
|
1208 |
my($FullDir, $RelDir, $Entry) = @_; |
|
1209 |
||
1210 |
if (!$Crle64) { |
|
1211 |
# Create and initialize the script if is doesn't already exit. |
|
1212 |
||
1213 |
$Crle64 = "$Tmpdir/$Prog.crle64.$$"; |
|
1214 |
open(CRLE64, "> $Crle64") || |
|
1215 |
die "$Prog: open failed: $Crle64: $!"; |
|
1216 |
||
1217 |
print CRLE64 "#!/bin/sh\ncrle -64\\\n"; |
|
1218 |
} |
|
1219 |
print CRLE64 "\t-o $FullDir -a $RelDir/$Entry \\\n"; |
|
1220 |
} |
|
1221 |
||
1222 |
# Create a crle(1) script for any 32-bit dependencies we locate. A runtime |
|
1223 |
# configuration file will be generated to establish alternative dependency |
|
1224 |
# mappings for all these dependencies. |
|
1225 |
||
1226 |
sub Entercrle32 { |
|
1227 |
my($FullDir, $RelDir, $Entry) = @_; |
|
1228 |
||
1229 |
if (!$Crle32) { |
|
1230 |
# Create and initialize the script if is doesn't already exit. |
|
1231 |
||
1232 |
$Crle32 = "$Tmpdir/$Prog.crle32.$$"; |
|
1233 |
open(CRLE32, "> $Crle32") || |
|
1234 |
die "$Prog: open failed: $Crle32: $!"; |
|
1235 |
||
1236 |
print CRLE32 "#!/bin/sh\ncrle \\\n"; |
|
1237 |
} |
|
1238 |
print CRLE32 "\t-o $FullDir -a $RelDir/$Entry \\\n"; |
|
1239 |
} |
|
1240 |
||
1241 |
# Having finished gathering dependencies, complete any crle(1) scripts and |
|
1242 |
# execute them to generate the associated runtime configuration files. In |
|
1243 |
# addition establish the environment variable required to pass the configuration |
|
1244 |
# files to ldd(1). |
|
1245 |
||
1246 |
sub GenConf { |
|
1247 |
if ($Crle64) { |
|
1248 |
$Conf64 = "$Tmpdir/$Prog.conf64.$$"; |
|
1249 |
print CRLE64 "\t-c $Conf64\n"; |
|
1250 |
||
1251 |
chmod 0755, $Crle64; |
|
1252 |
close CRLE64; |
|
1253 |
||
1254 |
if (system($Crle64)) { |
|
1255 |
undef $Conf64; |
|
1256 |
} |
|
1257 |
} |
|
1258 |
if ($Crle32) { |
|
1259 |
$Conf32 = "$Tmpdir/$Prog.conf32.$$"; |
|
1260 |
print CRLE32 "\t-c $Conf32\n"; |
|
1261 |
||
1262 |
chmod 0755, $Crle32; |
|
1263 |
close CRLE32; |
|
1264 |
||
1265 |
if (system($Crle32)) { |
|
1266 |
undef $Conf32; |
|
1267 |
} |
|
1268 |
} |
|
1269 |
||
1270 |
if ($Crle64 && $Conf64 && $Crle32 && $Conf32) { |
|
1271 |
$Env = "-e LD_FLAGS=config_64=$Conf64,config_32=$Conf32"; |
|
1272 |
} elsif ($Crle64 && $Conf64) { |
|
1273 |
$Env = "-e LD_FLAGS=config_64=$Conf64"; |
|
1274 |
} elsif ($Crle32 && $Conf32) { |
|
1275 |
$Env = "-e LD_FLAGS=config_32=$Conf32"; |
|
1276 |
} |
|
1277 |
} |
|
1278 |
||
1279 |
# Recurse through a directory hierarchy looking for appropriate dependencies. |
|
1280 |
||
1281 |
sub GetDeps { |
|
1282 |
my($FullDir, $RelDir) = @_; |
|
1283 |
my($NewFull); |
|
1284 |
||
1285 |
# Open the directory and read each entry, omit files starting with "." |
|
1286 |
if (opendir(DIR, $FullDir)) { |
|
1287 |
foreach my $Entry (readdir(DIR)) { |
|
1288 |
if ($Entry =~ /^\./) { |
|
1289 |
next; |
|
1290 |
} |
|
1291 |
$NewFull = "$FullDir/$Entry"; |
|
1292 |
||
1293 |
# We need to follow links so that any dependencies |
|
1294 |
# are expressed in all their available forms. |
|
1295 |
# Bail on symlinks like 32 -> . |
|
1296 |
if (-l $NewFull) { |
|
1297 |
if (readlink($NewFull) =~ /^\.$/) { |
|
1298 |
next; |
|
1299 |
} |
|
1300 |
} |
|
1301 |
if (!stat($NewFull)) { |
|
1302 |
next; |
|
1303 |
} |
|
1304 |
||
3967
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
1305 |
if (!$opt{a}) { |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
1306 |
if ($NewFull =~ $SkipCrleConf) { |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
1307 |
next; |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
1308 |
} |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
1309 |
} |
390705455279
6542674 check_rtime generates false unused messages for libc.so.1/libc_hwcap.so
rie
parents:
2912
diff
changeset
|
1310 |
|
0 | 1311 |
# If this is a directory descend into it. |
1312 |
if (-d _) { |
|
1313 |
my($NewRel); |
|
1314 |
||
1315 |
if ($RelDir =~ /^\/$/) { |
|
1316 |
$NewRel = "$RelDir$Entry"; |
|
1317 |
} else { |
|
1318 |
$NewRel = "$RelDir/$Entry"; |
|
1319 |
} |
|
1320 |
||
1321 |
GetDeps($NewFull, $NewRel); |
|
1322 |
next; |
|
1323 |
} |
|
1324 |
||
1325 |
# If this is a regular file determine if its a |
|
1326 |
# valid ELF dependency. |
|
1327 |
if (-f _) { |
|
1328 |
my($File); |
|
1329 |
||
1330 |
# Typically shared object dependencies end with |
|
1331 |
# ".so" or ".so.?", hence we can reduce the cost |
|
1332 |
# of this script (a lot!) by screening out files |
|
1333 |
# that don't follow this pattern. |
|
1334 |
if (!$opt{a}) { |
|
1335 |
if ($Entry !~ /\.so(?:\.\d+)*$/) { |
|
1336 |
next; |
|
1337 |
} |
|
1338 |
} |
|
1339 |
||
1340 |
$File = `file $NewFull`; |
|
1341 |
if ($File !~ /dynamic lib/) { |
|
1342 |
next; |
|
1343 |
} |
|
1344 |
||
1345 |
if ($File =~ /32-bit/) { |
|
1346 |
Entercrle32($FullDir, $RelDir, $Entry); |
|
1347 |
} elsif ($Ena64) { |
|
1348 |
Entercrle64($FullDir, $RelDir, $Entry); |
|
1349 |
} |
|
1350 |
next; |
|
1351 |
} |
|
1352 |
} |
|
1353 |
closedir(DIR); |
|
1354 |
} |
|
1355 |
} |
|
1356 |
exit $Error |