From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 21 Sep 2005 15:17:27 +0400 From: Alexey Tourbin To: devel@altlinux.ru Message-ID: <20050921111727.GH1848@solemn.turbinal.org> Mail-Followup-To: devel@altlinux.ru Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZY5CS28jBCfb727c" Content-Disposition: inline Subject: [devel] verify_elfsym X-BeenThere: devel@altlinux.ru X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ALT Devel discussion list List-Id: ALT Devel discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2005 11:18:37 -0000 Archived-At: List-Archive: List-Post: --ZY5CS28jBCfb727c Content-Type: multipart/mixed; boundary="uAgJxtfIS94j9H4T" Content-Disposition: inline --uAgJxtfIS94j9H4T Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =F7=CF=D4 =D5=D0=D2=CF=DD=C5=CE=CE=C1=D1 =D2=C5=C1=CC=C9=DA=C1=C3=C9=D1 =D0= =D2=CF=D7=C5=D2=CB=C9 ELF'=CF=D7, =CB=C1=CB =D1 =C5=A3 =D3=C5=C2=C5 =D0=D2= =C5=C4=D3=D4=C1=D7=CC=D1=C0. --uAgJxtfIS94j9H4T Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=verify_elfsym Content-Transfer-Encoding: quoted-printable #!/bin/sh -ef elf1_undefined_symbols() { local elf=3D"$1" err=3D err=3D"$(ldd -r "$elf" 2>&1 1>/dev/null)" || return [ -n "$err" ] || return 0 echo "$err" |awk '/^undefined symbol:/ { gsub("^[(]|[)]$", "", $NF) print $3 "\t" $NF }' } elf1_verify_strict() { local elf=3D"$1" err=3D err=3D$(elf1_undefined_symbols "$elf") || return 2 [ -n "$err" ] || return 0 echo "Error: $elf: undefined symbols" >&2 echo "$err" >&2 return 1 } elf1_verify_relaxed() { local elf=3D"$1" symtab=3D"$2" err=3D err=3D$(elf1_undefined_symbols "$elf") || return 2 [ -n "$err" ] || return 0 local rc=3D0 sym=3D obj=3D while IFS=3D$'\t' read -r sym obj; do if [ "$obj" !=3D "$elf" ]; then echo "Error: $elf: undefined symbol: $sym ($obj)" >&2 rc=3D1 elif ! bloom -e "$sym" "$symtab"; then echo "Error: $elf: undefined symbol: $sym" >&2 rc=3D1 fi done <<<"$err" return $rc }=09 rc=3D0 symtab=3D"$1"; shift for elf; do type=3D"$(file -b "$elf")" if [ -z "${type##*ELF*executable*dynamic*}" ]; then elf1_verify_strict "$elf" || rc=3D1 elif [ -z "${type##*ELF*shared*}" -a -z "${elf##*/lib/lib*.so*}" ]; then elf1_verify_strict "$elf" || rc=3D1 elif [ -z "${type##*ELF*dynamic*}" -o -z "${type##*ELF*shared*}" ]; then elf1_verify_relaxed "$elf" "$symtab" || rc=3D1 fi=09 done exit $rc --uAgJxtfIS94j9H4T-- --ZY5CS28jBCfb727c Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFDMUFHfBKgtDjnu0YRAgWPAJ0bne4+e/qZgyN/uH7ypHj61RbtsgCgiE0q Qu9iMsdnsu5u4686VuNtcAE= =6t4l -----END PGP SIGNATURE----- --ZY5CS28jBCfb727c--