1#!/bin/bash
2
3#
4# Copyright (C) 2016 The Android Open Source Project
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#      http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19# Exit in error if we use an undefined variable (i.e. commit a typo).
20set -u
21
22infile="$1"
23shift
24outfile="$1"
25shift
26
27retcode=0
28
29echo -e "\n\nChecking '$infile' for forbidden symbols\n\n" >&2
30
31for var in "$@"
32do
33	look_for=$(echo "$var" | sed 's/\([^=]*\)=\(.*\)/\1/g')
34	if echo "$var" | grep = >/dev/null
35	then
36		explanation=$(echo "$var" | sed 's/\([^=]*\)=/ /g')
37	else
38		explanation=""
39	fi
40
41	explanation="Forbidden function '$look_for' found. This is a build error.$explanation"
42
43
44	if ${CROSS_COMPILE}nm -a "$infile" |grep -e "[0-9a-f]\{8\} [Tt] $look_for" >/dev/null
45	then
46		echo $explanation >&2
47		retcode=-1
48	fi
49done
50
51if [ $retcode -eq 0 ]
52then
53	echo "Symcheck found nothing bad. Proceeding" >&2
54	cp "$infile" "$outfile"
55fi
56
57exit $retcode
58
59
60