-
Notifications
You must be signed in to change notification settings - Fork 14
/
module_checkimports.bash
executable file
·79 lines (61 loc) · 1.56 KB
/
module_checkimports.bash
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
#!/bin/bash
objdump_args=
if [[ "$1" == "-C" ]]; then
objdump_args="$1"
shift
fi
if [[ -z "$1" ]]; then
echo Missing module filename
exit 1
fi
if [[ -z "$OBJDUMP" ]]; then
OBJDUMP=objdump
fi
modules="$@"
scriptroot="$(cd "$(dirname "$0")" && pwd)"
declare -A kernel_syms
while IFS= read -r line; do
kernel_syms+=([$line]=1)
done < <("$scriptroot/kernel_exports.bash" $objdump_args)
echo Found ${#kernel_syms[@]} kernel symbols...
declare -a needed
declare -A syms
failed=
for module in $modules; do
echo Checking $module...
needed=()
# Get the needed modules from the dynamic section using objdump
while IFS= read -r line; do
needed+=("$line")
done < <("$OBJDUMP" -p "$module" |
grep -oP '(?<=NEEDED)\s+\S+\.km' |
grep -oP '\S.*')
syms=()
for sym in "${!kernel_syms[@]}"; do
syms+=([$sym]=1)
done
for need in "${needed[@]}"; do
echo ...needs $need
while IFS= read -r line; do
syms+=([$line]=1)
done < <("$scriptroot/kernel_exports.bash" $objdump_args "$need")
done
#echo ${#syms[@]} symbols available
msg=
while IFS= read -r line; do
if [[ -z "${syms[$line]}" ]]; then
if [[ -z "$msg" ]]; then
echo error: Module $module failed
msg=1
fi
echo Import failure: "$line"
failed=1
fi
done < <("$scriptroot/module_imports.bash" $objdump_args "$module")
done
if [[ -n "$failed" ]]; then
echo errors! failed
exit 1
else
echo good
fi