Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* ldd (almost the FAQ)
@ 1999-10-27  4:00 Alexander Mai
  1999-10-28  4:00 ` lar3ry gensch
  1999-10-28  4:00 ` Jeff Donsbach
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Mai @ 1999-10-27  4:00 UTC (permalink / raw)


The search for 'ldd' on DU is a FAQ and to my best knowledge
the answers are usually

  odump -Dl $1 $2 $3

the 'listobj' command in dbx.

The question remains whether there isn't a tool combining
the output of both (means version strings, full paths, etc.) ?!

I guess I could write a script script/code executing both but 
a smaller, clean solution would be preferred.

-- 
Alexander Mai
st002279@hrzpub.tu-darmstadt.de



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

* Re: ldd (almost the FAQ)
  1999-10-27  4:00 ldd (almost the FAQ) Alexander Mai
  1999-10-28  4:00 ` lar3ry gensch
@ 1999-10-28  4:00 ` Jeff Donsbach
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Donsbach @ 1999-10-28  4:00 UTC (permalink / raw)


The following script simulates "ldd" on OSF/DUNIX/Tru64 4.0<x> and earlier.
I got this from a collegue years ago. It actually has support for other
platforms in it as well. It still seems to work on Tru64 4.0F. Tru64 5.0 has
a real "ldd' command implemented.

Use it in good health.

Jeff Donsbach
Compaq Computer Corp
eInfrastructure Partner Engineering

------ Cut Here ------
#!/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:/us
r/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

-------- Cut Here --------

Alexander Mai <st002279@sub1.hrz.tu-darmstadt.de> wrote in message
news:7v6hok$g72$1@sun27.hrz.tu-darmstadt.de...
> The search for 'ldd' on DU is a FAQ and to my best knowledge
> the answers are usually
>
>   odump -Dl $1 $2 $3
>
> the 'listobj' command in dbx.
>
> The question remains whether there isn't a tool combining
> the output of both (means version strings, full paths, etc.) ?!
>
> I guess I could write a script script/code executing both but
> a smaller, clean solution would be preferred.
>
> --
> Alexander Mai
> st002279@hrzpub.tu-darmstadt.de




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

* Re: ldd (almost the FAQ)
  1999-10-27  4:00 ldd (almost the FAQ) Alexander Mai
@ 1999-10-28  4:00 ` lar3ry gensch
  1999-10-28  4:00 ` Jeff Donsbach
  1 sibling, 0 replies; 3+ messages in thread
From: lar3ry gensch @ 1999-10-28  4:00 UTC (permalink / raw)
  To: Alexander Mai

[Posted and mailed]

In article <7v6hok$g72$1@sun27.hrz.tu-darmstadt.de>,
	st002279@sub1.hrz.tu-darmstadt.de (Alexander Mai) writes:
> The search for 'ldd' on DU is a FAQ and to my best knowledge
> the answers are usually
> 
>   odump -Dl $1 $2 $3
> 
> the 'listobj' command in dbx.
> 
> The question remains whether there isn't a tool combining
> the output of both (means version strings, full paths, etc.) ?!

The `ldd(1)' utility has been added to Tru64 Unix in versions 4.0g and
5.0, and presumably for all versions higher than 4.0g.

This utility gives better information on exactly which libraries would
be linked in for a given executable or shared subroutine library than
the `odump(1)' utility, and can also print warnings for unresolved
symbol references.

-- 
Larry Gensch                                    Larry.Gensch@compaq.com
Compaq Computer Corporation                     As usual, the
110 Spit Brook Road ZKO3-2/W17                  standard disclaimers
Nashua, NH 03062                                apply, etc.



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

end of thread, other threads:[~1999-10-28  4:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-10-27  4:00 ldd (almost the FAQ) Alexander Mai
1999-10-28  4:00 ` lar3ry gensch
1999-10-28  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