3 # SPDX-License-Identifier: Beerware
5 # ----------------------------------------------------------------------------
6 # "THE BEER-WARE LICENSE" (Revision 42):
7 # <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
8 # can do whatever you want with this stuff. If we meet some day, and you think
9 # this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
10 # ----------------------------------------------------------------------------
12 # Sort options by "Matthew Emmerton" <matt@gsicomp.on.ca>
16 # This shell script will make a cross reference of the symbols of a kernel.
19 COMPILEDIR=/sys/`uname -m`/compile
23 args=`getopt h?k:s: $*`;
34 echo "Usage: $0 [ -k <kernelname> ] [ -s [ 'symbol' | 'filename' ] ]";
39 if [ -d ${COMPILEDIR}/${KERNELNAME} ];
44 echo "Kernel '$KERNELNAME' does not exist in ${COMPILEDIR}!";
48 if [ "x$2" = "xsymbol" ]
54 if [ "x$2" = "xfilename" ]
60 echo "Invalid selection for -s: $2";
70 cd ${COMPILEDIR}/${KERNELNAME}
72 MOD_OBJS=`find modules -name \*.o`
74 for i in *.o $MOD_OBJS
91 } else if ($3 == "D" || $3 == "T" || $3 == "B" || $3 == "R" || $3 == "A") {
97 } else if ($2 == "?") {
100 else if (def[$3] != "")
106 } else if ($2 == "C") {
109 else if (def[$3] == "")
120 printf "%s {%s} %s\n",i,def[i],ref[i]
123 ' | sort $SORTORDER | awk '
127 if (length($3) == 0) {
128 printf "%-31s %d %s\tUNREF\n",$1,0, $2
130 } else if ($2 == "{}") {
131 printf "%-31s %d {UNDEF}\n",$1, NF-2
134 printf "%-31s %d %s",$1,NF-2,$2
136 for (i = 3 ; i <= NF; i++) {
137 if (p+length ($i)+1 > 48) {
138 printf "\n\t\t\t\t\t%s", $i
154 printf "Total symbols: %5d\n",N1+N2+N3
155 printf "unref symbols: %5d\n",N1
156 printf "undef symbols: %5d\n",N2
157 printf "1 ref symbols: %5d\n",N4
158 printf "2 ref symbols: %5d\n",N5