
While descending directories, Kbuild produces objects for modules, but do not link final *.ko files; it is done in the modpost. To keep track of modules, Kbuild creates a *.mod file in $(MODVERDIR) for every module it is building. Some post-processing steps read the necessary information from *.mod files. This avoids descending into directories again. This mechanism was introduced in 2003 or so. Later, commit551559e13a
("kbuild: implement modules.order") added modules.order. So, we can simply read it out to know all the modules with directory paths. This is easier than parsing the first line of *.mod files. $(MODVERDIR) has a flat directory structure, that is, *.mod files are named only with base names. This is based on the assumption that the module name is unique across the tree. This assumption is really fragile. Stephen Rothwell reported a race condition caused by a module name conflict: https://lkml.org/lkml/2019/5/13/991 In parallel building, two different threads could write to the same $(MODVERDIR)/*.mod simultaneously. Non-unique module names are the source of all kind of troubles, hence commit3a48a91901
("kbuild: check uniqueness of module names") introduced a new checker script. However, it is still fragile in the build system point of view because this race happens before scripts/modules-check.sh is invoked. If it happens again, the modpost will emit unclear error messages. To fix this issue completely, create *.mod with full directory path so that two threads never attempt to write to the same file. $(MODVERDIR) is no longer needed. Since modules with directory paths are listed in modules.order, Kbuild is still able to find *.mod files without additional descending. I also killed cmd_secanalysis; scripts/mod/sumversion.c computes MD4 hash for modules with MODULE_VERSION(). When CONFIG_DEBUG_SECTION_MISMATCH=y, it occurs not only in the modpost stage, but also during directory descending, where sumversion.c may parse stale *.mod files. It would emit 'No such file or directory' warning when an object consisting a module is renamed, or when a single-obj module is turned into a multi-obj module or vice versa. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Nicolas Pitre <nico@fluxnic.net>
2.6 KiB
*.a *.aux *.bc *.bin .bz2 .c.[012]. *.cis *.cpio *.csp *.dsp *.dvi *.elf *.eps *.fw *.gcno *.gcov *.gen.S *.gif *.grep *.grp *.gz .html .i .jpeg .ko .ll .log .lst .lzma .lzo .mo .moc .mod .mod.c .o .o. .order .orig .out .patch .pdf .plist .png .pot .ps .rej .s .sgml .so .so.dbg .symtypes .tab.c .tab.h .tex .ver .xml .xz _MODULES _vga16.c ~ ## .9 . ..d .mm 53c700_d.h CVS ChangeSet GPATH GRTAGS GSYMS GTAGS Image Module.markers Module.symvers PENDING SCCS System.map TAGS aconf af_names.h aic7reg.h aic7reg_print.c aic7seq.h aicasm aicdb.h altivec.c asm-offsets.h asm_offsets.h autoconf.h av_permissions.h bbootsect bin2c binkernel.spec bootsect bounds.h bsetup btfixupprep build bvmlinux bzImage capability_names.h capflags.c classlist.h comp.log compile.h conf config config- config.mak config.mak.autogen conmakehash consolemap_deftbl.c cpustr.h crc32table.h cscope. defkeymap.c devlist.h devicetable-offsets.h dnotify_test dslm dtc elf2ecoff elfconfig.h evergreen_reg_safe.h fixdep flask.h fore200e_mkfirm fore200e_pca_fw.c gconf gconf-cfg gen-devlist gen_crc32table gen_init_cpio generated genheaders genksyms _gray256.c hpet_example hugepage-mmap hugepage-shm ihex2fw inat-tables.c initramfs_list int16.c int1.c int2.c int32.c int4.c int8.c kallsyms keywords.c ksym.c ksym.h lex.c lex..c linux logo_.c logo_clut224.c logo_mono.c mach-types mach-types.h machtypes.h map map_hugetlb mconf mconf-cfg miboot mk_elfconfig mkboot mkbugboot mkcpustr mkdep mkprep mkregtable mktables mktree mkutf8data modpost modules.builtin modules.builtin.modinfo modules.order modversions.h nconf nconf-cfg ncscope. offset.h oui.c page-types parse.c parse.h patches pca200e.bin pca200e_ecd.bin2 perf.data perf.data.old perf-archive piggyback piggy.gzip piggy.S pnmtologo ppc_defs.h pss_boot.h qconf qconf-cfg r100_reg_safe.h r200_reg_safe.h r300_reg_safe.h r420_reg_safe.h r600_reg_safe.h randomize_layout_hash.h randomize_layout_seed.h recordmcount relocs rlim_names.h rn50_reg_safe.h rs600_reg_safe.h rv515_reg_safe.h series setup setup.bin setup.elf sortextable sImage sm_tbl split-include syscalltab.h tables.c tags test_get_len tftpboot.img timeconst.h times.h trix_boot.h utsrelease.h vdso-syms.lds vdso.lds vdso32-int80-syms.lds vdso32-syms.lds vdso32-syscall-syms.lds vdso32-sysenter-syms.lds vdso32.lds vdso32.so.dbg vdso64.lds vdso64.so.dbg version.h vmImage vmlinux vmlinux- vmlinux.aout vmlinux.bin.all vmlinux.lds vmlinuz voffset.h vsyscall.lds vsyscall_32.lds wanxlfw.inc uImage unifdef utf8data.h wakeup.bin wakeup.elf wakeup.lds zImage zoffset.h