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