ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: ALT Devel discussion list <devel@altlinux.ru>
Subject: [devel] Re: q: _perl_vendor_check_dso problems
Date: Mon, 26 Sep 2005 18:41:41 +0400
Message-ID: <20050926144140.GC3650@solemn.turbinal.org> (raw)
In-Reply-To: <20050926141328.GB11525@basalt.office.altlinux.org>


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

On Mon, Sep 26, 2005 at 06:13:28PM +0400, Dmitry V. Levin wrote:
> $ ldd -r /usr/lib/apache/libhttpd.so 2>&1 |grep -wc undefined
> 50
> 
> Имеет смысл повесить на пакет `rpmquery -f /usr/lib/apache/libhttpd.so`
> багу.
> 
> Моё терпение скоро иссякнет, и rpmbuild начнёт нарушителей давить.

Так как "задавить" /usr/lib/apache/libhttpd.so?  Это же не публичная
библиотека (в частности, её нет в /etc/ld.so.cache).  К libhttpd.so
можно применить только очень слабую проверку.

То есть нужна более сложная модель, в которой можно выдвигать
предположения типа "libhttpd.so ни слинкована с libz.so" и как-нибудь
эти предположения проверять, возможно, методом резолюций.  Но это очень
сложно, я об этом даже думать не могу. :)

PS: вот на чем остановилось verify_elfsym.  Осталось сделать две вещи:
1) Вместо "${elf##*/lib/lib*.so*}" написать предикат elf1_is_public_library
2) Подумать, как в brp-alt "протащить" полный список предоставляемых
символов на всём репозитарии; вместо полного списка (60M) можно сделать
bloom filter (2M), но проблема по существу остается.

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

#!/bin/sh -ef

. /usr/lib/rpm/functions
[ -z "$RPM_BUILD_ROOT" ] || ValidateBuildRoot

RTLD=/lib/ld-linux.so.2
RTLD_libpath=/lib:/usr/lib:/usr/X11R6/lib

elf1_libpath()
{
	local elf="$1" libpath="$RTLD_libpath"
	[ -z "$LD_LIBRARY_PATH" ] ||
		libpath="$LD_LIBRARY_PATH:$libpath"
	[ -z "$RPM_FINDPROV_LIB_PATH" ] ||
		libpath="$RPM_FINDPROV_LIB_PATH:$libpath"
	local info= rpath=
	info="$(objdump -p "$elf")" || return
	rpath="$(echo "$info" |awk '($1=="RPATH"){printf "%s:", $2}')"
	[ -z "$rpath" ] ||
		libpath="$rpath$libpath"
	if [ -n "$RPM_BUILD_ROOT" ]; then
		local BR_libpath= path= IFS=:
		for path in $libpath; do
			BR_libpath="$BR_libpath:$RPM_BUILD_ROOT$path"
		done
		libpath="${BR_libpath#:}:$libpath"
	fi
	echo "$libpath"
}

elf1_ldd()
{
	local elf="$1" libpath=
	libpath="$(elf1_libpath "$elf")" || return
	LD_TRACE_LOADED_OBJECTS=1 LD_WARN=1 LD_BIND_NOW=1 LD_VERBOSE= \
		"$RTLD" --library-path "$libpath" --inhibit-rpath "$elf" "$elf"
}

elf1_undefined_symbols()
{
	local elf="$1" out=
	if ! out="$(elf1_ldd "$elf" 2>&1)"; then
		echo "$PROG: $elf: ldd failed:" >&2
		echo "$out" >&2
		return 2
	fi
	if [ -n "$out" -a -z "${out##* not found*}" ]; then
		echo "$PROG: $elf: unresolved dependencies:" >&2
		echo "$out" |grep -F ' not found' >&2
		return 1
	fi
	if [ -n "$out" -a -z "${out##*undefined symbol:*}" ]; then
		echo "$out" |awk '/^undefined symbol:/ {
			gsub("^[(]|[)]$", "", $NF)
			print $3 "\t" $NF }'
	fi
}

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

: ${VERIFY_ELF_SYM:=normal}
case "$VERIFY_ELF_SYM" in
	strict|normal|relaxed) : ;;
	no|none|skip) exit 0 ;;
	*) Fatal "Unrecognized $PROG method: $VERIFY_ELF_SYM" ;;
esac

rc=0 symtab="$1"
shift

for elf; do
	if ! type="$(file -bL "$elf")"; then
		echo "$PROG: $elf: $type" >&2
		rc=1
		continue
	fi
		
	[ -n "$type" ] || continue
	[ -z "${type##*ELF*dynamic*}" -o -z "${type##*ELF*shared*}" ] || continue

	if [ "$VERIFY_ELF_SYM" = strict ]; then
		elf1_verify_strict "$elf" || rc=1
	elif [ "$VERIFY_ELF_SYM" = relaxed ]; then
		elf1_verify_relaxed "$elf" "$symtab" || rc=1
	elif [ -z "${type##*ELF*executable*}" ]; 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
	else
		elf1_verify_relaxed "$elf" "$symtab" || rc=1
	fi	
done
exit $rc

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

  parent reply	other threads:[~2005-09-26 14:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-26 12:52 [devel] " Vladimir Lettiev
2005-09-26 13:01 ` [devel] " Alexey Tourbin
2005-09-26 13:23   ` Vladimir Lettiev
2005-09-26 13:57     ` Alexey Tourbin
2005-09-26 14:09       ` Alexey I.Froloff
2005-09-26 14:13       ` Dmitry V. Levin
2005-09-26 14:24         ` Michael Shigorin
2005-09-26 14:25         ` Alexey I.Froloff
2005-09-26 14:49           ` Alexey Tourbin
2005-09-26 21:39           ` Igor Zubkov
2005-09-26 14:41         ` Alexey Tourbin [this message]
2005-09-26 15:26           ` [devel] verify-elf Dmitry V. Levin
2005-09-26 16:05             ` [devel] verify-elf Alexey Tourbin
2005-09-26 16:57               ` Dmitry V. Levin
2005-09-26 17:56       ` [devel] Re: q: _perl_vendor_check_dso problems Konstantin A.Lepikhov

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=20050926144140.GC3650@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