xref: /openbmc/linux/arch/csky/kernel/vdso/Makefile (revision 9c73e1e0)
1# SPDX-License-Identifier: GPL-2.0-only
2
3# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
4# the inclusion of generic Makefile.
5ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT
6include $(srctree)/lib/vdso/Makefile
7
8# Symbols present in the vdso
9vdso-syms  += rt_sigreturn
10vdso-syms  += vgettimeofday
11
12# Files to link into the vdso
13obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
14
15ifneq ($(c-gettimeofday-y),)
16	CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
17endif
18
19ccflags-y := -fno-stack-protector -DBUILD_VDSO32
20
21# Build rules
22targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
23obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
24
25obj-y += vdso.o vdso-syms.o
26CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
27
28# Disable gcov profiling for VDSO code
29GCOV_PROFILE := n
30KCOV_INSTRUMENT := n
31
32# Force dependency
33$(obj)/vdso.o: $(obj)/vdso.so
34
35SYSCFLAGS_vdso.so.dbg = $(c_flags)
36$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
37	$(call if_changed,vdsold)
38SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
39	-Wl,--build-id=sha1 -Wl,--hash-style=both
40
41$(obj)/vdso-syms.S: $(obj)/vdso.so FORCE
42	$(call if_changed,so2s)
43
44# strip rule for the .so file
45$(obj)/%.so: OBJCOPYFLAGS := -S
46$(obj)/%.so: $(obj)/%.so.dbg FORCE
47	$(call if_changed,objcopy)
48
49# actual build commands
50# The DSO images are built using a special linker script
51# Make sure only to export the intended __vdso_xxx symbol offsets.
52quiet_cmd_vdsold = VDSOLD  $@
53      cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
54                           -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
55                   $(CROSS_COMPILE)objcopy \
56                           $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
57                   rm $@.tmp
58
59# Extracts symbol offsets from the VDSO, converting them into an assembly file
60# that contains the same symbols at the same offsets.
61quiet_cmd_so2s = SO2S    $@
62      cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
63
64# install commands for the unstripped file
65quiet_cmd_vdso_install = INSTALL $@
66      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
67
68vdso.so: $(obj)/vdso.so.dbg
69	@mkdir -p $(MODLIB)/vdso
70	$(call cmd,vdso_install)
71
72vdso_install: vdso.so
73