3 # ----------------------------------------------------------------------------
4 # "THE BEER-WARE LICENSE" (Revision 42):
5 # <phk@FreeBSD.org> 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 # ----------------------------------------------------------------------------
10 # Sort options by "Matthew Emmerton" <matt@gsicomp.on.ca>
14 # This shell script will make a cross reference of the symbols of a kernel.
17 COMPILEDIR=/sys/`uname -m`/compile
21 args=`getopt h?k:s: $*`;
32 echo "Usage: $0 [ -k <kernelname> ] [ -s [ 'symbol' | 'filename' ] ]";
37 if [ -d ${COMPILEDIR}/${KERNELNAME} ];
42 echo "Kernel '$KERNELNAME' does not exist in ${COMPILEDIR}!";
46 if [ "x$2" = "xsymbol" ]
52 if [ "x$2" = "xfilename" ]
58 echo "Invalid selection for -s: $2";
68 cd ${COMPILEDIR}/${KERNELNAME}
70 MOD_OBJS=`find modules -name \*.o`
72 for i in *.o $MOD_OBJS
89 } else if ($3 == "D" || $3 == "T" || $3 == "B" || $3 == "R" || $3 == "A") {
95 } else if ($2 == "?") {
98 else if (def[$3] != "")
104 } else if ($2 == "C") {
107 else if (def[$3] == "")
118 printf "%s {%s} %s\n",i,def[i],ref[i]
121 ' | sort $SORTORDER | awk '
125 if (length($3) == 0) {
126 printf "%-31s %d %s\tUNREF\n",$1,0, $2
128 } else if ($2 == "{}") {
129 printf "%-31s %d {UNDEF}\n",$1, NF-2
132 printf "%-31s %d %s",$1,NF-2,$2
134 for (i = 3 ; i <= NF; i++) {
135 if (p+length ($i)+1 > 48) {
136 printf "\n\t\t\t\t\t%s", $i
152 printf "Total symbols: %5d\n",N1+N2+N3
153 printf "unref symbols: %5d\n",N1
154 printf "undef symbols: %5d\n",N2
155 printf "1 ref symbols: %5d\n",N4
156 printf "2 ref symbols: %5d\n",N5