xref: /openbmc/linux/arch/loongarch/vdso/Makefile (revision 9760660e)
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 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	$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
25	-O2 -g -fno-strict-aliasing -fno-common -fno-builtin -G0 \
26	-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
27	$(call cc-option, -fno-asynchronous-unwind-tables) \
28	$(call cc-option, -fno-stack-protector)
29aflags-vdso := $(ccflags-vdso) \
30	-D__ASSEMBLY__ -Wa,-gdwarf-2
31
32ifneq ($(c-gettimeofday-y),)
33  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
34endif
35
36# VDSO linker flags.
37ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
38	$(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \
39	--hash-style=sysv --build-id -T
40
41GCOV_PROFILE := n
42
43#
44# Shared build commands.
45#
46
47quiet_cmd_vdsold_and_vdso_check = LD      $@
48      cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
49
50quiet_cmd_vdsoas_o_S = AS       $@
51      cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
52
53# Generate VDSO offsets using helper script
54gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
55quiet_cmd_vdsosym = VDSOSYM $@
56      cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
57
58include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
59	$(call if_changed,vdsosym)
60
61#
62# Build native VDSO.
63#
64
65native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
66
67targets += $(obj-vdso-y)
68targets += vdso.lds vdso.so.dbg vdso.so
69
70obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
71
72$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
73$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
74
75$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
76
77$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
78	$(call if_changed,vdsold_and_vdso_check)
79
80$(obj)/vdso.so: OBJCOPYFLAGS := -S
81$(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE
82	$(call if_changed,objcopy)
83
84obj-y += vdso.o
85
86$(obj)/vdso.o : $(obj)/vdso.so
87
88# install commands for the unstripped file
89quiet_cmd_vdso_install = INSTALL $@
90      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
91
92vdso.so: $(obj)/vdso.so.dbg
93	@mkdir -p $(MODLIB)/vdso
94	$(call cmd,vdso_install)
95
96vdso_install: vdso.so
97