xref: /linux/arch/s390/kernel/vdso64/Makefile (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
24bff8cb5SSven Schnelle# List of files in the vdso
3b020632eSMartin Schwidefsky
4aff69273SFangrui Song# Include the generic Makefile to check the built vdso.
54bff8cb5SSven Schnelleinclude $(srctree)/lib/vdso/Makefile
6*b920aa77SHeiko Carstensobj-vdso64 = vdso_user_wrapper.o note.o vgetrandom-chacha.o
7*b920aa77SHeiko Carstensobj-cvdso64 = vdso64_generic.o getcpu.o vgetrandom.o
800b55eafSSven SchnelleVDSO_CFLAGS_REMOVE := -pg $(CC_FLAGS_FTRACE) $(CC_FLAGS_EXPOLINE) $(CC_FLAGS_CHECK_STACK)
900b55eafSSven SchnelleCFLAGS_REMOVE_getcpu.o = $(VDSO_CFLAGS_REMOVE)
10*b920aa77SHeiko CarstensCFLAGS_REMOVE_vgetrandom.o = $(VDSO_CFLAGS_REMOVE)
1100b55eafSSven SchnelleCFLAGS_REMOVE_vdso64_generic.o = $(VDSO_CFLAGS_REMOVE)
12b020632eSMartin Schwidefsky
13*b920aa77SHeiko Carstensifneq ($(c-getrandom-y),)
14*b920aa77SHeiko Carstens	CFLAGS_vgetrandom.o += -include $(c-getrandom-y)
15*b920aa77SHeiko Carstensendif
16*b920aa77SHeiko Carstens
17b020632eSMartin Schwidefsky# Build rules
18b020632eSMartin Schwidefsky
194bff8cb5SSven Schnelletargets := $(obj-vdso64) $(obj-cvdso64) vdso64.so vdso64.so.dbg
20b020632eSMartin Schwidefskyobj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
214bff8cb5SSven Schnelleobj-cvdso64 := $(addprefix $(obj)/, $(obj-cvdso64))
22b020632eSMartin Schwidefsky
23bc3703f2SHendrik BruecknerKBUILD_AFLAGS += -DBUILD_VDSO
244bf3ec38SSven SchnelleKBUILD_CFLAGS += -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING
25bc3703f2SHendrik Brueckner
26b020632eSMartin SchwidefskyKBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS))
27f8210229SNathan ChancellorKBUILD_AFLAGS_64 += -m64
28b020632eSMartin Schwidefsky
29b020632eSMartin SchwidefskyKBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS))
30185445c7SHeiko CarstensKBUILD_CFLAGS_64 := $(filter-out -mpacked-stack,$(KBUILD_CFLAGS_64))
31d15e4314SSumanth KorikkarKBUILD_CFLAGS_64 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_64))
328192a1b3SSumanth KorikkarKBUILD_CFLAGS_64 := $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_64))
3310f70525SJens RemusKBUILD_CFLAGS_64 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_64))
3410f70525SJens RemusKBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin -fasynchronous-unwind-tables
350628c039SNathan Chancellorldflags-y := -shared -soname=linux-vdso64.so.1 \
36a9684337SBill Wendling	     --hash-style=both --build-id=sha1 -T
37b020632eSMartin Schwidefsky
38b020632eSMartin Schwidefsky$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64)
39b020632eSMartin Schwidefsky$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64)
40b020632eSMartin Schwidefsky
41b020632eSMartin Schwidefskyobj-y += vdso64_wrapper.o
42887af6d7SMasahiro Yamadatargets += vdso64.lds
43b020632eSMartin SchwidefskyCPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
44b020632eSMartin Schwidefsky
45b020632eSMartin Schwidefsky# Force dependency (incbin is bad)
46b020632eSMartin Schwidefsky$(obj)/vdso64_wrapper.o : $(obj)/vdso64.so
47b020632eSMartin Schwidefsky
480dd0bbc2SSven Schnellequiet_cmd_vdso_and_check = VDSO    $@
490dd0bbc2SSven Schnelle      cmd_vdso_and_check = $(cmd_ld); $(cmd_vdso_check)
500dd0bbc2SSven Schnelle
51b020632eSMartin Schwidefsky# link rule for the .so file, .lds has to be first
52b957df3bSMasahiro Yamada$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(obj-cvdso64) FORCE
530dd0bbc2SSven Schnelle	$(call if_changed,vdso_and_check)
54b020632eSMartin Schwidefsky
55b020632eSMartin Schwidefsky# strip rule for the .so file
56b020632eSMartin Schwidefsky$(obj)/%.so: OBJCOPYFLAGS := -S
57b020632eSMartin Schwidefsky$(obj)/%.so: $(obj)/%.so.dbg FORCE
58b020632eSMartin Schwidefsky	$(call if_changed,objcopy)
59b020632eSMartin Schwidefsky
60b020632eSMartin Schwidefsky# assembly rules for the .S files
61b44b136aSVasily Gorbik$(obj-vdso64): %.o: %.S FORCE
62b020632eSMartin Schwidefsky	$(call if_changed_dep,vdso64as)
63b020632eSMartin Schwidefsky
644bff8cb5SSven Schnelle$(obj-cvdso64): %.o: %.c FORCE
654bff8cb5SSven Schnelle	$(call if_changed_dep,vdso64cc)
664bff8cb5SSven Schnelle
67b020632eSMartin Schwidefsky# actual build commands
68b020632eSMartin Schwidefskyquiet_cmd_vdso64as = VDSO64A $@
69b020632eSMartin Schwidefsky      cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
704bff8cb5SSven Schnellequiet_cmd_vdso64cc = VDSO64C $@
714bff8cb5SSven Schnelle      cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $<
72b020632eSMartin Schwidefsky
73779df224SSven Schnelle# Generate VDSO offsets using helper script
74b1992c37SMasahiro Yamadagen-vdsosym := $(src)/gen_vdso_offsets.sh
75779df224SSven Schnellequiet_cmd_vdsosym = VDSOSYM $@
76779df224SSven Schnelle	cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
77779df224SSven Schnelle
78779df224SSven Schnelleinclude/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
79779df224SSven Schnelle	$(call if_changed,vdsosym)
80