kernxref.sh revision 12132
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# $Id: kernxref.sh,v 1.1 1995/10/15 11:33:42 phk Exp $ 11# 12# This shellscript will make a cross reference of the symbols of the LINT 13# kernel. 14 15cd /sys/compile/LINT 16nm -gon *.o /sys/libkern/obj/*.o /lkm/*.o | tr : ' ' | awk ' 17NF > 1 { 18 if (length($2) == 8) { 19 $2 = $3 20 $3 = $4 21 } 22 if ($2 == "t") 23 next 24 if ($2 == "F") 25 next 26 nm[$3]++ 27 if ($2 == "U") { 28 ref[$3]=ref[$3]" "$1 29 } else if ($2 == "T" || $2 == "D" || $2 == "A") { 30 if (def[$3] != "") 31 def[$3]=def[$3]","$1 32 else 33 def[$3]=$1 34 } else if ($2 == "?") { 35 if (def[$3] == "S") 36 i++ 37 else if (def[$3] != "") 38 def[$3]=def[$3]",S" 39 else 40 def[$3]="S" 41 ref[$3]=ref[$3]" "$1 42 } else if ($2 == "C") { 43 if (def[$3] == $2) 44 i++ 45 else if (def[$3] != "") 46 def[$3]=def[$3]",C" 47 else 48 def[$3]="C" 49 ref[$3]=ref[$3]" "$1 50 } else { 51 print ">>>",$0 52 } 53 } 54END { 55 for (i in nm) { 56 printf "%s {%s} %s\n",i,def[i],ref[i] 57 } 58 } 59' | sort | awk ' 60 { 61 if ($2 == "{S}") 62 $2 = "<Linker set>" 63 if ($2 == "{C}") 64 $2 = "<Common symbol>" 65 if (length($3) == 0) { 66 printf "%-30s %s UNREF\n",$1,$2 67 } else if ($2 == "{}") { 68 printf "%-30s {UNDEF}\n",$1 69 } else { 70 printf "%-30s %s\n\t%s\n",$1,$2,$3 71 } 72 } 73' 74