xref: /linux/arch/s390/kernel/vdso32/Makefile (revision 185445c7c137822ad856aae91a41e199370cb534)
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-vdso32 = vdso_user_wrapper-32.o note-32.o
9
10# Build rules
11
12targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
13obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
14
15KBUILD_AFLAGS += -DBUILD_VDSO
16KBUILD_CFLAGS += -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING
17
18KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
19KBUILD_AFLAGS_32 += -m31 -s
20
21KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
22KBUILD_CFLAGS_32 := $(filter-out -mpacked-stack,$(KBUILD_CFLAGS))
23KBUILD_CFLAGS_32 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_32))
24KBUILD_CFLAGS_32 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_32))
25KBUILD_CFLAGS_32 += -m31 -fPIC -shared -fno-common -fno-builtin -fasynchronous-unwind-tables
26
27LDFLAGS_vdso32.so.dbg += -shared -soname=linux-vdso32.so.1 \
28	--hash-style=both --build-id=sha1 -melf_s390 -T
29
30$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
31$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
32
33obj-y += vdso32_wrapper.o
34targets += vdso32.lds
35CPPFLAGS_vdso32.lds += -P -C -U$(ARCH)
36
37# Disable gcov profiling, ubsan and kasan for VDSO code
38GCOV_PROFILE := n
39UBSAN_SANITIZE := n
40KASAN_SANITIZE := n
41KCSAN_SANITIZE := n
42
43# Force dependency (incbin is bad)
44$(obj)/vdso32_wrapper.o : $(obj)/vdso32.so
45
46quiet_cmd_vdso_and_check = VDSO    $@
47      cmd_vdso_and_check = $(cmd_ld); $(cmd_vdso_check)
48
49$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) FORCE
50	$(call if_changed,vdso_and_check)
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$(obj-vdso32): %-32.o: %.S FORCE
58	$(call if_changed_dep,vdso32as)
59
60# actual build commands
61quiet_cmd_vdso32as = VDSO32A $@
62      cmd_vdso32as = $(CC) $(a_flags) -c -o $@ $<
63quiet_cmd_vdso32cc = VDSO32C $@
64      cmd_vdso32cc = $(CC) $(c_flags) -c -o $@ $<
65
66# Generate VDSO offsets using helper script
67gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
68quiet_cmd_vdsosym = VDSOSYM $@
69	cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
70
71include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE
72	$(call if_changed,vdsosym)
73