Print this page
9139 check_rtime should be able to forbid libraries
9140 check_rtime should learn libnsl is safe now
9141 check_rtime exceptions could be cleaner


  79 # expression variable will be undefined. Users of these variables must
  80 # test the variable with defined() prior to use:
  81 #
  82 #       defined($EXRE_exec_stack) && ($foo =~ $EXRE_exec_stack)
  83 #
  84 # or if the test is to make sure the item is not specified:
  85 #
  86 #       !defined($EXRE_exec_stack) || ($foo !~ $EXRE_exec_stack)
  87 #
  88 # ----
  89 #
  90 # The exceptions are:
  91 #
  92 #   EXEC_DATA
  93 #       Objects that are not required to have non-executable writable
  94 #       data segments.
  95 #
  96 #   EXEC_STACK
  97 #       Objects that are not required to have a non-executable stack
  98 #






  99 #   NOCRLEALT
 100 #       Objects that should be skipped by AltObjectConfig() when building
 101 #       the crle script that maps objects to the proto area.
 102 #
 103 #    NODIRECT
 104 #       Objects that are not required to use direct bindings
 105 #
 106 #    NOSYMSORT
 107 #       Objects we should not check for duplicate addresses in
 108 #       the symbol sort sections.
 109 #
 110 #    OLDDEP
 111 #       Objects that are no longer needed because their functionalty
 112 #       has migrated elsewhere. These are usually pure filters that
 113 #       point at libc.
 114 #
 115 #    SKIP
 116 #       Files and directories that should be excluded from analysis.
 117 #
 118 #    STAB


 121 #    TEXTREL
 122 #       Object for which relocations are allowed to the text segment
 123 #
 124 #    UNDEF_REF
 125 #       Objects that are allowed undefined references
 126 #
 127 #    UNREF_OBJ
 128 #       "unreferenced object=" ldd(1) diagnostics.
 129 #
 130 #    UNUSED_DEPS
 131 #       Objects that are allowed to have unused dependencies
 132 #
 133 #    UNUSED_OBJ
 134 #       Objects that are allowed to be unused dependencies
 135 #
 136 #    UNUSED_RPATH
 137 #       Objects with unused runpaths
 138 #
 139 
 140 use vars  qw($EXRE_exec_data $EXRE_exec_stack $EXRE_nocrlealt);
 141 use vars  qw($EXRE_nodirect $EXRE_nosymsort);
 142 use vars  qw($EXRE_olddep $EXRE_skip $EXRE_stab $EXRE_textrel $EXRE_undef_ref);
 143 use vars  qw($EXRE_unref_obj $EXRE_unused_deps $EXRE_unused_obj);
 144 use vars  qw($EXRE_unused_rpath);
 145 
 146 use strict;
 147 use Getopt::Std;
 148 use File::Basename;
 149 
 150 
 151 # Reliably compare two OS revisions.  Arguments are <ver1> <op> <ver2>.
 152 # <op> is the string form of a normal numeric comparison operator.
 153 sub cmp_os_ver {
 154         my @ver1 = split(/\./, $_[0]);
 155         my $op = $_[1];
 156         my @ver2 = split(/\./, $_[2]);
 157 
 158         push @ver2, ("0") x $#ver1 - $#ver2;
 159         push @ver1, ("0") x $#ver2 - $#ver1;
 160 
 161         my $diff = 0;


 426                                     "continued ...") if !$opt{o};
 427                                 next;
 428                         }
 429                         # Just print the symbol name.
 430                         $Line =~ s/$/\t<no -zdefs?>/;
 431                         onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath, $Line);
 432                         next;
 433                 }
 434                 # Look for any unused search paths.
 435                 if ($Line =~ /unused search path=/) {
 436                         next if defined($EXRE_unused_rpath) &&
 437                             ($Line =~ $EXRE_unused_rpath);
 438 
 439                         if ($Secure) {
 440                                 $Line =~ s!$Tmpdir/!!;
 441                         }
 442                         $Line =~ s/^[ \t]*(.*)/\t$1\t<remove search path?>/;
 443                         onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath, $Line);
 444                         next;
 445                 }

 446                 # Look for unreferenced dependencies.  Note, if any unreferenced
 447                 # objects are ignored, then set $UnDep so as to suppress any
 448                 # associated unused-object messages.
 449                 if ($Line =~ /unreferenced object=/) {
 450                         if (defined($EXRE_unref_obj) &&
 451                             ($Line =~ $EXRE_unref_obj)) {
 452                                 $UnDep = 0;
 453                                 next;
 454                         }
 455                         if ($Secure) {
 456                                 $Line =~ s!$Tmpdir/!!;
 457                         }
 458                         $Line =~ s/^[ \t]*(.*)/$1\t<remove lib or -zignore?>/;
 459                         onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath, $Line);
 460                         next;
 461                 }
 462                 # Look for any unused dependencies.
 463                 if ($UnDep && ($Line =~ /unused/)) {
 464                         # Skip if object is allowed to have unused dependencies
 465                         next if defined($EXRE_unused_deps) &&


 560                         $Relsz = hex((split(' ', $Line))[2]);
 561                         next;
 562                 }
 563 
 564                 # Does this file have any plt relocations.  If the plt size is
 565                 # equivalent to the total relocation size then we don't have
 566                 # any relocations suitable for combining into a .SUNW_reloc
 567                 # section.
 568                 if (($Pltsz == 0) && ($Line =~ / PLTRELSZ/)) {
 569                         $Pltsz = hex((split(' ', $Line))[2]);
 570                         next;
 571                 }
 572 
 573                 # Does this object have any dependencies.
 574                 if ($Line =~ /NEEDED/) {
 575                         my($Need) = (split(' ', $Line))[3];
 576 
 577                         if (defined($EXRE_olddep) && ($Need =~ $EXRE_olddep)) {
 578                                 # Catch any old (unnecessary) dependencies.
 579                                 onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath,
 580                         "NEEDED=$Need\t<dependency no longer necessary>");










 581                         } elsif ($opt{i}) {
 582                                 # Under the -i (information) option print out
 583                                 # any useful dynamic entries.
 584                                 onbld_elfmod::OutMsg($InfoFH, $InfoTtl, $RelPath,
 585                                     "NEEDED=$Need");
 586                         }
 587                         next;
 588                 }
 589 
 590                 # Is this object built with -B direct flag on?
 591                 if ($Line =~ / DIRECT /) {
 592                         $HasDirectBinding = 1;
 593                 }
 594 
 595                 # Does this object specify a runpath.
 596                 if ($opt{i} && ($Line =~ /RPATH/)) {
 597                         my($Rpath) = (split(' ', $Line))[3];
 598                         onbld_elfmod::OutMsg($InfoFH, $InfoTtl,
 599                             $RelPath, "RPATH=$Rpath");
 600                         next;




  79 # expression variable will be undefined. Users of these variables must
  80 # test the variable with defined() prior to use:
  81 #
  82 #       defined($EXRE_exec_stack) && ($foo =~ $EXRE_exec_stack)
  83 #
  84 # or if the test is to make sure the item is not specified:
  85 #
  86 #       !defined($EXRE_exec_stack) || ($foo !~ $EXRE_exec_stack)
  87 #
  88 # ----
  89 #
  90 # The exceptions are:
  91 #
  92 #   EXEC_DATA
  93 #       Objects that are not required to have non-executable writable
  94 #       data segments.
  95 #
  96 #   EXEC_STACK
  97 #       Objects that are not required to have a non-executable stack
  98 #
  99 #   FORBIDDEN_DEP
 100 #       Objects allowed to link to 'forbidden' objects
 101 #
 102 #   FORBIDDEN
 103 #       Objects to which nobody not excepted with FORBIDDEN_DEP may link
 104 #
 105 #   NOCRLEALT
 106 #       Objects that should be skipped by AltObjectConfig() when building
 107 #       the crle script that maps objects to the proto area.
 108 #
 109 #    NODIRECT
 110 #       Objects that are not required to use direct bindings
 111 #
 112 #    NOSYMSORT
 113 #       Objects we should not check for duplicate addresses in
 114 #       the symbol sort sections.
 115 #
 116 #    OLDDEP
 117 #       Objects that are no longer needed because their functionalty
 118 #       has migrated elsewhere. These are usually pure filters that
 119 #       point at libc.
 120 #
 121 #    SKIP
 122 #       Files and directories that should be excluded from analysis.
 123 #
 124 #    STAB


 127 #    TEXTREL
 128 #       Object for which relocations are allowed to the text segment
 129 #
 130 #    UNDEF_REF
 131 #       Objects that are allowed undefined references
 132 #
 133 #    UNREF_OBJ
 134 #       "unreferenced object=" ldd(1) diagnostics.
 135 #
 136 #    UNUSED_DEPS
 137 #       Objects that are allowed to have unused dependencies
 138 #
 139 #    UNUSED_OBJ
 140 #       Objects that are allowed to be unused dependencies
 141 #
 142 #    UNUSED_RPATH
 143 #       Objects with unused runpaths
 144 #
 145 
 146 use vars  qw($EXRE_exec_data $EXRE_exec_stack $EXRE_nocrlealt);
 147 use vars  qw($EXRE_nodirect $EXRE_nosymsort $EXRE_forbidden_dep $EXRE_forbidden);
 148 use vars  qw($EXRE_olddep $EXRE_skip $EXRE_stab $EXRE_textrel $EXRE_undef_ref);
 149 use vars  qw($EXRE_unref_obj $EXRE_unused_deps $EXRE_unused_obj);
 150 use vars  qw($EXRE_unused_rpath);
 151 
 152 use strict;
 153 use Getopt::Std;
 154 use File::Basename;
 155 
 156 
 157 # Reliably compare two OS revisions.  Arguments are <ver1> <op> <ver2>.
 158 # <op> is the string form of a normal numeric comparison operator.
 159 sub cmp_os_ver {
 160         my @ver1 = split(/\./, $_[0]);
 161         my $op = $_[1];
 162         my @ver2 = split(/\./, $_[2]);
 163 
 164         push @ver2, ("0") x $#ver1 - $#ver2;
 165         push @ver1, ("0") x $#ver2 - $#ver1;
 166 
 167         my $diff = 0;


 432                                     "continued ...") if !$opt{o};
 433                                 next;
 434                         }
 435                         # Just print the symbol name.
 436                         $Line =~ s/$/\t<no -zdefs?>/;
 437                         onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath, $Line);
 438                         next;
 439                 }
 440                 # Look for any unused search paths.
 441                 if ($Line =~ /unused search path=/) {
 442                         next if defined($EXRE_unused_rpath) &&
 443                             ($Line =~ $EXRE_unused_rpath);
 444 
 445                         if ($Secure) {
 446                                 $Line =~ s!$Tmpdir/!!;
 447                         }
 448                         $Line =~ s/^[ \t]*(.*)/\t$1\t<remove search path?>/;
 449                         onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath, $Line);
 450                         next;
 451                 }
 452                 
 453                 # Look for unreferenced dependencies.  Note, if any unreferenced
 454                 # objects are ignored, then set $UnDep so as to suppress any
 455                 # associated unused-object messages.
 456                 if ($Line =~ /unreferenced object=/) {
 457                         if (defined($EXRE_unref_obj) &&
 458                             ($Line =~ $EXRE_unref_obj)) {
 459                                 $UnDep = 0;
 460                                 next;
 461                         }
 462                         if ($Secure) {
 463                                 $Line =~ s!$Tmpdir/!!;
 464                         }
 465                         $Line =~ s/^[ \t]*(.*)/$1\t<remove lib or -zignore?>/;
 466                         onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath, $Line);
 467                         next;
 468                 }
 469                 # Look for any unused dependencies.
 470                 if ($UnDep && ($Line =~ /unused/)) {
 471                         # Skip if object is allowed to have unused dependencies
 472                         next if defined($EXRE_unused_deps) &&


 567                         $Relsz = hex((split(' ', $Line))[2]);
 568                         next;
 569                 }
 570 
 571                 # Does this file have any plt relocations.  If the plt size is
 572                 # equivalent to the total relocation size then we don't have
 573                 # any relocations suitable for combining into a .SUNW_reloc
 574                 # section.
 575                 if (($Pltsz == 0) && ($Line =~ / PLTRELSZ/)) {
 576                         $Pltsz = hex((split(' ', $Line))[2]);
 577                         next;
 578                 }
 579 
 580                 # Does this object have any dependencies.
 581                 if ($Line =~ /NEEDED/) {
 582                         my($Need) = (split(' ', $Line))[3];
 583 
 584                         if (defined($EXRE_olddep) && ($Need =~ $EXRE_olddep)) {
 585                                 # Catch any old (unnecessary) dependencies.
 586                                 onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath,
 587                                     "NEEDED=$Need\t<dependency no " .
 588                                     "longer necessary>");
 589                         } elsif (defined($EXRE_forbidden) && 
 590                             ($Need =~ $EXRE_forbidden)) {
 591                                 next if defined($EXRE_forbidden_dep) &&
 592                                     ($FullPath =~ $EXRE_forbidden_dep);
 593 
 594                                 onbld_elfmod::OutMsg($ErrFH, $ErrTtl, $RelPath, 
 595                                     "NEEDED=$Need\t<forbidden dependency, " .
 596                                     "missing -nodefaultlibs?>");
 597                                 next;
 598                         } elsif ($opt{i}) {
 599                                 # Under the -i (information) option print out
 600                                 # any useful dynamic entries.
 601                                 onbld_elfmod::OutMsg($InfoFH, $InfoTtl, $RelPath,
 602                                     "NEEDED=$Need");
 603                         }
 604                         next;
 605                 }
 606 
 607                 # Is this object built with -B direct flag on?
 608                 if ($Line =~ / DIRECT /) {
 609                         $HasDirectBinding = 1;
 610                 }
 611 
 612                 # Does this object specify a runpath.
 613                 if ($opt{i} && ($Line =~ /RPATH/)) {
 614                         my($Rpath) = (split(' ', $Line))[3];
 615                         onbld_elfmod::OutMsg($InfoFH, $InfoTtl,
 616                             $RelPath, "RPATH=$Rpath");
 617                         next;