blob: 2fe2d5de7a589e40f0ee86125774444fb9c71ddb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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 "$@"
|