2019-05-19 05:07:45 -07:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2017-07-10 18:07:09 -07:00
|
|
|
# Copied from arch/tile/kernel/vdso/Makefile
|
|
|
|
|
2023-03-10 12:07:50 -07:00
|
|
|
# Include the generic Makefile to check the built vdso.
|
2020-06-09 07:14:48 -07:00
|
|
|
include $(srctree)/lib/vdso/Makefile
|
2017-07-10 18:07:09 -07:00
|
|
|
# Symbols present in the vdso
|
2017-10-23 15:42:14 -07:00
|
|
|
vdso-syms = rt_sigreturn
|
2019-02-18 09:43:12 -07:00
|
|
|
ifdef CONFIG_64BIT
|
2020-06-09 07:14:48 -07:00
|
|
|
vdso-syms += vgettimeofday
|
2019-02-18 09:43:12 -07:00
|
|
|
endif
|
2017-10-23 15:42:14 -07:00
|
|
|
vdso-syms += getcpu
|
2017-10-25 14:32:16 -07:00
|
|
|
vdso-syms += flush_icache
|
2023-04-07 16:11:03 -07:00
|
|
|
vdso-syms += hwprobe
|
|
|
|
vdso-syms += sys_hwprobe
|
2017-07-10 18:07:09 -07:00
|
|
|
|
|
|
|
# Files to link into the vdso
|
2020-04-27 08:13:34 -07:00
|
|
|
obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
|
2017-07-10 18:07:09 -07:00
|
|
|
|
2020-07-29 00:51:29 -07:00
|
|
|
ccflags-y := -fno-stack-protector
|
2022-11-02 10:02:54 -07:00
|
|
|
ccflags-y += -DDISABLE_BRANCH_PROFILING
|
2024-10-16 01:36:24 -07:00
|
|
|
ccflags-y += -fno-builtin
|
2020-07-29 00:51:29 -07:00
|
|
|
|
2020-06-09 07:14:48 -07:00
|
|
|
ifneq ($(c-gettimeofday-y),)
|
2020-06-22 18:13:22 -07:00
|
|
|
CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
|
2020-06-09 07:14:48 -07:00
|
|
|
endif
|
|
|
|
|
2023-04-07 16:11:03 -07:00
|
|
|
CFLAGS_hwprobe.o += -fPIC
|
|
|
|
|
2017-07-10 18:07:09 -07:00
|
|
|
# Build rules
|
2021-08-04 10:32:14 -07:00
|
|
|
targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds
|
2017-07-10 18:07:09 -07:00
|
|
|
obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
|
|
|
|
|
2021-08-04 10:32:14 -07:00
|
|
|
obj-y += vdso.o
|
2017-07-10 18:07:09 -07:00
|
|
|
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
|
2022-11-08 10:13:23 -07:00
|
|
|
ifneq ($(filter vgettimeofday, $(vdso-syms)),)
|
|
|
|
CPPFLAGS_vdso.lds += -DHAS_VGETTIMEOFDAY
|
|
|
|
endif
|
2017-07-10 18:07:09 -07:00
|
|
|
|
2020-06-23 02:50:54 -07:00
|
|
|
# Disable -pg to prevent insert call site
|
2023-09-27 15:48:02 -07:00
|
|
|
CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
|
2024-03-13 00:35:46 -07:00
|
|
|
CFLAGS_REMOVE_hwprobe.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
|
2020-06-23 02:50:54 -07:00
|
|
|
|
2017-07-10 18:07:09 -07:00
|
|
|
# Force dependency
|
|
|
|
$(obj)/vdso.o: $(obj)/vdso.so
|
|
|
|
|
|
|
|
# link rule for the .so file, .lds has to be first
|
2021-04-02 06:29:08 -07:00
|
|
|
$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
|
2017-07-10 18:07:09 -07:00
|
|
|
$(call if_changed,vdsold)
|
2024-06-10 21:09:47 -07:00
|
|
|
LDFLAGS_vdso.so.dbg = -shared -soname=linux-vdso.so.1 \
|
2021-03-25 14:51:56 -07:00
|
|
|
--build-id=sha1 --hash-style=both --eh-frame-hdr
|
2017-07-10 18:07:09 -07:00
|
|
|
|
|
|
|
# strip rule for the .so file
|
|
|
|
$(obj)/%.so: OBJCOPYFLAGS := -S
|
|
|
|
$(obj)/%.so: $(obj)/%.so.dbg FORCE
|
|
|
|
$(call if_changed,objcopy)
|
|
|
|
|
2021-08-04 10:32:14 -07:00
|
|
|
# Generate VDSO offsets using helper script
|
kbuild: use $(src) instead of $(srctree)/$(src) for source directory
Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for
checked-in source files. It is merely a convention without any functional
difference. In fact, $(obj) and $(src) are exactly the same, as defined
in scripts/Makefile.build:
src := $(obj)
When the kernel is built in a separate output directory, $(src) does
not accurately reflect the source directory location. While Kbuild
resolves this discrepancy by specifying VPATH=$(srctree) to search for
source files, it does not cover all cases. For example, when adding a
header search path for local headers, -I$(srctree)/$(src) is typically
passed to the compiler.
This introduces inconsistency between upstream and downstream Makefiles
because $(src) is used instead of $(srctree)/$(src) for the latter.
To address this inconsistency, this commit changes the semantics of
$(src) so that it always points to the directory in the source tree.
Going forward, the variables used in Makefiles will have the following
meanings:
$(obj) - directory in the object tree
$(src) - directory in the source tree (changed by this commit)
$(objtree) - the top of the kernel object tree
$(srctree) - the top of the kernel source tree
Consequently, $(srctree)/$(src) in upstream Makefiles need to be replaced
with $(src).
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2024-04-27 07:55:02 -07:00
|
|
|
gen-vdsosym := $(src)/gen_vdso_offsets.sh
|
2021-08-04 10:32:14 -07:00
|
|
|
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-10 18:07:09 -07: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-25 14:51:56 -07:00
|
|
|
cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
|
|
|
|
$(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
|
2020-01-15 04:32:42 -07:00
|
|
|
rm $@.tmp
|