blob: d4eca5079cb864eb869201ccacb54f82d2e87586 [file] [log] [blame]
Behdad Esfahboda02d8642012-08-08 18:04:29 -04001#!/bin/sh
2
3LC_ALL=C
4export LC_ALL
5
6test -z "$srcdir" && srcdir=.
Ebrahim Byagowi72bec1c2018-01-05 12:42:20 +03307test -z "$libs" && libs=.libs
Behdad Esfahboda02d8642012-08-08 18:04:29 -04008stat=0
9
Behdad Esfahbode0939d82018-02-23 13:19:34 -080010IGNORED_SYMBOLS='_fini\|_init\|_fdata\|_ftext\|_fbss\|__bss_start\|__bss_start__\|__bss_end__\|_edata\|_end\|_bss_end__\|__end__\|__gcov_flush\|llvm_.*'
Behdad Esfahbod2af82622013-09-16 21:49:56 -040011
Behdad Esfahboda02d8642012-08-08 18:04:29 -040012if which nm 2>/dev/null >/dev/null; then
13 :
14else
Behdad Esfahbodbafdf3d2013-02-04 23:06:50 -050015 echo "check-symbols.sh: 'nm' not found; skipping test"
Behdad Esfahboda02d8642012-08-08 18:04:29 -040016 exit 77
17fi
18
Behdad Esfahboda02d8642012-08-08 18:04:29 -040019tested=false
Behdad Esfahboda981d792018-02-10 15:17:28 -060020for soname in harfbuzz harfbuzz-subset harfbuzz-icu harfbuzz-gobject; do
Ebrahim Byagowi844f48e2018-02-10 23:13:12 +033021 for suffix in so dylib; do
22 so=$libs/lib$soname.$suffix
23 if ! test -f "$so"; then continue; fi
Ebrahim Byagowibef240b2016-10-10 17:27:52 +033024
Ebrahim Byagowi844f48e2018-02-10 23:13:12 +033025 # On macOS, C symbols are prefixed with _
Behdad Esfahbode0939d82018-02-23 13:19:34 -080026 symprefix=
27 if test $suffix = dylib; then symprefix=_; fi
Behdad Esfahbod8c6bd342014-08-14 13:33:37 -040028
Behdad Esfahbode0939d82018-02-23 13:19:34 -080029 EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] .' | grep -v " $symprefix\\($IGNORED_SYMBOLS\\>\\)" | cut -d' ' -f3 | c++filt`"
30
31 prefix=$symprefix`basename "$so" | sed 's/libharfbuzz/hb/; s/-/_/g; s/[.].*//'`
32
Behdad Esfahbode0939d82018-02-23 13:19:34 -080033 echo "Checking that $so does not expose internal symbols"
Ebrahim Byagowi844f48e2018-02-10 23:13:12 +033034 if echo "$EXPORTED_SYMBOLS" | grep -v "^${prefix}\(_\|$\)"; then
35 echo "Ouch, internal symbols exposed"
36 stat=1
37 fi
Behdad Esfahbod2af82622013-09-16 21:49:56 -040038
Behdad Esfahbode0939d82018-02-23 13:19:34 -080039 def=$soname.def
40 if ! test -f "$def"; then
41 echo "'$def' not found; skipping"
42 else
Behdad Esfahbode0939d82018-02-23 13:19:34 -080043 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
Ebrahim Byagowi844f48e2018-02-10 23:13:12 +033052 tested=true
53 done
Behdad Esfahboda02d8642012-08-08 18:04:29 -040054done
55if ! $tested; then
Behdad Esfahbode0939d82018-02-23 13:19:34 -080056 echo "check-symbols.sh: no shared libraries found; skipping test"
Behdad Esfahboda02d8642012-08-08 18:04:29 -040057 exit 77
58fi
59
60exit $stat