Example 3 Using the ldd command

By default, ldd prints simple dynamic path information, including the dependencies recorded in the executable (or the shared library) followed by the physical location where the dynamic loader finds these libraries.

$ ldd a.out

./libx.so => ./libx.so

libc.so.1 => /usr/lib/hpux32/libc.so.1

libdl.so.1 =>

/usr/lib/hpux32/libdl.so.1

The -voption causes ldd to print the dependency relationships along with the dynamic path information.

$ ldd -v a.out

find library=./libx.so; required by a.out

 

./libx.so

=>

./libx.so

find

library=libc.so.1; required by a.out

 

libc.so.1

=>

/usr/lib/hpux32/libc.so.1

find

library=libdl.so.1; required by usr/lib/hpux32/libc.so.1

 

libdl.so.1 =>

/usr/lib/hpux32/libdl.so.1

The -roption to causes it to analyze all symbol references and print information about unsatisfied code and data symbols.

$ldd -r a.out

./libx.sl

=>

./libx.sl

libc.so.1

=>

/usr/lib/hpux32/libc.so.1

libdl.1 =>

/usr/lib/hpux32/libdl.so.1

symbol not

found: val1 (./libx.so)

symbol not

found: count (./libx.so)

symbol

not

found: func1

(./libx.so)

symbol

not

found: func2

(./libx.so)

The -y, <symbol> option can be used to point out the module from which the specified symbol is being resolved. It can also be used to point out modules that refer to the specified symbol.

$ ldd -y,bar a.out

libx.so

=>

 

./libx.so

libc.so.1 =>

/usr/lib/hpux32/libc.so.1

libdl.so.1

=>

/usr/lib/hpux32/libdl.so.1

bar (data)

: needed by

a.out; found in ./libx.so

bar (data)

: needed by

./libx.so; found in ./libx.so

$ ldd -y,foo a.out

 

 

 

libx.so

=>

 

./libx.so

libc.so.1 =>

/usr/lib/hpux32/libc.so.1

libdl.so.1

=>

/usr/lib/hpux32/libdl.so.1

foo (code)

: needed

by a.out; found in ./libx.so

foo (code)

: needed

by ./libx.so; found in ./libx.so

 

 

 

 

 

Listing Dynamic Libraries with pldd(1)

Given a process ID (PID) or a corefile, the pldd command prints a list of shared libraries loaded including those loaded explicitly with dlopen() and shl_load(). The pldd command works by attaching to the process to read its memory. Mismatch between executable and corefile may result in unpredictable behavior. The pldd command searches for the executable file in the current

Listing Dynamic Libraries with pldd(1) 61