-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwho_linked
More file actions
executable file
·42 lines (31 loc) · 865 Bytes
/
who_linked
File metadata and controls
executable file
·42 lines (31 loc) · 865 Bytes
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
#!/bin/bash
if [ "$#" -ne 1 ] && [ "$#" -ne 2 ]; then
echo "who_linked [-f] <shared library path>"
echo
exit
fi
if [[ "$1" == "-f" ]]; then
arg_full=true
shift
fi
arg_lib=$(readlink -f $1)
if [[ ! -e $arg_lib ]] ; then
echo "Can't find $arg_lib"
exit 1
fi
for p in /proc/[0-9]*; do
l=$(grep $arg_lib $p/maps 2>/dev/null)
u=$(grep "$arg_lib" $p/maps 2>/dev/null)
[[ "$l" ]] || continue
[[ "$arg_full" = true ]] && info="$(basename $(readlink -f $p/exe))($(basename $p))" \
|| info="$(basename $p)"
if [[ "$l" && "$u" ]] ; then
echo -n "$info "
if [[ "$arg_full" = true ]]; then
libs=$(grep -o 'libupatch_.*.so' $p/maps 2>/dev/null | sort -u | tr '\n' ' ')
[[ "$libs" ]] && echo -n " => $libs"
echo
fi
fi
done
echo