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