4
# Author : Manoj Srivastava ( srivasta@glaurung.internal.golden-gryphon.com )
5
# Created On : Fri Sep 29 15:36:22 2006
6
# Created On Node : glaurung.internal.golden-gryphon.com
7
# Last Modified By : Manoj Srivastava
8
# Last Modified On : Fri Sep 29 22:53:27 2006
9
# Last Machine Used: glaurung.internal.golden-gryphon.com
11
# Status : Unknown, Use with caution!
15
# arch-tag: 8ba11489-77fa-45a0-92c4-9c5b162ee119
17
# This program is free software; you can redistribute it and/or modify
18
# it under the terms of the GNU General Public License as published by
19
# the Free Software Foundation; either version 2 of the License, or
20
# (at your option) any later version.
22
# This program is distributed in the hope that it will be useful,
23
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
# GNU General Public License for more details.
27
# You should have received a copy of the GNU General Public License
28
# along with this program; if not, write to the Free Software
29
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32
# Make sure we abort on error
34
progname="$(basename \"$0\")"
36
trap 'rm -f search_patterns.txt;' ALRM HUP INT PIPE TERM ABRT FPE BUS QUIT SEGV ILL EXIT
38
# Find all undefined symbols in all ELF objects in this tree
39
readelf -s -D -W $(find . -type f -print0 | xargs -0r file | grep " ELF" | \
40
awk '{print $1}' | sed -e 's/:$//') | grep UND | grep -v LOCAL |
41
perl -ple 's/.*\s(\S+)\s*$/\^$1\$/g' | sort -u > search_patterns.txt;
43
# Find all the libraries needed in this tree
44
objdump -T --private-headers $(find . -type f -print0 | xargs -0r file | grep " ELF" | \
45
awk '{print $1}' | sed -e 's/:$//') | grep NEEDED | sort -u | awk '{print $2}' |
47
# For each library, see where it lives o the file system
49
for library_dir in "/lib" "/usr/lib" $EXTRA_LIBRARY_PATHS; do
50
if [ -e "$library_dir/$lib" ]; then
51
LIB="$library_dir/$lib";
55
if [ -z "$LIB" ]; then
56
echo >&2 "Can't find $lib"
59
# If we fond the library, find what symbols it defines, and if these symbols
60
# are some that we need
61
if readelf -s -D -W $LIB | grep -v UND | perl -ple 's/.*\s(\S+)\s*$/$1/g' | \
62
sort -u | grep -q -f search_patterns.txt ; then
63
# Library provides at least some symbols we need
64
if [ -n "$DEBUG" ]; then echo "Found $LIB"; fi
66
# Library does not provide any symbols we need
71
# Get rid of the intermediate file
72
rm -f search_patterns.txt;