ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: devel@altlinux.ru
Subject: [devel] verify_elfsym
Date: Wed, 21 Sep 2005 15:17:27 +0400
Message-ID: <20050921111727.GH1848@solemn.turbinal.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 71 bytes --]

Вот упрощенная реализация проверки ELF'ов, как я её себе представляю.

[-- Attachment #1.2: verify_elfsym --]
[-- Type: text/plain, Size: 1313 bytes --]

#!/bin/sh -ef

elf1_undefined_symbols()
{
	local elf="$1" err=
	err="$(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="$1" err=
	err=$(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="$1" symtab="$2" err=
	err=$(elf1_undefined_symbols "$elf") || return 2
	[ -n "$err" ] || return 0
	local rc=0 sym= obj=
	while IFS=$'\t' read -r sym obj; do
		if [ "$obj" != "$elf" ]; then
			echo "Error: $elf: undefined symbol: $sym ($obj)" >&2
			rc=1
		elif ! bloom -e "$sym" "$symtab"; then
			echo "Error: $elf: undefined symbol: $sym" >&2
			rc=1
		fi
	done <<<"$err"
	return $rc
}	

rc=0 symtab="$1"; shift
for elf; do
	type="$(file -b "$elf")"
	if [ -z "${type##*ELF*executable*dynamic*}" ]; then
		elf1_verify_strict "$elf" || rc=1
	elif [ -z "${type##*ELF*shared*}" -a -z "${elf##*/lib/lib*.so*}" ]; then
		elf1_verify_strict "$elf" || rc=1
	elif [ -z "${type##*ELF*dynamic*}" -o -z "${type##*ELF*shared*}" ]; then
		elf1_verify_relaxed "$elf" "$symtab" || rc=1
	fi	
done
exit $rc

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2005-09-21 11:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-21 11:17 Alexey Tourbin [this message]
2005-09-21 12:18 ` [devel] verify_elfsym Alexey Tourbin
2005-09-21 15:05 ` Alexey Tourbin
2005-09-21 16:57   ` Alexey Tourbin
2005-09-21 17:16     ` Dmitry V. Levin
2005-09-21 17:57       ` Alexey Tourbin
2005-09-21 18:06         ` Alexey Tourbin
2005-09-21 20:24         ` Dmitry V. Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050921111727.GH1848@solemn.turbinal.org \
    --to=at@altlinux.ru \
    --cc=devel@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git