about summary refs log tree commit diff
path: root/elf/ldd.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'elf/ldd.sh.in')
-rw-r--r--elf/ldd.sh.in54
1 files changed, 42 insertions, 12 deletions
diff --git a/elf/ldd.sh.in b/elf/ldd.sh.in
index 5b6cc3a75d..4351578b6d 100644
--- a/elf/ldd.sh.in
+++ b/elf/ldd.sh.in
@@ -25,23 +25,40 @@
 # variable LD_TRACE_LOADED_OBJECTS to a non-empty value.
 
 RTLD=@RTLD@
+RELOCS=
 
 while test $# -gt 0; do
   case "$1" in
-  --v*)
+  --v | --ve | --ver | --vers | --versi | --versio | --version)
     echo 'ldd (GNU libc) @VERSION@
 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'
     exit 0 ;;
-  --h*)
+  --h | --he | --hel | --help)
     echo "ldd [OPTION]... FILE...
-  --help           print this help and exit
-  --version        print version information and exit
+      --help              print this help and exit
+      --version           print version information and exit
+  -d, --data-relocs       process data relocations
+  -r, --function-relocs   process data and function relocations
 Report bugs using the \`glibcbug' script to <bugs@gnu.ai.mit.edu>."
     exit 0 ;;
+  -d | --d | --da | --dat | --data | --data- | --data-r | --data-re | \
+  --data-rel | --data-relo | --data-reloc | --data-relocs)
+    RELOCS='--data-relocs'
+    shift ;;
+  -r | --f | --fu | --fun | --func | --funct | --functi | --functio | \
+  --function | --function- | --function-r | --function-re | --function-rel | \
+  --function-relo | --function-reloc | --function-relocs)
+    RELOCS='--function-relocs'
+    shift ;;
   --)		# Stop option processing.
     shift; break ;;
+  -*)
+    echo >&2 "\
+ldd: unrecognized option \`$1'
+Try \`ldd --help' for more information."
+    exit 1 ;;
   *)
     break ;;
   esac
@@ -61,14 +78,21 @@ Try \`ldd --help' for more information."
   esac
   if test ! -f "$file"; then
     echo "${file}: no such file"
-  elif ${RTLD} --verify "$file"; then
-    LD_TRACE_LOADED_OBJECTS=1 exec ${RTLD} "$file" && exit 1
+    exit 1
   else
-    echo '	not a dynamic executable'
+    test -x "$file" ||
+      echo "warning: you do not have execution permission for \`$file'"
+    if ${RTLD} --verify "$file"; then
+      LD_TRACE_LOADED_OBJECTS=1 exec ${RTLD} ${RELOCS} "$file" || exit 1
+    else
+      echo '	not a dynamic executable'
+      exit 1
+    fi
   fi
   exit ;;
 *)
   set -e	# Bail out immediately if ${RTLD} loses on any argument.
+  result=0
   for file; do
     echo "${file}:"
     case "$file" in
@@ -76,13 +100,19 @@ Try \`ldd --help' for more information."
     *) file="./$file" ;;
     esac
     if test ! -f "$file"; then
-      echo "$file: no such file"
-    elif ${RTLD} --verify "$file"; then
-      LD_TRACE_LOADED_OBJECTS=1 ${RTLD} "$file"
+      echo "${file}: no such file"
+      result=1
     else
-      echo '	not a dynamic executable'
+      test -x "$file" ||
+	echo "warning: you do not have execution permission for \`$file'"
+      if ${RTLD} --verify "$file"; then
+	LD_TRACE_LOADED_OBJECTS=1 ${RTLD} ${RELOCS} "$file" || result=1
+      else
+	echo '	not a dynamic executable'
+	result=1
+      fi
     fi
   done
 esac
 
-exit 0
+exit $result