18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci# Objects to go into the VDSO. 38c2ecf20Sopenharmony_ciOBJECT_FILES_NON_STANDARD := y 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciKASAN_SANITIZE := n 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before 88c2ecf20Sopenharmony_ci# the inclusion of generic Makefile. 98c2ecf20Sopenharmony_ciARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOT 108c2ecf20Sopenharmony_ciinclude $(srctree)/lib/vdso/Makefile 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciobj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci# Common compiler flags between ABIs. 158c2ecf20Sopenharmony_ciccflags-vdso := \ 168c2ecf20Sopenharmony_ci $(filter -I%,$(KBUILD_CFLAGS)) \ 178c2ecf20Sopenharmony_ci $(filter -E%,$(KBUILD_CFLAGS)) \ 188c2ecf20Sopenharmony_ci $(filter -march=%,$(KBUILD_CFLAGS)) \ 198c2ecf20Sopenharmony_ci $(filter -m%-float,$(KBUILD_CFLAGS)) \ 208c2ecf20Sopenharmony_ci -D__VDSO__ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciifeq ($(cc-name),clang) 238c2ecf20Sopenharmony_ciccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS)) 248c2ecf20Sopenharmony_ciendif 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cicflags-vdso := $(ccflags-vdso) \ 278c2ecf20Sopenharmony_ci $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 288c2ecf20Sopenharmony_ci -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ 298c2ecf20Sopenharmony_ci -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ 308c2ecf20Sopenharmony_ci $(call cc-option, -fno-asynchronous-unwind-tables) \ 318c2ecf20Sopenharmony_ci $(call cc-option, -fno-stack-protector) 328c2ecf20Sopenharmony_ciaflags-vdso := $(ccflags-vdso) \ 338c2ecf20Sopenharmony_ci -D__ASSEMBLY__ -Wa,-gdwarf-2 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciifneq ($(c-gettimeofday-y),) 368c2ecf20Sopenharmony_ci CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) 378c2ecf20Sopenharmony_ciendif 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci# VDSO linker flags. 408c2ecf20Sopenharmony_cildflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ 418c2ecf20Sopenharmony_ci $(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \ 428c2ecf20Sopenharmony_ci --hash-style=sysv --build-id -T 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciGCOV_PROFILE := n 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci# 478c2ecf20Sopenharmony_ci# Shared build commands. 488c2ecf20Sopenharmony_ci# 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciquiet_cmd_vdsold_and_vdso_check = LD $@ 518c2ecf20Sopenharmony_ci cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciquiet_cmd_vdsoas_o_S = AS $@ 548c2ecf20Sopenharmony_ci cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $< 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci# Generate VDSO offsets using helper script 578c2ecf20Sopenharmony_cigen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 588c2ecf20Sopenharmony_ciquiet_cmd_vdsosym = VDSOSYM $@ 598c2ecf20Sopenharmony_ci cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciinclude/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE 628c2ecf20Sopenharmony_ci $(call if_changed,vdsosym) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci# 658c2ecf20Sopenharmony_ci# Build native VDSO. 668c2ecf20Sopenharmony_ci# 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cinative-abi := $(filter -mabi=%,$(KBUILD_CFLAGS)) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_citargets += $(obj-vdso-y) 718c2ecf20Sopenharmony_citargets += vdso.lds vdso.so.dbg vdso.so 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciobj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi) 768c2ecf20Sopenharmony_ci$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi) 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE 818c2ecf20Sopenharmony_ci $(call if_changed,vdsold_and_vdso_check) 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci$(obj)/vdso.so: OBJCOPYFLAGS := -S 848c2ecf20Sopenharmony_ci$(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE 858c2ecf20Sopenharmony_ci $(call if_changed,objcopy) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ciobj-y += vdso.o 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci$(obj)/vdso.o : $(obj)/vdso.so 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci# install commands for the unstripped file 928c2ecf20Sopenharmony_ciquiet_cmd_vdso_install = INSTALL $@ 938c2ecf20Sopenharmony_ci cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_civdso.so: $(obj)/vdso.so.dbg 968c2ecf20Sopenharmony_ci @mkdir -p $(MODLIB)/vdso 978c2ecf20Sopenharmony_ci $(call cmd,vdso_install) 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_civdso_install: vdso.so 100