1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2ebb5e78cSAlex Smith# Objects to go into the VDSO. 3*24640f23SVincenzo Frascino 4*24640f23SVincenzo Frascino# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before 5*24640f23SVincenzo Frascino# the inclusion of generic Makefile. 6*24640f23SVincenzo FrascinoARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT 7*24640f23SVincenzo Frascinoinclude $(srctree)/lib/vdso/Makefile 8*24640f23SVincenzo Frascino 9*24640f23SVincenzo Frascinoobj-vdso-y := elf.o vgettimeofday.o sigreturn.o 10ebb5e78cSAlex Smith 11ebb5e78cSAlex Smith# Common compiler flags between ABIs. 12ebb5e78cSAlex Smithccflags-vdso := \ 13ebb5e78cSAlex Smith $(filter -I%,$(KBUILD_CFLAGS)) \ 14ebb5e78cSAlex Smith $(filter -E%,$(KBUILD_CFLAGS)) \ 15bb93078eSJames Hogan $(filter -mmicromips,$(KBUILD_CFLAGS)) \ 16351fddddSPaul Burton $(filter -march=%,$(KBUILD_CFLAGS)) \ 170648e50eSPaul Burton $(filter -m%-float,$(KBUILD_CFLAGS)) \ 18351fddddSPaul Burton -D__VDSO__ 19ee67855eSPaul Burton 20076f421dSMasahiro Yamadaifdef CONFIG_CC_IS_CLANG 21ee67855eSPaul Burtonccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS)) 22ee67855eSPaul Burtonendif 23ee67855eSPaul Burton 24*24640f23SVincenzo Frascino# 25*24640f23SVincenzo Frascino# The -fno-jump-tables flag only prevents the compiler from generating 26*24640f23SVincenzo Frascino# jump tables but does not prevent the compiler from emitting absolute 27*24640f23SVincenzo Frascino# offsets. 28ebb5e78cSAlex Smithcflags-vdso := $(ccflags-vdso) \ 29ebb5e78cSAlex Smith $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 30*24640f23SVincenzo Frascino -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ 31*24640f23SVincenzo Frascino -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ 32cfd75c2dSRobert Schiele $(call cc-option, -fno-asynchronous-unwind-tables) \ 33ebb5e78cSAlex Smith $(call cc-option, -fno-stack-protector) 34ebb5e78cSAlex Smithaflags-vdso := $(ccflags-vdso) \ 35ebb5e78cSAlex Smith -D__ASSEMBLY__ -Wa,-gdwarf-2 36ebb5e78cSAlex Smith 37*24640f23SVincenzo Frascinoifneq ($(c-gettimeofday-y),) 38*24640f23SVincenzo FrascinoCFLAGS_vgettimeofday.o = -include $(c-gettimeofday-y) 39*24640f23SVincenzo Frascino 40*24640f23SVincenzo Frascino# config-n32-o32-env.c prepares the environment to build a 32bit vDSO 41*24640f23SVincenzo Frascino# library on a 64bit kernel. 42*24640f23SVincenzo Frascino# Note: Needs to be included before than the generic library. 43*24640f23SVincenzo FrascinoCFLAGS_vgettimeofday-o32.o = -include $(src)/config-n32-o32-env.c -include $(c-gettimeofday-y) 44*24640f23SVincenzo FrascinoCFLAGS_vgettimeofday-n32.o = -include $(src)/config-n32-o32-env.c -include $(c-gettimeofday-y) 45*24640f23SVincenzo Frascinoendif 46*24640f23SVincenzo Frascino 47*24640f23SVincenzo FrascinoCFLAGS_REMOVE_vgettimeofday.o = -pg 48*24640f23SVincenzo Frascino 49ebb5e78cSAlex Smith# 50ebb5e78cSAlex Smith# For the pre-R6 code in arch/mips/vdso/vdso.h for locating 51ebb5e78cSAlex Smith# the base address of VDSO, the linker will emit a R_MIPS_PC32 52ebb5e78cSAlex Smith# relocation in binutils > 2.25 but it will fail with older versions 53ebb5e78cSAlex Smith# because that relocation is not supported for that symbol. As a result 54ebb5e78cSAlex Smith# of which we are forced to disable the VDSO symbols when building 55ebb5e78cSAlex Smith# with < 2.25 binutils on pre-R6 kernels. For more references on why we 56ebb5e78cSAlex Smith# can't use other methods to get the base address of VDSO please refer to 57ebb5e78cSAlex Smith# the comments on that file. 58ebb5e78cSAlex Smith# 59ebb5e78cSAlex Smithifndef CONFIG_CPU_MIPSR6 60d5ece1cbSJames Hogan ifeq ($(call ld-ifversion, -lt, 225000000, y),y) 612a037f31SQais Yousef $(warning MIPS VDSO requires binutils >= 2.25) 62ebb5e78cSAlex Smith obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y)) 63ebb5e78cSAlex Smith ccflags-vdso += -DDISABLE_MIPS_VDSO 64ebb5e78cSAlex Smith endif 65ebb5e78cSAlex Smithendif 66ebb5e78cSAlex Smith 67ebb5e78cSAlex Smith# VDSO linker flags. 68ebb5e78cSAlex SmithVDSO_LDFLAGS := \ 69ebb5e78cSAlex Smith -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \ 702f002567SPaul Burton $(addprefix -Wl$(comma),$(filter -E%,$(KBUILD_CFLAGS))) \ 711e022137SNick Desaulniers -nostdlib -shared -Wl,--hash-style=sysv -Wl,--build-id 72ebb5e78cSAlex Smith 73*24640f23SVincenzo FrascinoCFLAGS_REMOVE_vdso.o = -pg 74*24640f23SVincenzo Frascino 75ebb5e78cSAlex SmithGCOV_PROFILE := n 761e35918aSHassan NaveedUBSAN_SANITIZE := n 77ebb5e78cSAlex Smith 78ebb5e78cSAlex Smith# 79ebb5e78cSAlex Smith# Shared build commands. 80ebb5e78cSAlex Smith# 81ebb5e78cSAlex Smith 82ebb5e78cSAlex Smithquiet_cmd_vdsold = VDSO $@ 83ebb5e78cSAlex Smith cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \ 84ebb5e78cSAlex Smith -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ 85ebb5e78cSAlex Smith 86b668970eSArnd Bergmannquiet_cmd_vdsoas_o_S = AS $@ 87b668970eSArnd Bergmann cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $< 88b668970eSArnd Bergmann 892afb9745SJames Hogan# Strip rule for the raw .so files 902afb9745SJames Hogan$(obj)/%.so.raw: OBJCOPYFLAGS := -S 912afb9745SJames Hogan$(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE 922afb9745SJames Hogan $(call if_changed,objcopy) 932afb9745SJames Hogan 94ebb5e78cSAlex Smithhostprogs-y := genvdso 95ebb5e78cSAlex Smith 96ebb5e78cSAlex Smithquiet_cmd_genvdso = GENVDSO $@ 97ebb5e78cSAlex Smithdefine cmd_genvdso 982afb9745SJames Hogan $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \ 992afb9745SJames Hogan $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME) 100ebb5e78cSAlex Smithendef 101ebb5e78cSAlex Smith 102ebb5e78cSAlex Smith# 103ebb5e78cSAlex Smith# Build native VDSO. 104ebb5e78cSAlex Smith# 105ebb5e78cSAlex Smith 106ebb5e78cSAlex Smithnative-abi := $(filter -mabi=%,$(KBUILD_CFLAGS)) 107ebb5e78cSAlex Smith 108ebb5e78cSAlex Smithtargets += $(obj-vdso-y) 1092afb9745SJames Hogantargets += vdso.lds 1102afb9745SJames Hogantargets += vdso.so.dbg.raw vdso.so.raw 1112afb9745SJames Hogantargets += vdso.so.dbg vdso.so 1122afb9745SJames Hogantargets += vdso-image.c 113ebb5e78cSAlex Smith 114ebb5e78cSAlex Smithobj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o) 115ebb5e78cSAlex Smith 116ebb5e78cSAlex Smith$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi) 117ebb5e78cSAlex Smith$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi) 118ebb5e78cSAlex Smith 119034827c7SJames Hogan$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi) 120ebb5e78cSAlex Smith 1212afb9745SJames Hogan$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE 122ebb5e78cSAlex Smith $(call if_changed,vdsold) 123*24640f23SVincenzo Frascino $(call if_changed,vdso_check) 124ebb5e78cSAlex Smith 1252afb9745SJames Hogan$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \ 1262afb9745SJames Hogan $(obj)/genvdso FORCE 127ebb5e78cSAlex Smith $(call if_changed,genvdso) 128ebb5e78cSAlex Smith 129ebb5e78cSAlex Smithobj-y += vdso-image.o 130ebb5e78cSAlex Smith 131ebb5e78cSAlex Smith# 132ebb5e78cSAlex Smith# Build O32 VDSO. 133ebb5e78cSAlex Smith# 134ebb5e78cSAlex Smith 135ebb5e78cSAlex Smith# Define these outside the ifdef to ensure they are picked up by clean. 136ebb5e78cSAlex Smithtargets += $(obj-vdso-y:%.o=%-o32.o) 1372afb9745SJames Hogantargets += vdso-o32.lds 1382afb9745SJames Hogantargets += vdso-o32.so.dbg.raw vdso-o32.so.raw 1392afb9745SJames Hogantargets += vdso-o32.so.dbg vdso-o32.so 1402afb9745SJames Hogantargets += vdso-o32-image.c 141ebb5e78cSAlex Smith 142ebb5e78cSAlex Smithifdef CONFIG_MIPS32_O32 143ebb5e78cSAlex Smith 144ebb5e78cSAlex Smithobj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o) 145ebb5e78cSAlex Smith 146ebb5e78cSAlex Smith$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32 147ebb5e78cSAlex Smith$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32 148ebb5e78cSAlex Smith 149ebb5e78cSAlex Smith$(obj)/%-o32.o: $(src)/%.S FORCE 150b668970eSArnd Bergmann $(call if_changed_dep,vdsoas_o_S) 151ebb5e78cSAlex Smith 152ebb5e78cSAlex Smith$(obj)/%-o32.o: $(src)/%.c FORCE 153ebb5e78cSAlex Smith $(call cmd,force_checksrc) 154ebb5e78cSAlex Smith $(call if_changed_rule,cc_o_c) 155ebb5e78cSAlex Smith 15667fc5dc8SPaul Burton$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32 157ebb5e78cSAlex Smith$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE 158ebb5e78cSAlex Smith $(call if_changed_dep,cpp_lds_S) 159ebb5e78cSAlex Smith 1602afb9745SJames Hogan$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE 161ebb5e78cSAlex Smith $(call if_changed,vdsold) 162*24640f23SVincenzo Frascino $(call if_changed,vdso_check) 163ebb5e78cSAlex Smith 164ebb5e78cSAlex Smith$(obj)/vdso-o32-image.c: VDSO_NAME := o32 1652afb9745SJames Hogan$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \ 1662afb9745SJames Hogan $(obj)/genvdso FORCE 167ebb5e78cSAlex Smith $(call if_changed,genvdso) 168ebb5e78cSAlex Smith 169ebb5e78cSAlex Smithobj-y += vdso-o32-image.o 170ebb5e78cSAlex Smith 171ebb5e78cSAlex Smithendif 172ebb5e78cSAlex Smith 173ebb5e78cSAlex Smith# 174ebb5e78cSAlex Smith# Build N32 VDSO. 175ebb5e78cSAlex Smith# 176ebb5e78cSAlex Smith 177ebb5e78cSAlex Smithtargets += $(obj-vdso-y:%.o=%-n32.o) 1782afb9745SJames Hogantargets += vdso-n32.lds 1792afb9745SJames Hogantargets += vdso-n32.so.dbg.raw vdso-n32.so.raw 1802afb9745SJames Hogantargets += vdso-n32.so.dbg vdso-n32.so 1812afb9745SJames Hogantargets += vdso-n32-image.c 182ebb5e78cSAlex Smith 183ebb5e78cSAlex Smithifdef CONFIG_MIPS32_N32 184ebb5e78cSAlex Smith 185ebb5e78cSAlex Smithobj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o) 186ebb5e78cSAlex Smith 187ebb5e78cSAlex Smith$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32 188ebb5e78cSAlex Smith$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32 189ebb5e78cSAlex Smith 190ebb5e78cSAlex Smith$(obj)/%-n32.o: $(src)/%.S FORCE 191b668970eSArnd Bergmann $(call if_changed_dep,vdsoas_o_S) 192ebb5e78cSAlex Smith 193ebb5e78cSAlex Smith$(obj)/%-n32.o: $(src)/%.c FORCE 194ebb5e78cSAlex Smith $(call cmd,force_checksrc) 195ebb5e78cSAlex Smith $(call if_changed_rule,cc_o_c) 196ebb5e78cSAlex Smith 19767fc5dc8SPaul Burton$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32 198ebb5e78cSAlex Smith$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE 199ebb5e78cSAlex Smith $(call if_changed_dep,cpp_lds_S) 200ebb5e78cSAlex Smith 2012afb9745SJames Hogan$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE 202ebb5e78cSAlex Smith $(call if_changed,vdsold) 203*24640f23SVincenzo Frascino $(call if_changed,vdso_check) 204ebb5e78cSAlex Smith 205ebb5e78cSAlex Smith$(obj)/vdso-n32-image.c: VDSO_NAME := n32 2062afb9745SJames Hogan$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \ 2072afb9745SJames Hogan $(obj)/genvdso FORCE 208ebb5e78cSAlex Smith $(call if_changed,genvdso) 209ebb5e78cSAlex Smith 210ebb5e78cSAlex Smithobj-y += vdso-n32-image.o 211ebb5e78cSAlex Smith 212ebb5e78cSAlex Smithendif 213ebb5e78cSAlex Smith 214ebb5e78cSAlex Smith# FIXME: Need install rule for debug. 215ebb5e78cSAlex Smith# Needs to deal with dependency for generation of dbg by cmd_genvdso... 216