~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/entry/vdso/Makefile

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 # SPDX-License-Identifier: GPL-2.0
  2 #
  3 # Building vDSO images for x86.
  4 #
  5 
  6 # Include the generic Makefile to check the built vDSO:
  7 include $(srctree)/lib/vdso/Makefile
  8 
  9 # Files to link into the vDSO:
 10 vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vgetrandom.o vgetrandom-chacha.o
 11 vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
 12 vobjs32-y += vdso32/vclock_gettime.o vdso32/vgetcpu.o
 13 vobjs-$(CONFIG_X86_SGX) += vsgx.o
 14 
 15 # Files to link into the kernel:
 16 obj-y                                           += vma.o extable.o
 17 
 18 # vDSO images to build:
 19 obj-$(CONFIG_X86_64)                            += vdso-image-64.o
 20 obj-$(CONFIG_X86_X32_ABI)                       += vdso-image-x32.o
 21 obj-$(CONFIG_COMPAT_32)                         += vdso-image-32.o vdso32-setup.o
 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-$(x).c vdso$(x).so vdso$(x).so.dbg)
 32 
 33 CPPFLAGS_vdso.lds += -P -C
 34 
 35 VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \
 36                         -z max-page-size=4096
 37 
 38 $(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
 39         $(call if_changed,vdso_and_check)
 40 
 41 HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi -I$(srctree)/arch/$(SUBARCH)/include/uapi
 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 $(obj)/vdso%.so $(obj)/vdso2c FORCE
 48         $(call if_changed,vdso2c)
 49 
 50 #
 51 # Don't omit frame pointers for ease of userspace debugging, but do
 52 # optimize sibling calls.
 53 #
 54 CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
 55        $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
 56        -fno-omit-frame-pointer -foptimize-sibling-calls \
 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 $(PADDING_CFLAGS) $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
 66 $(vobjs): KBUILD_AFLAGS += -DBUILD_VDSO
 67 
 68 #
 69 # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
 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 kernel data.
 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, which contains 64bit codes
 85 # so that it can reach 64bit address space with 64bit pointers.
 86 #
 87 
 88 CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
 89 VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \
 90                            -z max-page-size=4096
 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 vDSO.
 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-section __ex_table
108 $(obj)/%.so: $(obj)/%.so.dbg FORCE
109         $(call if_changed,objcopy)
110 
111 $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
112         $(call if_changed,vdso_and_check)
113 
114 CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
115 VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
116 
117 KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
118 $(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
119 $(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32
120 
121 KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
122 KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32))
123 KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
124 KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32))
125 KBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(KBUILD_CFLAGS_32))
126 KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
127 KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS_32))
128 KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS_32))
129 KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_CFI),$(KBUILD_CFLAGS_32))
130 KBUILD_CFLAGS_32 := $(filter-out $(PADDING_CFLAGS),$(KBUILD_CFLAGS_32))
131 KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic
132 KBUILD_CFLAGS_32 += -fno-stack-protector
133 KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
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_CFLAGS_32)
144 
145 $(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE
146         $(call if_changed,vdso_and_check)
147 
148 #
149 # The DSO images are built using a special linker script.
150 #
151 quiet_cmd_vdso = VDSO    $@
152       cmd_vdso = $(LD) -o $@ \
153                        $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
154                        -T $(filter %.lds,$^) $(filter %.o,$^) && \
155                  sh $(src)/checkundef.sh '$(NM)' '$@'
156 
157 VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 \
158         $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack
159 
160 quiet_cmd_vdso_and_check = VDSO    $@
161       cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php