| 1 | Rewrite the public symbol check to verify the shared libraries, to check for
|
| 2 | more things, and to avoid duplication; fixes make check on ARM
|
| 3 |
|
| 4 | Taken from Debian:
|
| 5 | https://salsa.debian.org/multimedia-team/mpeg2dec/blob/master/debian/patches/61_global-symbol-test.patch
|
| 6 |
|
| 7 | |
| 8 | |
| 9 | @@ -1,4 +1,8 @@
|
| 10 | #!/bin/sh
|
| 11 | +# TODO
|
| 12 | +# - fix checking of .a libs; problem is that "nm -g --defined-only" lists
|
| 13 | +# internal symbols; this can be solved by using objdump, but it's probably
|
| 14 | +# good enough to just run the tests on the shared lib
|
| 15 |
|
| 16 | if test x"$srcdir" != x""; then
|
| 17 | builddir="." # running from make check, but it does not define that
|
| 18 | @@ -14,22 +18,30 @@ builddir=`cd $builddir;pwd`
|
| 19 |
|
| 20 | error=0
|
| 21 |
|
| 22 | -bad_globals=`nm -g --defined-only $builddir/../libmpeg2/*.o |\
|
| 23 | - awk '{if ($3) print $3}' | grep -v '^_\?mpeg2_'`
|
| 24 | -
|
| 25 | -if test x"$bad_globals" != x""; then
|
| 26 | - echo BAD GLOBAL SYMBOLS:
|
| 27 | - for s in $bad_globals; do echo $s; done
|
| 28 | +# check_bad_public_symbols <symbol prefix> <lib file> [<lib file>...]
|
| 29 | +#
|
| 30 | +# checks public symbols in shared libs:
|
| 31 | +# - allow prefix_anything
|
| 32 | +# - reject _prefixanything
|
| 33 | +# - allow _anything
|
| 34 | +# - reject anything else
|
| 35 | +#
|
| 36 | +# NB: skips missing files
|
| 37 | +check_bad_public_symbols() {
|
| 38 | + symbols_prefix="$1"
|
| 39 | + shift
|
| 40 | + lib_files=`ls "$@" 2>/dev/null`
|
| 41 | + [ -z "$lib_files" ] && return
|
| 42 | + bad_globals=`nm -g --defined-only $lib_files |
|
| 43 | + awk '{if ($3) print $3}' |
|
| 44 | + sed -n "/^${symbols_prefix}_/ d; /^_${symbols_prefix}/ { p; d }; /^_/ d; p"`
|
| 45 | + [ -z "$bad_globals" ] && return
|
| 46 | error=1
|
| 47 | -fi
|
| 48 | -
|
| 49 | -bad_globals=`nm -g --defined-only $builddir/../libmpeg2/convert/*.o |\
|
| 50 | - awk '{if ($3) print $3}' | grep -v '^_\?mpeg2convert_'`
|
| 51 | + echo BAD GLOBAL SYMBOLS in $lib_files:
|
| 52 | + echo "$bad_globals"
|
| 53 | +}
|
| 54 |
|
| 55 | -if test x"$bad_globals" != x""; then
|
| 56 | - echo BAD GLOBAL SYMBOLS:
|
| 57 | - for s in $bad_globals; do echo $s; done
|
| 58 | - error=1
|
| 59 | -fi
|
| 60 | +check_bad_public_symbols mpeg2 $builddir/../libmpeg2/.libs/libmpeg2.so
|
| 61 | +check_bad_public_symbols mpeg2convert $builddir/../libmpeg2/convert/.libs/libmpeg2convert.so
|
| 62 |
|
| 63 | exit $error
|