Automatic date update in version.in
[binutils-gdb.git] / gprofng / libcollector / CHK_LIBC_OBJ
blobdbeb9cb8fb50ed0620ab846795a96fcc6b582d42
1 #!/bin/sh
3 # Copyright (C) 2021 Free Software Foundation, Inc.
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.
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.
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/>.
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}
23 # usage: cd to the output directory, and invoke ../src/CHK_LIBC_OBJ
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}
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
48 done
49 return ${res}
52 STATUS=0
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"
63 if [ ${STATUS} -eq 0 ]; then
64 STATUS=${res}
66 done
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"
77 if [ ${STATUS} -eq 0 ]; then
78 STATUS=${res}
80 done
82 exit $STATUS