301 $Ena64 = "ok"; |
301 $Ena64 = "ok"; |
302 } |
302 } |
303 } |
303 } |
304 |
304 |
305 # Check that we have arguments. |
305 # Check that we have arguments. |
306 if ((getopts('ad:imos', \%opt) == 0) || ($#ARGV == -1)) { |
306 if ((getopts('ad:imosv', \%opt) == 0) || ($#ARGV == -1)) { |
307 print "usage: $Prog [-a] [-d depdir] [-m] [-o] [-s] file | dir, ...\n"; |
307 print "usage: $Prog [-a] [-d depdir] [-m] [-o] [-s] file | dir, ...\n"; |
308 print "\t[-a]\t\tprocess all files (ignore any exception lists)\n"; |
308 print "\t[-a]\t\tprocess all files (ignore any exception lists)\n"; |
309 print "\t[-d dir]\testablish dependencies from under directory\n"; |
309 print "\t[-d dir]\testablish dependencies from under directory\n"; |
310 print "\t[-i]\t\tproduce dynamic table entry information\n"; |
310 print "\t[-i]\t\tproduce dynamic table entry information\n"; |
311 print "\t[-m]\t\tprocess mcs(1) comments\n"; |
311 print "\t[-m]\t\tprocess mcs(1) comments\n"; |
312 print "\t[-o]\t\tproduce one-liner output (prefixed with pathname)\n"; |
312 print "\t[-o]\t\tproduce one-liner output (prefixed with pathname)\n"; |
313 print "\t[-s]\t\tprocess .stab and .symtab entries\n"; |
313 print "\t[-s]\t\tprocess .stab and .symtab entries\n"; |
|
314 print "\t[-v]\t\tprocess version definition entries\n"; |
314 exit 1; |
315 exit 1; |
315 } else { |
316 } else { |
316 my($Proto); |
317 my($Proto); |
317 |
318 |
318 if ($opt{d}) { |
319 if ($opt{d}) { |
463 sub ProcFile { |
464 sub ProcFile { |
464 my($FullPath, $RelPath, $File, $Secure) = @_; |
465 my($FullPath, $RelPath, $File, $Secure) = @_; |
465 my(@Elf, @Ldd, $Dyn, $Intp, $Dll, $Ttl, $Sym, $Interp, $Stack); |
466 my(@Elf, @Ldd, $Dyn, $Intp, $Dll, $Ttl, $Sym, $Interp, $Stack); |
466 my($Sun, $Relsz, $Pltsz, $Tex, $Stab, $Strip, $Lddopt, $SymSort); |
467 my($Sun, $Relsz, $Pltsz, $Tex, $Stab, $Strip, $Lddopt, $SymSort); |
467 my($Val, $Header, $SkipLdd, $IsX86, $RWX, $UnDep); |
468 my($Val, $Header, $SkipLdd, $IsX86, $RWX, $UnDep); |
468 my($HasDirectBinding); |
469 my($HasDirectBinding, $HasVerdef); |
469 |
470 |
470 # Ignore symbolic links. |
471 # Ignore symbolic links. |
471 if (-l $FullPath) { |
472 if (-l $FullPath) { |
472 return; |
473 return; |
473 } |
474 } |
953 } |
958 } |
954 |
959 |
955 # If there are symbol sort sections in this object, report on |
960 # If there are symbol sort sections in this object, report on |
956 # any that have duplicate addresses. |
961 # any that have duplicate addresses. |
957 ProcSymSort($FullPath, $RelPath, \$Ttl) if $SymSort; |
962 ProcSymSort($FullPath, $RelPath, \$Ttl) if $SymSort; |
|
963 |
|
964 # If -v was specified, and the object has a version definition |
|
965 # section, generate output showing each public symbol and the |
|
966 # version it belongs to. |
|
967 ProcVerdef($FullPath, $RelPath, \$Ttl) if $HasVerdef && $opt{v}; |
958 } |
968 } |
959 |
969 |
960 |
970 |
961 ## ProcSymSortOutMsg(RefTtl, RelPath, secname, addr, names...) |
971 ## ProcSymSortOutMsg(RefTtl, RelPath, secname, addr, names...) |
962 # |
972 # |
1044 |
1054 |
1045 ProcSymSortOutMsg($RefTtl, $RelPath, $secname, $last_addr, @dups) |
1055 ProcSymSortOutMsg($RefTtl, $RelPath, $secname, $last_addr, @dups) |
1046 if (scalar(@dups) > 1); |
1056 if (scalar(@dups) > 1); |
1047 |
1057 |
1048 close SORT; |
1058 close SORT; |
|
1059 } |
|
1060 |
|
1061 |
|
1062 ## ProcVerdef(FullPath, RelPath) |
|
1063 # |
|
1064 # Examine the version definition section for the given object and report |
|
1065 # each public symbol along with the version it belongs to. |
|
1066 # |
|
1067 sub ProcVerdef { |
|
1068 |
|
1069 my($FullPath, $RelPath, $RefTtl) = @_; |
|
1070 my $line; |
|
1071 my $cur_ver = ''; |
|
1072 my $tab = $opt{o} ? '' : "\t"; |
|
1073 |
|
1074 # pvs -dov provides information about the versioning hierarchy |
|
1075 # in the file. Lines are of the format: |
|
1076 # path - version[XXX]; |
|
1077 # where [XXX] indicates optional information, such as flags |
|
1078 # or inherited versions. |
|
1079 # |
|
1080 # Private versions are allowed to change freely, so ignore them. |
|
1081 open(PVS, "pvs -dov $FullPath|") || |
|
1082 die "$Prog: Unable to execute pvs (version definition section)\n"; |
|
1083 |
|
1084 while ($line = <PVS>) { |
|
1085 chomp $line; |
|
1086 |
|
1087 if ($line =~ /^[^\s]+\s+-\s+([^;]+)/) { |
|
1088 my $ver = $1; |
|
1089 |
|
1090 next if $ver =~ /private/i; |
|
1091 OutMsg($$RefTtl++, $RelPath, "${tab}VERDEF=$ver"); |
|
1092 } |
|
1093 } |
|
1094 close PVS; |
|
1095 |
|
1096 # pvs -dos lists the symbols assigned to each version definition. |
|
1097 # Lines are of the format: |
|
1098 # path - version: symbol; |
|
1099 # path - version: symbol (size); |
|
1100 # where the (size) is added to data items, but not for functions. |
|
1101 # We strip off the size, if present. |
|
1102 |
|
1103 open(PVS, "pvs -dos $FullPath|") || |
|
1104 die "$Prog: Unable to execute pvs (version definition section)\n"; |
|
1105 while ($line = <PVS>) { |
|
1106 chomp $line; |
|
1107 if ($line =~ /^[^\s]+\s+-\s+([^:]+):\s*([^\s;]+)/) { |
|
1108 my $ver = $1; |
|
1109 my $sym = $2; |
|
1110 |
|
1111 next if $ver =~ /private/i; |
|
1112 |
|
1113 if ($opt{o}) { |
|
1114 OutMsg($$RefTtl++, $RelPath, |
|
1115 "VERSION=$ver, SYMBOL=$sym"); |
|
1116 } else { |
|
1117 if ($cur_ver ne $ver) { |
|
1118 OutMsg($$RefTtl++, $RelPath, "\tVERSION=$ver"); |
|
1119 $cur_ver = $ver; |
|
1120 } |
|
1121 OutMsg($$RefTtl++, $RelPath, "\t\tSYMBOL=$sym"); |
|
1122 } |
|
1123 } |
|
1124 } |
|
1125 |
|
1126 close PVS; |
1049 } |
1127 } |
1050 |
1128 |
1051 |
1129 |
1052 sub ProcDir { |
1130 sub ProcDir { |
1053 my($FullDir, $RelDir) = @_; |
1131 my($FullDir, $RelDir) = @_; |