diff options
Diffstat (limited to 'elf/ldd.bash.in')
-rw-r--r-- | elf/ldd.bash.in | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in index dd4fc6ab96..48d5c90fd5 100644 --- a/elf/ldd.bash.in +++ b/elf/ldd.bash.in @@ -69,6 +69,7 @@ Report bugs using the \`glibcbug' script to <bugs@gnu.ai.mit.edu>." esac done +add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now" case $# in 0) echo >&2 $"ldd: missing file arguments" @@ -86,20 +87,29 @@ case $# in elif test -r "$file"; then test -x "$file" || echo $"ldd: warning: you do not have execution permission for" "\`$file'" - if ${RTLD} --verify "$file"; then - LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now \ - exec ${RTLD} ${RELOCS} "$file" || exit 1 - else - echo $" not a dynamic executable" - exit 1 - fi + ${RTLD} --verify "$file" + case $? in + 0) + eval $add_env exec '"$file"' || exit 1 + ;; + 1) + echo $" not a dynamic executable" + exit 1 + ;; + 2) + eval $add_env exec \${RTLD} '"$file"' || exit 1 + ;; + *) + echo $"ldd: ${RTLD} exited with unknown exit code ($?)" >&2 + exit 1 + ;; + esac else echo $"ldd: error: you do not have read permission for" "\`$file'" exit 1 fi exit ;; *) - set -e # Bail out immediately if ${RTLD} loses on any argument. result=0 for file; do echo "${file}:" @@ -113,13 +123,23 @@ case $# in elif test -r "$file"; then test -x "$file" || echo $"\ ldd: warning: you do not have execution permission for" "\`$file'" - if ${RTLD} --verify "$file"; then - LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now \ - ${RTLD} ${RELOCS} "$file" || result=1 - else + ${RTLD} --verify "$file" + case $? in + 0) + eval $add_env '"$file"' || result=1 + ;; + 1) echo $" not a dynamic executable" result=1 - fi + ;; + 2) + eval $add_env ${RTLD} '"$file"' || result=1 + ;; + *) + echo $"ldd: ${RTLD} exited with unknown exit code ($?)" >&2 + exit 1 + ;; + esac else echo $"ldd: error: you do not have read permission for" "\`$file'" result=1 |