at commit c03c1a14
| 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | # Copied from arch/tile/kernel/vdso/Makefile |
| 3 | |
| 4 | # Include the generic Makefile to check the built vdso. |
| 5 | include $(srctree)/lib/vdso/Makefile.include |
| 6 | # Symbols present in the vdso |
| 7 | vdso-syms = rt_sigreturn |
| 8 | ifdef CONFIG_64BIT |
| 9 | vdso-syms += vgettimeofday |
| 10 | endif |
| 11 | vdso-syms += getcpu |
| 12 | vdso-syms += flush_icache |
| 13 | vdso-syms += hwprobe |
| 14 | vdso-syms += sys_hwprobe |
| 15 | |
| 16 | ifdef CONFIG_VDSO_GETRANDOM |
| 17 | vdso-syms += getrandom |
| 18 | endif |
| 19 | |
| 20 | ifdef VDSO_CFI_BUILD |
| 21 | CFI_MARCH = _zicfilp_zicfiss |
| 22 | CFI_FULL = -fcf-protection=full |
| 23 | CFI_SUFFIX = -cfi |
| 24 | OFFSET_SUFFIX = _cfi |
| 25 | ccflags-y += -DVDSO_CFI=1 |
| 26 | asflags-y += -DVDSO_CFI=1 |
| 27 | endif |
| 28 | |
| 29 | # Files to link into the vdso |
| 30 | obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o |
| 31 | |
| 32 | ifdef CONFIG_VDSO_GETRANDOM |
| 33 | obj-vdso += vgetrandom-chacha.o |
| 34 | endif |
| 35 | |
| 36 | ccflags-y := -fno-stack-protector |
| 37 | ccflags-y += -DDISABLE_BRANCH_PROFILING |
| 38 | ccflags-y += -fno-builtin |
| 39 | ccflags-y += $(CONFIG_CC_OPT_INLINE_MEMSET) |
| 40 | ccflags-y += $(KBUILD_BASE_ISA)$(CFI_MARCH) |
| 41 | ccflags-y += $(CFI_FULL) |
| 42 | asflags-y += $(KBUILD_BASE_ISA)$(CFI_MARCH) |
| 43 | asflags-y += $(CFI_FULL) |
| 44 | |
| 45 | ccflags-remove-y += $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_LTO) |
| 46 | |
| 47 | ifneq ($(c-gettimeofday-y),) |
| 48 | CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y) |
| 49 | endif |
| 50 | |
| 51 | ifneq ($(c-getrandom-y),) |
| 52 | CFLAGS_getrandom.o += -fPIC -include $(c-getrandom-y) |
| 53 | endif |
| 54 | |
| 55 | CFLAGS_hwprobe.o += -fPIC |
| 56 | |
| 57 | # Build rules |
| 58 | vdso_offsets := vdso$(if $(VDSO_CFI_BUILD),$(CFI_SUFFIX),)-offsets.h |
| 59 | vdso_o := vdso$(if $(VDSO_CFI_BUILD),$(CFI_SUFFIX),).o |
| 60 | vdso_so := vdso$(if $(VDSO_CFI_BUILD),$(CFI_SUFFIX),).so |
| 61 | vdso_so_dbg := vdso$(if $(VDSO_CFI_BUILD),$(CFI_SUFFIX),).so.dbg |
| 62 | vdso_lds := vdso.lds |
| 63 | |
| 64 | targets := $(obj-vdso) $(vdso_so) $(vdso_so_dbg) $(vdso_lds) |
| 65 | |
| 66 | obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) |
| 67 | |
| 68 | obj-y += vdso$(if $(VDSO_CFI_BUILD),$(CFI_SUFFIX),).o |
| 69 | CPPFLAGS_$(vdso_lds) += -P -C -U$(ARCH) |
| 70 | ifneq ($(filter vgettimeofday, $(vdso-syms)),) |
| 71 | CPPFLAGS_$(vdso_lds) += -DHAS_VGETTIMEOFDAY |
| 72 | endif |
| 73 | |
| 74 | # Force dependency |
| 75 | $(obj)/$(vdso_o): $(obj)/$(vdso_so) |
| 76 | |
| 77 | # link rule for the .so file, .lds has to be first |
| 78 | $(obj)/$(vdso_so_dbg): $(obj)/$(vdso_lds) $(obj-vdso) FORCE |
| 79 | $(call if_changed,vdsold_and_check) |
| 80 | LDFLAGS_$(vdso_so_dbg) = -shared -soname=linux-vdso.so.1 \ |
| 81 | --build-id=sha1 --eh-frame-hdr |
| 82 | |
| 83 | # strip rule for the .so file |
| 84 | $(obj)/%.so: OBJCOPYFLAGS := -S |
| 85 | $(obj)/%.so: $(obj)/%.so.dbg FORCE |
| 86 | $(call if_changed,objcopy) |
| 87 | |
| 88 | # Generate VDSO offsets using helper script |
| 89 | gen-vdsosym := $(src)/gen_vdso_offsets.sh |
| 90 | quiet_cmd_vdsosym = VDSOSYM $@ |
| 91 | cmd_vdsosym = $(NM) $< | $(gen-vdsosym) $(OFFSET_SUFFIX) | LC_ALL=C sort > $@ |
| 92 | |
| 93 | include/generated/$(vdso_offsets): $(obj)/$(vdso_so_dbg) FORCE |
| 94 | $(call if_changed,vdsosym) |
| 95 | |
| 96 | # actual build commands |
| 97 | # The DSO images are built using a special linker script |
| 98 | # Make sure only to export the intended __vdso_xxx symbol offsets. |
| 99 | quiet_cmd_vdsold_and_check = VDSOLD $@ |
| 100 | cmd_vdsold_and_check = $(LD) $(CFI_FULL) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \ |
| 101 | $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ |
| 102 | rm $@.tmp && \ |
| 103 | $(cmd_vdso_check) |