Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ldd manpage - example does not work

5 views
Skip to first unread message

Rainer Hurling

unread,
Apr 5, 2010, 2:35:18 PM4/5/10
to freebsd...@freebsd.org
The manpage for ldd(1) gives a nice example of finding binaries, which
link against a given library, see

http://www.freebsd.org/cgi/man.cgi?query=ldd&apropos=0&sektion=0&manpath=FreeBSD+8.0-RELEASE&format=html


The example looks as follows:

find . -type f | xargs -n1 file -F | grep ELF | cut -f1 -d' ' | xargs
ldd -f '%A %o\n' | grep libc.so.6


Unfortunately this example does not work for me. Is seems that the part
with xargs does not output anything and so is the showstopper (?)

It would be nice if someone could give me some advice what is wrong here.

Thanks in advance,
Rainer Hurling

Michael Butler

unread,
Apr 5, 2010, 2:52:02 PM4/5/10
to Garrett Cooper, freebsd...@freebsd.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/05/10 14:40, Garrett Cooper wrote:


> On Mon, Apr 5, 2010 at 11:35 AM, Rainer Hurling <rhu...@gwdg.de> wrote:

>> The example looks as follows:
>>
>> find . -type f | xargs -n1 file -F | grep ELF | cut -f1 -d' ' | xargs ldd -f
>> '%A %o\n' | grep libc.so.6

[ .. snip .. ]

> 1. The file(1) usage looks incorrect (I get a lot of messages like the
> following):
>
> Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator]
> [-m magicfiles] file...
> file -C -m magicfiles
> Try `file --help' for more information.
>
> 2. It's no longer libc.so.6 for many versions of FreeBSD; it can
> potentially be libc.so.7...

Try ..

find . -type f | xargs -n1 file -F ' ' | grep ELF | cut -f1 -d' ' \

| xargs ldd -f '%A %o\n' | grep libc.so.[67]

;-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAku6MVIACgkQQv9rrgRC1JLrXgCZAauZv2h8SrqkKdJNL5Xpv9KN
ml8An20zgpbjrJVZ2XdLc6/HVch69f3w
=sBOs
-----END PGP SIGNATURE-----

Garrett Cooper

unread,
Apr 5, 2010, 2:40:32 PM4/5/10
to Rainer Hurling, freebsd...@freebsd.org
On Mon, Apr 5, 2010 at 11:35 AM, Rainer Hurling <rhu...@gwdg.de> wrote:

1. The file(1) usage looks incorrect (I get a lot of messages like the
following):

Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator]
[-m magicfiles] file...
file -C -m magicfiles
Try `file --help' for more information.

2. It's no longer libc.so.6 for many versions of FreeBSD; it can
potentially be libc.so.7...

HTH,
-Garrett

Rainer Hurling

unread,
Apr 5, 2010, 4:09:28 PM4/5/10
to Michael Butler, Garrett Cooper, freebsd...@freebsd.org
Thank you very much for your answers!

On 05.04.2010 20:52 (UTC+1), Michael Butler wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 04/05/10 14:40, Garrett Cooper wrote:
>> On Mon, Apr 5, 2010 at 11:35 AM, Rainer Hurling<rhu...@gwdg.de> wrote:
>
>>> The example looks as follows:
>>>
>>> find . -type f | xargs -n1 file -F | grep ELF | cut -f1 -d' ' | xargs ldd -f
>>> '%A %o\n' | grep libc.so.6
>
> [ .. snip .. ]
>
>> 1. The file(1) usage looks incorrect (I get a lot of messages like the
>> following):
>>
>> Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator]
>> [-m magicfiles] file...
>> file -C -m magicfiles
>> Try `file --help' for more information.
>>
>> 2. It's no longer libc.so.6 for many versions of FreeBSD; it can
>> potentially be libc.so.7...

I want to create a list of binaries, which are linked against the old
libz.so.5 and must be upgraded ...

find /usr/local/ -type f | xargs -n1 file -F ' ' | grep ELF | cut -f1
-d' ' | xargs ldd -f '%A %o\n' | grep libz.so.5 > ~/libz.so.5.txt

Dominic Fandrey

unread,
Apr 5, 2010, 5:05:44 PM4/5/10
to Rainer Hurling, Garrett Cooper, freebsd...@freebsd.org
On 05/04/2010 22:09, Rainer Hurling wrote:
>> I want to create a list of binaries, which are linked against the old
>> libz.so.5 and must be upgraded ...

Install sysutils/bsdadminscripts and rung pkg_libchk. :)

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Rainer Hurling

unread,
Apr 6, 2010, 2:36:16 AM4/6/10
to Dominic Fandrey, freebsd...@freebsd.org
Am 05.04.2010 23:05 (UTC+1) schrieb Dominic Fandrey:
> On 05/04/2010 22:09, Rainer Hurling wrote:
>>> I want to create a list of binaries, which are linked against the old
>>> libz.so.5 and must be upgraded ...
>
> Install sysutils/bsdadminscripts and rung pkg_libchk. :)
>

Thanks Dominic,

I was not aware of this tool for this purpose :-)

With textproc/opensp installed the script hangs after some time with the
following message:

[..snip..]
ImageMagick-6.5.8.10_1: /usr/local/lib/libMagickWand.so.2 misses libz.so.5
arith: syntax error: ""0" + 1"-1.5.2_1

This behaviour (the last line) is on at least three machines. Do you
have any idea what is going on?

Rainer Hurling

Dominic Fandrey

unread,
Apr 6, 2010, 5:11:53 AM4/6/10
to Rainer Hurling, freebsd...@freebsd.org
On 06/04/2010 08:36, Rainer Hurling wrote:
> Am 05.04.2010 23:05 (UTC+1) schrieb Dominic Fandrey:
>> On 05/04/2010 22:09, Rainer Hurling wrote:
>>>> I want to create a list of binaries, which are linked against the old
>>>> libz.so.5 and must be upgraded ...
>>
>> Install sysutils/bsdadminscripts and rung pkg_libchk. :)
>>
>
> I was not aware of this tool for this purpose :-)

I originally wrote it for the update from 6.x to 7.x, so that I could
find all packages being linked against the compat-ports and avoid
unnecessary builds.

> With textproc/opensp installed the script hangs after some time with the
> following message:

I doubt there is a connection. OpenSP is installed on my system
and it works fine.

> [..snip..]
> ImageMagick-6.5.8.10_1: /usr/local/lib/libMagickWand.so.2 misses libz.so.5
> arith: syntax error: ""0" + 1"-1.5.2_1

The arithmetics happen mostly during locking. I suppose the -1.5.2_1
is a remainder of a status message and not connected to the error.

Does this always occur in the same place? Maybe run the command with
-j1 to gain more predictable output.

Regards

Rainer Hurling

unread,
Apr 6, 2010, 5:32:41 AM4/6/10
to Dominic Fandrey, freebsd...@freebsd.org
Am 06.04.2010 11:11 (UTC+1) schrieb Dominic Fandrey:
> On 06/04/2010 08:36, Rainer Hurling wrote:
>> Am 05.04.2010 23:05 (UTC+1) schrieb Dominic Fandrey:
>>> On 05/04/2010 22:09, Rainer Hurling wrote:
>>>>> I want to create a list of binaries, which are linked against the old
>>>>> libz.so.5 and must be upgraded ...
>>>
>>> Install sysutils/bsdadminscripts and rung pkg_libchk. :)
>>>
>>
>> I was not aware of this tool for this purpose :-)
>
> I originally wrote it for the update from 6.x to 7.x, so that I could
> find all packages being linked against the compat-ports and avoid
> unnecessary builds.
>
>> With textproc/opensp installed the script hangs after some time with the
>> following message:
>
> I doubt there is a connection. OpenSP is installed on my system
> and it works fine.

I think you are right ;-)

>> [..snip..]
>> ImageMagick-6.5.8.10_1: /usr/local/lib/libMagickWand.so.2 misses libz.so.5
>> arith: syntax error: ""0" + 1"-1.5.2_1
>
> The arithmetics happen mostly during locking. I suppose the -1.5.2_1
> is a remainder of a status message and not connected to the error.
>
> Does this always occur in the same place? Maybe run the command with
> -j1 to gain more predictable output.

The next try with -j1:

#pkg_libchk -j1
arith: syntax error: ""0" + 1"-2.14.17

No other output for the last 30 minutes. The only package installed with
this version number is ORBit2.

My systems are running under recent 9.0-CURRENT (amd64).

Dominic Fandrey

unread,
Apr 6, 2010, 5:57:14 AM4/6/10
to Rainer Hurling, jil...@freebsd.org, freebsd...@freebsd.org
On 06/04/2010 11:53, Rainer Hurling wrote:
> Am 06.04.2010 11:46 (UTC+1) schrieb Dominic Fandrey:
>> Now, this is a real clue. The svn log states several changes to
>> arithmetic expansion.
>>
>> I'm CC'ing this to the author of said changes. I suspect the
>> following function. I wonder, is this a regression or a bug
>> in my code?
>>
>> #
>> # This function frees a semaphore.
>> #
>> # @param $1
>> # The name of the semaphore.
>> #
>> semaphoreFree() {
>> local lock
>> lock="$sharedprefix-semaphore-$1"
>> lockf -k "$lock" sh -c "
>> state=\"\$((\"\$(cat '$lock')\" + 1))\"
>> echo \"\$state\"> '$lock'
>> "
>> }
>>
>>
>> Would you please change the line:
>> state=\"\$((\"\$(cat '$lock')\" + 1))\"
>> to
>> state=\"\$((\$(cat '$lock') + 1))\"
>> and test whether that fixes the issue?
>
> Seems to work this way :-)

Thanks a lot, I'll wait for Jilles reaction and decide whether
I have to push out a maintenance release.

0 new messages