blob: 9e2b95a222a9838fb2f7c06eee6b104b29f53d93 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Sven Schnelle4bff8cb2020-04-28 09:52:23 +02002# List of files in the vdso
Martin Schwidefskyb0206322008-12-25 13:38:36 +01003
Heiko Carstens907fa062016-06-20 14:08:32 +02004KCOV_INSTRUMENT := n
Sven Schnelle4bff8cb2020-04-28 09:52:23 +02005ARCH_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
Heiko Carstens907fa062016-06-20 14:08:32 +02007
Sven Schnelle4bff8cb2020-04-28 09:52:23 +02008include $(srctree)/lib/vdso/Makefile
Heiko Carstens87d59862020-11-16 08:06:40 +01009obj-vdso64 = vdso_user_wrapper.o note.o
Heiko Carstens80f06302020-11-16 08:06:41 +010010obj-cvdso64 = vdso64_generic.o getcpu.o
Sven Schnelle00b55ea2021-11-11 10:58:26 +010011VDSO_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)
Martin Schwidefskyb0206322008-12-25 13:38:36 +010014
15# Build rules
16
Sven Schnelle4bff8cb2020-04-28 09:52:23 +020017targets := $(obj-vdso64) $(obj-cvdso64) vdso64.so vdso64.so.dbg
Martin Schwidefskyb0206322008-12-25 13:38:36 +010018obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
Sven Schnelle4bff8cb2020-04-28 09:52:23 +020019obj-cvdso64 := $(addprefix $(obj)/, $(obj-cvdso64))
Martin Schwidefskyb0206322008-12-25 13:38:36 +010020
Hendrik Bruecknerbc3703f2017-11-20 11:41:07 +010021KBUILD_AFLAGS += -DBUILD_VDSO
Sven Schnelle4bf3ec32020-09-07 17:45:37 +020022KBUILD_CFLAGS += -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING
Hendrik Bruecknerbc3703f2017-11-20 11:41:07 +010023
Martin Schwidefskyb0206322008-12-25 13:38:36 +010024KBUILD_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
Masahiro Yamada7b737ad2021-11-08 01:21:11 +090029ldflags-y := -fPIC -shared -soname=linux-vdso64.so.1 \
Bill Wendlinga9684332020-09-22 16:21:40 -070030 --hash-style=both --build-id=sha1 -T
Martin Schwidefskyb0206322008-12-25 13:38:36 +010031
32$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64)
33$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64)
34
35obj-y += vdso64_wrapper.o
Masahiro Yamada887af6d2020-09-01 03:22:39 +090036targets += vdso64.lds
Martin Schwidefskyb0206322008-12-25 13:38:36 +010037CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
38
Vasily Gorbik34849842017-11-17 13:02:36 +010039# Disable gcov profiling, ubsan and kasan for VDSO code
Peter Oberparleiteradd74902011-05-23 10:24:31 +020040GCOV_PROFILE := n
Christian Borntraegerc42d8c72016-09-12 14:37:20 +020041UBSAN_SANITIZE := n
Vasily Gorbik34849842017-11-17 13:02:36 +010042KASAN_SANITIZE := n
Ilya Leoshkeviche37b3dd2021-07-28 13:59:04 +020043KCSAN_SANITIZE := n
Peter Oberparleiteradd74902011-05-23 10:24:31 +020044
Martin Schwidefskyb0206322008-12-25 13:38:36 +010045# 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
Sven Schnelle4bff8cb2020-04-28 09:52:23 +020049$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj-cvdso64) FORCE
Nathan Chancellor2b2a2582020-06-02 12:25:24 -070050 $(call if_changed,ld)
Martin Schwidefskyb0206322008-12-25 13:38:36 +010051
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
Vasily Gorbikb44b136a2018-10-19 15:37:01 +020058$(obj-vdso64): %.o: %.S FORCE
Martin Schwidefskyb0206322008-12-25 13:38:36 +010059 $(call if_changed_dep,vdso64as)
60
Sven Schnelle4bff8cb2020-04-28 09:52:23 +020061$(obj-cvdso64): %.o: %.c FORCE
62 $(call if_changed_dep,vdso64cc)
63
Martin Schwidefskyb0206322008-12-25 13:38:36 +010064# actual build commands
Martin Schwidefskyb0206322008-12-25 13:38:36 +010065quiet_cmd_vdso64as = VDSO64A $@
66 cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
Sven Schnelle4bff8cb2020-04-28 09:52:23 +020067quiet_cmd_vdso64cc = VDSO64C $@
68 cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $<
Martin Schwidefskyb0206322008-12-25 13:38:36 +010069
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
Sven Schnelle779df222021-06-25 14:50:08 +020079
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)