#!/bin/bash # pulled right out of mkinitrd.... DSO_DEPS="" LDSO="" get_dso_deps() { root="$1" ; shift bin="$1" ; shift DSO_DEPS="" declare -a FILES declare -a NAMES # this is a hack, but the only better way requires binutils or elfutils # be installed. i.e., we need readelf to find the interpretter. if [ -z "$LDSO" ]; then for ldso in $root/$LIBDIR/ld*.so* ; do [ -L $ldso ] && continue [ -x $ldso ] || continue $ldso --verify $bin >/dev/null 2>&1 || continue LDSO=$(echo $ldso |sed -e "s,$root,,") done fi # I still hate shell. declare -i n=0 while read NAME I0 FILE ADDR I1 ; do [ "$FILE" == "not" ] && FILE="$FILE $ADDR" NAMES[$n]="$NAME" FILES[$n]="$FILE" let n++ done << EOF $(/usr/sbin/chroot $root env LD_TRACE_PRELINKING=1 LD_WARN= \ LD_TRACE_LOADED_OBJECTS=1 $LDSO $bin) EOF [ ${#FILES[*]} -eq 0 ] && return 1 # we don't want the name of the binary in the list if [ "${FILES[0]}" == "$bin" ]; then FILES[0]="" NAMES[0]="" [ ${#FILES[*]} -eq 1 ] && return 1 fi declare -i n=0 while [ $n -lt ${#FILES[*]} ]; do FILE="${FILES[$n]}" if [ "$FILE" == "not found" ]; then cat 1>&2 <