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

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()
...

+673 -1009
-2
.gitignore
··· 51 51 *.symversions 52 52 *.tab.[ch] 53 53 *.tar 54 - *.usyms 55 54 *.xz 56 55 *.zst 57 56 Module.symvers ··· 111 112 # 112 113 /include/config/ 113 114 /include/generated/ 114 - /include/ksym/ 115 115 /arch/*/include/generated/ 116 116 117 117 # stgit generated dirs
+6
Documentation/kbuild/kbuild.rst
··· 150 150 The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian 151 151 architecture. 152 152 153 + KDOCFLAGS 154 + --------- 155 + Specify extra (warning/error) flags for kernel-doc checks during the build, 156 + see scripts/kernel-doc for which flags are supported. Note that this doesn't 157 + (currently) apply to documentation builds. 158 + 153 159 ARCH 154 160 ---- 155 161 Set ARCH to the architecture to be built.
+14
Documentation/process/changes.rst
··· 60 60 bc 1.06.95 bc --version 61 61 Sphinx\ [#f1]_ 1.7 sphinx-build --version 62 62 cpio any cpio --version 63 + GNU tar 1.28 tar --version 64 + gtags (optional) 6.6.5 gtags --version 63 65 ====================== =============== ======================================== 64 66 65 67 .. [#f1] Sphinx is needed only to build the Kernel documentation ··· 176 174 enabled. You will also need openssl development packages to build kernels 4.3 177 175 and higher. 178 176 177 + Tar 178 + --- 179 + 180 + GNU tar is needed if you want to enable access to the kernel headers via sysfs 181 + (CONFIG_IKHEADERS). 182 + 183 + gtags / GNU GLOBAL (optional) 184 + ----------------------------- 185 + 186 + The kernel build requires GNU GLOBAL version 6.6.5 or later to generate 187 + tag files through ``make gtags``. This is due to its use of the gtags 188 + ``-C (--directory)`` flag. 179 189 180 190 System utilities 181 191 ****************
+43 -51
Makefile
··· 38 38 # descending is started. They are now explicitly listed as the 39 39 # prepare rule. 40 40 41 + this-makefile := $(lastword $(MAKEFILE_LIST)) 42 + export abs_srctree := $(realpath $(dir $(this-makefile))) 43 + export abs_objtree := $(CURDIR) 44 + 41 45 ifneq ($(sub_make_done),1) 42 46 43 47 # Do not use make's built-in rules and variables ··· 189 185 190 186 # $(realpath ...) resolves symlinks 191 187 abs_objtree := $(realpath $(abs_objtree)) 192 - else 193 - abs_objtree := $(CURDIR) 194 188 endif # ifneq ($(KBUILD_OUTPUT),) 195 - 196 - ifeq ($(abs_objtree),$(CURDIR)) 197 - # Suppress "Entering directory ..." unless we are changing the work directory. 198 - MAKEFLAGS += --no-print-directory 199 - else 200 - need-sub-make := 1 201 - endif 202 - 203 - this-makefile := $(lastword $(MAKEFILE_LIST)) 204 - abs_srctree := $(realpath $(dir $(this-makefile))) 205 189 206 190 ifneq ($(words $(subst :, ,$(abs_srctree))), 1) 207 191 $(error source directory cannot contain spaces or colons) ··· 203 211 $(this-makefile): ; 204 212 endif 205 213 206 - export abs_srctree abs_objtree 207 214 export sub_make_done := 1 215 + 216 + endif # sub_make_done 217 + 218 + ifeq ($(abs_objtree),$(CURDIR)) 219 + # Suppress "Entering directory ..." if we are at the final work directory. 220 + no-print-directory := --no-print-directory 221 + else 222 + # Recursion to show "Entering directory ..." 223 + need-sub-make := 1 224 + endif 225 + 226 + ifeq ($(filter --no-print-directory, $(MAKEFLAGS)),) 227 + # If --no-print-directory is unset, recurse once again to set it. 228 + # You may end up recursing into __sub-make twice. This is needed due to the 229 + # behavior change in GNU Make 4.4.1. 230 + need-sub-make := 1 231 + endif 208 232 209 233 ifeq ($(need-sub-make),1) 210 234 ··· 231 223 232 224 # Invoke a second make in the output directory, passing relevant variables 233 225 __sub-make: 234 - $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) 226 + $(Q)$(MAKE) $(no-print-directory) -C $(abs_objtree) \ 227 + -f $(abs_srctree)/Makefile $(MAKECMDGOALS) 235 228 236 - endif # need-sub-make 237 - endif # sub_make_done 229 + else # need-sub-make 238 230 239 231 # We process the rest of the Makefile if this is the final invocation of make 240 - ifeq ($(need-sub-make),) 241 - 242 - # Do not print "Entering directory ...", 243 - # but we want to display it when entering to the output directory 244 - # so that IDEs/editors are able to understand relative filenames. 245 - MAKEFLAGS += --no-print-directory 246 232 247 233 ifeq ($(abs_srctree),$(abs_objtree)) 248 234 # building in the source tree ··· 1201 1199 export KBUILD_VMLINUX_LIBS 1202 1200 export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds 1203 1201 1204 - # Recurse until adjust_autoksyms.sh is satisfied 1205 - PHONY += autoksyms_recursive 1206 1202 ifdef CONFIG_TRIM_UNUSED_KSYMS 1207 1203 # For the kernel to actually contain only the needed exported symbols, 1208 1204 # we have to build modules as well to determine what those symbols are. 1209 - # (this can be evaluated only once include/config/auto.conf has been included) 1210 1205 KBUILD_MODULES := 1 1211 - 1212 - autoksyms_recursive: $(build-dir) modules.order 1213 - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ 1214 - "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive" 1215 1206 endif 1216 - 1217 - autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h) 1218 - 1219 - quiet_cmd_autoksyms_h = GEN $@ 1220 - cmd_autoksyms_h = mkdir -p $(dir $@); \ 1221 - $(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@ 1222 - 1223 - $(autoksyms_h): 1224 - $(call cmd,autoksyms_h) 1225 1207 1226 1208 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14 1227 1209 quiet_cmd_ar_vmlinux.a = AR $@ ··· 1215 1229 $(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt) 1216 1230 1217 1231 targets += vmlinux.a 1218 - vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE 1232 + vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE 1219 1233 $(call if_changed,ar_vmlinux.a) 1220 1234 1221 1235 PHONY += vmlinux_o ··· 1271 1285 PHONY += prepare archprepare 1272 1286 1273 1287 archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ 1274 - asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ 1288 + asm-generic $(version_h) include/generated/utsrelease.h \ 1275 1289 include/generated/compile.h include/generated/autoconf.h remove-stale-files 1276 1290 1277 1291 prepare0: archprepare ··· 1553 1567 endif 1554 1568 endif 1555 1569 1570 + endif # CONFIG_MODULES 1571 + 1556 1572 modinst_pre := 1557 1573 ifneq ($(filter modules_install,$(MAKECMDGOALS)),) 1558 1574 modinst_pre := __modinst_pre ··· 1565 1577 __modinst_pre: 1566 1578 @rm -rf $(MODLIB)/kernel 1567 1579 @rm -f $(MODLIB)/source 1568 - @mkdir -p $(MODLIB)/kernel 1580 + @mkdir -p $(MODLIB) 1581 + ifdef CONFIG_MODULES 1569 1582 @ln -s $(abspath $(srctree)) $(MODLIB)/source 1570 1583 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ 1571 1584 rm -f $(MODLIB)/build ; \ 1572 1585 ln -s $(CURDIR) $(MODLIB)/build ; \ 1573 1586 fi 1574 1587 @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order 1588 + endif 1575 1589 @cp -f modules.builtin $(MODLIB)/ 1576 1590 @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ 1577 - 1578 - endif # CONFIG_MODULES 1579 1591 1580 1592 ### 1581 1593 # Cleaning is done on three levels. ··· 1918 1930 @echo ' clean - remove generated files in module directory only' 1919 1931 @echo '' 1920 1932 1933 + __external_modules_error: 1934 + @echo >&2 '***' 1935 + @echo >&2 '*** The present kernel disabled CONFIG_MODULES.' 1936 + @echo >&2 '*** You cannot build or install external modules.' 1937 + @echo >&2 '***' 1938 + @false 1939 + 1921 1940 endif # KBUILD_EXTMOD 1922 1941 1923 1942 # --------------------------------------------------------------------------- ··· 1961 1966 # Modules not configured 1962 1967 # --------------------------------------------------------------------------- 1963 1968 1964 - modules modules_install: 1965 - @echo >&2 '***' 1966 - @echo >&2 '*** The present kernel configuration has modules disabled.' 1967 - @echo >&2 '*** To use the module feature, please run "make menuconfig" etc.' 1968 - @echo >&2 '*** to enable CONFIG_MODULES.' 1969 - @echo >&2 '***' 1970 - @exit 1 1969 + PHONY += __external_modules_error 1970 + 1971 + modules modules_install: __external_modules_error 1972 + @: 1971 1973 1972 1974 KBUILD_MODULES := 1973 1975 ··· 2037 2045 -o -name '*.dtb.S' -o -name '*.dtbo.S' \ 2038 2046 -o -name '*.dt.yaml' \ 2039 2047 -o -name '*.dwo' -o -name '*.lst' \ 2040 - -o -name '*.su' -o -name '*.mod' -o -name '*.usyms' \ 2048 + -o -name '*.su' -o -name '*.mod' \ 2041 2049 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 2042 2050 -o -name '*.lex.c' -o -name '*.tab.[ch]' \ 2043 2051 -o -name '*.asn1.[ch]' \
+4 -4
arch/arc/include/asm/linkage.h
··· 8 8 9 9 #include <asm/dwarf.h> 10 10 11 + #define ASM_NL ` /* use '`' to mark new line in macro */ 12 + #define __ALIGN .align 4 13 + #define __ALIGN_STR __stringify(__ALIGN) 14 + 11 15 #ifdef __ASSEMBLY__ 12 16 13 17 .macro ST2 e, o, off ··· 31 27 ld \o, [sp, \off+4] 32 28 #endif 33 29 .endm 34 - 35 - #define ASM_NL ` /* use '`' to mark new line in macro */ 36 - #define __ALIGN .align 4 37 - #define __ALIGN_STR __stringify(__ALIGN) 38 30 39 31 /* annotation for data we want in DCCM - if enabled in .config */ 40 32 .macro ARCFP_DATA nm
+1
arch/ia64/include/asm/Kbuild
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 generated-y += syscall_table.h 3 3 generic-y += agp.h 4 + generic-y += export.h 4 5 generic-y += kvm_para.h 5 6 generic-y += mcs_spinlock.h 6 7 generic-y += vtime.h
-3
arch/ia64/include/asm/export.h
··· 1 - /* EXPORT_DATA_SYMBOL != EXPORT_SYMBOL here */ 2 - #define KSYM_FUNC(name) @fptr(name) 3 - #include <asm-generic/export.h>
+1 -1
arch/ia64/kernel/head.S
··· 170 170 __PAGE_ALIGNED_DATA 171 171 172 172 .global empty_zero_page 173 - EXPORT_DATA_SYMBOL_GPL(empty_zero_page) 173 + EXPORT_SYMBOL_GPL(empty_zero_page) 174 174 empty_zero_page: 175 175 .skip PAGE_SIZE 176 176
+1 -1
arch/ia64/kernel/ivt.S
··· 87 87 88 88 .align 32768 // align on 32KB boundary 89 89 .global ia64_ivt 90 - EXPORT_DATA_SYMBOL(ia64_ivt) 90 + EXPORT_SYMBOL(ia64_ivt) 91 91 ia64_ivt: 92 92 ///////////////////////////////////////////////////////////////////////////////////////// 93 93 // 0x0000 Entry 0 (size 64 bundles) VHPT Translation (8,20,47)
+1 -1
arch/mips/Makefile
··· 346 346 KBUILD_LDFLAGS += -m $(ld-emul) 347 347 348 348 ifdef CONFIG_MIPS 349 - CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ 349 + CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ 350 350 grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ 351 351 sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') 352 352 endif
+1 -1
arch/powerpc/kernel/vdso/Makefile
··· 54 54 KCSAN_SANITIZE := n 55 55 56 56 ccflags-y := -fno-common -fno-builtin 57 - ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack 57 + ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS) 58 58 ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) 59 59 ldflags-$(CONFIG_LD_ORPHAN_WARN) += -Wl,--orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) 60 60
-7
arch/um/os-Linux/user_syms.c
··· 37 37 EXPORT_SYMBOL(vsyscall_end); 38 38 #endif 39 39 40 - /* Export symbols used by GCC for the stack protector. */ 41 - extern void __stack_smash_handler(void *) __attribute__((weak)); 42 - EXPORT_SYMBOL(__stack_smash_handler); 43 - 44 - extern long __guard __attribute__((weak)); 45 - EXPORT_SYMBOL(__guard); 46 - 47 40 #ifdef _FORTIFY_SOURCE 48 41 extern int __sprintf_chk(char *str, int flag, size_t len, const char *format); 49 42 EXPORT_SYMBOL(__sprintf_chk);
+3 -80
include/asm-generic/export.h
··· 3 3 #define __ASM_GENERIC_EXPORT_H 4 4 5 5 /* 6 - * This comment block is used by fixdep. Please do not remove. 7 - * 8 - * When CONFIG_MODVERSIONS is changed from n to y, all source files having 9 - * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a 10 - * side effect of the *.o build rule. 6 + * <asm/export.h> and <asm-generic/export.h> are deprecated. 7 + * Please include <linux/export.h> directly. 11 8 */ 12 - 13 - #ifndef KSYM_FUNC 14 - #define KSYM_FUNC(x) x 15 - #endif 16 - #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 17 - #define KSYM_ALIGN 4 18 - #elif defined(CONFIG_64BIT) 19 - #define KSYM_ALIGN 8 20 - #else 21 - #define KSYM_ALIGN 4 22 - #endif 23 - 24 - .macro __put, val, name 25 - #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 26 - .long \val - ., \name - ., 0 27 - #elif defined(CONFIG_64BIT) 28 - .quad \val, \name, 0 29 - #else 30 - .long \val, \name, 0 31 - #endif 32 - .endm 33 - 34 - /* 35 - * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) 36 - * section flag requires it. Use '%progbits' instead of '@progbits' since the 37 - * former apparently works on all arches according to the binutils source. 38 - */ 39 - 40 - .macro ___EXPORT_SYMBOL name,val,sec 41 - #if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS) 42 - .section ___ksymtab\sec+\name,"a" 43 - .balign KSYM_ALIGN 44 - __ksymtab_\name: 45 - __put \val, __kstrtab_\name 46 - .previous 47 - .section __ksymtab_strings,"aMS",%progbits,1 48 - __kstrtab_\name: 49 - .asciz "\name" 50 - .previous 51 - #endif 52 - .endm 53 - 54 - #if defined(CONFIG_TRIM_UNUSED_KSYMS) 55 - 56 - #include <linux/kconfig.h> 57 - #include <generated/autoksyms.h> 58 - 59 - .macro __ksym_marker sym 60 - .section ".discard.ksym","a" 61 - __ksym_marker_\sym: 62 - .previous 63 - .endm 64 - 65 - #define __EXPORT_SYMBOL(sym, val, sec) \ 66 - __ksym_marker sym; \ 67 - __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym)) 68 - #define __cond_export_sym(sym, val, sec, conf) \ 69 - ___cond_export_sym(sym, val, sec, conf) 70 - #define ___cond_export_sym(sym, val, sec, enabled) \ 71 - __cond_export_sym_##enabled(sym, val, sec) 72 - #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec 73 - #define __cond_export_sym_0(sym, val, sec) /* nothing */ 74 - 75 - #else 76 - #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec 77 - #endif 78 - 79 - #define EXPORT_SYMBOL(name) \ 80 - __EXPORT_SYMBOL(name, KSYM_FUNC(name),) 81 - #define EXPORT_SYMBOL_GPL(name) \ 82 - __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl) 83 - #define EXPORT_DATA_SYMBOL(name) \ 84 - __EXPORT_SYMBOL(name, name,) 85 - #define EXPORT_DATA_SYMBOL_GPL(name) \ 86 - __EXPORT_SYMBOL(name, name,_gpl) 9 + #include <linux/export.h> 87 10 88 11 #endif
+1
include/asm-generic/vmlinux.lds.h
··· 1016 1016 PATCHABLE_DISCARDS \ 1017 1017 *(.discard) \ 1018 1018 *(.discard.*) \ 1019 + *(.export_symbol) \ 1019 1020 *(.modinfo) \ 1020 1021 /* ld.bfd warns about .gnu.version* even when not emitted */ \ 1021 1022 *(.gnu.version*) \
+49
include/linux/export-internal.h
··· 10 10 #include <linux/compiler.h> 11 11 #include <linux/types.h> 12 12 13 + #if defined(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS) 14 + /* 15 + * relative reference: this reduces the size by half on 64-bit architectures, 16 + * and eliminates the need for absolute relocations that require runtime 17 + * processing on relocatable kernels. 18 + */ 19 + #define __KSYM_REF(sym) ".long " #sym "- ." 20 + #elif defined(CONFIG_64BIT) 21 + #define __KSYM_REF(sym) ".quad " #sym 22 + #else 23 + #define __KSYM_REF(sym) ".long " #sym 24 + #endif 25 + 26 + /* 27 + * For every exported symbol, do the following: 28 + * 29 + * - Put the name of the symbol and namespace (empty string "" for none) in 30 + * __ksymtab_strings. 31 + * - Place a struct kernel_symbol entry in the __ksymtab section. 32 + * 33 + * Note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) 34 + * section flag requires it. Use '%progbits' instead of '@progbits' since the 35 + * former apparently works on all arches according to the binutils source. 36 + */ 37 + #define __KSYMTAB(name, sym, sec, ns) \ 38 + asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1" "\n" \ 39 + "__kstrtab_" #name ":" "\n" \ 40 + " .asciz \"" #name "\"" "\n" \ 41 + "__kstrtabns_" #name ":" "\n" \ 42 + " .asciz \"" ns "\"" "\n" \ 43 + " .previous" "\n" \ 44 + " .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \ 45 + " .balign 4" "\n" \ 46 + "__ksymtab_" #name ":" "\n" \ 47 + __KSYM_REF(sym) "\n" \ 48 + __KSYM_REF(__kstrtab_ ##name) "\n" \ 49 + __KSYM_REF(__kstrtabns_ ##name) "\n" \ 50 + " .previous" "\n" \ 51 + ) 52 + 53 + #ifdef CONFIG_IA64 54 + #define KSYM_FUNC(name) @fptr(name) 55 + #else 56 + #define KSYM_FUNC(name) name 57 + #endif 58 + 59 + #define KSYMTAB_FUNC(name, sec, ns) __KSYMTAB(name, KSYM_FUNC(name), sec, ns) 60 + #define KSYMTAB_DATA(name, sec, ns) __KSYMTAB(name, name, sec, ns) 61 + 13 62 #define SYMBOL_CRC(sym, crc, sec) \ 14 63 asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \ 15 64 "__crc_" #sym ":" "\n" \
+31 -97
include/linux/export.h
··· 2 2 #ifndef _LINUX_EXPORT_H 3 3 #define _LINUX_EXPORT_H 4 4 5 + #include <linux/compiler.h> 6 + #include <linux/linkage.h> 5 7 #include <linux/stringify.h> 6 8 7 9 /* ··· 30 28 #else 31 29 #define THIS_MODULE ((struct module *)0) 32 30 #endif 31 + #endif /* __ASSEMBLY__ */ 33 32 34 - #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 35 - #include <linux/compiler.h> 36 - /* 37 - * Emit the ksymtab entry as a pair of relative references: this reduces 38 - * the size by half on 64-bit architectures, and eliminates the need for 39 - * absolute relocations that require runtime processing on relocatable 40 - * kernels. 41 - */ 42 - #define __KSYMTAB_ENTRY(sym, sec) \ 43 - __ADDRESSABLE(sym) \ 44 - asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ 45 - " .balign 4 \n" \ 46 - "__ksymtab_" #sym ": \n" \ 47 - " .long " #sym "- . \n" \ 48 - " .long __kstrtab_" #sym "- . \n" \ 49 - " .long __kstrtabns_" #sym "- . \n" \ 50 - " .previous \n") 51 - 52 - struct kernel_symbol { 53 - int value_offset; 54 - int name_offset; 55 - int namespace_offset; 56 - }; 33 + #ifdef CONFIG_64BIT 34 + #define __EXPORT_SYMBOL_REF(sym) \ 35 + .balign 8 ASM_NL \ 36 + .quad sym 57 37 #else 58 - #define __KSYMTAB_ENTRY(sym, sec) \ 59 - static const struct kernel_symbol __ksymtab_##sym \ 60 - __attribute__((section("___ksymtab" sec "+" #sym), used)) \ 61 - __aligned(sizeof(void *)) \ 62 - = { (unsigned long)&sym, __kstrtab_##sym, __kstrtabns_##sym } 63 - 64 - struct kernel_symbol { 65 - unsigned long value; 66 - const char *name; 67 - const char *namespace; 68 - }; 38 + #define __EXPORT_SYMBOL_REF(sym) \ 39 + .balign 4 ASM_NL \ 40 + .long sym 69 41 #endif 70 42 71 - #ifdef __GENKSYMS__ 72 - 73 - #define ___EXPORT_SYMBOL(sym, sec, ns) __GENKSYMS_EXPORT_SYMBOL(sym) 74 - 75 - #else 76 - 77 - /* 78 - * For every exported symbol, do the following: 79 - * 80 - * - Put the name of the symbol and namespace (empty string "" for none) in 81 - * __ksymtab_strings. 82 - * - Place a struct kernel_symbol entry in the __ksymtab section. 83 - * 84 - * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) 85 - * section flag requires it. Use '%progbits' instead of '@progbits' since the 86 - * former apparently works on all arches according to the binutils source. 87 - */ 88 - #define ___EXPORT_SYMBOL(sym, sec, ns) \ 89 - extern typeof(sym) sym; \ 90 - extern const char __kstrtab_##sym[]; \ 91 - extern const char __kstrtabns_##sym[]; \ 92 - asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1 \n" \ 93 - "__kstrtab_" #sym ": \n" \ 94 - " .asciz \"" #sym "\" \n" \ 95 - "__kstrtabns_" #sym ": \n" \ 96 - " .asciz \"" ns "\" \n" \ 97 - " .previous \n"); \ 98 - __KSYMTAB_ENTRY(sym, sec) 99 - 100 - #endif 43 + #define ___EXPORT_SYMBOL(sym, license, ns) \ 44 + .section ".export_symbol","a" ASM_NL \ 45 + __export_symbol_##sym: ASM_NL \ 46 + .asciz license ASM_NL \ 47 + .asciz ns ASM_NL \ 48 + __EXPORT_SYMBOL_REF(sym) ASM_NL \ 49 + .previous 101 50 102 51 #if !defined(CONFIG_MODULES) || defined(__DISABLE_EXPORTS) 103 52 ··· 57 104 * be reused in other execution contexts such as the UEFI stub or the 58 105 * decompressor. 59 106 */ 60 - #define __EXPORT_SYMBOL(sym, sec, ns) 107 + #define __EXPORT_SYMBOL(sym, license, ns) 61 108 62 - #elif defined(CONFIG_TRIM_UNUSED_KSYMS) 109 + #elif defined(__GENKSYMS__) 63 110 64 - #include <generated/autoksyms.h> 111 + #define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym) 65 112 66 - /* 67 - * For fine grained build dependencies, we want to tell the build system 68 - * about each possible exported symbol even if they're not actually exported. 69 - * We use a symbol pattern __ksym_marker_<symbol> that the build system filters 70 - * from the $(NM) output (see scripts/gen_ksymdeps.sh). These symbols are 71 - * discarded in the final link stage. 72 - */ 73 - #define __ksym_marker(sym) \ 74 - static int __ksym_marker_##sym[0] __section(".discard.ksym") __used 113 + #elif defined(__ASSEMBLY__) 75 114 76 - #define __EXPORT_SYMBOL(sym, sec, ns) \ 77 - __ksym_marker(sym); \ 78 - __cond_export_sym(sym, sec, ns, __is_defined(__KSYM_##sym)) 79 - #define __cond_export_sym(sym, sec, ns, conf) \ 80 - ___cond_export_sym(sym, sec, ns, conf) 81 - #define ___cond_export_sym(sym, sec, ns, enabled) \ 82 - __cond_export_sym_##enabled(sym, sec, ns) 83 - #define __cond_export_sym_1(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) 84 - 85 - #ifdef __GENKSYMS__ 86 - #define __cond_export_sym_0(sym, sec, ns) __GENKSYMS_EXPORT_SYMBOL(sym) 87 - #else 88 - #define __cond_export_sym_0(sym, sec, ns) /* nothing */ 89 - #endif 115 + #define __EXPORT_SYMBOL(sym, license, ns) \ 116 + ___EXPORT_SYMBOL(sym, license, ns) 90 117 91 118 #else 92 119 93 - #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) 120 + #define __EXPORT_SYMBOL(sym, license, ns) \ 121 + extern typeof(sym) sym; \ 122 + __ADDRESSABLE(sym) \ 123 + asm(__stringify(___EXPORT_SYMBOL(sym, license, ns))) 94 124 95 125 #endif /* CONFIG_MODULES */ 96 126 97 127 #ifdef DEFAULT_SYMBOL_NAMESPACE 98 - #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, __stringify(DEFAULT_SYMBOL_NAMESPACE)) 128 + #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, __stringify(DEFAULT_SYMBOL_NAMESPACE)) 99 129 #else 100 - #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "") 130 + #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "") 101 131 #endif 102 132 103 133 #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "") 104 - #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_gpl") 134 + #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL") 105 135 #define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", __stringify(ns)) 106 - #define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "_gpl", __stringify(ns)) 107 - 108 - #endif /* !__ASSEMBLY__ */ 136 + #define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", __stringify(ns)) 109 137 110 138 #endif /* _LINUX_EXPORT_H */
+5 -5
include/linux/pm.h
··· 375 375 } 376 376 377 377 #ifdef CONFIG_PM 378 - #define _EXPORT_DEV_PM_OPS(name, sec, ns) \ 378 + #define _EXPORT_DEV_PM_OPS(name, license, ns) \ 379 379 const struct dev_pm_ops name; \ 380 - __EXPORT_SYMBOL(name, sec, ns); \ 380 + __EXPORT_SYMBOL(name, license, ns); \ 381 381 const struct dev_pm_ops name 382 382 #define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name) 383 383 #define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns) 384 384 #else 385 - #define _EXPORT_DEV_PM_OPS(name, sec, ns) \ 385 + #define _EXPORT_DEV_PM_OPS(name, license, ns) \ 386 386 static __maybe_unused const struct dev_pm_ops __static_##name 387 387 #define EXPORT_PM_FN_GPL(name) 388 388 #define EXPORT_PM_FN_NS_GPL(name, ns) 389 389 #endif 390 390 391 391 #define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "") 392 - #define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "_gpl", "") 392 + #define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "GPL", "") 393 393 #define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns) 394 - #define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "_gpl", #ns) 394 + #define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "GPL", #ns) 395 395 396 396 /* 397 397 * Use this if you want to use the same suspend and resume callbacks for suspend
+1
init/Makefile
··· 60 60 $(obj)/version-timestamp.o: include/generated/utsversion.h 61 61 CFLAGS_version-timestamp.o := -include include/generated/utsversion.h 62 62 KASAN_SANITIZE_version-timestamp.o := n 63 + GCOV_PROFILE_version-timestamp.o := n
+3 -6
kernel/gen_kheaders.sh
··· 83 83 xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;' 84 84 85 85 # Create archive and try to normalize metadata for reproducibility. 86 - # For compatibility with older versions of tar, files are fed to tar 87 - # pre-sorted, as --sort=name might not be available. 88 - find $cpio_dir -printf "./%P\n" | LC_ALL=C sort | \ 89 - tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \ 90 - --owner=0 --group=0 --numeric-owner --no-recursion \ 91 - -I $XZ -cf $tarfile -C $cpio_dir/ -T - > /dev/null 86 + tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \ 87 + --owner=0 --group=0 --sort=name --numeric-owner \ 88 + -I $XZ -cf $tarfile -C $cpio_dir/ . > /dev/null 92 89 93 90 echo $headers_md5 > kernel/kheaders.md5 94 91 echo "$this_file_md5" >> kernel/kheaders.md5
+12
kernel/module/internal.h
··· 32 32 /* Maximum number of characters written by module_flags() */ 33 33 #define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4) 34 34 35 + struct kernel_symbol { 36 + #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 37 + int value_offset; 38 + int name_offset; 39 + int namespace_offset; 40 + #else 41 + unsigned long value; 42 + const char *name; 43 + const char *namespace; 44 + #endif 45 + }; 46 + 35 47 extern struct mutex module_mutex; 36 48 extern struct list_head modules; 37 49
+7 -24
scripts/Makefile.build
··· 82 82 targets-for-builtin += $(obj)/built-in.a 83 83 endif 84 84 85 - targets-for-modules := $(foreach x, o mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usyms), \ 85 + targets-for-modules := $(foreach x, o mod, \ 86 86 $(patsubst %.o, %.$x, $(filter %.o, $(obj-m)))) 87 87 88 88 ifdef need-modorder ··· 101 101 endif 102 102 103 103 ifneq ($(KBUILD_EXTRA_WARN),) 104 - cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< 104 + cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) \ 105 + $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \ 106 + $< 105 107 endif 106 108 107 109 # Compile C sources (.c) ··· 163 161 ifdef CONFIG_MODVERSIONS 164 162 # When module versioning is enabled the following steps are executed: 165 163 # o compile a <file>.o from <file>.c 166 - # o if <file>.o doesn't contain a __ksymtab version, i.e. does 164 + # o if <file>.o doesn't contain a __export_symbol_*, i.e. does 167 165 # not export symbols, it's done. 168 166 # o otherwise, we calculate symbol versions using the good old 169 167 # genksyms on the preprocessed source and dump them into the .cmd file. ··· 171 169 # be compiled and linked to the kernel and/or modules. 172 170 173 171 gen_symversions = \ 174 - if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \ 172 + if $(NM) $@ 2>/dev/null | grep -q ' __export_symbol_'; then \ 175 173 $(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ 176 174 >> $(dot-target).cmd; \ 177 175 fi ··· 217 215 218 216 $(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y)) 219 217 220 - ifdef CONFIG_TRIM_UNUSED_KSYMS 221 - cmd_gen_ksymdeps = \ 222 - $(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd 223 - endif 224 - 225 - cmd_check_local_export = $(srctree)/scripts/check-local-export $@ 226 - 227 218 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) 228 219 cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi))) 229 220 endif 230 221 231 222 define rule_cc_o_c 232 223 $(call cmd_and_fixdep,cc_o_c) 233 - $(call cmd,gen_ksymdeps) 234 - $(call cmd,check_local_export) 235 224 $(call cmd,checksrc) 236 225 $(call cmd,checkdoc) 237 226 $(call cmd,gen_objtooldep) ··· 233 240 234 241 define rule_as_o_S 235 242 $(call cmd_and_fixdep,as_o_S) 236 - $(call cmd,gen_ksymdeps) 237 - $(call cmd,check_local_export) 238 243 $(call cmd,gen_objtooldep) 239 244 $(call cmd,gen_symversions_S) 240 245 $(call cmd,warn_shared_object) ··· 250 259 251 260 $(obj)/%.mod: FORCE 252 261 $(call if_changed,mod) 253 - 254 - # List module undefined symbols 255 - cmd_undefined_syms = $(NM) $< | sed -n 's/^ *U //p' > $@ 256 - 257 - $(obj)/%.usyms: $(obj)/%.o FORCE 258 - $(call if_changed,undefined_syms) 259 262 260 263 quiet_cmd_cc_lst_c = MKLST $@ 261 264 cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ ··· 325 340 cmd_gensymtypes_S = \ 326 341 { echo "\#include <linux/kernel.h>" ; \ 327 342 echo "\#include <asm/asm-prototypes.h>" ; \ 328 - $(CPP) $(a_flags) $< | \ 329 - grep "\<___EXPORT_SYMBOL\>" | \ 330 - sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \ 343 + $(NM) $@ | sed -n 's/.* __export_symbol_\(.*\)/EXPORT_SYMBOL(\1);/p' ; } | \ 331 344 $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms) 332 345 333 346 quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
+1 -2
scripts/Makefile.clang
··· 35 35 CLANG_FLAGS += -Werror=ignored-optimization-argument 36 36 CLANG_FLAGS += -Werror=option-ignored 37 37 CLANG_FLAGS += -Werror=unused-command-line-argument 38 - KBUILD_CFLAGS += $(CLANG_FLAGS) 39 - KBUILD_AFLAGS += $(CLANG_FLAGS) 38 + KBUILD_CPPFLAGS += $(CLANG_FLAGS) 40 39 export CLANG_FLAGS
+3 -1
scripts/Makefile.clean
··· 37 37 38 38 # ========================================================================== 39 39 40 + # To make this rule robust against "Argument list too long" error, 41 + # remove $(obj)/ prefix, and restore it by a shell command. 40 42 quiet_cmd_clean = CLEAN $(obj) 41 - cmd_clean = rm -rf $(__clean-files) 43 + cmd_clean = printf '$(obj)/%s ' $(patsubst $(obj)/%,%,$(__clean-files)) | xargs rm -rf 42 44 43 45 __clean: $(subdir-ymn) 44 46 ifneq ($(strip $(__clean-files)),)
+2 -2
scripts/Makefile.compiler
··· 32 32 # Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,) 33 33 34 34 as-option = $(call try-run,\ 35 - $(CC) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) 35 + $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) 36 36 37 37 # as-instr 38 38 # Usage: aflags-y += $(call as-instr,instr,option1,option2) 39 39 40 40 as-instr = $(call try-run,\ 41 - printf "%b\n" "$(1)" | $(CC) -Werror $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) 41 + printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) 42 42 43 43 # __cc-option 44 44 # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
-3
scripts/Makefile.lib
··· 418 418 $(obj)/%.dtb: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE 419 419 $(call if_changed_dep,dtb) 420 420 421 - $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE 422 - $(call if_changed_dep,dtc) 423 - 424 421 $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE 425 422 $(call if_changed_dep,dtc) 426 423
+1 -1
scripts/Makefile.modfinal
··· 23 23 part-of-module = y 24 24 25 25 quiet_cmd_cc_o_c = CC [M] $@ 26 - cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI), $(c_flags)) -c -o $@ $< 26 + cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI) $(CFLAGS_GCOV), $(c_flags)) -c -o $@ $< 27 27 28 28 %.mod.o: %.mod.c FORCE 29 29 $(call if_changed_dep,cc_o_c)
+8
scripts/Makefile.modpost
··· 47 47 $(if $(KBUILD_MODPOST_WARN),-w) \ 48 48 $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ 49 49 $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \ 50 + $(if $(findstring 1, $(KBUILD_EXTRA_WARN)),-W) \ 50 51 -o $@ 51 52 52 53 modpost-deps := $(MODPOST) ··· 90 89 targets += .vmlinux.objs 91 90 .vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE 92 91 $(call if_changed,vmlinux_objs) 92 + 93 + ifdef CONFIG_TRIM_UNUSED_KSYMS 94 + ksym-wl := $(CONFIG_UNUSED_KSYMS_WHITELIST) 95 + ksym-wl := $(if $(filter-out /%, $(ksym-wl)),$(srctree)/)$(ksym-wl) 96 + modpost-args += -t $(addprefix -u , $(ksym-wl)) 97 + modpost-deps += $(ksym-wl) 98 + endif 93 99 94 100 ifeq ($(wildcard vmlinux.o),) 95 101 missing-input := vmlinux.o
+1
scripts/Makefile.vmlinux
··· 19 19 20 20 ifdef CONFIG_MODULES 21 21 KASAN_SANITIZE_.vmlinux.export.o := n 22 + GCOV_PROFILE_.vmlinux.export.o := n 22 23 targets += .vmlinux.export.o 23 24 vmlinux: .vmlinux.export.o 24 25 endif
-73
scripts/adjust_autoksyms.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0-only 3 - 4 - # Script to update include/generated/autoksyms.h and dependency files 5 - # 6 - # Copyright: (C) 2016 Linaro Limited 7 - # Created by: Nicolas Pitre, January 2016 8 - # 9 - 10 - # Update the include/generated/autoksyms.h file. 11 - # 12 - # For each symbol being added or removed, the corresponding dependency 13 - # file's timestamp is updated to force a rebuild of the affected source 14 - # file. All arguments passed to this script are assumed to be a command 15 - # to be exec'd to trigger a rebuild of those files. 16 - 17 - set -e 18 - 19 - cur_ksyms_file="include/generated/autoksyms.h" 20 - new_ksyms_file="include/generated/autoksyms.h.tmpnew" 21 - 22 - info() { 23 - if [ "$quiet" != "silent_" ]; then 24 - printf " %-7s %s\n" "$1" "$2" 25 - fi 26 - } 27 - 28 - info "CHK" "$cur_ksyms_file" 29 - 30 - # Use "make V=1" to debug this script. 31 - case "$KBUILD_VERBOSE" in 32 - *1*) 33 - set -x 34 - ;; 35 - esac 36 - 37 - # Generate a new symbol list file 38 - $CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh --modorder "$new_ksyms_file" 39 - 40 - # Extract changes between old and new list and touch corresponding 41 - # dependency files. 42 - changed=$( 43 - count=0 44 - sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u | 45 - sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | 46 - while read sympath; do 47 - if [ -z "$sympath" ]; then continue; fi 48 - depfile="include/ksym/${sympath}" 49 - mkdir -p "$(dirname "$depfile")" 50 - touch "$depfile" 51 - # Filesystems with coarse time precision may create timestamps 52 - # equal to the one from a file that was very recently built and that 53 - # needs to be rebuild. Let's guard against that by making sure our 54 - # dep files are always newer than the first file we created here. 55 - while [ ! "$depfile" -nt "$new_ksyms_file" ]; do 56 - touch "$depfile" 57 - done 58 - echo $((count += 1)) 59 - done | tail -1 ) 60 - changed=${changed:-0} 61 - 62 - if [ $changed -gt 0 ]; then 63 - # Replace the old list with tne new one 64 - old=$(grep -c "^#define __KSYM_" "$cur_ksyms_file" || true) 65 - new=$(grep -c "^#define __KSYM_" "$new_ksyms_file" || true) 66 - info "KSYMS" "symbols: before=$old, after=$new, changed=$changed" 67 - info "UPD" "$cur_ksyms_file" 68 - mv -f "$new_ksyms_file" "$cur_ksyms_file" 69 - # Then trigger a rebuild of affected source files 70 - exec $@ 71 - else 72 - rm -f "$new_ksyms_file" 73 - fi
+1 -2
scripts/basic/fixdep.c
··· 246 246 /* Ignore certain dependencies */ 247 247 static int is_ignored_file(const char *s, int len) 248 248 { 249 - return str_ends_with(s, len, "include/generated/autoconf.h") || 250 - str_ends_with(s, len, "include/generated/autoksyms.h"); 249 + return str_ends_with(s, len, "include/generated/autoconf.h"); 251 250 } 252 251 253 252 /* Do not parse these files */
-70
scripts/check-local-export
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0-only 3 - # 4 - # Copyright (C) 2022 Masahiro Yamada <masahiroy@kernel.org> 5 - # Copyright (C) 2022 Owen Rafferty <owen@owenrafferty.com> 6 - # 7 - # Exit with error if a local exported symbol is found. 8 - # EXPORT_SYMBOL should be used for global symbols. 9 - 10 - set -e 11 - pid=$$ 12 - 13 - # If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm) shows 14 - # 'no symbols' diagnostic (but exits with 0). It is harmless and hidden by 15 - # '2>/dev/null'. However, it suppresses real error messages as well. Add a 16 - # hand-crafted error message here. 17 - # 18 - # TODO: 19 - # Use --quiet instead of 2>/dev/null when we upgrade the minimum version of 20 - # binutils to 2.37, llvm to 13.0.0. 21 - # Then, the following line will be simpler: 22 - # { ${NM} --quiet ${1} || kill 0; } | 23 - 24 - { ${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; kill $pid; } } | 25 - ${AWK} -v "file=${1}" ' 26 - BEGIN { 27 - i = 0 28 - } 29 - 30 - # Skip the line if the number of fields is less than 3. 31 - # 32 - # case 1) 33 - # For undefined symbols, the first field (value) is empty. 34 - # The outout looks like this: 35 - # " U _printk" 36 - # It is unneeded to record undefined symbols. 37 - # 38 - # case 2) 39 - # For Clang LTO, llvm-nm outputs a line with type t but empty name: 40 - # "---------------- t" 41 - !length($3) { 42 - next 43 - } 44 - 45 - # save (name, type) in the associative array 46 - { symbol_types[$3]=$2 } 47 - 48 - # append the exported symbol to the array 49 - ($3 ~ /^__ksymtab_/) { 50 - export_symbols[i] = $3 51 - sub(/^__ksymtab_/, "", export_symbols[i]) 52 - i++ 53 - } 54 - 55 - END { 56 - exit_code = 0 57 - for (j = 0; j < i; ++j) { 58 - name = export_symbols[j] 59 - # nm(3) says "If lowercase, the symbol is usually local" 60 - if (symbol_types[name] ~ /[a-z]/) { 61 - printf "%s: error: local symbol %s was exported\n", 62 - file, name | "cat 1>&2" 63 - exit_code = 1 64 - } 65 - } 66 - 67 - exit exit_code 68 - }' 69 - 70 - exit $?
-62
scripts/gen_autoksyms.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0-only 3 - 4 - # Create an autoksyms.h header file from the list of all module's needed symbols 5 - # as recorded in *.usyms files and the user-provided symbol whitelist. 6 - 7 - set -e 8 - 9 - # Use "make V=1" to debug this script. 10 - case "$KBUILD_VERBOSE" in 11 - *1*) 12 - set -x 13 - ;; 14 - esac 15 - 16 - read_modorder= 17 - 18 - if [ "$1" = --modorder ]; then 19 - shift 20 - read_modorder=1 21 - fi 22 - 23 - output_file="$1" 24 - 25 - needed_symbols= 26 - 27 - # Special case for modversions (see modpost.c) 28 - if grep -q "^CONFIG_MODVERSIONS=y$" include/config/auto.conf; then 29 - needed_symbols="$needed_symbols module_layout" 30 - fi 31 - 32 - ksym_wl=$(sed -n 's/^CONFIG_UNUSED_KSYMS_WHITELIST=\(.*\)$/\1/p' include/config/auto.conf) 33 - if [ -n "$ksym_wl" ]; then 34 - [ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl" 35 - if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then 36 - echo "ERROR: '$ksym_wl' whitelist file not found" >&2 37 - exit 1 38 - fi 39 - fi 40 - 41 - # Generate a new ksym list file with symbols needed by the current 42 - # set of modules. 43 - cat > "$output_file" << EOT 44 - /* 45 - * Automatically generated file; DO NOT EDIT. 46 - */ 47 - 48 - EOT 49 - 50 - { 51 - [ -n "${read_modorder}" ] && sed 's/o$/usyms/' modules.order | xargs cat 52 - echo "$needed_symbols" 53 - [ -n "$ksym_wl" ] && cat "$ksym_wl" 54 - } | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' | 55 - # Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry 56 - # point addresses. 57 - sed -e 's/^\.//' | 58 - sort -u | 59 - # Ignore __this_module. It's not an exported symbol, and will be resolved 60 - # when the final .ko's are linked. 61 - grep -v '^__this_module$' | 62 - sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
-30
scripts/gen_ksymdeps.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - set -e 5 - 6 - # List of exported symbols 7 - # 8 - # If the object has no symbol, $NM warns 'no symbols'. 9 - # Suppress the stderr. 10 - # TODO: 11 - # Use -q instead of 2>/dev/null when we upgrade the minimum version of 12 - # binutils to 2.37, llvm to 13.0.0. 13 - ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p') 14 - 15 - if [ -z "$ksyms" ]; then 16 - exit 0 17 - fi 18 - 19 - echo 20 - echo "ksymdeps_$1 := \\" 21 - 22 - for s in $ksyms 23 - do 24 - printf ' $(wildcard include/ksym/%s) \\\n' "$s" 25 - done 26 - 27 - echo 28 - echo "$1: \$(ksymdeps_$1)" 29 - echo 30 - echo "\$(ksymdeps_$1):"
+33 -30
scripts/kallsyms.c
··· 19 19 * 20 20 */ 21 21 22 + #include <errno.h> 22 23 #include <getopt.h> 23 24 #include <stdbool.h> 24 25 #include <stdio.h> ··· 30 29 31 30 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) 32 31 33 - #define _stringify_1(x) #x 34 - #define _stringify(x) _stringify_1(x) 35 - 36 32 #define KSYM_NAME_LEN 512 37 - 38 - /* 39 - * A substantially bigger size than the current maximum. 40 - * 41 - * It cannot be defined as an expression because it gets stringified 42 - * for the fscanf() format string. Therefore, a _Static_assert() is 43 - * used instead to maintain the relationship with KSYM_NAME_LEN. 44 - */ 45 - #define KSYM_NAME_LEN_BUFFER 2048 46 - _Static_assert( 47 - KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4, 48 - "Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN" 49 - ); 50 33 51 34 struct sym_entry { 52 35 unsigned long long addr; ··· 121 136 } 122 137 } 123 138 124 - static struct sym_entry *read_symbol(FILE *in) 139 + static struct sym_entry *read_symbol(FILE *in, char **buf, size_t *buf_len) 125 140 { 126 - char name[KSYM_NAME_LEN_BUFFER+1], type; 141 + char *name, type, *p; 127 142 unsigned long long addr; 128 - unsigned int len; 143 + size_t len; 144 + ssize_t readlen; 129 145 struct sym_entry *sym; 130 - int rc; 131 146 132 - rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN_BUFFER) "s\n", &addr, &type, name); 133 - if (rc != 3) { 134 - if (rc != EOF && fgets(name, ARRAY_SIZE(name), in) == NULL) 135 - fprintf(stderr, "Read error or end of file.\n"); 147 + readlen = getline(buf, buf_len, in); 148 + if (readlen < 0) { 149 + if (errno) { 150 + perror("read_symbol"); 151 + exit(EXIT_FAILURE); 152 + } 136 153 return NULL; 137 154 } 138 - if (strlen(name) >= KSYM_NAME_LEN) { 155 + 156 + if ((*buf)[readlen - 1] == '\n') 157 + (*buf)[readlen - 1] = 0; 158 + 159 + addr = strtoull(*buf, &p, 16); 160 + 161 + if (*buf == p || *p++ != ' ' || !isascii((type = *p++)) || *p++ != ' ') { 162 + fprintf(stderr, "line format error\n"); 163 + exit(EXIT_FAILURE); 164 + } 165 + 166 + name = p; 167 + len = strlen(name); 168 + 169 + if (len >= KSYM_NAME_LEN) { 139 170 fprintf(stderr, "Symbol %s too long for kallsyms (%zu >= %d).\n" 140 171 "Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n", 141 - name, strlen(name), KSYM_NAME_LEN); 172 + name, len, KSYM_NAME_LEN); 142 173 return NULL; 143 174 } 144 175 ··· 170 169 171 170 /* include the type field in the symbol name, so that it gets 172 171 * compressed together */ 173 - 174 - len = strlen(name) + 1; 172 + len++; 175 173 176 174 sym = malloc(sizeof(*sym) + len + 1); 177 175 if (!sym) { ··· 257 257 { 258 258 FILE *fp; 259 259 struct sym_entry *sym; 260 + char *buf = NULL; 261 + size_t buflen = 0; 260 262 261 263 fp = fopen(in, "r"); 262 264 if (!fp) { ··· 267 265 } 268 266 269 267 while (!feof(fp)) { 270 - sym = read_symbol(fp); 268 + sym = read_symbol(fp, &buf, &buflen); 271 269 if (!sym) 272 270 continue; 273 271 ··· 286 284 table[table_cnt++] = sym; 287 285 } 288 286 287 + free(buf); 289 288 fclose(fp); 290 289 } 291 290 ··· 809 806 int main(int argc, char **argv) 810 807 { 811 808 while (1) { 812 - static struct option long_options[] = { 809 + static const struct option long_options[] = { 813 810 {"all-symbols", no_argument, &all_symbols, 1}, 814 811 {"absolute-percpu", no_argument, &absolute_percpu, 1}, 815 812 {"base-relative", no_argument, &base_relative, 1},
+1 -1
scripts/kconfig/streamline_config.pl
··· 317 317 $_ = convert_vars($_, %make_vars); 318 318 319 319 # collect objects after obj-$(CONFIG_FOO_BAR) 320 - if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { 320 + if (/obj-\$[({](CONFIG_[^})]*)[)}]\s*[+:]?=\s*(.*)/) { 321 321 $var = $1; 322 322 $objs = $2; 323 323
+23 -5
scripts/kernel-doc
··· 23 23 24 24 =head1 SYNOPSIS 25 25 26 - kernel-doc [-h] [-v] [-Werror] 26 + kernel-doc [-h] [-v] [-Werror] [-Wall] [-Wreturn] [-Wshort-description] [-Wcontents-before-sections] 27 27 [ -man | 28 28 -rst [-sphinx-version VERSION] [-enable-lineno] | 29 29 -none ··· 133 133 134 134 my $verbose = 0; 135 135 my $Werror = 0; 136 + my $Wreturn = 0; 137 + my $Wshort_desc = 0; 138 + my $Wcontents_before_sections = 0; 136 139 my $output_mode = "rst"; 137 140 my $output_preformatted = 0; 138 141 my $no_doc_sections = 0; ··· 190 187 } 191 188 } 192 189 190 + # reading this variable is for backwards compat just in case 191 + # someone was calling it with the variable from outside the 192 + # kernel's build system 193 193 if (defined($ENV{'KDOC_WERROR'})) { 194 194 $Werror = "$ENV{'KDOC_WERROR'}"; 195 195 } 196 + # other environment variables are converted to command-line 197 + # arguments in cmd_checkdoc in the build system 196 198 197 199 # Generated docbook code is inserted in a template at a point where 198 200 # docbook v3.1 requires a non-zero sequence of RefEntry's; see: ··· 326 318 $verbose = 1; 327 319 } elsif ($cmd eq "Werror") { 328 320 $Werror = 1; 321 + } elsif ($cmd eq "Wreturn") { 322 + $Wreturn = 1; 323 + } elsif ($cmd eq "Wshort-desc") { 324 + $Wshort_desc = 1; 325 + } elsif ($cmd eq "Wcontents-before-sections") { 326 + $Wcontents_before_sections = 1; 327 + } elsif ($cmd eq "Wall") { 328 + $Wreturn = 1; 329 + $Wshort_desc = 1; 330 + $Wcontents_before_sections = 1; 329 331 } elsif (($cmd eq "h") || ($cmd eq "help")) { 330 332 pod2usage(-exitval => 0, -verbose => 2); 331 333 } elsif ($cmd eq 'no-doc-sections') { ··· 1766 1748 # This check emits a lot of warnings at the moment, because many 1767 1749 # functions don't have a 'Return' doc section. So until the number 1768 1750 # of warnings goes sufficiently down, the check is only performed in 1769 - # verbose mode. 1751 + # -Wreturn mode. 1770 1752 # TODO: always perform the check. 1771 - if ($verbose && !$noret) { 1753 + if ($Wreturn && !$noret) { 1772 1754 check_return_section($file, $declaration_name, $return_type); 1773 1755 } 1774 1756 ··· 2072 2054 $state = STATE_NORMAL; 2073 2055 } 2074 2056 2075 - if (($declaration_purpose eq "") && $verbose) { 2057 + if (($declaration_purpose eq "") && $Wshort_desc) { 2076 2058 emit_warning("${file}:$.", "missing initial short description on line:\n$_"); 2077 2059 } 2078 2060 ··· 2121 2103 } 2122 2104 2123 2105 if (($contents ne "") && ($contents ne "\n")) { 2124 - if (!$in_doc_sect && $verbose) { 2106 + if (!$in_doc_sect && $Wcontents_before_sections) { 2125 2107 emit_warning("${file}:$.", "contents before sections\n"); 2126 2108 } 2127 2109 dump_section($file, $section, $contents);
+8 -2
scripts/mksysmap
··· 32 32 # (do not forget a space before each pattern) 33 33 34 34 # local symbols for ARM, MIPS, etc. 35 - / \$/d 35 + / \\$/d 36 36 37 37 # local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc. 38 38 / \.L/d ··· 40 40 # arm64 EFI stub namespace 41 41 / __efistub_/d 42 42 43 + # arm64 local symbols in PIE namespace 44 + / __pi_\\$/d 45 + / __pi_\.L/d 46 + 43 47 # arm64 local symbols in non-VHE KVM namespace 44 - / __kvm_nvhe_\$/d 48 + / __kvm_nvhe_\\$/d 45 49 / __kvm_nvhe_\.L/d 46 50 47 51 # arm64 lld ··· 62 58 63 59 # CFI type identifiers 64 60 / __kcfi_typeid_/d 61 + / __kvm_nvhe___kcfi_typeid_/d 62 + / __pi___kcfi_typeid_/d 65 63 66 64 # CRC from modversions 67 65 / __crc_/d
+379 -420
scripts/mod/modpost.c
··· 35 35 36 36 static int sec_mismatch_count; 37 37 static bool sec_mismatch_warn_only = true; 38 + /* Trim EXPORT_SYMBOLs that are unused by in-tree modules */ 39 + static bool trim_unused_exports; 40 + 38 41 /* ignore missing files */ 39 42 static bool ignore_missing_files; 40 43 /* If set to 1, only warn (instead of error) about missing ns imports */ 41 44 static bool allow_missing_ns_imports; 42 45 43 46 static bool error_occurred; 47 + 48 + static bool extra_warn; 44 49 45 50 /* 46 51 * Cut off the warnings when there are too many. This typically occurs when ··· 220 215 unsigned int crc; 221 216 bool crc_valid; 222 217 bool weak; 218 + bool is_func; 223 219 bool is_gpl_only; /* exported by EXPORT_SYMBOL_GPL */ 220 + bool used; /* there exists a user of this symbol */ 224 221 char name[]; 225 222 }; 226 223 ··· 304 297 { 305 298 struct namespace_list *list; 306 299 300 + /* 301 + * The default namespace is null string "", which is always implicitly 302 + * contained. 303 + */ 304 + if (!namespace[0]) 305 + return true; 306 + 307 307 list_for_each_entry(list, head, list) { 308 308 if (!strcmp(list->namespace, namespace)) 309 309 return true; ··· 366 352 367 353 #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) 368 354 369 - static void sym_update_namespace(const char *symname, const char *namespace) 370 - { 371 - struct symbol *s = find_symbol(symname); 372 - 373 - /* 374 - * That symbol should have been created earlier and thus this is 375 - * actually an assertion. 376 - */ 377 - if (!s) { 378 - error("Could not update namespace(%s) for symbol %s\n", 379 - namespace, symname); 380 - return; 381 - } 382 - 383 - free(s->namespace); 384 - s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL; 385 - } 386 - 387 355 static struct symbol *sym_add_exported(const char *name, struct module *mod, 388 - bool gpl_only) 356 + bool gpl_only, const char *namespace) 389 357 { 390 358 struct symbol *s = find_symbol(name); 391 359 ··· 380 384 s = alloc_symbol(name); 381 385 s->module = mod; 382 386 s->is_gpl_only = gpl_only; 387 + s->namespace = NOFAIL(strdup(namespace)); 383 388 list_add_tail(&s->list, &mod->exported_symbols); 384 389 hash_add_symbol(s); 385 390 ··· 528 531 fatal("%s has NOBITS .modinfo\n", filename); 529 532 info->modinfo = (void *)hdr + sechdrs[i].sh_offset; 530 533 info->modinfo_len = sechdrs[i].sh_size; 534 + } else if (!strcmp(secname, ".export_symbol")) { 535 + info->export_symbol_secndx = i; 531 536 } 532 537 533 538 if (sechdrs[i].sh_type == SHT_SYMTAB) { ··· 652 653 ELF_ST_BIND(sym->st_info) == STB_WEAK); 653 654 break; 654 655 default: 655 - /* All exported symbols */ 656 - if (strstarts(symname, "__ksymtab_")) { 657 - const char *name, *secname; 658 - 659 - name = symname + strlen("__ksymtab_"); 660 - secname = sec_name(info, get_secindex(info, sym)); 661 - 662 - if (strstarts(secname, "___ksymtab_gpl+")) 663 - sym_add_exported(name, mod, true); 664 - else if (strstarts(secname, "___ksymtab+")) 665 - sym_add_exported(name, mod, false); 666 - } 667 656 if (strcmp(symname, "init_module") == 0) 668 657 mod->has_init = true; 669 658 if (strcmp(symname, "cleanup_module") == 0) ··· 825 838 #define ALL_TEXT_SECTIONS ALL_INIT_TEXT_SECTIONS, ALL_EXIT_TEXT_SECTIONS, \ 826 839 TEXT_SECTIONS, OTHER_TEXT_SECTIONS 827 840 828 - /* init data sections */ 829 - static const char *const init_data_sections[] = 830 - { ALL_INIT_DATA_SECTIONS, NULL }; 831 - 832 - /* all init sections */ 833 - static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL }; 834 - 835 - /* all text sections */ 836 - static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL }; 837 - 838 - /* data section */ 839 - static const char *const data_sections[] = { DATA_SECTIONS, NULL }; 840 - 841 - static const char *const head_sections[] = { ".head.text*", NULL }; 842 - static const char *const linker_symbols[] = 843 - { "__init_begin", "_sinittext", "_einittext", NULL }; 844 - static const char *const optim_symbols[] = { "*.constprop.*", NULL }; 845 - 846 841 enum mismatch { 847 842 TEXT_TO_ANY_INIT, 848 843 DATA_TO_ANY_INIT, 849 - TEXT_TO_ANY_EXIT, 850 - DATA_TO_ANY_EXIT, 844 + TEXTDATA_TO_ANY_EXIT, 851 845 XXXINIT_TO_SOME_INIT, 852 846 XXXEXIT_TO_SOME_EXIT, 853 847 ANY_INIT_TO_ANY_EXIT, 854 848 ANY_EXIT_TO_ANY_INIT, 855 - EXPORT_TO_INIT_EXIT, 856 849 EXTABLE_TO_NON_TEXT, 857 850 }; 858 851 ··· 848 881 * targeting sections in this array (white-list). Can be empty. 849 882 * 850 883 * @mismatch: Type of mismatch. 851 - * 852 - * @handler: Specific handler to call when a match is found. If NULL, 853 - * default_mismatch_handler() will be called. 854 - * 855 884 */ 856 885 struct sectioncheck { 857 886 const char *fromsec[20]; 858 887 const char *bad_tosec[20]; 859 888 const char *good_tosec[20]; 860 889 enum mismatch mismatch; 861 - void (*handler)(const char *modname, struct elf_info *elf, 862 - const struct sectioncheck* const mismatch, 863 - Elf_Rela *r, Elf_Sym *sym, const char *fromsec); 864 - 865 890 }; 866 - 867 - static void extable_mismatch_handler(const char *modname, struct elf_info *elf, 868 - const struct sectioncheck* const mismatch, 869 - Elf_Rela *r, Elf_Sym *sym, 870 - const char *fromsec); 871 891 872 892 static const struct sectioncheck sectioncheck[] = { 873 893 /* Do not reference init/exit code/data from ··· 867 913 }, 868 914 { 869 915 .fromsec = { DATA_SECTIONS, NULL }, 870 - .bad_tosec = { ALL_XXXINIT_SECTIONS, NULL }, 916 + .bad_tosec = { ALL_XXXINIT_SECTIONS, INIT_SECTIONS, NULL }, 871 917 .mismatch = DATA_TO_ANY_INIT, 872 918 }, 873 919 { 874 - .fromsec = { DATA_SECTIONS, NULL }, 875 - .bad_tosec = { INIT_SECTIONS, NULL }, 876 - .mismatch = DATA_TO_ANY_INIT, 877 - }, 878 - { 879 - .fromsec = { TEXT_SECTIONS, NULL }, 920 + .fromsec = { TEXT_SECTIONS, DATA_SECTIONS, NULL }, 880 921 .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, 881 - .mismatch = TEXT_TO_ANY_EXIT, 882 - }, 883 - { 884 - .fromsec = { DATA_SECTIONS, NULL }, 885 - .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, 886 - .mismatch = DATA_TO_ANY_EXIT, 922 + .mismatch = TEXTDATA_TO_ANY_EXIT, 887 923 }, 888 924 /* Do not reference init code/data from meminit code/data */ 889 925 { ··· 904 960 .bad_tosec = { INIT_SECTIONS, NULL }, 905 961 .mismatch = ANY_INIT_TO_ANY_EXIT, 906 962 }, 907 - /* Do not export init/exit functions or data */ 908 - { 909 - .fromsec = { "___ksymtab*", NULL }, 910 - .bad_tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL }, 911 - .mismatch = EXPORT_TO_INIT_EXIT, 912 - }, 913 963 { 914 964 .fromsec = { "__ex_table", NULL }, 915 965 /* If you're adding any new black-listed sections in here, consider ··· 912 974 .bad_tosec = { ".altinstr_replacement", NULL }, 913 975 .good_tosec = {ALL_TEXT_SECTIONS , NULL}, 914 976 .mismatch = EXTABLE_TO_NON_TEXT, 915 - .handler = extable_mismatch_handler, 916 977 } 917 978 }; 918 979 ··· 985 1048 * fromsec = text section 986 1049 * refsymname = *.constprop.* 987 1050 * 988 - * Pattern 6: 989 - * Hide section mismatch warnings for ELF local symbols. The goal 990 - * is to eliminate false positive modpost warnings caused by 991 - * compiler-generated ELF local symbol names such as ".LANCHOR1". 992 - * Autogenerated symbol names bypass modpost's "Pattern 2" 993 - * whitelisting, which relies on pattern-matching against symbol 994 - * names to work. (One situation where gcc can autogenerate ELF 995 - * local symbols is when "-fsection-anchors" is used.) 996 1051 **/ 997 - static int secref_whitelist(const struct sectioncheck *mismatch, 998 - const char *fromsec, const char *fromsym, 1052 + static int secref_whitelist(const char *fromsec, const char *fromsym, 999 1053 const char *tosec, const char *tosym) 1000 1054 { 1001 1055 /* Check for pattern 1 */ 1002 - if (match(tosec, init_data_sections) && 1003 - match(fromsec, data_sections) && 1056 + if (match(tosec, PATTERNS(ALL_INIT_DATA_SECTIONS)) && 1057 + match(fromsec, PATTERNS(DATA_SECTIONS)) && 1004 1058 strstarts(fromsym, "__param")) 1005 1059 return 0; 1006 1060 1007 1061 /* Check for pattern 1a */ 1008 1062 if (strcmp(tosec, ".init.text") == 0 && 1009 - match(fromsec, data_sections) && 1063 + match(fromsec, PATTERNS(DATA_SECTIONS)) && 1010 1064 strstarts(fromsym, "__param_ops_")) 1011 1065 return 0; 1012 1066 ··· 1020 1092 return 0; 1021 1093 1022 1094 /* Check for pattern 3 */ 1023 - if (match(fromsec, head_sections) && 1024 - match(tosec, init_sections)) 1095 + if (strstarts(fromsec, ".head.text") && 1096 + match(tosec, PATTERNS(ALL_INIT_SECTIONS))) 1025 1097 return 0; 1026 1098 1027 1099 /* Check for pattern 4 */ 1028 - if (match(tosym, linker_symbols)) 1100 + if (match(tosym, PATTERNS("__init_begin", "_sinittext", "_einittext"))) 1029 1101 return 0; 1030 1102 1031 1103 /* Check for pattern 5 */ 1032 - if (match(fromsec, text_sections) && 1033 - match(tosec, init_sections) && 1034 - match(fromsym, optim_symbols)) 1035 - return 0; 1036 - 1037 - /* Check for pattern 6 */ 1038 - if (strstarts(fromsym, ".L")) 1104 + if (match(fromsec, PATTERNS(ALL_TEXT_SECTIONS)) && 1105 + match(tosec, PATTERNS(ALL_INIT_SECTIONS)) && 1106 + match(fromsym, PATTERNS("*.constprop.*"))) 1039 1107 return 0; 1040 1108 1041 1109 return 1; ··· 1055 1131 return !is_mapping_symbol(name); 1056 1132 } 1057 1133 1058 - /** 1059 - * Find symbol based on relocation record info. 1060 - * In some cases the symbol supplied is a valid symbol so 1061 - * return refsym. If st_name != 0 we assume this is a valid symbol. 1062 - * In other cases the symbol needs to be looked up in the symbol table 1063 - * based on section and address. 1064 - * **/ 1065 - static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, 1066 - Elf_Sym *relsym) 1134 + /* Look up the nearest symbol based on the section and the address */ 1135 + static Elf_Sym *find_nearest_sym(struct elf_info *elf, Elf_Addr addr, 1136 + unsigned int secndx, bool allow_negative, 1137 + Elf_Addr min_distance) 1067 1138 { 1068 1139 Elf_Sym *sym; 1069 1140 Elf_Sym *near = NULL; 1070 - Elf64_Sword distance = 20; 1071 - Elf64_Sword d; 1072 - unsigned int relsym_secindex; 1141 + Elf_Addr sym_addr, distance; 1142 + bool is_arm = (elf->hdr->e_machine == EM_ARM); 1073 1143 1074 - if (relsym->st_name != 0) 1075 - return relsym; 1076 - 1077 - relsym_secindex = get_secindex(elf, relsym); 1078 1144 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 1079 - if (get_secindex(elf, sym) != relsym_secindex) 1080 - continue; 1081 - if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) 1145 + if (get_secindex(elf, sym) != secndx) 1082 1146 continue; 1083 1147 if (!is_valid_name(elf, sym)) 1084 1148 continue; 1085 - if (sym->st_value == addr) 1086 - return sym; 1087 - /* Find a symbol nearby - addr are maybe negative */ 1088 - d = sym->st_value - addr; 1089 - if (d < 0) 1090 - d = addr - sym->st_value; 1091 - if (d < distance) { 1092 - distance = d; 1149 + 1150 + sym_addr = sym->st_value; 1151 + 1152 + /* 1153 + * For ARM Thumb instruction, the bit 0 of st_value is set 1154 + * if the symbol is STT_FUNC type. Mask it to get the address. 1155 + */ 1156 + if (is_arm && ELF_ST_TYPE(sym->st_info) == STT_FUNC) 1157 + sym_addr &= ~1; 1158 + 1159 + if (addr >= sym_addr) 1160 + distance = addr - sym_addr; 1161 + else if (allow_negative) 1162 + distance = sym_addr - addr; 1163 + else 1164 + continue; 1165 + 1166 + if (distance <= min_distance) { 1167 + min_distance = distance; 1093 1168 near = sym; 1094 1169 } 1095 - } 1096 - /* We need a close match */ 1097 - if (distance < 20) 1098 - return near; 1099 - else 1100 - return NULL; 1101 - } 1102 1170 1103 - /* 1104 - * Find symbols before or equal addr and after addr - in the section sec. 1105 - * If we find two symbols with equal offset prefer one with a valid name. 1106 - * The ELF format may have a better way to detect what type of symbol 1107 - * it is, but this works for now. 1108 - **/ 1109 - static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, 1110 - const char *sec) 1111 - { 1112 - Elf_Sym *sym; 1113 - Elf_Sym *near = NULL; 1114 - Elf_Addr distance = ~0; 1115 - 1116 - for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 1117 - const char *symsec; 1118 - 1119 - if (is_shndx_special(sym->st_shndx)) 1120 - continue; 1121 - symsec = sec_name(elf, get_secindex(elf, sym)); 1122 - if (strcmp(symsec, sec) != 0) 1123 - continue; 1124 - if (!is_valid_name(elf, sym)) 1125 - continue; 1126 - if (sym->st_value <= addr && addr - sym->st_value <= distance) { 1127 - distance = addr - sym->st_value; 1128 - near = sym; 1129 - } 1171 + if (min_distance == 0) 1172 + break; 1130 1173 } 1131 1174 return near; 1132 1175 } 1133 1176 1134 - static int is_function(Elf_Sym *sym) 1177 + static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr, 1178 + unsigned int secndx) 1135 1179 { 1136 - if (sym) 1137 - return ELF_ST_TYPE(sym->st_info) == STT_FUNC; 1138 - else 1139 - return -1; 1180 + return find_nearest_sym(elf, addr, secndx, false, ~0); 1140 1181 } 1141 1182 1142 - static inline void get_pretty_name(int is_func, const char** name, const char** name_p) 1183 + static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym) 1143 1184 { 1144 - switch (is_func) { 1145 - case 0: *name = "variable"; *name_p = ""; break; 1146 - case 1: *name = "function"; *name_p = "()"; break; 1147 - default: *name = "(unknown reference)"; *name_p = ""; break; 1148 - } 1185 + /* If the supplied symbol has a valid name, return it */ 1186 + if (is_valid_name(elf, sym)) 1187 + return sym; 1188 + 1189 + /* 1190 + * Strive to find a better symbol name, but the resulting name may not 1191 + * match the symbol referenced in the original code. 1192 + */ 1193 + return find_nearest_sym(elf, addr, get_secindex(elf, sym), true, 20); 1149 1194 } 1150 1195 1151 - /* 1152 - * Print a warning about a section mismatch. 1153 - * Try to find symbols near it so user can find it. 1154 - * Check whitelist before warning - it may be a false positive. 1155 - */ 1156 - static void report_sec_mismatch(const char *modname, 1157 - const struct sectioncheck *mismatch, 1158 - const char *fromsec, 1159 - const char *fromsym, 1160 - const char *tosec, const char *tosym) 1196 + static bool is_executable_section(struct elf_info *elf, unsigned int secndx) 1161 1197 { 1162 - sec_mismatch_count++; 1198 + if (secndx >= elf->num_sections) 1199 + return false; 1163 1200 1164 - switch (mismatch->mismatch) { 1165 - case TEXT_TO_ANY_INIT: 1166 - case DATA_TO_ANY_INIT: 1167 - case TEXT_TO_ANY_EXIT: 1168 - case DATA_TO_ANY_EXIT: 1169 - case XXXINIT_TO_SOME_INIT: 1170 - case XXXEXIT_TO_SOME_EXIT: 1171 - case ANY_INIT_TO_ANY_EXIT: 1172 - case ANY_EXIT_TO_ANY_INIT: 1173 - warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n", 1174 - modname, fromsym, fromsec, tosym, tosec); 1175 - break; 1176 - case EXPORT_TO_INIT_EXIT: 1177 - warn("%s: EXPORT_SYMBOL used for init/exit symbol: %s (section: %s)\n", 1178 - modname, tosym, tosec); 1179 - break; 1180 - case EXTABLE_TO_NON_TEXT: 1181 - fatal("There's a special handler for this mismatch type, we should never get here.\n"); 1182 - break; 1183 - } 1201 + return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0; 1184 1202 } 1185 1203 1186 1204 static void default_mismatch_handler(const char *modname, struct elf_info *elf, 1187 1205 const struct sectioncheck* const mismatch, 1188 - Elf_Rela *r, Elf_Sym *sym, const char *fromsec) 1206 + Elf_Sym *tsym, 1207 + unsigned int fsecndx, const char *fromsec, Elf_Addr faddr, 1208 + const char *tosec, Elf_Addr taddr) 1189 1209 { 1190 - const char *tosec; 1191 - Elf_Sym *to; 1192 1210 Elf_Sym *from; 1193 1211 const char *tosym; 1194 1212 const char *fromsym; 1195 1213 1196 - from = find_elf_symbol2(elf, r->r_offset, fromsec); 1214 + from = find_fromsym(elf, faddr, fsecndx); 1197 1215 fromsym = sym_name(elf, from); 1198 1216 1199 - tosec = sec_name(elf, get_secindex(elf, sym)); 1200 - to = find_elf_symbol(elf, r->r_addend, sym); 1201 - tosym = sym_name(elf, to); 1217 + tsym = find_tosym(elf, taddr, tsym); 1218 + tosym = sym_name(elf, tsym); 1202 1219 1203 1220 /* check whitelist - we may ignore it */ 1204 - if (secref_whitelist(mismatch, 1205 - fromsec, fromsym, tosec, tosym)) { 1206 - report_sec_mismatch(modname, mismatch, 1207 - fromsec, fromsym, tosec, tosym); 1208 - } 1209 - } 1210 - 1211 - static int is_executable_section(struct elf_info* elf, unsigned int section_index) 1212 - { 1213 - if (section_index > elf->num_sections) 1214 - fatal("section_index is outside elf->num_sections!\n"); 1215 - 1216 - return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); 1217 - } 1218 - 1219 - /* 1220 - * We rely on a gross hack in section_rel[a]() calling find_extable_entry_size() 1221 - * to know the sizeof(struct exception_table_entry) for the target architecture. 1222 - */ 1223 - static unsigned int extable_entry_size = 0; 1224 - static void find_extable_entry_size(const char* const sec, const Elf_Rela* r) 1225 - { 1226 - /* 1227 - * If we're currently checking the second relocation within __ex_table, 1228 - * that relocation offset tells us the offsetof(struct 1229 - * exception_table_entry, fixup) which is equal to sizeof(struct 1230 - * exception_table_entry) divided by two. We use that to our advantage 1231 - * since there's no portable way to get that size as every architecture 1232 - * seems to go with different sized types. Not pretty but better than 1233 - * hard-coding the size for every architecture.. 1234 - */ 1235 - if (!extable_entry_size) 1236 - extable_entry_size = r->r_offset * 2; 1237 - } 1238 - 1239 - static inline bool is_extable_fault_address(Elf_Rela *r) 1240 - { 1241 - /* 1242 - * extable_entry_size is only discovered after we've handled the 1243 - * _second_ relocation in __ex_table, so only abort when we're not 1244 - * handling the first reloc and extable_entry_size is zero. 1245 - */ 1246 - if (r->r_offset && extable_entry_size == 0) 1247 - fatal("extable_entry size hasn't been discovered!\n"); 1248 - 1249 - return ((r->r_offset == 0) || 1250 - (r->r_offset % extable_entry_size == 0)); 1251 - } 1252 - 1253 - #define is_second_extable_reloc(Start, Cur, Sec) \ 1254 - (((Cur) == (Start) + 1) && (strcmp("__ex_table", (Sec)) == 0)) 1255 - 1256 - static void report_extable_warnings(const char* modname, struct elf_info* elf, 1257 - const struct sectioncheck* const mismatch, 1258 - Elf_Rela* r, Elf_Sym* sym, 1259 - const char* fromsec, const char* tosec) 1260 - { 1261 - Elf_Sym* fromsym = find_elf_symbol2(elf, r->r_offset, fromsec); 1262 - const char* fromsym_name = sym_name(elf, fromsym); 1263 - Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym); 1264 - const char* tosym_name = sym_name(elf, tosym); 1265 - const char* from_pretty_name; 1266 - const char* from_pretty_name_p; 1267 - const char* to_pretty_name; 1268 - const char* to_pretty_name_p; 1269 - 1270 - get_pretty_name(is_function(fromsym), 1271 - &from_pretty_name, &from_pretty_name_p); 1272 - get_pretty_name(is_function(tosym), 1273 - &to_pretty_name, &to_pretty_name_p); 1274 - 1275 - warn("%s(%s+0x%lx): Section mismatch in reference from the %s %s%s to the %s %s:%s%s\n", 1276 - modname, fromsec, (long)r->r_offset, from_pretty_name, 1277 - fromsym_name, from_pretty_name_p, 1278 - to_pretty_name, tosec, tosym_name, to_pretty_name_p); 1279 - 1280 - if (!match(tosec, mismatch->bad_tosec) && 1281 - is_executable_section(elf, get_secindex(elf, sym))) 1282 - fprintf(stderr, 1283 - "The relocation at %s+0x%lx references\n" 1284 - "section \"%s\" which is not in the list of\n" 1285 - "authorized sections. If you're adding a new section\n" 1286 - "and/or if this reference is valid, add \"%s\" to the\n" 1287 - "list of authorized sections to jump to on fault.\n" 1288 - "This can be achieved by adding \"%s\" to \n" 1289 - "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", 1290 - fromsec, (long)r->r_offset, tosec, tosec, tosec); 1291 - } 1292 - 1293 - static void extable_mismatch_handler(const char* modname, struct elf_info *elf, 1294 - const struct sectioncheck* const mismatch, 1295 - Elf_Rela* r, Elf_Sym* sym, 1296 - const char *fromsec) 1297 - { 1298 - const char* tosec = sec_name(elf, get_secindex(elf, sym)); 1221 + if (!secref_whitelist(fromsec, fromsym, tosec, tosym)) 1222 + return; 1299 1223 1300 1224 sec_mismatch_count++; 1301 1225 1302 - report_extable_warnings(modname, elf, mismatch, r, sym, fromsec, tosec); 1226 + warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n", 1227 + modname, fromsym, (unsigned int)(faddr - from->st_value), fromsec, tosym, tosec); 1303 1228 1304 - if (match(tosec, mismatch->bad_tosec)) 1305 - fatal("The relocation at %s+0x%lx references\n" 1306 - "section \"%s\" which is black-listed.\n" 1307 - "Something is seriously wrong and should be fixed.\n" 1308 - "You might get more information about where this is\n" 1309 - "coming from by using scripts/check_extable.sh %s\n", 1310 - fromsec, (long)r->r_offset, tosec, modname); 1311 - else if (!is_executable_section(elf, get_secindex(elf, sym))) { 1312 - if (is_extable_fault_address(r)) 1229 + if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) { 1230 + if (match(tosec, mismatch->bad_tosec)) 1313 1231 fatal("The relocation at %s+0x%lx references\n" 1314 - "section \"%s\" which is not executable, IOW\n" 1315 - "it is not possible for the kernel to fault\n" 1316 - "at that address. Something is seriously wrong\n" 1317 - "and should be fixed.\n", 1318 - fromsec, (long)r->r_offset, tosec); 1232 + "section \"%s\" which is black-listed.\n" 1233 + "Something is seriously wrong and should be fixed.\n" 1234 + "You might get more information about where this is\n" 1235 + "coming from by using scripts/check_extable.sh %s\n", 1236 + fromsec, (long)faddr, tosec, modname); 1237 + else if (is_executable_section(elf, get_secindex(elf, tsym))) 1238 + warn("The relocation at %s+0x%lx references\n" 1239 + "section \"%s\" which is not in the list of\n" 1240 + "authorized sections. If you're adding a new section\n" 1241 + "and/or if this reference is valid, add \"%s\" to the\n" 1242 + "list of authorized sections to jump to on fault.\n" 1243 + "This can be achieved by adding \"%s\" to\n" 1244 + "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", 1245 + fromsec, (long)faddr, tosec, tosec, tosec); 1319 1246 else 1320 - fatal("The relocation at %s+0x%lx references\n" 1321 - "section \"%s\" which is not executable, IOW\n" 1322 - "the kernel will fault if it ever tries to\n" 1323 - "jump to it. Something is seriously wrong\n" 1324 - "and should be fixed.\n", 1325 - fromsec, (long)r->r_offset, tosec); 1247 + error("%s+0x%lx references non-executable section '%s'\n", 1248 + fromsec, (long)faddr, tosec); 1326 1249 } 1327 1250 } 1328 1251 1329 - static void check_section_mismatch(const char *modname, struct elf_info *elf, 1330 - Elf_Rela *r, Elf_Sym *sym, const char *fromsec) 1252 + static void check_export_symbol(struct module *mod, struct elf_info *elf, 1253 + Elf_Addr faddr, const char *secname, 1254 + Elf_Sym *sym) 1255 + { 1256 + static const char *prefix = "__export_symbol_"; 1257 + const char *label_name, *name, *data; 1258 + Elf_Sym *label; 1259 + struct symbol *s; 1260 + bool is_gpl; 1261 + 1262 + label = find_fromsym(elf, faddr, elf->export_symbol_secndx); 1263 + label_name = sym_name(elf, label); 1264 + 1265 + if (!strstarts(label_name, prefix)) { 1266 + error("%s: .export_symbol section contains strange symbol '%s'\n", 1267 + mod->name, label_name); 1268 + return; 1269 + } 1270 + 1271 + if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL && 1272 + ELF_ST_BIND(sym->st_info) != STB_WEAK) { 1273 + error("%s: local symbol '%s' was exported\n", mod->name, 1274 + label_name + strlen(prefix)); 1275 + return; 1276 + } 1277 + 1278 + name = sym_name(elf, sym); 1279 + if (strcmp(label_name + strlen(prefix), name)) { 1280 + error("%s: .export_symbol section references '%s', but it does not seem to be an export symbol\n", 1281 + mod->name, name); 1282 + return; 1283 + } 1284 + 1285 + data = sym_get_data(elf, label); /* license */ 1286 + if (!strcmp(data, "GPL")) { 1287 + is_gpl = true; 1288 + } else if (!strcmp(data, "")) { 1289 + is_gpl = false; 1290 + } else { 1291 + error("%s: unknown license '%s' was specified for '%s'\n", 1292 + mod->name, data, name); 1293 + return; 1294 + } 1295 + 1296 + data += strlen(data) + 1; /* namespace */ 1297 + s = sym_add_exported(name, mod, is_gpl, data); 1298 + 1299 + /* 1300 + * We need to be aware whether we are exporting a function or 1301 + * a data on some architectures. 1302 + */ 1303 + s->is_func = (ELF_ST_TYPE(sym->st_info) == STT_FUNC); 1304 + 1305 + if (match(secname, PATTERNS(INIT_SECTIONS))) 1306 + warn("%s: %s: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.\n", 1307 + mod->name, name); 1308 + else if (match(secname, PATTERNS(EXIT_SECTIONS))) 1309 + warn("%s: %s: EXPORT_SYMBOL used for exit symbol. Remove __exit or EXPORT_SYMBOL.\n", 1310 + mod->name, name); 1311 + } 1312 + 1313 + static void check_section_mismatch(struct module *mod, struct elf_info *elf, 1314 + Elf_Sym *sym, 1315 + unsigned int fsecndx, const char *fromsec, 1316 + Elf_Addr faddr, Elf_Addr taddr) 1331 1317 { 1332 1318 const char *tosec = sec_name(elf, get_secindex(elf, sym)); 1333 - const struct sectioncheck *mismatch = section_mismatch(fromsec, tosec); 1319 + const struct sectioncheck *mismatch; 1334 1320 1335 - if (mismatch) { 1336 - if (mismatch->handler) 1337 - mismatch->handler(modname, elf, mismatch, 1338 - r, sym, fromsec); 1339 - else 1340 - default_mismatch_handler(modname, elf, mismatch, 1341 - r, sym, fromsec); 1321 + if (elf->export_symbol_secndx == fsecndx) { 1322 + check_export_symbol(mod, elf, faddr, tosec, sym); 1323 + return; 1342 1324 } 1325 + 1326 + mismatch = section_mismatch(fromsec, tosec); 1327 + if (!mismatch) 1328 + return; 1329 + 1330 + default_mismatch_handler(mod->name, elf, mismatch, sym, 1331 + fsecndx, fromsec, faddr, 1332 + tosec, taddr); 1343 1333 } 1344 1334 1345 - static unsigned int *reloc_location(struct elf_info *elf, 1346 - Elf_Shdr *sechdr, Elf_Rela *r) 1347 - { 1348 - return sym_get_data_by_offset(elf, sechdr->sh_info, r->r_offset); 1349 - } 1350 - 1351 - static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) 1335 + static int addend_386_rel(uint32_t *location, Elf_Rela *r) 1352 1336 { 1353 1337 unsigned int r_typ = ELF_R_TYPE(r->r_info); 1354 - unsigned int *location = reloc_location(elf, sechdr, r); 1355 1338 1356 1339 switch (r_typ) { 1357 1340 case R_386_32: ··· 1267 1436 case R_386_PC32: 1268 1437 r->r_addend = TO_NATIVE(*location) + 4; 1269 1438 break; 1439 + default: 1440 + r->r_addend = (Elf_Addr)(-1); 1270 1441 } 1271 1442 return 0; 1272 1443 } ··· 1286 1453 #ifndef R_ARM_THM_JUMP24 1287 1454 #define R_ARM_THM_JUMP24 30 1288 1455 #endif 1456 + 1457 + #ifndef R_ARM_MOVW_ABS_NC 1458 + #define R_ARM_MOVW_ABS_NC 43 1459 + #endif 1460 + 1461 + #ifndef R_ARM_MOVT_ABS 1462 + #define R_ARM_MOVT_ABS 44 1463 + #endif 1464 + 1465 + #ifndef R_ARM_THM_MOVW_ABS_NC 1466 + #define R_ARM_THM_MOVW_ABS_NC 47 1467 + #endif 1468 + 1469 + #ifndef R_ARM_THM_MOVT_ABS 1470 + #define R_ARM_THM_MOVT_ABS 48 1471 + #endif 1472 + 1289 1473 #ifndef R_ARM_THM_JUMP19 1290 1474 #define R_ARM_THM_JUMP19 51 1291 1475 #endif 1292 1476 1293 - static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) 1477 + static int32_t sign_extend32(int32_t value, int index) 1478 + { 1479 + uint8_t shift = 31 - index; 1480 + 1481 + return (int32_t)(value << shift) >> shift; 1482 + } 1483 + 1484 + static int addend_arm_rel(void *loc, Elf_Sym *sym, Elf_Rela *r) 1294 1485 { 1295 1486 unsigned int r_typ = ELF_R_TYPE(r->r_info); 1487 + uint32_t inst, upper, lower, sign, j1, j2; 1488 + int32_t offset; 1296 1489 1297 1490 switch (r_typ) { 1298 1491 case R_ARM_ABS32: 1299 - /* From ARM ABI: (S + A) | T */ 1300 - r->r_addend = (int)(long) 1301 - (elf->symtab_start + ELF_R_SYM(r->r_info)); 1492 + case R_ARM_REL32: 1493 + inst = TO_NATIVE(*(uint32_t *)loc); 1494 + r->r_addend = inst + sym->st_value; 1495 + break; 1496 + case R_ARM_MOVW_ABS_NC: 1497 + case R_ARM_MOVT_ABS: 1498 + inst = TO_NATIVE(*(uint32_t *)loc); 1499 + offset = sign_extend32(((inst & 0xf0000) >> 4) | (inst & 0xfff), 1500 + 15); 1501 + r->r_addend = offset + sym->st_value; 1302 1502 break; 1303 1503 case R_ARM_PC24: 1304 1504 case R_ARM_CALL: 1305 1505 case R_ARM_JUMP24: 1506 + inst = TO_NATIVE(*(uint32_t *)loc); 1507 + offset = sign_extend32((inst & 0x00ffffff) << 2, 25); 1508 + r->r_addend = offset + sym->st_value + 8; 1509 + break; 1510 + case R_ARM_THM_MOVW_ABS_NC: 1511 + case R_ARM_THM_MOVT_ABS: 1512 + upper = TO_NATIVE(*(uint16_t *)loc); 1513 + lower = TO_NATIVE(*((uint16_t *)loc + 1)); 1514 + offset = sign_extend32(((upper & 0x000f) << 12) | 1515 + ((upper & 0x0400) << 1) | 1516 + ((lower & 0x7000) >> 4) | 1517 + (lower & 0x00ff), 1518 + 15); 1519 + r->r_addend = offset + sym->st_value; 1520 + break; 1521 + case R_ARM_THM_JUMP19: 1522 + /* 1523 + * Encoding T3: 1524 + * S = upper[10] 1525 + * imm6 = upper[5:0] 1526 + * J1 = lower[13] 1527 + * J2 = lower[11] 1528 + * imm11 = lower[10:0] 1529 + * imm32 = SignExtend(S:J2:J1:imm6:imm11:'0') 1530 + */ 1531 + upper = TO_NATIVE(*(uint16_t *)loc); 1532 + lower = TO_NATIVE(*((uint16_t *)loc + 1)); 1533 + 1534 + sign = (upper >> 10) & 1; 1535 + j1 = (lower >> 13) & 1; 1536 + j2 = (lower >> 11) & 1; 1537 + offset = sign_extend32((sign << 20) | (j2 << 19) | (j1 << 18) | 1538 + ((upper & 0x03f) << 12) | 1539 + ((lower & 0x07ff) << 1), 1540 + 20); 1541 + r->r_addend = offset + sym->st_value + 4; 1542 + break; 1306 1543 case R_ARM_THM_CALL: 1307 1544 case R_ARM_THM_JUMP24: 1308 - case R_ARM_THM_JUMP19: 1309 - /* From ARM ABI: ((S + A) | T) - P */ 1310 - r->r_addend = (int)(long)(elf->hdr + 1311 - sechdr->sh_offset + 1312 - (r->r_offset - sechdr->sh_addr)); 1545 + /* 1546 + * Encoding T4: 1547 + * S = upper[10] 1548 + * imm10 = upper[9:0] 1549 + * J1 = lower[13] 1550 + * J2 = lower[11] 1551 + * imm11 = lower[10:0] 1552 + * I1 = NOT(J1 XOR S) 1553 + * I2 = NOT(J2 XOR S) 1554 + * imm32 = SignExtend(S:I1:I2:imm10:imm11:'0') 1555 + */ 1556 + upper = TO_NATIVE(*(uint16_t *)loc); 1557 + lower = TO_NATIVE(*((uint16_t *)loc + 1)); 1558 + 1559 + sign = (upper >> 10) & 1; 1560 + j1 = (lower >> 13) & 1; 1561 + j2 = (lower >> 11) & 1; 1562 + offset = sign_extend32((sign << 24) | 1563 + ((~(j1 ^ sign) & 1) << 23) | 1564 + ((~(j2 ^ sign) & 1) << 22) | 1565 + ((upper & 0x03ff) << 12) | 1566 + ((lower & 0x07ff) << 1), 1567 + 24); 1568 + r->r_addend = offset + sym->st_value + 4; 1313 1569 break; 1314 1570 default: 1315 - return 1; 1571 + r->r_addend = (Elf_Addr)(-1); 1316 1572 } 1317 1573 return 0; 1318 1574 } 1319 1575 1320 - static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) 1576 + static int addend_mips_rel(uint32_t *location, Elf_Rela *r) 1321 1577 { 1322 1578 unsigned int r_typ = ELF_R_TYPE(r->r_info); 1323 - unsigned int *location = reloc_location(elf, sechdr, r); 1324 - unsigned int inst; 1579 + uint32_t inst; 1325 1580 1326 - if (r_typ == R_MIPS_HI16) 1327 - return 1; /* skip this */ 1328 1581 inst = TO_NATIVE(*location); 1329 1582 switch (r_typ) { 1330 1583 case R_MIPS_LO16: ··· 1422 1503 case R_MIPS_32: 1423 1504 r->r_addend = inst; 1424 1505 break; 1506 + default: 1507 + r->r_addend = (Elf_Addr)(-1); 1425 1508 } 1426 1509 return 0; 1427 1510 } ··· 1444 1523 #define R_LARCH_SUB32 55 1445 1524 #endif 1446 1525 1447 - static void section_rela(const char *modname, struct elf_info *elf, 1526 + static void section_rela(struct module *mod, struct elf_info *elf, 1448 1527 Elf_Shdr *sechdr) 1449 1528 { 1450 - Elf_Sym *sym; 1451 1529 Elf_Rela *rela; 1452 1530 Elf_Rela r; 1453 1531 unsigned int r_sym; 1454 - const char *fromsec; 1455 - 1532 + unsigned int fsecndx = sechdr->sh_info; 1533 + const char *fromsec = sec_name(elf, fsecndx); 1456 1534 Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset; 1457 1535 Elf_Rela *stop = (void *)start + sechdr->sh_size; 1458 1536 1459 - fromsec = sec_name(elf, sechdr->sh_info); 1460 1537 /* if from section (name) is know good then skip it */ 1461 1538 if (match(fromsec, section_white_list)) 1462 1539 return; ··· 1489 1570 continue; 1490 1571 break; 1491 1572 } 1492 - sym = elf->symtab_start + r_sym; 1493 - /* Skip special sections */ 1494 - if (is_shndx_special(sym->st_shndx)) 1495 - continue; 1496 - if (is_second_extable_reloc(start, rela, fromsec)) 1497 - find_extable_entry_size(fromsec, &r); 1498 - check_section_mismatch(modname, elf, &r, sym, fromsec); 1573 + 1574 + check_section_mismatch(mod, elf, elf->symtab_start + r_sym, 1575 + fsecndx, fromsec, r.r_offset, r.r_addend); 1499 1576 } 1500 1577 } 1501 1578 1502 - static void section_rel(const char *modname, struct elf_info *elf, 1579 + static void section_rel(struct module *mod, struct elf_info *elf, 1503 1580 Elf_Shdr *sechdr) 1504 1581 { 1505 - Elf_Sym *sym; 1506 1582 Elf_Rel *rel; 1507 1583 Elf_Rela r; 1508 1584 unsigned int r_sym; 1509 - const char *fromsec; 1510 - 1585 + unsigned int fsecndx = sechdr->sh_info; 1586 + const char *fromsec = sec_name(elf, fsecndx); 1511 1587 Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset; 1512 1588 Elf_Rel *stop = (void *)start + sechdr->sh_size; 1513 1589 1514 - fromsec = sec_name(elf, sechdr->sh_info); 1515 1590 /* if from section (name) is know good then skip it */ 1516 1591 if (match(fromsec, section_white_list)) 1517 1592 return; 1518 1593 1519 1594 for (rel = start; rel < stop; rel++) { 1595 + Elf_Sym *tsym; 1596 + void *loc; 1597 + 1520 1598 r.r_offset = TO_NATIVE(rel->r_offset); 1521 1599 #if KERNEL_ELFCLASS == ELFCLASS64 1522 1600 if (elf->hdr->e_machine == EM_MIPS) { ··· 1531 1615 r_sym = ELF_R_SYM(r.r_info); 1532 1616 #endif 1533 1617 r.r_addend = 0; 1618 + 1619 + loc = sym_get_data_by_offset(elf, fsecndx, r.r_offset); 1620 + tsym = elf->symtab_start + r_sym; 1621 + 1534 1622 switch (elf->hdr->e_machine) { 1535 1623 case EM_386: 1536 - if (addend_386_rel(elf, sechdr, &r)) 1537 - continue; 1624 + addend_386_rel(loc, &r); 1538 1625 break; 1539 1626 case EM_ARM: 1540 - if (addend_arm_rel(elf, sechdr, &r)) 1541 - continue; 1627 + addend_arm_rel(loc, tsym, &r); 1542 1628 break; 1543 1629 case EM_MIPS: 1544 - if (addend_mips_rel(elf, sechdr, &r)) 1545 - continue; 1630 + addend_mips_rel(loc, &r); 1546 1631 break; 1632 + default: 1633 + fatal("Please add code to calculate addend for this architecture\n"); 1547 1634 } 1548 - sym = elf->symtab_start + r_sym; 1549 - /* Skip special sections */ 1550 - if (is_shndx_special(sym->st_shndx)) 1551 - continue; 1552 - if (is_second_extable_reloc(start, rel, fromsec)) 1553 - find_extable_entry_size(fromsec, &r); 1554 - check_section_mismatch(modname, elf, &r, sym, fromsec); 1635 + 1636 + check_section_mismatch(mod, elf, tsym, 1637 + fsecndx, fromsec, r.r_offset, r.r_addend); 1555 1638 } 1556 1639 } 1557 1640 ··· 1566 1651 * to find all references to a section that reference a section that will 1567 1652 * be discarded and warns about it. 1568 1653 **/ 1569 - static void check_sec_ref(const char *modname, struct elf_info *elf) 1654 + static void check_sec_ref(struct module *mod, struct elf_info *elf) 1570 1655 { 1571 1656 int i; 1572 1657 Elf_Shdr *sechdrs = elf->sechdrs; 1573 1658 1574 1659 /* Walk through all sections */ 1575 1660 for (i = 0; i < elf->num_sections; i++) { 1576 - check_section(modname, elf, &elf->sechdrs[i]); 1661 + check_section(mod->name, elf, &elf->sechdrs[i]); 1577 1662 /* We want to process only relocation sections and not .init */ 1578 1663 if (sechdrs[i].sh_type == SHT_RELA) 1579 - section_rela(modname, elf, &elf->sechdrs[i]); 1664 + section_rela(mod, elf, &elf->sechdrs[i]); 1580 1665 else if (sechdrs[i].sh_type == SHT_REL) 1581 - section_rel(modname, elf, &elf->sechdrs[i]); 1666 + section_rel(mod, elf, &elf->sechdrs[i]); 1582 1667 } 1583 1668 } 1584 1669 ··· 1733 1818 } 1734 1819 } 1735 1820 1821 + if (extra_warn && !get_modinfo(&info, "description")) 1822 + warn("missing MODULE_DESCRIPTION() in %s\n", modname); 1736 1823 for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { 1737 1824 symname = remove_dot(info.strtab + sym->st_name); 1738 1825 ··· 1742 1825 handle_moddevtable(mod, &info, sym, symname); 1743 1826 } 1744 1827 1745 - for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { 1746 - symname = remove_dot(info.strtab + sym->st_name); 1747 - 1748 - /* Apply symbol namespaces from __kstrtabns_<symbol> entries. */ 1749 - if (strstarts(symname, "__kstrtabns_")) 1750 - sym_update_namespace(symname + strlen("__kstrtabns_"), 1751 - sym_get_data(&info, sym)); 1752 - } 1753 - 1754 - check_sec_ref(modname, &info); 1828 + check_sec_ref(mod, &info); 1755 1829 1756 1830 if (!mod->is_vmlinux) { 1757 1831 version = get_modinfo(&info, "version"); ··· 1833 1925 continue; 1834 1926 } 1835 1927 1928 + exp->used = true; 1836 1929 s->module = exp->module; 1837 1930 s->crc_valid = exp->crc_valid; 1838 1931 s->crc = exp->crc; ··· 1844 1935 else 1845 1936 basename = mod->name; 1846 1937 1847 - if (exp->namespace && 1848 - !contains_namespace(&mod->imported_namespaces, exp->namespace)) { 1938 + if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) { 1849 1939 modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR, 1850 1940 "module %s uses symbol %s from namespace %s, but does not import it.\n", 1851 1941 basename, exp->name, exp->namespace); ··· 1855 1947 error("GPL-incompatible module %s.ko uses GPL-only symbol '%s'\n", 1856 1948 basename, exp->name); 1857 1949 } 1950 + } 1951 + 1952 + static void handle_white_list_exports(const char *white_list) 1953 + { 1954 + char *buf, *p, *name; 1955 + 1956 + buf = read_text_file(white_list); 1957 + p = buf; 1958 + 1959 + while ((name = strsep(&p, "\n"))) { 1960 + struct symbol *sym = find_symbol(name); 1961 + 1962 + if (sym) 1963 + sym->used = true; 1964 + } 1965 + 1966 + free(buf); 1858 1967 } 1859 1968 1860 1969 static void check_modname_len(struct module *mod) ··· 1947 2022 { 1948 2023 struct symbol *sym; 1949 2024 2025 + /* generate struct for exported symbols */ 2026 + buf_printf(buf, "\n"); 2027 + list_for_each_entry(sym, &mod->exported_symbols, list) { 2028 + if (trim_unused_exports && !sym->used) 2029 + continue; 2030 + 2031 + buf_printf(buf, "KSYMTAB_%s(%s, \"%s\", \"%s\");\n", 2032 + sym->is_func ? "FUNC" : "DATA", sym->name, 2033 + sym->is_gpl_only ? "_gpl" : "", sym->namespace); 2034 + } 2035 + 1950 2036 if (!modversions) 1951 2037 return; 1952 2038 1953 2039 /* record CRCs for exported symbols */ 1954 2040 buf_printf(buf, "\n"); 1955 2041 list_for_each_entry(sym, &mod->exported_symbols, list) { 2042 + if (trim_unused_exports && !sym->used) 2043 + continue; 2044 + 1956 2045 if (!sym->crc_valid) 1957 2046 warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n" 1958 2047 "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n", ··· 2130 2191 char fname[PATH_MAX]; 2131 2192 int ret; 2132 2193 2133 - check_modname_len(mod); 2134 - check_exports(mod); 2135 - 2136 2194 add_header(&buf, mod); 2137 2195 add_exported_symbols(&buf, mod); 2138 2196 add_versions(&buf, mod); ··· 2201 2265 mod = new_module(modname, strlen(modname)); 2202 2266 mod->from_dump = true; 2203 2267 } 2204 - s = sym_add_exported(symname, mod, gpl_only); 2268 + s = sym_add_exported(symname, mod, gpl_only, namespace); 2205 2269 sym_set_crc(s, crc); 2206 - sym_update_namespace(symname, namespace); 2207 2270 } 2208 2271 free(buf); 2209 2272 return; ··· 2221 2286 if (mod->from_dump) 2222 2287 continue; 2223 2288 list_for_each_entry(sym, &mod->exported_symbols, list) { 2289 + if (trim_unused_exports && !sym->used) 2290 + continue; 2291 + 2224 2292 buf_printf(&buf, "0x%08x\t%s\t%s\tEXPORT_SYMBOL%s\t%s\n", 2225 2293 sym->crc, sym->name, mod->name, 2226 2294 sym->is_gpl_only ? "_GPL" : "", 2227 - sym->namespace ?: ""); 2295 + sym->namespace); 2228 2296 } 2229 2297 } 2230 2298 write_buf(&buf, fname); ··· 2266 2328 { 2267 2329 struct module *mod; 2268 2330 char *missing_namespace_deps = NULL; 2331 + char *unused_exports_white_list = NULL; 2269 2332 char *dump_write = NULL, *files_source = NULL; 2270 2333 int opt; 2271 2334 LIST_HEAD(dump_lists); 2272 2335 struct dump_list *dl, *dl2; 2273 2336 2274 - while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) { 2337 + while ((opt = getopt(argc, argv, "ei:mnT:to:au:WwENd:")) != -1) { 2275 2338 switch (opt) { 2276 2339 case 'e': 2277 2340 external_module = true; ··· 2296 2357 break; 2297 2358 case 'T': 2298 2359 files_source = optarg; 2360 + break; 2361 + case 't': 2362 + trim_unused_exports = true; 2363 + break; 2364 + case 'u': 2365 + unused_exports_white_list = optarg; 2366 + break; 2367 + case 'W': 2368 + extra_warn = true; 2299 2369 break; 2300 2370 case 'w': 2301 2371 warn_unresolved = true; ··· 2334 2386 2335 2387 if (files_source) 2336 2388 read_symbols_from_files(files_source); 2389 + 2390 + list_for_each_entry(mod, &modules, list) { 2391 + if (mod->from_dump || mod->is_vmlinux) 2392 + continue; 2393 + 2394 + check_modname_len(mod); 2395 + check_exports(mod); 2396 + } 2397 + 2398 + if (unused_exports_white_list) 2399 + handle_white_list_exports(unused_exports_white_list); 2337 2400 2338 2401 list_for_each_entry(mod, &modules, list) { 2339 2402 if (mod->from_dump)
+1 -5
scripts/mod/modpost.h
··· 137 137 Elf_Shdr *sechdrs; 138 138 Elf_Sym *symtab_start; 139 139 Elf_Sym *symtab_stop; 140 + unsigned int export_symbol_secndx; /* .export_symbol section */ 140 141 char *strtab; 141 142 char *modinfo; 142 143 unsigned int modinfo_len; ··· 151 150 Elf32_Word *symtab_shndx_start; 152 151 Elf32_Word *symtab_shndx_stop; 153 152 }; 154 - 155 - static inline int is_shndx_special(unsigned int i) 156 - { 157 - return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; 158 - } 159 153 160 154 /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ 161 155 static inline unsigned int get_secindex(const struct elf_info *info,
+5 -9
scripts/package/builddeb
··· 62 62 ${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install 63 63 fi 64 64 65 - if is_enabled CONFIG_MODULES; then 66 - ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install 67 - rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" 68 - rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source" 69 - if [ "${SRCARCH}" = um ] ; then 70 - mkdir -p "${pdir}/usr/lib/uml/modules" 71 - mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}" 72 - fi 73 - fi 65 + ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install 66 + rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" 67 + rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source" 74 68 75 69 # Install the kernel 76 70 if [ "${ARCH}" = um ] ; then 71 + mkdir -p "${pdir}/usr/lib/uml/modules" 72 + mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}" 77 73 mkdir -p "${pdir}/usr/bin" "${pdir}/usr/share/doc/${pname}" 78 74 cp System.map "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}/System.map" 79 75 cp ${KCONFIG_CONFIG} "${pdir}/usr/share/doc/${pname}/config"
+4
scripts/remove-stale-files
··· 33 33 rm -f scripts/bin2c 34 34 35 35 rm -f .scmversion 36 + 37 + rm -rf include/ksym 38 + 39 + find . -name '*.usyms' | xargs rm -f
+8 -1
scripts/tags.sh
··· 32 32 tree=${srctree}/ 33 33 fi 34 34 35 + # gtags(1) refuses to index any file outside of its current working dir. 36 + # If gtags indexing is requested and the build output directory is not 37 + # the kernel source tree, index all files in absolute-path form. 38 + if [[ "$1" == "gtags" && -n "${tree}" ]]; then 39 + tree=$(realpath "$tree")/ 40 + fi 41 + 35 42 # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH 36 43 if [ "${ALLSOURCE_ARCHS}" = "" ]; then 37 44 ALLSOURCE_ARCHS=${SRCARCH} ··· 138 131 139 132 dogtags() 140 133 { 141 - all_target_sources | gtags -i -f - 134 + all_target_sources | gtags -i -C "${tree:-.}" -f - "$PWD" 142 135 } 143 136 144 137 # Basic regular expressions with an optional /kind-spec/ for ctags and
+1
usr/Makefile
··· 64 64 $(CONFIG_SHELL) $< -o $@ -l $(obj)/.initramfs_data.cpio.d \ 65 65 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ 66 66 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \ 67 + $(if $(KBUILD_BUILD_TIMESTAMP), -d "$(KBUILD_BUILD_TIMESTAMP)") \ 67 68 $(ramfs-input) 68 69 69 70 # We rebuild initramfs_data.cpio if:
+9 -7
usr/gen_initramfs.sh
··· 23 23 -g <gid> Group ID to map to group ID 0 (root). 24 24 <gid> is only meaningful if <cpio_source> is a 25 25 directory. "squash" forces all files to gid 0. 26 + -d <date> Use date for all file mtime values 26 27 <cpio_source> File list or directory for cpio archive. 27 28 If <cpio_source> is a .cpio file it will be used 28 29 as direct input to initramfs. ··· 191 190 root_uid=0 192 191 root_gid=0 193 192 dep_list= 193 + timestamp= 194 194 cpio_list=$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX) 195 195 output="/dev/stdout" 196 196 ··· 220 218 [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0) 221 219 shift 222 220 ;; 221 + "-d") # date for file mtimes 222 + timestamp="$(date -d"$1" +%s || :)" 223 + if test -n "$timestamp"; then 224 + timestamp="-t $timestamp" 225 + fi 226 + shift 227 + ;; 223 228 "-h") 224 229 usage 225 230 exit 0 ··· 246 237 247 238 # If output_file is set we will generate cpio archive 248 239 # we are careful to delete tmp files 249 - timestamp= 250 - if test -n "$KBUILD_BUILD_TIMESTAMP"; then 251 - timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)" 252 - if test -n "$timestamp"; then 253 - timestamp="-t $timestamp" 254 - fi 255 - fi 256 240 usr/gen_init_cpio $timestamp $cpio_list > $output