platform_bionic/linker/ldd.sh
Pete Bentley 557308c732 Ignore LD_LIBRARY_PATH when determining file type in ldd.
Otherwise if a 32bit copy of a library used by Toybox
exists on LD_LIBRARY_PATH then file(1) will fail.

Bug: 181666541
Test: Manually copied to device and verified correct behaviour
Change-Id: I7d729927b1b433ec953c266920489613fc096e03
2021-03-02 16:56:39 +00:00

24 lines
374 B
Bash
Executable file

#!/system/bin/sh
# Rather than have ldd and ldd64, this script does the right thing depending
# on the argument.
function error() {
echo "$1"
exit 1
}
[ $# -eq 1 ] || error "usage: ldd FILE"
what=$(LD_LIBRARY_PATH= file -L "$1")
case "$what" in
*32-bit*)
linker --list "$1"
;;
*64-bit*)
linker64 --list "$1"
;;
*)
error "$what"
;;
esac