ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] rpmelfsym
@ 2005-09-13 11:31 Alexey Tourbin
  2005-09-13 14:37 ` Dmitry V. Levin
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Tourbin @ 2005-09-13 11:31 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 3229 bytes --]

Хочется сделать полный дамп символов всех ELF'ов в сизифе.
ELF'ы отсеиваются так:

	rpmfile "$rpm" >files
        awk -F'\t' '$3~/ELF.*(dynamic|shared)/{print$1}' files >elfs

Не ясно, какой формат для дампа символов выбрать.
Сделал на основе nm -D:

	while read elf; do
		nm -D d/"$elf" >d/.nm
		awk -v f="$elf" '{OFS="\t"}NF==2{print f,0,$1,$2}NF==3{print f,1,$2,$3}' d/.nm
	done <elfs

Получается вот что:

$ rpmelfsym ~/RPM/RPMS/perl-base-5.8.7-alt1.i686.rpm |head
/usr/bin/perl5.8.7      0       U       PL_do_undump
/usr/bin/perl5.8.7      0       U       PL_op_mutex
/usr/bin/perl5.8.7      0       U       PL_sigfpe_saved
/usr/bin/perl5.8.7      0       U       PL_use_safe_putenv
/usr/bin/perl5.8.7      0       U       Perl_atfork_lock
/usr/bin/perl5.8.7      0       U       Perl_atfork_unlock
/usr/bin/perl5.8.7      0       U       Perl_croak_nocontext
/usr/bin/perl5.8.7      0       U       Perl_newXS
/usr/bin/perl5.8.7      1       A       _DYNAMIC
/usr/bin/perl5.8.7      1       R       _IO_stdin_used
$ rpmelfsym ~/RPM/RPMS/perl-base-5.8.7-alt1.i686.rpm |sort -u -k1,1
/usr/bin/perl5.8.7      0       U       PL_do_undump
/usr/lib/libperl.so.5.8.7       1       A       DynaLoader
/usr/lib/perl5/i386-linux/auto/B/B.so   0       U       PL_op_desc
/usr/lib/perl5/i386-linux/auto/Cwd/Cwd.so       0       U       Perl_Gthr_key_ptr
/usr/lib/perl5/i386-linux/auto/Data/Dumper/Dumper.so    0       U       PL_utf8skip
/usr/lib/perl5/i386-linux/auto/Digest/MD5/MD5.so        0       U       Perl_Idowarn_ptr
/usr/lib/perl5/i386-linux/auto/Fcntl/Fcntl.so   0       U       Perl_Isv_undef_ptr
/usr/lib/perl5/i386-linux/auto/File/Glob/Glob.so        0       U       PL_memory_wrap
/usr/lib/perl5/i386-linux/auto/I18N/Langinfo/Langinfo.so        0       U       Perl_Gthr_key_ptr
/usr/lib/perl5/i386-linux/auto/IO/IO.so 0       U       PerlIO_getpos
/usr/lib/perl5/i386-linux/auto/IPC/SysV/SysV.so 0       U       Perl_Gthr_key_ptr
/usr/lib/perl5/i386-linux/auto/List/Util/Util.so        0       U       PL_ppaddr
/usr/lib/perl5/i386-linux/auto/MIME/Base64/Base64.so    0       U       Perl_Idowarn_ptr
/usr/lib/perl5/i386-linux/auto/Opcode/Opcode.so 0       U       Perl_Idefgv_ptr
/usr/lib/perl5/i386-linux/auto/POSIX/POSIX.so   0       U       PL_sig_name
/usr/lib/perl5/i386-linux/auto/Socket/Socket.so 0       U       Perl_Ireentrant_buffer_ptr
/usr/lib/perl5/i386-linux/auto/Sys/Hostname/Hostname.so 0       U       Perl_Gthr_key_ptr
/usr/lib/perl5/i386-linux/auto/Sys/Syslog/Syslog.so     0       U       Perl_Gthr_key_ptr
/usr/lib/perl5/i386-linux/auto/Time/HiRes/HiRes.so      0       U       Perl_Imodglobal_ptr
/usr/lib/perl5/i386-linux/auto/attrs/attrs.so   0       U       Perl_Icompcv_ptr
$ rpmelfsym ~/RPM/RPMS/perl-base-5.8.7-alt1.i686.rpm |wc -lc
   3639  195178
$

Нутром чую проблему:  дамп получится большой.  С гигабайт.  Может быть,
некоторые символы не нужны?  Интересуют только символы, связанные с
разделяемыми библиотеками.  То есть либо бинарь требует символ в
разделяемой библиотеке (это вроде U), либо библиотека предоставляет это
символ -- это будет T для функции и B/D для глобальной переменной.

...

Есть какие-нибудь идеи?

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

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

* Re: [devel] rpmelfsym
  2005-09-13 11:31 [devel] rpmelfsym Alexey Tourbin
@ 2005-09-13 14:37 ` Dmitry V. Levin
  2005-09-13 15:49   ` [devel] rpmelfsym Alexey Tourbin
  2005-09-13 16:09   ` [devel] lorder Alexey Tourbin
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry V. Levin @ 2005-09-13 14:37 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

On Tue, Sep 13, 2005 at 03:31:58PM +0400, Alexey Tourbin wrote:
[...]
> Нутром чую проблему:  дамп получится большой.  С гигабайт.  Может быть,
> некоторые символы не нужны?  Интересуют только символы, связанные с
> разделяемыми библиотеками.  То есть либо бинарь требует символ в
> разделяемой библиотеке (это вроде U), либо библиотека предоставляет это
> символ -- это будет T для функции и B/D для глобальной переменной.
> 
> ...
> 
> Есть какие-нибудь идеи?

См. postfix-lorder.sh в postfix-*.src.rpm


-- 
ldv

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

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

* [devel] Re: rpmelfsym
  2005-09-13 14:37 ` Dmitry V. Levin
@ 2005-09-13 15:49   ` Alexey Tourbin
  2005-09-13 16:09   ` [devel] lorder Alexey Tourbin
  1 sibling, 0 replies; 5+ messages in thread
From: Alexey Tourbin @ 2005-09-13 15:49 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]

On Tue, Sep 13, 2005 at 06:37:45PM +0400, Dmitry V. Levin wrote:
> > Есть какие-нибудь идеи?
> См. postfix-lorder.sh в postfix-*.src.rpm

Спасибо.  Там `nm -g' используется, он для dynamic/shared ничего не
показывает.  Это вроде как только для *.a архивов.  На всякий случай,
какие символы бывают:

$ find /bin /usr/bin /lib /usr/lib -type f -maxdepth 1 |file -f - |awk -F': +' '$2~/ELF.*(dynamic|shared)/{print$1}' |xargs nm -D |awk 'NF>1{print NF-1,$(NF-1)}' |sort |uniq -c |sort -n
     25 2 a
     54 1 v
   5864 1 w
   6488 2 R
   9310 2 A
  24821 2 D
  27751 2 B
  38616 2 V
  65737 2 W
 236795 1 U
 359673 2 T
$

Там используется [TDGR] для "globally defined symbols".  Как видим,
G у нас вообще нет, а вот B (BSS -- глобальные переменные без
инициализаторов, которые инициализируются нулями при загрузке) очень
даже есть.  

А также видно, что на "левых" символах сэкономить не удастся, потому
T и U в сумме (как и по отдельности) далеко оставляют позади всё остальное.

Зато "буквы" не "пересекаются" по наличию или отсутствию адреса.
То есть отдельное поле в дампе для "есть адрес/нет адреса" не нужно.
Наверное, это банальная истина, но вот я её с понтом проверил.

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

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

* [devel] lorder
  2005-09-13 14:37 ` Dmitry V. Levin
  2005-09-13 15:49   ` [devel] rpmelfsym Alexey Tourbin
@ 2005-09-13 16:09   ` Alexey Tourbin
  2005-09-13 16:38     ` Dmitry V. Levin
  1 sibling, 1 reply; 5+ messages in thread
From: Alexey Tourbin @ 2005-09-13 16:09 UTC (permalink / raw)
  To: ALT Devel discussion list


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

On Tue, Sep 13, 2005 at 06:37:45PM +0400, Dmitry V. Levin wrote:
> См. postfix-lorder.sh в postfix-*.src.rpm

Кстати, в старых юниксах есть такая штатная "бня".

$ find ~/v7 -name '*lorder*'
/home/at/v7/bin/lorder
/home/at/v7/usr/man/man1/lorder.1
$ file /home/at/v7/bin/lorder		-- СЮРПРЫЗ!!
/home/at/v7/bin/lorder: ASCII C++ program text
$ man /home/at/v7/bin/lorder |col -b
LORDER(1)                                                            LORDER(1)

NAME
       lorder - find ordering relation for an object library

SYNOPSIS
       lorder file ...

DESCRIPTION
       The  input  is one or more object or library archive (see ar(1)) files.
       The standard output is a list of pairs of object  file  names,  meaning
       that  the first file of the pair refers to external identifiers defined
       in the second.  The output may be processed  by  tsort(1)  to  find  an
       ordering of a library suitable for one-pass access by ld(1).

       This  brash one-liner intends to build a new library from existing `.o'
       files.

              ar cr library `lorder *.o | tsort`

FILES
       *symref, *symdef
       nm(1), sed(1), sort(1), join(1)

SEE ALSO
       tsort(1), ld(1), ar(1)

BUGS
       The names of object files, in and out of libraries, must end with `.o';
       nonsense results otherwise.
$

[-- Attachment #1.2: lorder --]
[-- Type: text/plain, Size: 400 bytes --]

trap "rm -f $$sym?ef; exit" 0 1 2 13 15
case $# in
0)	echo usage: lorder file ...
	exit ;;
1)	case $1 in
	*.o)	set $1 $1
	esac
esac
nm -g $* | sed '
	/^$/d
	/:$/{
		/\.o:/!d
		s/://
		h
		s/.*/& &/
		p
		d
	}
	/[TD] /{
		s/.* //
		G
		s/\n/ /
		w '$$symdef'
		d
	}
	s/.* //
	G
	s/\n/ /
	w '$$symref'
	d
'
sort $$symdef -o $$symdef
sort $$symref -o $$symref
join $$symref $$symdef | sed 's/[^ ]* *//'

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

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

* Re: [devel] lorder
  2005-09-13 16:09   ` [devel] lorder Alexey Tourbin
@ 2005-09-13 16:38     ` Dmitry V. Levin
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry V. Levin @ 2005-09-13 16:38 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

On Tue, Sep 13, 2005 at 08:09:33PM +0400, Alexey Tourbin wrote:
> On Tue, Sep 13, 2005 at 06:37:45PM +0400, Dmitry V. Levin wrote:
> > См. postfix-lorder.sh в postfix-*.src.rpm
> 
> Кстати, в старых юниксах есть такая штатная "бня".

У нас тоже есть, в пакете pmake.
Только в postfix'е он свежее, а обновить pmake всё некогда.


-- 
ldv

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

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

end of thread, other threads:[~2005-09-13 16:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-13 11:31 [devel] rpmelfsym Alexey Tourbin
2005-09-13 14:37 ` Dmitry V. Levin
2005-09-13 15:49   ` [devel] rpmelfsym Alexey Tourbin
2005-09-13 16:09   ` [devel] lorder Alexey Tourbin
2005-09-13 16:38     ` 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