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