Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 #
0003 # Building a vDSO image for AArch64.
0004 #
0005 # Author: Will Deacon <will.deacon@arm.com>
0006 # Heavily based on the vDSO Makefiles for other archs.
0007 #
0008 
0009 # Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
0010 # the inclusion of generic Makefile.
0011 ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64
0012 include $(srctree)/lib/vdso/Makefile
0013 
0014 obj-vdso := vgettimeofday.o note.o sigreturn.o
0015 
0016 # Build rules
0017 targets := $(obj-vdso) vdso.so vdso.so.dbg
0018 obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
0019 
0020 btildflags-$(CONFIG_ARM64_BTI_KERNEL) += -z force-bti
0021 
0022 # -Bsymbolic has been added for consistency with arm, the compat vDSO and
0023 # potential future proofing if we end up with internal calls to the exported
0024 # routines, as x86 does (see 6f121e548f83 ("x86, vdso: Reimplement vdso.so
0025 # preparation in build-time C")).
0026 ldflags-y := -shared -soname=linux-vdso.so.1 --hash-style=sysv  \
0027              -Bsymbolic --build-id=sha1 -n $(btildflags-y)
0028 
0029 ifdef CONFIG_LD_ORPHAN_WARN
0030   ldflags-y += --orphan-handling=warn
0031 endif
0032 
0033 ldflags-y += -T
0034 
0035 ccflags-y := -fno-common -fno-builtin -fno-stack-protector -ffixed-x18
0036 ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
0037 
0038 # -Wmissing-prototypes and -Wmissing-declarations are removed from
0039 # the CFLAGS of vgettimeofday.c to make possible to build the
0040 # kernel with CONFIG_WERROR enabled.
0041 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \
0042                                 $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) \
0043                                 $(CC_FLAGS_LTO) -Wmissing-prototypes -Wmissing-declarations
0044 KASAN_SANITIZE                  := n
0045 KCSAN_SANITIZE                  := n
0046 UBSAN_SANITIZE                  := n
0047 OBJECT_FILES_NON_STANDARD       := y
0048 KCOV_INSTRUMENT                 := n
0049 
0050 CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny -fasynchronous-unwind-tables
0051 
0052 ifneq ($(c-gettimeofday-y),)
0053   CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
0054 endif
0055 
0056 # Disable gcov profiling for VDSO code
0057 GCOV_PROFILE := n
0058 
0059 targets += vdso.lds
0060 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
0061 
0062 # Link rule for the .so file, .lds has to be first
0063 $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
0064         $(call if_changed,vdsold_and_vdso_check)
0065 
0066 # Strip rule for the .so file
0067 $(obj)/%.so: OBJCOPYFLAGS := -S
0068 $(obj)/%.so: $(obj)/%.so.dbg FORCE
0069         $(call if_changed,objcopy)
0070 
0071 # Generate VDSO offsets using helper script
0072 gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
0073 quiet_cmd_vdsosym = VDSOSYM $@
0074       cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
0075 
0076 include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
0077         $(call if_changed,vdsosym)
0078 
0079 # Actual build commands
0080 quiet_cmd_vdsold_and_vdso_check = LD      $@
0081       cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
0082 
0083 # Install commands for the unstripped file
0084 quiet_cmd_vdso_install = INSTALL $@
0085       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
0086 
0087 vdso.so: $(obj)/vdso.so.dbg
0088         @mkdir -p $(MODLIB)/vdso
0089         $(call cmd,vdso_install)
0090 
0091 vdso_install: vdso.so