1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 29031fefdSWill Deacon# 39031fefdSWill Deacon# Building a vDSO image for AArch64. 49031fefdSWill Deacon# 59031fefdSWill Deacon# Author: Will Deacon <will.deacon@arm.com> 69031fefdSWill Deacon# Heavily based on the vDSO Makefiles for other archs. 79031fefdSWill Deacon# 89031fefdSWill Deacon 9*aff69273SFangrui Song# Include the generic Makefile to check the built vdso. 1028b1a824SVincenzo Frascinoinclude $(srctree)/lib/vdso/Makefile 1128b1a824SVincenzo Frascino 1228b1a824SVincenzo Frascinoobj-vdso := vgettimeofday.o note.o sigreturn.o 139031fefdSWill Deacon 149031fefdSWill Deacon# Build rules 159031fefdSWill Deacontargets := $(obj-vdso) vdso.so vdso.so.dbg 169031fefdSWill Deaconobj-vdso := $(addprefix $(obj)/, $(obj-vdso)) 179031fefdSWill Deacon 185e02a188SMark Brownbtildflags-$(CONFIG_ARM64_BTI_KERNEL) += -z force-bti 195e02a188SMark Brown 2086b87837SVincenzo Frascino# -Bsymbolic has been added for consistency with arm, the compat vDSO and 2186b87837SVincenzo Frascino# potential future proofing if we end up with internal calls to the exported 2286b87837SVincenzo Frascino# routines, as x86 does (see 6f121e548f83 ("x86, vdso: Reimplement vdso.so 2386b87837SVincenzo Frascino# preparation in build-time C")). 2434688c76SMasahiro Yamadaldflags-y := -shared -soname=linux-vdso.so.1 --hash-style=sysv \ 25e0ab20b2SJoey Gouly -Bsymbolic --build-id=sha1 -n $(btildflags-y) 26e0ab20b2SJoey Gouly 27e0ab20b2SJoey Goulyifdef CONFIG_LD_ORPHAN_WARN 28e1789d7cSXin Li ldflags-y += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) 29e0ab20b2SJoey Goulyendif 30e0ab20b2SJoey Gouly 31e0ab20b2SJoey Goulyldflags-y += -T 329031fefdSWill Deacon 3398cd3c3fSPeter Collingbourneccflags-y := -fno-common -fno-builtin -fno-stack-protector -ffixed-x18 34e35123d8SWill Deaconccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO 3528b1a824SVincenzo Frascino 3658cd4a08SVincenzo Frascino# -Wmissing-prototypes and -Wmissing-declarations are removed from 3758cd4a08SVincenzo Frascino# the CFLAGS of vgettimeofday.c to make possible to build the 3858cd4a08SVincenzo Frascino# kernel with CONFIG_WERROR enabled. 39613f4b3eSKees CookCFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \ 40613f4b3eSKees Cook $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) \ 41f143ff39SSami Tolvanen $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \ 42f143ff39SSami Tolvanen -Wmissing-prototypes -Wmissing-declarations 4328b1a824SVincenzo FrascinoKASAN_SANITIZE := n 44dd03762aSKefeng WangKCSAN_SANITIZE := n 4528b1a824SVincenzo FrascinoUBSAN_SANITIZE := n 4628b1a824SVincenzo FrascinoOBJECT_FILES_NON_STANDARD := y 4728b1a824SVincenzo FrascinoKCOV_INSTRUMENT := n 4828b1a824SVincenzo Frascino 491578e5d0SVincenzo FrascinoCFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny -fasynchronous-unwind-tables 50a88754b2SVincenzo Frascino 51a88754b2SVincenzo Frascinoifneq ($(c-gettimeofday-y),) 52a88754b2SVincenzo Frascino CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) 5328b1a824SVincenzo Frascinoendif 5428b1a824SVincenzo Frascino 5554309784SArnd Bergmann# Disable gcov profiling for VDSO code 5654309784SArnd BergmannGCOV_PROFILE := n 5754309784SArnd Bergmann 58887af6d7SMasahiro Yamadatargets += vdso.lds 599031fefdSWill DeaconCPPFLAGS_vdso.lds += -P -C -U$(ARCH) 609031fefdSWill Deacon 619031fefdSWill Deacon# Link rule for the .so file, .lds has to be first 62697e96edSMasahiro Yamada$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE 632e2f3c9bSNaohiro Aota $(call if_changed,vdsold_and_vdso_check) 649031fefdSWill Deacon 659031fefdSWill Deacon# Strip rule for the .so file 669031fefdSWill Deacon$(obj)/%.so: OBJCOPYFLAGS := -S 679031fefdSWill Deacon$(obj)/%.so: $(obj)/%.so.dbg FORCE 689031fefdSWill Deacon $(call if_changed,objcopy) 699031fefdSWill Deacon 709031fefdSWill Deacon# Generate VDSO offsets using helper script 719031fefdSWill Deacongen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 729031fefdSWill Deaconquiet_cmd_vdsosym = VDSOSYM $@ 73697e96edSMasahiro Yamada cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ 749031fefdSWill Deacon 75a66649daSKevin Brodskyinclude/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE 769031fefdSWill Deacon $(call if_changed,vdsosym) 779031fefdSWill Deacon 789031fefdSWill Deacon# Actual build commands 792e2f3c9bSNaohiro Aotaquiet_cmd_vdsold_and_vdso_check = LD $@ 802e2f3c9bSNaohiro Aota cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check) 81