18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ciOBJECT_FILES_NON_STANDARD := y 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_cipurgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string.o 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_citargets += $(purgatory-y) 78c2ecf20Sopenharmony_ciPURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci$(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE 108c2ecf20Sopenharmony_ci $(call if_changed_rule,cc_o_c) 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci$(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE 138c2ecf20Sopenharmony_ci $(call if_changed_rule,cc_o_c) 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciCFLAGS_sha256.o := -D__DISABLE_EXPORTS 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci# When profile-guided optimization is enabled, llvm emits two different 188c2ecf20Sopenharmony_ci# overlapping text sections, which is not supported by kexec. Remove profile 198c2ecf20Sopenharmony_ci# optimization flags. 208c2ecf20Sopenharmony_ciKBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS)) 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci# When linking purgatory.ro with -r unresolved symbols are not checked, 238c2ecf20Sopenharmony_ci# also link a purgatory.chk binary without -r to check for unresolved symbols. 248c2ecf20Sopenharmony_ciPURGATORY_LDFLAGS := -e purgatory_start -nostdlib -z nodefaultlib 258c2ecf20Sopenharmony_ciLDFLAGS_purgatory.ro := -r $(PURGATORY_LDFLAGS) 268c2ecf20Sopenharmony_ciLDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS) 278c2ecf20Sopenharmony_citargets += purgatory.ro purgatory.chk 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci# Sanitizer, etc. runtimes are unavailable and cannot be linked here. 308c2ecf20Sopenharmony_ciGCOV_PROFILE := n 318c2ecf20Sopenharmony_ciKASAN_SANITIZE := n 328c2ecf20Sopenharmony_ciUBSAN_SANITIZE := n 338c2ecf20Sopenharmony_ciKCSAN_SANITIZE := n 348c2ecf20Sopenharmony_ciKCOV_INSTRUMENT := n 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci# These are adjustments to the compiler flags used for objects that 378c2ecf20Sopenharmony_ci# make up the standalone purgatory.ro 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciPURGATORY_CFLAGS_REMOVE := -mcmodel=kernel 408c2ecf20Sopenharmony_ciPURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0 418c2ecf20Sopenharmony_ciPURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING 428c2ecf20Sopenharmony_ciPURGATORY_CFLAGS += -fno-stack-protector 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That 458c2ecf20Sopenharmony_ci# in turn leaves some undefined symbols like __fentry__ in purgatory and not 468c2ecf20Sopenharmony_ci# sure how to relocate those. 478c2ecf20Sopenharmony_ciifdef CONFIG_FUNCTION_TRACER 488c2ecf20Sopenharmony_ciPURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_FTRACE) 498c2ecf20Sopenharmony_ciendif 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciifdef CONFIG_STACKPROTECTOR 528c2ecf20Sopenharmony_ciPURGATORY_CFLAGS_REMOVE += -fstack-protector 538c2ecf20Sopenharmony_ciendif 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciifdef CONFIG_STACKPROTECTOR_STRONG 568c2ecf20Sopenharmony_ciPURGATORY_CFLAGS_REMOVE += -fstack-protector-strong 578c2ecf20Sopenharmony_ciendif 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciifdef CONFIG_RETPOLINE 608c2ecf20Sopenharmony_ciPURGATORY_CFLAGS_REMOVE += $(RETPOLINE_CFLAGS) 618c2ecf20Sopenharmony_ciendif 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciCFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE) 648c2ecf20Sopenharmony_ciCFLAGS_purgatory.o += $(PURGATORY_CFLAGS) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciCFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE) 678c2ecf20Sopenharmony_ciCFLAGS_sha256.o += $(PURGATORY_CFLAGS) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciCFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE) 708c2ecf20Sopenharmony_ciCFLAGS_string.o += $(PURGATORY_CFLAGS) 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ciasflags-remove-y += -g -Wa,-gdwarf-2 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE 758c2ecf20Sopenharmony_ci $(call if_changed,ld) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci$(obj)/purgatory.chk: $(obj)/purgatory.ro FORCE 788c2ecf20Sopenharmony_ci $(call if_changed,ld) 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_citargets += kexec-purgatory.c 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciquiet_cmd_bin2c = BIN2C $@ 838c2ecf20Sopenharmony_ci cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci$(obj)/kexec-purgatory.c: $(obj)/purgatory.ro $(obj)/purgatory.chk FORCE 868c2ecf20Sopenharmony_ci $(call if_changed,bin2c) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ciobj-$(CONFIG_KEXEC_FILE) += kexec-purgatory.o 89