forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-entrypoints.sh
More file actions
executable file
·42 lines (36 loc) · 991 Bytes
/
verify-entrypoints.sh
File metadata and controls
executable file
·42 lines (36 loc) · 991 Bytes
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
#!/usr/bin/env bash
if (( $# != 3 )); then
echo "Usage:"
echo "verify-entrypoints.sh <path to shared library> <path to entries.c file> <path to NM command>"
exit 1
fi
nmCommand=$3
IFS=$'\n'
dllList=()
for line in $($nmCommand $1); do
pattern='^[[:xdigit:]]+ T _?([[:alnum:]_]+)'
if [[ $line =~ $pattern ]]; then
# skip symbols that we don't want to consider
case ${BASH_REMATCH[1]} in
init) ;;
fini) ;;
etext) ;;
PROCEDURE_LINKAGE_TABLE_) ;;
*) dllList+=(${BASH_REMATCH[1]});;
esac
fi
done
entriesList=()
for line in $(<$2); do
pattern='^[[:space:]]+DllImportEntry\(([[:alnum:]_]+)\)'
if [[ $line =~ $pattern ]]; then
entriesList+=(${BASH_REMATCH[1]})
fi
done
diffList=$(echo -n ${entriesList[@]} ${dllList[@]} | tr " " "\n" | sort | uniq -u)
if [ -n "$diffList" ]; then
echo "ERROR: $2 file did not match entries exported from $1" >&2
echo "DIFFERENCES FOUND: " >&2
echo $diffList | tr " " "," >&2
exit 2
fi