2020-02-28 17:20:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
|
|
# Create an autoksyms.h header file from the list of all module's needed symbols
|
2022-04-06 15:30:20 +00:00
|
|
|
# as recorded in *.usyms files and the user-provided symbol whitelist.
|
2020-02-28 17:20:14 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Use "make V=1" to debug this script.
|
|
|
|
case "$KBUILD_VERBOSE" in
|
|
|
|
*1*)
|
|
|
|
set -x
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-04-06 15:30:20 +00:00
|
|
|
read_modorder=
|
|
|
|
|
|
|
|
if [ "$1" = --modorder ]; then
|
|
|
|
shift
|
|
|
|
read_modorder=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
output_file="$1"
|
|
|
|
|
2021-02-26 06:25:48 +00:00
|
|
|
needed_symbols=
|
|
|
|
|
|
|
|
# Special case for modversions (see modpost.c)
|
2021-12-14 02:53:52 +00:00
|
|
|
if grep -q "^CONFIG_MODVERSIONS=y$" include/config/auto.conf; then
|
2021-02-26 06:25:48 +00:00
|
|
|
needed_symbols="$needed_symbols module_layout"
|
|
|
|
fi
|
|
|
|
|
kbuild: do not quote string values in include/config/auto.conf
The previous commit fixed up all shell scripts to not include
include/config/auto.conf.
Now that include/config/auto.conf is only included by Makefiles,
we can change it into a more Make-friendly form.
Previously, Kconfig output string values enclosed with double-quotes
(both in the .config and include/config/auto.conf):
CONFIG_X="foo bar"
Unlike shell, Make handles double-quotes (and single-quotes as well)
verbatim. We must rip them off when used.
There are some patterns:
[1] $(patsubst "%",%,$(CONFIG_X))
[2] $(CONFIG_X:"%"=%)
[3] $(subst ",,$(CONFIG_X))
[4] $(shell echo $(CONFIG_X))
These are not only ugly, but also fragile.
[1] and [2] do not work if the value contains spaces, like
CONFIG_X=" foo bar "
[3] does not work correctly if the value contains double-quotes like
CONFIG_X="foo\"bar"
[4] seems to work better, but has a cost of forking a process.
Anyway, quoted strings were always PITA for our Makefiles.
This commit changes Kconfig to stop quoting in include/config/auto.conf.
These are the string type symbols referenced in Makefiles or scripts:
ACPI_CUSTOM_DSDT_FILE
ARC_BUILTIN_DTB_NAME
ARC_TUNE_MCPU
BUILTIN_DTB_SOURCE
CC_IMPLICIT_FALLTHROUGH
CC_VERSION_TEXT
CFG80211_EXTRA_REGDB_KEYDIR
EXTRA_FIRMWARE
EXTRA_FIRMWARE_DIR
EXTRA_TARGETS
H8300_BUILTIN_DTB
INITRAMFS_SOURCE
LOCALVERSION
MODULE_SIG_HASH
MODULE_SIG_KEY
NDS32_BUILTIN_DTB
NIOS2_DTB_SOURCE
OPENRISC_BUILTIN_DTB
SOC_CANAAN_K210_DTB_SOURCE
SYSTEM_BLACKLIST_HASH_LIST
SYSTEM_REVOCATION_KEYS
SYSTEM_TRUSTED_KEYS
TARGET_CPU
UNUSED_KSYMS_WHITELIST
XILINX_MICROBLAZE0_FAMILY
XILINX_MICROBLAZE0_HW_VER
XTENSA_VARIANT_NAME
I checked them one by one, and fixed up the code where necessary.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-12-14 02:53:53 +00:00
|
|
|
ksym_wl=$(sed -n 's/^CONFIG_UNUSED_KSYMS_WHITELIST=\(.*\)$/\1/p' include/config/auto.conf)
|
2021-12-14 02:53:52 +00:00
|
|
|
if [ -n "$ksym_wl" ]; then
|
2020-02-28 17:20:14 +00:00
|
|
|
[ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl"
|
|
|
|
if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then
|
|
|
|
echo "ERROR: '$ksym_wl' whitelist file not found" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Generate a new ksym list file with symbols needed by the current
|
|
|
|
# set of modules.
|
|
|
|
cat > "$output_file" << EOT
|
|
|
|
/*
|
|
|
|
* Automatically generated file; DO NOT EDIT.
|
|
|
|
*/
|
|
|
|
|
|
|
|
EOT
|
|
|
|
|
2021-02-26 06:25:48 +00:00
|
|
|
{
|
2022-04-06 15:30:20 +00:00
|
|
|
[ -n "${read_modorder}" ] && sed 's/ko$/usyms/' modules.order | xargs cat
|
2021-02-26 06:25:48 +00:00
|
|
|
echo "$needed_symbols"
|
|
|
|
[ -n "$ksym_wl" ] && cat "$ksym_wl"
|
|
|
|
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
|
2021-02-11 06:14:16 +00:00
|
|
|
# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry
|
|
|
|
# point addresses.
|
|
|
|
sed -e 's/^\.//' |
|
2020-02-28 17:20:14 +00:00
|
|
|
sort -u |
|
2022-06-16 19:57:59 +00:00
|
|
|
# Ignore __this_module. It's not an exported symbol, and will be resolved
|
|
|
|
# when the final .ko's are linked.
|
|
|
|
grep -v '^__this_module$' |
|
2020-02-28 17:20:14 +00:00
|
|
|
sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
|