ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] verify_elfsym
@ 2005-09-21 11:17 Alexey Tourbin
  2005-09-21 12:18 ` [devel] verify_elfsym Alexey Tourbin
  2005-09-21 15:05 ` Alexey Tourbin
  0 siblings, 2 replies; 8+ messages in thread
From: Alexey Tourbin @ 2005-09-21 11:17 UTC (permalink / raw)
  To: devel


[-- 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 --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-21 20:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-21 11:17 [devel] verify_elfsym Alexey Tourbin
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

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