1
0
Fork 0
alistair23-linux/scripts
Masahiro Yamada b7dca6dd1e kbuild: create *.mod with full directory path and remove MODVERDIR
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, commit 551559e13a ("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
commit 3a48a91901 ("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>
2019-07-18 02:19:31 +09:00
..
atomic locking/atomics: Use sed(1) instead of non-standard head(1) option 2019-06-25 10:17:07 +02:00
basic fixdep: check return value of printf() and putchar() 2019-07-01 10:30:39 +09:00
coccinelle coccinelle: api: add devm_platform_ioremap_resource script 2019-07-17 22:37:51 +09:00
dtc Devicetree updates for v5.3: 2019-07-11 18:35:30 -07:00
gcc-plugins gcc-plugins: Handle unusual header environment 2019-05-31 10:26:05 -07:00
gdb kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree 2019-07-11 00:05:09 +09:00
genksyms genksyms: Teach parser about 128-bit built-in types 2019-06-24 03:43:03 +09:00
kconfig kconfig: fix missing choice values in auto.conf 2019-07-17 22:37:51 +09:00
ksymoops Fix dead URLs to ftp.kernel.org 2017-03-28 16:16:52 +02:00
mod kbuild: create *.mod with full directory path and remove MODVERDIR 2019-07-18 02:19:31 +09:00
package kbuild: create *.mod with full directory path and remove MODVERDIR 2019-07-18 02:19:31 +09:00
selinux treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
tracing treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 166 2019-05-30 11:26:39 -07:00
.gitignore scripts: remove unnecessary ihex2fw and check-lc_ctypes from .gitignore 2018-12-22 00:37:52 +09:00
Kbuild.include kbuild: remove unused hostcc-option 2019-07-17 22:37:51 +09:00
Kconfig.include treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Lindent License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile kbuild: remove build_unifdef target in scripts/Makefile 2019-06-15 19:57:01 +09:00
Makefile.asm-generic kbuild: force all architectures except um to include mandatory-y 2019-03-17 12:56:32 +09:00
Makefile.build kbuild: create *.mod with full directory path and remove MODVERDIR 2019-07-18 02:19:31 +09:00
Makefile.clean kbuild: remove deprecated host-progs variable 2018-08-09 21:51:17 +09:00
Makefile.dtbinst DeviceTree for 4.15: 2017-11-14 18:25:40 -08:00
Makefile.extrawarn kbuild: Remove unnecessary -Wno-unused-value 2019-06-24 03:43:03 +09:00
Makefile.gcc-plugins gcc-plugins: structleak: Generalize to all variable types 2019-03-04 09:29:41 -08:00
Makefile.headersinst kbuild: fix 'No such file or directory' warning for headers_install 2019-06-24 03:43:03 +09:00
Makefile.host Kbuild updates for v5.3 2019-07-12 16:03:16 -07:00
Makefile.kasan kasan: remove use after scope bugs detection. 2019-03-05 21:07:13 -08:00
Makefile.kcov treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile.lib kbuild: compile-test headers listed in header-test-m as well 2019-07-17 22:37:51 +09:00
Makefile.modbuiltin kbuild: get rid of kernel/ prefix from in-tree modules.{order,builtin} 2019-07-17 22:39:27 +09:00
Makefile.modinst kbuild: modinst: read modules.order instead of $(MODVERDIR)/*.mod 2019-07-17 22:39:27 +09:00
Makefile.modpost kbuild: create *.mod with full directory path and remove MODVERDIR 2019-07-18 02:19:31 +09:00
Makefile.modsign kbuild: modsign: read modules.order instead of $(MODVERDIR)/*.mod 2019-07-17 22:39:27 +09:00
Makefile.ubsan ubsan: Remove vla bound checks. 2019-05-06 11:12:09 -07:00
adjust_autoksyms.sh kbuild: create *.mod with full directory path and remove MODVERDIR 2019-07-18 02:19:31 +09:00
asn1_compiler.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
bin2c.c kbuild: move bin2c back to scripts/ from scripts/basic/ 2018-07-18 01:18:05 +09:00
bloat-o-meter bloat-o-meter: ignore __addressable_ symbols 2018-12-28 12:11:44 -08:00
bootgraph.pl treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 391 2019-06-05 17:37:11 +02:00
bpf_helpers_doc.py bpf: fix script for generating man page on BPF helpers 2019-05-13 01:12:45 +02:00
cc-can-link.sh bpfilter: check compiler capability in Kconfig 2018-06-28 13:36:39 +09:00
check_extable.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
checkincludes.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
checkkconfigsymbols.py treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 166 2019-05-30 11:26:39 -07:00
checkpatch.pl docs: timers: convert docs to ReST and rename to *.rst 2019-06-14 14:31:48 -06:00
checkstack.pl scripts/checkstack.pl: Fix arm64 wrong or unknown architecture 2019-06-05 02:33:10 +09:00
checksyscalls.sh checksyscalls: fix up mq_timedreceive and stat exceptions 2019-02-19 21:27:53 +01:00
checkversion.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
clang-version.sh kbuild: update comment block of scripts/clang-version.sh 2019-03-04 22:34:54 +09:00
cleanfile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cleanpatch License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
coccicheck coccicheck: return proper error code on fail 2018-08-14 08:58:56 +09:00
config License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
conmakehash.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 54 2019-05-24 17:36:42 +02:00
const_structs.checkpatch const_structs.checkpatch: add frequently used from Julia Lawall's list 2016-10-11 15:06:30 -07:00
decode_stacktrace.sh scripts/decode_stacktrace: Accept dash/underscore in modules 2019-07-12 11:05:41 -07:00
decodecode scripts/decodecode: set ARCH when running natively on arm/arm64 2018-12-28 12:11:44 -08:00
depmod.sh kbuild: modules_install: warn when missing System.map file 2018-09-09 09:14:07 +09:00
diffconfig License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
documentation-file-ref-check scripts/documentation-file-ref-check: ignore output dir 2019-06-14 14:43:01 -06:00
export_report.pl kbuild: export_report: read modules.order instead of .tmp_versions/*.mod 2019-07-18 02:19:31 +09:00
extract-cert.c
extract-ikconfig
extract-module-sig.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
extract-sys-certs.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
extract-vmlinux treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 378 2019-06-05 17:37:10 +02:00
extract_xc3028.pl treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 339 2019-06-05 17:37:07 +02:00
faddr2line scripts/faddr2line: fix location of start_kernel in comment 2018-11-18 10:15:09 -08:00
file-size.sh kbuild: Use ls(1) instead of stat(1) to obtain file size 2018-03-26 02:01:24 +09:00
find-unused-docs.sh scripts: Add a script to find unused documentation 2017-10-23 08:01:37 -06:00
gcc-goto.sh jump_label: move 'asm goto' support test to Kconfig 2019-01-06 09:46:51 +09:00
gcc-ld License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-plugin.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-version.sh kbuild: clean up scripts/gcc-version.sh 2019-03-04 22:35:04 +09:00
gcc-x86_32-has-stack-protector.sh stack-protector: test compiler capability in Kconfig and drop AUTO mode 2018-06-08 18:56:00 +09:00
gcc-x86_64-has-stack-protector.sh stack-protector: Fix test with 32-bit userland and CONFIG_64BIT=y 2018-06-25 23:21:13 +09:00
gen_compile_commands.py scripts: add a tool to produce a compile_commands.json file 2018-12-19 23:41:36 +09:00
gen_ksymdeps.sh kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS 2018-12-01 23:13:14 +09:00
get_abi.pl doc: ABI scripts: add a SPDX header file 2019-06-21 16:58:37 +02:00
get_dvb_firmware treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
get_maintainer.pl get_maintainer: allow option --mpath <directory> to read all files in <directory> 2018-08-22 10:52:48 -07:00
gfp-translate treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 166 2019-05-30 11:26:39 -07:00
headerdep.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
headers_check.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
headers_install.sh kbuild: simplify scripts/headers_install.sh 2019-06-15 19:57:02 +09:00
insert-sys-cert.c KEYS: Reserve an extra certificate symbol for inserting without recompiling 2016-02-26 15:30:20 +00:00
kallsyms.c kallsyms: exclude kasan local symbols on s390 2019-07-08 02:25:59 +09:00
kernel-doc kernel-doc: Don't try to mark up function names 2019-06-26 11:14:15 -06:00
ld-version.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
leaking_addresses.pl treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 166 2019-05-30 11:26:39 -07:00
link-vmlinux.sh Kbuild updates for v5.2 2019-05-08 12:25:12 -07:00
makelst License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
markup_oops.pl treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 373 2019-06-05 17:37:10 +02:00
mkcompile_h kbuild: remove unnecessary in-subshell execution 2019-01-28 09:11:17 +09:00
mkmakefile kbuild: mkmakefile: generate a simple wrapper of top Makefile 2019-04-02 23:27:38 +09:00
mksysmap
mkuboot.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
module-common.lds module: set .init_array alignment to 8 2017-03-13 09:40:28 -07:00
modules-check.sh kbuild: get rid of kernel/ prefix from in-tree modules.{order,builtin} 2019-07-17 22:39:27 +09:00
namespace.pl kbuild: rename built-in.o to built-in.a 2018-03-26 02:01:19 +09:00
objdiff treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 199 2019-05-30 11:29:23 -07:00
parse-maintainers.pl parse-maintainers: add ability to specify filenames 2017-11-17 16:10:01 -08:00
patch-kernel License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pnmtologo.c
profile2linkerlist.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
prune-kernel License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
recordmcount.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 378 2019-06-05 17:37:10 +02:00
recordmcount.h powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
recordmcount.pl treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 166 2019-05-30 11:26:39 -07:00
setlocalversion scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks 2018-11-21 23:57:33 +09:00
show_delta treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 438 2019-06-05 17:37:17 +02:00
sign-file.c sign-file: fix build error in sign-file.c with libressl 2017-02-10 12:43:47 +11:00
sortextable.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 378 2019-06-05 17:37:10 +02:00
sortextable.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 378 2019-06-05 17:37:10 +02:00
spdxcheck-test.sh scripts: add spdxcheck.py self test 2018-12-28 12:11:44 -08:00
spdxcheck.py spdxcheck.py: fix directory structures 2019-06-01 15:51:31 -07:00
spelling.txt scripts/spelling.txt: add more spellings to spelling.txt 2019-07-12 11:05:41 -07:00
sphinx-pre-install scripts/sphinx-pre-install: fix out-of-tree build 2019-06-26 16:08:21 -06:00
split-man.pl MAINTAINERS & files: Canonize the e-mails I use at files 2018-05-04 06:21:06 -04:00
stackdelta License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stackusage License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
subarch.include selftests: add headers_install to lib.mk 2018-09-05 08:12:09 -06:00
tags.sh kbuild: add a flag to force absolute path for srctree 2019-07-11 00:05:09 +09:00
unifdef.c unifdef: use memcpy instead of strncpy 2018-11-30 14:45:01 -08:00
ver_linux ver_linux: Assign constant RE to variable name for clarity 2019-01-22 13:34:35 +01:00
xen-hypercalls.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xz_wrap.sh