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. 5*127b0e05SThomas Weißschuhinclude $(srctree)/lib/vdso/Makefile.include 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 21bf40167dSAlexandre 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 40d1584d79SSami TolvanenCFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) 41ad14f7caSVladimir IsaevCFLAGS_REMOVE_hwprobe.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) 42e05d57dcSGuo Ren 43e2c0cdfbSPalmer Dabbelt# Force dependency 44e2c0cdfbSPalmer Dabbelt$(obj)/vdso.o: $(obj)/vdso.so 45e2c0cdfbSPalmer Dabbelt 46e2c0cdfbSPalmer Dabbelt# link rule for the .so file, .lds has to be first 47772d7891SJisheng Zhang$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE 48c6898d66SAlexandre Ghiti $(call if_changed,vdsold_and_check) 497587a360SChangbin DuLDFLAGS_vdso.so.dbg = -shared -soname=linux-vdso.so.1 \ 507f3d3490SNathan Chancellor --build-id=sha1 --hash-style=both --eh-frame-hdr 51e2c0cdfbSPalmer Dabbelt 52e2c0cdfbSPalmer Dabbelt# strip rule for the .so file 53e2c0cdfbSPalmer Dabbelt$(obj)/%.so: OBJCOPYFLAGS := -S 54e2c0cdfbSPalmer Dabbelt$(obj)/%.so: $(obj)/%.so.dbg FORCE 55e2c0cdfbSPalmer Dabbelt $(call if_changed,objcopy) 56e2c0cdfbSPalmer Dabbelt 57fde9c59aSSaleem Abdulrasool# Generate VDSO offsets using helper script 58b1992c37SMasahiro Yamadagen-vdsosym := $(src)/gen_vdso_offsets.sh 59fde9c59aSSaleem Abdulrasoolquiet_cmd_vdsosym = VDSOSYM $@ 60fde9c59aSSaleem Abdulrasool cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ 61fde9c59aSSaleem Abdulrasool 62fde9c59aSSaleem Abdulrasoolinclude/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE 63fde9c59aSSaleem Abdulrasool $(call if_changed,vdsosym) 64fde9c59aSSaleem Abdulrasool 65e2c0cdfbSPalmer Dabbelt# actual build commands 66e2c0cdfbSPalmer Dabbelt# The DSO images are built using a special linker script 67e2c0cdfbSPalmer Dabbelt# Make sure only to export the intended __vdso_xxx symbol offsets. 68c6898d66SAlexandre Ghitiquiet_cmd_vdsold_and_check = VDSOLD $@ 69c6898d66SAlexandre Ghiti cmd_vdsold_and_check = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \ 707f3d3490SNathan Chancellor $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ 71c6898d66SAlexandre Ghiti rm $@.tmp && \ 72c6898d66SAlexandre Ghiti $(cmd_vdso_check) 73