aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.ci/verify_symbols.sh
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-10-28 15:43:53 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-10-28 15:46:29 +0300
commit94690ab619aa4ed4894cf80c24146ce922647004 (patch)
tree2a51044729a39aae40aff881427d9f04aff6d81b /.ci/verify_symbols.sh
parentREADME: elaborate (diff)
downloadcmake-common-94690ab619aa4ed4894cf80c24146ce922647004.tar.gz
cmake-common-94690ab619aa4ed4894cf80c24146ce922647004.zip
CI: check that symbols are stripped
Diffstat (limited to '.ci/verify_symbols.sh')
-rwxr-xr-x.ci/verify_symbols.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/.ci/verify_symbols.sh b/.ci/verify_symbols.sh
new file mode 100755
index 0000000..2fe2d5d
--- /dev/null
+++ b/.ci/verify_symbols.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail
+
+script_name="$( basename -- "${BASH_SOURCE[0]}" )"
+readonly script_name
+
+main() {
+ if [ "$#" -lt 1 ]; then
+ echo "usage: $script_name BIN_PATH [SYMBOL...]" >&2
+ return 1
+ fi
+
+ local path="$1"
+ shift
+
+ local nm
+ nm="$( nm --demangle -- "$path" 2>&1 )"
+
+ if [ "$#" -eq 0 ]; then
+ if [ "$nm" == "nm: $path: no symbols" ]; then
+ echo "$script_name: file '$path' has no symbols, as expected"
+ return 0
+ else
+ echo "$script_name: file '$path' should not have symbols, but it does" >&2
+ return 1
+ fi
+ fi
+
+ local symbol
+ for symbol; do
+ if echo "$nm" | grep -F --quiet -e " $symbol"; then
+ echo "$script_name: file '$path' has symbol '$symbol'"
+ else
+ echo "$script_name: symbol '$symbol' wasn't found in file '$path'"
+ echo "$script_name: here's the complete symbol list:"
+ echo "$nm"
+ return 1
+ fi
+ done
+}
+
+main "$@"