Loading...
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
5# as recorded in *.usyms files and the user-provided symbol whitelist.
6
7set -e
8
9# Use "make V=1" to debug this script.
10case "$KBUILD_VERBOSE" in
11*1*)
12 set -x
13 ;;
14esac
15
16read_modorder=
17
18if [ "$1" = --modorder ]; then
19 shift
20 read_modorder=1
21fi
22
23output_file="$1"
24
25needed_symbols=
26
27# Special case for modversions (see modpost.c)
28if grep -q "^CONFIG_MODVERSIONS=y$" include/config/auto.conf; then
29 needed_symbols="$needed_symbols module_layout"
30fi
31
32ksym_wl=$(sed -n 's/^CONFIG_UNUSED_KSYMS_WHITELIST=\(.*\)$/\1/p' include/config/auto.conf)
33if [ -n "$ksym_wl" ]; then
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
39fi
40
41# Generate a new ksym list file with symbols needed by the current
42# set of modules.
43cat > "$output_file" << EOT
44/*
45 * Automatically generated file; DO NOT EDIT.
46 */
47
48EOT
49
50{
51 [ -n "${read_modorder}" ] && sed 's/o$/usyms/' modules.order | xargs cat
52 echo "$needed_symbols"
53 [ -n "$ksym_wl" ] && cat "$ksym_wl"
54} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
55# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry
56# point addresses.
57sed -e 's/^\.//' |
58sort -u |
59# Ignore __this_module. It's not an exported symbol, and will be resolved
60# when the final .ko's are linked.
61grep -v '^__this_module$' |
62sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
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
5# as recorded on the second line of *.mod files and the user-provided symbol
6# whitelist.
7
8set -e
9
10output_file="$1"
11
12# Use "make V=1" to debug this script.
13case "$KBUILD_VERBOSE" in
14*1*)
15 set -x
16 ;;
17esac
18
19# We need access to CONFIG_ symbols
20. include/config/auto.conf
21
22ksym_wl=/dev/null
23if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then
24 # Use 'eval' to expand the whitelist path and check if it is relative
25 eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
26 [ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl"
27 if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then
28 echo "ERROR: '$ksym_wl' whitelist file not found" >&2
29 exit 1
30 fi
31fi
32
33# Generate a new ksym list file with symbols needed by the current
34# set of modules.
35cat > "$output_file" << EOT
36/*
37 * Automatically generated file; DO NOT EDIT.
38 */
39
40EOT
41
42[ -f modules.order ] && modlist=modules.order || modlist=/dev/null
43sed 's/ko$/mod/' $modlist |
44xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- |
45cat - "$ksym_wl" |
46sort -u |
47sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
48
49# Special case for modversions (see modpost.c)
50if [ -n "$CONFIG_MODVERSIONS" ]; then
51 echo "#define __KSYM_module_layout 1" >> "$output_file"
52fi