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] list of libraries within binaries [2] (for sale or rent!)
Date: Sat, 15 Oct 2005 22:39:32 -0000
Message-ID: <20051015223926.GH7934@solemn.turbinal.org> (raw)


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

On Sat, Oct 08, 2005 at 04:00:26PM +0400, Alexey Tourbin wrote:
> Теперь ничего не стоит получить список бинарей, которые подозреваются
> в том, что статически слинкованы с библиотеками.
> 
> $ cut -f2,4 product |sort |uniq -cd >suspect
> $ du -hs suspect
> 816K    suspect
> $ head suspect
>      51 /lib/libaal-1.0.so.5.0.0        /lib/libaal-minimal.so.0.0.0
>       2 /lib/libaal-1.0.so.5.0.0        /usr/lib/libgift.so.0.0.0
>       2 /lib/libaal-1.0.so.5.0.0        /usr/lib/libmpfc-1.3.5.so
>      51 /lib/libaal-minimal.so.0.0.0    /lib/libaal-1.0.so.5.0.0
>       4 /lib/libanl-2.3.5.so    /usr/lib/debug/libanl-2.3.5.so
>      12 /lib/libattr.so.1.1.0   /lib/libc-2.3.5.so
>      12 /lib/libattr.so.1.1.0   /usr/lib/debug/libc-2.3.5.so
>       2 /lib/libattr.so.1.1.0   /usr/lib/libncurses.so.5.4
>      24 /lib/libbz2.so.1.0.3    /usr/lib/R/bin/R.bin
>      24 /lib/libbz2.so.1.0.3    /usr/lib/R/bin/libR.so
> $
> 
> В первой колонке здесь число совпадающих символов, которые предоставляют
> два эти (во второй и тертьей колонке) бинаря.  `uniq -d' исключает
> одиночные случайные совпадения.

Получен полный product (def x def).  Кто в танке, можно смотреть:

/raid/at/qa/qa-robot/dup_elf_symbols
mash:~at/.qa-robot/dup_elf_symbols/product
mash:~at/.qa-robot/dup_elf_symbols/suspect

То есть теперь можно искать совпадения символов между двумя произвольно
взятыми elf'ами (здесь есть много тонкостей, но в целом утверждение
верно).  Большое число совпадающих символов чаще всего означает
дублирование кода.

[-- Attachment #1.2: dup_elf_symbols --]
[-- Type: text/plain, Size: 1109 bytes --]

#!/bin/sh -ef

cd "${workdir:?}"
rpmelfsym -ap >sym
awk -F'\t' '$3~/[DT]/' sym >def
sort -t$'\t' -k4 -o def def
nelf=`sort -u -k2,2 def |wc -l`
cut -f4 def |uniq -cd >freq
awk -v n=$nelf '$1<sqrt(7*n){print$NF}' freq >defsym
sort -o defsym -u defsym
join -t$'\t' -14 -21 -o '1.1 1.2 1.3 1.4' def defsym >xdef

# product ::= pkg1 elf1 pkg2 elf2 symtype symname
join -t$'\t' -j 4 -o '1.1 1.2 1.3 2.1 2.2 2.3 0' xdef xdef |
	awk -F'\t' 'function prio(f) {
			if (f~"^/lib/lib[^/]+[.]so[^/]*$") return 1
			if (f~"^/usr/lib/lib[^/]+[.]so[^/]*$") return 2
			if (f~"^/usr/X11R./lib/lib[^/]+[.]so[^/]*$") return 3
			if (f~"lib/lib[^/]+[.]so[^/]*$") return 4
			if (f~"/lib[^/]+[.]so[^/]*$") return 5
			if (f~"[^/][.]so[^/]*$") return 6
			return 9
		}
		($2<$5 && $3==$6) {
			OFS="\t"
			pd = prio($2)-prio($5)
			if (pd<0 || pd==0 && length($2)<=length($5))
				print $1,$2,$4,$5,$6,$7
			else
				print $4,$5,$1,$2,$6,$7 }' >product

# suspect ::= pkg1 elf1 pkg2 elf2 symtype nsym
cut -f-5 product |sort |uniq -cd |sed 's/^ *\([0-9]\+\) \+\(.\+\)$/\2\t\1/' >suspect
sort -o suspect -u suspect
cat suspect
cd -

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

             reply	other threads:[~2005-10-15 22:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-15 22:39 Alexey Tourbin [this message]
2005-10-16 10:32 ` [devel] " Alexey Tourbin
2005-10-16 11:58   ` Dmitry Marochko
2005-10-18  7:34   ` Denis Ovsienko

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=20051015223926.GH7934@solemn.turbinal.org \
    --to=at@altlinux.ru \
    --cc=devel@altlinux.ru \
    --cc=devel@lists.altlinux.org \
    /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