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

Merge tag 'kbuild-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:
"Kbuild core:
- remove unneeded $(call cc-option,...) switches
- consolidate Clang compiler flags into CLANG_FLAGS
- announce the deprecation of SUBDIRS
- fix single target build for external module
- simplify the dependencies of 'prepare' stage targets
- allow fixdep to directly write to .*.cmd files
- simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS
- change if_changed_rule to accept multi-line recipe
- move .SECONDARY special target to scripts/Kbuild.include
- remove redundant 'set -e'
- improve parallel execution for CONFIG_HEADERS_CHECK
- misc cleanups

Treewide fixes and cleanups
- set Clang flags correctly for PowerPC boot images
- fix UML build error with CONFIG_GCC_PLUGINS
- remove unneeded patterns from .gitignore files
- refactor firmware/Makefile
- remove unneeded rules for *offsets.s
- avoid unneeded regeneration of intermediate .s files
- clean up ./Kbuild

Modpost:
- remove unused -M, -K options
- fix false positive warnings about section mismatch
- use simple devtable lookup instead of linker magic
- misc cleanups

Coccinelle:
- relax boolinit.cocci checks for overall consistency
- fix warning messages of boolinit.cocci

Other tools:
- improve -dirty check of scripts/setlocalversion
- add a tool to generate compile_commands.json from .*.cmd files"

* tag 'kbuild-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (51 commits)
kbuild: remove unused cmd_gentimeconst
kbuild: remove $(obj)/ prefixes in ./Kbuild
treewide: add intermediate .s files to targets
treewide: remove explicit rules for *offsets.s
firmware: refactor firmware/Makefile
firmware: remove unnecessary patterns from .gitignore
scripts: remove unnecessary ihex2fw and check-lc_ctypes from .gitignore
um: remove unused filechk_gen_header in Makefile
scripts: add a tool to produce a compile_commands.json file
kbuild: add -Werror=implicit-int flag unconditionally
kbuild: add -Werror=strict-prototypes flag unconditionally
kbuild: add -fno-PIE flag unconditionally
scripts: coccinelle: Correct warning message
scripts: coccinelle: only suggest true/false in files that already use them
kbuild: handle part-of-module correctly for *.ll and *.symtypes
kbuild: refactor part-of-module
kbuild: refactor quiet_modtag
kbuild: remove redundant quiet_modtag for $(obj-m)
kbuild: refactor Makefile.asm-generic
user/Makefile: Fix typo and capitalization in comment section
...

+541 -560
+1 -6
Documentation/kbuild/kbuild.txt
··· 81 81 -------------------------------------------------- 82 82 Set the directory to look for the kernel source when building external 83 83 modules. 84 - The directory can be specified in several ways: 85 - 1) Use "M=..." on the command line 86 - 2) Environment variable KBUILD_EXTMOD 87 - 3) Environment variable SUBDIRS 88 - The possibilities are listed in the order they take precedence. 89 - Using "M=..." will always override the others. 84 + Setting "M=..." takes precedence over KBUILD_EXTMOD. 90 85 91 86 KBUILD_OUTPUT 92 87 --------------------------------------------------
+5 -16
Kbuild
··· 16 16 always := $(bounds-file) 17 17 targets := kernel/bounds.s 18 18 19 - # We use internal kbuild rules to avoid the "is up to date" message from make 20 - kernel/bounds.s: kernel/bounds.c FORCE 21 - $(call if_changed_dep,cc_s_c) 22 - 23 - $(obj)/$(bounds-file): kernel/bounds.s FORCE 19 + $(bounds-file): kernel/bounds.s FORCE 24 20 $(call filechk,offsets,__LINUX_BOUNDS_H__) 25 21 26 22 ##### ··· 26 30 27 31 targets += $(timeconst-file) 28 32 29 - quiet_cmd_gentimeconst = GEN $@ 30 - define cmd_gentimeconst 31 - (echo $(CONFIG_HZ) | bc -q $< ) > $@ 32 - endef 33 33 define filechk_gentimeconst 34 34 (echo $(CONFIG_HZ) | bc -q $< ) 35 35 endef 36 36 37 - $(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE 37 + $(timeconst-file): kernel/time/timeconst.bc FORCE 38 38 $(call filechk,gentimeconst) 39 39 40 40 ##### ··· 42 50 always += $(offsets-file) 43 51 targets += arch/$(SRCARCH)/kernel/asm-offsets.s 44 52 45 - # We use internal kbuild rules to avoid the "is up to date" message from make 46 - arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ 47 - $(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE 48 - $(call if_changed_dep,cc_s_c) 53 + arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file) 49 54 50 - $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE 55 + $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE 51 56 $(call filechk,offsets,__ASM_OFFSETS_H__) 52 57 53 58 ##### ··· 66 77 67 78 extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py 68 79 69 - build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file) 80 + build_constants_py: $(timeconst-file) $(bounds-file) 70 81 @$(MAKE) $(build)=scripts/gdb/linux $@ 71 82 72 83 # Keep these three files during make clean
+51 -60
Makefile
··· 186 186 # Old syntax make ... SUBDIRS=$PWD is still supported 187 187 # Setting the environment variable KBUILD_EXTMOD take precedence 188 188 ifdef SUBDIRS 189 + $(warning ================= WARNING ================) 190 + $(warning 'SUBDIRS' will be removed after Linux 5.3) 191 + $(warning Please use 'M=' or 'KBUILD_EXTMOD' instead) 192 + $(warning ==========================================) 189 193 KBUILD_EXTMOD ?= $(SUBDIRS) 190 194 endif 191 195 ··· 426 422 -I$(objtree)/include \ 427 423 $(USERINCLUDE) 428 424 429 - KBUILD_AFLAGS := -D__ASSEMBLY__ 430 - KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 431 - -fno-strict-aliasing -fno-common -fshort-wchar \ 432 - -Werror-implicit-function-declaration \ 425 + KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE 426 + KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ 427 + -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ 428 + -Werror-implicit-function-declaration -Werror=implicit-int \ 433 429 -Wno-format-security \ 434 430 -std=gnu89 435 431 KBUILD_CPPFLAGS := -D__KERNEL__ ··· 491 487 492 488 ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) 493 489 ifneq ($(CROSS_COMPILE),) 494 - CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%)) 490 + CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) 495 491 GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) 496 - CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR) 492 + CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) 497 493 GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) 498 494 endif 499 495 ifneq ($(GCC_TOOLCHAIN),) 500 - CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN) 496 + CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) 501 497 endif 502 - KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) 503 - KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) 504 - KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) 505 - KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) 498 + CLANG_FLAGS += -no-integrated-as 499 + KBUILD_CFLAGS += $(CLANG_FLAGS) 500 + KBUILD_AFLAGS += $(CLANG_FLAGS) 501 + export CLANG_FLAGS 506 502 endif 507 503 508 504 RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register ··· 513 509 RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG))) 514 510 export RETPOLINE_CFLAGS 515 511 export RETPOLINE_VDSO_CFLAGS 516 - 517 - KBUILD_CFLAGS += $(call cc-option,-fno-PIE) 518 - KBUILD_AFLAGS += $(call cc-option,-fno-PIE) 519 512 520 513 # check for 'asm goto' 521 514 ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) ··· 829 828 # conserve stack if available 830 829 KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) 831 830 832 - # disallow errors like 'EXPORT_GPL(foo);' with missing header 833 - KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int) 834 - 835 - # require functions to have arguments in prototypes, not empty 'int foo()' 836 - KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes) 837 - 838 831 # Prohibit date/time macros, which would make the build non-deterministic 839 832 KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) 840 833 ··· 1021 1026 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 1022 1027 1023 1028 vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE 1024 - ifdef CONFIG_HEADERS_CHECK 1025 - $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 1026 - endif 1027 1029 ifdef CONFIG_GDB_SCRIPTS 1028 1030 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) 1029 1031 endif 1030 1032 +$(call if_changed,link-vmlinux) 1033 + 1034 + targets := vmlinux 1031 1035 1032 1036 # Build samples along the rest of the kernel. This needs headers_install. 1033 1037 ifdef CONFIG_SAMPLES ··· 1045 1051 # Error messages still appears in the original language 1046 1052 1047 1053 PHONY += $(vmlinux-dirs) 1048 - $(vmlinux-dirs): prepare scripts 1054 + $(vmlinux-dirs): prepare 1049 1055 $(Q)$(MAKE) $(build)=$@ need-builtin=1 1050 1056 1051 1057 define filechk_kernel.release ··· 1060 1066 # Carefully list dependencies so we do not try to build scripts twice 1061 1067 # in parallel 1062 1068 PHONY += scripts 1063 - scripts: scripts_basic scripts_dtc asm-generic gcc-plugins $(autoksyms_h) 1069 + scripts: scripts_basic scripts_dtc 1064 1070 $(Q)$(MAKE) $(build)=$(@) 1065 1071 1066 1072 # Things we need to do before we recursively start building the kernel ··· 1093 1099 prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h 1094 1100 $(cmd_crmodverdir) 1095 1101 1096 - archprepare: archheaders archscripts prepare1 scripts_basic 1102 + archprepare: archheaders archscripts prepare1 scripts 1097 1103 1098 - prepare0: archprepare gcc-plugins 1104 + prepare0: archprepare 1105 + $(Q)$(MAKE) $(build)=scripts/mod 1099 1106 $(Q)$(MAKE) $(build)=. 1100 1107 1101 1108 # All the preparing.. 1102 1109 prepare: prepare0 prepare-objtool 1103 1110 1104 1111 # Support for using generic headers in asm-generic 1112 + asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj 1113 + 1105 1114 PHONY += asm-generic uapi-asm-generic 1106 1115 asm-generic: uapi-asm-generic 1107 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ 1108 - src=asm obj=arch/$(SRCARCH)/include/generated/asm 1116 + $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm 1109 1117 uapi-asm-generic: 1110 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ 1111 - src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm 1118 + $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm 1112 1119 1113 1120 PHONY += prepare-objtool 1114 1121 prepare-objtool: $(objtool_target) ··· 1193 1198 headers_check: headers_install 1194 1199 $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1 1195 1200 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) HDRCHECK=1 1201 + 1202 + ifdef CONFIG_HEADERS_CHECK 1203 + all: headers_check 1204 + endif 1196 1205 1197 1206 # --------------------------------------------------------------------------- 1198 1207 # Kernel selftest ··· 1282 1283 1283 1284 # Target to prepare building external modules 1284 1285 PHONY += modules_prepare 1285 - modules_prepare: prepare scripts 1286 + modules_prepare: prepare 1286 1287 1287 1288 # Target to install modules 1288 1289 PHONY += modules_install ··· 1550 1551 1551 1552 # We are always building modules 1552 1553 KBUILD_MODULES := 1 1553 - PHONY += crmodverdir 1554 - crmodverdir: 1555 - $(cmd_crmodverdir) 1556 1554 1557 1555 PHONY += $(objtree)/Module.symvers 1558 1556 $(objtree)/Module.symvers: ··· 1561 1565 1562 1566 module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) 1563 1567 PHONY += $(module-dirs) modules 1564 - $(module-dirs): crmodverdir $(objtree)/Module.symvers 1568 + $(module-dirs): prepare $(objtree)/Module.symvers 1565 1569 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) 1566 1570 1567 1571 modules: $(module-dirs) ··· 1600 1604 @echo ' clean - remove generated files in module directory only' 1601 1605 @echo '' 1602 1606 1603 - # Dummies... 1604 - PHONY += prepare scripts 1605 - prepare: ; 1606 - scripts: ; 1607 + PHONY += prepare 1608 + prepare: 1609 + $(cmd_crmodverdir) 1607 1610 endif # KBUILD_EXTMOD 1608 1611 1609 1612 clean: $(clean-dirs) ··· 1707 1712 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) 1708 1713 endif 1709 1714 1710 - %.s: %.c prepare scripts FORCE 1715 + %.s: %.c prepare FORCE 1711 1716 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1712 - %.i: %.c prepare scripts FORCE 1717 + %.i: %.c prepare FORCE 1713 1718 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1714 - %.o: %.c prepare scripts FORCE 1719 + %.o: %.c prepare FORCE 1715 1720 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1716 - %.lst: %.c prepare scripts FORCE 1721 + %.lst: %.c prepare FORCE 1717 1722 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1718 - %.s: %.S prepare scripts FORCE 1723 + %.s: %.S prepare FORCE 1719 1724 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1720 - %.o: %.S prepare scripts FORCE 1725 + %.o: %.S prepare FORCE 1721 1726 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1722 - %.symtypes: %.c prepare scripts FORCE 1727 + %.symtypes: %.c prepare FORCE 1723 1728 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1724 - %.ll: %.c prepare scripts FORCE 1729 + %.ll: %.c prepare FORCE 1725 1730 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1726 1731 1727 1732 # Modules 1728 - /: prepare scripts FORCE 1729 - $(cmd_crmodverdir) 1733 + /: prepare FORCE 1730 1734 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1731 1735 $(build)=$(build-dir) 1732 1736 # Make sure the latest headers are built for Documentation 1733 1737 Documentation/ samples/: headers_install 1734 - %/: prepare scripts FORCE 1735 - $(cmd_crmodverdir) 1738 + %/: prepare FORCE 1736 1739 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1737 1740 $(build)=$(build-dir) 1738 - %.ko: prepare scripts FORCE 1739 - $(cmd_crmodverdir) 1741 + %.ko: prepare FORCE 1740 1742 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1741 1743 $(build)=$(build-dir) $(@:.ko=.o) 1742 1744 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost ··· 1757 1765 cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ 1758 1766 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) 1759 1767 1760 - # read all saved command lines 1761 - cmd_files := $(wildcard .*.cmd) 1768 + # read saved command lines for existing targets 1769 + existing-targets := $(wildcard $(sort $(targets))) 1762 1770 1763 - ifneq ($(cmd_files),) 1764 - $(cmd_files): ; # Do not try to update included dependency files 1765 - include $(cmd_files) 1766 - endif 1771 + cmd_files := $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 1772 + $(cmd_files): ; # Do not try to update included dependency files 1773 + -include $(cmd_files) 1767 1774 1768 1775 endif # ifeq ($(config-targets),1) 1769 1776 endif # ifeq ($(mixed-targets),1)
+1 -1
arch/arm/crypto/Makefile
··· 67 67 $(call cmd,perl) 68 68 endif 69 69 70 - targets += sha256-core.S sha512-core.S 70 + clean-files += sha256-core.S sha512-core.S
+2 -3
arch/arm/mach-at91/Makefile
··· 19 19 CFLAGS_pm.o += -DDEBUG 20 20 endif 21 21 22 - arch/arm/mach-at91/pm_data-offsets.s: arch/arm/mach-at91/pm_data-offsets.c 23 - $(call if_changed_dep,cc_s_c) 24 - 25 22 include/generated/at91_pm_data-offsets.h: arch/arm/mach-at91/pm_data-offsets.s FORCE 26 23 $(call filechk,offsets,__PM_DATA_OFFSETS_H__) 27 24 28 25 arch/arm/mach-at91/pm_suspend.o: include/generated/at91_pm_data-offsets.h 26 + 27 + targets += pm_data-offsets.s
+2 -3
arch/arm/mach-omap2/Makefile
··· 236 236 237 237 obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o 238 238 239 - arch/arm/mach-omap2/pm-asm-offsets.s: arch/arm/mach-omap2/pm-asm-offsets.c 240 - $(call if_changed_dep,cc_s_c) 241 - 242 239 include/generated/ti-pm-asm-offsets.h: arch/arm/mach-omap2/pm-asm-offsets.s FORCE 243 240 $(call filechk,offsets,__TI_PM_ASM_OFFSETS_H__) 244 241 245 242 $(obj)/sleep33xx.o $(obj)/sleep43xx.o: include/generated/ti-pm-asm-offsets.h 243 + 244 + targets += pm-asm-offsets.s
+1 -1
arch/arm64/crypto/Makefile
··· 78 78 $(call cmd,perlasm) 79 79 endif 80 80 81 - targets += sha256-core.S sha512-core.S 81 + clean-files += sha256-core.S sha512-core.S
+2 -5
arch/ia64/kernel/Makefile
··· 50 50 # The gate DSO image is built using a special linker script. 51 51 include $(src)/Makefile.gate 52 52 53 - # We use internal kbuild rules to avoid the "is up to date" message from make 54 - arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c 55 - $(Q)mkdir -p $(dir $@) 56 - $(call if_changed_dep,cc_s_c) 57 - 58 53 include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s FORCE 59 54 $(call filechk,offsets,__ASM_NR_IRQS_H__) 55 + 56 + targets += nr-irqs.s
+5
arch/powerpc/boot/Makefile
··· 55 55 56 56 BOOTARFLAGS := -cr$(KBUILD_ARFLAGS) 57 57 58 + ifdef CONFIG_CC_IS_CLANG 59 + BOOTCFLAGS += $(CLANG_FLAGS) 60 + BOOTAFLAGS += $(CLANG_FLAGS) 61 + endif 62 + 58 63 ifdef CONFIG_DEBUG_INFO 59 64 BOOTCFLAGS += -g 60 65 endif
+2 -24
arch/um/Makefile
··· 23 23 # features. 24 24 SHELL := /bin/bash 25 25 26 - filechk_gen_header = $< 27 - 28 26 core-y += $(ARCH_DIR)/kernel/ \ 29 27 $(ARCH_DIR)/drivers/ \ 30 28 $(ARCH_DIR)/os-$(OS)/ ··· 114 116 archheaders: 115 117 $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders 116 118 117 - archprepare: include/generated/user_constants.h 119 + archprepare: 120 + $(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h 118 121 119 122 LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 120 123 LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie) ··· 144 145 archclean: 145 146 @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 146 147 -o -name '*.gcov' \) -type f -print | xargs rm -f 147 - 148 - # Generated files 149 - 150 - $(HOST_DIR)/um/user-offsets.s: __headers FORCE 151 - $(Q)$(MAKE) $(build)=$(HOST_DIR)/um $@ 152 - 153 - define filechk_gen-asm-offsets 154 - (set -e; \ 155 - echo "/*"; \ 156 - echo " * DO NOT MODIFY."; \ 157 - echo " *"; \ 158 - echo " * This file was generated by arch/$(ARCH)/Makefile"; \ 159 - echo " *"; \ 160 - echo " */"; \ 161 - echo ""; \ 162 - sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" < $<; \ 163 - echo ""; ) 164 - endef 165 - 166 - include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s 167 - $(call filechk,gen-asm-offsets) 168 148 169 149 export HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH
+4 -1
arch/x86/um/Makefile
··· 36 36 37 37 USER_OBJS := bugs_$(BITS).o ptrace_user.o fault.o 38 38 39 - extra-y += user-offsets.s 40 39 $(obj)/user-offsets.s: c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ 41 40 -Iarch/x86/include/generated 41 + targets += user-offsets.s 42 + 43 + include/generated/user_constants.h: $(obj)/user-offsets.s 44 + $(call filechk,offsets,__USER_CONSTANT_H__) 42 45 43 46 UNPROFILE_OBJS := stub_segv.o 44 47 CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
+2 -3
drivers/memory/Makefile.asm-offsets
··· 1 - drivers/memory/emif-asm-offsets.s: drivers/memory/emif-asm-offsets.c 2 - $(call if_changed_dep,cc_s_c) 3 - 4 1 include/generated/ti-emif-asm-offsets.h: drivers/memory/emif-asm-offsets.s FORCE 5 2 $(call filechk,offsets,__TI_EMIF_ASM_OFFSETS_H__) 3 + 4 + targets += emif-asm-offsets.s
-7
drivers/mtd/maps/scx200_docflash.c
··· 216 216 217 217 module_init(init_scx200_docflash); 218 218 module_exit(cleanup_scx200_docflash); 219 - 220 - /* 221 - Local variables: 222 - compile-command: "make -k -C ../../.. SUBDIRS=drivers/mtd/maps modules" 223 - c-basic-offset: 8 224 - End: 225 - */
-7
drivers/watchdog/scx200_wdt.c
··· 262 262 263 263 module_init(scx200_wdt_init); 264 264 module_exit(scx200_wdt_cleanup); 265 - 266 - /* 267 - Local variables: 268 - compile-command: "make -k -C ../.. SUBDIRS=drivers/char modules" 269 - c-basic-offset: 8 270 - End: 271 - */
-5
firmware/.gitignore
··· 1 1 *.gen.S 2 - *.fw 3 - *.bin 4 - *.csp 5 - *.dsp 6 - ihex2fw
+28 -48
firmware/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - # 3 - # kbuild file for firmware/ 4 - # 5 2 6 - # Create $(fwabs) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a 3 + # Create $(fwdir) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a 7 4 # leading /, it's relative to $(srctree). 8 5 fwdir := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR)) 9 - fwabs := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir)) 6 + fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir)) 10 7 11 - fw-external-y := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE)) 8 + obj-y := $(addsuffix .gen.o, $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE))) 12 9 13 - quiet_cmd_fwbin = MK_FW $@ 14 - cmd_fwbin = FWNAME="$(patsubst firmware/%.gen.S,%,$@)"; \ 15 - FWSTR="$(subst /,_,$(subst .,_,$(subst -,_,$(patsubst \ 16 - firmware/%.gen.S,%,$@))))"; \ 17 - ASM_WORD=$(if $(CONFIG_64BIT),.quad,.long); \ 18 - ASM_ALIGN=$(if $(CONFIG_64BIT),3,2); \ 19 - PROGBITS=$(if $(CONFIG_ARM),%,@)progbits; \ 20 - echo "/* Generated by firmware/Makefile */" > $@;\ 21 - echo " .section .rodata" >>$@;\ 22 - echo " .p2align $${ASM_ALIGN}" >>$@;\ 23 - echo "_fw_$${FWSTR}_bin:" >>$@;\ 24 - echo " .incbin \"$(2)\"" >>$@;\ 25 - echo "_fw_end:" >>$@;\ 26 - echo " .section .rodata.str,\"aMS\",$${PROGBITS},1" >>$@;\ 27 - echo " .p2align $${ASM_ALIGN}" >>$@;\ 28 - echo "_fw_$${FWSTR}_name:" >>$@;\ 29 - echo " .string \"$$FWNAME\"" >>$@;\ 30 - echo " .section .builtin_fw,\"a\",$${PROGBITS}" >>$@;\ 31 - echo " .p2align $${ASM_ALIGN}" >>$@;\ 32 - echo " $${ASM_WORD} _fw_$${FWSTR}_name" >>$@;\ 33 - echo " $${ASM_WORD} _fw_$${FWSTR}_bin" >>$@;\ 34 - echo " $${ASM_WORD} _fw_end - _fw_$${FWSTR}_bin" >>$@; 10 + FWNAME = $(patsubst $(obj)/%.gen.S,%,$@) 11 + FWSTR = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME)))) 12 + ASM_WORD = $(if $(CONFIG_64BIT),.quad,.long) 13 + ASM_ALIGN = $(if $(CONFIG_64BIT),3,2) 14 + PROGBITS = $(if $(CONFIG_ARM),%,@)progbits 35 15 36 - # One of these files will change, or come into existence, whenever 37 - # the configuration changes between 32-bit and 64-bit. The .S files 38 - # need to change when that happens. 39 - wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h \ 40 - include/config/ppc32.h include/config/ppc64.h \ 41 - include/config/superh32.h include/config/superh64.h \ 42 - include/config/x86_32.h include/config/x86_64.h \ 43 - firmware/Makefile) 16 + filechk_fwbin = { \ 17 + echo "/* Generated by $(src)/Makefile */" ;\ 18 + echo " .section .rodata" ;\ 19 + echo " .p2align $(ASM_ALIGN)" ;\ 20 + echo "_fw_$(FWSTR)_bin:" ;\ 21 + echo " .incbin \"$(fwdir)/$(FWNAME)\"" ;\ 22 + echo "_fw_end:" ;\ 23 + echo " .section .rodata.str,\"aMS\",$(PROGBITS),1" ;\ 24 + echo " .p2align $(ASM_ALIGN)" ;\ 25 + echo "_fw_$(FWSTR)_name:" ;\ 26 + echo " .string \"$(FWNAME)\"" ;\ 27 + echo " .section .builtin_fw,\"a\",$(PROGBITS)" ;\ 28 + echo " .p2align $(ASM_ALIGN)" ;\ 29 + echo " $(ASM_WORD) _fw_$(FWSTR)_name" ;\ 30 + echo " $(ASM_WORD) _fw_$(FWSTR)_bin" ;\ 31 + echo " $(ASM_WORD) _fw_end - _fw_$(FWSTR)_bin" ;\ 32 + } 44 33 45 - $(patsubst %,$(obj)/%.gen.S, $(fw-external-y)): %: $(wordsize_deps) \ 46 - include/config/extra/firmware/dir.h 47 - $(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@)) 34 + $(obj)/%.gen.S: FORCE 35 + $(call filechk,fwbin) 48 36 49 37 # The .o files depend on the binaries directly; the .S files don't. 50 - $(patsubst %,$(obj)/%.gen.o, $(fw-external-y)): $(obj)/%.gen.o: $(fwdir)/% 51 - 52 - obj-y += $(patsubst %,%.gen.o, $(fw-external-y)) 53 - 54 - ifeq ($(KBUILD_SRC),) 55 - # Makefile.build only creates subdirectories for O= builds, but external 56 - # firmware might live outside the kernel source tree 57 - _dummy := $(foreach d,$(addprefix $(obj)/,$(dir $(fw-external-y))), $(shell [ -d $(d) ] || mkdir -p $(d))) 58 - endif 38 + $(addprefix $(obj)/, $(obj-y)): $(obj)/%.gen.o: $(fwdir)/% 59 39 60 40 targets := $(patsubst $(obj)/%,%, \ 61 41 $(shell find $(obj) -name \*.gen.S 2>/dev/null))
+8 -5
include/asm-generic/export.h
··· 59 59 .endm 60 60 #undef __put 61 61 62 - #if defined(__KSYM_DEPS__) 63 - 64 - #define __EXPORT_SYMBOL(sym, val, sec) === __KSYM_##sym === 65 - 66 - #elif defined(CONFIG_TRIM_UNUSED_KSYMS) 62 + #if defined(CONFIG_TRIM_UNUSED_KSYMS) 67 63 68 64 #include <linux/kconfig.h> 69 65 #include <generated/autoksyms.h> 70 66 67 + .macro __ksym_marker sym 68 + .section ".discard.ksym","a" 69 + __ksym_marker_\sym: 70 + .previous 71 + .endm 72 + 71 73 #define __EXPORT_SYMBOL(sym, val, sec) \ 74 + __ksym_marker sym; \ 72 75 __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym)) 73 76 #define __cond_export_sym(sym, val, sec, conf) \ 74 77 ___cond_export_sym(sym, val, sec, conf)
+11 -11
include/linux/export.h
··· 92 92 */ 93 93 #define __EXPORT_SYMBOL(sym, sec) 94 94 95 - #elif defined(__KSYM_DEPS__) 96 - 97 - /* 98 - * For fine grained build dependencies, we want to tell the build system 99 - * about each possible exported symbol even if they're not actually exported. 100 - * We use a string pattern that is unlikely to be valid code that the build 101 - * system filters out from the preprocessor output (see ksym_dep_filter 102 - * in scripts/Kbuild.include). 103 - */ 104 - #define __EXPORT_SYMBOL(sym, sec) === __KSYM_##sym === 105 - 106 95 #elif defined(CONFIG_TRIM_UNUSED_KSYMS) 107 96 108 97 #include <generated/autoksyms.h> 109 98 99 + /* 100 + * For fine grained build dependencies, we want to tell the build system 101 + * about each possible exported symbol even if they're not actually exported. 102 + * We use a symbol pattern __ksym_marker_<symbol> that the build system filters 103 + * from the $(NM) output (see scripts/gen_ksymdeps.sh). These symbols are 104 + * discarded in the final link stage. 105 + */ 106 + #define __ksym_marker(sym) \ 107 + static int __ksym_marker_##sym[0] __section(".discard.ksym") __used 108 + 110 109 #define __EXPORT_SYMBOL(sym, sec) \ 110 + __ksym_marker(sym); \ 111 111 __cond_export_sym(sym, sec, __is_defined(__KSYM_##sym)) 112 112 #define __cond_export_sym(sym, sec, conf) \ 113 113 ___cond_export_sym(sym, sec, conf)
+1 -3
samples/bpf/Makefile
··· 235 235 # Fix up variables inherited from Kbuild that tools/ build system won't like 236 236 $(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O= 237 237 238 - $(obj)/syscall_nrs.s: $(src)/syscall_nrs.c 239 - $(call if_changed_dep,cc_s_c) 240 - 241 238 $(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE 242 239 $(call filechk,offsets,__SYSCALL_NRS_H__) 243 240 241 + targets += syscall_nrs.s 244 242 clean-files += syscall_nrs.h 245 243 246 244 FORCE:
+1 -1
samples/connector/Makefile
··· 14 14 all: modules 15 15 16 16 modules clean: 17 - $(MAKE) -C ../.. SUBDIRS=$(CURDIR) $@ 17 + $(MAKE) -C ../.. M=$(CURDIR) $@
-2
scripts/.gitignore
··· 6 6 kallsyms 7 7 pnmtologo 8 8 unifdef 9 - ihex2fw 10 9 recordmcount 11 - check-lc_ctype 12 10 sortextable 13 11 asn1_compiler 14 12 extract-cert
+10 -42
scripts/Kbuild.include
··· 213 213 echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) 214 214 215 215 # printing commands 216 - cmd = @$(echo-cmd) $(cmd_$(1)) 216 + cmd = @set -e; $(echo-cmd) $(cmd_$(1)) 217 217 218 218 # Add $(obj)/ for paths that are not absolute 219 219 objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) ··· 249 249 250 250 # Execute command if command has changed or prerequisite(s) are updated. 251 251 if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ 252 - @set -e; \ 253 - $(echo-cmd) $(cmd_$(1)); \ 252 + $(cmd); \ 254 253 printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) 255 254 256 255 # Execute the command and also postprocess generated .d dependencies file. 257 - if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ 258 - @set -e; \ 259 - $(cmd_and_fixdep), @:) 260 - 261 - ifndef CONFIG_TRIM_UNUSED_KSYMS 256 + if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),$(cmd_and_fixdep),@:) 262 257 263 258 cmd_and_fixdep = \ 264 - $(echo-cmd) $(cmd_$(1)); \ 265 - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ 266 - rm -f $(depfile); \ 267 - mv -f $(dot-target).tmp $(dot-target).cmd; 268 - 269 - else 270 - 271 - # Filter out exported kernel symbol names from the preprocessor output. 272 - # See also __KSYM_DEPS__ in include/linux/export.h. 273 - # We disable the depfile generation here, so as not to overwrite the existing 274 - # depfile while fixdep is parsing it. 275 - flags_nodeps = $(filter-out -Wp$(comma)-M%, $($(1))) 276 - ksym_dep_filter = \ 277 - case "$(1)" in \ 278 - cc_*_c|cpp_i_c) \ 279 - $(CPP) $(call flags_nodeps,c_flags) -D__KSYM_DEPS__ $< ;; \ 280 - as_*_S|cpp_s_S) \ 281 - $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \ 282 - boot*|build*|cpp_its_S|*cpp_lds_S|dtc|host*|vdso*) : ;; \ 283 - *) echo "Don't know how to preprocess $(1)" >&2; false ;; \ 284 - esac | tr ";" "\n" | sed -n 's/^.*=== __KSYM_\(.*\) ===.*$$/_\1/p' 285 - 286 - cmd_and_fixdep = \ 287 - $(echo-cmd) $(cmd_$(1)); \ 288 - $(ksym_dep_filter) | \ 289 - scripts/basic/fixdep -e $(depfile) $@ '$(make-cmd)' \ 290 - > $(dot-target).tmp; \ 291 - rm -f $(depfile); \ 292 - mv -f $(dot-target).tmp $(dot-target).cmd; 293 - 294 - endif 259 + $(cmd); \ 260 + scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ 261 + rm -f $(depfile) 295 262 296 263 # Usage: $(call if_changed_rule,foo) 297 264 # Will check if $(cmd_foo) or any of the prerequisites changed, 298 265 # and if so will execute $(rule_foo). 299 - if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ 300 - @set -e; \ 301 - $(rule_$(1)), @:) 266 + if_changed_rule = $(if $(strip $(any-prereq) $(arg-check)),$(rule_$(1)),@:) 302 267 303 268 ### 304 269 # why - tell why a target got built ··· 356 391 357 392 # delete partially updated (i.e. corrupted) files on error 358 393 .DELETE_ON_ERROR: 394 + 395 + # do not delete intermediate files automatically 396 + .SECONDARY:
+2 -2
scripts/Makefile
··· 36 36 build_unifdef: $(obj)/unifdef 37 37 @: 38 38 39 + subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins 39 40 subdir-$(CONFIG_MODVERSIONS) += genksyms 40 - subdir-y += mod 41 41 subdir-$(CONFIG_SECURITY_SELINUX) += selinux 42 42 subdir-$(CONFIG_GDB_SCRIPTS) += gdb 43 43 44 44 # Let clean descend into subdirs 45 - subdir- += basic dtc kconfig package gcc-plugins 45 + subdir- += basic dtc kconfig mod package
+19 -18
scripts/Makefile.asm-generic
··· 2 2 # include/asm-generic contains a lot of files that are used 3 3 # verbatim by several architectures. 4 4 # 5 - # This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild 5 + # This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild 6 6 # and for each file listed in this file with generic-y creates 7 - # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src)) 7 + # a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm. 8 8 9 9 PHONY := all 10 10 all: 11 11 12 - kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild 13 - -include $(kbuild-file) 12 + src := $(subst /generated,,$(obj)) 13 + -include $(src)/Kbuild 14 14 15 15 include scripts/Kbuild.include 16 16 17 - # Create output directory if not already present 18 - _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) 17 + generic-y := $(addprefix $(obj)/, $(generic-y)) 18 + generated-y := $(addprefix $(obj)/, $(generated-y)) 19 19 20 - # Stale wrappers when the corresponding files are removed from generic-y 21 - # need removing. 22 - generated-y := $(generic-y) $(generated-y) 23 - all-files := $(patsubst %, $(obj)/%, $(generated-y)) 24 - old-headers := $(wildcard $(obj)/*.h) 25 - unwanted := $(filter-out $(all-files),$(old-headers)) 20 + # Remove stale wrappers when the corresponding files are removed from generic-y 21 + old-headers := $(wildcard $(obj)/*.h) 22 + unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers)) 26 23 27 24 quiet_cmd_wrap = WRAP $@ 28 - cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ 25 + cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@ 29 26 30 27 quiet_cmd_remove = REMOVE $(unwanted) 31 - cmd_remove = rm -f $(unwanted) 28 + cmd_remove = rm -f $(unwanted) 32 29 33 - all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE 34 - $(if $(unwanted),$(call cmd,remove),) 30 + all: $(generic-y) 31 + $(if $(unwanted),$(call cmd,remove)) 35 32 @: 36 33 37 34 $(obj)/%.h: 38 35 $(call cmd,wrap) 39 36 40 - PHONY += FORCE 37 + # Create output directory. Skip it if at least one old header exists 38 + # since we know the output directory already exists. 39 + ifeq ($(old-headers),) 40 + $(shell mkdir -p $(obj)) 41 + endif 42 + 41 43 .PHONY: $(PHONY) 42 - FORCE: ;
+49 -79
scripts/Makefile.build
··· 75 75 # Linus' kernel sanity checking tool 76 76 ifeq ($(KBUILD_CHECKSRC),1) 77 77 quiet_cmd_checksrc = CHECK $< 78 - cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; 78 + cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< 79 79 else ifeq ($(KBUILD_CHECKSRC),2) 80 80 quiet_cmd_force_checksrc = CHECK $< 81 - cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; 81 + cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< 82 82 endif 83 83 84 84 ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) 85 - cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ; 85 + cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< 86 86 endif 87 87 88 88 # Do section mismatch analysis for each module/built-in.a ··· 94 94 # --------------------------------------------------------------------------- 95 95 96 96 # Default is built-in, unless we know otherwise 97 + $(foreach x, i ll lst o s symtypes, $(patsubst %.o,%.$(x),$(real-obj-m))): \ 98 + part-of-module := y 99 + 97 100 modkern_cflags = \ 98 101 $(if $(part-of-module), \ 99 102 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ 100 103 $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) 101 - quiet_modtag := $(empty) $(empty) 102 - 103 - $(real-obj-m) : part-of-module := y 104 - $(real-obj-m:.o=.i) : part-of-module := y 105 - $(real-obj-m:.o=.s) : part-of-module := y 106 - $(real-obj-m:.o=.lst): part-of-module := y 107 - 108 - $(real-obj-m) : quiet_modtag := [M] 109 - $(real-obj-m:.o=.i) : quiet_modtag := [M] 110 - $(real-obj-m:.o=.s) : quiet_modtag := [M] 111 - $(real-obj-m:.o=.lst): quiet_modtag := [M] 112 - 113 - $(obj-m) : quiet_modtag := [M] 104 + quiet_modtag = $(if $(part-of-module),[M], ) 114 105 115 106 quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 116 107 cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< ··· 125 134 126 135 quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ 127 136 cmd_cc_symtypes_c = \ 128 - set -e; \ 129 137 $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ 130 138 test -s $@ || rm -f $@ 131 139 ··· 144 154 # (See cmd_cc_o_c + relevant part of rule_cc_o_c) 145 155 146 156 quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ 157 + cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 147 158 148 - ifndef CONFIG_MODVERSIONS 149 - cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 150 - 151 - else 159 + ifdef CONFIG_MODVERSIONS 152 160 # When module versioning is enabled the following steps are executed: 153 - # o compile a .tmp_<file>.o from <file>.c 154 - # o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does 155 - # not export symbols, we just rename .tmp_<file>.o to <file>.o and 156 - # are done. 161 + # o compile a <file>.o from <file>.c 162 + # o if <file>.o doesn't contain a __ksymtab version, i.e. does 163 + # not export symbols, it's done. 157 164 # o otherwise, we calculate symbol versions using the good old 158 165 # genksyms on the preprocessed source and postprocess them in a way 159 166 # that they are usable as a linker script 160 - # o generate <file>.o from .tmp_<file>.o using the linker to 167 + # o generate .tmp_<file>.o from <file>.o using the linker to 161 168 # replace the unresolved symbols __crc_exported_symbol with 162 169 # the actual value of the checksum generated by genksyms 163 - 164 - cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< 170 + # o remove .tmp_<file>.o to <file>.o 165 171 166 172 cmd_modversions_c = \ 167 - if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ 173 + if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \ 168 174 $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ 169 175 > $(@D)/.tmp_$(@F:.o=.ver); \ 170 176 \ 171 - $(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ 177 + $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \ 172 178 -T $(@D)/.tmp_$(@F:.o=.ver); \ 173 - rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ 174 - else \ 175 179 mv -f $(@D)/.tmp_$(@F) $@; \ 176 - fi; 180 + rm -f $(@D)/.tmp_$(@F:.o=.ver); \ 181 + fi 177 182 endif 178 183 179 184 ifdef CONFIG_FTRACE_MCOUNT_RECORD ··· 189 204 recordmcount_source := $(srctree)/scripts/recordmcount.c \ 190 205 $(srctree)/scripts/recordmcount.h 191 206 else 192 - sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ 207 + sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ 193 208 "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ 194 209 "$(if $(CONFIG_64BIT),64,32)" \ 195 210 "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)" \ ··· 201 216 if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ 202 217 "$(CC_FLAGS_FTRACE)" ]; then \ 203 218 $(sub_cmd_record_mcount) \ 204 - fi; 219 + fi 205 220 endif # CC_USING_RECORD_MCOUNT 206 221 endif # CONFIG_FTRACE_MCOUNT_RECORD 207 222 ··· 224 239 objtool_args += --retpoline 225 240 endif 226 241 227 - 228 - ifdef CONFIG_MODVERSIONS 229 - objtool_o = $(@D)/.tmp_$(@F) 230 - else 231 - objtool_o = $(@) 232 - endif 233 - 234 242 # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory 235 243 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file 236 244 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file 237 245 cmd_objtool = $(if $(patsubst y%,, \ 238 246 $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ 239 - $(__objtool_obj) $(objtool_args) "$(objtool_o)";) 247 + $(__objtool_obj) $(objtool_args) $@) 240 248 objtool_obj = $(if $(patsubst y%,, \ 241 249 $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ 242 250 $(__objtool_obj)) ··· 242 264 $(wildcard include/config/orc/unwinder.h \ 243 265 include/config/stack/validation.h) 244 266 267 + ifdef CONFIG_TRIM_UNUSED_KSYMS 268 + cmd_gen_ksymdeps = \ 269 + $(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd 270 + endif 271 + 245 272 define rule_cc_o_c 246 - $(call echo-cmd,checksrc) $(cmd_checksrc) \ 247 - $(call cmd_and_fixdep,cc_o_c) \ 248 - $(cmd_checkdoc) \ 249 - $(call echo-cmd,objtool) $(cmd_objtool) \ 250 - $(cmd_modversions_c) \ 251 - $(call echo-cmd,record_mcount) $(cmd_record_mcount) 273 + $(call cmd,checksrc) 274 + $(call cmd_and_fixdep,cc_o_c) 275 + $(call cmd,gen_ksymdeps) 276 + $(call cmd,checkdoc) 277 + $(call cmd,objtool) 278 + $(call cmd,modversions_c) 279 + $(call cmd,record_mcount) 252 280 endef 253 281 254 282 define rule_as_o_S 255 - $(call cmd_and_fixdep,as_o_S) \ 256 - $(call echo-cmd,objtool) $(cmd_objtool) \ 257 - $(cmd_modversions_S) 283 + $(call cmd_and_fixdep,as_o_S) 284 + $(call cmd,gen_ksymdeps) 285 + $(call cmd,objtool) 286 + $(call cmd,modversions_S) 258 287 endef 259 288 260 289 # List module undefined symbols (or empty line if not enabled) ··· 325 340 326 341 quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ 327 342 cmd_cc_symtypes_S = \ 328 - set -e; \ 329 343 $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ 330 344 test -s $@ || rm -f $@ 331 345 ··· 339 355 $(call if_changed_dep,cpp_s_S) 340 356 341 357 quiet_cmd_as_o_S = AS $(quiet_modtag) $@ 358 + cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 342 359 343 - ifndef CONFIG_MODVERSIONS 344 - cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 345 - 346 - else 360 + ifdef CONFIG_MODVERSIONS 347 361 348 362 ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h) 349 363 350 - ifeq ($(ASM_PROTOTYPES),) 351 - cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 352 - 353 - else 364 + ifneq ($(ASM_PROTOTYPES),) 354 365 355 366 # versioning matches the C process described above, with difference that 356 367 # we parse asm-prototypes.h C header to get function definitions. 357 368 358 - cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $< 359 - 360 369 cmd_modversions_S = \ 361 - if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ 370 + if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \ 362 371 $(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ 363 372 > $(@D)/.tmp_$(@F:.o=.ver); \ 364 373 \ 365 - $(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ 374 + $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \ 366 375 -T $(@D)/.tmp_$(@F:.o=.ver); \ 367 - rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ 368 - else \ 369 376 mv -f $(@D)/.tmp_$(@F) $@; \ 370 - fi; 377 + rm -f $(@D)/.tmp_$(@F:.o=.ver); \ 378 + fi 371 379 endif 372 380 endif 373 381 ··· 503 527 # optimization, we don't need to read them if the target does not 504 528 # exist, we will rebuild anyway in that case. 505 529 506 - cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) 530 + existing-targets := $(wildcard $(sort $(targets))) 507 531 508 - ifneq ($(cmd_files),) 509 - include $(cmd_files) 510 - endif 532 + -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 511 533 512 534 ifneq ($(KBUILD_SRC),) 513 535 # Create directories for object files if they do not exist 514 536 obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets)))) 515 - # If cmd_files exist, their directories apparently exist. Skip mkdir. 516 - exist-dirs := $(sort $(patsubst %/,%, $(dir $(cmd_files)))) 517 - obj-dirs := $(strip $(filter-out $(exist-dirs), $(obj-dirs))) 537 + # If targets exist, their directories apparently exist. Skip mkdir. 538 + existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets)))) 539 + obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs))) 518 540 ifneq ($(obj-dirs),) 519 541 $(shell mkdir -p $(obj-dirs)) 520 542 endif 521 543 endif 522 - 523 - # Some files contained in $(targets) are intermediate artifacts. 524 - # We never want them to be removed automatically. 525 - .SECONDARY: $(targets) 526 544 527 545 .PHONY: $(PHONY)
-8
scripts/Makefile.gcc-plugins
··· 55 55 # All enabled GCC plugins are collected here for building below. 56 56 GCC_PLUGIN := $(gcc-plugin-y) 57 57 export GCC_PLUGIN 58 - 59 - # Actually do the build, if requested. 60 - PHONY += gcc-plugins 61 - gcc-plugins: scripts_basic 62 - ifdef CONFIG_GCC_PLUGINS 63 - $(Q)$(MAKE) $(build)=scripts/gcc-plugins 64 - endif 65 - @:
-1
scripts/Makefile.headersinst
··· 44 44 installdir := $(INSTALL_HDR_PATH)/$(dst) 45 45 gendir := $(objtree)/$(subst include/,include/generated/,$(obj)) 46 46 header-files := $(notdir $(wildcard $(srcdir)/*.h)) 47 - header-files += $(notdir $(wildcard $(srcdir)/*.agh)) 48 47 header-files := $(filter-out $(no-export-headers), $(header-files)) 49 48 genhdr-files := $(notdir $(wildcard $(gendir)/*.h)) 50 49 genhdr-files := $(filter-out $(header-files), $(genhdr-files))
+1 -1
scripts/Makefile.lib
··· 426 426 # Use filechk to avoid rebuilds when a header changes, but the resulting file 427 427 # does not 428 428 define filechk_offsets 429 - (set -e; \ 429 + ( \ 430 430 echo "#ifndef $2"; \ 431 431 echo "#define $2"; \ 432 432 echo "/*"; \
+4 -27
scripts/basic/fixdep.c
··· 105 105 106 106 static void usage(void) 107 107 { 108 - fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n"); 109 - fprintf(stderr, " -e insert extra dependencies given on stdin\n"); 108 + fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n"); 110 109 exit(1); 111 110 } 112 111 ··· 128 129 prev_c = c; 129 130 } 130 131 printf(".h) \\\n"); 131 - } 132 - 133 - static void do_extra_deps(void) 134 - { 135 - char buf[80]; 136 - 137 - while (fgets(buf, sizeof(buf), stdin)) { 138 - int len = strlen(buf); 139 - 140 - if (len < 2 || buf[len - 1] != '\n') { 141 - fprintf(stderr, "fixdep: bad data on stdin\n"); 142 - exit(1); 143 - } 144 - print_dep(buf, len - 1, "include/ksym"); 145 - } 146 132 } 147 133 148 134 struct item { ··· 277 293 * assignments are parsed not only by make, but also by the rather simple 278 294 * parser in scripts/mod/sumversion.c. 279 295 */ 280 - static void parse_dep_file(char *m, const char *target, int insert_extra_deps) 296 + static void parse_dep_file(char *m, const char *target) 281 297 { 282 298 char *p; 283 299 int is_last, is_target; ··· 353 369 exit(1); 354 370 } 355 371 356 - if (insert_extra_deps) 357 - do_extra_deps(); 358 - 359 372 printf("\n%s: $(deps_%s)\n\n", target, target); 360 373 printf("$(deps_%s):\n", target); 361 374 } ··· 360 379 int main(int argc, char *argv[]) 361 380 { 362 381 const char *depfile, *target, *cmdline; 363 - int insert_extra_deps = 0; 364 382 void *buf; 365 383 366 - if (argc == 5 && !strcmp(argv[1], "-e")) { 367 - insert_extra_deps = 1; 368 - argv++; 369 - } else if (argc != 4) 384 + if (argc != 4) 370 385 usage(); 371 386 372 387 depfile = argv[1]; ··· 372 395 printf("cmd_%s := %s\n\n", target, cmdline); 373 396 374 397 buf = read_file(depfile); 375 - parse_dep_file(buf, target, insert_extra_deps); 398 + parse_dep_file(buf, target); 376 399 free(buf); 377 400 378 401 return 0;
+27 -16
scripts/coccinelle/misc/boolinit.cocci
··· 13 13 virtual org 14 14 virtual report 15 15 16 + @boolok@ 17 + symbol true,false; 18 + @@ 19 + ( 20 + true 21 + | 22 + false 23 + ) 24 + 16 25 @depends on patch@ 17 26 bool t; 18 - symbol true; 19 - symbol false; 20 27 @@ 21 28 22 29 ( ··· 70 63 + t 71 64 ) 72 65 73 - @depends on patch@ 66 + @depends on patch && boolok@ 74 67 bool b; 75 68 @@ 76 69 ( ··· 123 116 * t@p != 0 124 117 ) 125 118 126 - @r3 depends on !patch@ 119 + @r3 depends on !patch && boolok@ 127 120 bool b; 128 - position p1,p2; 129 - constant c; 121 + position p1; 130 122 @@ 131 123 ( 132 124 *b@p1 = 0 133 125 | 134 126 *b@p1 = 1 135 - | 136 - *b@p2 = c 137 127 ) 128 + 129 + @r4 depends on !patch@ 130 + bool b; 131 + position p2; 132 + constant c != {0,1}; 133 + @@ 134 + *b@p2 = c 138 135 139 136 @script:python depends on org@ 140 137 p << r1.p; ··· 150 139 p << r2.p; 151 140 @@ 152 141 153 - cocci.print_main("WARNING: Comparison of bool to 0/1",p) 142 + cocci.print_main("WARNING: Comparison of 0/1 to bool variable",p) 154 143 155 144 @script:python depends on org@ 156 145 p1 << r3.p1; 157 146 @@ 158 147 159 - cocci.print_main("WARNING: Assignment of bool to 0/1",p1) 148 + cocci.print_main("WARNING: Assignment of 0/1 to bool variable",p1) 160 149 161 150 @script:python depends on org@ 162 - p2 << r3.p2; 151 + p2 << r4.p2; 163 152 @@ 164 153 165 - cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2) 154 + cocci.print_main("ERROR: Assignment of non-0/1 constant to bool variable",p2) 166 155 167 156 @script:python depends on report@ 168 157 p << r1.p; ··· 174 163 p << r2.p; 175 164 @@ 176 165 177 - coccilib.report.print_report(p[0],"WARNING: Comparison of bool to 0/1") 166 + coccilib.report.print_report(p[0],"WARNING: Comparison of 0/1 to bool variable") 178 167 179 168 @script:python depends on report@ 180 169 p1 << r3.p1; 181 170 @@ 182 171 183 - coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1") 172 + coccilib.report.print_report(p1[0],"WARNING: Assignment of 0/1 to bool variable") 184 173 185 174 @script:python depends on report@ 186 - p2 << r3.p2; 175 + p2 << r4.p2; 187 176 @@ 188 177 189 - coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant") 178 + coccilib.report.print_report(p2[0],"ERROR: Assignment of non-0/1 constant to bool variable")
+151
scripts/gen_compile_commands.py
··· 1 + #!/usr/bin/env python 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # Copyright (C) Google LLC, 2018 5 + # 6 + # Author: Tom Roeder <tmroeder@google.com> 7 + # 8 + """A tool for generating compile_commands.json in the Linux kernel.""" 9 + 10 + import argparse 11 + import json 12 + import logging 13 + import os 14 + import re 15 + 16 + _DEFAULT_OUTPUT = 'compile_commands.json' 17 + _DEFAULT_LOG_LEVEL = 'WARNING' 18 + 19 + _FILENAME_PATTERN = r'^\..*\.cmd$' 20 + _LINE_PATTERN = r'^cmd_[^ ]*\.o := (.* )([^ ]*\.c)$' 21 + _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] 22 + 23 + # A kernel build generally has over 2000 entries in its compile_commands.json 24 + # database. If this code finds 500 or fewer, then warn the user that they might 25 + # not have all the .cmd files, and they might need to compile the kernel. 26 + _LOW_COUNT_THRESHOLD = 500 27 + 28 + 29 + def parse_arguments(): 30 + """Sets up and parses command-line arguments. 31 + 32 + Returns: 33 + log_level: A logging level to filter log output. 34 + directory: The directory to search for .cmd files. 35 + output: Where to write the compile-commands JSON file. 36 + """ 37 + usage = 'Creates a compile_commands.json database from kernel .cmd files' 38 + parser = argparse.ArgumentParser(description=usage) 39 + 40 + directory_help = ('Path to the kernel source directory to search ' 41 + '(defaults to the working directory)') 42 + parser.add_argument('-d', '--directory', type=str, help=directory_help) 43 + 44 + output_help = ('The location to write compile_commands.json (defaults to ' 45 + 'compile_commands.json in the search directory)') 46 + parser.add_argument('-o', '--output', type=str, help=output_help) 47 + 48 + log_level_help = ('The level of log messages to produce (one of ' + 49 + ', '.join(_VALID_LOG_LEVELS) + '; defaults to ' + 50 + _DEFAULT_LOG_LEVEL + ')') 51 + parser.add_argument( 52 + '--log_level', type=str, default=_DEFAULT_LOG_LEVEL, 53 + help=log_level_help) 54 + 55 + args = parser.parse_args() 56 + 57 + log_level = args.log_level 58 + if log_level not in _VALID_LOG_LEVELS: 59 + raise ValueError('%s is not a valid log level' % log_level) 60 + 61 + directory = args.directory or os.getcwd() 62 + output = args.output or os.path.join(directory, _DEFAULT_OUTPUT) 63 + directory = os.path.abspath(directory) 64 + 65 + return log_level, directory, output 66 + 67 + 68 + def process_line(root_directory, file_directory, command_prefix, relative_path): 69 + """Extracts information from a .cmd line and creates an entry from it. 70 + 71 + Args: 72 + root_directory: The directory that was searched for .cmd files. Usually 73 + used directly in the "directory" entry in compile_commands.json. 74 + file_directory: The path to the directory the .cmd file was found in. 75 + command_prefix: The extracted command line, up to the last element. 76 + relative_path: The .c file from the end of the extracted command. 77 + Usually relative to root_directory, but sometimes relative to 78 + file_directory and sometimes neither. 79 + 80 + Returns: 81 + An entry to append to compile_commands. 82 + 83 + Raises: 84 + ValueError: Could not find the extracted file based on relative_path and 85 + root_directory or file_directory. 86 + """ 87 + # The .cmd files are intended to be included directly by Make, so they 88 + # escape the pound sign '#', either as '\#' or '$(pound)' (depending on the 89 + # kernel version). The compile_commands.json file is not interepreted 90 + # by Make, so this code replaces the escaped version with '#'. 91 + prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#') 92 + 93 + cur_dir = root_directory 94 + expected_path = os.path.join(cur_dir, relative_path) 95 + if not os.path.exists(expected_path): 96 + # Try using file_directory instead. Some of the tools have a different 97 + # style of .cmd file than the kernel. 98 + cur_dir = file_directory 99 + expected_path = os.path.join(cur_dir, relative_path) 100 + if not os.path.exists(expected_path): 101 + raise ValueError('File %s not in %s or %s' % 102 + (relative_path, root_directory, file_directory)) 103 + return { 104 + 'directory': cur_dir, 105 + 'file': relative_path, 106 + 'command': prefix + relative_path, 107 + } 108 + 109 + 110 + def main(): 111 + """Walks through the directory and finds and parses .cmd files.""" 112 + log_level, directory, output = parse_arguments() 113 + 114 + level = getattr(logging, log_level) 115 + logging.basicConfig(format='%(levelname)s: %(message)s', level=level) 116 + 117 + filename_matcher = re.compile(_FILENAME_PATTERN) 118 + line_matcher = re.compile(_LINE_PATTERN) 119 + 120 + compile_commands = [] 121 + for dirpath, _, filenames in os.walk(directory): 122 + for filename in filenames: 123 + if not filename_matcher.match(filename): 124 + continue 125 + filepath = os.path.join(dirpath, filename) 126 + 127 + with open(filepath, 'rt') as f: 128 + for line in f: 129 + result = line_matcher.match(line) 130 + if not result: 131 + continue 132 + 133 + try: 134 + entry = process_line(directory, dirpath, 135 + result.group(1), result.group(2)) 136 + compile_commands.append(entry) 137 + except ValueError as err: 138 + logging.info('Could not add line from %s: %s', 139 + filepath, err) 140 + 141 + with open(output, 'wt') as f: 142 + json.dump(compile_commands, f, indent=2, sort_keys=True) 143 + 144 + count = len(compile_commands) 145 + if count < _LOW_COUNT_THRESHOLD: 146 + logging.warning( 147 + 'Found %s entries. Have you compiled the kernel?', count) 148 + 149 + 150 + if __name__ == '__main__': 151 + main()
+25
scripts/gen_ksymdeps.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + set -e 5 + 6 + # List of exported symbols 7 + ksyms=$($NM $1 | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z) 8 + 9 + if [ -z "$ksyms" ]; then 10 + exit 0 11 + fi 12 + 13 + echo 14 + echo "ksymdeps_$1 := \\" 15 + 16 + for s in $ksyms 17 + do 18 + echo $s | sed -e 's:^_*: $(wildcard include/ksym/:' \ 19 + -e 's:__*:/:g' -e 's/$/.h) \\/' 20 + done 21 + 22 + echo 23 + echo "$1: \$(ksymdeps_$1)" 24 + echo 25 + echo "\$(ksymdeps_$1):"
+51 -98
scripts/mod/file2alias.c
··· 47 47 struct devtable { 48 48 const char *device_id; /* name of table, __mod_<name>__*_device_table. */ 49 49 unsigned long id_size; 50 - void *function; 50 + int (*do_entry)(const char *filename, void *symval, char *alias); 51 51 }; 52 - 53 - #define ___cat(a,b) a ## b 54 - #define __cat(a,b) ___cat(a,b) 55 - 56 - /* we need some special handling for this host tool running eventually on 57 - * Darwin. The Mach-O section handling is a bit different than ELF section 58 - * handling. The differnces in detail are: 59 - * a) we have segments which have sections 60 - * b) we need a API call to get the respective section symbols */ 61 - #if defined(__MACH__) 62 - #include <mach-o/getsect.h> 63 - 64 - #define INIT_SECTION(name) do { \ 65 - unsigned long name ## _len; \ 66 - char *__cat(pstart_,name) = getsectdata("__TEXT", \ 67 - #name, &__cat(name,_len)); \ 68 - char *__cat(pstop_,name) = __cat(pstart_,name) + \ 69 - __cat(name, _len); \ 70 - __cat(__start_,name) = (void *)__cat(pstart_,name); \ 71 - __cat(__stop_,name) = (void *)__cat(pstop_,name); \ 72 - } while (0) 73 - #define SECTION(name) __attribute__((section("__TEXT, " #name))) 74 - 75 - struct devtable **__start___devtable, **__stop___devtable; 76 - #else 77 - #define INIT_SECTION(name) /* no-op for ELF */ 78 - #define SECTION(name) __attribute__((section(#name))) 79 - 80 - /* We construct a table of pointers in an ELF section (pointers generally 81 - * go unpadded by gcc). ld creates boundary syms for us. */ 82 - extern struct devtable *__start___devtable[], *__stop___devtable[]; 83 - #endif /* __MACH__ */ 84 - 85 - #if !defined(__used) 86 - # if __GNUC__ == 3 && __GNUC_MINOR__ < 3 87 - # define __used __attribute__((__unused__)) 88 - # else 89 - # define __used __attribute__((__used__)) 90 - # endif 91 - #endif 92 52 93 53 /* Define a variable f that holds the value of field f of struct devid 94 54 * based at address m. ··· 69 109 */ 70 110 #define DEF_FIELD_ADDR(m, devid, f) \ 71 111 DEF_FIELD_ADDR_VAR(m, devid, f, f) 72 - 73 - /* Add a table entry. We test function type matches while we're here. */ 74 - #define ADD_TO_DEVTABLE(device_id, type, function) \ 75 - static struct devtable __cat(devtable,__LINE__) = { \ 76 - device_id + 0*sizeof((function)((const char *)NULL, \ 77 - (void *)NULL, \ 78 - (char *)NULL)), \ 79 - SIZE_##type, (function) }; \ 80 - static struct devtable *SECTION(__devtable) __used \ 81 - __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) 82 112 83 113 #define ADD(str, sep, cond, field) \ 84 114 do { \ ··· 389 439 390 440 return 1; 391 441 } 392 - ADD_TO_DEVTABLE("hid", hid_device_id, do_hid_entry); 393 442 394 443 /* Looks like: ieee1394:venNmoNspNverN */ 395 444 static int do_ieee1394_entry(const char *filename, ··· 413 464 add_wildcard(alias); 414 465 return 1; 415 466 } 416 - ADD_TO_DEVTABLE("ieee1394", ieee1394_device_id, do_ieee1394_entry); 417 467 418 468 /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ 419 469 static int do_pci_entry(const char *filename, ··· 456 508 add_wildcard(alias); 457 509 return 1; 458 510 } 459 - ADD_TO_DEVTABLE("pci", pci_device_id, do_pci_entry); 460 511 461 512 /* looks like: "ccw:tNmNdtNdmN" */ 462 513 static int do_ccw_entry(const char *filename, ··· 479 532 add_wildcard(alias); 480 533 return 1; 481 534 } 482 - ADD_TO_DEVTABLE("ccw", ccw_device_id, do_ccw_entry); 483 535 484 536 /* looks like: "ap:tN" */ 485 537 static int do_ap_entry(const char *filename, ··· 489 543 sprintf(alias, "ap:t%02X*", dev_type); 490 544 return 1; 491 545 } 492 - ADD_TO_DEVTABLE("ap", ap_device_id, do_ap_entry); 493 546 494 547 /* looks like: "css:tN" */ 495 548 static int do_css_entry(const char *filename, ··· 499 554 sprintf(alias, "css:t%01X", type); 500 555 return 1; 501 556 } 502 - ADD_TO_DEVTABLE("css", css_device_id, do_css_entry); 503 557 504 558 /* Looks like: "serio:tyNprNidNexN" */ 505 559 static int do_serio_entry(const char *filename, ··· 518 574 add_wildcard(alias); 519 575 return 1; 520 576 } 521 - ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); 522 577 523 578 /* looks like: "acpi:ACPI0003" or "acpi:PNP0C0B" or "acpi:LNXVIDEO" or 524 579 * "acpi:bbsspp" (bb=base-class, ss=sub-class, pp=prog-if) ··· 555 612 } 556 613 return 1; 557 614 } 558 - ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); 559 615 560 616 /* looks like: "pnp:dD" */ 561 617 static void do_pnp_device_entry(void *symval, unsigned long size, ··· 678 736 add_wildcard(alias); 679 737 return 1; 680 738 } 681 - ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); 682 739 683 740 static int do_vio_entry(const char *filename, void *symval, 684 741 char *alias) ··· 697 756 add_wildcard(alias); 698 757 return 1; 699 758 } 700 - ADD_TO_DEVTABLE("vio", vio_device_id, do_vio_entry); 701 759 702 760 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 703 761 ··· 769 829 do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX); 770 830 return 1; 771 831 } 772 - ADD_TO_DEVTABLE("input", input_device_id, do_input_entry); 773 832 774 833 static int do_eisa_entry(const char *filename, void *symval, 775 834 char *alias) ··· 780 841 strcat(alias, "*"); 781 842 return 1; 782 843 } 783 - ADD_TO_DEVTABLE("eisa", eisa_device_id, do_eisa_entry); 784 844 785 845 /* Looks like: parisc:tNhvNrevNsvN */ 786 846 static int do_parisc_entry(const char *filename, void *symval, ··· 799 861 add_wildcard(alias); 800 862 return 1; 801 863 } 802 - ADD_TO_DEVTABLE("parisc", parisc_device_id, do_parisc_entry); 803 864 804 865 /* Looks like: sdio:cNvNdN. */ 805 866 static int do_sdio_entry(const char *filename, ··· 815 878 add_wildcard(alias); 816 879 return 1; 817 880 } 818 - ADD_TO_DEVTABLE("sdio", sdio_device_id, do_sdio_entry); 819 881 820 882 /* Looks like: ssb:vNidNrevN. */ 821 883 static int do_ssb_entry(const char *filename, ··· 831 895 add_wildcard(alias); 832 896 return 1; 833 897 } 834 - ADD_TO_DEVTABLE("ssb", ssb_device_id, do_ssb_entry); 835 898 836 899 /* Looks like: bcma:mNidNrevNclN. */ 837 900 static int do_bcma_entry(const char *filename, ··· 849 914 add_wildcard(alias); 850 915 return 1; 851 916 } 852 - ADD_TO_DEVTABLE("bcma", bcma_device_id, do_bcma_entry); 853 917 854 918 /* Looks like: virtio:dNvN */ 855 919 static int do_virtio_entry(const char *filename, void *symval, ··· 864 930 add_wildcard(alias); 865 931 return 1; 866 932 } 867 - ADD_TO_DEVTABLE("virtio", virtio_device_id, do_virtio_entry); 868 933 869 934 /* 870 935 * Looks like: vmbus:guid ··· 886 953 887 954 return 1; 888 955 } 889 - ADD_TO_DEVTABLE("vmbus", hv_vmbus_device_id, do_vmbus_entry); 890 956 891 957 /* Looks like: rpmsg:S */ 892 958 static int do_rpmsg_entry(const char *filename, void *symval, ··· 896 964 897 965 return 1; 898 966 } 899 - ADD_TO_DEVTABLE("rpmsg", rpmsg_device_id, do_rpmsg_entry); 900 967 901 968 /* Looks like: i2c:S */ 902 969 static int do_i2c_entry(const char *filename, void *symval, ··· 906 975 907 976 return 1; 908 977 } 909 - ADD_TO_DEVTABLE("i2c", i2c_device_id, do_i2c_entry); 910 978 911 979 /* Looks like: spi:S */ 912 980 static int do_spi_entry(const char *filename, void *symval, ··· 916 986 917 987 return 1; 918 988 } 919 - ADD_TO_DEVTABLE("spi", spi_device_id, do_spi_entry); 920 989 921 990 static const struct dmifield { 922 991 const char *prefix; ··· 970 1041 strcat(alias, ":"); 971 1042 return 1; 972 1043 } 973 - ADD_TO_DEVTABLE("dmi", dmi_system_id, do_dmi_entry); 974 1044 975 1045 static int do_platform_entry(const char *filename, 976 1046 void *symval, char *alias) ··· 978 1050 sprintf(alias, PLATFORM_MODULE_PREFIX "%s", *name); 979 1051 return 1; 980 1052 } 981 - ADD_TO_DEVTABLE("platform", platform_device_id, do_platform_entry); 982 1053 983 1054 static int do_mdio_entry(const char *filename, 984 1055 void *symval, char *alias) ··· 1002 1075 1003 1076 return 1; 1004 1077 } 1005 - ADD_TO_DEVTABLE("mdio", mdio_device_id, do_mdio_entry); 1006 1078 1007 1079 /* Looks like: zorro:iN. */ 1008 1080 static int do_zorro_entry(const char *filename, void *symval, ··· 1012 1086 ADD(alias, "i", id != ZORRO_WILDCARD, id); 1013 1087 return 1; 1014 1088 } 1015 - ADD_TO_DEVTABLE("zorro", zorro_device_id, do_zorro_entry); 1016 1089 1017 1090 /* looks like: "pnp:dD" */ 1018 1091 static int do_isapnp_entry(const char *filename, ··· 1027 1102 (function >> 12) & 0x0f, (function >> 8) & 0x0f); 1028 1103 return 1; 1029 1104 } 1030 - ADD_TO_DEVTABLE("isapnp", isapnp_device_id, do_isapnp_entry); 1031 1105 1032 1106 /* Looks like: "ipack:fNvNdN". */ 1033 1107 static int do_ipack_entry(const char *filename, ··· 1042 1118 add_wildcard(alias); 1043 1119 return 1; 1044 1120 } 1045 - ADD_TO_DEVTABLE("ipack", ipack_device_id, do_ipack_entry); 1046 1121 1047 1122 /* 1048 1123 * Append a match expression for a single masked hex digit. ··· 1112 1189 1113 1190 return 1; 1114 1191 } 1115 - ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); 1116 1192 1117 1193 /* 1118 1194 * looks like: "mipscdmm:tN" ··· 1127 1205 sprintf(alias, "mipscdmm:t%02X*", type); 1128 1206 return 1; 1129 1207 } 1130 - ADD_TO_DEVTABLE("mipscdmm", mips_cdmm_device_id, do_mips_cdmm_entry); 1131 1208 1132 1209 /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,* 1133 1210 * All fields are numbers. It would be nicer to use strings for vendor ··· 1151 1230 sprintf(alias + strlen(alias), "%04X*", feature); 1152 1231 return 1; 1153 1232 } 1154 - ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); 1155 1233 1156 1234 /* LOOKS like cpu:type:*:feature:*FEAT* */ 1157 1235 static int do_cpu_entry(const char *filename, void *symval, char *alias) ··· 1160 1240 sprintf(alias, "cpu:type:*:feature:*%04X*", feature); 1161 1241 return 1; 1162 1242 } 1163 - ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry); 1164 1243 1165 1244 /* Looks like: mei:S:uuid:N:* */ 1166 1245 static int do_mei_entry(const char *filename, void *symval, ··· 1178 1259 1179 1260 return 1; 1180 1261 } 1181 - ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); 1182 1262 1183 1263 /* Looks like: rapidio:vNdNavNadN */ 1184 1264 static int do_rio_entry(const char *filename, ··· 1197 1279 add_wildcard(alias); 1198 1280 return 1; 1199 1281 } 1200 - ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); 1201 1282 1202 1283 /* Looks like: ulpi:vNpN */ 1203 1284 static int do_ulpi_entry(const char *filename, void *symval, ··· 1209 1292 1210 1293 return 1; 1211 1294 } 1212 - ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry); 1213 1295 1214 1296 /* Looks like: hdaudio:vNrNaN */ 1215 1297 static int do_hda_entry(const char *filename, void *symval, char *alias) ··· 1225 1309 add_wildcard(alias); 1226 1310 return 1; 1227 1311 } 1228 - ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry); 1229 1312 1230 1313 /* Looks like: sdw:mNpN */ 1231 1314 static int do_sdw_entry(const char *filename, void *symval, char *alias) ··· 1239 1324 add_wildcard(alias); 1240 1325 return 1; 1241 1326 } 1242 - ADD_TO_DEVTABLE("sdw", sdw_device_id, do_sdw_entry); 1243 1327 1244 1328 /* Looks like: fsl-mc:vNdN */ 1245 1329 static int do_fsl_mc_entry(const char *filename, void *symval, ··· 1250 1336 sprintf(alias, "fsl-mc:v%08Xd%s", vendor, *obj_type); 1251 1337 return 1; 1252 1338 } 1253 - ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, do_fsl_mc_entry); 1254 1339 1255 1340 /* Looks like: tbsvc:kSpNvNrN */ 1256 1341 static int do_tbsvc_entry(const char *filename, void *symval, char *alias) ··· 1274 1361 add_wildcard(alias); 1275 1362 return 1; 1276 1363 } 1277 - ADD_TO_DEVTABLE("tbsvc", tb_service_id, do_tbsvc_entry); 1278 1364 1279 1365 /* Looks like: typec:idNmN */ 1280 1366 static int do_typec_entry(const char *filename, void *symval, char *alias) ··· 1286 1374 1287 1375 return 1; 1288 1376 } 1289 - ADD_TO_DEVTABLE("typec", typec_device_id, do_typec_entry); 1290 1377 1291 1378 /* Does namelen bytes of name exactly match the symbol? */ 1292 1379 static bool sym_is(const char *name, unsigned namelen, const char *symbol) ··· 1299 1388 static void do_table(void *symval, unsigned long size, 1300 1389 unsigned long id_size, 1301 1390 const char *device_id, 1302 - void *function, 1391 + int (*do_entry)(const char *filename, void *symval, char *alias), 1303 1392 struct module *mod) 1304 1393 { 1305 1394 unsigned int i; 1306 1395 char alias[500]; 1307 - int (*do_entry)(const char *, void *entry, char *alias) = function; 1308 1396 1309 1397 device_id_check(mod->name, device_id, size, id_size, symval); 1310 1398 /* Leave last one: it's the terminator. */ ··· 1316 1406 } 1317 1407 } 1318 1408 } 1409 + 1410 + static const struct devtable devtable[] = { 1411 + {"hid", SIZE_hid_device_id, do_hid_entry}, 1412 + {"ieee1394", SIZE_ieee1394_device_id, do_ieee1394_entry}, 1413 + {"pci", SIZE_pci_device_id, do_pci_entry}, 1414 + {"ccw", SIZE_ccw_device_id, do_ccw_entry}, 1415 + {"ap", SIZE_ap_device_id, do_ap_entry}, 1416 + {"css", SIZE_css_device_id, do_css_entry}, 1417 + {"serio", SIZE_serio_device_id, do_serio_entry}, 1418 + {"acpi", SIZE_acpi_device_id, do_acpi_entry}, 1419 + {"pcmcia", SIZE_pcmcia_device_id, do_pcmcia_entry}, 1420 + {"vio", SIZE_vio_device_id, do_vio_entry}, 1421 + {"input", SIZE_input_device_id, do_input_entry}, 1422 + {"eisa", SIZE_eisa_device_id, do_eisa_entry}, 1423 + {"parisc", SIZE_parisc_device_id, do_parisc_entry}, 1424 + {"sdio", SIZE_sdio_device_id, do_sdio_entry}, 1425 + {"ssb", SIZE_ssb_device_id, do_ssb_entry}, 1426 + {"bcma", SIZE_bcma_device_id, do_bcma_entry}, 1427 + {"virtio", SIZE_virtio_device_id, do_virtio_entry}, 1428 + {"vmbus", SIZE_hv_vmbus_device_id, do_vmbus_entry}, 1429 + {"rpmsg", SIZE_rpmsg_device_id, do_rpmsg_entry}, 1430 + {"i2c", SIZE_i2c_device_id, do_i2c_entry}, 1431 + {"spi", SIZE_spi_device_id, do_spi_entry}, 1432 + {"dmi", SIZE_dmi_system_id, do_dmi_entry}, 1433 + {"platform", SIZE_platform_device_id, do_platform_entry}, 1434 + {"mdio", SIZE_mdio_device_id, do_mdio_entry}, 1435 + {"zorro", SIZE_zorro_device_id, do_zorro_entry}, 1436 + {"isapnp", SIZE_isapnp_device_id, do_isapnp_entry}, 1437 + {"ipack", SIZE_ipack_device_id, do_ipack_entry}, 1438 + {"amba", SIZE_amba_id, do_amba_entry}, 1439 + {"mipscdmm", SIZE_mips_cdmm_device_id, do_mips_cdmm_entry}, 1440 + {"x86cpu", SIZE_x86_cpu_id, do_x86cpu_entry}, 1441 + {"cpu", SIZE_cpu_feature, do_cpu_entry}, 1442 + {"mei", SIZE_mei_cl_device_id, do_mei_entry}, 1443 + {"rapidio", SIZE_rio_device_id, do_rio_entry}, 1444 + {"ulpi", SIZE_ulpi_device_id, do_ulpi_entry}, 1445 + {"hdaudio", SIZE_hda_device_id, do_hda_entry}, 1446 + {"sdw", SIZE_sdw_device_id, do_sdw_entry}, 1447 + {"fslmc", SIZE_fsl_mc_device_id, do_fsl_mc_entry}, 1448 + {"tbsvc", SIZE_tb_service_id, do_tbsvc_entry}, 1449 + {"typec", SIZE_typec_device_id, do_typec_entry}, 1450 + }; 1319 1451 1320 1452 /* Create MODULE_ALIAS() statements. 1321 1453 * At this time, we cannot write the actual output C source yet, ··· 1412 1460 else if (sym_is(name, namelen, "pnp_card")) 1413 1461 do_pnp_card_entries(symval, sym->st_size, mod); 1414 1462 else { 1415 - struct devtable **p; 1416 - INIT_SECTION(__devtable); 1463 + int i; 1417 1464 1418 - for (p = __start___devtable; p < __stop___devtable; p++) { 1419 - if (sym_is(name, namelen, (*p)->device_id)) { 1420 - do_table(symval, sym->st_size, (*p)->id_size, 1421 - (*p)->device_id, (*p)->function, mod); 1465 + for (i = 0; i < ARRAY_SIZE(devtable); i++) { 1466 + const struct devtable *p = &devtable[i]; 1467 + 1468 + if (sym_is(name, namelen, p->device_id)) { 1469 + do_table(symval, sym->st_size, p->id_size, 1470 + p->device_id, p->do_entry, mod); 1422 1471 break; 1423 1472 } 1424 1473 }
+63 -51
scripts/mod/modpost.c
··· 1163 1163 * fromsec = text section 1164 1164 * refsymname = *.constprop.* 1165 1165 * 1166 + * Pattern 6: 1167 + * Hide section mismatch warnings for ELF local symbols. The goal 1168 + * is to eliminate false positive modpost warnings caused by 1169 + * compiler-generated ELF local symbol names such as ".LANCHOR1". 1170 + * Autogenerated symbol names bypass modpost's "Pattern 2" 1171 + * whitelisting, which relies on pattern-matching against symbol 1172 + * names to work. (One situation where gcc can autogenerate ELF 1173 + * local symbols is when "-fsection-anchors" is used.) 1166 1174 **/ 1167 1175 static int secref_whitelist(const struct sectioncheck *mismatch, 1168 1176 const char *fromsec, const char *fromsym, ··· 1209 1201 match(fromsym, optim_symbols)) 1210 1202 return 0; 1211 1203 1204 + /* Check for pattern 6 */ 1205 + if (strstarts(fromsym, ".L")) 1206 + return 0; 1207 + 1212 1208 return 1; 1209 + } 1210 + 1211 + static inline int is_arm_mapping_symbol(const char *str) 1212 + { 1213 + return str[0] == '$' && strchr("axtd", str[1]) 1214 + && (str[2] == '\0' || str[2] == '.'); 1215 + } 1216 + 1217 + /* 1218 + * If there's no name there, ignore it; likewise, ignore it if it's 1219 + * one of the magic symbols emitted used by current ARM tools. 1220 + * 1221 + * Otherwise if find_symbols_between() returns those symbols, they'll 1222 + * fail the whitelist tests and cause lots of false alarms ... fixable 1223 + * only by merging __exit and __init sections into __text, bloating 1224 + * the kernel (which is especially evil on embedded platforms). 1225 + */ 1226 + static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) 1227 + { 1228 + const char *name = elf->strtab + sym->st_name; 1229 + 1230 + if (!name || !strlen(name)) 1231 + return 0; 1232 + return !is_arm_mapping_symbol(name); 1213 1233 } 1214 1234 1215 1235 /** ··· 1265 1229 continue; 1266 1230 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) 1267 1231 continue; 1232 + if (!is_valid_name(elf, sym)) 1233 + continue; 1268 1234 if (sym->st_value == addr) 1269 1235 return sym; 1270 1236 /* Find a symbol nearby - addr are maybe negative */ ··· 1283 1245 return near; 1284 1246 else 1285 1247 return NULL; 1286 - } 1287 - 1288 - static inline int is_arm_mapping_symbol(const char *str) 1289 - { 1290 - return str[0] == '$' && strchr("axtd", str[1]) 1291 - && (str[2] == '\0' || str[2] == '.'); 1292 - } 1293 - 1294 - /* 1295 - * If there's no name there, ignore it; likewise, ignore it if it's 1296 - * one of the magic symbols emitted used by current ARM tools. 1297 - * 1298 - * Otherwise if find_symbols_between() returns those symbols, they'll 1299 - * fail the whitelist tests and cause lots of false alarms ... fixable 1300 - * only by merging __exit and __init sections into __text, bloating 1301 - * the kernel (which is especially evil on embedded platforms). 1302 - */ 1303 - static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) 1304 - { 1305 - const char *name = elf->strtab + sym->st_name; 1306 - 1307 - if (!name || !strlen(name)) 1308 - return 0; 1309 - return !is_arm_mapping_symbol(name); 1310 1248 } 1311 1249 1312 1250 /* ··· 2097 2083 } 2098 2084 } 2099 2085 2100 - static void check_exports(struct module *mod) 2086 + static int check_exports(struct module *mod) 2101 2087 { 2102 2088 struct symbol *s, *exp; 2089 + int err = 0; 2103 2090 2104 2091 for (s = mod->unres; s; s = s->next) { 2105 2092 const char *basename; 2106 2093 exp = find_symbol(s->name); 2107 - if (!exp || exp->module == mod) 2094 + if (!exp || exp->module == mod) { 2095 + if (have_vmlinux && !s->weak) { 2096 + if (warn_unresolved) { 2097 + warn("\"%s\" [%s.ko] undefined!\n", 2098 + s->name, mod->name); 2099 + } else { 2100 + merror("\"%s\" [%s.ko] undefined!\n", 2101 + s->name, mod->name); 2102 + err = 1; 2103 + } 2104 + } 2108 2105 continue; 2106 + } 2109 2107 basename = strrchr(mod->name, '/'); 2110 2108 if (basename) 2111 2109 basename++; ··· 2127 2101 check_for_gpl_usage(exp->export, basename, exp->name); 2128 2102 check_for_unused(exp->export, basename, exp->name); 2129 2103 } 2104 + 2105 + return err; 2130 2106 } 2131 2107 2132 2108 static int check_modname_len(struct module *mod) ··· 2206 2178 2207 2179 for (s = mod->unres; s; s = s->next) { 2208 2180 exp = find_symbol(s->name); 2209 - if (!exp || exp->module == mod) { 2210 - if (have_vmlinux && !s->weak) { 2211 - if (warn_unresolved) { 2212 - warn("\"%s\" [%s.ko] undefined!\n", 2213 - s->name, mod->name); 2214 - } else { 2215 - merror("\"%s\" [%s.ko] undefined!\n", 2216 - s->name, mod->name); 2217 - err = 1; 2218 - } 2219 - } 2181 + if (!exp || exp->module == mod) 2220 2182 continue; 2221 - } 2222 2183 s->module = exp->module; 2223 2184 s->crc_valid = exp->crc_valid; 2224 2185 s->crc = exp->crc; ··· 2244 2227 return err; 2245 2228 } 2246 2229 2247 - static void add_depends(struct buffer *b, struct module *mod, 2248 - struct module *modules) 2230 + static void add_depends(struct buffer *b, struct module *mod) 2249 2231 { 2250 2232 struct symbol *s; 2251 - struct module *m; 2252 2233 int first = 1; 2253 2234 2254 - for (m = modules; m; m = m->next) 2255 - m->seen = is_vmlinux(m->name); 2235 + /* Clear ->seen flag of modules that own symbols needed by this. */ 2236 + for (s = mod->unres; s; s = s->next) 2237 + if (s->module) 2238 + s->module->seen = is_vmlinux(s->module->name); 2256 2239 2257 2240 buf_printf(b, "\n"); 2258 2241 buf_printf(b, "static const char __module_depends[]\n"); ··· 2433 2416 struct ext_sym_list *extsym_iter; 2434 2417 struct ext_sym_list *extsym_start = NULL; 2435 2418 2436 - while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:E")) != -1) { 2419 + while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awE")) != -1) { 2437 2420 switch (opt) { 2438 2421 case 'i': 2439 2422 kernel_read = optarg; ··· 2499 2482 if (files_source) 2500 2483 read_symbols_from_files(files_source); 2501 2484 2502 - for (mod = modules; mod; mod = mod->next) { 2503 - if (mod->skip) 2504 - continue; 2505 - check_exports(mod); 2506 - } 2507 - 2508 2485 err = 0; 2509 2486 2510 2487 for (mod = modules; mod; mod = mod->next) { ··· 2510 2499 buf.pos = 0; 2511 2500 2512 2501 err |= check_modname_len(mod); 2502 + err |= check_exports(mod); 2513 2503 add_header(&buf, mod); 2514 2504 add_intree_flag(&buf, !external_module); 2515 2505 add_retpoline(&buf); 2516 2506 add_staging_flag(&buf, mod->name); 2517 2507 err |= add_versions(&buf, mod); 2518 - add_depends(&buf, mod, modules); 2508 + add_depends(&buf, mod); 2519 2509 add_moddevtable(&buf, mod); 2520 2510 add_srcversion(&buf, mod); 2521 2511
-1
scripts/package/Makefile
··· 33 33 34 34 quiet_cmd_src_tar = TAR $(2).tar.gz 35 35 cmd_src_tar = \ 36 - set -e; \ 37 36 if test "$(objtree)" != "$(srctree)"; then \ 38 37 echo >&2; \ 39 38 echo >&2 " ERROR:"; \
+10 -2
scripts/setlocalversion
··· 73 73 printf -- '-svn%s' "`git svn find-rev $head`" 74 74 fi 75 75 76 - # Check for uncommitted changes 77 - if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then 76 + # Check for uncommitted changes. 77 + # First, with git-status, but --no-optional-locks is only 78 + # supported in git >= 2.14, so fall back to git-diff-index if 79 + # it fails. Note that git-diff-index does not refresh the 80 + # index, so it may give misleading results. See 81 + # git-update-index(1), git-diff-index(1), and git-status(1). 82 + if { 83 + git --no-optional-locks status -uno --porcelain 2>/dev/null || 84 + git diff-index --name-only HEAD 85 + } | grep -qvE '^(.. )?scripts/package'; then 78 86 printf '%s' -dirty 79 87 fi 80 88
+2 -2
usr/Makefile
··· 49 49 50 50 $(deps_initramfs): klibcdirs 51 51 # We rebuild initramfs_data.cpio if: 52 - # 1) Any included file is newer then initramfs_data.cpio 52 + # 1) Any included file is newer than initramfs_data.cpio 53 53 # 2) There are changes in which files are included (added or deleted) 54 54 # 3) If gen_init_cpio are newer than initramfs_data.cpio 55 - # 4) arguments to gen_initramfs.sh changes 55 + # 4) Arguments to gen_initramfs.sh changes 56 56 $(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs 57 57 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) 58 58 $(call if_changed,initfs)