update from main archive 961119
[platform/upstream/glibc.git] / elf / ldd.bash.in
1 #! @BASH@
2
3 # Copyright (C) 1996 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
5
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
10
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Library General Public License for more details.
15
16 # You should have received a copy of the GNU Library General Public
17 # License along with the GNU C Library; see the file COPYING.LIB.  If not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
20
21
22 # This is the `ldd' command, which lists what shared libraries are
23 # used by given dynamically-linked executables.  It works by invoking the
24 # run-time dynamic linker as a command and setting the environment
25 # variable LD_TRACE_LOADED_OBJECTS to a non-empty value.
26
27 # We should be able to find the translation right at the beginning.
28 TEXTDOMAIN=libc
29 TEXTDOMAINDIR=@TEXTDOMAINDIR@
30
31 RTLD=@RTLD@
32
33 while test $# -gt 0; do
34   case "$1" in
35   --v*)
36     echo $"ldd (GNU libc) @VERSION@
37 Copyright (C) 1996 Free Software Foundation, Inc.
38 This is free software; see the source for copying conditions.  There is NO
39 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
40     exit 0 ;;
41   --h*)
42     echo $"ldd [OPTION]... FILE...
43   --help           print this help and exit
44   --version        print version information and exit
45 Report bugs to <bug-glibc@prep.ai.mit.edu>."
46     exit 0 ;;
47   --)           # Stop option prcessing.
48     shift; break ;;
49   *)
50     break ;;
51   esac
52 done
53
54 case $# in
55 0)
56   echo >&2 $"\
57 ldd: missing file arguments
58 Try \`ldd --help' for more information."
59   exit 1 ;;
60 1)
61   # We don't list the file name when there is only one.
62   case "$1" in
63   /*) file="$1" ;;
64   *) file="./$1" ;;
65   esac
66   if test ! -f "$file"; then
67     echo "${file}:" $"no such file"
68   elif ${RTLD} --verify "$file"; then
69     LD_TRACE_LOADED_OBJECTS=1 exec ${RTLD} "$file" && exit 1
70   else
71     echo $"     not a dynamic executable"
72   fi
73   exit ;;
74 *)
75   set -e        # Bail out immediately if ${RTLD} loses on any argument.
76   for file; do
77     echo "${file}:"
78     case "$file" in
79     /*) : ;;
80     *) file="./$file" ;;
81     esac
82     if test ! -f "$file"; then
83       echo "$file:" $"no such file"
84     elif ${RTLD} --verify "$file"; then
85       LD_TRACE_LOADED_OBJECTS=1 ${RTLD} "$file"
86     else
87       echo $"   not a dynamic executable"
88     fi
89   done
90 esac
91
92 exit 0
93 # Local Variables:
94 #  mode:ksh
95 # End: