blob: a0f2b3218675e44ea1c6243d8d1d427d8d935062 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
Author: Ain <41307858+nero@users.noreply.github.com>
Fix ldso configuration parsing for musl binaries
Previously, lddtree always checked for the glibc library paths, even
when ran on a musl binary. This resulted in incorrect results on
multiarch systems with both musl and glibc.
diff --git a/lddtree.sh b/lddtree.sh
index 5f06813..74ca830 100755
--- a/lddtree.sh
+++ b/lddtree.sh
@@ -107,7 +107,7 @@ c_ldso_paths_loaded='false'
find_elf() {
_find_elf=''
- local elf=$1 needed_by=$2
+ local interp elf=$1 needed_by=$2
if [ "${elf}" != "${elf##*/}" ] && [ -e "${elf}" ] ; then
_find_elf=${elf}
return 0
@@ -151,28 +151,36 @@ find_elf() {
if ! ${c_ldso_paths_loaded} ; then
c_ldso_paths_loaded='true'
c_ldso_paths=
- if [ -r ${ROOT}etc/ld.so.conf ] ; then
- read_ldso_conf() {
- local line p
- for p ; do
- # if the glob didnt match anything #360041,
- # or the files arent readable, skip it
- [ -r "${p}" ] || continue
- while read line ; do
- case ${line} in
- "#"*) ;;
- "include "*) read_ldso_conf ${line#* } ;;
- *) c_ldso_paths="$c_ldso_paths:${ROOT}${line#/}";;
- esac
- done <"${p}"
- done
- }
- # the 'include' command is relative
- local _oldpwd="$PWD"
- cd "$ROOT"etc >/dev/null
+ read_ldso_conf() {
+ local line p
+ for p ; do
+ # if the glob didnt match anything #360041,
+ # or the files arent readable, skip it
+ [ -r "${p}" ] || continue
+ while read line ; do
+ case ${line} in
+ "#"*) ;;
+ "include "*) read_ldso_conf ${line#* } ;;
+ *) c_ldso_paths="$c_ldso_paths:${ROOT}${line#/}";;
+ esac
+ done <"${p}"
+ done
+ }
+ # the 'include' command is relative
+ local _oldpwd="$PWD"
+ cd "$ROOT"etc >/dev/null
+ interp=$(elf_interp "${needed_by}")
+ case "$interp" in
+ */ld-musl-*)
+ musl_arch=${interp%.so*}
+ musl_arch=${musl_arch##*-}
+ read_ldso_conf "${ROOT}"etc/ld-musl-${musl_arch}.path
+ ;;
+ */ld-linux*|*/ld.so*) # glibc
read_ldso_conf "${ROOT}"etc/ld.so.conf
- cd "$_oldpwd"
- fi
+ ;;
+ esac
+ cd "$_oldpwd"
fi
if [ -n "${c_ldso_paths}" ] ; then
check_paths "${elf}" "${c_ldso_paths}" && return 0
|