1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2ebb5e78cSAlex Smith# Objects to go into the VDSO. 324640f23SVincenzo Frascino 4e0a8b93eSNemanja Rakovic# Sanitizer runtimes are unavailable and cannot be linked here. 5e0a8b93eSNemanja Rakovic KCSAN_SANITIZE := n 6e0a8b93eSNemanja Rakovic 7*aff69273SFangrui Song# Include the generic Makefile to check the built vdso. 824640f23SVincenzo Frascinoinclude $(srctree)/lib/vdso/Makefile 924640f23SVincenzo Frascino 1024640f23SVincenzo Frascinoobj-vdso-y := elf.o vgettimeofday.o sigreturn.o 11ebb5e78cSAlex Smith 12ebb5e78cSAlex Smith# Common compiler flags between ABIs. 13ebb5e78cSAlex Smithccflags-vdso := \ 14ebb5e78cSAlex Smith $(filter -I%,$(KBUILD_CFLAGS)) \ 15ebb5e78cSAlex Smith $(filter -E%,$(KBUILD_CFLAGS)) \ 16bb93078eSJames Hogan $(filter -mmicromips,$(KBUILD_CFLAGS)) \ 17351fddddSPaul Burton $(filter -march=%,$(KBUILD_CFLAGS)) \ 180648e50eSPaul Burton $(filter -m%-float,$(KBUILD_CFLAGS)) \ 192f2b4fd6SPaul Burton $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \ 2076d7fff2SNathan Chancellor $(CLANG_FLAGS) \ 21351fddddSPaul Burton -D__VDSO__ 22ee67855eSPaul Burton 2399570c3dSThomas Gleixnerifndef CONFIG_64BIT 2499570c3dSThomas Gleixnerccflags-vdso += -DBUILD_VDSO32 2599570c3dSThomas Gleixnerendif 2699570c3dSThomas Gleixner 2724640f23SVincenzo Frascino# 2824640f23SVincenzo Frascino# The -fno-jump-tables flag only prevents the compiler from generating 2924640f23SVincenzo Frascino# jump tables but does not prevent the compiler from emitting absolute 3024640f23SVincenzo Frascino# offsets. 31ebb5e78cSAlex Smithcflags-vdso := $(ccflags-vdso) \ 32ebb5e78cSAlex Smith $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 3324640f23SVincenzo Frascino -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ 3472cf3b3dSNathan Chancellor -mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \ 3524640f23SVincenzo Frascino -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ 36893ab004SMasahiro Yamada $(call cc-option, -fno-asynchronous-unwind-tables) 37ebb5e78cSAlex Smithaflags-vdso := $(ccflags-vdso) \ 38ebb5e78cSAlex Smith -D__ASSEMBLY__ -Wa,-gdwarf-2 39ebb5e78cSAlex Smith 4024640f23SVincenzo Frascinoifneq ($(c-gettimeofday-y),) 4124640f23SVincenzo FrascinoCFLAGS_vgettimeofday.o = -include $(c-gettimeofday-y) 4224640f23SVincenzo Frascino 4324640f23SVincenzo Frascino# config-n32-o32-env.c prepares the environment to build a 32bit vDSO 4424640f23SVincenzo Frascino# library on a 64bit kernel. 4524640f23SVincenzo Frascino# Note: Needs to be included before than the generic library. 46b4c0f7faSVincenzo FrascinoCFLAGS_vgettimeofday-o32.o = -include $(srctree)/$(src)/config-n32-o32-env.c -include $(c-gettimeofday-y) 47b4c0f7faSVincenzo FrascinoCFLAGS_vgettimeofday-n32.o = -include $(srctree)/$(src)/config-n32-o32-env.c -include $(c-gettimeofday-y) 4824640f23SVincenzo Frascinoendif 4924640f23SVincenzo Frascino 501b6bc35aSzhaoxiaoCFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) 5124640f23SVincenzo Frascino 52e91946d6SNathan Chancellorifdef CONFIG_MIPS_DISABLE_VDSO 538919975bSPaul Burton obj-vdso-y := $(filter-out vgettimeofday.o, $(obj-vdso-y)) 54ebb5e78cSAlex Smithendif 55ebb5e78cSAlex Smith 56ebb5e78cSAlex Smith# VDSO linker flags. 572ff90699SNathan Chancellorldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ 58bdbf2038SMasahiro Yamada $(filter -E%,$(KBUILD_CFLAGS)) -shared \ 59a9684337SBill Wendling -G 0 --eh-frame-hdr --hash-style=sysv --build-id=sha1 -T 60ebb5e78cSAlex Smith 611b6bc35aSzhaoxiaoCFLAGS_REMOVE_vdso.o = $(CC_FLAGS_FTRACE) 6224640f23SVincenzo Frascino 63ebb5e78cSAlex SmithGCOV_PROFILE := n 641e35918aSHassan NaveedUBSAN_SANITIZE := n 65dcf78ee6SAlexey KhoroshilovKCOV_INSTRUMENT := n 66ebb5e78cSAlex Smith 67976c23afSVictor Kamensky# Check that we don't have PIC 'jalr t9' calls left 68976c23afSVictor Kamenskyquiet_cmd_vdso_mips_check = VDSOCHK $@ 69d42f0c6aSTiezhu Yang cmd_vdso_mips_check = if $(OBJDUMP) --disassemble $@ | grep -E -h "jalr.*t9" > /dev/null; \ 70976c23afSVictor Kamensky then (echo >&2 "$@: PIC 'jalr t9' calls are not supported"; \ 71976c23afSVictor Kamensky rm -f $@; /bin/false); fi 72976c23afSVictor Kamensky 73ebb5e78cSAlex Smith# 74ebb5e78cSAlex Smith# Shared build commands. 75ebb5e78cSAlex Smith# 76ebb5e78cSAlex Smith 77cdab7e2cSVincenzo Frascinoquiet_cmd_vdsold_and_vdso_check = LD $@ 782ff90699SNathan Chancellor cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check); $(cmd_vdso_mips_check) 79ebb5e78cSAlex Smith 80b668970eSArnd Bergmannquiet_cmd_vdsoas_o_S = AS $@ 81b668970eSArnd Bergmann cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $< 82b668970eSArnd Bergmann 832afb9745SJames Hogan# Strip rule for the raw .so files 842afb9745SJames Hogan$(obj)/%.so.raw: OBJCOPYFLAGS := -S 852afb9745SJames Hogan$(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE 862afb9745SJames Hogan $(call if_changed,objcopy) 872afb9745SJames Hogan 885f2fb52fSMasahiro Yamadahostprogs := genvdso 89ebb5e78cSAlex Smith 90ebb5e78cSAlex Smithquiet_cmd_genvdso = GENVDSO $@ 91ebb5e78cSAlex Smithdefine cmd_genvdso 922afb9745SJames Hogan $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \ 932afb9745SJames Hogan $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME) 94ebb5e78cSAlex Smithendef 95ebb5e78cSAlex Smith 96ebb5e78cSAlex Smith# 97ebb5e78cSAlex Smith# Build native VDSO. 98ebb5e78cSAlex Smith# 99ebb5e78cSAlex Smith 100ebb5e78cSAlex Smithnative-abi := $(filter -mabi=%,$(KBUILD_CFLAGS)) 101ebb5e78cSAlex Smith 102ebb5e78cSAlex Smithtargets += $(obj-vdso-y) 1032afb9745SJames Hogantargets += vdso.lds 1042afb9745SJames Hogantargets += vdso.so.dbg.raw vdso.so.raw 1052afb9745SJames Hogantargets += vdso.so.dbg vdso.so 1062afb9745SJames Hogantargets += vdso-image.c 107ebb5e78cSAlex Smith 108ebb5e78cSAlex Smithobj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o) 109ebb5e78cSAlex Smith 110ebb5e78cSAlex Smith$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi) 111ebb5e78cSAlex Smith$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi) 112ebb5e78cSAlex Smith 113034827c7SJames Hogan$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi) 114ebb5e78cSAlex Smith 1152afb9745SJames Hogan$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE 116cdab7e2cSVincenzo Frascino $(call if_changed,vdsold_and_vdso_check) 117ebb5e78cSAlex Smith 1182afb9745SJames Hogan$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \ 1192afb9745SJames Hogan $(obj)/genvdso FORCE 120ebb5e78cSAlex Smith $(call if_changed,genvdso) 121ebb5e78cSAlex Smith 122ebb5e78cSAlex Smithobj-y += vdso-image.o 123ebb5e78cSAlex Smith 124ebb5e78cSAlex Smith# 125ebb5e78cSAlex Smith# Build O32 VDSO. 126ebb5e78cSAlex Smith# 127ebb5e78cSAlex Smith 128ebb5e78cSAlex Smith# Define these outside the ifdef to ensure they are picked up by clean. 129ebb5e78cSAlex Smithtargets += $(obj-vdso-y:%.o=%-o32.o) 1302afb9745SJames Hogantargets += vdso-o32.lds 1312afb9745SJames Hogantargets += vdso-o32.so.dbg.raw vdso-o32.so.raw 1322afb9745SJames Hogantargets += vdso-o32.so.dbg vdso-o32.so 1332afb9745SJames Hogantargets += vdso-o32-image.c 134ebb5e78cSAlex Smith 135ebb5e78cSAlex Smithifdef CONFIG_MIPS32_O32 136ebb5e78cSAlex Smith 137ebb5e78cSAlex Smithobj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o) 138ebb5e78cSAlex Smith 139ebb5e78cSAlex Smith$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32 140ebb5e78cSAlex Smith$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32 141ebb5e78cSAlex Smith 142ebb5e78cSAlex Smith$(obj)/%-o32.o: $(src)/%.S FORCE 143b668970eSArnd Bergmann $(call if_changed_dep,vdsoas_o_S) 144ebb5e78cSAlex Smith 145ebb5e78cSAlex Smith$(obj)/%-o32.o: $(src)/%.c FORCE 146ebb5e78cSAlex Smith $(call cmd,force_checksrc) 147ebb5e78cSAlex Smith $(call if_changed_rule,cc_o_c) 148ebb5e78cSAlex Smith 14967fc5dc8SPaul Burton$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32 150ebb5e78cSAlex Smith$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE 151ebb5e78cSAlex Smith $(call if_changed_dep,cpp_lds_S) 152ebb5e78cSAlex Smith 1532afb9745SJames Hogan$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE 154cdab7e2cSVincenzo Frascino $(call if_changed,vdsold_and_vdso_check) 155ebb5e78cSAlex Smith 156ebb5e78cSAlex Smith$(obj)/vdso-o32-image.c: VDSO_NAME := o32 1572afb9745SJames Hogan$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \ 1582afb9745SJames Hogan $(obj)/genvdso FORCE 159ebb5e78cSAlex Smith $(call if_changed,genvdso) 160ebb5e78cSAlex Smith 161ebb5e78cSAlex Smithobj-y += vdso-o32-image.o 162ebb5e78cSAlex Smith 163ebb5e78cSAlex Smithendif 164ebb5e78cSAlex Smith 165ebb5e78cSAlex Smith# 166ebb5e78cSAlex Smith# Build N32 VDSO. 167ebb5e78cSAlex Smith# 168ebb5e78cSAlex Smith 169ebb5e78cSAlex Smithtargets += $(obj-vdso-y:%.o=%-n32.o) 1702afb9745SJames Hogantargets += vdso-n32.lds 1712afb9745SJames Hogantargets += vdso-n32.so.dbg.raw vdso-n32.so.raw 1722afb9745SJames Hogantargets += vdso-n32.so.dbg vdso-n32.so 1732afb9745SJames Hogantargets += vdso-n32-image.c 174ebb5e78cSAlex Smith 175ebb5e78cSAlex Smithifdef CONFIG_MIPS32_N32 176ebb5e78cSAlex Smith 177ebb5e78cSAlex Smithobj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o) 178ebb5e78cSAlex Smith 179ebb5e78cSAlex Smith$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32 180ebb5e78cSAlex Smith$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32 181ebb5e78cSAlex Smith 182ebb5e78cSAlex Smith$(obj)/%-n32.o: $(src)/%.S FORCE 183b668970eSArnd Bergmann $(call if_changed_dep,vdsoas_o_S) 184ebb5e78cSAlex Smith 185ebb5e78cSAlex Smith$(obj)/%-n32.o: $(src)/%.c FORCE 186ebb5e78cSAlex Smith $(call cmd,force_checksrc) 187ebb5e78cSAlex Smith $(call if_changed_rule,cc_o_c) 188ebb5e78cSAlex Smith 18967fc5dc8SPaul Burton$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32 190ebb5e78cSAlex Smith$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE 191ebb5e78cSAlex Smith $(call if_changed_dep,cpp_lds_S) 192ebb5e78cSAlex Smith 1932afb9745SJames Hogan$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE 194cdab7e2cSVincenzo Frascino $(call if_changed,vdsold_and_vdso_check) 195ebb5e78cSAlex Smith 196ebb5e78cSAlex Smith$(obj)/vdso-n32-image.c: VDSO_NAME := n32 1972afb9745SJames Hogan$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \ 1982afb9745SJames Hogan $(obj)/genvdso FORCE 199ebb5e78cSAlex Smith $(call if_changed,genvdso) 200ebb5e78cSAlex Smith 201ebb5e78cSAlex Smithobj-y += vdso-n32-image.o 202ebb5e78cSAlex Smith 203ebb5e78cSAlex Smithendif 204ebb5e78cSAlex Smith 205ebb5e78cSAlex Smith# FIXME: Need install rule for debug. 206ebb5e78cSAlex Smith# Needs to deal with dependency for generation of dbg by cmd_genvdso... 207