|
Packit Service |
82fcde |
#! @BASH@
|
|
Packit Service |
82fcde |
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
# This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
# License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
# Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
# License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
# <http://www.gnu.org/licenses/>.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# This is the `ldd' command, which lists what shared libraries are
|
|
Packit Service |
82fcde |
# used by given dynamically-linked executables. It works by invoking the
|
|
Packit Service |
82fcde |
# run-time dynamic linker as a command and setting the environment
|
|
Packit Service |
82fcde |
# variable LD_TRACE_LOADED_OBJECTS to a non-empty value.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# We should be able to find the translation right at the beginning.
|
|
Packit Service |
82fcde |
TEXTDOMAIN=libc
|
|
Packit Service |
82fcde |
TEXTDOMAINDIR=@TEXTDOMAINDIR@
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
RTLDLIST=@RTLD@
|
|
Packit Service |
82fcde |
warn=
|
|
Packit Service |
82fcde |
bind_now=
|
|
Packit Service |
82fcde |
verbose=
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
while test $# -gt 0; do
|
|
Packit Service |
82fcde |
case "$1" in
|
|
Packit Service |
82fcde |
--vers | --versi | --versio | --version)
|
|
Packit Service |
82fcde |
echo 'ldd @PKGVERSION@@VERSION@'
|
|
Packit Service |
82fcde |
printf $"Copyright (C) %s Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This is free software; see the source for copying conditions. There is NO
|
|
Packit Service |
82fcde |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit Service |
82fcde |
" "2018"
|
|
Packit Service |
82fcde |
printf $"Written by %s and %s.
|
|
Packit Service |
82fcde |
" "Roland McGrath" "Ulrich Drepper"
|
|
Packit Service |
82fcde |
exit 0
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
--h | --he | --hel | --help)
|
|
Packit Service |
82fcde |
echo $"Usage: ldd [OPTION]... FILE...
|
|
Packit Service |
82fcde |
--help print this help and exit
|
|
Packit Service |
82fcde |
--version print version information and exit
|
|
Packit Service |
82fcde |
-d, --data-relocs process data relocations
|
|
Packit Service |
82fcde |
-r, --function-relocs process data and function relocations
|
|
Packit Service |
82fcde |
-u, --unused print unused direct dependencies
|
|
Packit Service |
82fcde |
-v, --verbose print all information
|
|
Packit Service |
82fcde |
"
|
|
Packit Service |
82fcde |
printf $"For bug reporting instructions, please see:\\n%s.\\n" \
|
|
Packit Service |
82fcde |
"@REPORT_BUGS_TO@"
|
|
Packit Service |
82fcde |
exit 0
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
-d | --d | --da | --dat | --data | --data- | --data-r | --data-re | \
|
|
Packit Service |
82fcde |
--data-rel | --data-relo | --data-reloc | --data-relocs)
|
|
Packit Service |
82fcde |
warn=yes
|
|
Packit Service |
82fcde |
shift
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
-r | --f | --fu | --fun | --func | --funct | --functi | --functio | \
|
|
Packit Service |
82fcde |
--function | --function- | --function-r | --function-re | --function-rel | \
|
|
Packit Service |
82fcde |
--function-relo | --function-reloc | --function-relocs)
|
|
Packit Service |
82fcde |
warn=yes
|
|
Packit Service |
82fcde |
bind_now=yes
|
|
Packit Service |
82fcde |
shift
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
-v | --verb | --verbo | --verbos | --verbose)
|
|
Packit Service |
82fcde |
verbose=yes
|
|
Packit Service |
82fcde |
shift
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
-u | --u | --un | --unu | --unus | --unuse | --unused)
|
|
Packit Service |
82fcde |
unused=yes
|
|
Packit Service |
82fcde |
shift
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
--v | --ve | --ver)
|
|
Packit Service |
82fcde |
echo >&2 $"ldd: option \`$1' is ambiguous"
|
|
Packit Service |
82fcde |
exit 1
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
--) # Stop option processing.
|
|
Packit Service |
82fcde |
shift; break
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
-*)
|
|
Packit Service |
82fcde |
echo >&2 'ldd:' $"unrecognized option" "\`$1'"
|
|
Packit Service |
82fcde |
echo >&2 $"Try \`ldd --help' for more information."
|
|
Packit Service |
82fcde |
exit 1
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
*)
|
|
Packit Service |
82fcde |
break
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
esac
|
|
Packit Service |
82fcde |
done
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
nonelf ()
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
# Maybe extra code for non-ELF binaries.
|
|
Packit Service |
82fcde |
return 1;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
|
|
Packit Service |
82fcde |
add_env="$add_env LD_VERBOSE=$verbose"
|
|
Packit Service |
82fcde |
if test "$unused" = yes; then
|
|
Packit Service |
82fcde |
add_env="$add_env LD_DEBUG=\"$LD_DEBUG${LD_DEBUG:+,}unused\""
|
|
Packit Service |
82fcde |
fi
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# The following command substitution is needed to make ldd work in SELinux
|
|
Packit Service |
82fcde |
# environments where the RTLD might not have permission to write to the
|
|
Packit Service |
82fcde |
# terminal. The extra "x" character prevents the shell from trimming trailing
|
|
Packit Service |
82fcde |
# newlines from command substitution results. This function is defined as a
|
|
Packit Service |
82fcde |
# subshell compound list (using "(...)") to prevent parameter assignments from
|
|
Packit Service |
82fcde |
# affecting the calling shell execution environment.
|
|
Packit Service |
82fcde |
try_trace() (
|
|
Packit Service |
82fcde |
output=$(eval $add_env '"$@"' 2>&1; rc=$?; printf 'x'; exit $rc)
|
|
Packit Service |
82fcde |
rc=$?
|
|
Packit Service |
82fcde |
printf '%s' "${output%x}"
|
|
Packit Service |
82fcde |
return $rc
|
|
Packit Service |
82fcde |
)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
case $# in
|
|
Packit Service |
82fcde |
0)
|
|
Packit Service |
82fcde |
echo >&2 'ldd:' $"missing file arguments"
|
|
Packit Service |
82fcde |
echo >&2 $"Try \`ldd --help' for more information."
|
|
Packit Service |
82fcde |
exit 1
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
1)
|
|
Packit Service |
82fcde |
single_file=t
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
*)
|
|
Packit Service |
82fcde |
single_file=f
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
esac
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
result=0
|
|
Packit Service |
82fcde |
for file do
|
|
Packit Service |
82fcde |
# We don't list the file name when there is only one.
|
|
Packit Service |
82fcde |
test $single_file = t || echo "${file}:"
|
|
Packit Service |
82fcde |
case $file in
|
|
Packit Service |
82fcde |
*/*) :
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
*) file=./$file
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
esac
|
|
Packit Service |
82fcde |
if test ! -e "$file"; then
|
|
Packit Service |
82fcde |
echo "ldd: ${file}:" $"No such file or directory" >&2
|
|
Packit Service |
82fcde |
result=1
|
|
Packit Service |
82fcde |
elif test ! -f "$file"; then
|
|
Packit Service |
82fcde |
echo "ldd: ${file}:" $"not regular file" >&2
|
|
Packit Service |
82fcde |
result=1
|
|
Packit Service |
82fcde |
elif test -r "$file"; then
|
|
Packit Service |
82fcde |
test -x "$file" || echo 'ldd:' $"\
|
|
Packit Service |
82fcde |
warning: you do not have execution permission for" "\`$file'" >&2
|
|
Packit Service |
82fcde |
RTLD=
|
|
Packit Service |
82fcde |
ret=1
|
|
Packit Service |
82fcde |
for rtld in ${RTLDLIST}; do
|
|
Packit Service |
82fcde |
if test -x $rtld; then
|
|
Packit Service |
82fcde |
verify_out=`${rtld} --verify "$file"`
|
|
Packit Service |
82fcde |
ret=$?
|
|
Packit Service |
82fcde |
case $ret in
|
|
Packit Service |
82fcde |
[02]) RTLD=${rtld}; break;;
|
|
Packit Service |
82fcde |
esac
|
|
Packit Service |
82fcde |
fi
|
|
Packit Service |
82fcde |
done
|
|
Packit Service |
82fcde |
case $ret in
|
|
Packit Service |
82fcde |
1)
|
|
Packit Service |
82fcde |
# This can be a non-ELF binary or no binary at all.
|
|
Packit Service |
82fcde |
nonelf "$file" || {
|
|
Packit Service |
82fcde |
echo $" not a dynamic executable"
|
|
Packit Service |
82fcde |
result=1
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
0|2)
|
|
Packit Service |
82fcde |
try_trace "$RTLD" "$file" || result=1
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
*)
|
|
Packit Service |
82fcde |
echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($ret)" >&2
|
|
Packit Service |
82fcde |
exit 1
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
esac
|
|
Packit Service |
82fcde |
else
|
|
Packit Service |
82fcde |
echo 'ldd:' $"error: you do not have read permission for" "\`$file'" >&2
|
|
Packit Service |
82fcde |
result=1
|
|
Packit Service |
82fcde |
fi
|
|
Packit Service |
82fcde |
done
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
exit $result
|
|
Packit Service |
82fcde |
# Local Variables:
|
|
Packit Service |
82fcde |
# mode:ksh
|
|
Packit Service |
82fcde |
# End:
|