hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/arch/x86/Makefile
....@@ -31,13 +31,13 @@
3131 CODE16GCC_CFLAGS := -m32 -Wa,$(srctree)/arch/x86/boot/code16gcc.h
3232 M16_CFLAGS := $(call cc-option, -m16, $(CODE16GCC_CFLAGS))
3333
34
-REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -DDISABLE_BRANCH_PROFILING \
34
+REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
3535 -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
3636 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
3737 -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)
3838
39
-REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
40
-REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
39
+REALMODE_CFLAGS += -ffreestanding
40
+REALMODE_CFLAGS += -fno-stack-protector
4141 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member)
4242 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
4343 REALMODE_CFLAGS += $(CLANG_FLAGS)
....@@ -47,10 +47,6 @@
4747 # and a 64 bit version to simplify shared Makefiles.
4848 # e.g.: obj-y += foo_$(BITS).o
4949 export BITS
50
-
51
-ifdef CONFIG_X86_NEED_RELOCS
52
- LDFLAGS_vmlinux := --emit-relocs --discard-none
53
-endif
5450
5551 #
5652 # Prevent GCC from generating any FP code by mistake.
....@@ -135,10 +131,6 @@
135131
136132 KBUILD_CFLAGS += -mno-red-zone
137133 KBUILD_CFLAGS += -mcmodel=kernel
138
-
139
- # -funit-at-a-time shrinks the kernel .text considerably
140
- # unfortunately it makes reading oopses harder.
141
- KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
142134 endif
143135
144136 ifdef CONFIG_X86_X32
....@@ -185,49 +177,6 @@
185177 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
186178 endif
187179
188
-# Stackpointer is addressed different for 32 bit and 64 bit x86
189
-sp-$(CONFIG_X86_32) := esp
190
-sp-$(CONFIG_X86_64) := rsp
191
-
192
-# do binutils support CFI?
193
-cfi := $(call as-instr,.cfi_startproc\n.cfi_rel_offset $(sp-y)$(comma)0\n.cfi_endproc,-DCONFIG_AS_CFI=1)
194
-# is .cfi_signal_frame supported too?
195
-cfi-sigframe := $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1)
196
-cfi-sections := $(call as-instr,.cfi_sections .debug_frame,-DCONFIG_AS_CFI_SECTIONS=1)
197
-
198
-# does binutils support specific instructions?
199
-asinstr := $(call as-instr,fxsaveq (%rax),-DCONFIG_AS_FXSAVEQ=1)
200
-asinstr += $(call as-instr,pshufb %xmm0$(comma)%xmm0,-DCONFIG_AS_SSSE3=1)
201
-asinstr += $(call as-instr,crc32l %eax$(comma)%eax,-DCONFIG_AS_CRC32=1)
202
-avx_instr := $(call as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_AVX=1)
203
-avx2_instr :=$(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1)
204
-avx512_instr :=$(call as-instr,vpmovm2b %k1$(comma)%zmm5,-DCONFIG_AS_AVX512=1)
205
-sha1_ni_instr :=$(call as-instr,sha1msg1 %xmm0$(comma)%xmm1,-DCONFIG_AS_SHA1_NI=1)
206
-sha256_ni_instr :=$(call as-instr,sha256msg1 %xmm0$(comma)%xmm1,-DCONFIG_AS_SHA256_NI=1)
207
-adx_instr := $(call as-instr,adox %r10$(comma)%r10,-DCONFIG_AS_ADX=1)
208
-
209
-KBUILD_AFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr) $(avx2_instr) $(avx512_instr) $(sha1_ni_instr) $(sha256_ni_instr) $(adx_instr)
210
-KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr) $(avx2_instr) $(avx512_instr) $(sha1_ni_instr) $(sha256_ni_instr) $(adx_instr)
211
-
212
-KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
213
-
214
-#
215
-# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
216
-# the linker to force 2MB page size regardless of the default page size used
217
-# by the linker.
218
-#
219
-ifdef CONFIG_X86_64
220
-KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
221
-endif
222
-
223
-ifdef CONFIG_LTO_CLANG
224
-ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
225
-KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
226
-endif
227
-endif
228
-
229
-# Speed up the build
230
-KBUILD_CFLAGS += -pipe
231180 # Workaround for a gcc prelease that unfortunately was shipped in a suse release
232181 KBUILD_CFLAGS += -Wno-sign-compare
233182 #
....@@ -246,6 +195,34 @@
246195 KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables)
247196 endif
248197 endif
198
+
199
+ifdef CONFIG_SLS
200
+ KBUILD_CFLAGS += -mharden-sls=all
201
+endif
202
+
203
+KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
204
+
205
+ifdef CONFIG_LTO_CLANG
206
+ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
207
+KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
208
+endif
209
+endif
210
+
211
+ifdef CONFIG_X86_NEED_RELOCS
212
+LDFLAGS_vmlinux := --emit-relocs --discard-none
213
+else
214
+LDFLAGS_vmlinux :=
215
+endif
216
+
217
+#
218
+# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
219
+# the linker to force 2MB page size regardless of the default page size used
220
+# by the linker.
221
+#
222
+ifdef CONFIG_X86_64
223
+LDFLAGS_vmlinux += -z max-page-size=0x200000
224
+endif
225
+
249226
250227 archscripts: scripts_basic
251228 $(Q)$(MAKE) $(build)=arch/x86/tools relocs
....@@ -286,12 +263,15 @@
286263
287264 boot := arch/x86/boot
288265
289
-BOOT_TARGETS = bzlilo bzdisk fdimage fdimage144 fdimage288 isoimage
266
+BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 isoimage
290267
291268 PHONY += bzImage $(BOOT_TARGETS)
292269
270
+# Don't compile Image in mixed build with "all" target
271
+ifndef KBUILD_MIXED_TREE
293272 # Default kernel to build
294273 all: bzImage
274
+endif
295275
296276 # KBUILD_IMAGE specify target image being built
297277 KBUILD_IMAGE := $(boot)/bzImage
....@@ -307,8 +287,8 @@
307287 $(BOOT_TARGETS): vmlinux
308288 $(Q)$(MAKE) $(build)=$(boot) $@
309289
310
-PHONY += install
311
-install:
290
+PHONY += install bzlilo
291
+install bzlilo:
312292 $(Q)$(MAKE) $(build)=$(boot) $@
313293
314294 PHONY += vdso_install
....@@ -317,6 +297,10 @@
317297
318298 archprepare: checkbin
319299 checkbin:
300
+ifndef CONFIG_CC_HAS_ASM_GOTO
301
+ @echo Compiler lacks asm-goto support.
302
+ @exit 1
303
+endif
320304 ifdef CONFIG_RETPOLINE
321305 ifeq ($(RETPOLINE_CFLAGS),)
322306 @echo "You are building kernel with non-retpoline compiler." >&2