Clean up a bit after the recent ahc/ahd/aic removal.
[dragonfly.git] / tools / tools / kernxref / kernxref.sh
1 :
2 #
3 # ----------------------------------------------------------------------------
4 # "THE BEER-WARE LICENSE" (Revision 42):
5 # <phk@login.dknet.dk> wrote this file.  As long as you retain this notice you
6 # can do whatever you want with this stuff. If we meet some day, and you think
7 # this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
8 # ----------------------------------------------------------------------------
9 #
10 # $FreeBSD: src/tools/tools/kernxref/kernxref.sh,v 1.13 1999/08/28 00:54:30 peter Exp $
11 #
12 # This shellscript will make a cross reference of the symbols of the LINT64 
13 # kernel.
14
15 COMPILEDIR=/sys/compile
16 KERNELNAME=LINT64
17
18 cd ${COMPILEDIR}/${KERNELNAME}
19
20 nm -gon `echo *.o /boot/kernel/*.ok     \
21         | tr ' ' '\012'                                 \
22         | egrep -v '(genassym)'`                        \
23         | tr : ' ' | awk '
24 NF > 1  {
25         if (length($2) == 8) {
26                 $2 = $3
27                 $3 = $4
28         }
29         if ($2 == "t") 
30                 next
31         if ($2 == "F")
32                 next
33         nm[$3]++
34         if ($2 == "U") {
35                 ref[$3]=ref[$3]" "$1
36         } else if ($2 == "T" || $2 == "D" || $2 == "A") {
37                 if (def[$3] != "")
38                         def[$3]=def[$3]" "$1
39                 else
40                         def[$3]=$1
41         } else if ($2 == "?") {
42                 if (def[$3] == "S")
43                         i++
44                 else if (def[$3] != "")
45                         def[$3]=def[$3]",S"
46                 else
47                         def[$3]="S"
48                 ref[$3]=ref[$3]" "$1
49         } else if ($2 == "C") {
50                 if (def[$3] == $2)
51                         i++
52                 else if (def[$3] == "")
53                         def[$3]=$1
54                 else
55                         ref[$3]=ref[$3]" "$1
56         } else {
57                 print ">>>",$0
58         }
59         }
60 END     {
61         for (i in nm) {
62                 printf "%s {%s} %s\n",i,def[i],ref[i]
63         }
64         }
65 ' | sort | awk '
66         {
67         if ($2 == "{S}")
68                 $2 = "<Linker set>"
69         if (length($3) == 0) {
70                 printf "%-30s %3d %s\n\tUNREF\n",$1,0, $2
71                 N1++
72         } else if ($2 == "{}") {
73                 printf "%-30s %3d {UNDEF}\n",$1, NF-2
74                 N2++
75         } else {
76                 printf "%-30s %3d %s",$1,NF-2,$2
77                 p = 80;
78                 for (i = 3 ; i <= NF; i++) {
79                         if (p+length ($i)+1 > 78) {
80                                 printf "\n\t%s", $i
81                                 p = 7;
82                         } else {
83                                 printf " %s", $i
84                         }
85                         p += 1 + length ($i)
86                 }
87                 printf "\n"
88                 N3++
89                 if (NF-2 == 1) 
90                         N4++
91                 if (NF-2 == 2)
92                         N5++
93         }
94         }
95 END     {
96         printf "Total symbols: %5d\n",N1+N2+N3
97         printf "unref symbols: %5d\n",N1
98         printf "undef symbols: %5d\n",N2
99         printf "1 ref symbols: %5d\n",N4
100         printf "2 ref symbols: %5d\n",N5
101         }
102 '