]> sourceware.org Git - glibc.git/blame - elf/ldd.sh.in
(\deftypevarheader, \deftypevrheader): Remove
[glibc.git] / elf / ldd.sh.in
CommitLineData
b122c703
RM
1#! /bin/sh
2
3# This is the `ldd' command, which lists what shared libraries are
4# used by given dynamically-linked executables. It works by invoking the
f0e44959
UD
5# run-time dynamic linker as a command and setting the environment
6# variable LD_TRACE_LOADED_OBJECTS to a non-empty value.
b122c703
RM
7
8RTLD=@RTLD@
f0e44959
UD
9usage="\
10ldd [OPTION]... FILE...
11 --help print this help and exit
12 --version print version information and exit
13Report bugs to <bug-glibc@prep.ai.mit.edu>."
14
15while test $# -gt 0; do
16 case "$1" in
17 --v*)
18 echo 'ldd (GNU libc) @VERSION@'; exit 0 ;;
19 --h*)
20 echo "$usage"; exit 0 ;;
21 --) # Stop option prcessing
22 shift; break ;;
23 *)
24 break ;;
25 esac
26done
b122c703
RM
27
28case $# in
290)
f0e44959
UD
30 echo >&2 "\
31ldd: missing file arguments
32Try \`ldd --help' for more information."
b122c703
RM
33 exit 1 ;;
341)
35 # We don't list the file name when there is only one.
d17e960c
RM
36 case "$1" in
37 /*) file="$1" ;;
38 *) file="./$1" ;;
39 esac
8145a974 40 if test ! -f "$file"; then
f0e44959 41 echo "${file}: no such file"
8145a974 42 elif ${RTLD} --verify "$file"; then
2de99474 43 LD_TRACE_LOADED_OBJECTS=1 exec ${RTLD} "$file" && exit 1
61965e9b
RM
44 else
45 echo ' not a dynamic executable'
46 fi
b122c703
RM
47 exit ;;
48*)
49 set -e # Bail out immediately if ${RTLD} loses on any argument.
50 for file; do
51 echo "${file}:"
d17e960c 52 case "$file" in
f0e44959 53 /*) : ;;
d17e960c
RM
54 *) file="./$file" ;;
55 esac
8145a974
UD
56 if test ! -f "$file"; then
57 echo "$file: no such file"
58 elif ${RTLD} --verify "$file"; then
2de99474 59 LD_TRACE_LOADED_OBJECTS=1 ${RTLD} "$file"
61965e9b
RM
60 else
61 echo ' not a dynamic executable'
62 fi
b122c703
RM
63 done
64esac
65
66exit 0
This page took 0.052399 seconds and 5 git commands to generate.