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