Advertisement
Guest User

arm-linux-gnueabihf-ldd

a guest
Jan 25th, 2019
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.71 KB | None | 0 0
  1. #! /bin/bash
  2. # Copyright (C) 1996-2018 Free Software Foundation, Inc.
  3. # This file is part of the GNU C Library.
  4.  
  5. # The GNU C Library is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2.1 of the License, or (at your option) any later version.
  9.  
  10. # The GNU C Library is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. # Lesser General Public License for more details.
  14.  
  15. # You should have received a copy of the GNU Lesser General Public
  16. # License along with the GNU C Library; if not, see
  17. # <http://www.gnu.org/licenses/>.
  18.  
  19.  
  20. # This is the `ldd' command, which lists what shared libraries are
  21. # used by given dynamically-linked executables.  It works by invoking the
  22. # run-time dynamic linker as a command and setting the environment
  23. # variable LD_TRACE_LOADED_OBJECTS to a non-empty value.
  24.  
  25. # We should be able to find the translation right at the beginning.
  26. TEXTDOMAIN=libc
  27. TEXTDOMAINDIR=/usr/share/locale
  28.  
  29. QEMU=qemu-arm-static
  30. CROSS_LIB_PATH=/usr/arm-linux-gnueabihf/lib
  31. export LD_LIBRARY_PATH=${CROSS_LIB_PATH}
  32. RTLDLIST="${CROSS_LIB_PATH}/ld-2.28.so ${CROSS_LIB_PATH}/ld-linux-armhf.so.3 ${CROSS_LIB_PATH}/ld-linux.so.3"
  33. warn=
  34. bind_now=
  35. verbose=
  36.  
  37. while test $# -gt 0; do
  38.   case "$1" in
  39.   --vers | --versi | --versio | --version)
  40.     echo 'ldd (Ubuntu GLIBC 2.28-0ubuntu1) 2.28'
  41.     printf $"Copyright (C) %s Free Software Foundation, Inc.
  42. This is free software; see the source for copying conditions.  There is NO
  43. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  44. " "2018"
  45.     printf $"Written by %s and %s.
  46. " "Roland McGrath" "Ulrich Drepper"
  47.     exit 0
  48.     ;;
  49.   --h | --he | --hel | --help)
  50.     echo $"Usage: ldd [OPTION]... FILE...
  51.      --help              print this help and exit
  52.      --version           print version information and exit
  53.  -d, --data-relocs       process data relocations
  54.  -r, --function-relocs   process data and function relocations
  55.  -u, --unused            print unused direct dependencies
  56.  -v, --verbose           print all information
  57. "
  58.     printf $"For bug reporting instructions, please see:\\n%s.\\n" \
  59.       "<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>"
  60.     exit 0
  61.     ;;
  62.   -d | --d | --da | --dat | --data | --data- | --data-r | --data-re | \
  63.   --data-rel | --data-relo | --data-reloc | --data-relocs)
  64.     warn=yes
  65.     shift
  66.     ;;
  67.   -r | --f | --fu | --fun | --func | --funct | --functi | --functio | \
  68.   --function | --function- | --function-r | --function-re | --function-rel | \
  69.   --function-relo | --function-reloc | --function-relocs)
  70.     warn=yes
  71.     bind_now=yes
  72.     shift
  73.     ;;
  74.   -v | --verb | --verbo | --verbos | --verbose)
  75.     verbose=yes
  76.     shift
  77.     ;;
  78.   -u | --u | --un | --unu | --unus | --unuse | --unused)
  79.     unused=yes
  80.     shift
  81.     ;;
  82.   --v | --ve | --ver)
  83.     echo >&2 $"ldd: option \`$1' is ambiguous"
  84.    exit 1
  85.    ;;
  86.  --)           # Stop option processing.
  87.    shift; break
  88.    ;;
  89.  -*)
  90.    echo >&2 'ldd:' $"unrecognized option" "\`$1'"
  91.     echo >&2 $"Try \`ldd --help' for more information."
  92.    exit 1
  93.    ;;
  94.  *)
  95.    break
  96.    ;;
  97.  esac
  98. done
  99.  
  100. nonelf ()
  101. {
  102.  # Maybe extra code for non-ELF binaries.
  103.  return 1;
  104. }
  105.  
  106. add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
  107. add_env="$add_env LD_LIBRARY_VERSION=\$verify_out"
  108. add_env="$add_env LD_VERBOSE=$verbose"
  109. if test "$unused" = yes; then
  110.  add_env="$add_env LD_DEBUG=\"$LD_DEBUG${LD_DEBUG:+,}unused\""
  111. fi
  112.  
  113. # The following command substitution is needed to make ldd work in SELinux
  114. # environments where the RTLD might not have permission to write to the
  115. # terminal.  The extra "x" character prevents the shell from trimming trailing
  116. # newlines from command substitution results.  This function is defined as a
  117. # subshell compound list (using "(...)") to prevent parameter assignments from
  118. # affecting the calling shell execution environment.
  119. try_trace() (
  120.  output=$(eval $add_env '"$@"' 2>&1; rc=$?; printf 'x'; exit $rc)
  121.  rc=$?
  122.  printf '%s' "${output%x}"
  123.  return $rc
  124. )
  125.  
  126. case $# in
  127. 0)
  128.  echo >&2 'ldd:' $"missing file arguments"
  129.  echo >&2 $"Try \`ldd --help' for more information."
  130.   exit 1
  131.   ;;
  132. 1)
  133.   single_file=t
  134.   ;;
  135. *)
  136.   single_file=f
  137.   ;;
  138. esac
  139.  
  140. result=0
  141. for file do
  142.   # We don't list the file name when there is only one.
  143.   test $single_file = t || echo "${file}:"
  144.   case $file in
  145.   */*) :
  146.        ;;
  147.   *) file=./$file
  148.      ;;
  149.   esac
  150.   if test ! -e "$file"; then
  151.     echo "ldd: ${file}:" $"No such file or directory" >&2
  152.     result=1
  153.   elif test ! -f "$file"; then
  154.     echo "ldd: ${file}:" $"not regular file" >&2
  155.     result=1
  156.   elif test -r "$file"; then
  157.     RTLD=
  158.     ret=1
  159.     for rtld in ${RTLDLIST}; do
  160.       if test -x $rtld; then
  161.         dummy=`${QEMU} $rtld 2>&1`
  162.         if test $? = 127; then
  163.           verify_out=`${QEMU} ${rtld} --verify "$file"`
  164.           ret=$?
  165.           case $ret in
  166.           [02]) RTLD=${rtld}; break;;
  167.           esac
  168.         fi
  169.       fi
  170.     done
  171.     case $ret in
  172.     1)
  173.       # This can be a non-ELF binary or no binary at all.
  174.       nonelf "$file" || {
  175.         echo $" not a dynamic executable"
  176.         result=1
  177.       }
  178.       ;;
  179.     0|2)
  180.       try_trace ${QEMU} "$RTLD" "$file" || result=1
  181.       ;;
  182.     *)
  183.       echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($ret)" >&2
  184.       exit 1
  185.       ;;
  186.     esac
  187.   else
  188.     echo 'ldd:' $"error: you do not have read permission for" "\`$file'" >&2
  189.     result=1
  190.   fi
  191. done
  192.  
  193. exit $result
  194. # Local Variables:
  195. #  mode:ksh
  196. # End:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement