Commit ad288597 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull Kbuild updates from Masahiro Yamada:

 - Remove the deprecated rule to build *.dtbo from *.dts

 - Refactor section mismatch detection in modpost

 - Fix bogus ARM section mismatch detections

 - Fix error of 'make gtags' with O= option

 - Add Clang's target triple to KBUILD_CPPFLAGS to fix a build error
   with the latest LLVM version

 - Rebuild the built-in initrd when KBUILD_BUILD_TIMESTAMP is changed

 - Ignore more compiler-generated symbols for kallsyms

 - Fix 'make local*config' to handle the ${CONFIG_FOO} form in Makefiles

 - Enable more kernel-doc warnings with W=2

 - Refactor <linux/export.h> by generating KSYMTAB data by modpost

 - Deprecate <asm/export.h> and <asm-generic/export.h>

 - Remove the EXPORT_DATA_SYMBOL macro

 - Move the check for static EXPORT_SYMBOL back to modpost, which makes
   the build faster

 - Re-implement CONFIG_TRIM_UNUSED_KSYMS with one-pass algorithm

 - Warn missing MODULE_DESCRIPTION when building modules with W=1

 - Make 'make clean' robust against too long argument error

 - Exclude more objects from GCOV to fix CFI failures with GCOV

 - Allow 'make modules_install' to install modules.builtin and
   modules.builtin.modinfo even when CONFIG_MODULES is disabled

 - Include modules.builtin and modules.builtin.modinfo in the
   linux-image Debian package even when CONFIG_MODULES is disabled

 - Revive "Entering directory" logging for the latest Make version

* tag 'kbuild-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (72 commits)
  modpost: define more R_ARM_* for old distributions
  kbuild: revive "Entering directory" for Make >= 4.4.1
  kbuild: set correct abs_srctree and abs_objtree for package builds
  scripts/mksysmap: Ignore prefixed KCFI symbols
  kbuild: deb-pkg: remove the CONFIG_MODULES check in buildeb
  kbuild: builddeb: always make modules_install, to install modules.builtin*
  modpost: continue even with unknown relocation type
  modpost: factor out Elf_Sym pointer calculation to section_rel()
  modpost: factor out inst location calculation to section_rel()
  kbuild: Disable GCOV for *.mod.o
  kbuild: Fix CFI failures with GCOV
  kbuild: make clean rule robust against too long argument error
  script: modpost: emit a warning when the description is missing
  kbuild: make modules_install copy modules.builtin(.modinfo)
  linux/export.h: rename 'sec' argument to 'license'
  modpost: show offset from symbol for section mismatch warnings
  modpost: merge two similar section mismatch warnings
  kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion
  modpost: use null string instead of NULL pointer for default namespace
  modpost: squash sym_update_namespace() into sym_add_exported()
  ...
parents e3c2b10d f5983dab
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
*.symversions *.symversions
*.tab.[ch] *.tab.[ch]
*.tar *.tar
*.usyms
*.xz *.xz
*.zst *.zst
Module.symvers Module.symvers
...@@ -112,7 +111,6 @@ modules.order ...@@ -112,7 +111,6 @@ modules.order
# #
/include/config/ /include/config/
/include/generated/ /include/generated/
/include/ksym/
/arch/*/include/generated/ /arch/*/include/generated/
# stgit generated dirs # stgit generated dirs
......
...@@ -150,6 +150,12 @@ the UTS_MACHINE variable, and on some architectures also the kernel config. ...@@ -150,6 +150,12 @@ the UTS_MACHINE variable, and on some architectures also the kernel config.
The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
architecture. architecture.
KDOCFLAGS
---------
Specify extra (warning/error) flags for kernel-doc checks during the build,
see scripts/kernel-doc for which flags are supported. Note that this doesn't
(currently) apply to documentation builds.
ARCH ARCH
---- ----
Set ARCH to the architecture to be built. Set ARCH to the architecture to be built.
......
...@@ -60,6 +60,8 @@ openssl & libcrypto 1.0.0 openssl version ...@@ -60,6 +60,8 @@ openssl & libcrypto 1.0.0 openssl version
bc 1.06.95 bc --version bc 1.06.95 bc --version
Sphinx\ [#f1]_ 1.7 sphinx-build --version Sphinx\ [#f1]_ 1.7 sphinx-build --version
cpio any cpio --version cpio any cpio --version
GNU tar 1.28 tar --version
gtags (optional) 6.6.5 gtags --version
====================== =============== ======================================== ====================== =============== ========================================
.. [#f1] Sphinx is needed only to build the Kernel documentation .. [#f1] Sphinx is needed only to build the Kernel documentation
...@@ -174,6 +176,18 @@ You will need openssl to build kernels 3.7 and higher if module signing is ...@@ -174,6 +176,18 @@ You will need openssl to build kernels 3.7 and higher if module signing is
enabled. You will also need openssl development packages to build kernels 4.3 enabled. You will also need openssl development packages to build kernels 4.3
and higher. and higher.
Tar
---
GNU tar is needed if you want to enable access to the kernel headers via sysfs
(CONFIG_IKHEADERS).
gtags / GNU GLOBAL (optional)
-----------------------------
The kernel build requires GNU GLOBAL version 6.6.5 or later to generate
tag files through ``make gtags``. This is due to its use of the gtags
``-C (--directory)`` flag.
System utilities System utilities
**************** ****************
......
...@@ -38,6 +38,10 @@ __all: ...@@ -38,6 +38,10 @@ __all:
# descending is started. They are now explicitly listed as the # descending is started. They are now explicitly listed as the
# prepare rule. # prepare rule.
this-makefile := $(lastword $(MAKEFILE_LIST))
export abs_srctree := $(realpath $(dir $(this-makefile)))
export abs_objtree := $(CURDIR)
ifneq ($(sub_make_done),1) ifneq ($(sub_make_done),1)
# Do not use make's built-in rules and variables # Do not use make's built-in rules and variables
...@@ -185,20 +189,8 @@ $(if $(abs_objtree),, \ ...@@ -185,20 +189,8 @@ $(if $(abs_objtree),, \
# $(realpath ...) resolves symlinks # $(realpath ...) resolves symlinks
abs_objtree := $(realpath $(abs_objtree)) abs_objtree := $(realpath $(abs_objtree))
else
abs_objtree := $(CURDIR)
endif # ifneq ($(KBUILD_OUTPUT),) endif # ifneq ($(KBUILD_OUTPUT),)
ifeq ($(abs_objtree),$(CURDIR))
# Suppress "Entering directory ..." unless we are changing the work directory.
MAKEFLAGS += --no-print-directory
else
need-sub-make := 1
endif
this-makefile := $(lastword $(MAKEFILE_LIST))
abs_srctree := $(realpath $(dir $(this-makefile)))
ifneq ($(words $(subst :, ,$(abs_srctree))), 1) ifneq ($(words $(subst :, ,$(abs_srctree))), 1)
$(error source directory cannot contain spaces or colons) $(error source directory cannot contain spaces or colons)
endif endif
...@@ -211,9 +203,25 @@ need-sub-make := 1 ...@@ -211,9 +203,25 @@ need-sub-make := 1
$(this-makefile): ; $(this-makefile): ;
endif endif
export abs_srctree abs_objtree
export sub_make_done := 1 export sub_make_done := 1
endif # sub_make_done
ifeq ($(abs_objtree),$(CURDIR))
# Suppress "Entering directory ..." if we are at the final work directory.
no-print-directory := --no-print-directory
else
# Recursion to show "Entering directory ..."
need-sub-make := 1
endif
ifeq ($(filter --no-print-directory, $(MAKEFLAGS)),)
# If --no-print-directory is unset, recurse once again to set it.
# You may end up recursing into __sub-make twice. This is needed due to the
# behavior change in GNU Make 4.4.1.
need-sub-make := 1
endif
ifeq ($(need-sub-make),1) ifeq ($(need-sub-make),1)
PHONY += $(MAKECMDGOALS) __sub-make PHONY += $(MAKECMDGOALS) __sub-make
...@@ -223,18 +231,12 @@ $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make ...@@ -223,18 +231,12 @@ $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
# Invoke a second make in the output directory, passing relevant variables # Invoke a second make in the output directory, passing relevant variables
__sub-make: __sub-make:
$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) $(Q)$(MAKE) $(no-print-directory) -C $(abs_objtree) \
-f $(abs_srctree)/Makefile $(MAKECMDGOALS)
endif # need-sub-make else # need-sub-make
endif # sub_make_done
# We process the rest of the Makefile if this is the final invocation of make # We process the rest of the Makefile if this is the final invocation of make
ifeq ($(need-sub-make),)
# Do not print "Entering directory ...",
# but we want to display it when entering to the output directory
# so that IDEs/editors are able to understand relative filenames.
MAKEFLAGS += --no-print-directory
ifeq ($(abs_srctree),$(abs_objtree)) ifeq ($(abs_srctree),$(abs_objtree))
# building in the source tree # building in the source tree
...@@ -1199,28 +1201,12 @@ endif ...@@ -1199,28 +1201,12 @@ endif
export KBUILD_VMLINUX_LIBS export KBUILD_VMLINUX_LIBS
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
# Recurse until adjust_autoksyms.sh is satisfied
PHONY += autoksyms_recursive
ifdef CONFIG_TRIM_UNUSED_KSYMS ifdef CONFIG_TRIM_UNUSED_KSYMS
# For the kernel to actually contain only the needed exported symbols, # For the kernel to actually contain only the needed exported symbols,
# we have to build modules as well to determine what those symbols are. # we have to build modules as well to determine what those symbols are.
# (this can be evaluated only once include/config/auto.conf has been included)
KBUILD_MODULES := 1 KBUILD_MODULES := 1
autoksyms_recursive: $(build-dir) modules.order
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
"$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
endif endif
autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
quiet_cmd_autoksyms_h = GEN $@
cmd_autoksyms_h = mkdir -p $(dir $@); \
$(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@
$(autoksyms_h):
$(call cmd,autoksyms_h)
# '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
quiet_cmd_ar_vmlinux.a = AR $@ quiet_cmd_ar_vmlinux.a = AR $@
cmd_ar_vmlinux.a = \ cmd_ar_vmlinux.a = \
...@@ -1229,7 +1215,7 @@ quiet_cmd_ar_vmlinux.a = AR $@ ...@@ -1229,7 +1215,7 @@ quiet_cmd_ar_vmlinux.a = AR $@
$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt) $(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
targets += vmlinux.a targets += vmlinux.a
vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
$(call if_changed,ar_vmlinux.a) $(call if_changed,ar_vmlinux.a)
PHONY += vmlinux_o PHONY += vmlinux_o
...@@ -1285,7 +1271,7 @@ scripts: scripts_basic scripts_dtc ...@@ -1285,7 +1271,7 @@ scripts: scripts_basic scripts_dtc
PHONY += prepare archprepare PHONY += prepare archprepare
archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ asm-generic $(version_h) include/generated/utsrelease.h \
include/generated/compile.h include/generated/autoconf.h remove-stale-files include/generated/compile.h include/generated/autoconf.h remove-stale-files
prepare0: archprepare prepare0: archprepare
...@@ -1567,6 +1553,8 @@ modules_sign_only := y ...@@ -1567,6 +1553,8 @@ modules_sign_only := y
endif endif
endif endif
endif # CONFIG_MODULES
modinst_pre := modinst_pre :=
ifneq ($(filter modules_install,$(MAKECMDGOALS)),) ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
modinst_pre := __modinst_pre modinst_pre := __modinst_pre
...@@ -1577,18 +1565,18 @@ PHONY += __modinst_pre ...@@ -1577,18 +1565,18 @@ PHONY += __modinst_pre
__modinst_pre: __modinst_pre:
@rm -rf $(MODLIB)/kernel @rm -rf $(MODLIB)/kernel
@rm -f $(MODLIB)/source @rm -f $(MODLIB)/source
@mkdir -p $(MODLIB)/kernel @mkdir -p $(MODLIB)
ifdef CONFIG_MODULES
@ln -s $(abspath $(srctree)) $(MODLIB)/source @ln -s $(abspath $(srctree)) $(MODLIB)/source
@if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
rm -f $(MODLIB)/build ; \ rm -f $(MODLIB)/build ; \
ln -s $(CURDIR) $(MODLIB)/build ; \ ln -s $(CURDIR) $(MODLIB)/build ; \
fi fi
@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
endif
@cp -f modules.builtin $(MODLIB)/ @cp -f modules.builtin $(MODLIB)/
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
endif # CONFIG_MODULES
### ###
# Cleaning is done on three levels. # Cleaning is done on three levels.
# make clean Delete most generated files # make clean Delete most generated files
...@@ -1930,6 +1918,13 @@ help: ...@@ -1930,6 +1918,13 @@ help:
@echo ' clean - remove generated files in module directory only' @echo ' clean - remove generated files in module directory only'
@echo '' @echo ''
__external_modules_error:
@echo >&2 '***'
@echo >&2 '*** The present kernel disabled CONFIG_MODULES.'
@echo >&2 '*** You cannot build or install external modules.'
@echo >&2 '***'
@false
endif # KBUILD_EXTMOD endif # KBUILD_EXTMOD
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -1966,13 +1961,10 @@ else # CONFIG_MODULES ...@@ -1966,13 +1961,10 @@ else # CONFIG_MODULES
# Modules not configured # Modules not configured
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
modules modules_install: PHONY += __external_modules_error
@echo >&2 '***'
@echo >&2 '*** The present kernel configuration has modules disabled.' modules modules_install: __external_modules_error
@echo >&2 '*** To use the module feature, please run "make menuconfig" etc.' @:
@echo >&2 '*** to enable CONFIG_MODULES.'
@echo >&2 '***'
@exit 1
KBUILD_MODULES := KBUILD_MODULES :=
...@@ -2045,7 +2037,7 @@ clean: $(clean-dirs) ...@@ -2045,7 +2037,7 @@ clean: $(clean-dirs)
-o -name '*.dtb.S' -o -name '*.dtbo.S' \ -o -name '*.dtb.S' -o -name '*.dtbo.S' \
-o -name '*.dt.yaml' \ -o -name '*.dt.yaml' \
-o -name '*.dwo' -o -name '*.lst' \ -o -name '*.dwo' -o -name '*.lst' \
-o -name '*.su' -o -name '*.mod' -o -name '*.usyms' \ -o -name '*.su' -o -name '*.mod' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-o -name '*.lex.c' -o -name '*.tab.[ch]' \ -o -name '*.lex.c' -o -name '*.tab.[ch]' \
-o -name '*.asn1.[ch]' \ -o -name '*.asn1.[ch]' \
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include <asm/dwarf.h> #include <asm/dwarf.h>
#define ASM_NL ` /* use '`' to mark new line in macro */
#define __ALIGN .align 4
#define __ALIGN_STR __stringify(__ALIGN)
#ifdef __ASSEMBLY__ #ifdef __ASSEMBLY__
.macro ST2 e, o, off .macro ST2 e, o, off
...@@ -28,10 +32,6 @@ ...@@ -28,10 +32,6 @@
#endif #endif
.endm .endm
#define ASM_NL ` /* use '`' to mark new line in macro */
#define __ALIGN .align 4
#define __ALIGN_STR __stringify(__ALIGN)
/* annotation for data we want in DCCM - if enabled in .config */ /* annotation for data we want in DCCM - if enabled in .config */
.macro ARCFP_DATA nm .macro ARCFP_DATA nm
#ifdef CONFIG_ARC_HAS_DCCM #ifdef CONFIG_ARC_HAS_DCCM
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
generated-y += syscall_table.h generated-y += syscall_table.h
generic-y += agp.h generic-y += agp.h
generic-y += export.h
generic-y += kvm_para.h generic-y += kvm_para.h
generic-y += mcs_spinlock.h generic-y += mcs_spinlock.h
generic-y += vtime.h generic-y += vtime.h
/* EXPORT_DATA_SYMBOL != EXPORT_SYMBOL here */
#define KSYM_FUNC(name) @fptr(name)
#include <asm-generic/export.h>
...@@ -170,7 +170,7 @@ RestRR: \ ...@@ -170,7 +170,7 @@ RestRR: \
__PAGE_ALIGNED_DATA __PAGE_ALIGNED_DATA
.global empty_zero_page .global empty_zero_page
EXPORT_DATA_SYMBOL_GPL(empty_zero_page) EXPORT_SYMBOL_GPL(empty_zero_page)
empty_zero_page: empty_zero_page:
.skip PAGE_SIZE .skip PAGE_SIZE
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
.align 32768 // align on 32KB boundary .align 32768 // align on 32KB boundary
.global ia64_ivt .global ia64_ivt
EXPORT_DATA_SYMBOL(ia64_ivt) EXPORT_SYMBOL(ia64_ivt)
ia64_ivt: ia64_ivt:
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// 0x0000 Entry 0 (size 64 bundles) VHPT Translation (8,20,47) // 0x0000 Entry 0 (size 64 bundles) VHPT Translation (8,20,47)
......
...@@ -346,7 +346,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables ...@@ -346,7 +346,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
KBUILD_LDFLAGS += -m $(ld-emul) KBUILD_LDFLAGS += -m $(ld-emul)
ifdef CONFIG_MIPS ifdef CONFIG_MIPS
CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \
sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
endif endif
......
...@@ -54,7 +54,7 @@ KASAN_SANITIZE := n ...@@ -54,7 +54,7 @@ KASAN_SANITIZE := n
KCSAN_SANITIZE := n KCSAN_SANITIZE := n
ccflags-y := -fno-common -fno-builtin ccflags-y := -fno-common -fno-builtin
ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS)
ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
ldflags-$(CONFIG_LD_ORPHAN_WARN) += -Wl,--orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) ldflags-$(CONFIG_LD_ORPHAN_WARN) += -Wl,--orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
......
...@@ -37,13 +37,6 @@ EXPORT_SYMBOL(vsyscall_ehdr); ...@@ -37,13 +37,6 @@ EXPORT_SYMBOL(vsyscall_ehdr);
EXPORT_SYMBOL(vsyscall_end); EXPORT_SYMBOL(vsyscall_end);
#endif #endif
/* Export symbols used by GCC for the stack protector. */
extern void __stack_smash_handler(void *) __attribute__((weak));
EXPORT_SYMBOL(__stack_smash_handler);
extern long __guard __attribute__((weak));
EXPORT_SYMBOL(__guard);
#ifdef _FORTIFY_SOURCE #ifdef _FORTIFY_SOURCE
extern int __sprintf_chk(char *str, int flag, size_t len, const char *format); extern int __sprintf_chk(char *str, int flag, size_t len, const char *format);
EXPORT_SYMBOL(__sprintf_chk); EXPORT_SYMBOL(__sprintf_chk);
......
...@@ -3,86 +3,9 @@ ...@@ -3,86 +3,9 @@
#define __ASM_GENERIC_EXPORT_H #define __ASM_GENERIC_EXPORT_H
/* /*
* This comment block is used by fixdep. Please do not remove. * <asm/export.h> and <asm-generic/export.h> are deprecated.
* * Please include <linux/export.h> directly.
* When CONFIG_MODVERSIONS is changed from n to y, all source files having
* EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
* side effect of the *.o build rule.
*/ */
#include <linux/export.h>
#ifndef KSYM_FUNC
#define KSYM_FUNC(x) x
#endif
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
#define KSYM_ALIGN 4
#elif defined(CONFIG_64BIT)
#define KSYM_ALIGN 8
#else
#define KSYM_ALIGN 4
#endif
.macro __put, val, name
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
.long \val - ., \name - ., 0
#elif defined(CONFIG_64BIT)
.quad \val, \name, 0
#else
.long \val, \name, 0
#endif
.endm
/*
* note on .section use: we specify progbits since usage of the "M" (SHF_MERGE)
* section flag requires it. Use '%progbits' instead of '@progbits' since the
* former apparently works on all arches according to the binutils source.
*/
.macro ___EXPORT_SYMBOL name,val,sec
#if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS)
.section ___ksymtab\sec+\name,"a"
.balign KSYM_ALIGN
__ksymtab_\name:
__put \val, __kstrtab_\name
.previous
.section __ksymtab_strings,"aMS",%progbits,1
__kstrtab_\name:
.asciz "\name"
.previous
#endif
.endm
#if defined(CONFIG_TRIM_UNUSED_KSYMS)
#include <linux/kconfig.h>
#include <generated/autoksyms.h>
.macro __ksym_marker sym
.section ".discard.ksym","a"
__ksym_marker_\sym:
.previous
.endm
#define __EXPORT_SYMBOL(sym, val, sec) \
__ksym_marker sym; \
__cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
#define __cond_export_sym(sym, val, sec, conf) \
___cond_export_sym(sym, val, sec, conf)
#define ___cond_export_sym(sym, val, sec, enabled) \
__cond_export_sym_##enabled(sym, val, sec)
#define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
#define __cond_export_sym_0(sym, val, sec) /* nothing */
#else
#define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
#endif
#define EXPORT_SYMBOL(name) \
__EXPORT_SYMBOL(name, KSYM_FUNC(name),)
#define EXPORT_SYMBOL_GPL(name) \
__EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl)
#define EXPORT_DATA_SYMBOL(name) \
__EXPORT_SYMBOL(name, name,)
#define EXPORT_DATA_SYMBOL_GPL(name) \
__EXPORT_SYMBOL(name, name,_gpl)
#endif #endif
...@@ -1016,6 +1016,7 @@ ...@@ -1016,6 +1016,7 @@
PATCHABLE_DISCARDS \ PATCHABLE_DISCARDS \
*(.discard) \ *(.discard) \
*(.discard.*) \ *(.discard.*) \
*(.export_symbol) \
*(.modinfo) \ *(.modinfo) \
/* ld.bfd warns about .gnu.version* even when not emitted */ \ /* ld.bfd warns about .gnu.version* even when not emitted */ \
*(.gnu.version*) \ *(.gnu.version*) \
......
...@@ -10,6 +10,55 @@ ...@@ -10,6 +10,55 @@
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/types.h> #include <linux/types.h>
#if defined(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)
/*
* relative reference: this reduces the size by half on 64-bit architectures,
* and eliminates the need for absolute relocations that require runtime
* processing on relocatable kernels.
*/
#define __KSYM_REF(sym) ".long " #sym "- ."
#elif defined(CONFIG_64BIT)
#define __KSYM_REF(sym) ".quad " #sym
#else
#define __KSYM_REF(sym) ".long " #sym
#endif
/*
* For every exported symbol, do the following:
*
* - Put the name of the symbol and namespace (empty string "" for none) in
* __ksymtab_strings.
* - Place a struct kernel_symbol entry in the __ksymtab section.
*
* Note on .section use: we specify progbits since usage of the "M" (SHF_MERGE)
* section flag requires it. Use '%progbits' instead of '@progbits' since the
* former apparently works on all arches according to the binutils source.
*/
#define __KSYMTAB(name, sym, sec, ns) \
asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1" "\n" \
"__kstrtab_" #name ":" "\n" \
" .asciz \"" #name "\"" "\n" \
"__kstrtabns_" #name ":" "\n" \
" .asciz \"" ns "\"" "\n" \
" .previous" "\n" \
" .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \
" .balign 4" "\n" \
"__ksymtab_" #name ":" "\n" \
__KSYM_REF(sym) "\n" \
__KSYM_REF(__kstrtab_ ##name) "\n" \
__KSYM_REF(__kstrtabns_ ##name) "\n" \
" .previous" "\n" \
)
#ifdef CONFIG_IA64
#define KSYM_FUNC(name) @fptr(name)
#else
#define KSYM_FUNC(name) name
#endif
#define KSYMTAB_FUNC(name, sec, ns) __KSYMTAB(name, KSYM_FUNC(name), sec, ns)
#define KSYMTAB_DATA(name, sec, ns) __KSYMTAB(name, name, sec, ns)
#define SYMBOL_CRC(sym, crc, sec) \ #define SYMBOL_CRC(sym, crc, sec) \
asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \ asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \
"__crc_" #sym ":" "\n" \ "__crc_" #sym ":" "\n" \
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#ifndef _LINUX_EXPORT_H #ifndef _LINUX_EXPORT_H
#define _LINUX_EXPORT_H #define _LINUX_EXPORT_H
#include <linux/compiler.h>
#include <linux/linkage.h>
#include <linux/stringify.h> #include <linux/stringify.h>
/* /*
...@@ -28,74 +30,25 @@ extern struct module __this_module; ...@@ -28,74 +30,25 @@ extern struct module __this_module;
#else #else
#define THIS_MODULE ((struct module *)0) #define THIS_MODULE ((struct module *)0)
#endif #endif
#endif /* __ASSEMBLY__ */
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS #ifdef CONFIG_64BIT
#include <linux/compiler.h> #define __EXPORT_SYMBOL_REF(sym) \
/* .balign 8 ASM_NL \
* Emit the ksymtab entry as a pair of relative references: this reduces .quad sym
* the size by half on 64-bit architectures, and eliminates the need for
* absolute relocations that require runtime processing on relocatable
* kernels.
*/
#define __KSYMTAB_ENTRY(sym, sec) \
__ADDRESSABLE(sym) \
asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \
" .balign 4 \n" \
"__ksymtab_" #sym ": \n" \
" .long " #sym "- . \n" \
" .long __kstrtab_" #sym "- . \n" \
" .long __kstrtabns_" #sym "- . \n" \
" .previous \n")
struct kernel_symbol {
int value_offset;
int name_offset;
int namespace_offset;
};
#else #else
#define __KSYMTAB_ENTRY(sym, sec) \ #define __EXPORT_SYMBOL_REF(sym) \
static const struct kernel_symbol __ksymtab_##sym \ .balign 4 ASM_NL \
__attribute__((section("___ksymtab" sec "+" #sym), used)) \ .long sym
__aligned(sizeof(void *)) \
= { (unsigned long)&sym, __kstrtab_##sym, __kstrtabns_##sym }
struct kernel_symbol {
unsigned long value;
const char *name;
const char *namespace;
};
#endif #endif
#ifdef __GENKSYMS__ #define ___EXPORT_SYMBOL(sym, license, ns) \
.section ".export_symbol","a" ASM_NL \
#define ___EXPORT_SYMBOL(sym, sec, ns) __GENKSYMS_EXPORT_SYMBOL(sym) __export_symbol_##sym: ASM_NL \
.asciz license ASM_NL \
#else .asciz ns ASM_NL \
__EXPORT_SYMBOL_REF(sym) ASM_NL \
/* .previous
* For every exported symbol, do the following:
*
* - Put the name of the symbol and namespace (empty string "" for none) in
* __ksymtab_strings.
* - Place a struct kernel_symbol entry in the __ksymtab section.
*
* note on .section use: we specify progbits since usage of the "M" (SHF_MERGE)
* section flag requires it. Use '%progbits' instead of '@progbits' since the
* former apparently works on all arches according to the binutils source.
*/
#define ___EXPORT_SYMBOL(sym, sec, ns) \
extern typeof(sym) sym; \
extern const char __kstrtab_##sym[]; \
extern const char __kstrtabns_##sym[]; \
asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1 \n" \
"__kstrtab_" #sym ": \n" \
" .asciz \"" #sym "\" \n" \
"__kstrtabns_" #sym ": \n" \
" .asciz \"" ns "\" \n" \
" .previous \n"); \
__KSYMTAB_ENTRY(sym, sec)
#endif
#if !defined(CONFIG_MODULES) || defined(__DISABLE_EXPORTS) #if !defined(CONFIG_MODULES) || defined(__DISABLE_EXPORTS)
...@@ -104,54 +57,35 @@ struct kernel_symbol { ...@@ -104,54 +57,35 @@ struct kernel_symbol {
* be reused in other execution contexts such as the UEFI stub or the * be reused in other execution contexts such as the UEFI stub or the
* decompressor. * decompressor.
*/ */
#define __EXPORT_SYMBOL(sym, sec, ns) #define __EXPORT_SYMBOL(sym, license, ns)
#elif defined(CONFIG_TRIM_UNUSED_KSYMS) #elif defined(__GENKSYMS__)
#include <generated/autoksyms.h> #define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
/* #elif defined(__ASSEMBLY__)
* For fine grained build dependencies, we want to tell the build system
* about each possible exported symbol even if they're not actually exported. #define __EXPORT_SYMBOL(sym, license, ns) \
* We use a symbol pattern __ksym_marker_<symbol> that the build system filters ___EXPORT_SYMBOL(sym, license, ns)
* from the $(NM) output (see scripts/gen_ksymdeps.sh). These symbols are
* discarded in the final link stage.
*/
#define __ksym_marker(sym) \
static int __ksym_marker_##sym[0] __section(".discard.ksym") __used
#define __EXPORT_SYMBOL(sym, sec, ns) \
__ksym_marker(sym); \
__cond_export_sym(sym, sec, ns, __is_defined(__KSYM_##sym))
#define __cond_export_sym(sym, sec, ns, conf) \
___cond_export_sym(sym, sec, ns, conf)
#define ___cond_export_sym(sym, sec, ns, enabled) \
__cond_export_sym_##enabled(sym, sec, ns)
#define __cond_export_sym_1(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns)
#ifdef __GENKSYMS__
#define __cond_export_sym_0(sym, sec, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
#else
#define __cond_export_sym_0(sym, sec, ns) /* nothing */
#endif
#else #else
#define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) #define __EXPORT_SYMBOL(sym, license, ns) \
extern typeof(sym) sym; \
__ADDRESSABLE(sym) \
asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
#endif /* CONFIG_MODULES */ #endif /* CONFIG_MODULES */
#ifdef DEFAULT_SYMBOL_NAMESPACE #ifdef DEFAULT_SYMBOL_NAMESPACE
#define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, __stringify(DEFAULT_SYMBOL_NAMESPACE)) #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, __stringify(DEFAULT_SYMBOL_NAMESPACE))
#else #else
#define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "") #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "")
#endif #endif
#define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "") #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
#define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_gpl") #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL")
#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", __stringify(ns)) #define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", __stringify(ns))
#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "_gpl", __stringify(ns)) #define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", __stringify(ns))
#endif /* !__ASSEMBLY__ */
#endif /* _LINUX_EXPORT_H */ #endif /* _LINUX_EXPORT_H */
...@@ -375,23 +375,23 @@ const struct dev_pm_ops name = { \ ...@@ -375,23 +375,23 @@ const struct dev_pm_ops name = { \
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
#define _EXPORT_DEV_PM_OPS(name, sec, ns) \ #define _EXPORT_DEV_PM_OPS(name, license, ns) \
const struct dev_pm_ops name; \ const struct dev_pm_ops name; \
__EXPORT_SYMBOL(name, sec, ns); \ __EXPORT_SYMBOL(name, license, ns); \
const struct dev_pm_ops name const struct dev_pm_ops name
#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name) #define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns) #define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
#else #else
#define _EXPORT_DEV_PM_OPS(name, sec, ns) \ #define _EXPORT_DEV_PM_OPS(name, license, ns) \
static __maybe_unused const struct dev_pm_ops __static_##name static __maybe_unused const struct dev_pm_ops __static_##name
#define EXPORT_PM_FN_GPL(name) #define EXPORT_PM_FN_GPL(name)
#define EXPORT_PM_FN_NS_GPL(name, ns) #define EXPORT_PM_FN_NS_GPL(name, ns)
#endif #endif
#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "") #define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "_gpl", "") #define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "GPL", "")
#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns) #define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns)
#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "_gpl", #ns) #define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "GPL", #ns)
/* /*
* Use this if you want to use the same suspend and resume callbacks for suspend * Use this if you want to use the same suspend and resume callbacks for suspend
......
...@@ -60,3 +60,4 @@ include/generated/utsversion.h: FORCE ...@@ -60,3 +60,4 @@ include/generated/utsversion.h: FORCE
$(obj)/version-timestamp.o: include/generated/utsversion.h $(obj)/version-timestamp.o: include/generated/utsversion.h
CFLAGS_version-timestamp.o := -include include/generated/utsversion.h CFLAGS_version-timestamp.o := -include include/generated/utsversion.h
KASAN_SANITIZE_version-timestamp.o := n KASAN_SANITIZE_version-timestamp.o := n
GCOV_PROFILE_version-timestamp.o := n
...@@ -83,12 +83,9 @@ find $cpio_dir -type f -print0 | ...@@ -83,12 +83,9 @@ find $cpio_dir -type f -print0 |
xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;' xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;'
# Create archive and try to normalize metadata for reproducibility. # Create archive and try to normalize metadata for reproducibility.
# For compatibility with older versions of tar, files are fed to tar tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \
# pre-sorted, as --sort=name might not be available. --owner=0 --group=0 --sort=name --numeric-owner \
find $cpio_dir -printf "./%P\n" | LC_ALL=C sort | \ -I $XZ -cf $tarfile -C $cpio_dir/ . > /dev/null
tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \
--owner=0 --group=0 --numeric-owner --no-recursion \
-I $XZ -cf $tarfile -C $cpio_dir/ -T - > /dev/null
echo $headers_md5 > kernel/kheaders.md5 echo $headers_md5 > kernel/kheaders.md5
echo "$this_file_md5" >> kernel/kheaders.md5 echo "$this_file_md5" >> kernel/kheaders.md5
......
...@@ -32,6 +32,18 @@ ...@@ -32,6 +32,18 @@
/* Maximum number of characters written by module_flags() */ /* Maximum number of characters written by module_flags() */
#define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4) #define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4)
struct kernel_symbol {
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
int value_offset;
int name_offset;
int namespace_offset;
#else
unsigned long value;
const char *name;
const char *namespace;
#endif
};
extern struct mutex module_mutex; extern struct mutex module_mutex;
extern struct list_head modules; extern struct list_head modules;
......
...@@ -82,7 +82,7 @@ ifdef need-builtin ...@@ -82,7 +82,7 @@ ifdef need-builtin
targets-for-builtin += $(obj)/built-in.a targets-for-builtin += $(obj)/built-in.a
endif endif
targets-for-modules := $(foreach x, o mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usyms), \ targets-for-modules := $(foreach x, o mod, \
$(patsubst %.o, %.$x, $(filter %.o, $(obj-m)))) $(patsubst %.o, %.$x, $(filter %.o, $(obj-m))))
ifdef need-modorder ifdef need-modorder
...@@ -101,7 +101,9 @@ else ifeq ($(KBUILD_CHECKSRC),2) ...@@ -101,7 +101,9 @@ else ifeq ($(KBUILD_CHECKSRC),2)
endif endif
ifneq ($(KBUILD_EXTRA_WARN),) ifneq ($(KBUILD_EXTRA_WARN),)
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) \
$(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
$<
endif endif
# Compile C sources (.c) # Compile C sources (.c)
...@@ -161,7 +163,7 @@ quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ ...@@ -161,7 +163,7 @@ quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
ifdef CONFIG_MODVERSIONS ifdef CONFIG_MODVERSIONS
# When module versioning is enabled the following steps are executed: # When module versioning is enabled the following steps are executed:
# o compile a <file>.o from <file>.c # o compile a <file>.o from <file>.c
# o if <file>.o doesn't contain a __ksymtab version, i.e. does # o if <file>.o doesn't contain a __export_symbol_*, i.e. does
# not export symbols, it's done. # not export symbols, it's done.
# o otherwise, we calculate symbol versions using the good old # o otherwise, we calculate symbol versions using the good old
# genksyms on the preprocessed source and dump them into the .cmd file. # genksyms on the preprocessed source and dump them into the .cmd file.
...@@ -169,7 +171,7 @@ ifdef CONFIG_MODVERSIONS ...@@ -169,7 +171,7 @@ ifdef CONFIG_MODVERSIONS
# be compiled and linked to the kernel and/or modules. # be compiled and linked to the kernel and/or modules.
gen_symversions = \ gen_symversions = \
if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \ if $(NM) $@ 2>/dev/null | grep -q ' __export_symbol_'; then \
$(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ $(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
>> $(dot-target).cmd; \ >> $(dot-target).cmd; \
fi fi
...@@ -215,21 +217,12 @@ is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetar ...@@ -215,21 +217,12 @@ is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetar
$(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y)) $(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
ifdef CONFIG_TRIM_UNUSED_KSYMS
cmd_gen_ksymdeps = \
$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
endif
cmd_check_local_export = $(srctree)/scripts/check-local-export $@
ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi))) cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi)))
endif endif
define rule_cc_o_c define rule_cc_o_c
$(call cmd_and_fixdep,cc_o_c) $(call cmd_and_fixdep,cc_o_c)
$(call cmd,gen_ksymdeps)
$(call cmd,check_local_export)
$(call cmd,checksrc) $(call cmd,checksrc)
$(call cmd,checkdoc) $(call cmd,checkdoc)
$(call cmd,gen_objtooldep) $(call cmd,gen_objtooldep)
...@@ -240,8 +233,6 @@ endef ...@@ -240,8 +233,6 @@ endef
define rule_as_o_S define rule_as_o_S
$(call cmd_and_fixdep,as_o_S) $(call cmd_and_fixdep,as_o_S)
$(call cmd,gen_ksymdeps)
$(call cmd,check_local_export)
$(call cmd,gen_objtooldep) $(call cmd,gen_objtooldep)
$(call cmd,gen_symversions_S) $(call cmd,gen_symversions_S)
$(call cmd,warn_shared_object) $(call cmd,warn_shared_object)
...@@ -260,12 +251,6 @@ cmd_mod = printf '%s\n' $(call real-search, $*.o, .o, -objs -y -m) | \ ...@@ -260,12 +251,6 @@ cmd_mod = printf '%s\n' $(call real-search, $*.o, .o, -objs -y -m) | \
$(obj)/%.mod: FORCE $(obj)/%.mod: FORCE
$(call if_changed,mod) $(call if_changed,mod)
# List module undefined symbols
cmd_undefined_syms = $(NM) $< | sed -n 's/^ *U //p' > $@
$(obj)/%.usyms: $(obj)/%.o FORCE
$(call if_changed,undefined_syms)
quiet_cmd_cc_lst_c = MKLST $@ quiet_cmd_cc_lst_c = MKLST $@
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
$(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
...@@ -340,9 +325,7 @@ $(obj)/%.ll: $(src)/%.rs FORCE ...@@ -340,9 +325,7 @@ $(obj)/%.ll: $(src)/%.rs FORCE
cmd_gensymtypes_S = \ cmd_gensymtypes_S = \
{ echo "\#include <linux/kernel.h>" ; \ { echo "\#include <linux/kernel.h>" ; \
echo "\#include <asm/asm-prototypes.h>" ; \ echo "\#include <asm/asm-prototypes.h>" ; \
$(CPP) $(a_flags) $< | \ $(NM) $@ | sed -n 's/.* __export_symbol_\(.*\)/EXPORT_SYMBOL(\1);/p' ; } | \
grep "\<___EXPORT_SYMBOL\>" | \
sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \
$(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms) $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms)
quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
......
...@@ -35,6 +35,5 @@ CLANG_FLAGS += -Werror=unknown-warning-option ...@@ -35,6 +35,5 @@ CLANG_FLAGS += -Werror=unknown-warning-option
CLANG_FLAGS += -Werror=ignored-optimization-argument CLANG_FLAGS += -Werror=ignored-optimization-argument
CLANG_FLAGS += -Werror=option-ignored CLANG_FLAGS += -Werror=option-ignored
CLANG_FLAGS += -Werror=unused-command-line-argument CLANG_FLAGS += -Werror=unused-command-line-argument
KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_CPPFLAGS += $(CLANG_FLAGS)
KBUILD_AFLAGS += $(CLANG_FLAGS)
export CLANG_FLAGS export CLANG_FLAGS
...@@ -37,8 +37,10 @@ __clean-files := $(wildcard $(addprefix $(obj)/, $(__clean-files))) ...@@ -37,8 +37,10 @@ __clean-files := $(wildcard $(addprefix $(obj)/, $(__clean-files)))
# ========================================================================== # ==========================================================================
# To make this rule robust against "Argument list too long" error,
# remove $(obj)/ prefix, and restore it by a shell command.
quiet_cmd_clean = CLEAN $(obj) quiet_cmd_clean = CLEAN $(obj)
cmd_clean = rm -rf $(__clean-files) cmd_clean = printf '$(obj)/%s ' $(patsubst $(obj)/%,%,$(__clean-files)) | xargs rm -rf
__clean: $(subdir-ymn) __clean: $(subdir-ymn)
ifneq ($(strip $(__clean-files)),) ifneq ($(strip $(__clean-files)),)
......
...@@ -32,13 +32,13 @@ try-run = $(shell set -e; \ ...@@ -32,13 +32,13 @@ try-run = $(shell set -e; \
# Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,) # Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
as-option = $(call try-run,\ as-option = $(call try-run,\
$(CC) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2))
# as-instr # as-instr
# Usage: aflags-y += $(call as-instr,instr,option1,option2) # Usage: aflags-y += $(call as-instr,instr,option1,option2)
as-instr = $(call try-run,\ as-instr = $(call try-run,\
printf "%b\n" "$(1)" | $(CC) -Werror $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3))
# __cc-option # __cc-option
# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
......
...@@ -418,9 +418,6 @@ endif ...@@ -418,9 +418,6 @@ endif
$(obj)/%.dtb: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE $(obj)/%.dtb: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE
$(call if_changed_dep,dtb) $(call if_changed_dep,dtb)
$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
$(call if_changed_dep,dtc)
$(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE
$(call if_changed_dep,dtc) $(call if_changed_dep,dtc)
......
...@@ -23,7 +23,7 @@ modname = $(notdir $(@:.mod.o=)) ...@@ -23,7 +23,7 @@ modname = $(notdir $(@:.mod.o=))
part-of-module = y part-of-module = y
quiet_cmd_cc_o_c = CC [M] $@ quiet_cmd_cc_o_c = CC [M] $@
cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI), $(c_flags)) -c -o $@ $< cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI) $(CFLAGS_GCOV), $(c_flags)) -c -o $@ $<
%.mod.o: %.mod.c FORCE %.mod.o: %.mod.c FORCE
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
......
...@@ -47,6 +47,7 @@ modpost-args = \ ...@@ -47,6 +47,7 @@ modpost-args = \
$(if $(KBUILD_MODPOST_WARN),-w) \ $(if $(KBUILD_MODPOST_WARN),-w) \
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \
$(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \ $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \
$(if $(findstring 1, $(KBUILD_EXTRA_WARN)),-W) \
-o $@ -o $@
modpost-deps := $(MODPOST) modpost-deps := $(MODPOST)
...@@ -90,6 +91,13 @@ targets += .vmlinux.objs ...@@ -90,6 +91,13 @@ targets += .vmlinux.objs
.vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE .vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
$(call if_changed,vmlinux_objs) $(call if_changed,vmlinux_objs)
ifdef CONFIG_TRIM_UNUSED_KSYMS
ksym-wl := $(CONFIG_UNUSED_KSYMS_WHITELIST)
ksym-wl := $(if $(filter-out /%, $(ksym-wl)),$(srctree)/)$(ksym-wl)
modpost-args += -t $(addprefix -u , $(ksym-wl))
modpost-deps += $(ksym-wl)
endif
ifeq ($(wildcard vmlinux.o),) ifeq ($(wildcard vmlinux.o),)
missing-input := vmlinux.o missing-input := vmlinux.o
output-symdump := modules-only.symvers output-symdump := modules-only.symvers
......
...@@ -19,6 +19,7 @@ quiet_cmd_cc_o_c = CC $@ ...@@ -19,6 +19,7 @@ quiet_cmd_cc_o_c = CC $@
ifdef CONFIG_MODULES ifdef CONFIG_MODULES
KASAN_SANITIZE_.vmlinux.export.o := n KASAN_SANITIZE_.vmlinux.export.o := n
GCOV_PROFILE_.vmlinux.export.o := n
targets += .vmlinux.export.o targets += .vmlinux.export.o
vmlinux: .vmlinux.export.o vmlinux: .vmlinux.export.o
endif endif
......
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
# Script to update include/generated/autoksyms.h and dependency files
#
# Copyright: (C) 2016 Linaro Limited
# Created by: Nicolas Pitre, January 2016
#
# Update the include/generated/autoksyms.h file.
#
# For each symbol being added or removed, the corresponding dependency
# file's timestamp is updated to force a rebuild of the affected source
# file. All arguments passed to this script are assumed to be a command
# to be exec'd to trigger a rebuild of those files.
set -e
cur_ksyms_file="include/generated/autoksyms.h"
new_ksyms_file="include/generated/autoksyms.h.tmpnew"
info() {
if [ "$quiet" != "silent_" ]; then
printf " %-7s %s\n" "$1" "$2"
fi
}
info "CHK" "$cur_ksyms_file"
# Use "make V=1" to debug this script.
case "$KBUILD_VERBOSE" in
*1*)
set -x
;;
esac
# Generate a new symbol list file
$CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh --modorder "$new_ksyms_file"
# Extract changes between old and new list and touch corresponding
# dependency files.
changed=$(
count=0
sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u |
sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' |
while read sympath; do
if [ -z "$sympath" ]; then continue; fi
depfile="include/ksym/${sympath}"
mkdir -p "$(dirname "$depfile")"
touch "$depfile"
# Filesystems with coarse time precision may create timestamps
# equal to the one from a file that was very recently built and that
# needs to be rebuild. Let's guard against that by making sure our
# dep files are always newer than the first file we created here.
while [ ! "$depfile" -nt "$new_ksyms_file" ]; do
touch "$depfile"
done
echo $((count += 1))
done | tail -1 )
changed=${changed:-0}
if [ $changed -gt 0 ]; then
# Replace the old list with tne new one
old=$(grep -c "^#define __KSYM_" "$cur_ksyms_file" || true)
new=$(grep -c "^#define __KSYM_" "$new_ksyms_file" || true)
info "KSYMS" "symbols: before=$old, after=$new, changed=$changed"
info "UPD" "$cur_ksyms_file"
mv -f "$new_ksyms_file" "$cur_ksyms_file"
# Then trigger a rebuild of affected source files
exec $@
else
rm -f "$new_ksyms_file"
fi
...@@ -246,8 +246,7 @@ static void *read_file(const char *filename) ...@@ -246,8 +246,7 @@ static void *read_file(const char *filename)
/* Ignore certain dependencies */ /* Ignore certain dependencies */
static int is_ignored_file(const char *s, int len) static int is_ignored_file(const char *s, int len)
{ {
return str_ends_with(s, len, "include/generated/autoconf.h") || return str_ends_with(s, len, "include/generated/autoconf.h");
str_ends_with(s, len, "include/generated/autoksyms.h");
} }
/* Do not parse these files */ /* Do not parse these files */
......
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2022 Masahiro Yamada <masahiroy@kernel.org>
# Copyright (C) 2022 Owen Rafferty <owen@owenrafferty.com>
#
# Exit with error if a local exported symbol is found.
# EXPORT_SYMBOL should be used for global symbols.
set -e
pid=$$
# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm) shows
# 'no symbols' diagnostic (but exits with 0). It is harmless and hidden by
# '2>/dev/null'. However, it suppresses real error messages as well. Add a
# hand-crafted error message here.
#
# TODO:
# Use --quiet instead of 2>/dev/null when we upgrade the minimum version of
# binutils to 2.37, llvm to 13.0.0.
# Then, the following line will be simpler:
# { ${NM} --quiet ${1} || kill 0; } |
{ ${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; kill $pid; } } |
${AWK} -v "file=${1}" '
BEGIN {
i = 0
}
# Skip the line if the number of fields is less than 3.
#
# case 1)
# For undefined symbols, the first field (value) is empty.
# The outout looks like this:
# " U _printk"
# It is unneeded to record undefined symbols.
#
# case 2)
# For Clang LTO, llvm-nm outputs a line with type t but empty name:
# "---------------- t"
!length($3) {
next
}
# save (name, type) in the associative array
{ symbol_types[$3]=$2 }
# append the exported symbol to the array
($3 ~ /^__ksymtab_/) {
export_symbols[i] = $3
sub(/^__ksymtab_/, "", export_symbols[i])
i++
}
END {
exit_code = 0
for (j = 0; j < i; ++j) {
name = export_symbols[j]
# nm(3) says "If lowercase, the symbol is usually local"
if (symbol_types[name] ~ /[a-z]/) {
printf "%s: error: local symbol %s was exported\n",
file, name | "cat 1>&2"
exit_code = 1
}
}
exit exit_code
}'
exit $?
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
# Create an autoksyms.h header file from the list of all module's needed symbols
# as recorded in *.usyms files and the user-provided symbol whitelist.
set -e
# Use "make V=1" to debug this script.
case "$KBUILD_VERBOSE" in
*1*)
set -x
;;
esac
read_modorder=
if [ "$1" = --modorder ]; then
shift
read_modorder=1
fi
output_file="$1"
needed_symbols=
# Special case for modversions (see modpost.c)
if grep -q "^CONFIG_MODVERSIONS=y$" include/config/auto.conf; then
needed_symbols="$needed_symbols module_layout"
fi
ksym_wl=$(sed -n 's/^CONFIG_UNUSED_KSYMS_WHITELIST=\(.*\)$/\1/p' include/config/auto.conf)
if [ -n "$ksym_wl" ]; then
[ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl"
if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then
echo "ERROR: '$ksym_wl' whitelist file not found" >&2
exit 1
fi
fi
# Generate a new ksym list file with symbols needed by the current
# set of modules.
cat > "$output_file" << EOT
/*
* Automatically generated file; DO NOT EDIT.
*/
EOT
{
[ -n "${read_modorder}" ] && sed 's/o$/usyms/' modules.order | xargs cat
echo "$needed_symbols"
[ -n "$ksym_wl" ] && cat "$ksym_wl"
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry
# point addresses.
sed -e 's/^\.//' |
sort -u |
# Ignore __this_module. It's not an exported symbol, and will be resolved
# when the final .ko's are linked.
grep -v '^__this_module$' |
sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
set -e
# List of exported symbols
#
# If the object has no symbol, $NM warns 'no symbols'.
# Suppress the stderr.
# TODO:
# Use -q instead of 2>/dev/null when we upgrade the minimum version of
# binutils to 2.37, llvm to 13.0.0.
ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p')
if [ -z "$ksyms" ]; then
exit 0
fi
echo
echo "ksymdeps_$1 := \\"
for s in $ksyms
do
printf ' $(wildcard include/ksym/%s) \\\n' "$s"
done
echo
echo "$1: \$(ksymdeps_$1)"
echo
echo "\$(ksymdeps_$1):"
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* *
*/ */
#include <errno.h>
#include <getopt.h> #include <getopt.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
...@@ -29,24 +30,8 @@ ...@@ -29,24 +30,8 @@
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
#define _stringify_1(x) #x
#define _stringify(x) _stringify_1(x)
#define KSYM_NAME_LEN 512 #define KSYM_NAME_LEN 512
/*
* A substantially bigger size than the current maximum.
*
* It cannot be defined as an expression because it gets stringified
* for the fscanf() format string. Therefore, a _Static_assert() is
* used instead to maintain the relationship with KSYM_NAME_LEN.
*/
#define KSYM_NAME_LEN_BUFFER 2048
_Static_assert(
KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4,
"Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN"
);
struct sym_entry { struct sym_entry {
unsigned long long addr; unsigned long long addr;
unsigned int len; unsigned int len;
...@@ -136,24 +121,40 @@ static void check_symbol_range(const char *sym, unsigned long long addr, ...@@ -136,24 +121,40 @@ static void check_symbol_range(const char *sym, unsigned long long addr,
} }
} }
static struct sym_entry *read_symbol(FILE *in) static struct sym_entry *read_symbol(FILE *in, char **buf, size_t *buf_len)
{ {
char name[KSYM_NAME_LEN_BUFFER+1], type; char *name, type, *p;
unsigned long long addr; unsigned long long addr;
unsigned int len; size_t len;
ssize_t readlen;
struct sym_entry *sym; struct sym_entry *sym;
int rc;
rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN_BUFFER) "s\n", &addr, &type, name); readlen = getline(buf, buf_len, in);
if (rc != 3) { if (readlen < 0) {
if (rc != EOF && fgets(name, ARRAY_SIZE(name), in) == NULL) if (errno) {
fprintf(stderr, "Read error or end of file.\n"); perror("read_symbol");
exit(EXIT_FAILURE);
}
return NULL; return NULL;
} }
if (strlen(name) >= KSYM_NAME_LEN) {
if ((*buf)[readlen - 1] == '\n')
(*buf)[readlen - 1] = 0;
addr = strtoull(*buf, &p, 16);
if (*buf == p || *p++ != ' ' || !isascii((type = *p++)) || *p++ != ' ') {
fprintf(stderr, "line format error\n");
exit(EXIT_FAILURE);
}
name = p;
len = strlen(name);
if (len >= KSYM_NAME_LEN) {
fprintf(stderr, "Symbol %s too long for kallsyms (%zu >= %d).\n" fprintf(stderr, "Symbol %s too long for kallsyms (%zu >= %d).\n"
"Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n", "Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n",
name, strlen(name), KSYM_NAME_LEN); name, len, KSYM_NAME_LEN);
return NULL; return NULL;
} }
...@@ -169,8 +170,7 @@ static struct sym_entry *read_symbol(FILE *in) ...@@ -169,8 +170,7 @@ static struct sym_entry *read_symbol(FILE *in)
/* include the type field in the symbol name, so that it gets /* include the type field in the symbol name, so that it gets
* compressed together */ * compressed together */
len++;
len = strlen(name) + 1;
sym = malloc(sizeof(*sym) + len + 1); sym = malloc(sizeof(*sym) + len + 1);
if (!sym) { if (!sym) {
...@@ -257,6 +257,8 @@ static void read_map(const char *in) ...@@ -257,6 +257,8 @@ static void read_map(const char *in)
{ {
FILE *fp; FILE *fp;
struct sym_entry *sym; struct sym_entry *sym;
char *buf = NULL;
size_t buflen = 0;
fp = fopen(in, "r"); fp = fopen(in, "r");
if (!fp) { if (!fp) {
...@@ -265,7 +267,7 @@ static void read_map(const char *in) ...@@ -265,7 +267,7 @@ static void read_map(const char *in)
} }
while (!feof(fp)) { while (!feof(fp)) {
sym = read_symbol(fp); sym = read_symbol(fp, &buf, &buflen);
if (!sym) if (!sym)
continue; continue;
...@@ -284,6 +286,7 @@ static void read_map(const char *in) ...@@ -284,6 +286,7 @@ static void read_map(const char *in)
table[table_cnt++] = sym; table[table_cnt++] = sym;
} }
free(buf);
fclose(fp); fclose(fp);
} }
...@@ -806,7 +809,7 @@ static void record_relative_base(void) ...@@ -806,7 +809,7 @@ static void record_relative_base(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
while (1) { while (1) {
static struct option long_options[] = { static const struct option long_options[] = {
{"all-symbols", no_argument, &all_symbols, 1}, {"all-symbols", no_argument, &all_symbols, 1},
{"absolute-percpu", no_argument, &absolute_percpu, 1}, {"absolute-percpu", no_argument, &absolute_percpu, 1},
{"base-relative", no_argument, &base_relative, 1}, {"base-relative", no_argument, &base_relative, 1},
......
...@@ -317,7 +317,7 @@ foreach my $makefile (@makefiles) { ...@@ -317,7 +317,7 @@ foreach my $makefile (@makefiles) {
$_ = convert_vars($_, %make_vars); $_ = convert_vars($_, %make_vars);
# collect objects after obj-$(CONFIG_FOO_BAR) # collect objects after obj-$(CONFIG_FOO_BAR)
if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { if (/obj-\$[({](CONFIG_[^})]*)[)}]\s*[+:]?=\s*(.*)/) {
$var = $1; $var = $1;
$objs = $2; $objs = $2;
......
...@@ -23,7 +23,7 @@ kernel-doc - Print formatted kernel documentation to stdout ...@@ -23,7 +23,7 @@ kernel-doc - Print formatted kernel documentation to stdout
=head1 SYNOPSIS =head1 SYNOPSIS
kernel-doc [-h] [-v] [-Werror] kernel-doc [-h] [-v] [-Werror] [-Wall] [-Wreturn] [-Wshort-description] [-Wcontents-before-sections]
[ -man | [ -man |
-rst [-sphinx-version VERSION] [-enable-lineno] | -rst [-sphinx-version VERSION] [-enable-lineno] |
-none -none
...@@ -133,6 +133,9 @@ my $dohighlight = ""; ...@@ -133,6 +133,9 @@ my $dohighlight = "";
my $verbose = 0; my $verbose = 0;
my $Werror = 0; my $Werror = 0;
my $Wreturn = 0;
my $Wshort_desc = 0;
my $Wcontents_before_sections = 0;
my $output_mode = "rst"; my $output_mode = "rst";
my $output_preformatted = 0; my $output_preformatted = 0;
my $no_doc_sections = 0; my $no_doc_sections = 0;
...@@ -187,9 +190,14 @@ if (defined($ENV{'KCFLAGS'})) { ...@@ -187,9 +190,14 @@ if (defined($ENV{'KCFLAGS'})) {
} }
} }
# reading this variable is for backwards compat just in case
# someone was calling it with the variable from outside the
# kernel's build system
if (defined($ENV{'KDOC_WERROR'})) { if (defined($ENV{'KDOC_WERROR'})) {
$Werror = "$ENV{'KDOC_WERROR'}"; $Werror = "$ENV{'KDOC_WERROR'}";
} }
# other environment variables are converted to command-line
# arguments in cmd_checkdoc in the build system
# Generated docbook code is inserted in a template at a point where # Generated docbook code is inserted in a template at a point where
# docbook v3.1 requires a non-zero sequence of RefEntry's; see: # docbook v3.1 requires a non-zero sequence of RefEntry's; see:
...@@ -318,6 +326,16 @@ while ($ARGV[0] =~ m/^--?(.*)/) { ...@@ -318,6 +326,16 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
$verbose = 1; $verbose = 1;
} elsif ($cmd eq "Werror") { } elsif ($cmd eq "Werror") {
$Werror = 1; $Werror = 1;
} elsif ($cmd eq "Wreturn") {
$Wreturn = 1;
} elsif ($cmd eq "Wshort-desc") {
$Wshort_desc = 1;
} elsif ($cmd eq "Wcontents-before-sections") {
$Wcontents_before_sections = 1;
} elsif ($cmd eq "Wall") {
$Wreturn = 1;
$Wshort_desc = 1;
$Wcontents_before_sections = 1;
} elsif (($cmd eq "h") || ($cmd eq "help")) { } elsif (($cmd eq "h") || ($cmd eq "help")) {
pod2usage(-exitval => 0, -verbose => 2); pod2usage(-exitval => 0, -verbose => 2);
} elsif ($cmd eq 'no-doc-sections') { } elsif ($cmd eq 'no-doc-sections') {
...@@ -1748,9 +1766,9 @@ sub dump_function($$) { ...@@ -1748,9 +1766,9 @@ sub dump_function($$) {
# This check emits a lot of warnings at the moment, because many # This check emits a lot of warnings at the moment, because many
# functions don't have a 'Return' doc section. So until the number # functions don't have a 'Return' doc section. So until the number
# of warnings goes sufficiently down, the check is only performed in # of warnings goes sufficiently down, the check is only performed in
# verbose mode. # -Wreturn mode.
# TODO: always perform the check. # TODO: always perform the check.
if ($verbose && !$noret) { if ($Wreturn && !$noret) {
check_return_section($file, $declaration_name, $return_type); check_return_section($file, $declaration_name, $return_type);
} }
...@@ -2054,7 +2072,7 @@ sub process_name($$) { ...@@ -2054,7 +2072,7 @@ sub process_name($$) {
$state = STATE_NORMAL; $state = STATE_NORMAL;
} }
if (($declaration_purpose eq "") && $verbose) { if (($declaration_purpose eq "") && $Wshort_desc) {
emit_warning("${file}:$.", "missing initial short description on line:\n$_"); emit_warning("${file}:$.", "missing initial short description on line:\n$_");
} }
...@@ -2103,7 +2121,7 @@ sub process_body($$) { ...@@ -2103,7 +2121,7 @@ sub process_body($$) {
} }
if (($contents ne "") && ($contents ne "\n")) { if (($contents ne "") && ($contents ne "\n")) {
if (!$in_doc_sect && $verbose) { if (!$in_doc_sect && $Wcontents_before_sections) {
emit_warning("${file}:$.", "contents before sections\n"); emit_warning("${file}:$.", "contents before sections\n");
} }
dump_section($file, $section, $contents); dump_section($file, $section, $contents);
......
...@@ -32,7 +32,7 @@ ${NM} -n ${1} | sed >${2} -e " ...@@ -32,7 +32,7 @@ ${NM} -n ${1} | sed >${2} -e "
# (do not forget a space before each pattern) # (do not forget a space before each pattern)
# local symbols for ARM, MIPS, etc. # local symbols for ARM, MIPS, etc.
/ \$/d / \\$/d
# local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc. # local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc.
/ \.L/d / \.L/d
...@@ -40,8 +40,12 @@ ${NM} -n ${1} | sed >${2} -e " ...@@ -40,8 +40,12 @@ ${NM} -n ${1} | sed >${2} -e "
# arm64 EFI stub namespace # arm64 EFI stub namespace
/ __efistub_/d / __efistub_/d
# arm64 local symbols in PIE namespace
/ __pi_\\$/d
/ __pi_\.L/d
# arm64 local symbols in non-VHE KVM namespace # arm64 local symbols in non-VHE KVM namespace
/ __kvm_nvhe_\$/d / __kvm_nvhe_\\$/d
/ __kvm_nvhe_\.L/d / __kvm_nvhe_\.L/d
# arm64 lld # arm64 lld
...@@ -58,6 +62,8 @@ ${NM} -n ${1} | sed >${2} -e " ...@@ -58,6 +62,8 @@ ${NM} -n ${1} | sed >${2} -e "
# CFI type identifiers # CFI type identifiers
/ __kcfi_typeid_/d / __kcfi_typeid_/d
/ __kvm_nvhe___kcfi_typeid_/d
/ __pi___kcfi_typeid_/d
# CRC from modversions # CRC from modversions
/ __crc_/d / __crc_/d
......
This diff is collapsed.
...@@ -137,6 +137,7 @@ struct elf_info { ...@@ -137,6 +137,7 @@ struct elf_info {
Elf_Shdr *sechdrs; Elf_Shdr *sechdrs;
Elf_Sym *symtab_start; Elf_Sym *symtab_start;
Elf_Sym *symtab_stop; Elf_Sym *symtab_stop;
unsigned int export_symbol_secndx; /* .export_symbol section */
char *strtab; char *strtab;
char *modinfo; char *modinfo;
unsigned int modinfo_len; unsigned int modinfo_len;
...@@ -151,11 +152,6 @@ struct elf_info { ...@@ -151,11 +152,6 @@ struct elf_info {
Elf32_Word *symtab_shndx_stop; Elf32_Word *symtab_shndx_stop;
}; };
static inline int is_shndx_special(unsigned int i)
{
return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
}
/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
static inline unsigned int get_secindex(const struct elf_info *info, static inline unsigned int get_secindex(const struct elf_info *info,
const Elf_Sym *sym) const Elf_Sym *sym)
......
...@@ -62,18 +62,14 @@ install_linux_image () { ...@@ -62,18 +62,14 @@ install_linux_image () {
${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install ${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install
fi fi
if is_enabled CONFIG_MODULES; then ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install
${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build"
rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source"
rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source"
if [ "${SRCARCH}" = um ] ; then
mkdir -p "${pdir}/usr/lib/uml/modules"
mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}"
fi
fi
# Install the kernel # Install the kernel
if [ "${ARCH}" = um ] ; then if [ "${ARCH}" = um ] ; then
mkdir -p "${pdir}/usr/lib/uml/modules"
mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}"
mkdir -p "${pdir}/usr/bin" "${pdir}/usr/share/doc/${pname}" mkdir -p "${pdir}/usr/bin" "${pdir}/usr/share/doc/${pname}"
cp System.map "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}/System.map" cp System.map "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}/System.map"
cp ${KCONFIG_CONFIG} "${pdir}/usr/share/doc/${pname}/config" cp ${KCONFIG_CONFIG} "${pdir}/usr/share/doc/${pname}/config"
......
...@@ -33,3 +33,7 @@ rm -f rust/target.json ...@@ -33,3 +33,7 @@ rm -f rust/target.json
rm -f scripts/bin2c rm -f scripts/bin2c
rm -f .scmversion rm -f .scmversion
rm -rf include/ksym
find . -name '*.usyms' | xargs rm -f
...@@ -32,6 +32,13 @@ else ...@@ -32,6 +32,13 @@ else
tree=${srctree}/ tree=${srctree}/
fi fi
# gtags(1) refuses to index any file outside of its current working dir.
# If gtags indexing is requested and the build output directory is not
# the kernel source tree, index all files in absolute-path form.
if [[ "$1" == "gtags" && -n "${tree}" ]]; then
tree=$(realpath "$tree")/
fi
# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
if [ "${ALLSOURCE_ARCHS}" = "" ]; then if [ "${ALLSOURCE_ARCHS}" = "" ]; then
ALLSOURCE_ARCHS=${SRCARCH} ALLSOURCE_ARCHS=${SRCARCH}
...@@ -131,7 +138,7 @@ docscope() ...@@ -131,7 +138,7 @@ docscope()
dogtags() dogtags()
{ {
all_target_sources | gtags -i -f - all_target_sources | gtags -i -C "${tree:-.}" -f - "$PWD"
} }
# Basic regular expressions with an optional /kind-spec/ for ctags and # Basic regular expressions with an optional /kind-spec/ for ctags and
......
...@@ -64,6 +64,7 @@ quiet_cmd_initfs = GEN $@ ...@@ -64,6 +64,7 @@ quiet_cmd_initfs = GEN $@
$(CONFIG_SHELL) $< -o $@ -l $(obj)/.initramfs_data.cpio.d \ $(CONFIG_SHELL) $< -o $@ -l $(obj)/.initramfs_data.cpio.d \
$(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
$(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \ $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \
$(if $(KBUILD_BUILD_TIMESTAMP), -d "$(KBUILD_BUILD_TIMESTAMP)") \
$(ramfs-input) $(ramfs-input)
# We rebuild initramfs_data.cpio if: # We rebuild initramfs_data.cpio if:
......
...@@ -23,6 +23,7 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ... ...@@ -23,6 +23,7 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
-g <gid> Group ID to map to group ID 0 (root). -g <gid> Group ID to map to group ID 0 (root).
<gid> is only meaningful if <cpio_source> is a <gid> is only meaningful if <cpio_source> is a
directory. "squash" forces all files to gid 0. directory. "squash" forces all files to gid 0.
-d <date> Use date for all file mtime values
<cpio_source> File list or directory for cpio archive. <cpio_source> File list or directory for cpio archive.
If <cpio_source> is a .cpio file it will be used If <cpio_source> is a .cpio file it will be used
as direct input to initramfs. as direct input to initramfs.
...@@ -190,6 +191,7 @@ prog=$0 ...@@ -190,6 +191,7 @@ prog=$0
root_uid=0 root_uid=0
root_gid=0 root_gid=0
dep_list= dep_list=
timestamp=
cpio_list=$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX) cpio_list=$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)
output="/dev/stdout" output="/dev/stdout"
...@@ -218,6 +220,13 @@ while [ $# -gt 0 ]; do ...@@ -218,6 +220,13 @@ while [ $# -gt 0 ]; do
[ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0) [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
shift shift
;; ;;
"-d") # date for file mtimes
timestamp="$(date -d"$1" +%s || :)"
if test -n "$timestamp"; then
timestamp="-t $timestamp"
fi
shift
;;
"-h") "-h")
usage usage
exit 0 exit 0
...@@ -237,11 +246,4 @@ done ...@@ -237,11 +246,4 @@ done
# If output_file is set we will generate cpio archive # If output_file is set we will generate cpio archive
# we are careful to delete tmp files # we are careful to delete tmp files
timestamp=
if test -n "$KBUILD_BUILD_TIMESTAMP"; then
timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)"
if test -n "$timestamp"; then
timestamp="-t $timestamp"
fi
fi
usr/gen_init_cpio $timestamp $cpio_list > $output usr/gen_init_cpio $timestamp $cpio_list > $output
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment