--- glibc-2.3.4/elf/ldd.bash.in.ldd-non-exec 2004-12-28 14:05:06.000000000 +0100 +++ glibc-2.3.4/elf/ldd.bash.in 2004-12-28 14:33:51.377182592 +0100 @@ -31,6 +31,7 @@ RTLDLIST=@RTLD@ warn= bind_now= verbose= +file_magic_regex="ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib)" while test $# -gt 0; do case "$1" in @@ -148,8 +149,11 @@ for file do echo "ldd: ${file}:" $"No such file or directory" >&2 result=1 elif test -r "$file"; then + if eval file -L "$file" 2>/dev/null \ + | sed 10q | egrep -v "$file_magic_regex" > /dev/null; then test -x "$file" || echo 'ldd:' $"\ warning: you do not have execution permission for" "\`$file'" >&2 + fi RTLD= for rtld in ${RTLDLIST}; do if test -x $rtld; then @@ -171,8 +175,14 @@ warning: you do not have execution permi # If the program exits with exit code 5, it means the process has been # invoked with __libc_enable_secure. Fall back to running it through # the dynamic linker. - try_trace "$file" - rc=$? + if [ ! -x "$file" ] && eval file -L "$file" 2>/dev/null \ + | sed 10q | egrep "$file_magic_regex" > /dev/null; then + try_trace "$RTLD" "$file" + rc=$? + else + try_trace "$file" + rc=$? + fi if [ $rc = 5 ]; then try_trace "$RTLD" "$file" rc=$?