2019-05-19 20:07:45 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2017-07-11 09:07:09 +08:00
|
|
|
# Copied from arch/tile/kernel/vdso/Makefile
|
|
|
|
|
2020-06-09 22:14:48 +08:00
|
|
|
# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
|
|
|
|
# the inclusion of generic Makefile.
|
|
|
|
ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
|
|
|
|
include $(srctree)/lib/vdso/Makefile
|
2017-07-11 09:07:09 +08:00
|
|
|
# Symbols present in the vdso
|
2017-10-24 06:42:14 +08:00
|
|
|
vdso-syms = rt_sigreturn
|
2019-02-19 00:43:12 +08:00
|
|
|
ifdef CONFIG_64BIT
|
2020-06-09 22:14:48 +08:00
|
|
|
vdso-syms += vgettimeofday
|
2019-02-19 00:43:12 +08:00
|
|
|
endif
|
2017-10-24 06:42:14 +08:00
|
|
|
vdso-syms += getcpu
|
2017-10-26 05:32:16 +08:00
|
|
|
vdso-syms += flush_icache
|
2017-07-11 09:07:09 +08:00
|
|
|
|
|
|
|
# Files to link into the vdso
|
2020-04-27 23:13:34 +08:00
|
|
|
obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
|
2017-07-11 09:07:09 +08:00
|
|
|
|
2020-06-09 22:14:48 +08:00
|
|
|
ifneq ($(c-gettimeofday-y),)
|
2020-06-23 09:13:22 +08:00
|
|
|
CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
|
2020-06-09 22:14:48 +08:00
|
|
|
endif
|
|
|
|
|
2017-07-11 09:07:09 +08:00
|
|
|
# Build rules
|
|
|
|
targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
|
|
|
|
obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
|
|
|
|
|
|
|
|
obj-y += vdso.o vdso-syms.o
|
|
|
|
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
|
|
|
|
|
2020-06-23 17:50:54 +08:00
|
|
|
# Disable -pg to prevent insert call site
|
|
|
|
CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
|
|
|
|
|
2017-07-11 09:07:09 +08:00
|
|
|
# Disable gcov profiling for VDSO code
|
|
|
|
GCOV_PROFILE := n
|
2020-06-26 20:40:56 +08:00
|
|
|
KCOV_INSTRUMENT := n
|
2017-07-11 09:07:09 +08:00
|
|
|
|
|
|
|
# Force dependency
|
|
|
|
$(obj)/vdso.o: $(obj)/vdso.so
|
|
|
|
|
|
|
|
# link rule for the .so file, .lds has to be first
|
|
|
|
SYSCFLAGS_vdso.so.dbg = $(c_flags)
|
|
|
|
$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
|
|
|
|
$(call if_changed,vdsold)
|
|
|
|
|
|
|
|
# We also create a special relocatable object that should mirror the symbol
|
2020-04-15 22:29:58 +08:00
|
|
|
# table and layout of the linked DSO. With ld --just-symbols we can then
|
|
|
|
# refer to these symbols in the kernel code rather than hand-coded addresses.
|
2017-07-11 09:07:09 +08:00
|
|
|
|
|
|
|
SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
|
2019-07-11 10:38:40 +08:00
|
|
|
-Wl,--build-id -Wl,--hash-style=both
|
2017-07-11 09:07:09 +08:00
|
|
|
$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
|
|
|
|
$(call if_changed,vdsold)
|
|
|
|
|
2020-04-15 22:29:58 +08:00
|
|
|
LDFLAGS_vdso-syms.o := -r --just-symbols
|
2017-07-11 09:07:09 +08:00
|
|
|
$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
|
|
|
|
$(call if_changed,ld)
|
|
|
|
|
|
|
|
# strip rule for the .so file
|
|
|
|
$(obj)/%.so: OBJCOPYFLAGS := -S
|
|
|
|
$(obj)/%.so: $(obj)/%.so.dbg FORCE
|
|
|
|
$(call if_changed,objcopy)
|
|
|
|
|
|
|
|
# actual build commands
|
|
|
|
# The DSO images are built using a special linker script
|
|
|
|
# Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions.
|
|
|
|
# Make sure only to export the intended __vdso_xxx symbol offsets.
|
|
|
|
quiet_cmd_vdsold = VDSOLD $@
|
2018-07-05 05:07:14 +08:00
|
|
|
cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
|
|
|
|
-Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
|
2017-07-11 09:07:09 +08:00
|
|
|
$(CROSS_COMPILE)objcopy \
|
2020-01-15 19:32:42 +08:00
|
|
|
$(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
|
|
|
|
rm $@.tmp
|
2017-07-11 09:07:09 +08:00
|
|
|
|
|
|
|
# install commands for the unstripped file
|
|
|
|
quiet_cmd_vdso_install = INSTALL $@
|
|
|
|
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
|
|
|
|
|
|
|
vdso.so: $(obj)/vdso.so.dbg
|
|
|
|
@mkdir -p $(MODLIB)/vdso
|
|
|
|
$(call cmd,vdso_install)
|
|
|
|
|
|
|
|
vdso_install: vdso.so
|