Pull Kbuild updates from Masahiro Yamada: - Remove the support for -O3 (CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3) - Fix error of rpm-pkg cross-builds - Support riscv for checkstack tool - Re-enable -Wformwat warnings for Clang - Clean up modpost, Makefiles, and misc scripts * tag 'kbuild-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (30 commits) modpost: remove .symbol_white_list field entirely modpost: remove unneeded .symbol_white_list initializers modpost: add PATTERNS() helper macro modpost: shorten warning messages in report_sec_mismatch() Revert "Kbuild, lto, workaround: Don't warn for initcall_reference in modpost" modpost: use more reliable way to get fromsec in section_rel(a)() modpost: add array range check to sec_name() modpost: refactor get_secindex() kbuild: set EXIT trap before creating temporary directory modpost: remove unused Elf_Sword macro Makefile.extrawarn: re-enable -Wformat for clang kbuild: add dtbs_prepare target kconfig: Qt5: tell the user which packages are required modpost: use sym_get_data() to get module device_table data modpost: drop executable ELF support checkstack: add riscv support for scripts/checkstack.pl kconfig: shorten the temporary directory name for cc-option scripts: headers_install.sh: Update config leak ignore entries kbuild: error out if $(INSTALL_MOD_PATH) contains % or : kbuild: error out if $(KBUILD_EXTMOD) contains % or : ...
Unified · Split
| @@ -672,7 +672,7 @@ Future kconfig work · 671 unmodified lines | ||
| 672 | 672 | Work on kconfig is welcomed on both areas of clarifying semantics and on |
| 673 | 673 | evaluating the use of a full SAT solver for it. A full SAT solver can be |
| 674 | 674 | desirable to enable more complex dependency mappings and / or queries, |
| 675 | −for instance on possible use case for a SAT solver could be that of handling | |
| 675 | +for instance one possible use case for a SAT solver could be that of handling | |
| 676 | 676 | the current known recursive dependency issues. It is not known if this would |
| 677 | 677 | address such issues but such evaluation is desirable. If support for a full SAT |
| 678 | 678 | solver proves too complex or that it cannot address recursive dependency issues |
| @@ -4783,7 +4783,6 @@ L: keyrings@vger.kernel.org · 4782 unmodified lines | ||
| 4783 | 4783 | S: Maintained |
| 4784 | 4784 | F: Documentation/admin-guide/module-signing.rst |
| 4785 | 4785 | F: certs/ |
| 4786 | −F: scripts/check-blacklist-hashes.awk | |
| 4787 | 4786 | F: scripts/sign-file.c |
| 4788 | 4787 | F: tools/certs/ |
| 4789 | 4788 | |
| @@ -129,6 +129,9 @@ endif · 128 unmodified lines | ||
| 129 | 129 | $(if $(word 2, $(KBUILD_EXTMOD)), \ |
| 130 | 130 | $(error building multiple external modules is not supported)) |
| 131 | 131 | |
| 132 | +$(foreach x, % :, $(if $(findstring $x, $(KBUILD_EXTMOD)), \ | |
| 133 | + $(error module directory path cannot contain '$x'))) | |
| 134 | + | |
| 132 | 135 | # Remove trailing slashes |
| 133 | 136 | ifneq ($(filter %/, $(KBUILD_EXTMOD)),) |
| 134 | 137 | KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).) |
| @@ -755,8 +758,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) · 620 unmodified lines | ||
| 755 | 758 | |
| 756 | 759 | ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE |
| 757 | 760 | KBUILD_CFLAGS += -O2 |
| 758 | −else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 | |
| 759 | −KBUILD_CFLAGS += -O3 | |
| 760 | 761 | else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE |
| 761 | 762 | KBUILD_CFLAGS += -Os |
| 762 | 763 | endif |
| @@ -1370,16 +1371,21 @@ endif · 607 unmodified lines | ||
| 1370 | 1371 | |
| 1371 | 1372 | ifneq ($(dtstree),) |
| 1372 | 1373 | |
| 1373 | −%.dtb: include/config/kernel.release scripts_dtc | |
| 1374 | +%.dtb: dtbs_prepare | |
| 1374 | 1375 | $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ |
| 1375 | 1376 | |
| 1376 | −%.dtbo: include/config/kernel.release scripts_dtc | |
| 1377 | +%.dtbo: dtbs_prepare | |
| 1377 | 1378 | $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ |
| 1378 | 1379 | |
| 1379 | −PHONY += dtbs dtbs_install dtbs_check | |
| 1380 | −dtbs: include/config/kernel.release scripts_dtc | |
| 1380 | +PHONY += dtbs dtbs_prepare dtbs_install dtbs_check | |
| 1381 | +dtbs: dtbs_prepare | |
| 1381 | 1382 | $(Q)$(MAKE) $(build)=$(dtstree) |
| 1382 | 1383 | |
| 1384 | +# include/config/kernel.release is actually needed when installing DTBs because | |
| 1385 | +# INSTALL_DTBS_PATH contains $(KERNELRELEASE). However, we do not want to make | |
| 1386 | +# dtbs_install depend on it as dtbs_install may run as root. | |
| 1387 | +dtbs_prepare: include/config/kernel.release scripts_dtc | |
| 1388 | + | |
| 1383 | 1389 | ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) |
| 1384 | 1390 | export CHECK_DTBS=y |
| 1385 | 1391 | dtbs: dt_binding_check |
| @@ -9,7 +9,6 @@ CONFIG_NAMESPACES=y · 8 unmodified lines | ||
| 9 | 9 | # CONFIG_UTS_NS is not set |
| 10 | 10 | # CONFIG_PID_NS is not set |
| 11 | 11 | CONFIG_BLK_DEV_INITRD=y |
| 12 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 13 | 12 | CONFIG_EMBEDDED=y |
| 14 | 13 | CONFIG_PERF_EVENTS=y |
| 15 | 14 | # CONFIG_VM_EVENT_COUNTERS is not set |
| @@ -9,7 +9,6 @@ CONFIG_NAMESPACES=y · 8 unmodified lines | ||
| 9 | 9 | # CONFIG_UTS_NS is not set |
| 10 | 10 | # CONFIG_PID_NS is not set |
| 11 | 11 | CONFIG_BLK_DEV_INITRD=y |
| 12 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 13 | 12 | CONFIG_EMBEDDED=y |
| 14 | 13 | CONFIG_PERF_EVENTS=y |
| 15 | 14 | # CONFIG_VM_EVENT_COUNTERS is not set |
| @@ -9,7 +9,6 @@ CONFIG_NAMESPACES=y · 8 unmodified lines | ||
| 9 | 9 | # CONFIG_UTS_NS is not set |
| 10 | 10 | # CONFIG_PID_NS is not set |
| 11 | 11 | CONFIG_BLK_DEV_INITRD=y |
| 12 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 13 | 12 | CONFIG_EMBEDDED=y |
| 14 | 13 | CONFIG_PERF_EVENTS=y |
| 15 | 14 | # CONFIG_VM_EVENT_COUNTERS is not set |
| @@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y · 10 unmodified lines | ||
| 11 | 11 | # CONFIG_UTS_NS is not set |
| 12 | 12 | # CONFIG_PID_NS is not set |
| 13 | 13 | CONFIG_BLK_DEV_INITRD=y |
| 14 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 15 | 14 | CONFIG_EXPERT=y |
| 16 | 15 | CONFIG_PERF_EVENTS=y |
| 17 | 16 | # CONFIG_COMPAT_BRK is not set |
| @@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y · 10 unmodified lines | ||
| 11 | 11 | # CONFIG_UTS_NS is not set |
| 12 | 12 | # CONFIG_PID_NS is not set |
| 13 | 13 | CONFIG_BLK_DEV_INITRD=y |
| 14 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 15 | 14 | CONFIG_EMBEDDED=y |
| 16 | 15 | CONFIG_PERF_EVENTS=y |
| 17 | 16 | # CONFIG_VM_EVENT_COUNTERS is not set |
| @@ -9,7 +9,6 @@ CONFIG_NAMESPACES=y · 8 unmodified lines | ||
| 9 | 9 | # CONFIG_PID_NS is not set |
| 10 | 10 | CONFIG_BLK_DEV_INITRD=y |
| 11 | 11 | CONFIG_BLK_DEV_RAM=y |
| 12 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 13 | 12 | CONFIG_EMBEDDED=y |
| 14 | 13 | CONFIG_PERF_EVENTS=y |
| 15 | 14 | # CONFIG_VM_EVENT_COUNTERS is not set |
| @@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y · 10 unmodified lines | ||
| 11 | 11 | # CONFIG_UTS_NS is not set |
| 12 | 12 | # CONFIG_PID_NS is not set |
| 13 | 13 | CONFIG_BLK_DEV_INITRD=y |
| 14 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 15 | 14 | CONFIG_KALLSYMS_ALL=y |
| 16 | 15 | CONFIG_EMBEDDED=y |
| 17 | 16 | CONFIG_PERF_EVENTS=y |
| @@ -10,7 +10,6 @@ CONFIG_NAMESPACES=y · 9 unmodified lines | ||
| 10 | 10 | # CONFIG_UTS_NS is not set |
| 11 | 11 | # CONFIG_PID_NS is not set |
| 12 | 12 | CONFIG_BLK_DEV_INITRD=y |
| 13 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 14 | 13 | CONFIG_KALLSYMS_ALL=y |
| 15 | 14 | CONFIG_EMBEDDED=y |
| 16 | 15 | CONFIG_PERF_EVENTS=y |
| @@ -10,7 +10,6 @@ CONFIG_NAMESPACES=y · 9 unmodified lines | ||
| 10 | 10 | # CONFIG_UTS_NS is not set |
| 11 | 11 | # CONFIG_PID_NS is not set |
| 12 | 12 | CONFIG_BLK_DEV_INITRD=y |
| 13 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 14 | 13 | CONFIG_KALLSYMS_ALL=y |
| 15 | 14 | CONFIG_EMBEDDED=y |
| 16 | 15 | CONFIG_PERF_EVENTS=y |
| @@ -8,7 +8,6 @@ CONFIG_IKCONFIG_PROC=y · 7 unmodified lines | ||
| 8 | 8 | # CONFIG_UTS_NS is not set |
| 9 | 9 | # CONFIG_PID_NS is not set |
| 10 | 10 | CONFIG_BLK_DEV_INITRD=y |
| 11 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 12 | 11 | CONFIG_PERF_EVENTS=y |
| 13 | 12 | # CONFIG_COMPAT_BRK is not set |
| 14 | 13 | CONFIG_KPROBES=y |
| @@ -14,7 +14,6 @@ CONFIG_INITRAMFS_SOURCE="../tb10x-rootfs.cpio" · 13 unmodified lines | ||
| 14 | 14 | CONFIG_INITRAMFS_ROOT_UID=2100 |
| 15 | 15 | CONFIG_INITRAMFS_ROOT_GID=501 |
| 16 | 16 | # CONFIG_RD_GZIP is not set |
| 17 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 18 | 17 | CONFIG_KALLSYMS_ALL=y |
| 19 | 18 | # CONFIG_AIO is not set |
| 20 | 19 | CONFIG_EMBEDDED=y |
| @@ -4,7 +4,6 @@ CONFIG_HIGH_RES_TIMERS=y · 3 unmodified lines | ||
| 4 | 4 | CONFIG_IKCONFIG=y |
| 5 | 5 | CONFIG_IKCONFIG_PROC=y |
| 6 | 6 | CONFIG_BLK_DEV_INITRD=y |
| 7 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 8 | 7 | CONFIG_EMBEDDED=y |
| 9 | 8 | CONFIG_PERF_EVENTS=y |
| 10 | 9 | # CONFIG_VM_EVENT_COUNTERS is not set |
| @@ -4,7 +4,6 @@ CONFIG_HIGH_RES_TIMERS=y · 3 unmodified lines | ||
| 4 | 4 | CONFIG_IKCONFIG=y |
| 5 | 5 | CONFIG_IKCONFIG_PROC=y |
| 6 | 6 | CONFIG_BLK_DEV_INITRD=y |
| 7 | −CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y | |
| 8 | 7 | CONFIG_EMBEDDED=y |
| 9 | 8 | CONFIG_PERF_EVENTS=y |
| 10 | 9 | # CONFIG_VM_EVENT_COUNTERS is not set |
| @@ -4,24 +4,22 @@ · 3 unmodified lines | ||
| 4 | 4 | # |
| 5 | 5 | |
| 6 | 6 | obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o |
| 7 | −obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o | |
| 7 | +obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o blacklist_hashes.o | |
| 8 | 8 | obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revocation_certificates.o |
| 9 | −ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),) | |
| 10 | 9 | |
| 11 | 10 | $(obj)/blacklist_hashes.o: $(obj)/blacklist_hash_list |
| 12 | 11 | CFLAGS_blacklist_hashes.o := -I $(obj) |
| 13 | 12 | |
| 14 | 13 | quiet_cmd_check_and_copy_blacklist_hash_list = GEN $@ |
| 15 | 14 | cmd_check_and_copy_blacklist_hash_list = \ |
| 16 | − $(AWK) -f $(srctree)/scripts/check-blacklist-hashes.awk $(CONFIG_SYSTEM_BLACKLIST_HASH_LIST) >&2; \ | |
| 17 | − cat $(CONFIG_SYSTEM_BLACKLIST_HASH_LIST) > $@ | |
| 15 | + $(if $(CONFIG_SYSTEM_BLACKLIST_HASH_LIST), \ | |
| 16 | + $(AWK) -f $(srctree)/$(src)/check-blacklist-hashes.awk $(CONFIG_SYSTEM_BLACKLIST_HASH_LIST) >&2; \ | |
| 17 | + { cat $(CONFIG_SYSTEM_BLACKLIST_HASH_LIST); echo $(comma) NULL; } > $@, \ | |
| 18 | + echo NULL > $@) | |
| 18 | 19 | |
| 19 | 20 | $(obj)/blacklist_hash_list: $(CONFIG_SYSTEM_BLACKLIST_HASH_LIST) FORCE |
| 20 | 21 | $(call if_changed,check_and_copy_blacklist_hash_list) |
| 21 | −obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_hashes.o | |
| 22 | −else | |
| 23 | −obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_nohashes.o | |
| 24 | −endif | |
| 22 | + | |
| 25 | 23 | targets += blacklist_hash_list |
| 26 | 24 | |
| 27 | 25 | quiet_cmd_extract_certs = CERT $@ |
| @@ -3,5 +3,4 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | const char __initconst *const blacklist_hashes[] = { |
| 5 | 5 | #include "blacklist_hash_list" |
| 6 | − , NULL | |
| 7 | 6 | }; |
| @@ -1,6 +0,0 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0 | |
| 2 | −#include "blacklist.h" | |
| 3 | − | |
| 4 | −const char __initconst *const blacklist_hashes[] = { | |
| 5 | − NULL | |
| 6 | −}; | |
File renamed without changes.
| @@ -1411,13 +1411,6 @@ config CC_OPTIMIZE_FOR_PERFORMANCE · 1410 unmodified lines | ||
| 1411 | 1411 | with the "-O2" compiler flag for best performance and most |
| 1412 | 1412 | helpful compile-time warnings. |
| 1413 | 1413 | |
| 1414 | −config CC_OPTIMIZE_FOR_PERFORMANCE_O3 | |
| 1415 | − bool "Optimize more for performance (-O3)" | |
| 1416 | − depends on ARC | |
| 1417 | − help | |
| 1418 | − Choosing this option will pass "-O3" to your compiler to optimize | |
| 1419 | − the kernel yet more for performance. | |
| 1420 | − | |
| 1421 | 1414 | config CC_OPTIMIZE_FOR_SIZE |
| 1422 | 1415 | bool "Optimize for size (-Os)" |
| 1423 | 1416 | help |
| @@ -1733,16 +1726,17 @@ config KALLSYMS_ALL · 309 unmodified lines | ||
| 1733 | 1726 | help |
| 1734 | 1727 | Normally kallsyms only contains the symbols of functions for nicer |
| 1735 | 1728 | OOPS messages and backtraces (i.e., symbols from the text and inittext |
| 1736 | − sections). This is sufficient for most cases. And only in very rare | |
| 1737 | − cases (e.g., when a debugger is used) all symbols are required (e.g., | |
| 1738 | − names of variables from the data sections, etc). | |
| 1729 | + sections). This is sufficient for most cases. And only if you want to | |
| 1730 | + enable kernel live patching, or other less common use cases (e.g., | |
| 1731 | + when a debugger is used) all symbols are required (i.e., names of | |
| 1732 | + variables from the data sections, etc). | |
| 1739 | 1733 | |
| 1740 | 1734 | This option makes sure that all symbols are loaded into the kernel |
| 1741 | 1735 | image (i.e., symbols from all sections) in cost of increased kernel |
| 1742 | 1736 | size (depending on the kernel configuration, it may be 300KiB or |
| 1743 | 1737 | something like this). |
| 1744 | 1738 | |
| 1745 | − Say N unless you really need all symbols. | |
| 1739 | + Say N unless you really need all symbols, or kernel live patching. | |
| 1746 | 1740 | |
| 1747 | 1741 | config KALLSYMS_ABSOLUTE_PERCPU |
| 1748 | 1742 | bool |
| @@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y) · 24 unmodified lines | ||
| 25 | 25 | |
| 26 | 26 | # $(cc-option,<flag>) |
| 27 | 27 | # Return y if the compiler supports <flag>, n otherwise |
| 28 | −cc-option = $(success,mkdir .tmp_$$$$; trap "rm -rf .tmp_$$$$" EXIT; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$$$/tmp.o) | |
| 28 | +cc-option = $(success,trap "rm -rf .tmp_$$" EXIT; mkdir .tmp_$$; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$/tmp.o) | |
| 29 | 29 | |
| 30 | 30 | # $(ld-option,<flag>) |
| 31 | 31 | # Return y if the linker supports <flag>, n otherwise |
| @@ -358,9 +358,8 @@ $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ; · 357 unmodified lines | ||
| 358 | 358 | |
| 359 | 359 | quiet_cmd_ar_builtin = AR $@ |
| 360 | 360 | cmd_ar_builtin = rm -f $@; \ |
| 361 | − echo $(patsubst $(obj)/%,%,$(real-prereqs)) | \ | |
| 362 | − sed -E 's:([^ ]+):$(obj)/\1:g' | \ | |
| 363 | − xargs $(AR) cDPrST $@ | |
| 361 | + $(if $(real-prereqs), printf "$(obj)/%s " $(patsubst $(obj)/%,%,$(real-prereqs)) | xargs) \ | |
| 362 | + $(AR) cDPrST $@ | |
| 364 | 363 | |
| 365 | 364 | $(obj)/built-in.a: $(real-obj-y) FORCE |
| 366 | 365 | $(call if_changed,ar_builtin) |
| @@ -21,8 +21,8 @@ TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$ · 20 unmodified lines | ||
| 21 | 21 | # automatically cleaned up. |
| 22 | 22 | try-run = $(shell set -e; \ |
| 23 | 23 | TMP=$(TMPOUT)/tmp; \ |
| 24 | − mkdir -p $(TMPOUT); \ | |
| 25 | 24 | trap "rm -rf $(TMPOUT)" EXIT; \ |
| 25 | + mkdir -p $(TMPOUT); \ | |
| 26 | 26 | if ($(1)) >/dev/null 2>&1; \ |
| 27 | 27 | then echo "$(2)"; \ |
| 28 | 28 | else echo "$(3)"; \ |
| @@ -47,7 +47,6 @@ else · 46 unmodified lines | ||
| 47 | 47 | |
| 48 | 48 | ifdef CONFIG_CC_IS_CLANG |
| 49 | 49 | KBUILD_CFLAGS += -Wno-initializer-overrides |
| 50 | −KBUILD_CFLAGS += -Wno-format | |
| 51 | 50 | KBUILD_CFLAGS += -Wno-sign-compare |
| 52 | 51 | KBUILD_CFLAGS += -Wno-format-zero-length |
| 53 | 52 | KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast) |
| @@ -18,6 +18,9 @@ INSTALL_MOD_DIR ?= extra · 17 unmodified lines | ||
| 18 | 18 | dst := $(MODLIB)/$(INSTALL_MOD_DIR) |
| 19 | 19 | endif |
| 20 | 20 | |
| 21 | +$(foreach x, % :, $(if $(findstring $x, $(dst)), \ | |
| 22 | + $(error module installation path cannot contain '$x'))) | |
| 23 | + | |
| 21 | 24 | suffix-y := |
| 22 | 25 | suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz |
| 23 | 26 | suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz |
| @@ -56,7 +56,7 @@ rpm-pkg: · 55 unmodified lines | ||
| 56 | 56 | $(MAKE) clean |
| 57 | 57 | $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec |
| 58 | 58 | $(call cmd,src_tar,$(KERNELPATH),kernel.spec) |
| 59 | − +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \ | |
| 59 | + +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \ | |
| 60 | 60 | --define='_smp_mflags %{nil}' |
| 61 | 61 | |
| 62 | 62 | # binrpm-pkg |
| @@ -66,7 +66,7 @@ binrpm-pkg: · 3 unmodified lines | ||
| 66 | 66 | $(MAKE) -f $(srctree)/Makefile |
| 67 | 67 | $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec |
| 68 | 68 | +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ |
| 69 | − $(UTS_MACHINE) -bb $(objtree)/binkernel.spec | |
| 69 | + $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec | |
| 70 | 70 | |
| 71 | 71 | PHONY += deb-pkg |
| 72 | 72 | deb-pkg: |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | # AArch64, PARISC ports by Kyle McMartin |
| 17 | 17 | # sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk> |
| 18 | 18 | # ppc64le port by Breno Leitao <leitao@debian.org> |
| 19 | +# riscv port by Wadim Mueller <wafgo01@gmail.com> | |
| 19 | 20 | # |
| 20 | 21 | # Usage: |
| 21 | 22 | # objdump -d vmlinux | scripts/checkstack.pl [arch] |
| @@ -108,6 +109,9 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack); · 86 unmodified lines | ||
| 108 | 109 | } elsif ($arch eq 'sparc' || $arch eq 'sparc64') { |
| 109 | 110 | # f0019d10: 9d e3 bf 90 save %sp, -112, %sp |
| 110 | 111 | $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o; |
| 112 | + } elsif ($arch =~ /^riscv(64)?$/) { | |
| 113 | + #ffffffff8036e868: c2010113 addi sp,sp,-992 | |
| 114 | + $re = qr/.*addi.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o; | |
| 111 | 115 | } else { |
| 112 | 116 | print("wrong or unknown architecture \"$arch\"\n"); |
| 113 | 117 | exit |
Empty file added.
| @@ -96,12 +96,8 @@ fi · 95 unmodified lines | ||
| 96 | 96 | |
| 97 | 97 | # To set GCC_PLUGINS |
| 98 | 98 | if arg_contain -print-file-name=plugin "$@"; then |
| 99 | − plugin_dir=$(mktemp -d) | |
| 100 | − | |
| 101 | − mkdir -p $plugin_dir/include | |
| 102 | − touch $plugin_dir/include/plugin-version.h | |
| 103 | − | |
| 104 | − echo $plugin_dir | |
| 99 | + # Use $0 to find the in-tree dummy directory | |
| 100 | + echo "$(dirname "$(readlink -f "$0")")/dummy-plugin-dir" | |
| 105 | 101 | exit 0 |
| 106 | 102 | fi |
| 107 | 103 | |
| @@ -70,7 +70,6 @@ configs=$(sed -e ' · 69 unmodified lines | ||
| 70 | 70 | # |
| 71 | 71 | # The format is <file-name>:<CONFIG-option> in each line. |
| 72 | 72 | config_leak_ignores=" |
| 73 | −arch/alpha/include/uapi/asm/setup.h:CONFIG_ALPHA_LEGACY_START_ADDRESS | |
| 74 | 73 | arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K |
| 75 | 74 | arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K |
| 76 | 75 | arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE |
| @@ -84,7 +83,6 @@ arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT · 7 unmodified lines | ||
| 84 | 83 | arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION |
| 85 | 84 | arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64 |
| 86 | 85 | arch/x86/include/uapi/asm/mman.h:CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS |
| 87 | −include/uapi/asm-generic/fcntl.h:CONFIG_64BIT | |
| 88 | 86 | include/uapi/linux/atmdev.h:CONFIG_COMPAT |
| 89 | 87 | include/uapi/linux/eventpoll.h:CONFIG_PM_SLEEP |
| 90 | 88 | include/uapi/linux/hw_breakpoint.h:CONFIG_HAVE_MIXED_BREAKPOINTS_REGS |
| @@ -20,5 +20,6 @@ fi · 19 unmodified lines | ||
| 20 | 20 | echo >&2 "*" |
| 21 | 21 | echo >&2 "* Could not find Qt5 via ${HOSTPKG_CONFIG}." |
| 22 | 22 | echo >&2 "* Please install Qt5 and make sure it's in PKG_CONFIG_PATH" |
| 23 | +echo >&2 "* You need $PKG" | |
| 23 | 24 | echo >&2 "*" |
| 24 | 25 | exit 1 |
| @@ -1571,9 +1571,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, · 1570 unmodified lines | ||
| 1571 | 1571 | zeros = calloc(1, sym->st_size); |
| 1572 | 1572 | symval = zeros; |
| 1573 | 1573 | } else { |
| 1574 | − symval = (void *)info->hdr | |
| 1575 | − + info->sechdrs[get_secindex(info, sym)].sh_offset | |
| 1576 | − + sym->st_value; | |
| 1574 | + symval = sym_get_data(info, sym); | |
| 1577 | 1575 | } |
| 1578 | 1576 | |
| 1579 | 1577 | /* First handle the "special" cases */ |
| @@ -321,13 +321,10 @@ static void *sym_get_data_by_offset(const struct elf_info *info, · 320 unmodified lines | ||
| 321 | 321 | { |
| 322 | 322 | Elf_Shdr *sechdr = &info->sechdrs[secindex]; |
| 323 | 323 | |
| 324 | − if (info->hdr->e_type != ET_REL) | |
| 325 | − offset -= sechdr->sh_addr; | |
| 326 | − | |
| 327 | 324 | return (void *)info->hdr + sechdr->sh_offset + offset; |
| 328 | 325 | } |
| 329 | 326 | |
| 330 | −static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym) | |
| 327 | +void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym) | |
| 331 | 328 | { |
| 332 | 329 | return sym_get_data_by_offset(info, get_secindex(info, sym), |
| 333 | 330 | sym->st_value); |
| @@ -339,8 +336,16 @@ static const char *sech_name(const struct elf_info *info, Elf_Shdr *sechdr) · 5 unmodified lines | ||
| 339 | 336 | sechdr->sh_name); |
| 340 | 337 | } |
| 341 | 338 | |
| 342 | −static const char *sec_name(const struct elf_info *info, int secindex) | |
| 339 | +static const char *sec_name(const struct elf_info *info, unsigned int secindex) | |
| 343 | 340 | { |
| 341 | + /* | |
| 342 | + * If sym->st_shndx is a special section index, there is no | |
| 343 | + * corresponding section header. | |
| 344 | + * Return "" if the index is out of range of info->sechdrs[] array. | |
| 345 | + */ | |
| 346 | + if (secindex >= info->num_sections) | |
| 347 | + return ""; | |
| 348 | + | |
| 344 | 349 | return sech_name(info, &info->sechdrs[secindex]); |
| 345 | 350 | } |
| 346 | 351 | |
| @@ -466,6 +471,10 @@ static int parse_elf(struct elf_info *info, const char *filename) · 119 unmodified lines | ||
| 466 | 471 | sechdrs = (void *)hdr + hdr->e_shoff; |
| 467 | 472 | info->sechdrs = sechdrs; |
| 468 | 473 | |
| 474 | + /* modpost only works for relocatable objects */ | |
| 475 | + if (hdr->e_type != ET_REL) | |
| 476 | + fatal("%s: not relocatable object.", filename); | |
| 477 | + | |
| 469 | 478 | /* Check if file offset is correct */ |
| 470 | 479 | if (hdr->e_shoff > info->size) { |
| 471 | 480 | fatal("section header offset=%lu in file '%s' is bigger than filesize=%zu\n", |
| @@ -737,12 +746,18 @@ static bool match(const char *string, const char *const patterns[]) · 265 unmodified lines | ||
| 737 | 746 | return false; |
| 738 | 747 | } |
| 739 | 748 | |
| 749 | +/* useful to pass patterns to match() directly */ | |
| 750 | +#define PATTERNS(...) \ | |
| 751 | + ({ \ | |
| 752 | + static const char *const patterns[] = {__VA_ARGS__, NULL}; \ | |
| 753 | + patterns; \ | |
| 754 | + }) | |
| 755 | + | |
| 740 | 756 | /* sections that we do not want to do full section mismatch check on */ |
| 741 | 757 | static const char *const section_white_list[] = |
| 742 | 758 | { |
| 743 | 759 | ".comment*", |
| 744 | 760 | ".debug*", |
| 745 | − ".cranges", /* sh64 */ | |
| 746 | 761 | ".zdebug*", /* Compressed debug sections. */ |
| 747 | 762 | ".GCC.command.line", /* record-gcc-switches */ |
| 748 | 763 | ".mdebug*", /* alpha, score, mips etc. */ |
| @@ -830,28 +845,12 @@ static const char *const init_data_sections[] = · 81 unmodified lines | ||
| 830 | 845 | /* all init sections */ |
| 831 | 846 | static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL }; |
| 832 | 847 | |
| 833 | −/* All init and exit sections (code + data) */ | |
| 834 | −static const char *const init_exit_sections[] = | |
| 835 | − {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }; | |
| 836 | − | |
| 837 | 848 | /* all text sections */ |
| 838 | 849 | static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL }; |
| 839 | 850 | |
| 840 | 851 | /* data section */ |
| 841 | 852 | static const char *const data_sections[] = { DATA_SECTIONS, NULL }; |
| 842 | 853 | |
| 843 | − | |
| 844 | −/* symbols in .data that may refer to init/exit sections */ | |
| 845 | −#define DEFAULT_SYMBOL_WHITE_LIST \ | |
| 846 | − "*driver", \ | |
| 847 | − "*_template", /* scsi uses *_template a lot */ \ | |
| 848 | − "*_timer", /* arm uses ops structures named _timer a lot */ \ | |
| 849 | − "*_sht", /* scsi also used *_sht to some extent */ \ | |
| 850 | − "*_ops", \ | |
| 851 | − "*_probe", \ | |
| 852 | − "*_probe_one", \ | |
| 853 | − "*_console" | |
| 854 | − | |
| 855 | 854 | static const char *const head_sections[] = { ".head.text*", NULL }; |
| 856 | 855 | static const char *const linker_symbols[] = |
| 857 | 856 | { "__init_begin", "_sinittext", "_einittext", NULL }; |
| @@ -883,9 +882,6 @@ enum mismatch { · 25 unmodified lines | ||
| 883 | 882 | * |
| 884 | 883 | * @mismatch: Type of mismatch. |
| 885 | 884 | * |
| 886 | − * @symbol_white_list: Do not match a relocation to a symbol in this list | |
| 887 | − * even if it is targeting a section in @bad_to_sec. | |
| 888 | − * | |
| 889 | 885 | * @handler: Specific handler to call when a match is found. If NULL, |
| 890 | 886 | * default_mismatch_handler() will be called. |
| 891 | 887 | * |
| @@ -895,7 +891,6 @@ struct sectioncheck { · 3 unmodified lines | ||
| 895 | 891 | const char *bad_tosec[20]; |
| 896 | 892 | const char *good_tosec[20]; |
| 897 | 893 | enum mismatch mismatch; |
| 898 | − const char *symbol_white_list[20]; | |
| 899 | 894 | void (*handler)(const char *modname, struct elf_info *elf, |
| 900 | 895 | const struct sectioncheck* const mismatch, |
| 901 | 896 | Elf_Rela *r, Elf_Sym *sym, const char *fromsec); |
| @@ -915,75 +910,61 @@ static const struct sectioncheck sectioncheck[] = { · 13 unmodified lines | ||
| 915 | 910 | .fromsec = { TEXT_SECTIONS, NULL }, |
| 916 | 911 | .bad_tosec = { ALL_INIT_SECTIONS, NULL }, |
| 917 | 912 | .mismatch = TEXT_TO_ANY_INIT, |
| 918 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 919 | 913 | }, |
| 920 | 914 | { |
| 921 | 915 | .fromsec = { DATA_SECTIONS, NULL }, |
| 922 | 916 | .bad_tosec = { ALL_XXXINIT_SECTIONS, NULL }, |
| 923 | 917 | .mismatch = DATA_TO_ANY_INIT, |
| 924 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 925 | 918 | }, |
| 926 | 919 | { |
| 927 | 920 | .fromsec = { DATA_SECTIONS, NULL }, |
| 928 | 921 | .bad_tosec = { INIT_SECTIONS, NULL }, |
| 929 | 922 | .mismatch = DATA_TO_ANY_INIT, |
| 930 | − .symbol_white_list = { | |
| 931 | − "*_template", "*_timer", "*_sht", "*_ops", | |
| 932 | − "*_probe", "*_probe_one", "*_console", NULL | |
| 933 | − }, | |
| 934 | 923 | }, |
| 935 | 924 | { |
| 936 | 925 | .fromsec = { TEXT_SECTIONS, NULL }, |
| 937 | 926 | .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, |
| 938 | 927 | .mismatch = TEXT_TO_ANY_EXIT, |
| 939 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 940 | 928 | }, |
| 941 | 929 | { |
| 942 | 930 | .fromsec = { DATA_SECTIONS, NULL }, |
| 943 | 931 | .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, |
| 944 | 932 | .mismatch = DATA_TO_ANY_EXIT, |
| 945 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 946 | 933 | }, |
| 947 | 934 | /* Do not reference init code/data from meminit code/data */ |
| 948 | 935 | { |
| 949 | 936 | .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, |
| 950 | 937 | .bad_tosec = { INIT_SECTIONS, NULL }, |
| 951 | 938 | .mismatch = XXXINIT_TO_SOME_INIT, |
| 952 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 953 | 939 | }, |
| 954 | 940 | /* Do not reference exit code/data from memexit code/data */ |
| 955 | 941 | { |
| 956 | 942 | .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, |
| 957 | 943 | .bad_tosec = { EXIT_SECTIONS, NULL }, |
| 958 | 944 | .mismatch = XXXEXIT_TO_SOME_EXIT, |
| 959 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 960 | 945 | }, |
| 961 | 946 | /* Do not use exit code/data from init code */ |
| 962 | 947 | { |
| 963 | 948 | .fromsec = { ALL_INIT_SECTIONS, NULL }, |
| 964 | 949 | .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, |
| 965 | 950 | .mismatch = ANY_INIT_TO_ANY_EXIT, |
| 966 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 967 | 951 | }, |
| 968 | 952 | /* Do not use init code/data from exit code */ |
| 969 | 953 | { |
| 970 | 954 | .fromsec = { ALL_EXIT_SECTIONS, NULL }, |
| 971 | 955 | .bad_tosec = { ALL_INIT_SECTIONS, NULL }, |
| 972 | 956 | .mismatch = ANY_EXIT_TO_ANY_INIT, |
| 973 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 974 | 957 | }, |
| 975 | 958 | { |
| 976 | 959 | .fromsec = { ALL_PCI_INIT_SECTIONS, NULL }, |
| 977 | 960 | .bad_tosec = { INIT_SECTIONS, NULL }, |
| 978 | 961 | .mismatch = ANY_INIT_TO_ANY_EXIT, |
| 979 | − .symbol_white_list = { NULL }, | |
| 980 | 962 | }, |
| 981 | 963 | /* Do not export init/exit functions or data */ |
| 982 | 964 | { |
| 983 | 965 | .fromsec = { "___ksymtab*", NULL }, |
| 984 | 966 | .bad_tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL }, |
| 985 | 967 | .mismatch = EXPORT_TO_INIT_EXIT, |
| 986 | − .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | |
| 987 | 968 | }, |
| 988 | 969 | { |
| 989 | 970 | .fromsec = { "__ex_table", NULL }, |
| @@ -1044,15 +1025,6 @@ static const struct sectioncheck *section_mismatch( · 54 unmodified lines | ||
| 1044 | 1025 | * fromsec = .data* |
| 1045 | 1026 | * atsym = __param_ops_* |
| 1046 | 1027 | * |
| 1047 | − * Pattern 2: | |
| 1048 | − * Many drivers utilise a *driver container with references to | |
| 1049 | − * add, remove, probe functions etc. | |
| 1050 | − * the pattern is identified by: | |
| 1051 | − * tosec = init or exit section | |
| 1052 | − * fromsec = data section | |
| 1053 | − * atsym = *driver, *_template, *_sht, *_ops, *_probe, | |
| 1054 | − * *probe_one, *_console, *_timer | |
| 1055 | − * | |
| 1056 | 1028 | * Pattern 3: |
| 1057 | 1029 | * Whitelist all references from .head.text to any init section |
| 1058 | 1030 | * |
| @@ -1101,10 +1073,22 @@ static int secref_whitelist(const struct sectioncheck *mismatch, · 42 unmodified lines | ||
| 1101 | 1073 | strstarts(fromsym, "__param_ops_")) |
| 1102 | 1074 | return 0; |
| 1103 | 1075 | |
| 1104 | − /* Check for pattern 2 */ | |
| 1105 | − if (match(tosec, init_exit_sections) && | |
| 1106 | − match(fromsec, data_sections) && | |
| 1107 | − match(fromsym, mismatch->symbol_white_list)) | |
| 1076 | + /* symbols in data sections that may refer to any init/exit sections */ | |
| 1077 | + if (match(fromsec, PATTERNS(DATA_SECTIONS)) && | |
| 1078 | + match(tosec, PATTERNS(ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS)) && | |
| 1079 | + match(fromsym, PATTERNS("*_template", // scsi uses *_template a lot | |
| 1080 | + "*_timer", // arm uses ops structures named _timer a lot | |
| 1081 | + "*_sht", // scsi also used *_sht to some extent | |
| 1082 | + "*_ops", | |
| 1083 | + "*_probe", | |
| 1084 | + "*_probe_one", | |
| 1085 | + "*_console"))) | |
| 1086 | + return 0; | |
| 1087 | + | |
| 1088 | + /* symbols in data sections that may refer to meminit/exit sections */ | |
| 1089 | + if (match(fromsec, PATTERNS(DATA_SECTIONS)) && | |
| 1090 | + match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_EXIT_SECTIONS)) && | |
| 1091 | + match(fromsym, PATTERNS("*driver"))) | |
| 1108 | 1092 | return 0; |
| 1109 | 1093 | |
| 1110 | 1094 | /* Check for pattern 3 */ |
| @@ -1230,42 +1214,6 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, · 119 unmodified lines | ||
| 1230 | 1214 | return near; |
| 1231 | 1215 | } |
| 1232 | 1216 | |
| 1233 | −/* | |
| 1234 | − * Convert a section name to the function/data attribute | |
| 1235 | − * .init.text => __init | |
| 1236 | − * .memexitconst => __memconst | |
| 1237 | − * etc. | |
| 1238 | − * | |
| 1239 | − * The memory of returned value has been allocated on a heap. The user of this | |
| 1240 | − * method should free it after usage. | |
| 1241 | −*/ | |
| 1242 | −static char *sec2annotation(const char *s) | |
| 1243 | −{ | |
| 1244 | − if (match(s, init_exit_sections)) { | |
| 1245 | − char *p = NOFAIL(malloc(20)); | |
| 1246 | − char *r = p; | |
| 1247 | − | |
| 1248 | − *p++ = '_'; | |
| 1249 | − *p++ = '_'; | |
| 1250 | − if (*s == '.') | |
| 1251 | − s++; | |
| 1252 | − while (*s && *s != '.') | |
| 1253 | − *p++ = *s++; | |
| 1254 | − *p = '\0'; | |
| 1255 | − if (*s == '.') | |
| 1256 | − s++; | |
| 1257 | − if (strstr(s, "rodata") != NULL) | |
| 1258 | − strcat(p, "const "); | |
| 1259 | − else if (strstr(s, "data") != NULL) | |
| 1260 | − strcat(p, "data "); | |
| 1261 | − else | |
| 1262 | − strcat(p, " "); | |
| 1263 | − return r; | |
| 1264 | − } else { | |
| 1265 | − return NOFAIL(strdup("")); | |
| 1266 | − } | |
| 1267 | −} | |
| 1268 | − | |
| 1269 | 1217 | static int is_function(Elf_Sym *sym) |
| 1270 | 1218 | { |
| 1271 | 1219 | if (sym) |
| @@ -1274,19 +1222,6 @@ static int is_function(Elf_Sym *sym) · 2 unmodified lines | ||
| 1274 | 1222 | return -1; |
| 1275 | 1223 | } |
| 1276 | 1224 | |
| 1277 | −static void print_section_list(const char * const list[20]) | |
| 1278 | −{ | |
| 1279 | − const char *const *s = list; | |
| 1280 | − | |
| 1281 | − while (*s) { | |
| 1282 | − fprintf(stderr, "%s", *s); | |
| 1283 | − s++; | |
| 1284 | − if (*s) | |
| 1285 | − fprintf(stderr, ", "); | |
| 1286 | − } | |
| 1287 | − fprintf(stderr, "\n"); | |
| 1288 | −} | |
| 1289 | − | |
| 1290 | 1225 | static inline void get_pretty_name(int is_func, const char** name, const char** name_p) |
| 1291 | 1226 | { |
| 1292 | 1227 | switch (is_func) { |
| @@ -1304,141 +1239,31 @@ static inline void get_pretty_name(int is_func, const char** name, const char** · 11 unmodified lines | ||
| 1304 | 1239 | static void report_sec_mismatch(const char *modname, |
| 1305 | 1240 | const struct sectioncheck *mismatch, |
| 1306 | 1241 | const char *fromsec, |
| 1307 | − unsigned long long fromaddr, | |
| 1308 | 1242 | const char *fromsym, |
| 1309 | − int from_is_func, | |
| 1310 | − const char *tosec, const char *tosym, | |
| 1311 | − int to_is_func) | |
| 1243 | + const char *tosec, const char *tosym) | |
| 1312 | 1244 | { |
| 1313 | − const char *from, *from_p; | |
| 1314 | − const char *to, *to_p; | |
| 1315 | − char *prl_from; | |
| 1316 | − char *prl_to; | |
| 1317 | − | |
| 1318 | 1245 | sec_mismatch_count++; |
| 1319 | 1246 | |
| 1320 | − get_pretty_name(from_is_func, &from, &from_p); | |
| 1321 | − get_pretty_name(to_is_func, &to, &to_p); | |
| 1322 | − | |
| 1323 | − warn("%s(%s+0x%llx): Section mismatch in reference from the %s %s%s " | |
| 1324 | − "to the %s %s:%s%s\n", | |
| 1325 | − modname, fromsec, fromaddr, from, fromsym, from_p, to, tosec, | |
| 1326 | − tosym, to_p); | |
| 1327 | − | |
| 1328 | 1247 | switch (mismatch->mismatch) { |
| 1329 | 1248 | case TEXT_TO_ANY_INIT: |
| 1330 | − prl_from = sec2annotation(fromsec); | |
| 1331 | − prl_to = sec2annotation(tosec); | |
| 1332 | − fprintf(stderr, | |
| 1333 | − "The function %s%s() references\n" | |
| 1334 | − "the %s %s%s%s.\n" | |
| 1335 | − "This is often because %s lacks a %s\n" | |
| 1336 | − "annotation or the annotation of %s is wrong.\n", | |
| 1337 | − prl_from, fromsym, | |
| 1338 | − to, prl_to, tosym, to_p, | |
| 1339 | − fromsym, prl_to, tosym); | |
| 1340 | − free(prl_from); | |
| 1341 | − free(prl_to); | |
| 1342 | − break; | |
| 1343 | − case DATA_TO_ANY_INIT: { | |
| 1344 | − prl_to = sec2annotation(tosec); | |
| 1345 | − fprintf(stderr, | |
| 1346 | − "The variable %s references\n" | |
| 1347 | − "the %s %s%s%s\n" | |
| 1348 | − "If the reference is valid then annotate the\n" | |
| 1349 | − "variable with __init* or __refdata (see linux/init.h) " | |
| 1350 | − "or name the variable:\n", | |
| 1351 | − fromsym, to, prl_to, tosym, to_p); | |
| 1352 | − print_section_list(mismatch->symbol_white_list); | |
| 1353 | − free(prl_to); | |
| 1354 | − break; | |
| 1355 | − } | |
| 1249 | + case DATA_TO_ANY_INIT: | |
| 1356 | 1250 | case TEXT_TO_ANY_EXIT: |
| 1357 | − prl_to = sec2annotation(tosec); | |
| 1358 | − fprintf(stderr, | |
| 1359 | − "The function %s() references a %s in an exit section.\n" | |
| 1360 | − "Often the %s %s%s has valid usage outside the exit section\n" | |
| 1361 | − "and the fix is to remove the %sannotation of %s.\n", | |
| 1362 | − fromsym, to, to, tosym, to_p, prl_to, tosym); | |
| 1363 | − free(prl_to); | |
| 1364 | − break; | |
| 1365 | − case DATA_TO_ANY_EXIT: { | |
| 1366 | − prl_to = sec2annotation(tosec); | |
| 1367 | − fprintf(stderr, | |
| 1368 | − "The variable %s references\n" | |
| 1369 | − "the %s %s%s%s\n" | |
| 1370 | − "If the reference is valid then annotate the\n" | |
| 1371 | − "variable with __exit* (see linux/init.h) or " | |
| 1372 | − "name the variable:\n", | |
| 1373 | − fromsym, to, prl_to, tosym, to_p); | |
| 1374 | − print_section_list(mismatch->symbol_white_list); | |
| 1375 | − free(prl_to); | |
| 1376 | − break; | |
| 1377 | − } | |
| 1251 | + case DATA_TO_ANY_EXIT: | |
| 1378 | 1252 | case XXXINIT_TO_SOME_INIT: |
| 1379 | 1253 | case XXXEXIT_TO_SOME_EXIT: |
| 1380 | − prl_from = sec2annotation(fromsec); | |
| 1381 | − prl_to = sec2annotation(tosec); | |
| 1382 | − fprintf(stderr, | |
| 1383 | − "The %s %s%s%s references\n" | |
| 1384 | − "a %s %s%s%s.\n" | |
| 1385 | − "If %s is only used by %s then\n" | |
| 1386 | − "annotate %s with a matching annotation.\n", | |
| 1387 | − from, prl_from, fromsym, from_p, | |
| 1388 | − to, prl_to, tosym, to_p, | |
| 1389 | − tosym, fromsym, tosym); | |
| 1390 | − free(prl_from); | |
| 1391 | − free(prl_to); | |
| 1392 | − break; | |
| 1393 | 1254 | case ANY_INIT_TO_ANY_EXIT: |
| 1394 | − prl_from = sec2annotation(fromsec); | |
| 1395 | − prl_to = sec2annotation(tosec); | |
| 1396 | − fprintf(stderr, | |
| 1397 | − "The %s %s%s%s references\n" | |
| 1398 | − "a %s %s%s%s.\n" | |
| 1399 | − "This is often seen when error handling " | |
| 1400 | − "in the init function\n" | |
| 1401 | − "uses functionality in the exit path.\n" | |
| 1402 | − "The fix is often to remove the %sannotation of\n" | |
| 1403 | − "%s%s so it may be used outside an exit section.\n", | |
| 1404 | − from, prl_from, fromsym, from_p, | |
| 1405 | − to, prl_to, tosym, to_p, | |
| 1406 | − prl_to, tosym, to_p); | |
| 1407 | − free(prl_from); | |
| 1408 | − free(prl_to); | |
| 1409 | − break; | |
| 1410 | 1255 | case ANY_EXIT_TO_ANY_INIT: |
| 1411 | − prl_from = sec2annotation(fromsec); | |
| 1412 | − prl_to = sec2annotation(tosec); | |
| 1413 | − fprintf(stderr, | |
| 1414 | − "The %s %s%s%s references\n" | |
| 1415 | − "a %s %s%s%s.\n" | |
| 1416 | − "This is often seen when error handling " | |
| 1417 | − "in the exit function\n" | |
| 1418 | − "uses functionality in the init path.\n" | |
| 1419 | − "The fix is often to remove the %sannotation of\n" | |
| 1420 | − "%s%s so it may be used outside an init section.\n", | |
| 1421 | − from, prl_from, fromsym, from_p, | |
| 1422 | − to, prl_to, tosym, to_p, | |
| 1423 | − prl_to, tosym, to_p); | |
| 1424 | − free(prl_from); | |
| 1425 | − free(prl_to); | |
| 1256 | + warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n", | |
| 1257 | + modname, fromsym, fromsec, tosym, tosec); | |
| 1426 | 1258 | break; |
| 1427 | 1259 | case EXPORT_TO_INIT_EXIT: |
| 1428 | − prl_to = sec2annotation(tosec); | |
| 1429 | − fprintf(stderr, | |
| 1430 | − "The symbol %s is exported and annotated %s\n" | |
| 1431 | − "Fix this by removing the %sannotation of %s " | |
| 1432 | − "or drop the export.\n", | |
| 1433 | − tosym, prl_to, prl_to, tosym); | |
| 1434 | − free(prl_to); | |
| 1260 | + warn("%s: EXPORT_SYMBOL used for init/exit symbol: %s (section: %s)\n", | |
| 1261 | + modname, tosym, tosec); | |
| 1435 | 1262 | break; |
| 1436 | 1263 | case EXTABLE_TO_NON_TEXT: |
| 1437 | − fatal("There's a special handler for this mismatch type, " | |
| 1438 | − "we should never get here."); | |
| 1264 | + fatal("There's a special handler for this mismatch type, we should never get here.\n"); | |
| 1439 | 1265 | break; |
| 1440 | 1266 | } |
| 1441 | − fprintf(stderr, "\n"); | |
| 1442 | 1267 | } |
| 1443 | 1268 | |
| 1444 | 1269 | static void default_mismatch_handler(const char *modname, struct elf_info *elf, |
| @@ -1454,9 +1279,6 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, · 9 unmodified lines | ||
| 1454 | 1279 | from = find_elf_symbol2(elf, r->r_offset, fromsec); |
| 1455 | 1280 | fromsym = sym_name(elf, from); |
| 1456 | 1281 | |
| 1457 | − if (strstarts(fromsym, "reference___initcall")) | |
| 1458 | − return; | |
| 1459 | − | |
| 1460 | 1282 | tosec = sec_name(elf, get_secindex(elf, sym)); |
| 1461 | 1283 | to = find_elf_symbol(elf, r->r_addend, sym); |
| 1462 | 1284 | tosym = sym_name(elf, to); |
| @@ -1465,9 +1287,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, · 2 unmodified lines | ||
| 1465 | 1287 | if (secref_whitelist(mismatch, |
| 1466 | 1288 | fromsec, fromsym, tosec, tosym)) { |
| 1467 | 1289 | report_sec_mismatch(modname, mismatch, |
| 1468 | − fromsec, r->r_offset, fromsym, | |
| 1469 | − is_function(from), tosec, tosym, | |
| 1470 | − is_function(to)); | |
| 1290 | + fromsec, fromsym, tosec, tosym); | |
| 1471 | 1291 | } |
| 1472 | 1292 | } |
| 1473 | 1293 | |
| @@ -1623,9 +1443,6 @@ static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) · 149 unmodified lines | ||
| 1623 | 1443 | break; |
| 1624 | 1444 | case R_386_PC32: |
| 1625 | 1445 | r->r_addend = TO_NATIVE(*location) + 4; |
| 1626 | − /* For CONFIG_RELOCATABLE=y */ | |
| 1627 | − if (elf->hdr->e_type == ET_EXEC) | |
| 1628 | − r->r_addend += r->r_offset; | |
| 1629 | 1446 | break; |
| 1630 | 1447 | } |
| 1631 | 1448 | return 0; |
| @@ -1718,8 +1535,7 @@ static void section_rela(const char *modname, struct elf_info *elf, · 86 unmodified lines | ||
| 1718 | 1535 | Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset; |
| 1719 | 1536 | Elf_Rela *stop = (void *)start + sechdr->sh_size; |
| 1720 | 1537 | |
| 1721 | − fromsec = sech_name(elf, sechdr); | |
| 1722 | − fromsec += strlen(".rela"); | |
| 1538 | + fromsec = sec_name(elf, sechdr->sh_info); | |
| 1723 | 1539 | /* if from section (name) is know good then skip it */ |
| 1724 | 1540 | if (match(fromsec, section_white_list)) |
| 1725 | 1541 | return; |
| @@ -1771,8 +1587,7 @@ static void section_rel(const char *modname, struct elf_info *elf, · 45 unmodified lines | ||
| 1771 | 1587 | Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset; |
| 1772 | 1588 | Elf_Rel *stop = (void *)start + sechdr->sh_size; |
| 1773 | 1589 | |
| 1774 | − fromsec = sech_name(elf, sechdr); | |
| 1775 | − fromsec += strlen(".rel"); | |
| 1590 | + fromsec = sec_name(elf, sechdr->sh_info); | |
| 1776 | 1591 | /* if from section (name) is know good then skip it */ |
| 1777 | 1592 | if (match(fromsec, section_white_list)) |
| 1778 | 1593 | return; |
| @@ -26,7 +26,6 @@ · 25 unmodified lines | ||
| 26 | 26 | #define Elf_Shdr Elf32_Shdr |
| 27 | 27 | #define Elf_Sym Elf32_Sym |
| 28 | 28 | #define Elf_Addr Elf32_Addr |
| 29 | −#define Elf_Sword Elf64_Sword | |
| 30 | 29 | #define Elf_Section Elf32_Half |
| 31 | 30 | #define ELF_ST_BIND ELF32_ST_BIND |
| 32 | 31 | #define ELF_ST_TYPE ELF32_ST_TYPE |
| @@ -41,7 +40,6 @@ · 8 unmodified lines | ||
| 41 | 40 | #define Elf_Shdr Elf64_Shdr |
| 42 | 41 | #define Elf_Sym Elf64_Sym |
| 43 | 42 | #define Elf_Addr Elf64_Addr |
| 44 | −#define Elf_Sword Elf64_Sxword | |
| 45 | 43 | #define Elf_Section Elf64_Half |
| 46 | 44 | #define ELF_ST_BIND ELF64_ST_BIND |
| 47 | 45 | #define ELF_ST_TYPE ELF64_ST_TYPE |
| @@ -158,22 +156,28 @@ static inline int is_shndx_special(unsigned int i) · 110 unmodified lines | ||
| 158 | 156 | return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; |
| 159 | 157 | } |
| 160 | 158 | |
| 161 | −/* | |
| 162 | − * Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of | |
| 163 | − * the way to -256..-1, to avoid conflicting with real section | |
| 164 | − * indices. | |
| 165 | − */ | |
| 166 | −#define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1)) | |
| 167 | − | |
| 168 | 159 | /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ |
| 169 | 160 | static inline unsigned int get_secindex(const struct elf_info *info, |
| 170 | 161 | const Elf_Sym *sym) |
| 171 | 162 | { |
| 172 | − if (is_shndx_special(sym->st_shndx)) | |
| 173 | − return SPECIAL(sym->st_shndx); | |
| 174 | − if (sym->st_shndx != SHN_XINDEX) | |
| 175 | − return sym->st_shndx; | |
| 176 | − return info->symtab_shndx_start[sym - info->symtab_start]; | |
| 163 | + unsigned int index = sym->st_shndx; | |
| 164 | + | |
| 165 | + /* | |
| 166 | + * Elf{32,64}_Sym::st_shndx is 2 byte. Big section numbers are available | |
| 167 | + * in the .symtab_shndx section. | |
| 168 | + */ | |
| 169 | + if (index == SHN_XINDEX) | |
| 170 | + return info->symtab_shndx_start[sym - info->symtab_start]; | |
| 171 | + | |
| 172 | + /* | |
| 173 | + * Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of | |
| 174 | + * the way to UINT_MAX-255..UINT_MAX, to avoid conflicting with real | |
| 175 | + * section indices. | |
| 176 | + */ | |
| 177 | + if (index >= SHN_LORESERVE && index <= SHN_HIRESERVE) | |
| 178 | + return index - SHN_HIRESERVE - 1; | |
| 179 | + | |
| 180 | + return index; | |
| 177 | 181 | } |
| 178 | 182 | |
| 179 | 183 | /* file2alias.c */ |
| @@ -187,6 +191,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen); · 7 unmodified lines | ||
| 187 | 191 | /* from modpost.c */ |
| 188 | 192 | char *read_text_file(const char *filename); |
| 189 | 193 | char *get_line(char **stringp); |
| 194 | +void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym); | |
| 190 | 195 | |
| 191 | 196 | enum loglevel { |
| 192 | 197 | LOG_WARN, |
| @@ -49,6 +49,9 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF · 48 unmodified lines | ||
| 49 | 49 | URL: https://www.kernel.org |
| 50 | 50 | $S Source: kernel-$__KERNELRELEASE.tar.gz |
| 51 | 51 | Provides: $PROVIDES |
| 52 | + # $UTS_MACHINE as a fallback of _arch in case | |
| 53 | + # /usr/lib/rpm/platform/*/macros was not included. | |
| 54 | + %define _arch %{?_arch:$UTS_MACHINE} | |
| 52 | 55 | %define __spec_install_post /usr/lib/rpm/brp-compress || : |
| 53 | 56 | %define debug_package %{nil} |
| 54 | 57 | |