Merge tag 'rtc-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[linux-2.6-block.git] / arch / riscv / purgatory / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 OBJECT_FILES_NON_STANDARD := y
3
4 purgatory-y := purgatory.o sha256.o entry.o string.o ctype.o memcpy.o memset.o
5 purgatory-y += strcmp.o strlen.o strncmp.o
6
7 targets += $(purgatory-y)
8 PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
9
10 $(obj)/string.o: $(srctree)/lib/string.c FORCE
11         $(call if_changed_rule,cc_o_c)
12
13 $(obj)/ctype.o: $(srctree)/lib/ctype.c FORCE
14         $(call if_changed_rule,cc_o_c)
15
16 $(obj)/memcpy.o: $(srctree)/arch/riscv/lib/memcpy.S FORCE
17         $(call if_changed_rule,as_o_S)
18
19 $(obj)/memset.o: $(srctree)/arch/riscv/lib/memset.S FORCE
20         $(call if_changed_rule,as_o_S)
21
22 $(obj)/strcmp.o: $(srctree)/arch/riscv/lib/strcmp.S FORCE
23         $(call if_changed_rule,as_o_S)
24
25 $(obj)/strlen.o: $(srctree)/arch/riscv/lib/strlen.S FORCE
26         $(call if_changed_rule,as_o_S)
27
28 $(obj)/strncmp.o: $(srctree)/arch/riscv/lib/strncmp.S FORCE
29         $(call if_changed_rule,as_o_S)
30
31 $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
32         $(call if_changed_rule,cc_o_c)
33
34 CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY
35 CFLAGS_string.o := -D__DISABLE_EXPORTS
36 CFLAGS_ctype.o := -D__DISABLE_EXPORTS
37
38 # When profile-guided optimization is enabled, llvm emits two different
39 # overlapping text sections, which is not supported by kexec. Remove profile
40 # optimization flags.
41 KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
42
43 # When linking purgatory.ro with -r unresolved symbols are not checked,
44 # also link a purgatory.chk binary without -r to check for unresolved symbols.
45 PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib
46 LDFLAGS_purgatory.ro := -r $(PURGATORY_LDFLAGS)
47 LDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS)
48 targets += purgatory.ro purgatory.chk
49
50 # Sanitizer, etc. runtimes are unavailable and cannot be linked here.
51 GCOV_PROFILE    := n
52 KASAN_SANITIZE  := n
53 UBSAN_SANITIZE  := n
54 KCSAN_SANITIZE  := n
55 KCOV_INSTRUMENT := n
56
57 # These are adjustments to the compiler flags used for objects that
58 # make up the standalone purgatory.ro
59
60 PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
61 PURGATORY_CFLAGS := -mcmodel=medany -ffreestanding -fno-zero-initialized-in-bss
62 PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
63 PURGATORY_CFLAGS += -fno-stack-protector -g0
64
65 # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
66 # in turn leaves some undefined symbols like __fentry__ in purgatory and not
67 # sure how to relocate those.
68 ifdef CONFIG_FUNCTION_TRACER
69 PURGATORY_CFLAGS_REMOVE         += $(CC_FLAGS_FTRACE)
70 endif
71
72 ifdef CONFIG_STACKPROTECTOR
73 PURGATORY_CFLAGS_REMOVE         += -fstack-protector
74 endif
75
76 ifdef CONFIG_STACKPROTECTOR_STRONG
77 PURGATORY_CFLAGS_REMOVE         += -fstack-protector-strong
78 endif
79
80 ifdef CONFIG_CFI_CLANG
81 PURGATORY_CFLAGS_REMOVE         += $(CC_FLAGS_CFI)
82 endif
83
84 CFLAGS_REMOVE_purgatory.o       += $(PURGATORY_CFLAGS_REMOVE)
85 CFLAGS_purgatory.o              += $(PURGATORY_CFLAGS)
86
87 CFLAGS_REMOVE_sha256.o          += $(PURGATORY_CFLAGS_REMOVE)
88 CFLAGS_sha256.o                 += $(PURGATORY_CFLAGS)
89
90 CFLAGS_REMOVE_string.o          += $(PURGATORY_CFLAGS_REMOVE)
91 CFLAGS_string.o                 += $(PURGATORY_CFLAGS)
92
93 CFLAGS_REMOVE_ctype.o           += $(PURGATORY_CFLAGS_REMOVE)
94 CFLAGS_ctype.o                  += $(PURGATORY_CFLAGS)
95
96 asflags-remove-y                += $(foreach x, -g -gdwarf-4 -gdwarf-5, $(x) -Wa,$(x))
97
98 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
99                 $(call if_changed,ld)
100
101 $(obj)/purgatory.chk: $(obj)/purgatory.ro FORCE
102                 $(call if_changed,ld)
103
104 $(obj)/kexec-purgatory.o: $(obj)/purgatory.ro $(obj)/purgatory.chk
105
106 obj-y += kexec-purgatory.o