2 ##############################################################################
3 # Copyright (c) 2003-2006,2010 Free Software Foundation, Inc. #
5 # Permission is hereby granted, free of charge, to any person obtaining a #
6 # copy of this software and associated documentation files (the "Software"), #
7 # to deal in the Software without restriction, including without limitation #
8 # the rights to use, copy, modify, merge, publish, distribute, distribute #
9 # with modifications, sublicense, and/or sell copies of the Software, and to #
10 # permit persons to whom the Software is furnished to do so, subject to the #
11 # following conditions: #
13 # The above copyright notice and this permission notice shall be included in #
14 # all copies or substantial portions of the Software. #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
19 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
22 # DEALINGS IN THE SOFTWARE. #
24 # Except as contained in this notice, the name(s) of the above copyright #
25 # holders shall not be used in advertising or otherwise to promote the sale, #
26 # use or other dealings in this Software without prior written #
28 ##############################################################################
29 # $Id: listused.sh,v 1.8 2010/09/18 15:15:15 tom Exp $
30 # A very simple script to list all entrypoints that are used by either a test
31 # program, or within the libraries. This relies on the output format of 'nm',
32 # and assumes that the libraries are configured with TRACE defined, and using
37 # Static libraries are used, to provide some filtering based on internal usage
38 # of the different symbols.
40 # keep the sorting independent of locale:
41 if test "${LANGUAGE+set}" = set; then LANGUAGE
=C
; export LANGUAGE
; fi
42 if test "${LANG+set}" = set; then LANG
=C
; export LANG
; fi
43 if test "${LC_ALL+set}" = set; then LC_ALL
=C
; export LC_ALL
; fi
44 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES
=C
; export LC_MESSAGES
; fi
45 if test "${LC_CTYPE+set}" = set; then LC_CTYPE
=C
; export LC_CTYPE
; fi
46 if test "${LC_COLLATE+set}" = set; then LC_COLLATE
=C
; export LC_COLLATE
; fi
50 if test ! -d ..
/objects
; then
51 echo "? need objects to run this script"
53 elif test ! -d ..
/lib
; then
54 echo "? need libraries to run this script"
59 for name
in `(echo "test:";sort modules; echo "progs:";sort ../progs/modules) |sed -e 's/[ ].*//' -e '/^[#@]/d'`
66 NAME
=..
/objects
/${name}.o
78 LIB
=`basename $lib .a`
85 tmp
=`echo $LIB|sed -e 's/w$//'`
88 echo $tmp |
sed -e 's/./-/g'
89 # Construct a list of public externals provided by the library.
90 WANT
=`nm $NM_OPTS $lib |\
100 # List programs which use that external.
113 TEST
=`nm $NM_OPTS $prog |\
114 sed -e 's/^[^ ]*//' \
121 -e 's/^'${name}'$/_/' \
125 have
=`basename $prog .o`
128 if test "$last" = "$tags"
132 HAVE
="$HAVE $tags $have"
142 # if we did not find a program using it directly, see if it
143 # is used within a library.
146 for tmp
in ..
/lib
/*.a
153 TEST
=`nm $NM_OPTS $tmp |\
154 sed -e 's/^[^ ]*//' \
162 -e 's/^'${name}'$/_/' \
166 tmp
=`basename $tmp .a |sed -e 's/w$//'`
167 HAVE
=`echo $tmp | sed -e 's/lib/lib: /'`
172 test -z "$HAVE" && HAVE
="-"
173 lenn
=`expr 39 - length $name`
174 lenn
=`expr $lenn / 8`
176 while test $lenn != 0
179 lenn
=`expr $lenn - 1`
181 echo "${name}${tabs}${HAVE}"