Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
0002 #
0003 # Building vDSO images for sparc.
0004 #
0005 
0006 VDSO64-$(CONFIG_SPARC64)        := y
0007 VDSOCOMPAT-$(CONFIG_COMPAT)     := y
0008 
0009 # files to link into the vdso
0010 vobjs-y := vdso-note.o vclock_gettime.o
0011 
0012 # files to link into kernel
0013 obj-y                           += vma.o
0014 
0015 # vDSO images to build
0016 vdso_img-$(VDSO64-y)            += 64
0017 vdso_img-$(VDSOCOMPAT-y)        += 32
0018 
0019 vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
0020 
0021 $(obj)/vdso.o: $(obj)/vdso.so
0022 
0023 targets += vdso.lds $(vobjs-y)
0024 
0025 # Build the vDSO image C files and link them in.
0026 vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o)
0027 vdso_img_cfiles := $(vdso_img-y:%=vdso-image-%.c)
0028 vdso_img_sodbg := $(vdso_img-y:%=vdso%.so.dbg)
0029 obj-y += $(vdso_img_objs)
0030 targets += $(vdso_img_cfiles)
0031 targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so)
0032 
0033 CPPFLAGS_vdso.lds += -P -C
0034 
0035 VDSO_LDFLAGS_vdso.lds = -m elf64_sparc -soname linux-vdso.so.1 --no-undefined \
0036                         -z max-page-size=8192
0037 
0038 $(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
0039         $(call if_changed,vdso)
0040 
0041 HOST_EXTRACFLAGS += -I$(srctree)/tools/include
0042 hostprogs += vdso2c 
0043 
0044 quiet_cmd_vdso2c = VDSO2C  $@
0045       cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
0046 
0047 $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
0048         $(call if_changed,vdso2c)
0049 
0050 #
0051 # Don't omit frame pointers for ease of userspace debugging, but do
0052 # optimize sibling calls.
0053 #
0054 CFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64 \
0055        $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
0056        -fno-omit-frame-pointer -foptimize-sibling-calls \
0057        -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
0058 
0059 SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 -fcall-used-g5 -fcall-used-g7
0060 
0061 $(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
0062 
0063 #
0064 # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
0065 #
0066 CFLAGS_REMOVE_vclock_gettime.o = -pg
0067 CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
0068 
0069 $(obj)/%.so: OBJCOPYFLAGS := -S
0070 $(obj)/%.so: $(obj)/%.so.dbg FORCE
0071         $(call if_changed,objcopy)
0072 
0073 CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
0074 VDSO_LDFLAGS_vdso32.lds = -m elf32_sparc -soname linux-gate.so.1
0075 
0076 #This makes sure the $(obj) subdirectory exists even though vdso32/
0077 #is not a kbuild sub-make subdirectory
0078 override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
0079 
0080 targets += vdso32/vdso32.lds
0081 targets += vdso32/vdso-note.o
0082 targets += vdso32/vclock_gettime.o
0083 
0084 KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
0085 $(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
0086 $(obj)/vdso32.so.dbg: asflags-$(CONFIG_SPARC64) += -m32
0087 
0088 KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
0089 KBUILD_CFLAGS_32 := $(filter-out -mcmodel=medlow,$(KBUILD_CFLAGS_32))
0090 KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
0091 KBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(KBUILD_CFLAGS_32))
0092 KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
0093 KBUILD_CFLAGS_32 := $(filter-out $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS_32))
0094 KBUILD_CFLAGS_32 += -m32 -msoft-float -fpic
0095 KBUILD_CFLAGS_32 += -fno-stack-protector
0096 KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
0097 KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
0098 KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
0099 KBUILD_CFLAGS_32 += -mv8plus
0100 $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
0101 
0102 $(obj)/vdso32.so.dbg: FORCE \
0103                         $(obj)/vdso32/vdso32.lds \
0104                         $(obj)/vdso32/vclock_gettime.o \
0105                         $(obj)/vdso32/vdso-note.o
0106                 $(call  if_changed,vdso)
0107 
0108 #
0109 # The DSO images are built using a special linker script.
0110 #
0111 quiet_cmd_vdso = VDSO    $@
0112       cmd_vdso = $(LD) -nostdlib -o $@ \
0113                        $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
0114                        -T $(filter %.lds,$^) $(filter %.o,$^) && \
0115                 sh $(srctree)/$(src)/checkundef.sh '$(OBJDUMP)' '$@'
0116 
0117 VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic
0118 GCOV_PROFILE := n
0119 
0120 #
0121 # Install the unstripped copies of vdso*.so.  If our toolchain supports
0122 # build-id, install .build-id links as well.
0123 #
0124 quiet_cmd_vdso_install = INSTALL $(@:install_%=%)
0125 define cmd_vdso_install
0126         cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \
0127         if readelf -n $< |grep -q 'Build ID'; then \
0128           buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
0129           first=`echo $$buildid | cut -b-2`; \
0130           last=`echo $$buildid | cut -b3-`; \
0131           mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
0132           ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
0133         fi
0134 endef
0135 
0136 vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%)
0137 
0138 $(MODLIB)/vdso: FORCE
0139         @mkdir -p $(MODLIB)/vdso
0140 
0141 $(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE
0142         $(call cmd,vdso_install)
0143 
0144 PHONY += vdso_install $(vdso_img_insttargets)
0145 vdso_install: $(vdso_img_insttargets) FORCE