1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#!/bin/bash
#
# check_pyext_symbol_hiding.sh PATHS...
#
# Check that .so files under the given directories export only a
# single public dynamic symbol each.
#
set -e
count_text_symbols() {
nm -D --defined-only "$1" | wc -l
}
check_symbols() {
NUM=`count_text_symbols "$1"`
FILENAME=$(basename "$1")
# special function error handling requires shared state between extension
# modules that depend on it. There is a shared library encapsulating this
# state which is an exception.
if [[ "$FILENAME" == "libsf_error_state.so" ]]; then
return 0
fi
if [[ "$NUM" != "1" ]]; then
echo "$1: too many public symbols!"
nm -D --defined-only "$1"
exit 1
fi
}
find "$@" -type f -name '*.so' -print | while read F; do
check_symbols "$F"
done
echo "Symbol hiding OK"
exit 0
|