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