Add missing $DragonFly$ keywords
[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 # $DragonFly: src/tools/tools/kernxref/kernxref.sh,v 1.2 2003/06/17 04:29:11 dillon Exp $
12 #
13 # This shellscript will make a cross reference of the symbols of the LINT 
14 # kernel.
15
16 COMPILEDIR=/sys/compile
17 KERNELNAME=LINT
18
19 cd ${COMPILEDIR}/${KERNELNAME}
20 if file vers.o | grep -q ELF; then
21         OBJFORMAT=elf;
22 else
23         OBJFORMAT=aout;
24 fi
25
26 OBJFORMAT=${OBJFORMAT} nm -gon `echo *.o /modules/*.ko  \
27         | tr ' ' '\012'                                 \
28         | egrep -v '(aicasm|genassym)'`                 \
29         | tr : ' ' | awk '
30 NF > 1  {
31         if (length($2) == 8) {
32                 $2 = $3
33                 $3 = $4
34         }
35         if ($2 == "t") 
36                 next
37         if ($2 == "F")
38                 next
39         nm[$3]++
40         if ($2 == "U") {
41                 ref[$3]=ref[$3]" "$1
42         } else if ($2 == "T" || $2 == "D" || $2 == "A") {
43                 if (def[$3] != "")
44                         def[$3]=def[$3]" "$1
45                 else
46                         def[$3]=$1
47         } else if ($2 == "?") {
48                 if (def[$3] == "S")
49                         i++
50                 else if (def[$3] != "")
51                         def[$3]=def[$3]",S"
52                 else
53                         def[$3]="S"
54                 ref[$3]=ref[$3]" "$1
55         } else if ($2 == "C") {
56                 if (def[$3] == $2)
57                         i++
58                 else if (def[$3] == "")
59                         def[$3]=$1
60                 else
61                         ref[$3]=ref[$3]" "$1
62         } else {
63                 print ">>>",$0
64         }
65         }
66 END     {
67         for (i in nm) {
68                 printf "%s {%s} %s\n",i,def[i],ref[i]
69         }
70         }
71 ' | sort | awk '
72         {
73         if ($2 == "{S}")
74                 $2 = "<Linker set>"
75         if (length($3) == 0) {
76                 printf "%-30s %3d %s\n\tUNREF\n",$1,0, $2
77                 N1++
78         } else if ($2 == "{}") {
79                 printf "%-30s %3d {UNDEF}\n",$1, NF-2
80                 N2++
81         } else {
82                 printf "%-30s %3d %s",$1,NF-2,$2
83                 p = 80;
84                 for (i = 3 ; i <= NF; i++) {
85                         if (p+length ($i)+1 > 78) {
86                                 printf "\n\t%s", $i
87                                 p = 7;
88                         } else {
89                                 printf " %s", $i
90                         }
91                         p += 1 + length ($i)
92                 }
93                 printf "\n"
94                 N3++
95                 if (NF-2 == 1) 
96                         N4++
97                 if (NF-2 == 2)
98                         N5++
99         }
100         }
101 END     {
102         printf "Total symbols: %5d\n",N1+N2+N3
103         printf "unref symbols: %5d\n",N1
104         printf "undef symbols: %5d\n",N2
105         printf "1 ref symbols: %5d\n",N4
106         printf "2 ref symbols: %5d\n",N5
107         }
108 '