GNU Linux-libre 5.19-rc6-gnu
[releases.git] / arch / csky / kernel / vdso / Makefile
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.
5 ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT
6 include $(srctree)/lib/vdso/Makefile
7
8 # Symbols present in the vdso
9 vdso-syms  += rt_sigreturn
10 vdso-syms  += vgettimeofday
11
12 # Files to link into the vdso
13 obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
14
15 ifneq ($(c-gettimeofday-y),)
16         CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
17 endif
18
19 ccflags-y := -fno-stack-protector -DBUILD_VDSO32
20
21 # Build rules
22 targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
23 obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
24
25 obj-y += vdso.o vdso-syms.o
26 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
27
28 # Disable gcov profiling for VDSO code
29 GCOV_PROFILE := n
30 KCOV_INSTRUMENT := n
31
32 # Force dependency
33 $(obj)/vdso.o: $(obj)/vdso.so
34
35 SYSCFLAGS_vdso.so.dbg = $(c_flags)
36 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
37         $(call if_changed,vdsold)
38 SYSCFLAGS_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.
52 quiet_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.
61 quiet_cmd_so2s = SO2S    $@
62       cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
63
64 # install commands for the unstripped file
65 quiet_cmd_vdso_install = INSTALL $@
66       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
67
68 vdso.so: $(obj)/vdso.so.dbg
69         @mkdir -p $(MODLIB)/vdso
70         $(call cmd,vdso_install)
71
72 vdso_install: vdso.so