Test for hton/ntoh functions.
[glibc/history.git] / elf / ldd.bash.in
blob32a9405422e1390c05a3136f80c4f1ba664a0348
1 #! @BASH@
3 # Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
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.
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.
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.
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.
27 # We should be able to find the translation right at the beginning.
28 TEXTDOMAIN=libc
29 TEXTDOMAINDIR=@TEXTDOMAINDIR@
31 RTLD=@RTLD@
32 warn=
33 bind_now=
34 verbose=
36 while test $# -gt 0; do
37 case "$1" in
38 --vers | --versi | --versio | --version)
39 echo 'ldd (GNU libc) @VERSION@'
40 echo $"Copyright (C) 1996, 1997 Free Software Foundation, Inc.
41 This is free software; see the source for copying conditions. There is NO
42 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
43 Written by Roland McGrath and Ulrich Drepper."
44 exit 0 ;;
45 --h | --he | --hel | --help)
46 echo $"ldd [OPTION]... FILE...
47 --help print this help and exit
48 --version print version information and exit
49 -d, --data-relocs process data relocations
50 -r, --function-relocs process data and function relocations
51 -v, --verbose print all information
52 Report bugs using the \`glibcbug' script to <bugs@gnu.ai.mit.edu>."
53 exit 0 ;;
54 -d | --d | --da | --dat | --data | --data- | --data-r | --data-re | \
55 --data-rel | --data-relo | --data-reloc | --data-relocs)
56 warn=yes
57 shift ;;
58 -r | --f | --fu | --fun | --func | --funct | --functi | --functio | \
59 --function | --function- | --function-r | --function-re | --function-rel | \
60 --function-relo | --function-reloc | --function-relocs)
61 warn=yes
62 bind_now=yes
63 shift ;;
64 -v | --verb | --verbo | --verbos | --verbose)
65 verbose=yes
66 shift ;;
67 --v | --ve | --ver)
68 echo >&2 $"ldd: option \`$1' is ambiguous"
69 exit 1 ;;
70 --) # Stop option processing.
71 shift; break ;;
72 -*)
73 echo >&2 'ldd:' $"unrecognized option" "\`$1'"
74 echo >&2 $"Try \`ldd --help' for more information."
75 exit 1 ;;
77 break ;;
78 esac
79 done
81 add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
82 add_env="$add_env LD_VERBOSE=$verbose"
83 case $# in
85 echo >&2 'ldd:' $"missing file arguments"
86 echo >&2 $"Try \`ldd --help' for more information."
87 exit 1 ;;
89 # We don't list the file name when there is only one.
90 case "$1" in
91 /*) file="$1" ;;
92 *) file="./$1" ;;
93 esac
94 if test ! -f "$file"; then
95 echo "ldd: ${file}:" $"no such file"
96 exit 1
97 elif test -r "$file"; then
98 test -x "$file" ||
99 echo 'ldd:' $"warning: you do not have execution permission for" "\`$file'"
100 ${RTLD} --verify "$file"
101 case $? in
103 eval $add_env exec '"$file"' || exit 1
106 echo $" not a dynamic executable"
107 exit 1
110 eval $add_env exec \${RTLD} '"$file"' || exit 1
113 echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($?)" >&2
114 exit 1
116 esac
117 else
118 echo 'ldd:' $"error: you do not have read permission for" "\`$file'"
119 exit 1
121 exit ;;
123 result=0
124 for file; do
125 echo "${file}:"
126 case "$file" in
127 /*) : ;;
128 *) file="./$file" ;;
129 esac
130 if test ! -f "$file"; then
131 echo "ldd: ${file}:" $"no such file"
132 result=1
133 elif test -r "$file"; then
134 test -x "$file" || echo 'ldd:' $"\
135 warning: you do not have execution permission for" "\`$file'"
136 ${RTLD} --verify "$file"
137 case $? in
139 eval $add_env '"$file"' || result=1
142 echo $" not a dynamic executable"
143 result=1
146 eval $add_env ${RTLD} '"$file"' || result=1
149 echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($?)" >&2
150 exit 1
152 esac
153 else
154 echo 'ldd:' $"error: you do not have read permission for" "\`$file'"
155 result=1
157 done
158 esac
160 exit $result
161 # Local Variables:
162 # mode:ksh
163 # End: