xref: /openbmc/linux/arch/s390/kernel/vdso64/Makefile (revision 65b96377)
1# SPDX-License-Identifier: GPL-2.0
2# List of files in the vdso
3
4KCOV_INSTRUMENT := n
5ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
6ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
7
8include $(srctree)/lib/vdso/Makefile
9obj-vdso64 = vdso_user_wrapper.o note.o
10obj-cvdso64 = vdso64_generic.o getcpu.o
11VDSO_CFLAGS_REMOVE := -pg $(CC_FLAGS_FTRACE) $(CC_FLAGS_EXPOLINE) $(CC_FLAGS_CHECK_STACK)
12CFLAGS_REMOVE_getcpu.o = $(VDSO_CFLAGS_REMOVE)
13CFLAGS_REMOVE_vdso64_generic.o = $(VDSO_CFLAGS_REMOVE)
14
15# Build rules
16
17targets := $(obj-vdso64) $(obj-cvdso64) vdso64.so vdso64.so.dbg
18obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
19obj-cvdso64 := $(addprefix $(obj)/, $(obj-cvdso64))
20
21KBUILD_AFLAGS += -DBUILD_VDSO
22KBUILD_CFLAGS += -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING
23
24KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS))
25KBUILD_AFLAGS_64 += -m64 -s
26
27KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS))
28KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin
29ldflags-y := -fPIC -shared -soname=linux-vdso64.so.1 \
30	     --hash-style=both --build-id=sha1 -T
31
32$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64)
33$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64)
34
35obj-y += vdso64_wrapper.o
36targets += vdso64.lds
37CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
38
39# Disable gcov profiling, ubsan and kasan for VDSO code
40GCOV_PROFILE := n
41UBSAN_SANITIZE := n
42KASAN_SANITIZE := n
43KCSAN_SANITIZE := n
44
45# Force dependency (incbin is bad)
46$(obj)/vdso64_wrapper.o : $(obj)/vdso64.so
47
48# link rule for the .so file, .lds has to be first
49$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj-cvdso64) FORCE
50	$(call if_changed,ld)
51
52# strip rule for the .so file
53$(obj)/%.so: OBJCOPYFLAGS := -S
54$(obj)/%.so: $(obj)/%.so.dbg FORCE
55	$(call if_changed,objcopy)
56
57# assembly rules for the .S files
58$(obj-vdso64): %.o: %.S FORCE
59	$(call if_changed_dep,vdso64as)
60
61$(obj-cvdso64): %.o: %.c FORCE
62	$(call if_changed_dep,vdso64cc)
63
64# actual build commands
65quiet_cmd_vdso64as = VDSO64A $@
66      cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
67quiet_cmd_vdso64cc = VDSO64C $@
68      cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $<
69
70# install commands for the unstripped file
71quiet_cmd_vdso_install = INSTALL $@
72      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
73
74vdso64.so: $(obj)/vdso64.so.dbg
75	@mkdir -p $(MODLIB)/vdso
76	$(call cmd,vdso_install)
77
78vdso_install: vdso64.so
79
80# Generate VDSO offsets using helper script
81gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
82quiet_cmd_vdsosym = VDSOSYM $@
83	cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
84
85include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
86	$(call if_changed,vdsosym)
87