kbuild: fix UNUSED_KSYMS_WHITELIST for Clang LTO
Commitfbe078d397
("kbuild: lto: add a default list of used symbols") does not work as expected if the .config file has already specified CONFIG_UNUSED_KSYMS_WHITELIST="my/own/white/list" before enabling CONFIG_LTO_CLANG. So, the user-supplied whitelist and LTO-specific white list must be independent of each other. I refactored the shell script so CONFIG_MODVERSIONS and CONFIG_CLANG_LTO handle whitelists in the same way. Fixes:fbe078d397
("kbuild: lto: add a default list of used symbols") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
This commit is contained in:
Родитель
da83616bcd
Коммит
a6aaeb8411
|
@ -2283,7 +2283,6 @@ config TRIM_UNUSED_KSYMS
|
||||||
config UNUSED_KSYMS_WHITELIST
|
config UNUSED_KSYMS_WHITELIST
|
||||||
string "Whitelist of symbols to keep in ksymtab"
|
string "Whitelist of symbols to keep in ksymtab"
|
||||||
depends on TRIM_UNUSED_KSYMS
|
depends on TRIM_UNUSED_KSYMS
|
||||||
default "scripts/lto-used-symbollist.txt" if LTO_CLANG
|
|
||||||
help
|
help
|
||||||
By default, all unused exported symbols will be un-exported from the
|
By default, all unused exported symbols will be un-exported from the
|
||||||
build when TRIM_UNUSED_KSYMS is selected.
|
build when TRIM_UNUSED_KSYMS is selected.
|
||||||
|
|
|
@ -19,7 +19,26 @@ esac
|
||||||
# We need access to CONFIG_ symbols
|
# We need access to CONFIG_ symbols
|
||||||
. include/config/auto.conf
|
. include/config/auto.conf
|
||||||
|
|
||||||
ksym_wl=/dev/null
|
needed_symbols=
|
||||||
|
|
||||||
|
# Special case for modversions (see modpost.c)
|
||||||
|
if [ -n "$CONFIG_MODVERSIONS" ]; then
|
||||||
|
needed_symbols="$needed_symbols module_layout"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# With CONFIG_LTO_CLANG, LLVM bitcode has not yet been compiled into a binary
|
||||||
|
# when the .mod files are generated, which means they don't yet contain
|
||||||
|
# references to certain symbols that will be present in the final binaries.
|
||||||
|
if [ -n "$CONFIG_LTO_CLANG" ]; then
|
||||||
|
# intrinsic functions
|
||||||
|
needed_symbols="$needed_symbols memcpy memmove memset"
|
||||||
|
# ftrace
|
||||||
|
needed_symbols="$needed_symbols _mcount"
|
||||||
|
# stack protector symbols
|
||||||
|
needed_symbols="$needed_symbols __stack_chk_fail __stack_chk_guard"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ksym_wl=
|
||||||
if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then
|
if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then
|
||||||
# Use 'eval' to expand the whitelist path and check if it is relative
|
# Use 'eval' to expand the whitelist path and check if it is relative
|
||||||
eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
|
eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
|
||||||
|
@ -40,16 +59,14 @@ cat > "$output_file" << EOT
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
[ -f modules.order ] && modlist=modules.order || modlist=/dev/null
|
[ -f modules.order ] && modlist=modules.order || modlist=/dev/null
|
||||||
sed 's/ko$/mod/' $modlist |
|
|
||||||
xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- |
|
{
|
||||||
cat - "$ksym_wl" |
|
sed 's/ko$/mod/' $modlist | xargs -n1 sed -n -e '2p'
|
||||||
|
echo "$needed_symbols"
|
||||||
|
[ -n "$ksym_wl" ] && cat "$ksym_wl"
|
||||||
|
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
|
||||||
# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry
|
# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry
|
||||||
# point addresses.
|
# point addresses.
|
||||||
sed -e 's/^\.//' |
|
sed -e 's/^\.//' |
|
||||||
sort -u |
|
sort -u |
|
||||||
sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
|
sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
|
||||||
|
|
||||||
# Special case for modversions (see modpost.c)
|
|
||||||
if [ -n "$CONFIG_MODVERSIONS" ]; then
|
|
||||||
echo "#define __KSYM_module_layout 1" >> "$output_file"
|
|
||||||
fi
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
memcpy
|
|
||||||
memmove
|
|
||||||
memset
|
|
||||||
_mcount
|
|
||||||
__stack_chk_fail
|
|
||||||
__stack_chk_guard
|
|
Загрузка…
Ссылка в новой задаче