File: check_pyext_symbol_hiding.sh

package info (click to toggle)
scipy 1.16.0-1exp7
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 234,820 kB
  • sloc: cpp: 503,145; python: 344,611; ansic: 195,638; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 848; makefile: 785; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (39 lines) | stat: -rwxr-xr-x 843 bytes parent folder | download | duplicates (3)
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