1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 2 # Objects to go into the VDSO. 2 # Objects to go into the VDSO. 3 !! 3 obj-vdso-y := elf.o gettimeofday.o sigreturn.o 4 # Include the generic Makefile to check the bu << 5 include $(srctree)/lib/vdso/Makefile << 6 << 7 obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o << 8 vgetrandom-chacha.o sigreturn.o << 9 4 10 # Common compiler flags between ABIs. 5 # Common compiler flags between ABIs. 11 ccflags-vdso := \ 6 ccflags-vdso := \ 12 $(filter -I%,$(KBUILD_CFLAGS)) \ 7 $(filter -I%,$(KBUILD_CFLAGS)) \ 13 $(filter -E%,$(KBUILD_CFLAGS)) \ 8 $(filter -E%,$(KBUILD_CFLAGS)) \ >> 9 $(filter -mmicromips,$(KBUILD_CFLAGS)) \ 14 $(filter -march=%,$(KBUILD_CFLAGS)) \ 10 $(filter -march=%,$(KBUILD_CFLAGS)) \ 15 $(filter -m%-float,$(KBUILD_CFLAGS)) \ 11 $(filter -m%-float,$(KBUILD_CFLAGS)) \ 16 $(CLANG_FLAGS) \ !! 12 $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \ 17 -D__VDSO__ 13 -D__VDSO__ 18 14 >> 15 ifdef CONFIG_CC_IS_CLANG >> 16 ccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS)) >> 17 endif >> 18 19 cflags-vdso := $(ccflags-vdso) \ 19 cflags-vdso := $(ccflags-vdso) \ 20 -isystem $(shell $(CC) -print-file-nam << 21 $(filter -W%,$(filter-out -Wa$(comma)% 20 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 22 -O2 -g -fno-strict-aliasing -fno-commo !! 21 -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ 23 -fno-stack-protector -fno-jump-tables !! 22 -DDISABLE_BRANCH_PROFILING \ 24 $(call cc-option, -fno-asynchronous-un 23 $(call cc-option, -fno-asynchronous-unwind-tables) \ 25 $(call cc-option, -fno-stack-protector 24 $(call cc-option, -fno-stack-protector) 26 aflags-vdso := $(ccflags-vdso) \ 25 aflags-vdso := $(ccflags-vdso) \ 27 -D__ASSEMBLY__ -Wa,-gdwarf-2 26 -D__ASSEMBLY__ -Wa,-gdwarf-2 28 27 29 ifneq ($(c-gettimeofday-y),) !! 28 # 30 CFLAGS_vgettimeofday.o += -include $(c-getti !! 29 # For the pre-R6 code in arch/mips/vdso/vdso.h for locating 31 endif !! 30 # the base address of VDSO, the linker will emit a R_MIPS_PC32 32 !! 31 # relocation in binutils > 2.25 but it will fail with older versions 33 ifneq ($(c-getrandom-y),) !! 32 # because that relocation is not supported for that symbol. As a result 34 CFLAGS_vgetrandom.o += -include $(c-getrando !! 33 # of which we are forced to disable the VDSO symbols when building >> 34 # with < 2.25 binutils on pre-R6 kernels. For more references on why we >> 35 # can't use other methods to get the base address of VDSO please refer to >> 36 # the comments on that file. >> 37 # >> 38 ifndef CONFIG_CPU_MIPSR6 >> 39 ifeq ($(call ld-ifversion, -lt, 225000000, y),y) >> 40 $(warning MIPS VDSO requires binutils >= 2.25) >> 41 obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y)) >> 42 ccflags-vdso += -DDISABLE_MIPS_VDSO >> 43 endif 35 endif 44 endif 36 45 37 # VDSO linker flags. 46 # VDSO linker flags. 38 ldflags-y := -Bsymbolic --no-undefined -soname !! 47 VDSO_LDFLAGS := \ 39 $(filter -E%,$(KBUILD_CFLAGS)) -nostdl !! 48 -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \ 40 --hash-style=sysv --build-id -T !! 49 $(addprefix -Wl$(comma),$(filter -E%,$(KBUILD_CFLAGS))) \ >> 50 -nostdlib -shared -Wl,--hash-style=sysv -Wl,--build-id >> 51 >> 52 GCOV_PROFILE := n >> 53 UBSAN_SANITIZE := n 41 54 42 # 55 # 43 # Shared build commands. 56 # Shared build commands. 44 # 57 # 45 58 46 quiet_cmd_vdsold_and_vdso_check = LD $@ !! 59 quiet_cmd_vdsold = VDSO $@ 47 cmd_vdsold_and_vdso_check = $(cmd_ld); $ !! 60 cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \ >> 61 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ 48 62 49 quiet_cmd_vdsoas_o_S = AS $@ 63 quiet_cmd_vdsoas_o_S = AS $@ 50 cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o 64 cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $< 51 65 52 # Generate VDSO offsets using helper script !! 66 # Strip rule for the raw .so files 53 gen-vdsosym := $(src)/gen_vdso_offsets.sh !! 67 $(obj)/%.so.raw: OBJCOPYFLAGS := -S 54 quiet_cmd_vdsosym = VDSOSYM $@ !! 68 $(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE 55 cmd_vdsosym = $(NM) $< | $(gen-vdsosym) !! 69 $(call if_changed,objcopy) >> 70 >> 71 hostprogs-y := genvdso 56 72 57 include/generated/vdso-offsets.h: $(obj)/vdso. !! 73 quiet_cmd_genvdso = GENVDSO $@ 58 $(call if_changed,vdsosym) !! 74 define cmd_genvdso >> 75 $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \ >> 76 $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME) >> 77 endef 59 78 60 # 79 # 61 # Build native VDSO. 80 # Build native VDSO. 62 # 81 # 63 82 64 native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS 83 native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS)) 65 84 66 targets += $(obj-vdso-y) 85 targets += $(obj-vdso-y) 67 targets += vdso.lds vdso.so.dbg vdso.so !! 86 targets += vdso.lds >> 87 targets += vdso.so.dbg.raw vdso.so.raw >> 88 targets += vdso.so.dbg vdso.so >> 89 targets += vdso-image.c 68 90 69 obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o) 91 obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o) 70 92 71 $(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $ 93 $(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi) 72 $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $ 94 $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi) 73 95 74 $(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags- 96 $(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi) 75 97 76 $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso !! 98 $(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE 77 $(call if_changed,vdsold_and_vdso_chec !! 99 $(call if_changed,vdsold) 78 100 79 $(obj)/vdso.so: OBJCOPYFLAGS := -S !! 101 $(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \ 80 $(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE !! 102 $(obj)/genvdso FORCE 81 $(call if_changed,objcopy) !! 103 $(call if_changed,genvdso) >> 104 >> 105 obj-y += vdso-image.o >> 106 >> 107 # >> 108 # Build O32 VDSO. >> 109 # >> 110 >> 111 # Define these outside the ifdef to ensure they are picked up by clean. >> 112 targets += $(obj-vdso-y:%.o=%-o32.o) >> 113 targets += vdso-o32.lds >> 114 targets += vdso-o32.so.dbg.raw vdso-o32.so.raw >> 115 targets += vdso-o32.so.dbg vdso-o32.so >> 116 targets += vdso-o32-image.c >> 117 >> 118 ifdef CONFIG_MIPS32_O32 >> 119 >> 120 obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o) >> 121 >> 122 $(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32 >> 123 $(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32 >> 124 >> 125 $(obj)/%-o32.o: $(src)/%.S FORCE >> 126 $(call if_changed_dep,vdsoas_o_S) 82 127 83 obj-y += vdso.o !! 128 $(obj)/%-o32.o: $(src)/%.c FORCE >> 129 $(call cmd,force_checksrc) >> 130 $(call if_changed_rule,cc_o_c) >> 131 >> 132 $(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32 >> 133 $(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE >> 134 $(call if_changed_dep,cpp_lds_S) >> 135 >> 136 $(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE >> 137 $(call if_changed,vdsold) >> 138 >> 139 $(obj)/vdso-o32-image.c: VDSO_NAME := o32 >> 140 $(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \ >> 141 $(obj)/genvdso FORCE >> 142 $(call if_changed,genvdso) >> 143 >> 144 obj-y += vdso-o32-image.o >> 145 >> 146 endif >> 147 >> 148 # >> 149 # Build N32 VDSO. >> 150 # >> 151 >> 152 targets += $(obj-vdso-y:%.o=%-n32.o) >> 153 targets += vdso-n32.lds >> 154 targets += vdso-n32.so.dbg.raw vdso-n32.so.raw >> 155 targets += vdso-n32.so.dbg vdso-n32.so >> 156 targets += vdso-n32-image.c >> 157 >> 158 ifdef CONFIG_MIPS32_N32 >> 159 >> 160 obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o) >> 161 >> 162 $(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32 >> 163 $(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32 >> 164 >> 165 $(obj)/%-n32.o: $(src)/%.S FORCE >> 166 $(call if_changed_dep,vdsoas_o_S) >> 167 >> 168 $(obj)/%-n32.o: $(src)/%.c FORCE >> 169 $(call cmd,force_checksrc) >> 170 $(call if_changed_rule,cc_o_c) >> 171 >> 172 $(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32 >> 173 $(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE >> 174 $(call if_changed_dep,cpp_lds_S) >> 175 >> 176 $(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE >> 177 $(call if_changed,vdsold) >> 178 >> 179 $(obj)/vdso-n32-image.c: VDSO_NAME := n32 >> 180 $(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \ >> 181 $(obj)/genvdso FORCE >> 182 $(call if_changed,genvdso) >> 183 >> 184 obj-y += vdso-n32-image.o >> 185 >> 186 endif 84 187 85 $(obj)/vdso.o : $(obj)/vdso.so !! 188 # FIXME: Need install rule for debug. >> 189 # Needs to deal with dependency for generation of dbg by cmd_genvdso...
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.