1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only 29a08862aSNagarathnam Muthusamy# 39a08862aSNagarathnam Muthusamy# Building vDSO images for sparc. 49a08862aSNagarathnam Muthusamy# 59a08862aSNagarathnam Muthusamy 69a08862aSNagarathnam Muthusamy# files to link into the vdso 79a08862aSNagarathnam Muthusamyvobjs-y := vdso-note.o vclock_gettime.o 89a08862aSNagarathnam Muthusamy 99a08862aSNagarathnam Muthusamy# files to link into kernel 109a08862aSNagarathnam Muthusamyobj-y += vma.o 119a08862aSNagarathnam Muthusamy 129a08862aSNagarathnam Muthusamy# vDSO images to build 13918d8f94SMasahiro Yamadaobj-$(CONFIG_SPARC64) += vdso-image-64.o 14918d8f94SMasahiro Yamadaobj-$(CONFIG_COMPAT) += vdso-image-32.o 159a08862aSNagarathnam Muthusamy 16d821f8a2SMasahiro Yamadavobjs := $(addprefix $(obj)/, $(vobjs-y)) 179a08862aSNagarathnam Muthusamy 189a08862aSNagarathnam Muthusamy$(obj)/vdso.o: $(obj)/vdso.so 199a08862aSNagarathnam Muthusamy 209a08862aSNagarathnam Muthusamytargets += vdso.lds $(vobjs-y) 2153c5adffSMasahiro Yamadatargets += $(foreach x, 32 64, vdso-image-$(x).c vdso$(x).so vdso$(x).so.dbg) 229a08862aSNagarathnam Muthusamy 238cf7765dSMasahiro YamadaCPPFLAGS_vdso.lds += -P -C 249a08862aSNagarathnam Muthusamy 253c2b2d94SDavid S. MillerVDSO_LDFLAGS_vdso.lds = -m elf64_sparc -soname linux-vdso.so.1 --no-undefined \ 260ff70f62Sndesaulniers@google.com -z max-page-size=8192 279a08862aSNagarathnam Muthusamy 288cf7765dSMasahiro Yamada$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE 299a08862aSNagarathnam Muthusamy $(call if_changed,vdso) 309a08862aSNagarathnam Muthusamy 319a08862aSNagarathnam MuthusamyHOST_EXTRACFLAGS += -I$(srctree)/tools/include 325f2fb52fSMasahiro Yamadahostprogs += vdso2c 339a08862aSNagarathnam Muthusamy 349a08862aSNagarathnam Muthusamyquiet_cmd_vdso2c = VDSO2C $@ 358cf7765dSMasahiro Yamada cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@ 369a08862aSNagarathnam Muthusamy 379a08862aSNagarathnam Muthusamy$(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE 389a08862aSNagarathnam Muthusamy $(call if_changed,vdso2c) 399a08862aSNagarathnam Muthusamy 409a08862aSNagarathnam Muthusamy# 419a08862aSNagarathnam Muthusamy# Don't omit frame pointers for ease of userspace debugging, but do 429a08862aSNagarathnam Muthusamy# optimize sibling calls. 439a08862aSNagarathnam Muthusamy# 445615edccSDavid S. MillerCFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64 \ 45893ab004SMasahiro Yamada $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \ 465615edccSDavid S. Miller -fno-omit-frame-pointer -foptimize-sibling-calls \ 4744231b7fSDavid S. Miller -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO 489a08862aSNagarathnam Muthusamy 49*69114be1SKoakumaSPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) 505615edccSDavid S. Miller 51613f4b3eSKees Cook$(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) 529a08862aSNagarathnam Muthusamy 539a08862aSNagarathnam Muthusamy# 549a08862aSNagarathnam Muthusamy# vDSO code runs in userspace and -pg doesn't help with profiling anyway. 559a08862aSNagarathnam Muthusamy# 569a08862aSNagarathnam MuthusamyCFLAGS_REMOVE_vclock_gettime.o = -pg 5753472914SMasahiro YamadaCFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg 589a08862aSNagarathnam Muthusamy 599a08862aSNagarathnam Muthusamy$(obj)/%.so: OBJCOPYFLAGS := -S 60269fe565SMasahiro Yamada$(obj)/%.so: $(obj)/%.so.dbg FORCE 619a08862aSNagarathnam Muthusamy $(call if_changed,objcopy) 629a08862aSNagarathnam Muthusamy 6353472914SMasahiro YamadaCPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds) 643c2b2d94SDavid S. MillerVDSO_LDFLAGS_vdso32.lds = -m elf32_sparc -soname linux-gate.so.1 659a08862aSNagarathnam Muthusamy 669a08862aSNagarathnam Muthusamy#This makes sure the $(obj) subdirectory exists even though vdso32/ 679a08862aSNagarathnam Muthusamy#is not a kbuild sub-make subdirectory 689a08862aSNagarathnam Muthusamyoverride obj-dirs = $(dir $(obj)) $(obj)/vdso32/ 699a08862aSNagarathnam Muthusamy 709a08862aSNagarathnam Muthusamytargets += vdso32/vdso32.lds 719a08862aSNagarathnam Muthusamytargets += vdso32/vdso-note.o 729a08862aSNagarathnam Muthusamytargets += vdso32/vclock_gettime.o 739a08862aSNagarathnam Muthusamy 749a08862aSNagarathnam MuthusamyKBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO 759a08862aSNagarathnam Muthusamy$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) 769a08862aSNagarathnam Muthusamy$(obj)/vdso32.so.dbg: asflags-$(CONFIG_SPARC64) += -m32 779a08862aSNagarathnam Muthusamy 789a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) 799a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 := $(filter-out -mcmodel=medlow,$(KBUILD_CFLAGS_32)) 809a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32)) 81613f4b3eSKees CookKBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(KBUILD_CFLAGS_32)) 829a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32)) 835615edccSDavid S. MillerKBUILD_CFLAGS_32 := $(filter-out $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS_32)) 845615edccSDavid S. MillerKBUILD_CFLAGS_32 += -m32 -msoft-float -fpic 85893ab004SMasahiro YamadaKBUILD_CFLAGS_32 += -fno-stack-protector 869a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) 879a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 += -fno-omit-frame-pointer 889a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING 899a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 += -mv8plus 909a08862aSNagarathnam Muthusamy$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) 919a08862aSNagarathnam Muthusamy 929a08862aSNagarathnam Muthusamy$(obj)/vdso32.so.dbg: FORCE \ 939a08862aSNagarathnam Muthusamy $(obj)/vdso32/vdso32.lds \ 949a08862aSNagarathnam Muthusamy $(obj)/vdso32/vclock_gettime.o \ 959a08862aSNagarathnam Muthusamy $(obj)/vdso32/vdso-note.o 969a08862aSNagarathnam Muthusamy $(call if_changed,vdso) 979a08862aSNagarathnam Muthusamy 989a08862aSNagarathnam Muthusamy# 999a08862aSNagarathnam Muthusamy# The DSO images are built using a special linker script. 1009a08862aSNagarathnam Muthusamy# 1019a08862aSNagarathnam Muthusamyquiet_cmd_vdso = VDSO $@ 1023c2b2d94SDavid S. Miller cmd_vdso = $(LD) -nostdlib -o $@ \ 1039a08862aSNagarathnam Muthusamy $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ 104ecd4c19fSDavid S. Miller -T $(filter %.lds,$^) $(filter %.o,$^) && \ 105b1992c37SMasahiro Yamada sh $(src)/checkundef.sh '$(OBJDUMP)' '$@' 1069a08862aSNagarathnam Muthusamy 107a9684337SBill WendlingVDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic 108