aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helper/Makefile.am13
l---------helper/check-globals.sh1
-rw-r--r--platform/linux-generic/Makefile.am13
l---------platform/linux-generic/check-globals.sh1
-rwxr-xr-xscripts/check-globals.sh37
5 files changed, 65 insertions, 0 deletions
diff --git a/helper/Makefile.am b/helper/Makefile.am
index 95167c3be..264b3d365 100644
--- a/helper/Makefile.am
+++ b/helper/Makefile.am
@@ -79,3 +79,16 @@ __LIB__libodphelper_la_LIBADD = $(PTHREAD_LIBS)
__LIB__libodphelper_la_LIBADD += $(LIBCLI_LIBS)
lib_LTLIBRARIES = $(LIB)/libodphelper.la
+
+CHECK_GLOBALS_REGEX = " odph_"
+
+TESTS_ENVIRONMENT = \
+ LIBTOOL="$(LIBTOOL)" \
+ NM="$(NM)" \
+ LIB="$(LIB)" \
+ lib_LTLIBRARIES="$(lib_LTLIBRARIES)" \
+ CHECK_GLOBALS_REGEX=$(CHECK_GLOBALS_REGEX)
+
+dist_check_SCRIPTS = check-globals.sh
+
+TESTS = $(dist_check_SCRIPTS)
diff --git a/helper/check-globals.sh b/helper/check-globals.sh
new file mode 120000
index 000000000..821608c6e
--- /dev/null
+++ b/helper/check-globals.sh
@@ -0,0 +1 @@
+../scripts/check-globals.sh \ No newline at end of file
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 1d9a3bbdb..f563040f5 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -373,3 +373,16 @@ __LIB__libodp_linux_la_LIBADD += $(TIMER_LIBS)
if ODP_PKTIO_PCAP
__LIB__libodp_linux_la_LIBADD += $(PCAP_LIBS)
endif
+
+CHECK_GLOBALS_REGEX = " (odp_|_odp_|_deprecated_odp_|miniz_|mz_|tdefl_|tinfl_|mp_hdlr_init_odp_pool_ops)"
+
+TESTS_ENVIRONMENT = \
+ LIBTOOL="$(LIBTOOL)" \
+ NM="$(NM)" \
+ LIB="$(LIB)" \
+ lib_LTLIBRARIES="$(lib_LTLIBRARIES)" \
+ CHECK_GLOBALS_REGEX=$(CHECK_GLOBALS_REGEX)
+
+dist_check_SCRIPTS = check-globals.sh
+
+TESTS = $(dist_check_SCRIPTS)
diff --git a/platform/linux-generic/check-globals.sh b/platform/linux-generic/check-globals.sh
new file mode 120000
index 000000000..c999a29ef
--- /dev/null
+++ b/platform/linux-generic/check-globals.sh
@@ -0,0 +1 @@
+../../scripts/check-globals.sh \ No newline at end of file
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