mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 17:22:07 +00:00
Kbuild updates for v6.7
- 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 -----BEGIN PGP SIGNATURE----- iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmVFIZgVHG1hc2FoaXJv eUBrZXJuZWwub3JnAAoJED2LAQed4NsGeKwP+wd2kCrxAgS4zPffOcO3cVHfZwJe AXOrTp/v73gzxb9eHXH6TmEDf1Rv7EwW3fmmGJosopJGD6itBqzJa4bNDrbq40rY XStmg0NRmTrIG20CHGgaGWxb8/7WMrYfu0rhFdUXJjmbny6XwJ3US9FvDPC0mZz7 w9VCq5CZOqMsJcQyGkAR7uCHDRzNWiZ/Vnfbz3aa6abFzp7dsjhOgDy5SQ6qZgQz AwHHKNEN+G3HWmGDZqcbV9aDaCk4btnz64h843RAxjy2HNJF360Ohm2KOcdJr5lo DSSStkogBkZNSRQPtqtfknDjzITjeF4JAnUw5ivOtt8ERaO3JRUcr5gHjfw5iV/n o4pC1SXmFzdfoN4dogoYF9rz3j955mSFlT/DSbSbuQS/ELzQs0nsqERxhV4zNCsX KvYPUqKzZLW3i8pHNuhh7z7t4Nbz1zXqUa19FvaLNtFTCtS8/IA868a59S0uqT9I EAIqrNy9qAsk8UuQUxWVx0qf9f5wKGYxW62iMIF9F2lsFRWA8H588CFPUuSU9Bhk KAsvzq249MUGJd0RAjF92EWJgNz/nYzZfFTEL5HKAVauYY5UCyR3AVjrak761I8z ctVskA7eVkaW4eARfcp15Fna15FHVzxBJ3B26oKYIJBQfJLjzZcV8XeMtEcQjEGU jzl+oRqB/Q3oD7Nx =PeX7 -----END PGP SIGNATURE----- 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 ...
This commit is contained in:
commit
5c5e048b24
1
.gitignore
vendored
1
.gitignore
vendored
@ -74,7 +74,6 @@ modules.order
|
||||
#
|
||||
# RPM spec file (make rpm-pkg)
|
||||
#
|
||||
/kernel.spec
|
||||
/rpmbuild/
|
||||
|
||||
#
|
||||
|
@ -243,6 +243,12 @@ The output directory is often set using "O=..." on the commandline.
|
||||
|
||||
The value can be overridden in which case the default value is ignored.
|
||||
|
||||
INSTALL_DTBS_PATH
|
||||
-----------------
|
||||
INSTALL_DTBS_PATH specifies where to install device tree blobs for
|
||||
relocations required by build roots. This is not defined in the
|
||||
makefile but the argument can be passed to make if needed.
|
||||
|
||||
KBUILD_ABS_SRCTREE
|
||||
--------------------------------------------------
|
||||
Kbuild uses a relative path to point to the tree when possible. For instance,
|
||||
|
@ -937,6 +937,10 @@ Example::
|
||||
# net/bpfilter/Makefile
|
||||
bpfilter_umh-userldflags += -static
|
||||
|
||||
To specify libraries linked to a userspace program, you can use
|
||||
``<executable>-userldlibs``. The ``userldlibs`` syntax specifies libraries
|
||||
linked to all userspace programs created in the current Makefile.
|
||||
|
||||
When linking bpfilter_umh, it will be passed the extra option -static.
|
||||
|
||||
From command line, :ref:`USERCFLAGS and USERLDFLAGS <userkbuildflags>` will also be used.
|
||||
@ -1623,6 +1627,13 @@ INSTALL_MOD_STRIP
|
||||
INSTALL_MOD_STRIP value will be used as the option(s) to the strip
|
||||
command.
|
||||
|
||||
INSTALL_DTBS_PATH
|
||||
This variable specifies a prefix for relocations required by build
|
||||
roots. It defines a place for installing the device tree blobs. Like
|
||||
INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed
|
||||
by the user if desired. Otherwise it defaults to the kernel install
|
||||
path.
|
||||
|
||||
Makefile language
|
||||
=================
|
||||
|
||||
|
@ -3781,7 +3781,7 @@ F: net/sched/act_bpf.c
|
||||
F: net/sched/cls_bpf.c
|
||||
F: samples/bpf/
|
||||
F: scripts/bpf_doc.py
|
||||
F: scripts/pahole-flags.sh
|
||||
F: scripts/Makefile.btf
|
||||
F: scripts/pahole-version.sh
|
||||
F: tools/bpf/
|
||||
F: tools/lib/bpf/
|
||||
|
38
Makefile
38
Makefile
@ -277,10 +277,6 @@ no-dot-config-targets := $(clean-targets) \
|
||||
$(version_h) headers headers_% archheaders archscripts \
|
||||
%asm-generic kernelversion %src-pkg dt_binding_check \
|
||||
outputmakefile rustavailable rustfmt rustfmtcheck
|
||||
# Installation targets should not require compiler. Unfortunately, vdso_install
|
||||
# is an exception where build artifacts may be updated. This must be fixed.
|
||||
no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
|
||||
headers_install modules_install modules_sign kernelrelease image_name
|
||||
no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
|
||||
image_name
|
||||
single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/
|
||||
@ -288,7 +284,6 @@ single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %
|
||||
config-build :=
|
||||
mixed-build :=
|
||||
need-config := 1
|
||||
need-compiler := 1
|
||||
may-sync-config := 1
|
||||
single-build :=
|
||||
|
||||
@ -298,18 +293,14 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
|
||||
ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
|
||||
need-compiler :=
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
|
||||
ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
|
||||
may-sync-config :=
|
||||
endif
|
||||
endif
|
||||
|
||||
need-compiler := $(may-sync-config)
|
||||
|
||||
ifneq ($(KBUILD_EXTMOD),)
|
||||
may-sync-config :=
|
||||
endif
|
||||
@ -522,8 +513,6 @@ LZ4 = lz4c
|
||||
XZ = xz
|
||||
ZSTD = zstd
|
||||
|
||||
PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh)
|
||||
|
||||
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
|
||||
-Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
|
||||
NOSTDINC_FLAGS :=
|
||||
@ -614,7 +603,6 @@ export KBUILD_RUSTFLAGS RUSTFLAGS_KERNEL RUSTFLAGS_MODULE
|
||||
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
|
||||
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_RUSTFLAGS_MODULE KBUILD_LDFLAGS_MODULE
|
||||
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL KBUILD_RUSTFLAGS_KERNEL
|
||||
export PAHOLE_FLAGS
|
||||
|
||||
# Files to ignore in find ... statements
|
||||
|
||||
@ -684,7 +672,7 @@ ifdef config-build
|
||||
# *config targets only - make sure prerequisites are updated, and descend
|
||||
# in scripts/kconfig to make the *config target
|
||||
|
||||
# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
|
||||
# Read arch-specific Makefile to set KBUILD_DEFCONFIG as needed.
|
||||
# KBUILD_DEFCONFIG may point out an alternative default configuration
|
||||
# used for 'make defconfig'
|
||||
include $(srctree)/arch/$(SRCARCH)/Makefile
|
||||
@ -698,7 +686,7 @@ config: outputmakefile scripts_basic FORCE
|
||||
|
||||
else #!config-build
|
||||
# ===========================================================================
|
||||
# Build targets only - this includes vmlinux, arch specific targets, clean
|
||||
# Build targets only - this includes vmlinux, arch-specific targets, clean
|
||||
# targets and others. In general all targets except *config targets.
|
||||
|
||||
# If building an external module we do not care about the all: rule
|
||||
@ -1011,6 +999,7 @@ KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
|
||||
# include additional Makefiles when needed
|
||||
include-y := scripts/Makefile.extrawarn
|
||||
include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
|
||||
include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf
|
||||
include-$(CONFIG_KASAN) += scripts/Makefile.kasan
|
||||
include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
|
||||
include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan
|
||||
@ -1317,6 +1306,14 @@ scripts_unifdef: scripts_basic
|
||||
quiet_cmd_install = INSTALL $(INSTALL_PATH)
|
||||
cmd_install = unset sub_make_done; $(srctree)/scripts/install.sh
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# vDSO install
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install: export INSTALL_FILES = $(vdso-install-y)
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tools
|
||||
|
||||
@ -1486,7 +1483,7 @@ MRPROPER_FILES += include/config include/generated \
|
||||
certs/signing_key.pem \
|
||||
certs/x509.genkey \
|
||||
vmlinux-gdb.py \
|
||||
kernel.spec rpmbuild \
|
||||
rpmbuild \
|
||||
rust/libmacros.so
|
||||
|
||||
# clean - Delete most, but leave enough to build external modules
|
||||
@ -1560,6 +1557,7 @@ help:
|
||||
@echo '* vmlinux - Build the bare kernel'
|
||||
@echo '* modules - Build all modules'
|
||||
@echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
|
||||
@echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
|
||||
@echo ' dir/ - Build all files in dir and below'
|
||||
@echo ' dir/file.[ois] - Build specified target only'
|
||||
@echo ' dir/file.ll - Build the LLVM assembly file'
|
||||
@ -1637,9 +1635,9 @@ help:
|
||||
@echo 'Documentation targets:'
|
||||
@$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
|
||||
@echo ''
|
||||
@echo 'Architecture specific targets ($(SRCARCH)):'
|
||||
@echo 'Architecture-specific targets ($(SRCARCH)):'
|
||||
@$(or $(archhelp),\
|
||||
echo ' No architecture specific help defined for $(SRCARCH)')
|
||||
echo ' No architecture-specific help defined for $(SRCARCH)')
|
||||
@echo ''
|
||||
@$(if $(boards), \
|
||||
$(foreach b, $(boards), \
|
||||
@ -1681,7 +1679,7 @@ help-boards: $(help-board-dirs)
|
||||
boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
|
||||
|
||||
$(help-board-dirs): help-%:
|
||||
@echo 'Architecture specific targets ($(SRCARCH) $*):'
|
||||
@echo 'Architecture-specific targets ($(SRCARCH) $*):'
|
||||
@$(if $(boards-per-dir), \
|
||||
$(foreach b, $(boards-per-dir), \
|
||||
printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
|
||||
|
@ -304,11 +304,7 @@ $(INSTALL_TARGETS): KBUILD_IMAGE = $(boot)/$(patsubst %install,%Image,$@)
|
||||
$(INSTALL_TARGETS):
|
||||
$(call cmd,install)
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install:
|
||||
ifeq ($(CONFIG_VDSO),y)
|
||||
$(Q)$(MAKE) $(build)=arch/arm/vdso $@
|
||||
endif
|
||||
vdso-install-$(CONFIG_VDSO) += arch/arm/vdso/vdso.so.dbg
|
||||
|
||||
# My testing targets (bypasses dependencies)
|
||||
bp:; $(Q)$(MAKE) $(build)=$(boot) $(boot)/bootpImage
|
||||
@ -331,7 +327,6 @@ define archhelp
|
||||
echo ' Install using (your) ~/bin/$(INSTALLKERNEL) or'
|
||||
echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
|
||||
echo ' install to $$(INSTALL_PATH) and run lilo'
|
||||
echo ' vdso_install - Install unstripped vdso.so to $$(INSTALL_MOD_PATH)/vdso'
|
||||
echo
|
||||
echo ' multi_v7_lpae_defconfig - multi_v7_defconfig with CONFIG_ARM_LPAE enabled'
|
||||
endef
|
||||
|
@ -63,28 +63,3 @@ quiet_cmd_vdsold_and_vdso_check = LD $@
|
||||
|
||||
quiet_cmd_vdsomunge = MUNGE $@
|
||||
cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@
|
||||
|
||||
#
|
||||
# Install the unstripped copy of vdso.so.dbg. If our toolchain
|
||||
# supports build-id, install .build-id links as well.
|
||||
#
|
||||
# Cribbed from arch/x86/vdso/Makefile.
|
||||
#
|
||||
quiet_cmd_vdso_install = INSTALL $<
|
||||
define cmd_vdso_install
|
||||
cp $< "$(MODLIB)/vdso/vdso.so"; \
|
||||
if readelf -n $< | grep -q 'Build ID'; then \
|
||||
buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
|
||||
first=`echo $$buildid | cut -b-2`; \
|
||||
last=`echo $$buildid | cut -b3-`; \
|
||||
mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
|
||||
ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
|
||||
fi
|
||||
endef
|
||||
|
||||
$(MODLIB)/vdso: FORCE
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
@ -169,12 +169,6 @@ install: KBUILD_IMAGE := $(boot)/Image
|
||||
install zinstall:
|
||||
$(call cmd,install)
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
|
||||
$(if $(CONFIG_COMPAT_VDSO), \
|
||||
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@)
|
||||
|
||||
archprepare:
|
||||
$(Q)$(MAKE) $(build)=arch/arm64/tools kapi
|
||||
ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
|
||||
@ -205,6 +199,9 @@ ifdef CONFIG_COMPAT_VDSO
|
||||
endif
|
||||
endif
|
||||
|
||||
vdso-install-y += arch/arm64/kernel/vdso/vdso.so.dbg
|
||||
vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso.so.dbg:vdso32.so
|
||||
|
||||
include $(srctree)/scripts/Makefile.defconf
|
||||
|
||||
PHONY += virtconfig
|
||||
|
@ -78,13 +78,3 @@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
|
||||
# Actual build commands
|
||||
quiet_cmd_vdsold_and_vdso_check = LD $@
|
||||
cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
|
||||
|
||||
# Install commands for the unstripped file
|
||||
quiet_cmd_vdso_install = INSTALL $@
|
||||
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
||||
|
||||
vdso.so: $(obj)/vdso.so.dbg
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
vdso_install: vdso.so
|
||||
|
@ -172,13 +172,3 @@ gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh
|
||||
quiet_cmd_vdsosym = VDSOSYM $@
|
||||
# The AArch64 nm should be able to read an AArch32 binary
|
||||
cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
|
||||
|
||||
# Install commands for the unstripped file
|
||||
quiet_cmd_vdso_install = INSTALL32 $@
|
||||
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so
|
||||
|
||||
vdso.so: $(obj)/vdso.so.dbg
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
vdso_install: vdso.so
|
||||
|
@ -58,13 +58,3 @@ quiet_cmd_vdsold = VDSOLD $@
|
||||
# that contains the same symbols at the same offsets.
|
||||
quiet_cmd_so2s = SO2S $@
|
||||
cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
|
||||
|
||||
# install commands for the unstripped file
|
||||
quiet_cmd_vdso_install = INSTALL $@
|
||||
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
||||
|
||||
vdso.so: $(obj)/vdso.so.dbg
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
vdso_install: vdso.so
|
||||
|
@ -136,9 +136,7 @@ vdso_prepare: prepare0
|
||||
$(Q)$(MAKE) $(build)=arch/loongarch/vdso include/generated/vdso-offsets.h
|
||||
endif
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/loongarch/vdso $@
|
||||
vdso-install-y += arch/loongarch/vdso/vdso.so.dbg
|
||||
|
||||
all: $(notdir $(KBUILD_IMAGE))
|
||||
|
||||
|
@ -83,13 +83,3 @@ $(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE
|
||||
obj-y += vdso.o
|
||||
|
||||
$(obj)/vdso.o : $(obj)/vdso.so
|
||||
|
||||
# install commands for the unstripped file
|
||||
quiet_cmd_vdso_install = INSTALL $@
|
||||
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
||||
|
||||
vdso.so: $(obj)/vdso.so.dbg
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
vdso_install: vdso.so
|
||||
|
@ -31,9 +31,6 @@ ifeq ($(CONFIG_RELOCATABLE),y)
|
||||
$(call if_changed,relocs)
|
||||
endif
|
||||
|
||||
%.ko: FORCE
|
||||
@true
|
||||
|
||||
clean:
|
||||
@true
|
||||
|
||||
|
@ -177,12 +177,8 @@ vdso_prepare: prepare0
|
||||
$(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 include/generated/vdso32-offsets.h
|
||||
endif
|
||||
|
||||
PHONY += vdso_install
|
||||
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso $@
|
||||
$(if $(CONFIG_COMPAT_VDSO), \
|
||||
$(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 $@)
|
||||
vdso-install-y += arch/parisc/kernel/vdso32/vdso32.so
|
||||
vdso-install-$(CONFIG_64BIT) += arch/parisc/kernel/vdso64/vdso64.so
|
||||
|
||||
install: KBUILD_IMAGE := vmlinux
|
||||
zinstall: KBUILD_IMAGE := vmlinuz
|
||||
|
@ -35,9 +35,6 @@ ifdef CONFIG_RELOCATABLE
|
||||
$(call if_changed,relocs_check)
|
||||
endif
|
||||
|
||||
%.ko: FORCE
|
||||
@true
|
||||
|
||||
clean:
|
||||
rm -f .tmp_symbols.txt
|
||||
|
||||
|
@ -130,12 +130,6 @@ endif
|
||||
libs-y += arch/riscv/lib/
|
||||
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
|
||||
$(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
|
||||
$(build)=arch/riscv/kernel/compat_vdso compat_$@)
|
||||
|
||||
ifeq ($(KBUILD_EXTMOD),)
|
||||
ifeq ($(CONFIG_MMU),y)
|
||||
prepare: vdso_prepare
|
||||
@ -147,6 +141,9 @@ vdso_prepare: prepare0
|
||||
endif
|
||||
endif
|
||||
|
||||
vdso-install-y += arch/riscv/kernel/vdso/vdso.so.dbg
|
||||
vdso-install-$(CONFIG_COMPAT) += arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg:../compat_vdso/compat_vdso.so
|
||||
|
||||
ifneq ($(CONFIG_XIP_KERNEL),y)
|
||||
ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
|
||||
KBUILD_IMAGE := $(boot)/loader.bin
|
||||
|
@ -36,9 +36,6 @@ ifdef CONFIG_RELOCATABLE
|
||||
$(call if_changed,relocs_strip)
|
||||
endif
|
||||
|
||||
%.ko: FORCE
|
||||
@true
|
||||
|
||||
clean:
|
||||
@true
|
||||
|
||||
|
@ -76,13 +76,3 @@ quiet_cmd_compat_vdsold = VDSOLD $@
|
||||
# actual build commands
|
||||
quiet_cmd_compat_vdsoas = VDSOAS $@
|
||||
cmd_compat_vdsoas = $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c -o $@ $<
|
||||
|
||||
# install commands for the unstripped file
|
||||
quiet_cmd_compat_vdso_install = INSTALL $@
|
||||
cmd_compat_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/compat_vdso/$@
|
||||
|
||||
compat_vdso.so: $(obj)/compat_vdso.so.dbg
|
||||
@mkdir -p $(MODLIB)/compat_vdso
|
||||
$(call cmd,compat_vdso_install)
|
||||
|
||||
compat_vdso_install: compat_vdso.so
|
||||
|
@ -73,13 +73,3 @@ quiet_cmd_vdsold = VDSOLD $@
|
||||
cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
|
||||
$(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
|
||||
rm $@.tmp
|
||||
|
||||
# install commands for the unstripped file
|
||||
quiet_cmd_vdso_install = INSTALL $@
|
||||
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
||||
|
||||
vdso.so: $(obj)/vdso.so.dbg
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
vdso_install: vdso.so
|
||||
|
@ -138,9 +138,6 @@ bzImage: vmlinux
|
||||
zfcpdump:
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
||||
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
|
||||
|
||||
archheaders:
|
||||
$(Q)$(MAKE) $(build)=$(syscalls) uapi
|
||||
|
||||
@ -160,6 +157,9 @@ vdso_prepare: prepare0
|
||||
$(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
|
||||
$(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h)
|
||||
|
||||
vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg
|
||||
vdso-install-$(CONFIG_COMPAT) += arch/s390/kernel/vdso32/vdso32.so.dbg
|
||||
|
||||
ifdef CONFIG_EXPOLINE_EXTERN
|
||||
modules_prepare: expoline_prepare
|
||||
expoline_prepare: scripts
|
||||
|
@ -61,16 +61,6 @@ quiet_cmd_vdso32as = VDSO32A $@
|
||||
quiet_cmd_vdso32cc = VDSO32C $@
|
||||
cmd_vdso32cc = $(CC) $(c_flags) -c -o $@ $<
|
||||
|
||||
# install commands for the unstripped file
|
||||
quiet_cmd_vdso_install = INSTALL $@
|
||||
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
||||
|
||||
vdso32.so: $(obj)/vdso32.so.dbg
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
vdso_install: vdso32.so
|
||||
|
||||
# Generate VDSO offsets using helper script
|
||||
gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
|
||||
quiet_cmd_vdsosym = VDSOSYM $@
|
||||
|
@ -70,16 +70,6 @@ quiet_cmd_vdso64as = VDSO64A $@
|
||||
quiet_cmd_vdso64cc = VDSO64C $@
|
||||
cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $<
|
||||
|
||||
# install commands for the unstripped file
|
||||
quiet_cmd_vdso_install = INSTALL $@
|
||||
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
||||
|
||||
vdso64.so: $(obj)/vdso64.so.dbg
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
vdso_install: vdso64.so
|
||||
|
||||
# Generate VDSO offsets using helper script
|
||||
gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
|
||||
quiet_cmd_vdsosym = VDSOSYM $@
|
||||
|
@ -76,9 +76,8 @@ install:
|
||||
archheaders:
|
||||
$(Q)$(MAKE) $(build)=arch/sparc/kernel/syscalls all
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/sparc/vdso $@
|
||||
vdso-install-$(CONFIG_SPARC64) += arch/sparc/vdso/vdso64.so.dbg
|
||||
vdso-install-$(CONFIG_COMPAT) += arch/sparc/vdso/vdso32.so.dbg
|
||||
|
||||
# This is the image used for packaging
|
||||
KBUILD_IMAGE := $(boot)/zImage
|
||||
|
@ -116,30 +116,3 @@ quiet_cmd_vdso = VDSO $@
|
||||
|
||||
VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic
|
||||
GCOV_PROFILE := n
|
||||
|
||||
#
|
||||
# Install the unstripped copies of vdso*.so. If our toolchain supports
|
||||
# build-id, install .build-id links as well.
|
||||
#
|
||||
quiet_cmd_vdso_install = INSTALL $(@:install_%=%)
|
||||
define cmd_vdso_install
|
||||
cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \
|
||||
if readelf -n $< |grep -q 'Build ID'; then \
|
||||
buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
|
||||
first=`echo $$buildid | cut -b-2`; \
|
||||
last=`echo $$buildid | cut -b3-`; \
|
||||
mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
|
||||
ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
|
||||
fi
|
||||
endef
|
||||
|
||||
vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%)
|
||||
|
||||
$(MODLIB)/vdso: FORCE
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
|
||||
$(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
PHONY += vdso_install $(vdso_img_insttargets)
|
||||
vdso_install: $(vdso_img_insttargets) FORCE
|
||||
|
@ -294,9 +294,10 @@ PHONY += install
|
||||
install:
|
||||
$(call cmd,install)
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/x86/entry/vdso $@
|
||||
vdso-install-$(CONFIG_X86_64) += arch/x86/entry/vdso/vdso64.so.dbg
|
||||
vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdsox32.so.dbg
|
||||
vdso-install-$(CONFIG_X86_32) += arch/x86/entry/vdso/vdso32.so.dbg
|
||||
vdso-install-$(CONFIG_IA32_EMULATION) += arch/x86/entry/vdso/vdso32.so.dbg
|
||||
|
||||
archprepare: checkbin
|
||||
checkbin:
|
||||
|
@ -34,9 +34,6 @@ ifeq ($(CONFIG_X86_NEED_RELOCS),y)
|
||||
$(call cmd,strip_relocs)
|
||||
endif
|
||||
|
||||
%.ko: FORCE
|
||||
@true
|
||||
|
||||
clean:
|
||||
@rm -f $(OUT_RELOCS)/vmlinux.relocs
|
||||
|
||||
|
@ -191,31 +191,4 @@ GCOV_PROFILE := n
|
||||
quiet_cmd_vdso_and_check = VDSO $@
|
||||
cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
|
||||
|
||||
#
|
||||
# Install the unstripped copies of vdso*.so. If our toolchain supports
|
||||
# build-id, install .build-id links as well.
|
||||
#
|
||||
quiet_cmd_vdso_install = INSTALL $(@:install_%=%)
|
||||
define cmd_vdso_install
|
||||
cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \
|
||||
if readelf -n $< |grep -q 'Build ID'; then \
|
||||
buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
|
||||
first=`echo $$buildid | cut -b-2`; \
|
||||
last=`echo $$buildid | cut -b3-`; \
|
||||
mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
|
||||
ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
|
||||
fi
|
||||
endef
|
||||
|
||||
vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%)
|
||||
|
||||
$(MODLIB)/vdso: FORCE
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
|
||||
$(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
PHONY += vdso_install $(vdso_img_insttargets)
|
||||
vdso_install: $(vdso_img_insttargets)
|
||||
|
||||
clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so*
|
||||
|
@ -67,15 +67,3 @@ quiet_cmd_vdso = VDSO $@
|
||||
|
||||
VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv -z noexecstack
|
||||
GCOV_PROFILE := n
|
||||
|
||||
#
|
||||
# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
|
||||
#
|
||||
quiet_cmd_vdso_install = INSTALL $@
|
||||
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
||||
$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
|
||||
@mkdir -p $(MODLIB)/vdso
|
||||
$(call cmd,vdso_install)
|
||||
|
||||
PHONY += vdso_install $(vdso-install-y)
|
||||
vdso_install: $(vdso-install-y)
|
||||
|
@ -356,7 +356,6 @@
|
||||
*(.ref.data) \
|
||||
*(.data..shared_aligned) /* percpu related */ \
|
||||
MEM_KEEP(init.data*) \
|
||||
MEM_KEEP(exit.data*) \
|
||||
*(.data.unlikely) \
|
||||
__start_once = .; \
|
||||
*(.data.once) \
|
||||
@ -521,7 +520,6 @@
|
||||
__init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
|
||||
*(.ref.rodata) \
|
||||
MEM_KEEP(init.rodata) \
|
||||
MEM_KEEP(exit.rodata) \
|
||||
} \
|
||||
\
|
||||
/* Built-in module parameters. */ \
|
||||
@ -574,7 +572,6 @@
|
||||
*(.ref.text) \
|
||||
*(.text.asan.* .text.tsan.*) \
|
||||
MEM_KEEP(init.text*) \
|
||||
MEM_KEEP(exit.text*) \
|
||||
|
||||
|
||||
/* sched.text is aling to function alignment to secure we have same
|
||||
@ -714,13 +711,10 @@
|
||||
*(.exit.data .exit.data.*) \
|
||||
*(.fini_array .fini_array.*) \
|
||||
*(.dtors .dtors.*) \
|
||||
MEM_DISCARD(exit.data*) \
|
||||
MEM_DISCARD(exit.rodata*)
|
||||
|
||||
#define EXIT_TEXT \
|
||||
*(.exit.text) \
|
||||
*(.text.exit) \
|
||||
MEM_DISCARD(exit.text)
|
||||
|
||||
#define EXIT_CALL \
|
||||
*(.exitcall.exit)
|
||||
|
@ -89,9 +89,6 @@
|
||||
__latent_entropy
|
||||
#define __meminitdata __section(".meminit.data")
|
||||
#define __meminitconst __section(".meminit.rodata")
|
||||
#define __memexit __section(".memexit.text") __exitused __cold notrace
|
||||
#define __memexitdata __section(".memexit.data")
|
||||
#define __memexitconst __section(".memexit.rodata")
|
||||
|
||||
/* For assembly routines */
|
||||
#define __HEAD .section ".head.text","ax"
|
||||
|
@ -381,6 +381,8 @@ $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE
|
||||
quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
|
||||
cmd_rustc_procmacro = \
|
||||
$(RUSTC_OR_CLIPPY) $(rust_common_flags) \
|
||||
-Clinker-flavor=gcc -Clinker=$(HOSTCC) \
|
||||
-Clink-args='$(call escsq,$(KBUILD_HOSTLDFLAGS))' \
|
||||
--emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
|
||||
--crate-type proc-macro \
|
||||
--crate-name $(patsubst lib%.so,%,$(notdir $@)) $<
|
||||
|
19
scripts/Makefile.btf
Normal file
19
scripts/Makefile.btf
Normal file
@ -0,0 +1,19 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
pahole-ver := $(CONFIG_PAHOLE_VERSION)
|
||||
pahole-flags-y :=
|
||||
|
||||
# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
|
||||
ifeq ($(call test-le, $(pahole-ver), 121),y)
|
||||
pahole-flags-$(call test-ge, $(pahole-ver), 118) += --skip_encoding_btf_vars
|
||||
endif
|
||||
|
||||
pahole-flags-$(call test-ge, $(pahole-ver), 121) += --btf_gen_floats
|
||||
|
||||
pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j
|
||||
|
||||
pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust
|
||||
|
||||
pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsistent_proto --btf_gen_optimized
|
||||
|
||||
export PAHOLE_FLAGS := $(pahole-flags-y)
|
@ -425,7 +425,7 @@ $(obj)/lib.a: $(lib-y) FORCE
|
||||
$(call if_changed,ar)
|
||||
|
||||
quiet_cmd_ld_multi_m = LD [M] $@
|
||||
cmd_ld_multi_m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) $(cmd_objtool)
|
||||
cmd_ld_multi_m = $(LD) $(ld_flags) -r -o $@ @$< $(cmd_objtool)
|
||||
|
||||
define rule_ld_multi_m
|
||||
$(call cmd_and_savecmd,ld_multi_m)
|
||||
|
@ -91,6 +91,8 @@ hostcxx_flags = -Wp,-MMD,$(depfile) \
|
||||
# current working directory, which may be not accessible in the out-of-tree
|
||||
# modules case.
|
||||
hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \
|
||||
-Clinker-flavor=gcc -Clinker=$(HOSTCC) \
|
||||
-Clink-args='$(call escsq,$(KBUILD_HOSTLDFLAGS))' \
|
||||
$(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \
|
||||
$(HOSTRUSTFLAGS_$(target-stem))
|
||||
|
||||
|
@ -28,14 +28,11 @@ quiet_cmd_cc_o_c = CC [M] $@
|
||||
%.mod.o: %.mod.c FORCE
|
||||
$(call if_changed_dep,cc_o_c)
|
||||
|
||||
ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
|
||||
|
||||
quiet_cmd_ld_ko_o = LD [M] $@
|
||||
cmd_ld_ko_o += \
|
||||
$(LD) -r $(KBUILD_LDFLAGS) \
|
||||
$(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
|
||||
-T scripts/module.lds -o $@ $(filter %.o, $^); \
|
||||
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
|
||||
-T scripts/module.lds -o $@ $(filter %.o, $^)
|
||||
|
||||
quiet_cmd_btf_ko = BTF [M] $@
|
||||
cmd_btf_ko = \
|
||||
|
@ -69,9 +69,9 @@ $(linux-tarballs): .tmp_HEAD FORCE
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
quiet_cmd_mkspec = GEN $@
|
||||
cmd_mkspec = $(srctree)/scripts/package/mkspec > $@
|
||||
cmd_mkspec = $(srctree)/scripts/package/mkspec $@
|
||||
|
||||
kernel.spec: FORCE
|
||||
rpmbuild/SPECS/kernel.spec: FORCE
|
||||
$(call cmd,mkspec)
|
||||
|
||||
PHONY += rpm-sources
|
||||
@ -88,14 +88,12 @@ srcrpm-pkg: private build-type := s
|
||||
binrpm-pkg: private build-type := b
|
||||
|
||||
rpm-pkg srcrpm-pkg: rpm-sources
|
||||
rpm-pkg srcrpm-pkg binrpm-pkg: kernel.spec
|
||||
+$(strip rpmbuild -b$(build-type) kernel.spec \
|
||||
rpm-pkg srcrpm-pkg binrpm-pkg: rpmbuild/SPECS/kernel.spec
|
||||
+$(strip rpmbuild -b$(build-type) rpmbuild/SPECS/kernel.spec \
|
||||
--define='_topdir $(abspath rpmbuild)' \
|
||||
$(if $(filter a b, $(build-type)), \
|
||||
--target $(UTS_MACHINE)-linux --build-in-place --noprep --define='_smp_mflags %{nil}' \
|
||||
$$(rpm -q rpm >/dev/null 2>&1 || echo --nodeps)) \
|
||||
$(if $(filter b, $(build-type)), \
|
||||
--without devel) \
|
||||
$(RPMOPTS))
|
||||
|
||||
# deb-pkg srcdeb-pkg bindeb-pkg
|
||||
|
@ -19,19 +19,19 @@ user-cobjs := $(addprefix $(obj)/, $(user-cobjs))
|
||||
user_ccflags = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \
|
||||
$($(target-stem)-userccflags)
|
||||
user_ldflags = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags)
|
||||
user_ldlibs = $(userldlibs) $($(target-stem)-userldlibs)
|
||||
|
||||
# Create an executable from a single .c file
|
||||
quiet_cmd_user_cc_c = CC [U] $@
|
||||
cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \
|
||||
$($(target-stem)-userldlibs)
|
||||
$(user_ldlibs)
|
||||
$(user-csingle): $(obj)/%: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,user_cc_c)
|
||||
|
||||
# Link an executable based on list of .o files
|
||||
quiet_cmd_user_ld = LD [U] $@
|
||||
cmd_user_ld = $(CC) $(user_ldflags) -o $@ \
|
||||
$(addprefix $(obj)/, $($(target-stem)-objs)) \
|
||||
$($(target-stem)-userldlibs)
|
||||
$(addprefix $(obj)/, $($(target-stem)-objs)) $(user_ldlibs)
|
||||
$(user-cmulti): FORCE
|
||||
$(call if_changed,user_ld)
|
||||
$(call multi_depend, $(user-cmulti), , -objs)
|
||||
|
45
scripts/Makefile.vdsoinst
Normal file
45
scripts/Makefile.vdsoinst
Normal file
@ -0,0 +1,45 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# ==========================================================================
|
||||
# Install unstripped copies of vDSO
|
||||
# ==========================================================================
|
||||
|
||||
PHONY := __default
|
||||
__default:
|
||||
@:
|
||||
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
|
||||
install-dir := $(MODLIB)/vdso
|
||||
|
||||
define gen_install_rules
|
||||
|
||||
src := $$(firstword $$(subst :,$(space),$(1)))
|
||||
dest := $(install-dir)/$$(or $$(word 2,$$(subst :,$(space),$(1))),$$(patsubst %.dbg,%,$$(notdir $(1))))
|
||||
|
||||
__default: $$(dest)
|
||||
$$(dest): $$(src) FORCE
|
||||
$$(call cmd,install)
|
||||
|
||||
# Some architectures create .build-id symlinks
|
||||
ifneq ($(filter arm sparc x86, $(SRCARCH)),)
|
||||
link := $(install-dir)/.build-id/$$(shell $(READELF) -n $$(src) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
|
||||
|
||||
__default: $$(link)
|
||||
$$(link): $$(dest) FORCE
|
||||
$$(call cmd,symlink)
|
||||
endif
|
||||
|
||||
endef
|
||||
|
||||
$(foreach x, $(sort $(INSTALL_FILES)), $(eval $(call gen_install_rules,$(x))))
|
||||
|
||||
quiet_cmd_install = INSTALL $@
|
||||
cmd_install = mkdir -p $(dir $@); cp $< $@
|
||||
|
||||
quiet_cmd_symlink = SYMLINK $@
|
||||
cmd_symlink = mkdir -p $(dir $@); ln -sf --relative $< $@
|
||||
|
||||
PHONY += FORCE
|
||||
FORCE:
|
||||
|
||||
.PHONY: $(PHONY)
|
@ -91,6 +91,16 @@ if arg_contain -S "$@"; then
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# For arch/powerpc/tools/gcc-check-fpatchable-function-entry.sh
|
||||
if arg_contain -m64 "$@" && arg_contain -fpatchable-function-entry=2 "$@"; then
|
||||
echo "func:"
|
||||
echo ".section __patchable_function_entries"
|
||||
echo ".localentry"
|
||||
echo " nop"
|
||||
echo " nop"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# To set GCC_PLUGINS
|
||||
|
@ -5,7 +5,7 @@ CFLAGS_REMOVE_empty.o += $(CC_FLAGS_LTO)
|
||||
hostprogs-always-y += modpost mk_elfconfig
|
||||
always-y += empty.o
|
||||
|
||||
modpost-objs := modpost.o file2alias.o sumversion.o
|
||||
modpost-objs := modpost.o file2alias.o sumversion.o symsearch.o
|
||||
|
||||
devicetable-offsets-file := devicetable-offsets.h
|
||||
|
||||
@ -16,7 +16,7 @@ targets += $(devicetable-offsets-file) devicetable-offsets.s
|
||||
|
||||
# dependencies on generated files need to be listed explicitly
|
||||
|
||||
$(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
|
||||
$(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o $(obj)/symsearch.o: $(obj)/elfconfig.h
|
||||
$(obj)/file2alias.o: $(obj)/$(devicetable-offsets-file)
|
||||
|
||||
quiet_cmd_elfconfig = MKELF $@
|
||||
|
@ -1348,13 +1348,13 @@ static int do_typec_entry(const char *filename, void *symval, char *alias)
|
||||
/* Looks like: tee:uuid */
|
||||
static int do_tee_entry(const char *filename, void *symval, char *alias)
|
||||
{
|
||||
DEF_FIELD(symval, tee_client_device_id, uuid);
|
||||
DEF_FIELD_ADDR(symval, tee_client_device_id, uuid);
|
||||
|
||||
sprintf(alias, "tee:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
uuid.b[0], uuid.b[1], uuid.b[2], uuid.b[3], uuid.b[4],
|
||||
uuid.b[5], uuid.b[6], uuid.b[7], uuid.b[8], uuid.b[9],
|
||||
uuid.b[10], uuid.b[11], uuid.b[12], uuid.b[13], uuid.b[14],
|
||||
uuid.b[15]);
|
||||
uuid->b[0], uuid->b[1], uuid->b[2], uuid->b[3], uuid->b[4],
|
||||
uuid->b[5], uuid->b[6], uuid->b[7], uuid->b[8], uuid->b[9],
|
||||
uuid->b[10], uuid->b[11], uuid->b[12], uuid->b[13], uuid->b[14],
|
||||
uuid->b[15]);
|
||||
|
||||
add_wildcard(alias);
|
||||
return 1;
|
||||
@ -1401,10 +1401,10 @@ static int do_mhi_ep_entry(const char *filename, void *symval, char *alias)
|
||||
/* Looks like: ishtp:{guid} */
|
||||
static int do_ishtp_entry(const char *filename, void *symval, char *alias)
|
||||
{
|
||||
DEF_FIELD(symval, ishtp_device_id, guid);
|
||||
DEF_FIELD_ADDR(symval, ishtp_device_id, guid);
|
||||
|
||||
strcpy(alias, ISHTP_MODULE_PREFIX "{");
|
||||
add_guid(alias, guid);
|
||||
add_guid(alias, *guid);
|
||||
strcat(alias, "}");
|
||||
|
||||
return 1;
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <errno.h>
|
||||
#include "modpost.h"
|
||||
#include "../../include/linux/license.h"
|
||||
#include "../../include/linux/module_symbol.h"
|
||||
|
||||
static bool module_enabled;
|
||||
/* Are we using CONFIG_MODVERSIONS? */
|
||||
@ -577,11 +576,14 @@ static int parse_elf(struct elf_info *info, const char *filename)
|
||||
*p = TO_NATIVE(*p);
|
||||
}
|
||||
|
||||
symsearch_init(info);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void parse_elf_finish(struct elf_info *info)
|
||||
{
|
||||
symsearch_finish(info);
|
||||
release_file(info->hdr, info->size);
|
||||
}
|
||||
|
||||
@ -792,24 +794,16 @@ static void check_section(const char *modname, struct elf_info *elf,
|
||||
#define ALL_INIT_DATA_SECTIONS \
|
||||
".init.setup", ".init.rodata", ".meminit.rodata", \
|
||||
".init.data", ".meminit.data"
|
||||
#define ALL_EXIT_DATA_SECTIONS \
|
||||
".exit.data", ".memexit.data"
|
||||
|
||||
#define ALL_INIT_TEXT_SECTIONS \
|
||||
".init.text", ".meminit.text"
|
||||
#define ALL_EXIT_TEXT_SECTIONS \
|
||||
".exit.text", ".memexit.text"
|
||||
|
||||
#define ALL_PCI_INIT_SECTIONS \
|
||||
".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \
|
||||
".pci_fixup_enable", ".pci_fixup_resume", \
|
||||
".pci_fixup_resume_early", ".pci_fixup_suspend"
|
||||
|
||||
#define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS
|
||||
#define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS
|
||||
#define ALL_XXXINIT_SECTIONS ".meminit.*"
|
||||
|
||||
#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
|
||||
#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
|
||||
#define ALL_EXIT_SECTIONS ".exit.*"
|
||||
|
||||
#define DATA_SECTIONS ".data", ".data.rel"
|
||||
#define TEXT_SECTIONS ".text", ".text.*", ".sched.text", \
|
||||
@ -819,20 +813,13 @@ static void check_section(const char *modname, struct elf_info *elf,
|
||||
".coldtext", ".softirqentry.text"
|
||||
|
||||
#define INIT_SECTIONS ".init.*"
|
||||
#define MEM_INIT_SECTIONS ".meminit.*"
|
||||
|
||||
#define EXIT_SECTIONS ".exit.*"
|
||||
#define MEM_EXIT_SECTIONS ".memexit.*"
|
||||
|
||||
#define ALL_TEXT_SECTIONS ALL_INIT_TEXT_SECTIONS, ALL_EXIT_TEXT_SECTIONS, \
|
||||
#define ALL_TEXT_SECTIONS ".init.text", ".meminit.text", ".exit.text", \
|
||||
TEXT_SECTIONS, OTHER_TEXT_SECTIONS
|
||||
|
||||
enum mismatch {
|
||||
TEXT_TO_ANY_INIT,
|
||||
DATA_TO_ANY_INIT,
|
||||
TEXTDATA_TO_ANY_EXIT,
|
||||
TEXTDATA_TO_ANY_INIT_EXIT,
|
||||
XXXINIT_TO_SOME_INIT,
|
||||
XXXEXIT_TO_SOME_EXIT,
|
||||
ANY_INIT_TO_ANY_EXIT,
|
||||
ANY_EXIT_TO_ANY_INIT,
|
||||
EXTABLE_TO_NON_TEXT,
|
||||
@ -862,20 +849,10 @@ static const struct sectioncheck sectioncheck[] = {
|
||||
/* Do not reference init/exit code/data from
|
||||
* normal code and data
|
||||
*/
|
||||
{
|
||||
.fromsec = { TEXT_SECTIONS, NULL },
|
||||
.bad_tosec = { ALL_INIT_SECTIONS, NULL },
|
||||
.mismatch = TEXT_TO_ANY_INIT,
|
||||
},
|
||||
{
|
||||
.fromsec = { DATA_SECTIONS, NULL },
|
||||
.bad_tosec = { ALL_XXXINIT_SECTIONS, INIT_SECTIONS, NULL },
|
||||
.mismatch = DATA_TO_ANY_INIT,
|
||||
},
|
||||
{
|
||||
.fromsec = { TEXT_SECTIONS, DATA_SECTIONS, NULL },
|
||||
.bad_tosec = { ALL_EXIT_SECTIONS, NULL },
|
||||
.mismatch = TEXTDATA_TO_ANY_EXIT,
|
||||
.bad_tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL },
|
||||
.mismatch = TEXTDATA_TO_ANY_INIT_EXIT,
|
||||
},
|
||||
/* Do not reference init code/data from meminit code/data */
|
||||
{
|
||||
@ -883,12 +860,6 @@ static const struct sectioncheck sectioncheck[] = {
|
||||
.bad_tosec = { INIT_SECTIONS, NULL },
|
||||
.mismatch = XXXINIT_TO_SOME_INIT,
|
||||
},
|
||||
/* Do not reference exit code/data from memexit code/data */
|
||||
{
|
||||
.fromsec = { ALL_XXXEXIT_SECTIONS, NULL },
|
||||
.bad_tosec = { EXIT_SECTIONS, NULL },
|
||||
.mismatch = XXXEXIT_TO_SOME_EXIT,
|
||||
},
|
||||
/* Do not use exit code/data from init code */
|
||||
{
|
||||
.fromsec = { ALL_INIT_SECTIONS, NULL },
|
||||
@ -1006,19 +977,7 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
|
||||
/* symbols in data sections that may refer to any init/exit sections */
|
||||
if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
|
||||
match(tosec, PATTERNS(ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
|
||||
match(fromsym, PATTERNS("*_template", // scsi uses *_template a lot
|
||||
"*_timer", // arm uses ops structures named _timer a lot
|
||||
"*_sht", // scsi also used *_sht to some extent
|
||||
"*_ops",
|
||||
"*_probe",
|
||||
"*_probe_one",
|
||||
"*_console")))
|
||||
return 0;
|
||||
|
||||
/* symbols in data sections that may refer to meminit sections */
|
||||
if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
|
||||
match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_XXXEXIT_SECTIONS)) &&
|
||||
match(fromsym, PATTERNS("*driver")))
|
||||
match(fromsym, PATTERNS("*_ops", "*_probe", "*_console")))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
@ -1028,7 +987,7 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
|
||||
*/
|
||||
if (!extra_warn &&
|
||||
match(fromsec, PATTERNS(DATA_SECTIONS)) &&
|
||||
match(tosec, PATTERNS(EXIT_SECTIONS)) &&
|
||||
match(tosec, PATTERNS(ALL_EXIT_SECTIONS)) &&
|
||||
match(fromsym, PATTERNS("*driver")))
|
||||
return 0;
|
||||
|
||||
@ -1050,71 +1009,10 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there's no name there, ignore it; likewise, ignore it if it's
|
||||
* one of the magic symbols emitted used by current tools.
|
||||
*
|
||||
* Otherwise if find_symbols_between() returns those symbols, they'll
|
||||
* fail the whitelist tests and cause lots of false alarms ... fixable
|
||||
* only by merging __exit and __init sections into __text, bloating
|
||||
* the kernel (which is especially evil on embedded platforms).
|
||||
*/
|
||||
static inline bool is_valid_name(struct elf_info *elf, Elf_Sym *sym)
|
||||
{
|
||||
const char *name = elf->strtab + sym->st_name;
|
||||
|
||||
if (!name || !strlen(name))
|
||||
return false;
|
||||
return !is_mapping_symbol(name);
|
||||
}
|
||||
|
||||
/* Look up the nearest symbol based on the section and the address */
|
||||
static Elf_Sym *find_nearest_sym(struct elf_info *elf, Elf_Addr addr,
|
||||
unsigned int secndx, bool allow_negative,
|
||||
Elf_Addr min_distance)
|
||||
{
|
||||
Elf_Sym *sym;
|
||||
Elf_Sym *near = NULL;
|
||||
Elf_Addr sym_addr, distance;
|
||||
bool is_arm = (elf->hdr->e_machine == EM_ARM);
|
||||
|
||||
for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
|
||||
if (get_secindex(elf, sym) != secndx)
|
||||
continue;
|
||||
if (!is_valid_name(elf, sym))
|
||||
continue;
|
||||
|
||||
sym_addr = sym->st_value;
|
||||
|
||||
/*
|
||||
* For ARM Thumb instruction, the bit 0 of st_value is set
|
||||
* if the symbol is STT_FUNC type. Mask it to get the address.
|
||||
*/
|
||||
if (is_arm && ELF_ST_TYPE(sym->st_info) == STT_FUNC)
|
||||
sym_addr &= ~1;
|
||||
|
||||
if (addr >= sym_addr)
|
||||
distance = addr - sym_addr;
|
||||
else if (allow_negative)
|
||||
distance = sym_addr - addr;
|
||||
else
|
||||
continue;
|
||||
|
||||
if (distance <= min_distance) {
|
||||
min_distance = distance;
|
||||
near = sym;
|
||||
}
|
||||
|
||||
if (min_distance == 0)
|
||||
break;
|
||||
}
|
||||
return near;
|
||||
}
|
||||
|
||||
static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr,
|
||||
unsigned int secndx)
|
||||
{
|
||||
return find_nearest_sym(elf, addr, secndx, false, ~0);
|
||||
return symsearch_find_nearest(elf, addr, secndx, false, ~0);
|
||||
}
|
||||
|
||||
static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym)
|
||||
@ -1127,7 +1025,8 @@ static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym)
|
||||
* Strive to find a better symbol name, but the resulting name may not
|
||||
* match the symbol referenced in the original code.
|
||||
*/
|
||||
return find_nearest_sym(elf, addr, get_secindex(elf, sym), true, 20);
|
||||
return symsearch_find_nearest(elf, addr, get_secindex(elf, sym),
|
||||
true, 20);
|
||||
}
|
||||
|
||||
static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
|
||||
@ -1248,10 +1147,10 @@ static void check_export_symbol(struct module *mod, struct elf_info *elf,
|
||||
ELF_ST_TYPE(sym->st_info) == STT_LOPROC)
|
||||
s->is_func = true;
|
||||
|
||||
if (match(secname, PATTERNS(INIT_SECTIONS)))
|
||||
if (match(secname, PATTERNS(ALL_INIT_SECTIONS)))
|
||||
warn("%s: %s: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.\n",
|
||||
mod->name, name);
|
||||
else if (match(secname, PATTERNS(EXIT_SECTIONS)))
|
||||
else if (match(secname, PATTERNS(ALL_EXIT_SECTIONS)))
|
||||
warn("%s: %s: EXPORT_SYMBOL used for exit symbol. Remove __exit or EXPORT_SYMBOL.\n",
|
||||
mod->name, name);
|
||||
}
|
||||
@ -1468,32 +1367,20 @@ static void get_rel_type_and_sym(struct elf_info *elf, uint64_t r_info,
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_64bit) {
|
||||
Elf64_Xword r_info64 = r_info;
|
||||
|
||||
r_info = TO_NATIVE(r_info64);
|
||||
} else {
|
||||
Elf32_Word r_info32 = r_info;
|
||||
|
||||
r_info = TO_NATIVE(r_info32);
|
||||
}
|
||||
if (is_64bit)
|
||||
r_info = TO_NATIVE((Elf64_Xword)r_info);
|
||||
else
|
||||
r_info = TO_NATIVE((Elf32_Word)r_info);
|
||||
|
||||
*r_type = ELF_R_TYPE(r_info);
|
||||
*r_sym = ELF_R_SYM(r_info);
|
||||
}
|
||||
|
||||
static void section_rela(struct module *mod, struct elf_info *elf,
|
||||
Elf_Shdr *sechdr)
|
||||
unsigned int fsecndx, const char *fromsec,
|
||||
const Elf_Rela *start, const Elf_Rela *stop)
|
||||
{
|
||||
Elf_Rela *rela;
|
||||
unsigned int fsecndx = sechdr->sh_info;
|
||||
const char *fromsec = sec_name(elf, fsecndx);
|
||||
Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset;
|
||||
Elf_Rela *stop = (void *)start + sechdr->sh_size;
|
||||
|
||||
/* if from section (name) is know good then skip it */
|
||||
if (match(fromsec, section_white_list))
|
||||
return;
|
||||
const Elf_Rela *rela;
|
||||
|
||||
for (rela = start; rela < stop; rela++) {
|
||||
Elf_Addr taddr, r_offset;
|
||||
@ -1523,17 +1410,10 @@ static void section_rela(struct module *mod, struct elf_info *elf,
|
||||
}
|
||||
|
||||
static void section_rel(struct module *mod, struct elf_info *elf,
|
||||
Elf_Shdr *sechdr)
|
||||
unsigned int fsecndx, const char *fromsec,
|
||||
const Elf_Rel *start, const Elf_Rel *stop)
|
||||
{
|
||||
Elf_Rel *rel;
|
||||
unsigned int fsecndx = sechdr->sh_info;
|
||||
const char *fromsec = sec_name(elf, fsecndx);
|
||||
Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset;
|
||||
Elf_Rel *stop = (void *)start + sechdr->sh_size;
|
||||
|
||||
/* if from section (name) is know good then skip it */
|
||||
if (match(fromsec, section_white_list))
|
||||
return;
|
||||
const Elf_Rel *rel;
|
||||
|
||||
for (rel = start; rel < stop; rel++) {
|
||||
Elf_Sym *tsym;
|
||||
@ -1581,16 +1461,33 @@ static void section_rel(struct module *mod, struct elf_info *elf,
|
||||
static void check_sec_ref(struct module *mod, struct elf_info *elf)
|
||||
{
|
||||
int i;
|
||||
Elf_Shdr *sechdrs = elf->sechdrs;
|
||||
|
||||
/* Walk through all sections */
|
||||
for (i = 0; i < elf->num_sections; i++) {
|
||||
check_section(mod->name, elf, &elf->sechdrs[i]);
|
||||
Elf_Shdr *sechdr = &elf->sechdrs[i];
|
||||
|
||||
check_section(mod->name, elf, sechdr);
|
||||
/* We want to process only relocation sections and not .init */
|
||||
if (sechdrs[i].sh_type == SHT_RELA)
|
||||
section_rela(mod, elf, &elf->sechdrs[i]);
|
||||
else if (sechdrs[i].sh_type == SHT_REL)
|
||||
section_rel(mod, elf, &elf->sechdrs[i]);
|
||||
if (sechdr->sh_type == SHT_REL || sechdr->sh_type == SHT_RELA) {
|
||||
/* section to which the relocation applies */
|
||||
unsigned int secndx = sechdr->sh_info;
|
||||
const char *secname = sec_name(elf, secndx);
|
||||
const void *start, *stop;
|
||||
|
||||
/* If the section is known good, skip it */
|
||||
if (match(secname, section_white_list))
|
||||
continue;
|
||||
|
||||
start = sym_get_data_by_offset(elf, i, 0);
|
||||
stop = start + sechdr->sh_size;
|
||||
|
||||
if (sechdr->sh_type == SHT_RELA)
|
||||
section_rela(mod, elf, secndx, secname,
|
||||
start, stop);
|
||||
else
|
||||
section_rel(mod, elf, secndx, secname,
|
||||
start, stop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <byteswap.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -10,6 +11,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <elf.h>
|
||||
#include "../../include/linux/module_symbol.h"
|
||||
|
||||
#include "list.h"
|
||||
#include "elfconfig.h"
|
||||
@ -50,21 +52,19 @@
|
||||
#define ELF_R_TYPE ELF64_R_TYPE
|
||||
#endif
|
||||
|
||||
#define bswap(x) \
|
||||
({ \
|
||||
_Static_assert(sizeof(x) == 1 || sizeof(x) == 2 || \
|
||||
sizeof(x) == 4 || sizeof(x) == 8, "bug"); \
|
||||
(typeof(x))(sizeof(x) == 2 ? bswap_16(x) : \
|
||||
sizeof(x) == 4 ? bswap_32(x) : \
|
||||
sizeof(x) == 8 ? bswap_64(x) : \
|
||||
x); \
|
||||
})
|
||||
|
||||
#if KERNEL_ELFDATA != HOST_ELFDATA
|
||||
|
||||
static inline void __endian(const void *src, void *dest, unsigned int size)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < size; i++)
|
||||
((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1];
|
||||
}
|
||||
|
||||
#define TO_NATIVE(x) \
|
||||
({ \
|
||||
typeof(x) __x; \
|
||||
__endian(&(x), &(__x), sizeof(__x)); \
|
||||
__x; \
|
||||
})
|
||||
#define TO_NATIVE(x) (bswap(x))
|
||||
|
||||
#else /* endianness matches */
|
||||
|
||||
@ -128,6 +128,8 @@ struct elf_info {
|
||||
* take shndx from symtab_shndx_start[N] instead */
|
||||
Elf32_Word *symtab_shndx_start;
|
||||
Elf32_Word *symtab_shndx_stop;
|
||||
|
||||
struct symsearch *symsearch;
|
||||
};
|
||||
|
||||
/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
|
||||
@ -154,6 +156,28 @@ static inline unsigned int get_secindex(const struct elf_info *info,
|
||||
return index;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there's no name there, ignore it; likewise, ignore it if it's
|
||||
* one of the magic symbols emitted used by current tools.
|
||||
*
|
||||
* Internal symbols created by tools should be ignored by modpost.
|
||||
*/
|
||||
static inline bool is_valid_name(struct elf_info *elf, Elf_Sym *sym)
|
||||
{
|
||||
const char *name = elf->strtab + sym->st_name;
|
||||
|
||||
if (!name || !strlen(name))
|
||||
return false;
|
||||
return !is_mapping_symbol(name);
|
||||
}
|
||||
|
||||
/* symsearch.c */
|
||||
void symsearch_init(struct elf_info *elf);
|
||||
void symsearch_finish(struct elf_info *elf);
|
||||
Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr,
|
||||
unsigned int secndx, bool allow_negative,
|
||||
Elf_Addr min_distance);
|
||||
|
||||
/* file2alias.c */
|
||||
void handle_moddevtable(struct module *mod, struct elf_info *info,
|
||||
Elf_Sym *sym, const char *symname);
|
||||
|
199
scripts/mod/symsearch.c
Normal file
199
scripts/mod/symsearch.c
Normal file
@ -0,0 +1,199 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
/*
|
||||
* Helper functions for finding the symbol in an ELF which is "nearest"
|
||||
* to a given address.
|
||||
*/
|
||||
|
||||
#include "modpost.h"
|
||||
|
||||
struct syminfo {
|
||||
unsigned int symbol_index;
|
||||
unsigned int section_index;
|
||||
Elf_Addr addr;
|
||||
};
|
||||
|
||||
/*
|
||||
* Container used to hold an entire binary search table.
|
||||
* Entries in table are ascending, sorted first by section_index,
|
||||
* then by addr, and last by symbol_index. The sorting by
|
||||
* symbol_index is used to ensure predictable behavior when
|
||||
* multiple symbols are present with the same address; all
|
||||
* symbols past the first are effectively ignored, by eliding
|
||||
* them in symsearch_fixup().
|
||||
*/
|
||||
struct symsearch {
|
||||
unsigned int table_size;
|
||||
struct syminfo table[];
|
||||
};
|
||||
|
||||
static int syminfo_compare(const void *s1, const void *s2)
|
||||
{
|
||||
const struct syminfo *sym1 = s1;
|
||||
const struct syminfo *sym2 = s2;
|
||||
|
||||
if (sym1->section_index > sym2->section_index)
|
||||
return 1;
|
||||
if (sym1->section_index < sym2->section_index)
|
||||
return -1;
|
||||
if (sym1->addr > sym2->addr)
|
||||
return 1;
|
||||
if (sym1->addr < sym2->addr)
|
||||
return -1;
|
||||
if (sym1->symbol_index > sym2->symbol_index)
|
||||
return 1;
|
||||
if (sym1->symbol_index < sym2->symbol_index)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int symbol_count(struct elf_info *elf)
|
||||
{
|
||||
unsigned int result = 0;
|
||||
|
||||
for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
|
||||
if (is_valid_name(elf, sym))
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Populate the search array that we just allocated.
|
||||
* Be slightly paranoid here. The ELF file is mmap'd and could
|
||||
* conceivably change between symbol_count() and symsearch_populate().
|
||||
* If we notice any difference, bail out rather than potentially
|
||||
* propagating errors or crashing.
|
||||
*/
|
||||
static void symsearch_populate(struct elf_info *elf,
|
||||
struct syminfo *table,
|
||||
unsigned int table_size)
|
||||
{
|
||||
bool is_arm = (elf->hdr->e_machine == EM_ARM);
|
||||
|
||||
for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
|
||||
if (is_valid_name(elf, sym)) {
|
||||
if (table_size-- == 0)
|
||||
fatal("%s: size mismatch\n", __func__);
|
||||
table->symbol_index = sym - elf->symtab_start;
|
||||
table->section_index = get_secindex(elf, sym);
|
||||
table->addr = sym->st_value;
|
||||
|
||||
/*
|
||||
* For ARM Thumb instruction, the bit 0 of st_value is
|
||||
* set if the symbol is STT_FUNC type. Mask it to get
|
||||
* the address.
|
||||
*/
|
||||
if (is_arm && ELF_ST_TYPE(sym->st_info) == STT_FUNC)
|
||||
table->addr &= ~1;
|
||||
|
||||
table++;
|
||||
}
|
||||
}
|
||||
|
||||
if (table_size != 0)
|
||||
fatal("%s: size mismatch\n", __func__);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do any fixups on the table after sorting.
|
||||
* For now, this just finds adjacent entries which have
|
||||
* the same section_index and addr, and it propagates
|
||||
* the first symbol_index over the subsequent entries,
|
||||
* so that only one symbol_index is seen for any given
|
||||
* section_index and addr. This ensures that whether
|
||||
* we're looking at an address from "above" or "below"
|
||||
* that we see the same symbol_index.
|
||||
* This does leave some duplicate entries in the table;
|
||||
* in practice, these are a small fraction of the
|
||||
* total number of entries, and they are harmless to
|
||||
* the binary search algorithm other than a few occasional
|
||||
* unnecessary comparisons.
|
||||
*/
|
||||
static void symsearch_fixup(struct syminfo *table, unsigned int table_size)
|
||||
{
|
||||
/* Don't look at index 0, it will never change. */
|
||||
for (unsigned int i = 1; i < table_size; i++) {
|
||||
if (table[i].addr == table[i - 1].addr &&
|
||||
table[i].section_index == table[i - 1].section_index) {
|
||||
table[i].symbol_index = table[i - 1].symbol_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void symsearch_init(struct elf_info *elf)
|
||||
{
|
||||
unsigned int table_size = symbol_count(elf);
|
||||
|
||||
elf->symsearch = NOFAIL(malloc(sizeof(struct symsearch) +
|
||||
sizeof(struct syminfo) * table_size));
|
||||
elf->symsearch->table_size = table_size;
|
||||
|
||||
symsearch_populate(elf, elf->symsearch->table, table_size);
|
||||
qsort(elf->symsearch->table, table_size,
|
||||
sizeof(struct syminfo), syminfo_compare);
|
||||
|
||||
symsearch_fixup(elf->symsearch->table, table_size);
|
||||
}
|
||||
|
||||
void symsearch_finish(struct elf_info *elf)
|
||||
{
|
||||
free(elf->symsearch);
|
||||
elf->symsearch = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the syminfo which is in secndx and "nearest" to addr.
|
||||
* allow_negative: allow returning a symbol whose address is > addr.
|
||||
* min_distance: ignore symbols which are further away than this.
|
||||
*
|
||||
* Returns a pointer into the symbol table for success.
|
||||
* Returns NULL if no legal symbol is found within the requested range.
|
||||
*/
|
||||
Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr,
|
||||
unsigned int secndx, bool allow_negative,
|
||||
Elf_Addr min_distance)
|
||||
{
|
||||
unsigned int hi = elf->symsearch->table_size;
|
||||
unsigned int lo = 0;
|
||||
struct syminfo *table = elf->symsearch->table;
|
||||
struct syminfo target;
|
||||
|
||||
target.addr = addr;
|
||||
target.section_index = secndx;
|
||||
target.symbol_index = ~0; /* compares greater than any actual index */
|
||||
while (hi > lo) {
|
||||
unsigned int mid = lo + (hi - lo) / 2; /* Avoids overflow */
|
||||
|
||||
if (syminfo_compare(&table[mid], &target) > 0)
|
||||
hi = mid;
|
||||
else
|
||||
lo = mid + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* table[hi], if it exists, is the first entry in the array which
|
||||
* lies beyond target. table[hi - 1], if it exists, is the last
|
||||
* entry in the array which comes before target, including the
|
||||
* case where it perfectly matches the section and the address.
|
||||
*
|
||||
* Note -- if the address we're looking up falls perfectly
|
||||
* in the middle of two symbols, this is written to always
|
||||
* prefer the symbol with the lower address.
|
||||
*/
|
||||
Elf_Sym *result = NULL;
|
||||
|
||||
if (allow_negative &&
|
||||
hi < elf->symsearch->table_size &&
|
||||
table[hi].section_index == secndx &&
|
||||
table[hi].addr - addr <= min_distance) {
|
||||
min_distance = table[hi].addr - addr;
|
||||
result = &elf->symtab_start[table[hi].symbol_index];
|
||||
}
|
||||
if (hi > 0 &&
|
||||
table[hi - 1].section_index == secndx &&
|
||||
addr - table[hi - 1].addr <= min_distance) {
|
||||
result = &elf->symtab_start[table[hi - 1].symbol_index];
|
||||
}
|
||||
return result;
|
||||
}
|
@ -9,6 +9,12 @@
|
||||
# Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
|
||||
#
|
||||
|
||||
output=$1
|
||||
|
||||
mkdir -p "$(dirname "${output}")"
|
||||
|
||||
exec >"${output}"
|
||||
|
||||
if grep -q CONFIG_MODULES=y include/config/auto.conf; then
|
||||
echo '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}'
|
||||
else
|
||||
|
@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
extra_paholeopt=
|
||||
|
||||
if ! [ -x "$(command -v ${PAHOLE})" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE})
|
||||
|
||||
if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
|
||||
# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
|
||||
extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
|
||||
fi
|
||||
if [ "${pahole_ver}" -ge "121" ]; then
|
||||
extra_paholeopt="${extra_paholeopt} --btf_gen_floats"
|
||||
fi
|
||||
if [ "${pahole_ver}" -ge "122" ]; then
|
||||
extra_paholeopt="${extra_paholeopt} -j"
|
||||
fi
|
||||
if [ "${pahole_ver}" -ge "124" ]; then
|
||||
# see PAHOLE_HAS_LANG_EXCLUDE
|
||||
extra_paholeopt="${extra_paholeopt} --lang_exclude=rust"
|
||||
fi
|
||||
if [ "${pahole_ver}" -ge "125" ]; then
|
||||
extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_inconsistent_proto --btf_gen_optimized"
|
||||
fi
|
||||
|
||||
echo ${extra_paholeopt}
|
@ -38,4 +38,4 @@ rm -rf include/ksym
|
||||
|
||||
find . -name '*.usyms' | xargs rm -f
|
||||
|
||||
rm -f binkernel.spec
|
||||
rm -f *.spec
|
||||
|
Loading…
Reference in New Issue
Block a user