1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only 29a08862aSNagarathnam Muthusamy# 39a08862aSNagarathnam Muthusamy# Building vDSO images for sparc. 49a08862aSNagarathnam Muthusamy# 59a08862aSNagarathnam Muthusamy 69a08862aSNagarathnam MuthusamyVDSO64-$(CONFIG_SPARC64) := y 79a08862aSNagarathnam MuthusamyVDSOCOMPAT-$(CONFIG_COMPAT) := y 89a08862aSNagarathnam Muthusamy 99a08862aSNagarathnam Muthusamy# files to link into the vdso 109a08862aSNagarathnam Muthusamyvobjs-y := vdso-note.o vclock_gettime.o 119a08862aSNagarathnam Muthusamy 129a08862aSNagarathnam Muthusamy# files to link into kernel 139a08862aSNagarathnam Muthusamyobj-y += vma.o 149a08862aSNagarathnam Muthusamy 159a08862aSNagarathnam Muthusamy# vDSO images to build 169a08862aSNagarathnam Muthusamyvdso_img-$(VDSO64-y) += 64 179a08862aSNagarathnam Muthusamyvdso_img-$(VDSOCOMPAT-y) += 32 189a08862aSNagarathnam Muthusamy 199a08862aSNagarathnam Muthusamyvobjs := $(foreach F,$(vobjs-y),$(obj)/$F) 209a08862aSNagarathnam Muthusamy 219a08862aSNagarathnam Muthusamy$(obj)/vdso.o: $(obj)/vdso.so 229a08862aSNagarathnam Muthusamy 239a08862aSNagarathnam Muthusamytargets += vdso.lds $(vobjs-y) 249a08862aSNagarathnam Muthusamy 259a08862aSNagarathnam Muthusamy# Build the vDSO image C files and link them in. 269a08862aSNagarathnam Muthusamyvdso_img_objs := $(vdso_img-y:%=vdso-image-%.o) 279a08862aSNagarathnam Muthusamyvdso_img_cfiles := $(vdso_img-y:%=vdso-image-%.c) 289a08862aSNagarathnam Muthusamyvdso_img_sodbg := $(vdso_img-y:%=vdso%.so.dbg) 299a08862aSNagarathnam Muthusamyobj-y += $(vdso_img_objs) 309a08862aSNagarathnam Muthusamytargets += $(vdso_img_cfiles) 3154a702f7SMasahiro Yamadatargets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so) 329a08862aSNagarathnam Muthusamy 338cf7765dSMasahiro YamadaCPPFLAGS_vdso.lds += -P -C 349a08862aSNagarathnam Muthusamy 353c2b2d94SDavid S. MillerVDSO_LDFLAGS_vdso.lds = -m elf64_sparc -soname linux-vdso.so.1 --no-undefined \ 360ff70f62Sndesaulniers@google.com -z max-page-size=8192 379a08862aSNagarathnam Muthusamy 388cf7765dSMasahiro Yamada$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE 399a08862aSNagarathnam Muthusamy $(call if_changed,vdso) 409a08862aSNagarathnam Muthusamy 419a08862aSNagarathnam MuthusamyHOST_EXTRACFLAGS += -I$(srctree)/tools/include 425f2fb52fSMasahiro Yamadahostprogs += vdso2c 439a08862aSNagarathnam Muthusamy 449a08862aSNagarathnam Muthusamyquiet_cmd_vdso2c = VDSO2C $@ 458cf7765dSMasahiro Yamada cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@ 469a08862aSNagarathnam Muthusamy 479a08862aSNagarathnam Muthusamy$(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE 489a08862aSNagarathnam Muthusamy $(call if_changed,vdso2c) 499a08862aSNagarathnam Muthusamy 509a08862aSNagarathnam Muthusamy# 519a08862aSNagarathnam Muthusamy# Don't omit frame pointers for ease of userspace debugging, but do 529a08862aSNagarathnam Muthusamy# optimize sibling calls. 539a08862aSNagarathnam Muthusamy# 545615edccSDavid S. MillerCFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64 \ 55893ab004SMasahiro Yamada $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \ 565615edccSDavid S. Miller -fno-omit-frame-pointer -foptimize-sibling-calls \ 5744231b7fSDavid S. Miller -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO 589a08862aSNagarathnam Muthusamy 595615edccSDavid S. MillerSPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 -fcall-used-g5 -fcall-used-g7 605615edccSDavid S. Miller 61*613f4b3eSKees Cook$(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) 629a08862aSNagarathnam Muthusamy 639a08862aSNagarathnam Muthusamy# 649a08862aSNagarathnam Muthusamy# vDSO code runs in userspace and -pg doesn't help with profiling anyway. 659a08862aSNagarathnam Muthusamy# 669a08862aSNagarathnam MuthusamyCFLAGS_REMOVE_vclock_gettime.o = -pg 6753472914SMasahiro YamadaCFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg 689a08862aSNagarathnam Muthusamy 699a08862aSNagarathnam Muthusamy$(obj)/%.so: OBJCOPYFLAGS := -S 70269fe565SMasahiro Yamada$(obj)/%.so: $(obj)/%.so.dbg FORCE 719a08862aSNagarathnam Muthusamy $(call if_changed,objcopy) 729a08862aSNagarathnam Muthusamy 7353472914SMasahiro YamadaCPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds) 743c2b2d94SDavid S. MillerVDSO_LDFLAGS_vdso32.lds = -m elf32_sparc -soname linux-gate.so.1 759a08862aSNagarathnam Muthusamy 769a08862aSNagarathnam Muthusamy#This makes sure the $(obj) subdirectory exists even though vdso32/ 779a08862aSNagarathnam Muthusamy#is not a kbuild sub-make subdirectory 789a08862aSNagarathnam Muthusamyoverride obj-dirs = $(dir $(obj)) $(obj)/vdso32/ 799a08862aSNagarathnam Muthusamy 809a08862aSNagarathnam Muthusamytargets += vdso32/vdso32.lds 819a08862aSNagarathnam Muthusamytargets += vdso32/vdso-note.o 829a08862aSNagarathnam Muthusamytargets += vdso32/vclock_gettime.o 839a08862aSNagarathnam Muthusamy 849a08862aSNagarathnam MuthusamyKBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO 859a08862aSNagarathnam Muthusamy$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) 869a08862aSNagarathnam Muthusamy$(obj)/vdso32.so.dbg: asflags-$(CONFIG_SPARC64) += -m32 879a08862aSNagarathnam Muthusamy 889a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) 899a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 := $(filter-out -mcmodel=medlow,$(KBUILD_CFLAGS_32)) 909a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32)) 91*613f4b3eSKees CookKBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(KBUILD_CFLAGS_32)) 929a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32)) 935615edccSDavid S. MillerKBUILD_CFLAGS_32 := $(filter-out $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS_32)) 945615edccSDavid S. MillerKBUILD_CFLAGS_32 += -m32 -msoft-float -fpic 95893ab004SMasahiro YamadaKBUILD_CFLAGS_32 += -fno-stack-protector 969a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) 979a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 += -fno-omit-frame-pointer 989a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING 999a08862aSNagarathnam MuthusamyKBUILD_CFLAGS_32 += -mv8plus 1009a08862aSNagarathnam Muthusamy$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) 1019a08862aSNagarathnam Muthusamy 1029a08862aSNagarathnam Muthusamy$(obj)/vdso32.so.dbg: FORCE \ 1039a08862aSNagarathnam Muthusamy $(obj)/vdso32/vdso32.lds \ 1049a08862aSNagarathnam Muthusamy $(obj)/vdso32/vclock_gettime.o \ 1059a08862aSNagarathnam Muthusamy $(obj)/vdso32/vdso-note.o 1069a08862aSNagarathnam Muthusamy $(call if_changed,vdso) 1079a08862aSNagarathnam Muthusamy 1089a08862aSNagarathnam Muthusamy# 1099a08862aSNagarathnam Muthusamy# The DSO images are built using a special linker script. 1109a08862aSNagarathnam Muthusamy# 1119a08862aSNagarathnam Muthusamyquiet_cmd_vdso = VDSO $@ 1123c2b2d94SDavid S. Miller cmd_vdso = $(LD) -nostdlib -o $@ \ 1139a08862aSNagarathnam Muthusamy $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ 114ecd4c19fSDavid S. Miller -T $(filter %.lds,$^) $(filter %.o,$^) && \ 115ecd4c19fSDavid S. Miller sh $(srctree)/$(src)/checkundef.sh '$(OBJDUMP)' '$@' 1169a08862aSNagarathnam Muthusamy 117a9684337SBill WendlingVDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic 1189a08862aSNagarathnam MuthusamyGCOV_PROFILE := n 119