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