Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 # Objects to go into the VDSO.
0003 
0004 # Sanitizer runtimes are unavailable and cannot be linked here.
0005  KCSAN_SANITIZE                 := n
0006 
0007 # Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
0008 # the inclusion of generic Makefile.
0009 ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT
0010 include $(srctree)/lib/vdso/Makefile
0011 
0012 obj-vdso-y := elf.o vgettimeofday.o sigreturn.o
0013 
0014 # Common compiler flags between ABIs.
0015 ccflags-vdso := \
0016         $(filter -I%,$(KBUILD_CFLAGS)) \
0017         $(filter -E%,$(KBUILD_CFLAGS)) \
0018         $(filter -mmicromips,$(KBUILD_CFLAGS)) \
0019         $(filter -march=%,$(KBUILD_CFLAGS)) \
0020         $(filter -m%-float,$(KBUILD_CFLAGS)) \
0021         $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \
0022         $(CLANG_FLAGS) \
0023         -D__VDSO__
0024 
0025 ifndef CONFIG_64BIT
0026 ccflags-vdso += -DBUILD_VDSO32
0027 endif
0028 
0029 #
0030 # The -fno-jump-tables flag only prevents the compiler from generating
0031 # jump tables but does not prevent the compiler from emitting absolute
0032 # offsets.
0033 cflags-vdso := $(ccflags-vdso) \
0034         $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
0035         -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
0036         -mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \
0037         -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
0038         $(call cc-option, -fno-asynchronous-unwind-tables)
0039 aflags-vdso := $(ccflags-vdso) \
0040         -D__ASSEMBLY__ -Wa,-gdwarf-2
0041 
0042 ifneq ($(c-gettimeofday-y),)
0043 CFLAGS_vgettimeofday.o = -include $(c-gettimeofday-y)
0044 
0045 # config-n32-o32-env.c prepares the environment to build a 32bit vDSO
0046 # library on a 64bit kernel.
0047 # Note: Needs to be included before than the generic library.
0048 CFLAGS_vgettimeofday-o32.o = -include $(srctree)/$(src)/config-n32-o32-env.c -include $(c-gettimeofday-y) 
0049 CFLAGS_vgettimeofday-n32.o = -include $(srctree)/$(src)/config-n32-o32-env.c -include $(c-gettimeofday-y) 
0050 endif
0051 
0052 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE)
0053 
0054 ifdef CONFIG_MIPS_DISABLE_VDSO
0055   ifndef CONFIG_MIPS_LD_CAN_LINK_VDSO
0056     $(warning MIPS VDSO requires binutils >= 2.25)
0057   endif
0058   obj-vdso-y := $(filter-out vgettimeofday.o, $(obj-vdso-y))
0059 endif
0060 
0061 # VDSO linker flags.
0062 ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
0063         $(filter -E%,$(KBUILD_CFLAGS)) -shared \
0064         -G 0 --eh-frame-hdr --hash-style=sysv --build-id=sha1 -T
0065 
0066 CFLAGS_REMOVE_vdso.o = $(CC_FLAGS_FTRACE)
0067 
0068 GCOV_PROFILE := n
0069 UBSAN_SANITIZE := n
0070 KCOV_INSTRUMENT := n
0071 
0072 # Check that we don't have PIC 'jalr t9' calls left
0073 quiet_cmd_vdso_mips_check = VDSOCHK $@
0074       cmd_vdso_mips_check = if $(OBJDUMP) --disassemble $@ | egrep -h "jalr.*t9" > /dev/null; \
0075                        then (echo >&2 "$@: PIC 'jalr t9' calls are not supported"; \
0076                              rm -f $@; /bin/false); fi
0077 
0078 #
0079 # Shared build commands.
0080 #
0081 
0082 quiet_cmd_vdsold_and_vdso_check = LD      $@
0083       cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check); $(cmd_vdso_mips_check)
0084 
0085 quiet_cmd_vdsoas_o_S = AS      $@
0086       cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
0087 
0088 # Strip rule for the raw .so files
0089 $(obj)/%.so.raw: OBJCOPYFLAGS := -S
0090 $(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE
0091         $(call if_changed,objcopy)
0092 
0093 hostprogs := genvdso
0094 
0095 quiet_cmd_genvdso = GENVDSO $@
0096 define cmd_genvdso
0097         $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \
0098         $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME)
0099 endef
0100 
0101 #
0102 # Build native VDSO.
0103 #
0104 
0105 native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
0106 
0107 targets += $(obj-vdso-y)
0108 targets += vdso.lds
0109 targets += vdso.so.dbg.raw vdso.so.raw
0110 targets += vdso.so.dbg vdso.so
0111 targets += vdso-image.c
0112 
0113 obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
0114 
0115 $(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
0116 $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
0117 
0118 $(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
0119 
0120 $(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
0121         $(call if_changed,vdsold_and_vdso_check)
0122 
0123 $(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \
0124                      $(obj)/genvdso FORCE
0125         $(call if_changed,genvdso)
0126 
0127 obj-y += vdso-image.o
0128 
0129 #
0130 # Build O32 VDSO.
0131 #
0132 
0133 # Define these outside the ifdef to ensure they are picked up by clean.
0134 targets += $(obj-vdso-y:%.o=%-o32.o)
0135 targets += vdso-o32.lds
0136 targets += vdso-o32.so.dbg.raw vdso-o32.so.raw
0137 targets += vdso-o32.so.dbg vdso-o32.so
0138 targets += vdso-o32-image.c
0139 
0140 ifdef CONFIG_MIPS32_O32
0141 
0142 obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
0143 
0144 $(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
0145 $(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
0146 
0147 $(obj)/%-o32.o: $(src)/%.S FORCE
0148         $(call if_changed_dep,vdsoas_o_S)
0149 
0150 $(obj)/%-o32.o: $(src)/%.c FORCE
0151         $(call cmd,force_checksrc)
0152         $(call if_changed_rule,cc_o_c)
0153 
0154 $(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32
0155 $(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
0156         $(call if_changed_dep,cpp_lds_S)
0157 
0158 $(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
0159         $(call if_changed,vdsold_and_vdso_check)
0160 
0161 $(obj)/vdso-o32-image.c: VDSO_NAME := o32
0162 $(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \
0163                          $(obj)/genvdso FORCE
0164         $(call if_changed,genvdso)
0165 
0166 obj-y += vdso-o32-image.o
0167 
0168 endif
0169 
0170 #
0171 # Build N32 VDSO.
0172 #
0173 
0174 targets += $(obj-vdso-y:%.o=%-n32.o)
0175 targets += vdso-n32.lds
0176 targets += vdso-n32.so.dbg.raw vdso-n32.so.raw
0177 targets += vdso-n32.so.dbg vdso-n32.so
0178 targets += vdso-n32-image.c
0179 
0180 ifdef CONFIG_MIPS32_N32
0181 
0182 obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o)
0183 
0184 $(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32
0185 $(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32
0186 
0187 $(obj)/%-n32.o: $(src)/%.S FORCE
0188         $(call if_changed_dep,vdsoas_o_S)
0189 
0190 $(obj)/%-n32.o: $(src)/%.c FORCE
0191         $(call cmd,force_checksrc)
0192         $(call if_changed_rule,cc_o_c)
0193 
0194 $(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32
0195 $(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
0196         $(call if_changed_dep,cpp_lds_S)
0197 
0198 $(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
0199         $(call if_changed,vdsold_and_vdso_check)
0200 
0201 $(obj)/vdso-n32-image.c: VDSO_NAME := n32
0202 $(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \
0203                          $(obj)/genvdso FORCE
0204         $(call if_changed,genvdso)
0205 
0206 obj-y += vdso-n32-image.o
0207 
0208 endif
0209 
0210 # FIXME: Need install rule for debug.
0211 # Needs to deal with dependency for generation of dbg by cmd_genvdso...