xref: /openbmc/linux/arch/csky/kernel/vdso/Makefile (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
187f3248cSGuo Ren# SPDX-License-Identifier: GPL-2.0-only
287f3248cSGuo Ren
3*aff69273SFangrui Song# Include the generic Makefile to check the built vdso.
487f3248cSGuo Reninclude $(srctree)/lib/vdso/Makefile
587f3248cSGuo Ren
687f3248cSGuo Ren# Symbols present in the vdso
70d3b051aSGuo Renvdso-syms  += rt_sigreturn
80d3b051aSGuo Renvdso-syms  += vgettimeofday
987f3248cSGuo Ren
1087f3248cSGuo Ren# Files to link into the vdso
1187f3248cSGuo Renobj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
1287f3248cSGuo Ren
130d3b051aSGuo Renifneq ($(c-gettimeofday-y),)
140d3b051aSGuo Ren	CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
150d3b051aSGuo Renendif
160d3b051aSGuo Ren
170d3b051aSGuo Renccflags-y := -fno-stack-protector -DBUILD_VDSO32
1887f3248cSGuo Ren
1987f3248cSGuo Ren# Build rules
2087f3248cSGuo Rentargets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
2187f3248cSGuo Renobj-vdso := $(addprefix $(obj)/, $(obj-vdso))
2287f3248cSGuo Ren
2387f3248cSGuo Renobj-y += vdso.o vdso-syms.o
2487f3248cSGuo RenCPPFLAGS_vdso.lds += -P -C -U$(ARCH)
2587f3248cSGuo Ren
2687f3248cSGuo Ren# Disable gcov profiling for VDSO code
2787f3248cSGuo RenGCOV_PROFILE := n
2887f3248cSGuo RenKCOV_INSTRUMENT := n
2987f3248cSGuo Ren
3087f3248cSGuo Ren# Force dependency
3187f3248cSGuo Ren$(obj)/vdso.o: $(obj)/vdso.so
3287f3248cSGuo Ren
3387f3248cSGuo RenSYSCFLAGS_vdso.so.dbg = $(c_flags)
3487f3248cSGuo Ren$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
3587f3248cSGuo Ren	$(call if_changed,vdsold)
3687f3248cSGuo RenSYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
3787f3248cSGuo Ren	-Wl,--build-id=sha1 -Wl,--hash-style=both
3887f3248cSGuo Ren
3987f3248cSGuo Ren$(obj)/vdso-syms.S: $(obj)/vdso.so FORCE
4087f3248cSGuo Ren	$(call if_changed,so2s)
4187f3248cSGuo Ren
4287f3248cSGuo Ren# strip rule for the .so file
4387f3248cSGuo Ren$(obj)/%.so: OBJCOPYFLAGS := -S
4487f3248cSGuo Ren$(obj)/%.so: $(obj)/%.so.dbg FORCE
4587f3248cSGuo Ren	$(call if_changed,objcopy)
4687f3248cSGuo Ren
4787f3248cSGuo Ren# actual build commands
4887f3248cSGuo Ren# The DSO images are built using a special linker script
4987f3248cSGuo Ren# Make sure only to export the intended __vdso_xxx symbol offsets.
5087f3248cSGuo Renquiet_cmd_vdsold = VDSOLD  $@
5187f3248cSGuo Ren      cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
5287f3248cSGuo Ren                           -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
5387f3248cSGuo Ren                   $(CROSS_COMPILE)objcopy \
5487f3248cSGuo Ren                           $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
5587f3248cSGuo Ren                   rm $@.tmp
5687f3248cSGuo Ren
5787f3248cSGuo Ren# Extracts symbol offsets from the VDSO, converting them into an assembly file
5887f3248cSGuo Ren# that contains the same symbols at the same offsets.
5987f3248cSGuo Renquiet_cmd_so2s = SO2S    $@
6087f3248cSGuo Ren      cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
6187f3248cSGuo Ren
6287f3248cSGuo Ren# install commands for the unstripped file
6387f3248cSGuo Renquiet_cmd_vdso_install = INSTALL $@
6487f3248cSGuo Ren      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
6587f3248cSGuo Ren
6687f3248cSGuo Renvdso.so: $(obj)/vdso.so.dbg
6787f3248cSGuo Ren	@mkdir -p $(MODLIB)/vdso
6887f3248cSGuo Ren	$(call cmd,vdso_install)
6987f3248cSGuo Ren
7087f3248cSGuo Renvdso_install: vdso.so
71