1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2ebb5e78cSAlex Smith# Objects to go into the VDSO. 324640f23SVincenzo Frascino 4aff69273SFangrui Song# Include the generic Makefile to check the built vdso. 5*127b0e05SThomas Weißschuhinclude $(srctree)/lib/vdso/Makefile.include 624640f23SVincenzo Frascino 724640f23SVincenzo Frascinoobj-vdso-y := elf.o vgettimeofday.o sigreturn.o 8ebb5e78cSAlex Smith 9ebb5e78cSAlex Smith# Common compiler flags between ABIs. 10ebb5e78cSAlex Smithccflags-vdso := \ 11ebb5e78cSAlex Smith $(filter -I%,$(KBUILD_CFLAGS)) \ 12ebb5e78cSAlex Smith $(filter -E%,$(KBUILD_CFLAGS)) \ 13bb93078eSJames Hogan $(filter -mmicromips,$(KBUILD_CFLAGS)) \ 14351fddddSPaul Burton $(filter -march=%,$(KBUILD_CFLAGS)) \ 150648e50eSPaul Burton $(filter -m%-float,$(KBUILD_CFLAGS)) \ 162f2b4fd6SPaul Burton $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \ 1776d7fff2SNathan Chancellor $(CLANG_FLAGS) \ 18351fddddSPaul Burton -D__VDSO__ 19ee67855eSPaul Burton 2099570c3dSThomas Gleixnerifndef CONFIG_64BIT 2199570c3dSThomas Gleixnerccflags-vdso += -DBUILD_VDSO32 2299570c3dSThomas Gleixnerendif 2399570c3dSThomas Gleixner 2424640f23SVincenzo Frascino# 2524640f23SVincenzo Frascino# The -fno-jump-tables flag only prevents the compiler from generating 2624640f23SVincenzo Frascino# jump tables but does not prevent the compiler from emitting absolute 2724640f23SVincenzo Frascino# offsets. 28ebb5e78cSAlex Smithcflags-vdso := $(ccflags-vdso) \ 29ebb5e78cSAlex Smith $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 3024640f23SVincenzo Frascino -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ 3172cf3b3dSNathan Chancellor -mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \ 3224640f23SVincenzo Frascino -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ 33893ab004SMasahiro Yamada $(call cc-option, -fno-asynchronous-unwind-tables) 34ebb5e78cSAlex Smithaflags-vdso := $(ccflags-vdso) \ 35ebb5e78cSAlex Smith -D__ASSEMBLY__ -Wa,-gdwarf-2 36ebb5e78cSAlex Smith 3724640f23SVincenzo Frascinoifneq ($(c-gettimeofday-y),) 3824640f23SVincenzo FrascinoCFLAGS_vgettimeofday.o = -include $(c-gettimeofday-y) 3924640f23SVincenzo Frascino 4024640f23SVincenzo Frascino# config-n32-o32-env.c prepares the environment to build a 32bit vDSO 4124640f23SVincenzo Frascino# library on a 64bit kernel. 4224640f23SVincenzo Frascino# Note: Needs to be included before than the generic library. 43b1992c37SMasahiro YamadaCFLAGS_vgettimeofday-o32.o = -include $(src)/config-n32-o32-env.c -include $(c-gettimeofday-y) 44b1992c37SMasahiro YamadaCFLAGS_vgettimeofday-n32.o = -include $(src)/config-n32-o32-env.c -include $(c-gettimeofday-y) 4524640f23SVincenzo Frascinoendif 4624640f23SVincenzo Frascino 471b6bc35aSzhaoxiaoCFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) 4824640f23SVincenzo Frascino 49e91946d6SNathan Chancellorifdef CONFIG_MIPS_DISABLE_VDSO 508919975bSPaul Burton obj-vdso-y := $(filter-out vgettimeofday.o, $(obj-vdso-y)) 51ebb5e78cSAlex Smithendif 52ebb5e78cSAlex Smith 53ebb5e78cSAlex Smith# VDSO linker flags. 542ff90699SNathan Chancellorldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ 55bdbf2038SMasahiro Yamada $(filter -E%,$(KBUILD_CFLAGS)) -shared \ 56a9684337SBill Wendling -G 0 --eh-frame-hdr --hash-style=sysv --build-id=sha1 -T 57ebb5e78cSAlex Smith 581b6bc35aSzhaoxiaoCFLAGS_REMOVE_vdso.o = $(CC_FLAGS_FTRACE) 5924640f23SVincenzo Frascino 60976c23afSVictor Kamensky# Check that we don't have PIC 'jalr t9' calls left 61976c23afSVictor Kamenskyquiet_cmd_vdso_mips_check = VDSOCHK $@ 62d42f0c6aSTiezhu Yang cmd_vdso_mips_check = if $(OBJDUMP) --disassemble $@ | grep -E -h "jalr.*t9" > /dev/null; \ 63976c23afSVictor Kamensky then (echo >&2 "$@: PIC 'jalr t9' calls are not supported"; \ 64976c23afSVictor Kamensky rm -f $@; /bin/false); fi 65976c23afSVictor Kamensky 66ebb5e78cSAlex Smith# 67ebb5e78cSAlex Smith# Shared build commands. 68ebb5e78cSAlex Smith# 69ebb5e78cSAlex Smith 70cdab7e2cSVincenzo Frascinoquiet_cmd_vdsold_and_vdso_check = LD $@ 712ff90699SNathan Chancellor cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check); $(cmd_vdso_mips_check) 72ebb5e78cSAlex Smith 73b668970eSArnd Bergmannquiet_cmd_vdsoas_o_S = AS $@ 74b668970eSArnd Bergmann cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $< 75b668970eSArnd Bergmann 762afb9745SJames Hogan# Strip rule for the raw .so files 772afb9745SJames Hogan$(obj)/%.so.raw: OBJCOPYFLAGS := -S 782afb9745SJames Hogan$(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE 792afb9745SJames Hogan $(call if_changed,objcopy) 802afb9745SJames Hogan 815f2fb52fSMasahiro Yamadahostprogs := genvdso 82ebb5e78cSAlex Smith 83ebb5e78cSAlex Smithquiet_cmd_genvdso = GENVDSO $@ 84ebb5e78cSAlex Smithdefine cmd_genvdso 852afb9745SJames Hogan $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \ 862afb9745SJames Hogan $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME) 87ebb5e78cSAlex Smithendef 88ebb5e78cSAlex Smith 89ebb5e78cSAlex Smith# 90ebb5e78cSAlex Smith# Build native VDSO. 91ebb5e78cSAlex Smith# 92ebb5e78cSAlex Smith 93ebb5e78cSAlex Smithnative-abi := $(filter -mabi=%,$(KBUILD_CFLAGS)) 94ebb5e78cSAlex Smith 95ebb5e78cSAlex Smithtargets += $(obj-vdso-y) 962afb9745SJames Hogantargets += vdso.lds 972afb9745SJames Hogantargets += vdso.so.dbg.raw vdso.so.raw 982afb9745SJames Hogantargets += vdso.so.dbg vdso.so 992afb9745SJames Hogantargets += vdso-image.c 100ebb5e78cSAlex Smith 101ebb5e78cSAlex Smithobj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o) 102ebb5e78cSAlex Smith 103ebb5e78cSAlex Smith$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi) 104ebb5e78cSAlex Smith$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi) 105ebb5e78cSAlex Smith 106034827c7SJames Hogan$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi) 107ebb5e78cSAlex Smith 1082afb9745SJames Hogan$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE 109cdab7e2cSVincenzo Frascino $(call if_changed,vdsold_and_vdso_check) 110ebb5e78cSAlex Smith 1112afb9745SJames Hogan$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \ 1122afb9745SJames Hogan $(obj)/genvdso FORCE 113ebb5e78cSAlex Smith $(call if_changed,genvdso) 114ebb5e78cSAlex Smith 115ebb5e78cSAlex Smithobj-y += vdso-image.o 116ebb5e78cSAlex Smith 117ebb5e78cSAlex Smith# 118ebb5e78cSAlex Smith# Build O32 VDSO. 119ebb5e78cSAlex Smith# 120ebb5e78cSAlex Smith 121ebb5e78cSAlex Smith# Define these outside the ifdef to ensure they are picked up by clean. 122ebb5e78cSAlex Smithtargets += $(obj-vdso-y:%.o=%-o32.o) 1232afb9745SJames Hogantargets += vdso-o32.lds 1242afb9745SJames Hogantargets += vdso-o32.so.dbg.raw vdso-o32.so.raw 1252afb9745SJames Hogantargets += vdso-o32.so.dbg vdso-o32.so 1262afb9745SJames Hogantargets += vdso-o32-image.c 127ebb5e78cSAlex Smith 128ebb5e78cSAlex Smithifdef CONFIG_MIPS32_O32 129ebb5e78cSAlex Smith 130ebb5e78cSAlex Smithobj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o) 131ebb5e78cSAlex Smith 132ebb5e78cSAlex Smith$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32 133ebb5e78cSAlex Smith$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32 134ebb5e78cSAlex Smith 135ebb5e78cSAlex Smith$(obj)/%-o32.o: $(src)/%.S FORCE 136b668970eSArnd Bergmann $(call if_changed_dep,vdsoas_o_S) 137ebb5e78cSAlex Smith 138ebb5e78cSAlex Smith$(obj)/%-o32.o: $(src)/%.c FORCE 139ebb5e78cSAlex Smith $(call cmd,force_checksrc) 140ebb5e78cSAlex Smith $(call if_changed_rule,cc_o_c) 141ebb5e78cSAlex Smith 14267fc5dc8SPaul Burton$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32 143ebb5e78cSAlex Smith$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE 144ebb5e78cSAlex Smith $(call if_changed_dep,cpp_lds_S) 145ebb5e78cSAlex Smith 1462afb9745SJames Hogan$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE 147cdab7e2cSVincenzo Frascino $(call if_changed,vdsold_and_vdso_check) 148ebb5e78cSAlex Smith 149ebb5e78cSAlex Smith$(obj)/vdso-o32-image.c: VDSO_NAME := o32 1502afb9745SJames Hogan$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \ 1512afb9745SJames Hogan $(obj)/genvdso FORCE 152ebb5e78cSAlex Smith $(call if_changed,genvdso) 153ebb5e78cSAlex Smith 154ebb5e78cSAlex Smithobj-y += vdso-o32-image.o 155ebb5e78cSAlex Smith 156ebb5e78cSAlex Smithendif 157ebb5e78cSAlex Smith 158ebb5e78cSAlex Smith# 159ebb5e78cSAlex Smith# Build N32 VDSO. 160ebb5e78cSAlex Smith# 161ebb5e78cSAlex Smith 162ebb5e78cSAlex Smithtargets += $(obj-vdso-y:%.o=%-n32.o) 1632afb9745SJames Hogantargets += vdso-n32.lds 1642afb9745SJames Hogantargets += vdso-n32.so.dbg.raw vdso-n32.so.raw 1652afb9745SJames Hogantargets += vdso-n32.so.dbg vdso-n32.so 1662afb9745SJames Hogantargets += vdso-n32-image.c 167ebb5e78cSAlex Smith 168ebb5e78cSAlex Smithifdef CONFIG_MIPS32_N32 169ebb5e78cSAlex Smith 170ebb5e78cSAlex Smithobj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o) 171ebb5e78cSAlex Smith 172ebb5e78cSAlex Smith$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32 173ebb5e78cSAlex Smith$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32 174ebb5e78cSAlex Smith 175ebb5e78cSAlex Smith$(obj)/%-n32.o: $(src)/%.S FORCE 176b668970eSArnd Bergmann $(call if_changed_dep,vdsoas_o_S) 177ebb5e78cSAlex Smith 178ebb5e78cSAlex Smith$(obj)/%-n32.o: $(src)/%.c FORCE 179ebb5e78cSAlex Smith $(call cmd,force_checksrc) 180ebb5e78cSAlex Smith $(call if_changed_rule,cc_o_c) 181ebb5e78cSAlex Smith 18267fc5dc8SPaul Burton$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32 183ebb5e78cSAlex Smith$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE 184ebb5e78cSAlex Smith $(call if_changed_dep,cpp_lds_S) 185ebb5e78cSAlex Smith 1862afb9745SJames Hogan$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE 187cdab7e2cSVincenzo Frascino $(call if_changed,vdsold_and_vdso_check) 188ebb5e78cSAlex Smith 189ebb5e78cSAlex Smith$(obj)/vdso-n32-image.c: VDSO_NAME := n32 1902afb9745SJames Hogan$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \ 1912afb9745SJames Hogan $(obj)/genvdso FORCE 192ebb5e78cSAlex Smith $(call if_changed,genvdso) 193ebb5e78cSAlex Smith 194ebb5e78cSAlex Smithobj-y += vdso-n32-image.o 195ebb5e78cSAlex Smith 196ebb5e78cSAlex Smithendif 197ebb5e78cSAlex Smith 198ebb5e78cSAlex Smith# FIXME: Need install rule for debug. 199ebb5e78cSAlex Smith# Needs to deal with dependency for generation of dbg by cmd_genvdso... 200