aboutsummaryrefslogtreecommitdiff
path: root/tools/tools/kernxref/kernxref.sh
blob: ca483c56942cc1d69f5291b53ce44a0ae81a798b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
:
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <phk@login.dknet.dk> wrote this file.  As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
# ----------------------------------------------------------------------------
#
# $Id$
#
# This shellscript will make a cross reference of the symbols of the LINT 
# kernel.

cd /sys/compile/LINT
nm -gon *.o /lkm/*.o | tr : ' ' | awk '
NF > 1	{
	if (length($2) == 8) {
		$2 = $3
		$3 = $4
	}
	if ($2 == "t") 
		next
	if ($2 == "F")
		next
	nm[$3]++
	if ($2 == "U") {
		ref[$3]=ref[$3]" "$1
	} else if ($2 == "T" || $2 == "D" || $2 == "A") {
		if (def[$3] != "")
			def[$3]=def[$3]" "$1
		else
			def[$3]=$1
	} else if ($2 == "?") {
		if (def[$3] == "S")
			i++
		else if (def[$3] != "")
			def[$3]=def[$3]",S"
		else
			def[$3]="S"
		ref[$3]=ref[$3]" "$1
	} else if ($2 == "C") {
		if (def[$3] == $2)
			i++
		else if (def[$3] == "")
			def[$3]=$1
		else
			ref[$3]=ref[$3]" "$1
	} else {
		print ">>>",$0
	}
	}
END	{
	for (i in nm) {
		printf "%s {%s} %s\n",i,def[i],ref[i]
	}
	}
' | sort | awk '
	{
	if ($2 == "{S}")
		$2 = "<Linker set>"
	if (length($3) == 0) {
		printf "%-30s %3d %s\n\tUNREF\n",$1,0, $2
		N1++
	} else if ($2 == "{}") {
		printf "%-30s %3d {UNDEF}\n",$1, NF-2
		N2++
	} else {
		printf "%-30s %3d %s",$1,NF-2,$2
		p = 80;
		for (i = 3 ; i <= NF; i++) {
			if (p+length ($i)+1 > 78) {
				printf "\n\t%s", $i
				p = 7;
			} else {
				printf " %s", $i
			}
			p += 1 + length ($i)
		}
		printf "\n"
		N3++
		if (NF-2 == 1) 
			N4++
		if (NF-2 == 2)
			N5++
	}
	}
END	{
	printf "Total symbols: %5d\n",N1+N2+N3
	printf "unref symbols: %5d\n",N1
	printf "undef symbols: %5d\n",N2
	printf "1 ref symbols: %5d\n",N4
	printf "2 ref symbols: %5d\n",N5
	}
'