drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / arch / x86 / purgatory / Makefile
blobebdfd7b84feb3eb4d1cc0fd958a97aa2c4f344e8
1 # SPDX-License-Identifier: GPL-2.0
3 purgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string.o
5 targets += $(purgatory-y)
6 PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
8 $(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE
9 $(call if_changed_rule,cc_o_c)
11 $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
12 $(call if_changed_rule,cc_o_c)
14 CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY
16 # When profile-guided optimization is enabled, llvm emits two different
17 # overlapping text sections, which is not supported by kexec. Remove profile
18 # optimization flags.
19 KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
21 # When LTO is enabled, llvm emits many text sections, which is not supported
22 # by kexec. Remove -flto=* flags.
23 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS))
25 # When linking purgatory.ro with -r unresolved symbols are not checked,
26 # also link a purgatory.chk binary without -r to check for unresolved symbols.
27 PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib
28 LDFLAGS_purgatory.ro := -r $(PURGATORY_LDFLAGS)
29 LDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS)
30 targets += purgatory.ro purgatory.chk
32 # These are adjustments to the compiler flags used for objects that
33 # make up the standalone purgatory.ro
35 PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
36 PURGATORY_CFLAGS := -mcmodel=small -ffreestanding -fno-zero-initialized-in-bss -g0
37 PURGATORY_CFLAGS += -fpic -fvisibility=hidden
38 PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
39 PURGATORY_CFLAGS += -fno-stack-protector
41 # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
42 # in turn leaves some undefined symbols like __fentry__ in purgatory and not
43 # sure how to relocate those.
44 ifdef CONFIG_FUNCTION_TRACER
45 PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_FTRACE)
46 endif
48 ifdef CONFIG_STACKPROTECTOR
49 PURGATORY_CFLAGS_REMOVE += -fstack-protector
50 endif
52 ifdef CONFIG_STACKPROTECTOR_STRONG
53 PURGATORY_CFLAGS_REMOVE += -fstack-protector-strong
54 endif
56 ifdef CONFIG_MITIGATION_RETPOLINE
57 PURGATORY_CFLAGS_REMOVE += $(RETPOLINE_CFLAGS)
58 endif
60 ifdef CONFIG_CFI_CLANG
61 PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_CFI)
62 endif
64 CFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE)
65 CFLAGS_purgatory.o += $(PURGATORY_CFLAGS)
67 CFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE)
68 CFLAGS_sha256.o += $(PURGATORY_CFLAGS)
70 CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE)
71 CFLAGS_string.o += $(PURGATORY_CFLAGS)
73 asflags-remove-y += $(foreach x, -g -gdwarf-4 -gdwarf-5, $(x) -Wa,$(x))
75 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
76 $(call if_changed,ld)
78 $(obj)/purgatory.chk: $(obj)/purgatory.ro FORCE
79 $(call if_changed,ld)
81 $(obj)/kexec-purgatory.o: $(obj)/purgatory.ro $(obj)/purgatory.chk
83 obj-y += kexec-purgatory.o