#!/bin/sh - # # lsisl -- Locate Symbols In Shared Libraries # # Written for FreeBSD 6, probably won't work elsewhere. # Usage: lsisl [...] # # Copyright (C) 2006 Oliver Fromme # All rights reserved. Standard 2-clause BSD license and disclaimer applies. # if [ $# -lt 1 -o -z "$1" -o "x$1" != "x${1#-}" ]; then echo "Usage: ${0##*/} [...]" >&2 echo "Locates the shared libraries that contain the given symbols." >&2 exit 1 fi LIBDIRS=$(/sbin/ldconfig -r | sed -n 's/:/ /g;/earch director/s+^[^/]*/+/+p') SYMBOLS="$*" export SYMBOLS for DIR in $LIBDIRS; do if [ -d "$DIR" ]; then echo "$DIR" fi done | xargs -J% find % -depth 1 -type f -name "*.so.*" | sort | xargs nm -D | awk ' BEGIN { split(ENVIRON["SYMBOLS"], a) for (i in a) symbols[a[i]] = 1 } { if (NF == 1) { currlib = $1 sub(/:$/, "", currlib) } else if ($1 ~ /^[0-9a-f]/ && $3 in symbols) if (libs[$3]) libs[$3] = libs[$3] " " currlib else libs[$3] = currlib } END { for (sym in libs) printf "%-23s\t%s\n", sym, libs[sym] } ' | sort #--