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