Commit | Line | Data |
---|---|---|
cd195bc4 QP |
1 | #!/bin/sh |
2 | # SPDX-License-Identifier: GPL-2.0-only | |
3 | ||
4 | # Create an autoksyms.h header file from the list of all module's needed symbols | |
9413e764 | 5 | # as recorded in *.usyms files and the user-provided symbol whitelist. |
cd195bc4 QP |
6 | |
7 | set -e | |
8 | ||
cd195bc4 QP |
9 | # Use "make V=1" to debug this script. |
10 | case "$KBUILD_VERBOSE" in | |
11 | *1*) | |
12 | set -x | |
13 | ;; | |
14 | esac | |
15 | ||
9413e764 MY |
16 | read_modorder= |
17 | ||
18 | if [ "$1" = --modorder ]; then | |
19 | shift | |
20 | read_modorder=1 | |
21 | fi | |
22 | ||
23 | output_file="$1" | |
24 | ||
a6aaeb84 MY |
25 | needed_symbols= |
26 | ||
27 | # Special case for modversions (see modpost.c) | |
7d153696 | 28 | if grep -q "^CONFIG_MODVERSIONS=y$" include/config/auto.conf; then |
a6aaeb84 MY |
29 | needed_symbols="$needed_symbols module_layout" |
30 | fi | |
31 | ||
129ab0d2 | 32 | ksym_wl=$(sed -n 's/^CONFIG_UNUSED_KSYMS_WHITELIST=\(.*\)$/\1/p' include/config/auto.conf) |
7d153696 | 33 | if [ -n "$ksym_wl" ]; then |
cd195bc4 QP |
34 | [ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl" |
35 | if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then | |
36 | echo "ERROR: '$ksym_wl' whitelist file not found" >&2 | |
37 | exit 1 | |
38 | fi | |
39 | fi | |
40 | ||
41 | # Generate a new ksym list file with symbols needed by the current | |
42 | # set of modules. | |
43 | cat > "$output_file" << EOT | |
44 | /* | |
45 | * Automatically generated file; DO NOT EDIT. | |
46 | */ | |
47 | ||
48 | EOT | |
49 | ||
a6aaeb84 | 50 | { |
f65a4868 | 51 | [ -n "${read_modorder}" ] && sed 's/o$/usyms/' modules.order | xargs cat |
a6aaeb84 MY |
52 | echo "$needed_symbols" |
53 | [ -n "$ksym_wl" ] && cat "$ksym_wl" | |
54 | } | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' | | |
29500f15 MY |
55 | # Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry |
56 | # point addresses. | |
57 | sed -e 's/^\.//' | | |
cd195bc4 | 58 | sort -u | |
ff139766 ST |
59 | # Ignore __this_module. It's not an exported symbol, and will be resolved |
60 | # when the final .ko's are linked. | |
61 | grep -v '^__this_module$' | | |
cd195bc4 | 62 | sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file" |