Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Re: Which libraries are linked in?
  1998-06-09  4:00 Which libraries are linked in? Asgar Ali
  1998-06-09  4:00 ` Thomas Riechen
@ 1998-06-09  4:00 ` Eric Dumazet
  1998-06-09  4:00 ` Jarkko Hietaniemi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 1998-06-09  4:00 UTC (permalink / raw)



Hi Asgar,

There is no easy way to do that.

I use 2 methods :

1) odump

$ odump -Dl /path_to_exe

This one gives the names of the .so, not the real path used by the
loader at exec time. But it works even if a .so is not found.

2) Traces on /sbin/loader
$ _RLD_ARGS=-v /path_to_exe <some option/arg that makes exe exits>

With this your LD_LIBRARY_PATH is taken into account. But the program is
started. You must know how to ask nothing to the program.
You could do : man loader to learn more options on /sbin/loader

Eric Dumazet
Asgar Ali wrote:
> 
> On DEC Unix V4, does anyone know the command that will display a list of
> libraries that an executable would use.
> ie command <exec name>   produces
> /usr/lib/xxx
> /usr/lib/xx
> /usr/directory/libalib.so  etc.



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

* Re: Which libraries are linked in?
  1998-06-09  4:00 Which libraries are linked in? Asgar Ali
@ 1998-06-09  4:00 ` Thomas Riechen
  1998-06-09  4:00 ` Eric Dumazet
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Thomas Riechen @ 1998-06-09  4:00 UTC (permalink / raw)



Asgar Ali wrote:
> 
> On DEC Unix V4, does anyone know the command that will display a list of
> libraries that an executable would use.
> ie command <exec name>   produces
> /usr/lib/xxx
> /usr/lib/xx
> /usr/directory/libalib.so  etc.


You can use 'odump -Dl <exec name>', but you wouldn't see the path.

For more informations use '_RLD_ARGS="-log_stdout -v" <exec name>', but you
would run the command!  See loader(5) for details.


Thomas



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

* Re: Which libraries are linked in?
  1998-06-09  4:00 Which libraries are linked in? Asgar Ali
  1998-06-09  4:00 ` Thomas Riechen
  1998-06-09  4:00 ` Eric Dumazet
@ 1998-06-09  4:00 ` Jarkko Hietaniemi
  1998-06-10  4:00 ` D. Sean Davidson
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Jarkko Hietaniemi @ 1998-06-09  4:00 UTC (permalink / raw)




Asgar Ali <asgar.ali@citicorp.com> writes:

> 
> On DEC Unix V4, does anyone know the command that will display a list of
> libraries that an executable would use. 
> ie command <exec name>   produces
> /usr/lib/xxx
> /usr/lib/xx
> /usr/directory/libalib.so  etc.

odump -Dl execname

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen



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

* Which libraries are linked in?
@ 1998-06-09  4:00 Asgar Ali
  1998-06-09  4:00 ` Thomas Riechen
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Asgar Ali @ 1998-06-09  4:00 UTC (permalink / raw)



On DEC Unix V4, does anyone know the command that will display a list of
libraries that an executable would use. 
ie command <exec name>   produces
/usr/lib/xxx
/usr/lib/xx
/usr/directory/libalib.so  etc.



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

* Re: Which libraries are linked in?
  1998-06-09  4:00 Which libraries are linked in? Asgar Ali
                   ` (3 preceding siblings ...)
  1998-06-10  4:00 ` D. Sean Davidson
@ 1998-06-10  4:00 ` Asgar Ali
  1998-06-12  4:00 ` Thomas Unger
  5 siblings, 0 replies; 8+ messages in thread
From: Asgar Ali @ 1998-06-10  4:00 UTC (permalink / raw)



Cheers Guys..

Both odump, and _RLD_ARGS_= ... worked a treat!

Asgar.



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

* Re: Which libraries are linked in?
  1998-06-09  4:00 Which libraries are linked in? Asgar Ali
                   ` (2 preceding siblings ...)
  1998-06-09  4:00 ` Jarkko Hietaniemi
@ 1998-06-10  4:00 ` D. Sean Davidson
  1998-06-10  4:00 ` Asgar Ali
  1998-06-12  4:00 ` Thomas Unger
  5 siblings, 0 replies; 8+ messages in thread
From: D. Sean Davidson @ 1998-06-10  4:00 UTC (permalink / raw)



Asgar Ali wrote:
> 
> On DEC Unix V4, does anyone know the command that will display a list of
> libraries that an executable would use.
> ie command <exec name>   produces
> /usr/lib/xxx
> /usr/lib/xx
> /usr/directory/libalib.so  etc.

The /usr/bin/odump command will give you the libraries that are linked
against and executable, even other libraries:

% odump -D /usr/bin/X11/xterm | grep 'NEEDED:' | awk '{print $2}'
libXaw.so
libXmu.so
libXt.so
libSM.so
libICE.so
libXext.so
libX11.so
libc.so

also RPATH: will show you the alternate search path for the shared
libraries instead of the default.



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

* Re: Which libraries are linked in?
  1998-06-09  4:00 Which libraries are linked in? Asgar Ali
                   ` (4 preceding siblings ...)
  1998-06-10  4:00 ` Asgar Ali
@ 1998-06-12  4:00 ` Thomas Unger
  1998-06-19  4:00   ` Jeff Donsbach
  5 siblings, 1 reply; 8+ messages in thread
From: Thomas Unger @ 1998-06-12  4:00 UTC (permalink / raw)



Asgar Ali <asgar.ali@citicorp.com> wrote:
: On DEC Unix V4, does anyone know the command that will display a list of
: libraries that an executable would use. 
: ie command <exec name>   produces
: /usr/lib/xxx
: /usr/lib/xx
: /usr/directory/libalib.so  etc.

You can use 'ldd' to do this and more:
(ldd is available at 'http://www.informatik.uni-siegen.de/~unger/ldd'
 and requires ebash and gdb to be installed)




tcsh> ldd -a /usr/local/bin/ALPHA/cp

using </usr/local/bin/ALPHA/cp>, an ALPHA executable
RPATH:     /usr/local/lib/ALPHA


                        ***LIBRARY LIST SECTION***
        Name             Time-Stamp        CheckSum   Flags Version
/usr/local/bin/ALPHA/cp:
        libintl.so   Nov 19 16:58:19 1996 0xac00b749     0 
        libfu.so     Nov 19 16:57:40 1996 0x2133d1f0     0 
        libgcc.so    Nov 19 15:47:29 1996 0x9494d91a     0 
        libc.so      May 20 04:18:46 1996 0xf937323b     0 osf.1
        libgcc.so    Nov 19 15:47:29 1996 0x9494d91a     0 

library locations:
        /usr/local/lib/ALPHA/libintl.so
        /usr/local/lib/ALPHA/libfu.so
        /usr/local/lib/ALPHA/libgcc.so
        /usr/shlib/libc.so

+/usr/local/bin/ALPHA/cp [  <NO DATE STRING> ; <NO VERSION INFO> ]
           +/usr/local/lib/ALPHA/libintl.so [  Tue Nov 19 16:58:19 1996 ; <NO VERSION INFO> ]
                      +/usr/shlib/libc.so [  Tue Dec 30 00:09:30 1997 ; osf.1 ]
           +/usr/local/lib/ALPHA/libfu.so [  Tue Nov 19 16:57:40 1996 ; <NO VERSION INFO> ]
                      +/usr/shlib/libc.so [  Tue Dec 30 00:09:30 1997 ; osf.1 ]
           +/usr/local/lib/ALPHA/libgcc.so [  Wed Jan 14 19:10:57 1998 ; <NO VERSION INFO> ]
           +/usr/shlib/libc.so [  Tue Dec 30 00:09:30 1997 ; osf.1 ]
           +/usr/local/lib/ALPHA/libgcc.so [  Wed Jan 14 19:10:57 1998 ; <NO VERSION INFO> ]


   Greetings,
	Thomas

-- 

/*******************************************************\
* Thomas Unger                                          *
* Informatik Universitaet GH Siegen                     *
* unger@informatik.uni-siegen.de                        *
* http://www.informatik.uni-siegen.de/~unger            *
\*******************************************************/



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

* Re: Which libraries are linked in?
  1998-06-12  4:00 ` Thomas Unger
@ 1998-06-19  4:00   ` Jeff Donsbach
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Donsbach @ 1998-06-19  4:00 UTC (permalink / raw)



Here is a shell script that I got from one of my co-workers that does
more or less what "ldd" does. It is a multiplatform script and on a Sun,
it just passes the input argument to the real "ldd" command. I don't
know about the other platforms, but I just ran it on Digital Unix 4.0B
and it seems to work just fine. I haven't fully tested it though (like
for cases where something was linked with the "-rpath" linker flag).

I'm told that a real "ldd" command will be in the next major release of
Digital Unix.

-Jeff D

Here is the script -

#!/bin/sh
#-------------------------------------------------------------------------------

#
# Script to produce consistent dynamic dependency information across
platforms.
#
# Syntax: ldd <exe> ...
#
#-------------------------------------------------------------------------------

#
# To use the general code at the bottom of this script, you must define
the
# following three functions:-
#
#    need <file>        - Returns the dynamic dependencies for the
supplied
#                         file, one per line. If the dependency contains
a "/"
#                         character then it will not be subject to a
path
#                         search. A second word can be added to any line
which
#                         supplies a default name to use if the search
should
#                         fail.
#
#    conlib <file>      - Converts the supplied file name into a loader
library
#                         reference (eg /lib/libc.a -> -lc) if it is of
the
#                         correct form. Otherwise the original name will
be
#                         returned.
#
#    search <file>      - Returns a colon separated search path for
locating
#                         the dependencies of the supplied file.
#
#-------------------------------------------------------------------------------

#
# Switch on machine type
#
case `uname` in
#
# Use ldd for SunOS4
#  - Loop over args as pipe suppresses output of filename
#
SunOS)  for file do
                   if [ $# -gt 1 ]; then echo "$file:"; fi
                   /bin/ldd "$file" |
                      sed -e 's/^       /     /' -e 's/ => /    => /'
                done
                exit 0;;
#
# Define functions for HPUX 9
#
HP-UX)  need() {
                   chatr $1 2>/dev/null | awk ' \
                      BEGIN { exe = 0; got = 0; } \
                      $0 ~ /^[  ]*shared executable[    ]*/ { exe = 1; }
\
                      $0 ~ /^[  ]*demand load executable[       ]*/ {
exe = 1; }
\
                      /^[       ]*shared library list:[         ]*$/ { \

                         got = 1; \
                         next; \
                      } \
                      got != 0 { \
                         if (NF == 2 && ($1 == "static" || $1 ==
"dynamic")) { \
                            if (!exe || got != 1) { \
                               if ($1 == "static") print $2; \
                               else { \
                                  for (i=length($2)-1;i>0;i--) \
                                     if (substr($2,i,1) == "/") break; \

                                  print substr($2,i+1),$2; \
                               } \
                            } \
                            got++; \
                         } \
                         else got = 0; \
                      }'
                }
                conlib() {
                   echo "$1" | sed -e 's/^lib\(.*\)\.sl$/-l\1/'
                }
                search() {
                   temp=`chatr $1 2>/dev/null | awk ' \
                      BEGIN { got = 0; first=0; shlib=""; embed=""; } \
                      /^[       ]*shared library dynamic path search:[
]*$/ { \
                         got = 1; \
                         next; \
                      } \
                      got != 0 { \
                         if ($1 == "SHLIB_PATH" && $2 == "enabled") { \
                            shlib = "$SHLIB_PATH"; \
                            first = ($3 == "first"); \
                         } \
                         if ($1 == "embedded" && $2 == "path" && $3 ==
"enabled"
&& (NF != 6 || $5 != "Not" || $6 != "Defined")) { \
                            first = ($4 != "first"); \
                            embed = $5; \
                            for (i=6; i<=NF; i++) embed = embed " " $i;
\
                         } \
                         if (got++ > 2) exit; \
                      } \
                      END { \
                         if (first) print shlib ":" embed; \
                         else print embed ":" shlib; \
                      }'`
                   eval echo "$temp"
                };;
#
# Define functions for Mips Irix 5
#
IRIX)   need() {
                   odump -D $1 2>/dev/null |
                      sed -n 's/^[      ]*NEEDED:[      ]*//p'
                }
                rpath() {
                   odump -D $1 2>/dev/null |
                      sed -n 's/^[      ]*RPATH:[       ]*//p'
                }
                conlib() {
                   echo "$1" | sed -e 's/^lib\(.*\)\.so\.[0-9]$/-l\1/' \

                                   -e 's/^lib\(.*\)\.so$/-l\1/'
                }
                search() {
                   echo "`rpath
$1`:$LD_LIBRARY_PATH:/lib:/usr/lib:/lib/cmplrs/cc:/usr/lib/cmplrs/cc"
                };;
#
# Define functions for Alpha OSF 1
#
OSF1)   need() {
                   odump -D $1 2>/dev/null |
                      sed -n 's/^[      ]*NEEDED:[      ]*//p'
                }
                rpath() {
                   odump -D $1 2>/dev/null |
                      sed -n 's/^[      ]*RPATH:[       ]*//p'
                }
                conlib() {
                   echo "$1" | sed -e 's/^lib\(.*\)\.so\.[0-9]$/-l\1/' \

                                   -e 's/^lib\(.*\)\.so$/-l\1/'
                }
                search() {
                   echo "`rpath
$1`:$LD_LIBRARY_PATH:/usr/shlib:/usr/ccs/lib:/usr/lib/cmplrs/cc:/usr/lib:/usr/lo

cal/lib"
                };;
#
# Define functions for Solaris 2
#
sparc_5)        need() {
                   dump -Lv $1 2>/dev/null |
                      sed -n 's/^\[[0-9]*\][    ]*NEEDED[       ]*//p'
                }
                rpath() {
                   dump -Lv $1 2>/dev/null |
                      sed -n 's/^\[[0-9]*\][    ]*RPATH[        ]*//p'
                }
                conlib() {
                   echo "$1" | sed -e 's/^lib\(.*\)\.so\.[0-9]$/-l\1/' \

                                   -e 's/^lib\(.*\)\.so$/-l\1/'
                }
                search() {
                   echo "$LD_LIBRARY_PATH:`rpath
$1`:/usr/ccs/lib:/usr/lib"
                };;
#
# Unknown platforms
#
*)              echo "$0 Not supported on this platform"
                exit 1;;
esac
#
# Process files in turn
#
for file do
   deps="`need $file`"
   if [ -z "$deps" ]; then
      if [ ! -f $file ]; then echo "$file: No such file or directory"
      else echo "$file: Statically linked"; fi
      continue
   fi

   if [ $# -gt 1 ]; then echo "$file:"; fi
   scan=`search $file`

   echo "$deps" | while read name def; do
      case $name in
      */*)      echo "     $name";;
      *)        ( IFS=":"
                  soname=""
                  for path in $scan; do
                     if [ -f "$path/$name" ]; then
                        soname="$path/$name"
                        break;
                     fi
                  done
                  if [ -z "$soname" -a -f "$def" ]; then soname=$def; fi

                  echo "     `conlib $name`     => ${soname:-(not
found)}"
                );;
      esac
   done
done


--
=========================
Jeff Donsbach   Compaq Computer Corporation, Software Partners Engineering
                200 Forest St., MRO1-3/F26, Marlborough, MA 01752-3011
Email: Jeff.Donsbach@nospam.digital.com    "10 bucks is 10 bucks" - Geddy Lee
       remove "nospam" to reply






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

end of thread, other threads:[~1998-06-19  4:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-06-09  4:00 Which libraries are linked in? Asgar Ali
1998-06-09  4:00 ` Thomas Riechen
1998-06-09  4:00 ` Eric Dumazet
1998-06-09  4:00 ` Jarkko Hietaniemi
1998-06-10  4:00 ` D. Sean Davidson
1998-06-10  4:00 ` Asgar Ali
1998-06-12  4:00 ` Thomas Unger
1998-06-19  4:00   ` Jeff Donsbach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox