1# SPDX-License-Identifier: GPL-2.0 2# Objects to go into the VDSO. 3obj-vdso-y := elf.o gettimeofday.o sigreturn.o 4 5# Common compiler flags between ABIs. 6ccflags-vdso := \ 7 $(filter -I%,$(KBUILD_CFLAGS)) \ 8 $(filter -E%,$(KBUILD_CFLAGS)) \ 9 $(filter -mmicromips,$(KBUILD_CFLAGS)) \ 10 $(filter -march=%,$(KBUILD_CFLAGS)) \ 11 -D__VDSO__ 12cflags-vdso := $(ccflags-vdso) \ 13 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 14 -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ 15 -DDISABLE_BRANCH_PROFILING \ 16 $(call cc-option, -fno-asynchronous-unwind-tables) \ 17 $(call cc-option, -fno-stack-protector) 18aflags-vdso := $(ccflags-vdso) \ 19 -D__ASSEMBLY__ -Wa,-gdwarf-2 20 21# 22# For the pre-R6 code in arch/mips/vdso/vdso.h for locating 23# the base address of VDSO, the linker will emit a R_MIPS_PC32 24# relocation in binutils > 2.25 but it will fail with older versions 25# because that relocation is not supported for that symbol. As a result 26# of which we are forced to disable the VDSO symbols when building 27# with < 2.25 binutils on pre-R6 kernels. For more references on why we 28# can't use other methods to get the base address of VDSO please refer to 29# the comments on that file. 30# 31ifndef CONFIG_CPU_MIPSR6 32 ifeq ($(call ld-ifversion, -lt, 225000000, y),y) 33 $(warning MIPS VDSO requires binutils >= 2.25) 34 obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y)) 35 ccflags-vdso += -DDISABLE_MIPS_VDSO 36 endif 37endif 38 39# VDSO linker flags. 40VDSO_LDFLAGS := \ 41 -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \ 42 -nostdlib -shared \ 43 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \ 44 $(call cc-ldoption, -Wl$(comma)--build-id) 45 46GCOV_PROFILE := n 47 48# 49# Shared build commands. 50# 51 52quiet_cmd_vdsold = VDSO $@ 53 cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \ 54 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ 55 56quiet_cmd_vdsoas_o_S = AS $@ 57 cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $< 58 59# Strip rule for the raw .so files 60$(obj)/%.so.raw: OBJCOPYFLAGS := -S 61$(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE 62 $(call if_changed,objcopy) 63 64hostprogs-y := genvdso 65 66quiet_cmd_genvdso = GENVDSO $@ 67define cmd_genvdso 68 $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \ 69 $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME) 70endef 71 72# 73# Build native VDSO. 74# 75 76native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS)) 77 78targets += $(obj-vdso-y) 79targets += vdso.lds 80targets += vdso.so.dbg.raw vdso.so.raw 81targets += vdso.so.dbg vdso.so 82targets += vdso-image.c 83 84obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o) 85 86$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi) 87$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi) 88 89$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi) 90 91$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE 92 $(call if_changed,vdsold) 93 94$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \ 95 $(obj)/genvdso FORCE 96 $(call if_changed,genvdso) 97 98obj-y += vdso-image.o 99 100# 101# Build O32 VDSO. 102# 103 104# Define these outside the ifdef to ensure they are picked up by clean. 105targets += $(obj-vdso-y:%.o=%-o32.o) 106targets += vdso-o32.lds 107targets += vdso-o32.so.dbg.raw vdso-o32.so.raw 108targets += vdso-o32.so.dbg vdso-o32.so 109targets += vdso-o32-image.c 110 111ifdef CONFIG_MIPS32_O32 112 113obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o) 114 115$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32 116$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32 117 118$(obj)/%-o32.o: $(src)/%.S FORCE 119 $(call if_changed_dep,vdsoas_o_S) 120 121$(obj)/%-o32.o: $(src)/%.c FORCE 122 $(call cmd,force_checksrc) 123 $(call if_changed_rule,cc_o_c) 124 125$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := -mabi=32 126$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE 127 $(call if_changed_dep,cpp_lds_S) 128 129$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE 130 $(call if_changed,vdsold) 131 132$(obj)/vdso-o32-image.c: VDSO_NAME := o32 133$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \ 134 $(obj)/genvdso FORCE 135 $(call if_changed,genvdso) 136 137obj-y += vdso-o32-image.o 138 139endif 140 141# 142# Build N32 VDSO. 143# 144 145targets += $(obj-vdso-y:%.o=%-n32.o) 146targets += vdso-n32.lds 147targets += vdso-n32.so.dbg.raw vdso-n32.so.raw 148targets += vdso-n32.so.dbg vdso-n32.so 149targets += vdso-n32-image.c 150 151ifdef CONFIG_MIPS32_N32 152 153obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o) 154 155$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32 156$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32 157 158$(obj)/%-n32.o: $(src)/%.S FORCE 159 $(call if_changed_dep,vdsoas_o_S) 160 161$(obj)/%-n32.o: $(src)/%.c FORCE 162 $(call cmd,force_checksrc) 163 $(call if_changed_rule,cc_o_c) 164 165$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := -mabi=n32 166$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE 167 $(call if_changed_dep,cpp_lds_S) 168 169$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE 170 $(call if_changed,vdsold) 171 172$(obj)/vdso-n32-image.c: VDSO_NAME := n32 173$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \ 174 $(obj)/genvdso FORCE 175 $(call if_changed,genvdso) 176 177obj-y += vdso-n32-image.o 178 179endif 180 181# FIXME: Need install rule for debug. 182# Needs to deal with dependency for generation of dbg by cmd_genvdso... 183