xref: /linux/arch/loongarch/vdso/Makefile (revision 8ca4fc323d2e4ab9dabbdd57633af40b0c7e6af9)
1# SPDX-License-Identifier: GPL-2.0
2# Objects to go into the VDSO.
3
4# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
5# the inclusion of generic Makefile.
6ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOT
7include $(srctree)/lib/vdso/Makefile
8
9obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o
10
11# Common compiler flags between ABIs.
12ccflags-vdso := \
13	$(filter -I%,$(KBUILD_CFLAGS)) \
14	$(filter -E%,$(KBUILD_CFLAGS)) \
15	$(filter -march=%,$(KBUILD_CFLAGS)) \
16	$(filter -m%-float,$(KBUILD_CFLAGS)) \
17	-D__VDSO__
18
19ifeq ($(cc-name),clang)
20ccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS))
21endif
22
23cflags-vdso := $(ccflags-vdso) \
24	-isystem $(shell $(CC) -print-file-name=include) \
25	$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
26	-O2 -g -fno-strict-aliasing -fno-common -fno-builtin -G0 \
27	-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
28	$(call cc-option, -fno-asynchronous-unwind-tables) \
29	$(call cc-option, -fno-stack-protector)
30aflags-vdso := $(ccflags-vdso) \
31	-D__ASSEMBLY__ -Wa,-gdwarf-2
32
33ifneq ($(c-gettimeofday-y),)
34  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
35endif
36
37# VDSO linker flags.
38ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
39	$(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \
40	--hash-style=sysv --build-id -T
41
42GCOV_PROFILE := n
43
44#
45# Shared build commands.
46#
47
48quiet_cmd_vdsold_and_vdso_check = LD      $@
49      cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
50
51quiet_cmd_vdsoas_o_S = AS       $@
52      cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
53
54# Generate VDSO offsets using helper script
55gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
56quiet_cmd_vdsosym = VDSOSYM $@
57      cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
58
59include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
60	$(call if_changed,vdsosym)
61
62#
63# Build native VDSO.
64#
65
66native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
67
68targets += $(obj-vdso-y)
69targets += vdso.lds vdso.so.dbg vdso.so
70
71obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
72
73$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
74$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
75
76$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
77
78$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
79	$(call if_changed,vdsold_and_vdso_check)
80
81$(obj)/vdso.so: OBJCOPYFLAGS := -S
82$(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE
83	$(call if_changed,objcopy)
84
85obj-y += vdso.o
86
87$(obj)/vdso.o : $(obj)/vdso.so
88
89# install commands for the unstripped file
90quiet_cmd_vdso_install = INSTALL $@
91      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
92
93vdso.so: $(obj)/vdso.so.dbg
94	@mkdir -p $(MODLIB)/vdso
95	$(call cmd,vdso_install)
96
97vdso_install: vdso.so
98