1#!/bin/sh 2 3LC_ALL=C 4export LC_ALL 5 6test -z "$srcdir" && srcdir=. 7test -z "$libs" && libs=.libs 8stat=0 9 10IGNORED_SYMBOLS='_fini\|_init\|_fdata\|_ftext\|_fbss\|__bss_start\|__bss_start__\|__bss_end__\|_edata\|_end\|_bss_end__\|__end__\|__gcov_flush\|llvm_.*' 11 12if which nm 2>/dev/null >/dev/null; then 13 : 14else 15 echo "check-symbols.sh: 'nm' not found; skipping test" 16 exit 77 17fi 18 19tested=false 20for soname in harfbuzz harfbuzz-subset harfbuzz-icu harfbuzz-gobject; do 21 for suffix in so dylib; do 22 so=$libs/lib$soname.$suffix 23 if ! test -f "$so"; then continue; fi 24 25 # On macOS, C symbols are prefixed with _ 26 symprefix= 27 if test $suffix = dylib; then symprefix=_; fi 28 29 EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRST] .' | grep -v " $symprefix\\($IGNORED_SYMBOLS\\>\\)" | cut -d' ' -f3 | c++filt`" 30 31 prefix=$symprefix`basename "$so" | sed 's/libharfbuzz/hb/; s/-/_/g; s/[.].*//'` 32 33 echo "Checking that $so does not expose internal symbols" 34 if echo "$EXPORTED_SYMBOLS" | grep -v "^${prefix}\(_\|$\)"; then 35 echo "Ouch, internal symbols exposed" 36 stat=1 37 fi 38 39 def=$soname.def 40 if ! test -f "$def"; then 41 echo "'$def' not found; skipping" 42 else 43 echo "Checking that $so has the same symbol list as $def" 44 { 45 echo EXPORTS 46 echo "$EXPORTED_SYMBOLS" | sed -e "s/^${symprefix}hb/hb/g" 47 # cheat: copy the last line from the def file! 48 tail -n1 "$def" 49 } | c++filt | diff "$def" - >&2 || stat=1 50 fi 51 52 tested=true 53 done 54done 55if ! $tested; then 56 echo "check-symbols.sh: no shared libraries found; skipping test" 57 exit 77 58fi 59 60exit $stat 61