aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-globals.sh
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2021-05-26 17:03:10 +0300
committerGitHub <noreply@github.com>2021-05-26 17:03:10 +0300
commit3cc4177b551f32aa4b3b0d76c248f5342362a028 (patch)
treeec8f42fce582fb0400074c34cdf1aa2a4f070cf7 /scripts/check-globals.sh
parentcb9db0fa8ca6dd0d58ffe6180affe43abe53956c (diff)
parentce0f58291aa87b856c7df2501c8e7de9a16a9b5d (diff)
Merge ODP v1.28.0.0v1.28.0.0_DPDK_19.11
Merge ODP linux-generic v1.28.0.0 into ODP-DPDK.
Diffstat (limited to 'scripts/check-globals.sh')
-rwxr-xr-xscripts/check-globals.sh37
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