xref: /linux/arch/loongarch/vdso/Makefile (revision 18efd0b10e0fd77fe649a375f9f17a387b5d1609)
1c6b99bedSHuacai Chen# SPDX-License-Identifier: GPL-2.0
2c6b99bedSHuacai Chen# Objects to go into the VDSO.
3c6b99bedSHuacai Chen
4aff69273SFangrui Song# Include the generic Makefile to check the built vdso.
5c6b99bedSHuacai Cheninclude $(srctree)/lib/vdso/Makefile
6c6b99bedSHuacai Chen
7*18efd0b1SXi Ruoyaoobj-vdso-y := elf.o vgetcpu.o vgettimeofday.o vgetrandom.o \
8*18efd0b1SXi Ruoyao              vgetrandom-chacha.o sigreturn.o
9c6b99bedSHuacai Chen
10c6b99bedSHuacai Chen# Common compiler flags between ABIs.
11c6b99bedSHuacai Chenccflags-vdso := \
12c6b99bedSHuacai Chen	$(filter -I%,$(KBUILD_CFLAGS)) \
13c6b99bedSHuacai Chen	$(filter -E%,$(KBUILD_CFLAGS)) \
14c6b99bedSHuacai Chen	$(filter -march=%,$(KBUILD_CFLAGS)) \
15c6b99bedSHuacai Chen	$(filter -m%-float,$(KBUILD_CFLAGS)) \
16b89673a9SWANG Xuerui	$(CLANG_FLAGS) \
17c6b99bedSHuacai Chen	-D__VDSO__
18c6b99bedSHuacai Chen
19c6b99bedSHuacai Chencflags-vdso := $(ccflags-vdso) \
20e6ee9023SHuacai Chen	-isystem $(shell $(CC) -print-file-name=include) \
21c6b99bedSHuacai Chen	$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
2238b10b26SWANG Xuerui	-O2 -g -fno-strict-aliasing -fno-common -fno-builtin \
23c6b99bedSHuacai Chen	-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
24c6b99bedSHuacai Chen	$(call cc-option, -fno-asynchronous-unwind-tables) \
25c6b99bedSHuacai Chen	$(call cc-option, -fno-stack-protector)
26c6b99bedSHuacai Chenaflags-vdso := $(ccflags-vdso) \
27c6b99bedSHuacai Chen	-D__ASSEMBLY__ -Wa,-gdwarf-2
28c6b99bedSHuacai Chen
29c6b99bedSHuacai Chenifneq ($(c-gettimeofday-y),)
30c6b99bedSHuacai Chen  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
31c6b99bedSHuacai Chenendif
32c6b99bedSHuacai Chen
33*18efd0b1SXi Ruoyaoifneq ($(c-getrandom-y),)
34*18efd0b1SXi Ruoyao  CFLAGS_vgetrandom.o += -include $(c-getrandom-y)
35*18efd0b1SXi Ruoyaoendif
36*18efd0b1SXi Ruoyao
37c6b99bedSHuacai Chen# VDSO linker flags.
38c6b99bedSHuacai Chenldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
39c6b99bedSHuacai Chen	$(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \
40c6b99bedSHuacai Chen	--hash-style=sysv --build-id -T
41c6b99bedSHuacai Chen
42c6b99bedSHuacai Chen#
43c6b99bedSHuacai Chen# Shared build commands.
44c6b99bedSHuacai Chen#
45c6b99bedSHuacai Chen
46c6b99bedSHuacai Chenquiet_cmd_vdsold_and_vdso_check = LD      $@
47c6b99bedSHuacai Chen      cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
48c6b99bedSHuacai Chen
49c6b99bedSHuacai Chenquiet_cmd_vdsoas_o_S = AS       $@
50c6b99bedSHuacai Chen      cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
51c6b99bedSHuacai Chen
52c6b99bedSHuacai Chen# Generate VDSO offsets using helper script
53b1992c37SMasahiro Yamadagen-vdsosym := $(src)/gen_vdso_offsets.sh
54c6b99bedSHuacai Chenquiet_cmd_vdsosym = VDSOSYM $@
55c6b99bedSHuacai Chen      cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
56c6b99bedSHuacai Chen
57c6b99bedSHuacai Cheninclude/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
58c6b99bedSHuacai Chen	$(call if_changed,vdsosym)
59c6b99bedSHuacai Chen
60c6b99bedSHuacai Chen#
61c6b99bedSHuacai Chen# Build native VDSO.
62c6b99bedSHuacai Chen#
63c6b99bedSHuacai Chen
64c6b99bedSHuacai Chennative-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
65c6b99bedSHuacai Chen
66c6b99bedSHuacai Chentargets += $(obj-vdso-y)
67c6b99bedSHuacai Chentargets += vdso.lds vdso.so.dbg vdso.so
68c6b99bedSHuacai Chen
69c6b99bedSHuacai Chenobj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
70c6b99bedSHuacai Chen
71c6b99bedSHuacai Chen$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
72c6b99bedSHuacai Chen$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
73c6b99bedSHuacai Chen
74c6b99bedSHuacai Chen$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
75c6b99bedSHuacai Chen
76c6b99bedSHuacai Chen$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
77c6b99bedSHuacai Chen	$(call if_changed,vdsold_and_vdso_check)
78c6b99bedSHuacai Chen
79c6b99bedSHuacai Chen$(obj)/vdso.so: OBJCOPYFLAGS := -S
80c6b99bedSHuacai Chen$(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE
81c6b99bedSHuacai Chen	$(call if_changed,objcopy)
82c6b99bedSHuacai Chen
83c6b99bedSHuacai Chenobj-y += vdso.o
84c6b99bedSHuacai Chen
85c6b99bedSHuacai Chen$(obj)/vdso.o : $(obj)/vdso.so
86