1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only 2e2c0cdfbSPalmer Dabbelt# Copied from arch/tile/kernel/vdso/Makefile 3e2c0cdfbSPalmer Dabbelt 4aff69273SFangrui Song# Include the generic Makefile to check the built vdso. 5ad5d1122SVincent Cheninclude $(srctree)/lib/vdso/Makefile 6e2c0cdfbSPalmer Dabbelt# Symbols present in the vdso 7e2c0cdfbSPalmer Dabbeltvdso-syms = rt_sigreturn 8d4c08b97SArnd Bergmannifdef CONFIG_64BIT 9ad5d1122SVincent Chenvdso-syms += vgettimeofday 10d4c08b97SArnd Bergmannendif 1128dfbe6eSAndrew Watermanvdso-syms += getcpu 12921ebd8fSAndrew Watermanvdso-syms += flush_icache 13aa5af0aaSEvan Greenvdso-syms += hwprobe 14aa5af0aaSEvan Greenvdso-syms += sys_hwprobe 15e2c0cdfbSPalmer Dabbelt 16e2c0cdfbSPalmer Dabbelt# Files to link into the vdso 170a9f2a61SAndreas Schwabobj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o 18e2c0cdfbSPalmer Dabbelt 1940284a07STobias Klauserccflags-y := -fno-stack-protector 2074f6bb55SJisheng Zhangccflags-y += -DDISABLE_BRANCH_PROFILING 21*c19a0c17SAlexandre Ghiticcflags-y += -fno-builtin 2240284a07STobias Klauser 23ad5d1122SVincent Chenifneq ($(c-gettimeofday-y),) 24a0fc3b32SVincent Chen CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y) 25ad5d1122SVincent Chenendif 26ad5d1122SVincent Chen 27aa5af0aaSEvan GreenCFLAGS_hwprobe.o += -fPIC 28aa5af0aaSEvan Green 29e2c0cdfbSPalmer Dabbelt# Build rules 30fde9c59aSSaleem Abdulrasooltargets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds 31e2c0cdfbSPalmer Dabbeltobj-vdso := $(addprefix $(obj)/, $(obj-vdso)) 32e2c0cdfbSPalmer Dabbelt 33fde9c59aSSaleem Abdulrasoolobj-y += vdso.o 34e2c0cdfbSPalmer DabbeltCPPFLAGS_vdso.lds += -P -C -U$(ARCH) 35fcae44fdSNathan Chancellorifneq ($(filter vgettimeofday, $(vdso-syms)),) 36fcae44fdSNathan ChancellorCPPFLAGS_vdso.lds += -DHAS_VGETTIMEOFDAY 37fcae44fdSNathan Chancellorendif 38e2c0cdfbSPalmer Dabbelt 39e05d57dcSGuo Ren# Disable -pg to prevent insert call site 4050f4dd65SJisheng ZhangCFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) 41e05d57dcSGuo Ren 42f3d60f2aSTobias Klauser# Disable profiling and instrumentation for VDSO code 43e2c0cdfbSPalmer DabbeltGCOV_PROFILE := n 4420d38f7cSTobias KlauserKCOV_INSTRUMENT := n 45f3d60f2aSTobias KlauserKASAN_SANITIZE := n 468341dcfbSJisheng ZhangUBSAN_SANITIZE := n 47e2c0cdfbSPalmer Dabbelt 48e2c0cdfbSPalmer Dabbelt# Force dependency 49e2c0cdfbSPalmer Dabbelt$(obj)/vdso.o: $(obj)/vdso.so 50e2c0cdfbSPalmer Dabbelt 51e2c0cdfbSPalmer Dabbelt# link rule for the .so file, .lds has to be first 52772d7891SJisheng Zhang$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE 53e2c0cdfbSPalmer Dabbelt $(call if_changed,vdsold) 54fde9c59aSSaleem AbdulrasoolLDFLAGS_vdso.so.dbg = -shared -S -soname=linux-vdso.so.1 \ 557f3d3490SNathan Chancellor --build-id=sha1 --hash-style=both --eh-frame-hdr 56e2c0cdfbSPalmer Dabbelt 57e2c0cdfbSPalmer Dabbelt# strip rule for the .so file 58e2c0cdfbSPalmer Dabbelt$(obj)/%.so: OBJCOPYFLAGS := -S 59e2c0cdfbSPalmer Dabbelt$(obj)/%.so: $(obj)/%.so.dbg FORCE 60e2c0cdfbSPalmer Dabbelt $(call if_changed,objcopy) 61e2c0cdfbSPalmer Dabbelt 62fde9c59aSSaleem Abdulrasool# Generate VDSO offsets using helper script 63fde9c59aSSaleem Abdulrasoolgen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 64fde9c59aSSaleem Abdulrasoolquiet_cmd_vdsosym = VDSOSYM $@ 65fde9c59aSSaleem Abdulrasool cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ 66fde9c59aSSaleem Abdulrasool 67fde9c59aSSaleem Abdulrasoolinclude/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE 68fde9c59aSSaleem Abdulrasool $(call if_changed,vdsosym) 69fde9c59aSSaleem Abdulrasool 70e2c0cdfbSPalmer Dabbelt# actual build commands 71e2c0cdfbSPalmer Dabbelt# The DSO images are built using a special linker script 72e2c0cdfbSPalmer Dabbelt# Make sure only to export the intended __vdso_xxx symbol offsets. 73e2c0cdfbSPalmer Dabbeltquiet_cmd_vdsold = VDSOLD $@ 747f3d3490SNathan Chancellor cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \ 757f3d3490SNathan Chancellor $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ 7695f4d9ccSIlie Halip rm $@.tmp 77