1# SPDX-License-Identifier: GPL-2.0 2 3# List of files in the vdso, has to be asm only for now 4 5# Include the generic Makefile to check the built vdso. 6include $(srctree)/lib/vdso/Makefile 7 8obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o 9obj-vdso64 = sigtramp64-64.o gettimeofday-64.o datapage-64.o cacheflush-64.o note-64.o getcpu-64.o 10 11ifneq ($(c-gettimeofday-y),) 12 CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y) 13# Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That used to be true 14# by accident when the VDSO was hand-written asm code, but may not be now that the VDSO is 15# compiler generated. To avoid breaking Go tell GCC not to use r30. Impact on code 16# generation is minimal, it will just use r29 instead. 17 CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y) $(call cc-option, -ffixed-r30) 18endif 19 20# Build rules 21 22ifdef CROSS32_COMPILE 23 VDSOCC := $(CROSS32_COMPILE)gcc 24else 25 VDSOCC := $(CC) 26endif 27 28targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o 29obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) 30targets += $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o 31obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64)) 32 33GCOV_PROFILE := n 34KCOV_INSTRUMENT := n 35UBSAN_SANITIZE := n 36KASAN_SANITIZE := n 37KCSAN_SANITIZE := n 38 39ccflags-y := -fno-common -fno-builtin 40ccflags-y += $(DISABLE_LATENT_ENTROPY_PLUGIN) 41ccflags-y += $(call cc-option, -fno-stack-protector) 42ccflags-y += -DDISABLE_BRANCH_PROFILING 43ccflags-y += -ffreestanding -fasynchronous-unwind-tables 44ccflags-remove-y := $(CC_FLAGS_FTRACE) 45ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS) 46ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) 47ldflags-$(CONFIG_LD_ORPHAN_WARN) += -Wl,--orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) 48 49# Filter flags that clang will warn are unused for linking 50ldflags-y += $(filter-out $(CC_AUTO_VAR_INIT_ZERO_ENABLER) $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS)) 51 52CC32FLAGS := -m32 53CC32FLAGSREMOVE := -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc 54ifdef CONFIG_CC_IS_CLANG 55# This flag is supported by clang for 64-bit but not 32-bit so it will cause 56# an unused command line flag warning for this file. 57CC32FLAGSREMOVE += -fno-stack-clash-protection 58# -mstack-protector-guard values from the 64-bit build are not valid for the 59# 32-bit one. clang validates the values passed to these arguments during 60# parsing, even when -fno-stack-protector is passed afterwards. 61CC32FLAGSREMOVE += -mstack-protector-guard% 62endif 63LD32FLAGS := -Wl,-soname=linux-vdso32.so.1 64AS32FLAGS := -D__VDSO32__ 65 66LD64FLAGS := -Wl,-soname=linux-vdso64.so.1 67AS64FLAGS := -D__VDSO64__ 68 69targets += vdso32.lds 70CPPFLAGS_vdso32.lds += -P -C -Upowerpc 71targets += vdso64.lds 72CPPFLAGS_vdso64.lds += -P -C -U$(ARCH) 73 74# link rule for the .so file, .lds has to be first 75$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o FORCE 76 $(call if_changed,vdso32ld_and_check) 77$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday-64.o FORCE 78 $(call if_changed,vdso64ld_and_check) 79 80# assembly rules for the .S files 81$(obj-vdso32): %-32.o: %.S FORCE 82 $(call if_changed_dep,vdso32as) 83$(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE 84 $(call if_changed_dep,vdso32cc) 85$(obj-vdso64): %-64.o: %.S FORCE 86 $(call if_changed_dep,vdso64as) 87$(obj)/vgettimeofday-64.o: %-64.o: %.c FORCE 88 $(call if_changed_dep,cc_o_c) 89 90# Generate VDSO offsets using helper script 91gen-vdso32sym := $(srctree)/$(src)/gen_vdso32_offsets.sh 92quiet_cmd_vdso32sym = VDSO32SYM $@ 93 cmd_vdso32sym = $(NM) $< | $(gen-vdso32sym) | LC_ALL=C sort > $@ 94gen-vdso64sym := $(srctree)/$(src)/gen_vdso64_offsets.sh 95quiet_cmd_vdso64sym = VDSO64SYM $@ 96 cmd_vdso64sym = $(NM) $< | $(gen-vdso64sym) | LC_ALL=C sort > $@ 97 98include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE 99 $(call if_changed,vdso32sym) 100include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE 101 $(call if_changed,vdso64sym) 102 103# actual build commands 104quiet_cmd_vdso32ld_and_check = VDSO32L $@ 105 cmd_vdso32ld_and_check = $(VDSOCC) $(ldflags-y) $(CC32FLAGS) $(LD32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) 106quiet_cmd_vdso32as = VDSO32A $@ 107 cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $< 108quiet_cmd_vdso32cc = VDSO32C $@ 109 cmd_vdso32cc = $(VDSOCC) $(filter-out $(CC32FLAGSREMOVE), $(c_flags)) $(CC32FLAGS) -c -o $@ $< 110 111quiet_cmd_vdso64ld_and_check = VDSO64L $@ 112 cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) 113quiet_cmd_vdso64as = VDSO64A $@ 114 cmd_vdso64as = $(VDSOCC) $(a_flags) $(AS64FLAGS) -c -o $@ $< 115 116OBJECT_FILES_NON_STANDARD := y 117