regen config
[binutils-gdb.git] / gprofng / libcollector / CHK_LIBC_OBJ
1 #!/bin/sh
2 #
3 # Copyright (C) 2021-2023 Free Software Foundation, Inc.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; see the file COPYING3. If not see
17 # <http://www.gnu.org/licenses/>.
18
19 #
20 # CHK_LIBC_OBJ -- a script to scan the .o's in an output directory,
21 # which is one of ../{intel-S2,sparc-S2,intel-Linux,sparc-Linux}
22 #
23 # usage: cd to the output directory, and invoke ../src/CHK_LIBC_OBJ
24
25
26 check_obj() {
27 logF="nm.`basename $1`.log"
28 if [ `uname` = 'Linux' ]; then
29 nm $1 | grep -v GLIBC_ > ${logF}
30 else
31 nm $1 > ${logF}
32 fi
33
34 FUNC_LIST="strcpy strlcpy strncpy strcat strlcat strncat strncmp strlen \
35 strerror strchr strrchr strpbrk strstr strtok strtok_r \
36 printf fprintf sprintf snprintf asprintf wsprintf \
37 vprintf vfprintf vsprintf vsnprintf vasprintf \
38 memset memcmp memcpy strtol strtoll strtoul strtoull \
39 getcpuid calloc malloc free strdup"
40 res=0
41 echo " -- Checking Object file '$1' for functions from libc"
42 for j in `echo ${FUNC_LIST}` ; do
43 grep -w ${j} ${logF} | grep UNDEF> grep.log 2>&1
44 if [ $? -eq 0 ]; then
45 grep -w ${j} ${logF}
46 res=1
47 fi
48 done
49 return ${res}
50 }
51
52 STATUS=0
53
54 for i in *.o ; do
55 echo ""
56 check_obj ${i}
57 res=$?
58 if [ ${res} -eq 0 ]; then
59 echo "Object file ${i} does not reference functions in libc"
60 else
61 echo "======Object file: ${i} DOES reference functions in libc"
62 fi
63 if [ ${STATUS} -eq 0 ]; then
64 STATUS=${res}
65 fi
66 done
67
68 for i in *.so ; do
69 echo ""
70 check_obj ${i}
71 res=$?
72 if [ ${res} -eq 0 ]; then
73 echo "Object file ${i} does not reference functions in libc"
74 else
75 echo "======Object file: ${i} DOES reference functions in libc"
76 fi
77 if [ ${STATUS} -eq 0 ]; then
78 STATUS=${res}
79 fi
80 done
81
82 exit $STATUS