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