scripts/kallsyms: exclude symbols generated by itself dynamically
authorMasahiro Yamada <masahiroy@kernel.org>
Wed, 8 Mar 2023 11:52:39 +0000 (20:52 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Mon, 17 Apr 2023 02:03:56 +0000 (11:03 +0900)
Drop the symbols generated by scripts/kallsyms itself automatically
instead of maintaining the symbol list manually.

Pass the kallsyms object from the previous kallsyms step (if it exists)
as the third parameter of scripts/mksysmap, which will weed out the
generated symbols from the input to the next kallsyms step.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kallsyms.c
scripts/link-vmlinux.sh
scripts/mksysmap

index 8148e880f78e81d522b8567637d246e3286528f4..0325d0d3ce97db170c28ad5711fccddb10cf1887 100644 (file)
@@ -104,22 +104,6 @@ static bool is_ignored_symbol(const char *name, char type)
 {
        /* Symbol names that exactly match to the following are ignored.*/
        static const char * const ignored_symbols[] = {
-               /*
-                * Symbols which vary between passes. Passes 1 and 2 must have
-                * identical symbol lists. The kallsyms_* symbols below are
-                * only added after pass 1, they would be included in pass 2
-                * when --all-symbols is specified so exclude them to get a
-                * stable symbol list.
-                */
-               "kallsyms_addresses",
-               "kallsyms_offsets",
-               "kallsyms_relative_base",
-               "kallsyms_num_syms",
-               "kallsyms_names",
-               "kallsyms_markers",
-               "kallsyms_token_table",
-               "kallsyms_token_index",
-               "kallsyms_seqs_of_names",
                /* Exclude linker generated symbols which vary between passes */
                "_SDA_BASE_",           /* ppc */
                "_SDA2_BASE_",          /* ppc */
index 32e573943cf036bda7d45082779917676b7a05fe..679eb4653b166ee2f4d3ae1e0c45660511eb6ec9 100755 (executable)
@@ -174,7 +174,7 @@ kallsyms_step()
        kallsyms_S=${kallsyms_vmlinux}.S
 
        vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o}
-       mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms
+       mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms ${kallsymso_prev}
        kallsyms ${kallsyms_vmlinux}.syms ${kallsyms_S}
 
        info AS ${kallsyms_S}
@@ -188,7 +188,7 @@ kallsyms_step()
 mksysmap()
 {
        info NM ${2}
-       ${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2}
+       ${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2} ${3}
 }
 
 sorttable()
@@ -277,7 +277,7 @@ if is_enabled CONFIG_DEBUG_INFO_BTF && is_enabled CONFIG_BPF; then
        ${RESOLVE_BTFIDS} vmlinux
 fi
 
-mksysmap vmlinux System.map
+mksysmap vmlinux System.map ${kallsymso}
 
 if is_enabled CONFIG_BUILDTIME_TABLE_SORT; then
        info SORTTAB vmlinux
index 41ad4605aeefddea5c03ac8126ac74f3ae9e7ebf..ff91ec8ecca79d74e4510bb60c40a8cb32b09607 100755 (executable)
@@ -4,7 +4,7 @@
 # tools to retrieve the actual addresses of symbols in the kernel.
 #
 # Usage
-# mksysmap vmlinux System.map
+# mksysmap vmlinux System.map [exclude]
 
 
 #####
@@ -52,4 +52,13 @@ ${NM} -n ${1} | sed >${2} -e "
 
 # for LoongArch?
 / L0$/d
+
+# ---------------------------------------------------------------------------
+# Ignored kallsyms symbols
+#
+# If the 3rd parameter exists, symbols from it will be omitted from the output.
+# This makes kallsyms have the identical symbol lists in the step 1 and 2.
+# Without this, the step2 would get new symbols generated by scripts/kallsyms.c
+# when CONFIG_KALLSYMS_ALL is enabled. That might require one more pass.
+$(if [ $# -ge 3 ]; then ${NM} ${3} | sed -n '/ U /!s:.* \([^ ]*\)$:/ \1$/d:p'; fi)
 "