]>
Commit | Line | Data |
---|---|---|
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 | |
8 | RTLD=@RTLD@ | |
f0e44959 UD |
9 | usage="\ |
10 | ldd [OPTION]... FILE... | |
11 | --help print this help and exit | |
12 | --version print version information and exit | |
13 | Report bugs to <bug-glibc@prep.ai.mit.edu>." | |
14 | ||
15 | while 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 | |
26 | done | |
b122c703 RM |
27 | |
28 | case $# in | |
29 | 0) | |
f0e44959 UD |
30 | echo >&2 "\ |
31 | ldd: missing file arguments | |
32 | Try \`ldd --help' for more information." | |
b122c703 RM |
33 | exit 1 ;; |
34 | 1) | |
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 |
64 | esac | |
65 | ||
66 | exit 0 |