riscv: optimized memset
[platform/kernel/linux-starfive.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 rvstring.o
5
6 targets += $(purgatory-y)
7 PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
8
9 $(obj)/string.o: $(srctree)/lib/string.c FORCE
10         $(call if_changed_rule,cc_o_c)
11
12 $(obj)/ctype.o: $(srctree)/lib/ctype.c FORCE
13         $(call if_changed_rule,cc_o_c)
14
15 $(obj)/rvstring.o: $(srctree)/arch/riscv/lib/string.c FORCE
16         $(call if_changed_rule,cc_o_c)
17
18 $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
19         $(call if_changed_rule,cc_o_c)
20
21 CFLAGS_sha256.o := -D__DISABLE_EXPORTS
22 CFLAGS_string.o := -D__DISABLE_EXPORTS
23 CFLAGS_ctype.o := -D__DISABLE_EXPORTS
24
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
31
32 # Sanitizer, etc. runtimes are unavailable and cannot be linked here.
33 GCOV_PROFILE    := n
34 KASAN_SANITIZE  := n
35 UBSAN_SANITIZE  := n
36 KCSAN_SANITIZE  := n
37 KCOV_INSTRUMENT := n
38
39 # These are adjustments to the compiler flags used for objects that
40 # make up the standalone purgatory.ro
41
42 PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
43 PURGATORY_CFLAGS := -mcmodel=medany -ffreestanding -fno-zero-initialized-in-bss
44 PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
45 PURGATORY_CFLAGS += -fno-stack-protector -g0
46
47 # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
48 # in turn leaves some undefined symbols like __fentry__ in purgatory and not
49 # sure how to relocate those.
50 ifdef CONFIG_FUNCTION_TRACER
51 PURGATORY_CFLAGS_REMOVE         += $(CC_FLAGS_FTRACE)
52 endif
53
54 ifdef CONFIG_STACKPROTECTOR
55 PURGATORY_CFLAGS_REMOVE         += -fstack-protector
56 endif
57
58 ifdef CONFIG_STACKPROTECTOR_STRONG
59 PURGATORY_CFLAGS_REMOVE         += -fstack-protector-strong
60 endif
61
62 CFLAGS_REMOVE_purgatory.o       += $(PURGATORY_CFLAGS_REMOVE)
63 CFLAGS_purgatory.o              += $(PURGATORY_CFLAGS)
64
65 CFLAGS_REMOVE_sha256.o          += $(PURGATORY_CFLAGS_REMOVE)
66 CFLAGS_sha256.o                 += $(PURGATORY_CFLAGS)
67
68 CFLAGS_REMOVE_string.o          += $(PURGATORY_CFLAGS_REMOVE)
69 CFLAGS_string.o                 += $(PURGATORY_CFLAGS)
70
71 CFLAGS_REMOVE_ctype.o           += $(PURGATORY_CFLAGS_REMOVE)
72 CFLAGS_ctype.o                  += $(PURGATORY_CFLAGS)
73
74 AFLAGS_REMOVE_entry.o           += -Wa,-gdwarf-2
75 AFLAGS_REMOVE_memcpy.o          += -Wa,-gdwarf-2
76 AFLAGS_REMOVE_memset.o          += -Wa,-gdwarf-2
77
78 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
79                 $(call if_changed,ld)
80
81 $(obj)/purgatory.chk: $(obj)/purgatory.ro FORCE
82                 $(call if_changed,ld)
83
84 $(obj)/kexec-purgatory.o: $(obj)/purgatory.ro $(obj)/purgatory.chk
85
86 obj-y += kexec-purgatory.o