File: check_external_calls.sh

package info (click to toggle)
libclc 0.2.0+git20190827-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 3,492 kB
  • sloc: lisp: 13,323; ansic: 2,435; python: 640; cpp: 93; sh: 29; makefile: 10; pascal: 7
file content (36 lines) | stat: -rwxr-xr-x 697 bytes parent folder | download | duplicates (7)
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
#!/bin/sh

FILE=$1
if [ ! -f $FILE ]; then
	echo "ERROR: Not a file: $FILE"
	exit 3
fi
ret=0
if [ "x$LLVM_CONFIG" = "x" ]; then
	LLVM_CONFIG=llvm-config
	echo 'WARNING: $LLVM_CONFIG not set, falling back to $PATH llvm-config'
	ret=2
fi


BIN_DIR=$($LLVM_CONFIG --bindir)
DIS="$BIN_DIR/llvm-dis"
if [ ! -x $DIS ]; then
	echo "ERROR: Disassembler '$DIS' is not executable"
	exit 3
fi

TMP_FILE=$(mktemp)

# Check for calls. Calls to llvm intrinsics are OK
$DIS < $FILE | grep ' call ' | grep -v '@llvm' > "$TMP_FILE"
COUNT=$(wc -l < "$TMP_FILE")

if [ "$COUNT" -ne "0" ]; then
	echo "ERROR: $COUNT unresolved calls detected in $FILE"
	cat $TMP_FILE
	ret=1
else
	echo "File $FILE is OK"
fi
exit $ret