hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/x86/purgatory/Makefile
....@@ -9,24 +9,37 @@
99 $(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE
1010 $(call if_changed_rule,cc_o_c)
1111
12
-$(obj)/sha256.o: $(srctree)/lib/sha256.c FORCE
12
+$(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
1313 $(call if_changed_rule,cc_o_c)
1414
15
-LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
16
-targets += purgatory.ro
15
+CFLAGS_sha256.o := -D__DISABLE_EXPORTS
16
+
17
+# When profile-guided optimization is enabled, llvm emits two different
18
+# overlapping text sections, which is not supported by kexec. Remove profile
19
+# optimization flags.
20
+KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
21
+
22
+# When linking purgatory.ro with -r unresolved symbols are not checked,
23
+# also link a purgatory.chk binary without -r to check for unresolved symbols.
24
+PURGATORY_LDFLAGS := -e purgatory_start -nostdlib -z nodefaultlib
25
+LDFLAGS_purgatory.ro := -r $(PURGATORY_LDFLAGS)
26
+LDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS)
27
+targets += purgatory.ro purgatory.chk
1728
1829 # Sanitizer, etc. runtimes are unavailable and cannot be linked here.
1930 GCOV_PROFILE := n
2031 KASAN_SANITIZE := n
2132 UBSAN_SANITIZE := n
33
+KCSAN_SANITIZE := n
2234 KCOV_INSTRUMENT := n
2335
2436 # These are adjustments to the compiler flags used for objects that
2537 # make up the standalone purgatory.ro
2638
27
-PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
28
-PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss
39
+PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel $(CC_FLAGS_CFI)
40
+PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0
2941 PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
42
+PURGATORY_CFLAGS += -fno-stack-protector
3043
3144 # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
3245 # in turn leaves some undefined symbols like __fentry__ in purgatory and not
....@@ -56,7 +69,12 @@
5669 CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE)
5770 CFLAGS_string.o += $(PURGATORY_CFLAGS)
5871
72
+asflags-remove-y += -g -Wa,-gdwarf-2
73
+
5974 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
75
+ $(call if_changed,ld)
76
+
77
+$(obj)/purgatory.chk: $(obj)/purgatory.ro FORCE
6078 $(call if_changed,ld)
6179
6280 targets += kexec-purgatory.c
....@@ -64,7 +82,7 @@
6482 quiet_cmd_bin2c = BIN2C $@
6583 cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@
6684
67
-$(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
85
+$(obj)/kexec-purgatory.c: $(obj)/purgatory.ro $(obj)/purgatory.chk FORCE
6886 $(call if_changed,bin2c)
6987
7088 obj-$(CONFIG_KEXEC_FILE) += kexec-purgatory.o