x
[heimdal.git] / cf / check-symbols.sh
blob465bedc6fbf4a9ce0f6956a400eea157377c3852
1 #!/bin/sh
2 # check library exported symbols
3 # $Id$
5 LANG=C
6 export LANG
8 esym="__i686.get_pc_thunk fc_softc"
9 symbols=
11 # AIX has different default output format
12 nmargs=""
13 if [ "`uname`" = AIX ]; then
14 nmargs="-B"
17 while test $# != 0 ;do
18 case "$1" in
19 -lib) lib="$2" ; shift;;
20 -com_err)
21 esym="${esym} com_right\$ free_error_table\$ initialize_error_table_r\$"
22 esym="${esym} com_err error_message\$ error_table_name\$"
23 esym="${esym} init_error_table\$ add_to_error_table\$"
24 esym="${esym} reset_com_err_hook\$ set_com_err_hook\$ _et_list\$"
25 esym="${esym} et_[A-Za-z0-9]*_error_table"
26 esym="${esym} initialize_[A-Za-z0-9]*_error_table et_*_error_table" ;;
27 -version)
28 esym="${esym} print_version\$" ;;
29 -asn1compile)
30 esym="${esym} copy_ free_ length_ decode_ encode_ length_ "
31 esym="${esym} *.2int\$ int2 asn1_[A-Za-z0-9]*_units\$" ;;
32 -*) echo "unknown option $1" ; exit 1 ;;
33 *) break ;;
34 esac
35 shift
36 done
38 for a in "$@" $esym; do
39 symbols="\$3 !~ /^[_\.]?${a}/ ${symbols:+&&} ${symbols}"
40 done
42 # F filename, N debugsymbols, W weak symbols, U undefined
44 (nm $nmargs .libs/lib${lib}.a || nm $nmargs .libs/lib${lib}.so*) |
45 awk "BEGIN { stat = 0 }
46 NF == 3 && \$2 ~ /[A-EG-MO-TVX-Z]/ && $symbols { printf \"%s should not be exported (type %s)\\n\", \$3, \$2; ++stat } END { exit stat }"