Merge from vendor branch HEIMDAL:
[dragonfly.git] / tools / tools / local_syms / local_syms.sh
1 #! /bin/sh
2 # $DragonFly: src/tools/tools/local_syms/local_syms.sh,v 1.1 2005/01/10 22:13:45 joerg Exp $
3
4 # Process all object files in the current directory and build a list
5 # of symbols which are used only locally. Those are good candidates
6 # for static.
7
8 tempfoo=`basename $0`
9 TMPFILE=`mktemp -d -t ${tempfoo}` || exit 1
10
11 for a in *.o
12 do
13         nm -gpu "$a" | sed 's/^ *U //'
14 done | sort | uniq > ${TMPFILE}/external_syms
15
16 for a in *.o
17 do
18         nm -pg --defined-only $a | awk '{ print $3 ; }' | sort > ${TMPFILE}/defined_syms
19         comm -23 ${TMPFILE}/defined_syms ${TMPFILE}/external_syms > ${TMPFILE}/uniq_syms
20         if test `wc -l < ${TMPFILE}/uniq_syms` -gt 0
21         then
22                 echo "$a:"
23                 cat ${TMPFILE}/uniq_syms
24                 echo
25         fi
26 done
27
28 rm -R ${TMPFILE}