# are searched for, but with -a option, all syms, both defined and
# undefined are searched.
#
-# First, it tries with nm(1), and if that gets nowhere (like in the
-# case of stripped libraries), fall back on objdump(1).
+# Uses objdump(1).
## Code:
ourname=${0##*/}
# Library directories.
# These are the directories we search. If you have other lib directories
# such as /usr/local/lib, /opt/lib, add them here.
-lib_dirs=(/usr/lib /usr/X11/lib /lib)
+lib_dirs=(/usr/lib /usr/X11R6/lib /lib)
+
+# bastard library directories...
+#lib_dirs=(/usr/lib /usr/X11R6/lib /lib /opt/qt/lib)
if [ "$1" = "-a" ]; then
- nm_opts="--demangle=gnu-v3 --debug-syms"
+ obj_opts="--demangle=gnu-v3 --reloc --syms --debugging"
+ want_all=1
shift
else
- nm_opts="--demangle=gnu-v3 --defined-only --dynamic"
+ obj_opts="--demangle=gnu-v3 --reloc --syms"
+ want_all=0
fi
-obj_opts="--demangle=gnu-v3 --reloc --dynamic-reloc --syms --dynamic-syms"
+
# $1 should now be the symbol (or symbol regexp) to search for
sym=${1}
-all_libs=$(find -H -L ${lib_dirs[*]} -type f \( -name "lib*.so" -o -name "lib*.a" \) -print)
+all_libs=$(find ${lib_dirs[*]} -name lost+found -prune -o \( -name lib\*.so\* -o -name lib\*.a \) -print)
for lib in ${all_libs} ; do
- unset good_file lib_syms
- good_file="$(file ${lib}|grep \(\(shared object\)\|\(ar archive\)\) 2>/dev/null)"
+ unset good_file
+ good_file="$(file ${lib}|grep '\(shared object\|ar archive\)' 2>/dev/null)"
if [ -n "${good_file}" ]; then
- lib_syms=$(nm ${nm_opts} ${lib} 2>/dev/null)
- if [ -n "${lib_syms}" ]; then
- echo ${lib_syms}|grep -E ${sym} 1>/dev/null && echo ${lib}
+ if [ $want_all -eq 1 ]; then
+ objdump ${obj_opts} ${lib}|grep -q -E ${sym} && echo ${lib}
else
- objdump ${obj_opts} ${lib} 2>/dev/null |
- grep -E ${sym} 1>/dev/null &&
- echo ${lib}
+ objdump ${obj_opts} ${lib}|grep -v UND|grep -q -E ${sym} && echo ${lib}
fi
fi
done