Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: split the second line of *.mod into *.usyms

The *.mod files have two lines; the first line lists the member objects
of the module, and the second line, if CONFIG_TRIM_UNUSED_KSYMS=y, lists
the undefined symbols.

Currently, we generate *.mod after constructing composite modules,
otherwise, we cannot compute the second line. No prerequisite is
required to print the first line.

They are orthogonal. Splitting them into separate commands will ease
further cleanups.

This commit splits the list of undefined symbols out to *.usyms files.

Previously, the list of undefined symbols ended up with a very long
line, but now it has one symbol per line.

Use sed like we did before commit 7d32358be8ac ("kbuild: avoid split
lines in .mod files").

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

+25 -26
+1
.gitignore
··· 45 45 *.symversions 46 46 *.tab.[ch] 47 47 *.tar 48 + *.usyms 48 49 *.xz 49 50 *.zst 50 51 Module.symvers
+1 -1
Makefile
··· 1848 1848 -o -name '*.ko.*' \ 1849 1849 -o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ 1850 1850 -o -name '*.dwo' -o -name '*.lst' \ 1851 - -o -name '*.su' -o -name '*.mod' \ 1851 + -o -name '*.su' -o -name '*.mod' -o -name '*.usyms' \ 1852 1852 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1853 1853 -o -name '*.lex.c' -o -name '*.tab.[ch]' \ 1854 1854 -o -name '*.asn1.[ch]' \
+9 -8
scripts/Makefile.build
··· 85 85 targets-for-builtin += $(obj)/built-in.a 86 86 endif 87 87 88 - targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m))) 88 + targets-for-modules := $(foreach x, mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usyms), \ 89 + $(patsubst %.o, %.$x, $(filter %.o, $(obj-m)))) 89 90 90 91 ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),) 91 92 targets-for-modules += $(patsubst %.o, %.prelink.o, $(filter %.o, $(obj-m))) ··· 257 256 ifdef CONFIG_TRIM_UNUSED_KSYMS 258 257 cmd_gen_ksymdeps = \ 259 258 $(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd 260 - 261 - # List module undefined symbols 262 - undefined_syms = $(NM) $< | $(AWK) '$$1 == "U" { printf("%s%s", x++ ? " " : "", $$2) }'; 263 259 endif 264 260 265 261 define rule_cc_o_c ··· 303 305 $(call if_changed,cc_prelink_modules) 304 306 endif 305 307 306 - cmd_mod = { \ 307 - echo $(addprefix $(obj)/, $(call real-search, $*.o, .o, -objs -y -m)); \ 308 - $(undefined_syms) echo; \ 309 - } > $@ 308 + cmd_mod = echo $(addprefix $(obj)/, $(call real-search, $*.o, .o, -objs -y -m)) > $@ 310 309 311 310 $(obj)/%.mod: $(obj)/%$(mod-prelink-ext).o FORCE 312 311 $(call if_changed,mod) 312 + 313 + # List module undefined symbols 314 + cmd_undefined_syms = $(NM) $< | sed -n 's/^ *U //p' > $@ 315 + 316 + $(obj)/%.usyms: $(obj)/%$(mod-prelink-ext).o FORCE 317 + $(call if_changed,undefined_syms) 313 318 314 319 quiet_cmd_cc_lst_c = MKLST $@ 315 320 cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
+1 -1
scripts/adjust_autoksyms.sh
··· 35 35 esac 36 36 37 37 # Generate a new symbol list file 38 - $CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh "$new_ksyms_file" 38 + $CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh --modorder "$new_ksyms_file" 39 39 40 40 # Extract changes between old and new list and touch corresponding 41 41 # dependency files.
+11 -7
scripts/gen_autoksyms.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0-only 3 3 4 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. 5 + # as recorded in *.usyms files and the user-provided symbol whitelist. 7 6 8 7 set -e 9 - 10 - output_file="$1" 11 8 12 9 # Use "make V=1" to debug this script. 13 10 case "$KBUILD_VERBOSE" in ··· 12 15 set -x 13 16 ;; 14 17 esac 18 + 19 + read_modorder= 20 + 21 + if [ "$1" = --modorder ]; then 22 + shift 23 + read_modorder=1 24 + fi 25 + 26 + output_file="$1" 15 27 16 28 needed_symbols= 17 29 ··· 47 41 48 42 EOT 49 43 50 - [ -f modules.order ] && modlist=modules.order || modlist=/dev/null 51 - 52 44 { 53 - sed 's/ko$/mod/' $modlist | xargs -n1 sed -n -e '2p' 45 + [ -n "${read_modorder}" ] && sed 's/ko$/usyms/' modules.order | xargs cat 54 46 echo "$needed_symbols" 55 47 [ -n "$ksym_wl" ] && cat "$ksym_wl" 56 48 } | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
+2 -9
scripts/mod/sumversion.c
··· 387 387 /* Calc and record src checksum. */ 388 388 void get_src_version(const char *modname, char sum[], unsigned sumlen) 389 389 { 390 - char *buf, *pos, *firstline; 390 + char *buf; 391 391 struct md4_ctx md; 392 392 char *fname; 393 393 char filelist[PATH_MAX + 1]; ··· 397 397 398 398 buf = read_text_file(filelist); 399 399 400 - pos = buf; 401 - firstline = get_line(&pos); 402 - if (!firstline) { 403 - warn("bad ending versions file for %s\n", modname); 404 - goto free; 405 - } 406 - 407 400 md4_init(&md); 408 - while ((fname = strsep(&firstline, " "))) { 401 + while ((fname = strsep(&buf, " \n"))) { 409 402 if (!*fname) 410 403 continue; 411 404 if (!(is_static_library(fname)) &&