diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2021-02-22 15:53:03 +0200 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2021-02-26 15:09:58 +0200 |
commit | 21cd5e4e309a24a81bfdea2b998a83426891876a (patch) | |
tree | 6224937581a70600420ea7f751358d891f82a215 /scripts | |
parent | 706e1e6b24a40bfd9c2b07f084af47532bc2141f (diff) |
build: check names of global symbols in static libraries
Add tests to check that global symbols in static libodp-linux and
libodphelper conform to certain prefix patterns.
Fixes: https://github.com/OpenDataPlane/odp/issues/805
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/check-globals.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/check-globals.sh b/scripts/check-globals.sh new file mode 100755 index 000000000..d198c50c8 --- /dev/null +++ b/scripts/check-globals.sh @@ -0,0 +1,37 @@ +#!/bin/bash -e +# +# Check that global symbols in a static library conform to a given regex. +# Only static library is checked, since libtool -export-symbols-regex +# takes care of dynamic libraries. +# +# Required variables: +# LIBTOOL Path to libtool. +# NM Path to nm. +# LIB Library directory. +# lib_LTLIBRARIES Library .la file. +# CHECK_GLOBALS_REGEX Global symbols matching this regex are accepted. +# + +tmpfile=$(mktemp) + +# get $objdir +$LIBTOOL --config > $tmpfile +. $tmpfile + +# get $old_library (static library name) +. $lib_LTLIBRARIES + +echo "$old_library: Checking global symbols, regex: $CHECK_GLOBALS_REGEX" + +# get a list of symbols that are global, are not undefined or weak, and +# do not match the regex +$NM -g --defined-only $LIB/$objdir/$old_library | \ + egrep " [uA-T] " | egrep -v "$CHECK_GLOBALS_REGEX" | tee $tmpfile + +num=$(cat $tmpfile | wc -l) +rm -f $tmpfile + +if [ "$num" != "0" ]; then + echo "$old_library: ($num non-matching symbols)" + false +fi |