1 # SPDX-License-Identifier: GPL-2.0 2 # 3 # Building vDSO images for x86. 4 # 5 6 # Include the generic Makefile to check the bu 7 include $(srctree)/lib/vdso/Makefile 8 9 # Files to link into the vDSO: 10 vobjs-y := vdso-note.o vclock_gettime.o vgetcp 11 vobjs32-y := vdso32/note.o vdso32/system_call. 12 vobjs32-y += vdso32/vclock_gettime.o vdso32/vg 13 vobjs-$(CONFIG_X86_SGX) += vsgx.o 14 15 # Files to link into the kernel: 16 obj-y 17 18 # vDSO images to build: 19 obj-$(CONFIG_X86_64) 20 obj-$(CONFIG_X86_X32_ABI) 21 obj-$(CONFIG_COMPAT_32) 22 23 vobjs := $(addprefix $(obj)/, $(vobjs-y)) 24 vobjs32 := $(addprefix $(obj)/, $(vobjs32-y)) 25 26 $(obj)/vdso.o: $(obj)/vdso.so 27 28 targets += vdso.lds $(vobjs-y) 29 targets += vdso32/vdso32.lds $(vobjs32-y) 30 31 targets += $(foreach x, 64 x32 32, vdso-image- 32 33 CPPFLAGS_vdso.lds += -P -C 34 35 VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname 36 -z max-page-size=4096 37 38 $(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) 39 $(call if_changed,vdso_and_check) 40 41 HOST_EXTRACFLAGS += -I$(srctree)/tools/include 42 hostprogs += vdso2c 43 44 quiet_cmd_vdso2c = VDSO2C $@ 45 cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg= 46 47 $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(o 48 $(call if_changed,vdso2c) 49 50 # 51 # Don't omit frame pointers for ease of usersp 52 # optimize sibling calls. 53 # 54 CFL := $(PROFILING) -mcmodel=small -fPIC -O2 - 55 $(filter -g%,$(KBUILD_CFLAGS)) -fno-sta 56 -fno-omit-frame-pointer -foptimize-sibl 57 -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO 58 59 ifdef CONFIG_MITIGATION_RETPOLINE 60 ifneq ($(RETPOLINE_VDSO_CFLAGS),) 61 CFL += $(RETPOLINE_VDSO_CFLAGS) 62 endif 63 endif 64 65 $(vobjs): KBUILD_CFLAGS := $(filter-out $(PADD 66 $(vobjs): KBUILD_AFLAGS += -DBUILD_VDSO 67 68 # 69 # vDSO code runs in userspace and -pg doesn't 70 # 71 CFLAGS_REMOVE_vclock_gettime.o = -pg 72 CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg 73 CFLAGS_REMOVE_vgetcpu.o = -pg 74 CFLAGS_REMOVE_vdso32/vgetcpu.o = -pg 75 CFLAGS_REMOVE_vsgx.o = -pg 76 CFLAGS_REMOVE_vgetrandom.o = -pg 77 78 # 79 # X32 processes use x32 vDSO to access 64bit k 80 # 81 # Build x32 vDSO image: 82 # 1. Compile x32 vDSO as 64bit. 83 # 2. Convert object files to x32. 84 # 3. Build x32 VDSO image with x32 objects, wh 85 # so that it can reach 64bit address space wit 86 # 87 88 CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds) 89 VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -so 90 -z max-page-size=40 91 92 # x32-rebranded versions 93 vobjx32s-y := $(vobjs-y:.o=-x32.o) 94 95 # same thing, but in the output directory 96 vobjx32s := $(addprefix $(obj)/, $(vobjx32s-y) 97 98 # Convert 64bit object file to x32 for x32 vDS 99 quiet_cmd_x32 = X32 $@ 100 cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< 101 102 $(obj)/%-x32.o: $(obj)/%.o FORCE 103 $(call if_changed,x32) 104 105 targets += vdsox32.lds $(vobjx32s-y) 106 107 $(obj)/%.so: OBJCOPYFLAGS := -S --remove-secti 108 $(obj)/%.so: $(obj)/%.so.dbg FORCE 109 $(call if_changed,objcopy) 110 111 $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vo 112 $(call if_changed,vdso_and_check) 113 114 CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.l 115 VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname 116 117 KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD 118 $(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD 119 $(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) 120 121 KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD 122 KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kern 123 KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KB 124 KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KB 125 KBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_ 126 KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS 127 KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_C 128 KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_LT 129 KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_CF 130 KBUILD_CFLAGS_32 := $(filter-out $(PADDING_CFL 131 KBUILD_CFLAGS_32 += -m32 -msoft-float -mregpar 132 KBUILD_CFLAGS_32 += -fno-stack-protector 133 KBUILD_CFLAGS_32 += $(call cc-option, -foptimi 134 KBUILD_CFLAGS_32 += -fno-omit-frame-pointer 135 KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING 136 137 ifdef CONFIG_MITIGATION_RETPOLINE 138 ifneq ($(RETPOLINE_VDSO_CFLAGS),) 139 KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS) 140 endif 141 endif 142 143 $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD 144 145 $(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds 146 $(call if_changed,vdso_and_check) 147 148 # 149 # The DSO images are built using a special lin 150 # 151 quiet_cmd_vdso = VDSO $@ 152 cmd_vdso = $(LD) -o $@ \ 153 $(VDSO_LDFLAGS) $(VDSO_ 154 -T $(filter %.lds,$^) $ 155 sh $(src)/checkundef.sh '$(NM 156 157 VDSO_LDFLAGS = -shared --hash-style=both --bui 158 $(call ld-option, --eh-frame-hdr) -Bsy 159 160 quiet_cmd_vdso_and_check = VDSO $@ 161 cmd_vdso_and_check = $(cmd_vdso); $(cmd_
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.