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