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