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

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

Pull Kbuild updates from Masahiro Yamada:

- Implement the binary search in modpost for faster symbol lookup

- Respect HOSTCC when linking host programs written in Rust

- Change the binrpm-pkg target to generate kernel-devel RPM package

- Fix endianness issues for tee and ishtp MODULE_DEVICE_TABLE

- Unify vdso_install rules

- Remove unused __memexit* annotations

- Eliminate stale whitelisting for __devinit/__devexit from modpost

- Enable dummy-tools to handle the -fpatchable-function-entry flag

- Add 'userldlibs' syntax

* tag 'kbuild-v6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (30 commits)
kbuild: support 'userldlibs' syntax
kbuild: dummy-tools: pretend we understand -fpatchable-function-entry
kbuild: Correct missing architecture-specific hyphens
modpost: squash ALL_{INIT,EXIT}_TEXT_SECTIONS to ALL_TEXT_SECTIONS
modpost: merge sectioncheck table entries regarding init/exit sections
modpost: use ALL_INIT_SECTIONS for the section check from DATA_SECTIONS
modpost: disallow the combination of EXPORT_SYMBOL and __meminit*
modpost: remove EXIT_SECTIONS macro
modpost: remove MEM_INIT_SECTIONS macro
modpost: remove more symbol patterns from the section check whitelist
modpost: disallow *driver to reference .meminit* sections
linux/init: remove __memexit* annotations
modpost: remove ALL_EXIT_DATA_SECTIONS macro
kbuild: simplify cmd_ld_multi_m
kbuild: avoid too many execution of scripts/pahole-flags.sh
kbuild: remove ARCH_POSTLINK from module builds
kbuild: unify no-compiler-targets and no-sync-config-targets
kbuild: unify vdso_install rules
docs: kbuild: add INSTALL_DTBS_PATH
UML: remove unused cmd_vdso_install
...

+443 -469
-1
.gitignore
··· 74 74 # 75 75 # RPM spec file (make rpm-pkg) 76 76 # 77 - /kernel.spec 78 77 /rpmbuild/ 79 78 80 79 #
+6
Documentation/kbuild/kbuild.rst
··· 243 243 244 244 The value can be overridden in which case the default value is ignored. 245 245 246 + INSTALL_DTBS_PATH 247 + ----------------- 248 + INSTALL_DTBS_PATH specifies where to install device tree blobs for 249 + relocations required by build roots. This is not defined in the 250 + makefile but the argument can be passed to make if needed. 251 + 246 252 KBUILD_ABS_SRCTREE 247 253 -------------------------------------------------- 248 254 Kbuild uses a relative path to point to the tree when possible. For instance,
+11
Documentation/kbuild/makefiles.rst
··· 937 937 # net/bpfilter/Makefile 938 938 bpfilter_umh-userldflags += -static 939 939 940 + To specify libraries linked to a userspace program, you can use 941 + ``<executable>-userldlibs``. The ``userldlibs`` syntax specifies libraries 942 + linked to all userspace programs created in the current Makefile. 943 + 940 944 When linking bpfilter_umh, it will be passed the extra option -static. 941 945 942 946 From command line, :ref:`USERCFLAGS and USERLDFLAGS <userkbuildflags>` will also be used. ··· 1626 1622 default option --strip-debug will be used. Otherwise, the 1627 1623 INSTALL_MOD_STRIP value will be used as the option(s) to the strip 1628 1624 command. 1625 + 1626 + INSTALL_DTBS_PATH 1627 + This variable specifies a prefix for relocations required by build 1628 + roots. It defines a place for installing the device tree blobs. Like 1629 + INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed 1630 + by the user if desired. Otherwise it defaults to the kernel install 1631 + path. 1629 1632 1630 1633 Makefile language 1631 1634 =================
+1 -1
MAINTAINERS
··· 3781 3781 F: net/sched/cls_bpf.c 3782 3782 F: samples/bpf/ 3783 3783 F: scripts/bpf_doc.py 3784 - F: scripts/pahole-flags.sh 3784 + F: scripts/Makefile.btf 3785 3785 F: scripts/pahole-version.sh 3786 3786 F: tools/bpf/ 3787 3787 F: tools/lib/bpf/
+18 -20
Makefile
··· 277 277 $(version_h) headers headers_% archheaders archscripts \ 278 278 %asm-generic kernelversion %src-pkg dt_binding_check \ 279 279 outputmakefile rustavailable rustfmt rustfmtcheck 280 - # Installation targets should not require compiler. Unfortunately, vdso_install 281 - # is an exception where build artifacts may be updated. This must be fixed. 282 - no-compiler-targets := $(no-dot-config-targets) install dtbs_install \ 283 - headers_install modules_install modules_sign kernelrelease image_name 284 280 no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \ 285 281 image_name 286 282 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/ ··· 284 288 config-build := 285 289 mixed-build := 286 290 need-config := 1 287 - need-compiler := 1 288 291 may-sync-config := 1 289 292 single-build := 290 293 ··· 293 298 endif 294 299 endif 295 300 296 - ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),) 297 - ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),) 298 - need-compiler := 299 - endif 300 - endif 301 - 302 301 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) 303 302 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) 304 303 may-sync-config := 305 304 endif 306 305 endif 306 + 307 + need-compiler := $(may-sync-config) 307 308 308 309 ifneq ($(KBUILD_EXTMOD),) 309 310 may-sync-config := ··· 513 522 XZ = xz 514 523 ZSTD = zstd 515 524 516 - PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh) 517 - 518 525 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 519 526 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) 520 527 NOSTDINC_FLAGS := ··· 603 614 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 604 615 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_RUSTFLAGS_MODULE KBUILD_LDFLAGS_MODULE 605 616 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL KBUILD_RUSTFLAGS_KERNEL 606 - export PAHOLE_FLAGS 607 617 608 618 # Files to ignore in find ... statements 609 619 ··· 672 684 # *config targets only - make sure prerequisites are updated, and descend 673 685 # in scripts/kconfig to make the *config target 674 686 675 - # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. 687 + # Read arch-specific Makefile to set KBUILD_DEFCONFIG as needed. 676 688 # KBUILD_DEFCONFIG may point out an alternative default configuration 677 689 # used for 'make defconfig' 678 690 include $(srctree)/arch/$(SRCARCH)/Makefile ··· 686 698 687 699 else #!config-build 688 700 # =========================================================================== 689 - # Build targets only - this includes vmlinux, arch specific targets, clean 701 + # Build targets only - this includes vmlinux, arch-specific targets, clean 690 702 # targets and others. In general all targets except *config targets. 691 703 692 704 # If building an external module we do not care about the all: rule ··· 999 1011 # include additional Makefiles when needed 1000 1012 include-y := scripts/Makefile.extrawarn 1001 1013 include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug 1014 + include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf 1002 1015 include-$(CONFIG_KASAN) += scripts/Makefile.kasan 1003 1016 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan 1004 1017 include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan ··· 1307 1318 cmd_install = unset sub_make_done; $(srctree)/scripts/install.sh 1308 1319 1309 1320 # --------------------------------------------------------------------------- 1321 + # vDSO install 1322 + 1323 + PHONY += vdso_install 1324 + vdso_install: export INSTALL_FILES = $(vdso-install-y) 1325 + vdso_install: 1326 + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst 1327 + 1328 + # --------------------------------------------------------------------------- 1310 1329 # Tools 1311 1330 1312 1331 ifdef CONFIG_OBJTOOL ··· 1483 1486 certs/signing_key.pem \ 1484 1487 certs/x509.genkey \ 1485 1488 vmlinux-gdb.py \ 1486 - kernel.spec rpmbuild \ 1489 + rpmbuild \ 1487 1490 rust/libmacros.so 1488 1491 1489 1492 # clean - Delete most, but leave enough to build external modules ··· 1557 1560 @echo '* vmlinux - Build the bare kernel' 1558 1561 @echo '* modules - Build all modules' 1559 1562 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' 1563 + @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)' 1560 1564 @echo ' dir/ - Build all files in dir and below' 1561 1565 @echo ' dir/file.[ois] - Build specified target only' 1562 1566 @echo ' dir/file.ll - Build the LLVM assembly file' ··· 1635 1637 @echo 'Documentation targets:' 1636 1638 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp 1637 1639 @echo '' 1638 - @echo 'Architecture specific targets ($(SRCARCH)):' 1640 + @echo 'Architecture-specific targets ($(SRCARCH)):' 1639 1641 @$(or $(archhelp),\ 1640 - echo ' No architecture specific help defined for $(SRCARCH)') 1642 + echo ' No architecture-specific help defined for $(SRCARCH)') 1641 1643 @echo '' 1642 1644 @$(if $(boards), \ 1643 1645 $(foreach b, $(boards), \ ··· 1679 1681 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig))) 1680 1682 1681 1683 $(help-board-dirs): help-%: 1682 - @echo 'Architecture specific targets ($(SRCARCH) $*):' 1684 + @echo 'Architecture-specific targets ($(SRCARCH) $*):' 1683 1685 @$(if $(boards-per-dir), \ 1684 1686 $(foreach b, $(boards-per-dir), \ 1685 1687 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
+1 -6
arch/arm/Makefile
··· 304 304 $(INSTALL_TARGETS): 305 305 $(call cmd,install) 306 306 307 - PHONY += vdso_install 308 - vdso_install: 309 - ifeq ($(CONFIG_VDSO),y) 310 - $(Q)$(MAKE) $(build)=arch/arm/vdso $@ 311 - endif 307 + vdso-install-$(CONFIG_VDSO) += arch/arm/vdso/vdso.so.dbg 312 308 313 309 # My testing targets (bypasses dependencies) 314 310 bp:; $(Q)$(MAKE) $(build)=$(boot) $(boot)/bootpImage ··· 327 331 echo ' Install using (your) ~/bin/$(INSTALLKERNEL) or' 328 332 echo ' (distribution) /sbin/$(INSTALLKERNEL) or' 329 333 echo ' install to $$(INSTALL_PATH) and run lilo' 330 - echo ' vdso_install - Install unstripped vdso.so to $$(INSTALL_MOD_PATH)/vdso' 331 334 echo 332 335 echo ' multi_v7_lpae_defconfig - multi_v7_defconfig with CONFIG_ARM_LPAE enabled' 333 336 endef
-25
arch/arm/vdso/Makefile
··· 63 63 64 64 quiet_cmd_vdsomunge = MUNGE $@ 65 65 cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@ 66 - 67 - # 68 - # Install the unstripped copy of vdso.so.dbg. If our toolchain 69 - # supports build-id, install .build-id links as well. 70 - # 71 - # Cribbed from arch/x86/vdso/Makefile. 72 - # 73 - quiet_cmd_vdso_install = INSTALL $< 74 - define cmd_vdso_install 75 - cp $< "$(MODLIB)/vdso/vdso.so"; \ 76 - if readelf -n $< | grep -q 'Build ID'; then \ 77 - buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ 78 - first=`echo $$buildid | cut -b-2`; \ 79 - last=`echo $$buildid | cut -b3-`; \ 80 - mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ 81 - ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ 82 - fi 83 - endef 84 - 85 - $(MODLIB)/vdso: FORCE 86 - @mkdir -p $(MODLIB)/vdso 87 - 88 - PHONY += vdso_install 89 - vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso 90 - $(call cmd,vdso_install)
+3 -6
arch/arm64/Makefile
··· 169 169 install zinstall: 170 170 $(call cmd,install) 171 171 172 - PHONY += vdso_install 173 - vdso_install: 174 - $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ 175 - $(if $(CONFIG_COMPAT_VDSO), \ 176 - $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@) 177 - 178 172 archprepare: 179 173 $(Q)$(MAKE) $(build)=arch/arm64/tools kapi 180 174 ifeq ($(CONFIG_ARM64_ERRATUM_843419),y) ··· 198 204 include/generated/vdso32-offsets.h arch/arm64/kernel/vdso32/vdso.so 199 205 endif 200 206 endif 207 + 208 + vdso-install-y += arch/arm64/kernel/vdso/vdso.so.dbg 209 + vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso.so.dbg:vdso32.so 201 210 202 211 include $(srctree)/scripts/Makefile.defconf 203 212
-10
arch/arm64/kernel/vdso/Makefile
··· 78 78 # Actual build commands 79 79 quiet_cmd_vdsold_and_vdso_check = LD $@ 80 80 cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check) 81 - 82 - # Install commands for the unstripped file 83 - quiet_cmd_vdso_install = INSTALL $@ 84 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 85 - 86 - vdso.so: $(obj)/vdso.so.dbg 87 - @mkdir -p $(MODLIB)/vdso 88 - $(call cmd,vdso_install) 89 - 90 - vdso_install: vdso.so
-10
arch/arm64/kernel/vdso32/Makefile
··· 172 172 quiet_cmd_vdsosym = VDSOSYM $@ 173 173 # The AArch64 nm should be able to read an AArch32 binary 174 174 cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ 175 - 176 - # Install commands for the unstripped file 177 - quiet_cmd_vdso_install = INSTALL32 $@ 178 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so 179 - 180 - vdso.so: $(obj)/vdso.so.dbg 181 - @mkdir -p $(MODLIB)/vdso 182 - $(call cmd,vdso_install) 183 - 184 - vdso_install: vdso.so
-10
arch/csky/kernel/vdso/Makefile
··· 58 58 # that contains the same symbols at the same offsets. 59 59 quiet_cmd_so2s = SO2S $@ 60 60 cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@ 61 - 62 - # install commands for the unstripped file 63 - quiet_cmd_vdso_install = INSTALL $@ 64 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 65 - 66 - vdso.so: $(obj)/vdso.so.dbg 67 - @mkdir -p $(MODLIB)/vdso 68 - $(call cmd,vdso_install) 69 - 70 - vdso_install: vdso.so
+1 -3
arch/loongarch/Makefile
··· 136 136 $(Q)$(MAKE) $(build)=arch/loongarch/vdso include/generated/vdso-offsets.h 137 137 endif 138 138 139 - PHONY += vdso_install 140 - vdso_install: 141 - $(Q)$(MAKE) $(build)=arch/loongarch/vdso $@ 139 + vdso-install-y += arch/loongarch/vdso/vdso.so.dbg 142 140 143 141 all: $(notdir $(KBUILD_IMAGE)) 144 142
-10
arch/loongarch/vdso/Makefile
··· 83 83 obj-y += vdso.o 84 84 85 85 $(obj)/vdso.o : $(obj)/vdso.so 86 - 87 - # install commands for the unstripped file 88 - quiet_cmd_vdso_install = INSTALL $@ 89 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 90 - 91 - vdso.so: $(obj)/vdso.so.dbg 92 - @mkdir -p $(MODLIB)/vdso 93 - $(call cmd,vdso_install) 94 - 95 - vdso_install: vdso.so
+2 -6
arch/parisc/Makefile
··· 177 177 $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 include/generated/vdso32-offsets.h 178 178 endif 179 179 180 - PHONY += vdso_install 181 - 182 - vdso_install: 183 - $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso $@ 184 - $(if $(CONFIG_COMPAT_VDSO), \ 185 - $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 $@) 180 + vdso-install-y += arch/parisc/kernel/vdso32/vdso32.so 181 + vdso-install-$(CONFIG_64BIT) += arch/parisc/kernel/vdso64/vdso64.so 186 182 187 183 install: KBUILD_IMAGE := vmlinux 188 184 zinstall: KBUILD_IMAGE := vmlinuz
+3 -6
arch/riscv/Makefile
··· 130 130 libs-y += arch/riscv/lib/ 131 131 libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a 132 132 133 - PHONY += vdso_install 134 - vdso_install: 135 - $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@ 136 - $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \ 137 - $(build)=arch/riscv/kernel/compat_vdso compat_$@) 138 - 139 133 ifeq ($(KBUILD_EXTMOD),) 140 134 ifeq ($(CONFIG_MMU),y) 141 135 prepare: vdso_prepare ··· 140 146 141 147 endif 142 148 endif 149 + 150 + vdso-install-y += arch/riscv/kernel/vdso/vdso.so.dbg 151 + vdso-install-$(CONFIG_COMPAT) += arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg:../compat_vdso/compat_vdso.so 143 152 144 153 ifneq ($(CONFIG_XIP_KERNEL),y) 145 154 ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
-10
arch/riscv/kernel/compat_vdso/Makefile
··· 76 76 # actual build commands 77 77 quiet_cmd_compat_vdsoas = VDSOAS $@ 78 78 cmd_compat_vdsoas = $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c -o $@ $< 79 - 80 - # install commands for the unstripped file 81 - quiet_cmd_compat_vdso_install = INSTALL $@ 82 - cmd_compat_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/compat_vdso/$@ 83 - 84 - compat_vdso.so: $(obj)/compat_vdso.so.dbg 85 - @mkdir -p $(MODLIB)/compat_vdso 86 - $(call cmd,compat_vdso_install) 87 - 88 - compat_vdso_install: compat_vdso.so
-10
arch/riscv/kernel/vdso/Makefile
··· 73 73 cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \ 74 74 $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ 75 75 rm $@.tmp 76 - 77 - # install commands for the unstripped file 78 - quiet_cmd_vdso_install = INSTALL $@ 79 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 80 - 81 - vdso.so: $(obj)/vdso.so.dbg 82 - @mkdir -p $(MODLIB)/vdso 83 - $(call cmd,vdso_install) 84 - 85 - vdso_install: vdso.so
+3 -3
arch/s390/Makefile
··· 138 138 zfcpdump: 139 139 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 140 140 141 - vdso_install: 142 - $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@ 143 - 144 141 archheaders: 145 142 $(Q)$(MAKE) $(build)=$(syscalls) uapi 146 143 ··· 156 159 $(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h 157 160 $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \ 158 161 $(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h) 162 + 163 + vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg 164 + vdso-install-$(CONFIG_COMPAT) += arch/s390/kernel/vdso32/vdso32.so.dbg 159 165 160 166 ifdef CONFIG_EXPOLINE_EXTERN 161 167 modules_prepare: expoline_prepare
-10
arch/s390/kernel/vdso32/Makefile
··· 61 61 quiet_cmd_vdso32cc = VDSO32C $@ 62 62 cmd_vdso32cc = $(CC) $(c_flags) -c -o $@ $< 63 63 64 - # install commands for the unstripped file 65 - quiet_cmd_vdso_install = INSTALL $@ 66 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 67 - 68 - vdso32.so: $(obj)/vdso32.so.dbg 69 - @mkdir -p $(MODLIB)/vdso 70 - $(call cmd,vdso_install) 71 - 72 - vdso_install: vdso32.so 73 - 74 64 # Generate VDSO offsets using helper script 75 65 gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 76 66 quiet_cmd_vdsosym = VDSOSYM $@
-10
arch/s390/kernel/vdso64/Makefile
··· 70 70 quiet_cmd_vdso64cc = VDSO64C $@ 71 71 cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $< 72 72 73 - # install commands for the unstripped file 74 - quiet_cmd_vdso_install = INSTALL $@ 75 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 76 - 77 - vdso64.so: $(obj)/vdso64.so.dbg 78 - @mkdir -p $(MODLIB)/vdso 79 - $(call cmd,vdso_install) 80 - 81 - vdso_install: vdso64.so 82 - 83 73 # Generate VDSO offsets using helper script 84 74 gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 85 75 quiet_cmd_vdsosym = VDSOSYM $@
+2 -3
arch/sparc/Makefile
··· 76 76 archheaders: 77 77 $(Q)$(MAKE) $(build)=arch/sparc/kernel/syscalls all 78 78 79 - PHONY += vdso_install 80 - vdso_install: 81 - $(Q)$(MAKE) $(build)=arch/sparc/vdso $@ 79 + vdso-install-$(CONFIG_SPARC64) += arch/sparc/vdso/vdso64.so.dbg 80 + vdso-install-$(CONFIG_COMPAT) += arch/sparc/vdso/vdso32.so.dbg 82 81 83 82 # This is the image used for packaging 84 83 KBUILD_IMAGE := $(boot)/zImage
-27
arch/sparc/vdso/Makefile
··· 116 116 117 117 VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic 118 118 GCOV_PROFILE := n 119 - 120 - # 121 - # Install the unstripped copies of vdso*.so. If our toolchain supports 122 - # build-id, install .build-id links as well. 123 - # 124 - quiet_cmd_vdso_install = INSTALL $(@:install_%=%) 125 - define cmd_vdso_install 126 - cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \ 127 - if readelf -n $< |grep -q 'Build ID'; then \ 128 - buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ 129 - first=`echo $$buildid | cut -b-2`; \ 130 - last=`echo $$buildid | cut -b3-`; \ 131 - mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ 132 - ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ 133 - fi 134 - endef 135 - 136 - vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%) 137 - 138 - $(MODLIB)/vdso: FORCE 139 - @mkdir -p $(MODLIB)/vdso 140 - 141 - $(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE 142 - $(call cmd,vdso_install) 143 - 144 - PHONY += vdso_install $(vdso_img_insttargets) 145 - vdso_install: $(vdso_img_insttargets) FORCE
+4 -3
arch/x86/Makefile
··· 294 294 install: 295 295 $(call cmd,install) 296 296 297 - PHONY += vdso_install 298 - vdso_install: 299 - $(Q)$(MAKE) $(build)=arch/x86/entry/vdso $@ 297 + vdso-install-$(CONFIG_X86_64) += arch/x86/entry/vdso/vdso64.so.dbg 298 + vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdsox32.so.dbg 299 + vdso-install-$(CONFIG_X86_32) += arch/x86/entry/vdso/vdso32.so.dbg 300 + vdso-install-$(CONFIG_IA32_EMULATION) += arch/x86/entry/vdso/vdso32.so.dbg 300 301 301 302 archprepare: checkbin 302 303 checkbin:
-27
arch/x86/entry/vdso/Makefile
··· 191 191 quiet_cmd_vdso_and_check = VDSO $@ 192 192 cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check) 193 193 194 - # 195 - # Install the unstripped copies of vdso*.so. If our toolchain supports 196 - # build-id, install .build-id links as well. 197 - # 198 - quiet_cmd_vdso_install = INSTALL $(@:install_%=%) 199 - define cmd_vdso_install 200 - cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \ 201 - if readelf -n $< |grep -q 'Build ID'; then \ 202 - buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ 203 - first=`echo $$buildid | cut -b-2`; \ 204 - last=`echo $$buildid | cut -b3-`; \ 205 - mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ 206 - ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ 207 - fi 208 - endef 209 - 210 - vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%) 211 - 212 - $(MODLIB)/vdso: FORCE 213 - @mkdir -p $(MODLIB)/vdso 214 - 215 - $(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso 216 - $(call cmd,vdso_install) 217 - 218 - PHONY += vdso_install $(vdso_img_insttargets) 219 - vdso_install: $(vdso_img_insttargets) 220 - 221 194 clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so*
-12
arch/x86/um/vdso/Makefile
··· 67 67 68 68 VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv -z noexecstack 69 69 GCOV_PROFILE := n 70 - 71 - # 72 - # Install the unstripped copy of vdso*.so listed in $(vdso-install-y). 73 - # 74 - quiet_cmd_vdso_install = INSTALL $@ 75 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 76 - $(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE 77 - @mkdir -p $(MODLIB)/vdso 78 - $(call cmd,vdso_install) 79 - 80 - PHONY += vdso_install $(vdso-install-y) 81 - vdso_install: $(vdso-install-y)
-6
include/asm-generic/vmlinux.lds.h
··· 356 356 *(.ref.data) \ 357 357 *(.data..shared_aligned) /* percpu related */ \ 358 358 MEM_KEEP(init.data*) \ 359 - MEM_KEEP(exit.data*) \ 360 359 *(.data.unlikely) \ 361 360 __start_once = .; \ 362 361 *(.data.once) \ ··· 520 521 __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \ 521 522 *(.ref.rodata) \ 522 523 MEM_KEEP(init.rodata) \ 523 - MEM_KEEP(exit.rodata) \ 524 524 } \ 525 525 \ 526 526 /* Built-in module parameters. */ \ ··· 572 574 *(.ref.text) \ 573 575 *(.text.asan.* .text.tsan.*) \ 574 576 MEM_KEEP(init.text*) \ 575 - MEM_KEEP(exit.text*) \ 576 577 577 578 578 579 /* sched.text is aling to function alignment to secure we have same ··· 711 714 *(.exit.data .exit.data.*) \ 712 715 *(.fini_array .fini_array.*) \ 713 716 *(.dtors .dtors.*) \ 714 - MEM_DISCARD(exit.data*) \ 715 - MEM_DISCARD(exit.rodata*) 716 717 717 718 #define EXIT_TEXT \ 718 719 *(.exit.text) \ 719 720 *(.text.exit) \ 720 - MEM_DISCARD(exit.text) 721 721 722 722 #define EXIT_CALL \ 723 723 *(.exitcall.exit)
-3
include/linux/init.h
··· 89 89 __latent_entropy 90 90 #define __meminitdata __section(".meminit.data") 91 91 #define __meminitconst __section(".meminit.rodata") 92 - #define __memexit __section(".memexit.text") __exitused __cold notrace 93 - #define __memexitdata __section(".memexit.data") 94 - #define __memexitconst __section(".memexit.rodata") 95 92 96 93 /* For assembly routines */ 97 94 #define __HEAD .section ".head.text","ax"
+2
rust/Makefile
··· 381 381 quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@ 382 382 cmd_rustc_procmacro = \ 383 383 $(RUSTC_OR_CLIPPY) $(rust_common_flags) \ 384 + -Clinker-flavor=gcc -Clinker=$(HOSTCC) \ 385 + -Clink-args='$(call escsq,$(KBUILD_HOSTLDFLAGS))' \ 384 386 --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \ 385 387 --crate-type proc-macro \ 386 388 --crate-name $(patsubst lib%.so,%,$(notdir $@)) $<
+19
scripts/Makefile.btf
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + pahole-ver := $(CONFIG_PAHOLE_VERSION) 4 + pahole-flags-y := 5 + 6 + # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars 7 + ifeq ($(call test-le, $(pahole-ver), 121),y) 8 + pahole-flags-$(call test-ge, $(pahole-ver), 118) += --skip_encoding_btf_vars 9 + endif 10 + 11 + pahole-flags-$(call test-ge, $(pahole-ver), 121) += --btf_gen_floats 12 + 13 + pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j 14 + 15 + pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust 16 + 17 + pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsistent_proto --btf_gen_optimized 18 + 19 + export PAHOLE_FLAGS := $(pahole-flags-y)
+1 -1
scripts/Makefile.build
··· 425 425 $(call if_changed,ar) 426 426 427 427 quiet_cmd_ld_multi_m = LD [M] $@ 428 - cmd_ld_multi_m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) $(cmd_objtool) 428 + cmd_ld_multi_m = $(LD) $(ld_flags) -r -o $@ @$< $(cmd_objtool) 429 429 430 430 define rule_ld_multi_m 431 431 $(call cmd_and_savecmd,ld_multi_m)
+2
scripts/Makefile.host
··· 91 91 # current working directory, which may be not accessible in the out-of-tree 92 92 # modules case. 93 93 hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \ 94 + -Clinker-flavor=gcc -Clinker=$(HOSTCC) \ 95 + -Clink-args='$(call escsq,$(KBUILD_HOSTLDFLAGS))' \ 94 96 $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \ 95 97 $(HOSTRUSTFLAGS_$(target-stem)) 96 98
+1 -4
scripts/Makefile.modfinal
··· 28 28 %.mod.o: %.mod.c FORCE 29 29 $(call if_changed_dep,cc_o_c) 30 30 31 - ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) 32 - 33 31 quiet_cmd_ld_ko_o = LD [M] $@ 34 32 cmd_ld_ko_o += \ 35 33 $(LD) -r $(KBUILD_LDFLAGS) \ 36 34 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ 37 - -T scripts/module.lds -o $@ $(filter %.o, $^); \ 38 - $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 35 + -T scripts/module.lds -o $@ $(filter %.o, $^) 39 36 40 37 quiet_cmd_btf_ko = BTF [M] $@ 41 38 cmd_btf_ko = \
+4 -6
scripts/Makefile.package
··· 69 69 # --------------------------------------------------------------------------- 70 70 71 71 quiet_cmd_mkspec = GEN $@ 72 - cmd_mkspec = $(srctree)/scripts/package/mkspec > $@ 72 + cmd_mkspec = $(srctree)/scripts/package/mkspec $@ 73 73 74 - kernel.spec: FORCE 74 + rpmbuild/SPECS/kernel.spec: FORCE 75 75 $(call cmd,mkspec) 76 76 77 77 PHONY += rpm-sources ··· 88 88 binrpm-pkg: private build-type := b 89 89 90 90 rpm-pkg srcrpm-pkg: rpm-sources 91 - rpm-pkg srcrpm-pkg binrpm-pkg: kernel.spec 92 - +$(strip rpmbuild -b$(build-type) kernel.spec \ 91 + rpm-pkg srcrpm-pkg binrpm-pkg: rpmbuild/SPECS/kernel.spec 92 + +$(strip rpmbuild -b$(build-type) rpmbuild/SPECS/kernel.spec \ 93 93 --define='_topdir $(abspath rpmbuild)' \ 94 94 $(if $(filter a b, $(build-type)), \ 95 95 --target $(UTS_MACHINE)-linux --build-in-place --noprep --define='_smp_mflags %{nil}' \ 96 96 $$(rpm -q rpm >/dev/null 2>&1 || echo --nodeps)) \ 97 - $(if $(filter b, $(build-type)), \ 98 - --without devel) \ 99 97 $(RPMOPTS)) 100 98 101 99 # deb-pkg srcdeb-pkg bindeb-pkg
+3 -3
scripts/Makefile.userprogs
··· 19 19 user_ccflags = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \ 20 20 $($(target-stem)-userccflags) 21 21 user_ldflags = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags) 22 + user_ldlibs = $(userldlibs) $($(target-stem)-userldlibs) 22 23 23 24 # Create an executable from a single .c file 24 25 quiet_cmd_user_cc_c = CC [U] $@ 25 26 cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \ 26 - $($(target-stem)-userldlibs) 27 + $(user_ldlibs) 27 28 $(user-csingle): $(obj)/%: $(src)/%.c FORCE 28 29 $(call if_changed_dep,user_cc_c) 29 30 30 31 # Link an executable based on list of .o files 31 32 quiet_cmd_user_ld = LD [U] $@ 32 33 cmd_user_ld = $(CC) $(user_ldflags) -o $@ \ 33 - $(addprefix $(obj)/, $($(target-stem)-objs)) \ 34 - $($(target-stem)-userldlibs) 34 + $(addprefix $(obj)/, $($(target-stem)-objs)) $(user_ldlibs) 35 35 $(user-cmulti): FORCE 36 36 $(call if_changed,user_ld) 37 37 $(call multi_depend, $(user-cmulti), , -objs)
+45
scripts/Makefile.vdsoinst
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + # ========================================================================== 3 + # Install unstripped copies of vDSO 4 + # ========================================================================== 5 + 6 + PHONY := __default 7 + __default: 8 + @: 9 + 10 + include $(srctree)/scripts/Kbuild.include 11 + 12 + install-dir := $(MODLIB)/vdso 13 + 14 + define gen_install_rules 15 + 16 + src := $$(firstword $$(subst :,$(space),$(1))) 17 + dest := $(install-dir)/$$(or $$(word 2,$$(subst :,$(space),$(1))),$$(patsubst %.dbg,%,$$(notdir $(1)))) 18 + 19 + __default: $$(dest) 20 + $$(dest): $$(src) FORCE 21 + $$(call cmd,install) 22 + 23 + # Some architectures create .build-id symlinks 24 + ifneq ($(filter arm sparc x86, $(SRCARCH)),) 25 + link := $(install-dir)/.build-id/$$(shell $(READELF) -n $$(src) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') 26 + 27 + __default: $$(link) 28 + $$(link): $$(dest) FORCE 29 + $$(call cmd,symlink) 30 + endif 31 + 32 + endef 33 + 34 + $(foreach x, $(sort $(INSTALL_FILES)), $(eval $(call gen_install_rules,$(x)))) 35 + 36 + quiet_cmd_install = INSTALL $@ 37 + cmd_install = mkdir -p $(dir $@); cp $< $@ 38 + 39 + quiet_cmd_symlink = SYMLINK $@ 40 + cmd_symlink = mkdir -p $(dir $@); ln -sf --relative $< $@ 41 + 42 + PHONY += FORCE 43 + FORCE: 44 + 45 + .PHONY: $(PHONY)
+10
scripts/dummy-tools/gcc
··· 91 91 fi 92 92 exit 0 93 93 fi 94 + 95 + # For arch/powerpc/tools/gcc-check-fpatchable-function-entry.sh 96 + if arg_contain -m64 "$@" && arg_contain -fpatchable-function-entry=2 "$@"; then 97 + echo "func:" 98 + echo ".section __patchable_function_entries" 99 + echo ".localentry" 100 + echo " nop" 101 + echo " nop" 102 + exit 0 103 + fi 94 104 fi 95 105 96 106 # To set GCC_PLUGINS
+2 -2
scripts/mod/Makefile
··· 5 5 hostprogs-always-y += modpost mk_elfconfig 6 6 always-y += empty.o 7 7 8 - modpost-objs := modpost.o file2alias.o sumversion.o 8 + modpost-objs := modpost.o file2alias.o sumversion.o symsearch.o 9 9 10 10 devicetable-offsets-file := devicetable-offsets.h 11 11 ··· 16 16 17 17 # dependencies on generated files need to be listed explicitly 18 18 19 - $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h 19 + $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o $(obj)/symsearch.o: $(obj)/elfconfig.h 20 20 $(obj)/file2alias.o: $(obj)/$(devicetable-offsets-file) 21 21 22 22 quiet_cmd_elfconfig = MKELF $@
+7 -7
scripts/mod/file2alias.c
··· 1348 1348 /* Looks like: tee:uuid */ 1349 1349 static int do_tee_entry(const char *filename, void *symval, char *alias) 1350 1350 { 1351 - DEF_FIELD(symval, tee_client_device_id, uuid); 1351 + DEF_FIELD_ADDR(symval, tee_client_device_id, uuid); 1352 1352 1353 1353 sprintf(alias, "tee:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", 1354 - uuid.b[0], uuid.b[1], uuid.b[2], uuid.b[3], uuid.b[4], 1355 - uuid.b[5], uuid.b[6], uuid.b[7], uuid.b[8], uuid.b[9], 1356 - uuid.b[10], uuid.b[11], uuid.b[12], uuid.b[13], uuid.b[14], 1357 - uuid.b[15]); 1354 + uuid->b[0], uuid->b[1], uuid->b[2], uuid->b[3], uuid->b[4], 1355 + uuid->b[5], uuid->b[6], uuid->b[7], uuid->b[8], uuid->b[9], 1356 + uuid->b[10], uuid->b[11], uuid->b[12], uuid->b[13], uuid->b[14], 1357 + uuid->b[15]); 1358 1358 1359 1359 add_wildcard(alias); 1360 1360 return 1; ··· 1401 1401 /* Looks like: ishtp:{guid} */ 1402 1402 static int do_ishtp_entry(const char *filename, void *symval, char *alias) 1403 1403 { 1404 - DEF_FIELD(symval, ishtp_device_id, guid); 1404 + DEF_FIELD_ADDR(symval, ishtp_device_id, guid); 1405 1405 1406 1406 strcpy(alias, ISHTP_MODULE_PREFIX "{"); 1407 - add_guid(alias, guid); 1407 + add_guid(alias, *guid); 1408 1408 strcat(alias, "}"); 1409 1409 1410 1410 return 1;
+49 -152
scripts/mod/modpost.c
··· 22 22 #include <errno.h> 23 23 #include "modpost.h" 24 24 #include "../../include/linux/license.h" 25 - #include "../../include/linux/module_symbol.h" 26 25 27 26 static bool module_enabled; 28 27 /* Are we using CONFIG_MODVERSIONS? */ ··· 576 577 *p = TO_NATIVE(*p); 577 578 } 578 579 580 + symsearch_init(info); 581 + 579 582 return 1; 580 583 } 581 584 582 585 static void parse_elf_finish(struct elf_info *info) 583 586 { 587 + symsearch_finish(info); 584 588 release_file(info->hdr, info->size); 585 589 } 586 590 ··· 794 792 #define ALL_INIT_DATA_SECTIONS \ 795 793 ".init.setup", ".init.rodata", ".meminit.rodata", \ 796 794 ".init.data", ".meminit.data" 797 - #define ALL_EXIT_DATA_SECTIONS \ 798 - ".exit.data", ".memexit.data" 799 - 800 - #define ALL_INIT_TEXT_SECTIONS \ 801 - ".init.text", ".meminit.text" 802 - #define ALL_EXIT_TEXT_SECTIONS \ 803 - ".exit.text", ".memexit.text" 804 795 805 796 #define ALL_PCI_INIT_SECTIONS \ 806 797 ".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \ 807 798 ".pci_fixup_enable", ".pci_fixup_resume", \ 808 799 ".pci_fixup_resume_early", ".pci_fixup_suspend" 809 800 810 - #define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS 811 - #define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS 801 + #define ALL_XXXINIT_SECTIONS ".meminit.*" 812 802 813 803 #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS 814 - #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS 804 + #define ALL_EXIT_SECTIONS ".exit.*" 815 805 816 806 #define DATA_SECTIONS ".data", ".data.rel" 817 807 #define TEXT_SECTIONS ".text", ".text.*", ".sched.text", \ ··· 813 819 ".coldtext", ".softirqentry.text" 814 820 815 821 #define INIT_SECTIONS ".init.*" 816 - #define MEM_INIT_SECTIONS ".meminit.*" 817 822 818 - #define EXIT_SECTIONS ".exit.*" 819 - #define MEM_EXIT_SECTIONS ".memexit.*" 820 - 821 - #define ALL_TEXT_SECTIONS ALL_INIT_TEXT_SECTIONS, ALL_EXIT_TEXT_SECTIONS, \ 823 + #define ALL_TEXT_SECTIONS ".init.text", ".meminit.text", ".exit.text", \ 822 824 TEXT_SECTIONS, OTHER_TEXT_SECTIONS 823 825 824 826 enum mismatch { 825 - TEXT_TO_ANY_INIT, 826 - DATA_TO_ANY_INIT, 827 - TEXTDATA_TO_ANY_EXIT, 827 + TEXTDATA_TO_ANY_INIT_EXIT, 828 828 XXXINIT_TO_SOME_INIT, 829 - XXXEXIT_TO_SOME_EXIT, 830 829 ANY_INIT_TO_ANY_EXIT, 831 830 ANY_EXIT_TO_ANY_INIT, 832 831 EXTABLE_TO_NON_TEXT, ··· 850 863 * normal code and data 851 864 */ 852 865 { 853 - .fromsec = { TEXT_SECTIONS, NULL }, 854 - .bad_tosec = { ALL_INIT_SECTIONS, NULL }, 855 - .mismatch = TEXT_TO_ANY_INIT, 856 - }, 857 - { 858 - .fromsec = { DATA_SECTIONS, NULL }, 859 - .bad_tosec = { ALL_XXXINIT_SECTIONS, INIT_SECTIONS, NULL }, 860 - .mismatch = DATA_TO_ANY_INIT, 861 - }, 862 - { 863 866 .fromsec = { TEXT_SECTIONS, DATA_SECTIONS, NULL }, 864 - .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, 865 - .mismatch = TEXTDATA_TO_ANY_EXIT, 867 + .bad_tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }, 868 + .mismatch = TEXTDATA_TO_ANY_INIT_EXIT, 866 869 }, 867 870 /* Do not reference init code/data from meminit code/data */ 868 871 { 869 872 .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, 870 873 .bad_tosec = { INIT_SECTIONS, NULL }, 871 874 .mismatch = XXXINIT_TO_SOME_INIT, 872 - }, 873 - /* Do not reference exit code/data from memexit code/data */ 874 - { 875 - .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, 876 - .bad_tosec = { EXIT_SECTIONS, NULL }, 877 - .mismatch = XXXEXIT_TO_SOME_EXIT, 878 875 }, 879 876 /* Do not use exit code/data from init code */ 880 877 { ··· 977 1006 /* symbols in data sections that may refer to any init/exit sections */ 978 1007 if (match(fromsec, PATTERNS(DATA_SECTIONS)) && 979 1008 match(tosec, PATTERNS(ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS)) && 980 - match(fromsym, PATTERNS("*_template", // scsi uses *_template a lot 981 - "*_timer", // arm uses ops structures named _timer a lot 982 - "*_sht", // scsi also used *_sht to some extent 983 - "*_ops", 984 - "*_probe", 985 - "*_probe_one", 986 - "*_console"))) 987 - return 0; 988 - 989 - /* symbols in data sections that may refer to meminit sections */ 990 - if (match(fromsec, PATTERNS(DATA_SECTIONS)) && 991 - match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_XXXEXIT_SECTIONS)) && 992 - match(fromsym, PATTERNS("*driver"))) 1009 + match(fromsym, PATTERNS("*_ops", "*_probe", "*_console"))) 993 1010 return 0; 994 1011 995 1012 /* ··· 987 1028 */ 988 1029 if (!extra_warn && 989 1030 match(fromsec, PATTERNS(DATA_SECTIONS)) && 990 - match(tosec, PATTERNS(EXIT_SECTIONS)) && 1031 + match(tosec, PATTERNS(ALL_EXIT_SECTIONS)) && 991 1032 match(fromsym, PATTERNS("*driver"))) 992 1033 return 0; 993 1034 ··· 1009 1050 return 1; 1010 1051 } 1011 1052 1012 - /* 1013 - * If there's no name there, ignore it; likewise, ignore it if it's 1014 - * one of the magic symbols emitted used by current tools. 1015 - * 1016 - * Otherwise if find_symbols_between() returns those symbols, they'll 1017 - * fail the whitelist tests and cause lots of false alarms ... fixable 1018 - * only by merging __exit and __init sections into __text, bloating 1019 - * the kernel (which is especially evil on embedded platforms). 1020 - */ 1021 - static inline bool is_valid_name(struct elf_info *elf, Elf_Sym *sym) 1022 - { 1023 - const char *name = elf->strtab + sym->st_name; 1024 - 1025 - if (!name || !strlen(name)) 1026 - return false; 1027 - return !is_mapping_symbol(name); 1028 - } 1029 - 1030 - /* Look up the nearest symbol based on the section and the address */ 1031 - static Elf_Sym *find_nearest_sym(struct elf_info *elf, Elf_Addr addr, 1032 - unsigned int secndx, bool allow_negative, 1033 - Elf_Addr min_distance) 1034 - { 1035 - Elf_Sym *sym; 1036 - Elf_Sym *near = NULL; 1037 - Elf_Addr sym_addr, distance; 1038 - bool is_arm = (elf->hdr->e_machine == EM_ARM); 1039 - 1040 - for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 1041 - if (get_secindex(elf, sym) != secndx) 1042 - continue; 1043 - if (!is_valid_name(elf, sym)) 1044 - continue; 1045 - 1046 - sym_addr = sym->st_value; 1047 - 1048 - /* 1049 - * For ARM Thumb instruction, the bit 0 of st_value is set 1050 - * if the symbol is STT_FUNC type. Mask it to get the address. 1051 - */ 1052 - if (is_arm && ELF_ST_TYPE(sym->st_info) == STT_FUNC) 1053 - sym_addr &= ~1; 1054 - 1055 - if (addr >= sym_addr) 1056 - distance = addr - sym_addr; 1057 - else if (allow_negative) 1058 - distance = sym_addr - addr; 1059 - else 1060 - continue; 1061 - 1062 - if (distance <= min_distance) { 1063 - min_distance = distance; 1064 - near = sym; 1065 - } 1066 - 1067 - if (min_distance == 0) 1068 - break; 1069 - } 1070 - return near; 1071 - } 1072 - 1073 1053 static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr, 1074 1054 unsigned int secndx) 1075 1055 { 1076 - return find_nearest_sym(elf, addr, secndx, false, ~0); 1056 + return symsearch_find_nearest(elf, addr, secndx, false, ~0); 1077 1057 } 1078 1058 1079 1059 static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym) ··· 1025 1127 * Strive to find a better symbol name, but the resulting name may not 1026 1128 * match the symbol referenced in the original code. 1027 1129 */ 1028 - return find_nearest_sym(elf, addr, get_secindex(elf, sym), true, 20); 1130 + return symsearch_find_nearest(elf, addr, get_secindex(elf, sym), 1131 + true, 20); 1029 1132 } 1030 1133 1031 1134 static bool is_executable_section(struct elf_info *elf, unsigned int secndx) ··· 1147 1248 ELF_ST_TYPE(sym->st_info) == STT_LOPROC) 1148 1249 s->is_func = true; 1149 1250 1150 - if (match(secname, PATTERNS(INIT_SECTIONS))) 1251 + if (match(secname, PATTERNS(ALL_INIT_SECTIONS))) 1151 1252 warn("%s: %s: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.\n", 1152 1253 mod->name, name); 1153 - else if (match(secname, PATTERNS(EXIT_SECTIONS))) 1254 + else if (match(secname, PATTERNS(ALL_EXIT_SECTIONS))) 1154 1255 warn("%s: %s: EXPORT_SYMBOL used for exit symbol. Remove __exit or EXPORT_SYMBOL.\n", 1155 1256 mod->name, name); 1156 1257 } ··· 1367 1468 return; 1368 1469 } 1369 1470 1370 - if (is_64bit) { 1371 - Elf64_Xword r_info64 = r_info; 1372 - 1373 - r_info = TO_NATIVE(r_info64); 1374 - } else { 1375 - Elf32_Word r_info32 = r_info; 1376 - 1377 - r_info = TO_NATIVE(r_info32); 1378 - } 1471 + if (is_64bit) 1472 + r_info = TO_NATIVE((Elf64_Xword)r_info); 1473 + else 1474 + r_info = TO_NATIVE((Elf32_Word)r_info); 1379 1475 1380 1476 *r_type = ELF_R_TYPE(r_info); 1381 1477 *r_sym = ELF_R_SYM(r_info); 1382 1478 } 1383 1479 1384 1480 static void section_rela(struct module *mod, struct elf_info *elf, 1385 - Elf_Shdr *sechdr) 1481 + unsigned int fsecndx, const char *fromsec, 1482 + const Elf_Rela *start, const Elf_Rela *stop) 1386 1483 { 1387 - Elf_Rela *rela; 1388 - unsigned int fsecndx = sechdr->sh_info; 1389 - const char *fromsec = sec_name(elf, fsecndx); 1390 - Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset; 1391 - Elf_Rela *stop = (void *)start + sechdr->sh_size; 1392 - 1393 - /* if from section (name) is know good then skip it */ 1394 - if (match(fromsec, section_white_list)) 1395 - return; 1484 + const Elf_Rela *rela; 1396 1485 1397 1486 for (rela = start; rela < stop; rela++) { 1398 1487 Elf_Addr taddr, r_offset; ··· 1410 1523 } 1411 1524 1412 1525 static void section_rel(struct module *mod, struct elf_info *elf, 1413 - Elf_Shdr *sechdr) 1526 + unsigned int fsecndx, const char *fromsec, 1527 + const Elf_Rel *start, const Elf_Rel *stop) 1414 1528 { 1415 - Elf_Rel *rel; 1416 - unsigned int fsecndx = sechdr->sh_info; 1417 - const char *fromsec = sec_name(elf, fsecndx); 1418 - Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset; 1419 - Elf_Rel *stop = (void *)start + sechdr->sh_size; 1420 - 1421 - /* if from section (name) is know good then skip it */ 1422 - if (match(fromsec, section_white_list)) 1423 - return; 1529 + const Elf_Rel *rel; 1424 1530 1425 1531 for (rel = start; rel < stop; rel++) { 1426 1532 Elf_Sym *tsym; ··· 1461 1581 static void check_sec_ref(struct module *mod, struct elf_info *elf) 1462 1582 { 1463 1583 int i; 1464 - Elf_Shdr *sechdrs = elf->sechdrs; 1465 1584 1466 1585 /* Walk through all sections */ 1467 1586 for (i = 0; i < elf->num_sections; i++) { 1468 - check_section(mod->name, elf, &elf->sechdrs[i]); 1587 + Elf_Shdr *sechdr = &elf->sechdrs[i]; 1588 + 1589 + check_section(mod->name, elf, sechdr); 1469 1590 /* We want to process only relocation sections and not .init */ 1470 - if (sechdrs[i].sh_type == SHT_RELA) 1471 - section_rela(mod, elf, &elf->sechdrs[i]); 1472 - else if (sechdrs[i].sh_type == SHT_REL) 1473 - section_rel(mod, elf, &elf->sechdrs[i]); 1591 + if (sechdr->sh_type == SHT_REL || sechdr->sh_type == SHT_RELA) { 1592 + /* section to which the relocation applies */ 1593 + unsigned int secndx = sechdr->sh_info; 1594 + const char *secname = sec_name(elf, secndx); 1595 + const void *start, *stop; 1596 + 1597 + /* If the section is known good, skip it */ 1598 + if (match(secname, section_white_list)) 1599 + continue; 1600 + 1601 + start = sym_get_data_by_offset(elf, i, 0); 1602 + stop = start + sechdr->sh_size; 1603 + 1604 + if (sechdr->sh_type == SHT_RELA) 1605 + section_rela(mod, elf, secndx, secname, 1606 + start, stop); 1607 + else 1608 + section_rel(mod, elf, secndx, secname, 1609 + start, stop); 1610 + } 1474 1611 } 1475 1612 } 1476 1613
+37 -13
scripts/mod/modpost.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 + #include <byteswap.h> 2 3 #include <stdbool.h> 3 4 #include <stdio.h> 4 5 #include <stdlib.h> ··· 11 10 #include <fcntl.h> 12 11 #include <unistd.h> 13 12 #include <elf.h> 13 + #include "../../include/linux/module_symbol.h" 14 14 15 15 #include "list.h" 16 16 #include "elfconfig.h" ··· 52 50 #define ELF_R_TYPE ELF64_R_TYPE 53 51 #endif 54 52 53 + #define bswap(x) \ 54 + ({ \ 55 + _Static_assert(sizeof(x) == 1 || sizeof(x) == 2 || \ 56 + sizeof(x) == 4 || sizeof(x) == 8, "bug"); \ 57 + (typeof(x))(sizeof(x) == 2 ? bswap_16(x) : \ 58 + sizeof(x) == 4 ? bswap_32(x) : \ 59 + sizeof(x) == 8 ? bswap_64(x) : \ 60 + x); \ 61 + }) 62 + 55 63 #if KERNEL_ELFDATA != HOST_ELFDATA 56 64 57 - static inline void __endian(const void *src, void *dest, unsigned int size) 58 - { 59 - unsigned int i; 60 - for (i = 0; i < size; i++) 61 - ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1]; 62 - } 63 - 64 - #define TO_NATIVE(x) \ 65 - ({ \ 66 - typeof(x) __x; \ 67 - __endian(&(x), &(__x), sizeof(__x)); \ 68 - __x; \ 69 - }) 65 + #define TO_NATIVE(x) (bswap(x)) 70 66 71 67 #else /* endianness matches */ 72 68 ··· 128 128 * take shndx from symtab_shndx_start[N] instead */ 129 129 Elf32_Word *symtab_shndx_start; 130 130 Elf32_Word *symtab_shndx_stop; 131 + 132 + struct symsearch *symsearch; 131 133 }; 132 134 133 135 /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ ··· 155 153 156 154 return index; 157 155 } 156 + 157 + /* 158 + * If there's no name there, ignore it; likewise, ignore it if it's 159 + * one of the magic symbols emitted used by current tools. 160 + * 161 + * Internal symbols created by tools should be ignored by modpost. 162 + */ 163 + static inline bool is_valid_name(struct elf_info *elf, Elf_Sym *sym) 164 + { 165 + const char *name = elf->strtab + sym->st_name; 166 + 167 + if (!name || !strlen(name)) 168 + return false; 169 + return !is_mapping_symbol(name); 170 + } 171 + 172 + /* symsearch.c */ 173 + void symsearch_init(struct elf_info *elf); 174 + void symsearch_finish(struct elf_info *elf); 175 + Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr, 176 + unsigned int secndx, bool allow_negative, 177 + Elf_Addr min_distance); 158 178 159 179 /* file2alias.c */ 160 180 void handle_moddevtable(struct module *mod, struct elf_info *info,
+199
scripts/mod/symsearch.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + /* 4 + * Helper functions for finding the symbol in an ELF which is "nearest" 5 + * to a given address. 6 + */ 7 + 8 + #include "modpost.h" 9 + 10 + struct syminfo { 11 + unsigned int symbol_index; 12 + unsigned int section_index; 13 + Elf_Addr addr; 14 + }; 15 + 16 + /* 17 + * Container used to hold an entire binary search table. 18 + * Entries in table are ascending, sorted first by section_index, 19 + * then by addr, and last by symbol_index. The sorting by 20 + * symbol_index is used to ensure predictable behavior when 21 + * multiple symbols are present with the same address; all 22 + * symbols past the first are effectively ignored, by eliding 23 + * them in symsearch_fixup(). 24 + */ 25 + struct symsearch { 26 + unsigned int table_size; 27 + struct syminfo table[]; 28 + }; 29 + 30 + static int syminfo_compare(const void *s1, const void *s2) 31 + { 32 + const struct syminfo *sym1 = s1; 33 + const struct syminfo *sym2 = s2; 34 + 35 + if (sym1->section_index > sym2->section_index) 36 + return 1; 37 + if (sym1->section_index < sym2->section_index) 38 + return -1; 39 + if (sym1->addr > sym2->addr) 40 + return 1; 41 + if (sym1->addr < sym2->addr) 42 + return -1; 43 + if (sym1->symbol_index > sym2->symbol_index) 44 + return 1; 45 + if (sym1->symbol_index < sym2->symbol_index) 46 + return -1; 47 + return 0; 48 + } 49 + 50 + static unsigned int symbol_count(struct elf_info *elf) 51 + { 52 + unsigned int result = 0; 53 + 54 + for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 55 + if (is_valid_name(elf, sym)) 56 + result++; 57 + } 58 + return result; 59 + } 60 + 61 + /* 62 + * Populate the search array that we just allocated. 63 + * Be slightly paranoid here. The ELF file is mmap'd and could 64 + * conceivably change between symbol_count() and symsearch_populate(). 65 + * If we notice any difference, bail out rather than potentially 66 + * propagating errors or crashing. 67 + */ 68 + static void symsearch_populate(struct elf_info *elf, 69 + struct syminfo *table, 70 + unsigned int table_size) 71 + { 72 + bool is_arm = (elf->hdr->e_machine == EM_ARM); 73 + 74 + for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 75 + if (is_valid_name(elf, sym)) { 76 + if (table_size-- == 0) 77 + fatal("%s: size mismatch\n", __func__); 78 + table->symbol_index = sym - elf->symtab_start; 79 + table->section_index = get_secindex(elf, sym); 80 + table->addr = sym->st_value; 81 + 82 + /* 83 + * For ARM Thumb instruction, the bit 0 of st_value is 84 + * set if the symbol is STT_FUNC type. Mask it to get 85 + * the address. 86 + */ 87 + if (is_arm && ELF_ST_TYPE(sym->st_info) == STT_FUNC) 88 + table->addr &= ~1; 89 + 90 + table++; 91 + } 92 + } 93 + 94 + if (table_size != 0) 95 + fatal("%s: size mismatch\n", __func__); 96 + } 97 + 98 + /* 99 + * Do any fixups on the table after sorting. 100 + * For now, this just finds adjacent entries which have 101 + * the same section_index and addr, and it propagates 102 + * the first symbol_index over the subsequent entries, 103 + * so that only one symbol_index is seen for any given 104 + * section_index and addr. This ensures that whether 105 + * we're looking at an address from "above" or "below" 106 + * that we see the same symbol_index. 107 + * This does leave some duplicate entries in the table; 108 + * in practice, these are a small fraction of the 109 + * total number of entries, and they are harmless to 110 + * the binary search algorithm other than a few occasional 111 + * unnecessary comparisons. 112 + */ 113 + static void symsearch_fixup(struct syminfo *table, unsigned int table_size) 114 + { 115 + /* Don't look at index 0, it will never change. */ 116 + for (unsigned int i = 1; i < table_size; i++) { 117 + if (table[i].addr == table[i - 1].addr && 118 + table[i].section_index == table[i - 1].section_index) { 119 + table[i].symbol_index = table[i - 1].symbol_index; 120 + } 121 + } 122 + } 123 + 124 + void symsearch_init(struct elf_info *elf) 125 + { 126 + unsigned int table_size = symbol_count(elf); 127 + 128 + elf->symsearch = NOFAIL(malloc(sizeof(struct symsearch) + 129 + sizeof(struct syminfo) * table_size)); 130 + elf->symsearch->table_size = table_size; 131 + 132 + symsearch_populate(elf, elf->symsearch->table, table_size); 133 + qsort(elf->symsearch->table, table_size, 134 + sizeof(struct syminfo), syminfo_compare); 135 + 136 + symsearch_fixup(elf->symsearch->table, table_size); 137 + } 138 + 139 + void symsearch_finish(struct elf_info *elf) 140 + { 141 + free(elf->symsearch); 142 + elf->symsearch = NULL; 143 + } 144 + 145 + /* 146 + * Find the syminfo which is in secndx and "nearest" to addr. 147 + * allow_negative: allow returning a symbol whose address is > addr. 148 + * min_distance: ignore symbols which are further away than this. 149 + * 150 + * Returns a pointer into the symbol table for success. 151 + * Returns NULL if no legal symbol is found within the requested range. 152 + */ 153 + Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr, 154 + unsigned int secndx, bool allow_negative, 155 + Elf_Addr min_distance) 156 + { 157 + unsigned int hi = elf->symsearch->table_size; 158 + unsigned int lo = 0; 159 + struct syminfo *table = elf->symsearch->table; 160 + struct syminfo target; 161 + 162 + target.addr = addr; 163 + target.section_index = secndx; 164 + target.symbol_index = ~0; /* compares greater than any actual index */ 165 + while (hi > lo) { 166 + unsigned int mid = lo + (hi - lo) / 2; /* Avoids overflow */ 167 + 168 + if (syminfo_compare(&table[mid], &target) > 0) 169 + hi = mid; 170 + else 171 + lo = mid + 1; 172 + } 173 + 174 + /* 175 + * table[hi], if it exists, is the first entry in the array which 176 + * lies beyond target. table[hi - 1], if it exists, is the last 177 + * entry in the array which comes before target, including the 178 + * case where it perfectly matches the section and the address. 179 + * 180 + * Note -- if the address we're looking up falls perfectly 181 + * in the middle of two symbols, this is written to always 182 + * prefer the symbol with the lower address. 183 + */ 184 + Elf_Sym *result = NULL; 185 + 186 + if (allow_negative && 187 + hi < elf->symsearch->table_size && 188 + table[hi].section_index == secndx && 189 + table[hi].addr - addr <= min_distance) { 190 + min_distance = table[hi].addr - addr; 191 + result = &elf->symtab_start[table[hi].symbol_index]; 192 + } 193 + if (hi > 0 && 194 + table[hi - 1].section_index == secndx && 195 + addr - table[hi - 1].addr <= min_distance) { 196 + result = &elf->symtab_start[table[hi - 1].symbol_index]; 197 + } 198 + return result; 199 + }
+6
scripts/package/mkspec
··· 9 9 # Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net> 10 10 # 11 11 12 + output=$1 13 + 14 + mkdir -p "$(dirname "${output}")" 15 + 16 + exec >"${output}" 17 + 12 18 if grep -q CONFIG_MODULES=y include/config/auto.conf; then 13 19 echo '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}' 14 20 else
-30
scripts/pahole-flags.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - extra_paholeopt= 5 - 6 - if ! [ -x "$(command -v ${PAHOLE})" ]; then 7 - exit 0 8 - fi 9 - 10 - pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE}) 11 - 12 - if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then 13 - # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars 14 - extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars" 15 - fi 16 - if [ "${pahole_ver}" -ge "121" ]; then 17 - extra_paholeopt="${extra_paholeopt} --btf_gen_floats" 18 - fi 19 - if [ "${pahole_ver}" -ge "122" ]; then 20 - extra_paholeopt="${extra_paholeopt} -j" 21 - fi 22 - if [ "${pahole_ver}" -ge "124" ]; then 23 - # see PAHOLE_HAS_LANG_EXCLUDE 24 - extra_paholeopt="${extra_paholeopt} --lang_exclude=rust" 25 - fi 26 - if [ "${pahole_ver}" -ge "125" ]; then 27 - extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_inconsistent_proto --btf_gen_optimized" 28 - fi 29 - 30 - echo ${extra_paholeopt}
+1 -1
scripts/remove-stale-files
··· 38 38 39 39 find . -name '*.usyms' | xargs rm -f 40 40 41 - rm -f binkernel.spec 41 + rm -f *.spec