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-07-29 15:51:29 +08:00
|
|
|
ccflags-y := -fno-stack-protector
|
2022-11-03 01:02:54 +08:00
|
|
|
ccflags-y += -DDISABLE_BRANCH_PROFILING
|
2020-07-29 15:51:29 +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
|
2021-08-05 01:32:14 +08:00
|
|
|
targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds
|
2017-07-11 09:07:09 +08:00
|
|
|
obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
|
|
|
|
|
2021-08-05 01:32:14 +08:00
|
|
|
obj-y += vdso.o
|
2017-07-11 09:07:09 +08:00
|
|
|
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
|
2022-11-09 01:13:23 +08:00
|
|
|
ifneq ($(filter vgettimeofday, $(vdso-syms)),)
|
|
|
|
CPPFLAGS_vdso.lds += -DHAS_VGETTIMEOFDAY
|
|
|
|
endif
|
2017-07-11 09:07:09 +08:00
|
|
|
|
2020-06-23 17:50:54 +08:00
|
|
|
# Disable -pg to prevent insert call site
|
2022-11-01 02:29:43 +08:00
|
|
|
CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE)
|
2020-06-23 17:50:54 +08:00
|
|
|
|
2021-02-17 01:33:05 +08:00
|
|
|
# Disable profiling and instrumentation for VDSO code
|
2017-07-11 09:07:09 +08:00
|
|
|
GCOV_PROFILE := n
|
2020-06-26 20:40:56 +08:00
|
|
|
KCOV_INSTRUMENT := n
|
2021-02-17 01:33:05 +08:00
|
|
|
KASAN_SANITIZE := n
|
2021-08-05 00:30:59 +08:00
|
|
|
UBSAN_SANITIZE := 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
|
2021-04-02 21:29:08 +08:00
|
|
|
$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
|
2017-07-11 09:07:09 +08:00
|
|
|
$(call if_changed,vdsold)
|
2021-08-05 01:32:14 +08:00
|
|
|
LDFLAGS_vdso.so.dbg = -shared -S -soname=linux-vdso.so.1 \
|
2021-03-26 05:51:56 +08:00
|
|
|
--build-id=sha1 --hash-style=both --eh-frame-hdr
|
2017-07-11 09:07:09 +08:00
|
|
|
|
|
|
|
# strip rule for the .so file
|
|
|
|
$(obj)/%.so: OBJCOPYFLAGS := -S
|
|
|
|
$(obj)/%.so: $(obj)/%.so.dbg FORCE
|
|
|
|
$(call if_changed,objcopy)
|
|
|
|
|
2021-08-05 01:32:14 +08:00
|
|
|
# Generate VDSO offsets using helper script
|
|
|
|
gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
|
|
|
|
quiet_cmd_vdsosym = VDSOSYM $@
|
|
|
|
cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
|
|
|
|
|
|
|
|
include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
|
|
|
|
$(call if_changed,vdsosym)
|
|
|
|
|
2017-07-11 09:07:09 +08:00
|
|
|
# actual build commands
|
|
|
|
# The DSO images are built using a special linker script
|
|
|
|
# Make sure only to export the intended __vdso_xxx symbol offsets.
|
|
|
|
quiet_cmd_vdsold = VDSOLD $@
|
2021-03-26 05:51:56 +08:00
|
|
|
cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
|
|
|
|
$(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
|
2020-01-15 19:32:42 +08:00
|
|
|
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
|