#!/bin/sh12#3# Copyright (C) 2007 Alexander Leidinger <[email protected]>.4# All rights reserved.5#6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions8# are met:9# 1. Redistributions of source code must retain the above copyright10# notice, this list of conditions and the following disclaimer.11# 2. Redistributions in binary form must reproduce the above copyright12# notice, this list of conditions and the following disclaimer in the13# documentation and/or other materials provided with the distribution.14#15# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25# SUCH DAMAGE.26#2728#29# The purpose of this script is to find as much dependencies of a binary30# as possible. A dependecy is for example a library which is directly31# referenced in the binary.32#3334# XXX: it doesn't handle calls to dlopen() or the corresponding libltdl35# function. I don't know if this is needed to detect references to stuff36# which can be added as LIB_DEPENDS.3738if [ -z "$1" ]; then39echo "Usage: $0 binary_file ..."40exit 241fi4243for i in "$@"; do44kind=$(file -bi "$i")4546case "${kind}" in47application/x-executable*|application/x-sharedlib*)48# ok, fall through49;;50*)51# not ok, go to next one52shift53continue54;;55esac5657objdump -x "$i" | awk '/NEEDED/ {print $2}'58shift59done | sort -u606162