1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2c0dd6716SJosh PoimboeufOBJECT_FILES_NON_STANDARD := y 3c0dd6716SJosh Poimboeuf 48fc5b4d4SVivek Goyalpurgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string.o 58fc5b4d4SVivek Goyal 68fc5b4d4SVivek Goyaltargets += $(purgatory-y) 78fc5b4d4SVivek GoyalPURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) 88fc5b4d4SVivek Goyal 94ce97317SNick Desaulniers$(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE 104ce97317SNick Desaulniers $(call if_changed_rule,cc_o_c) 114ce97317SNick Desaulniers 12ad767ee8SHans de Goede$(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE 13df6f2801SPhilipp Rudo $(call if_changed_rule,cc_o_c) 14df6f2801SPhilipp Rudo 1501d3aee8SHans de GoedeCFLAGS_sha256.o := -D__DISABLE_EXPORTS 1601d3aee8SHans de Goede 17e4160b2eSHans de Goede# When linking purgatory.ro with -r unresolved symbols are not checked, 18e4160b2eSHans de Goede# also link a purgatory.chk binary without -r to check for unresolved symbols. 199102fa34SMasahiro YamadaPURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib 20e4160b2eSHans de GoedeLDFLAGS_purgatory.ro := -r $(PURGATORY_LDFLAGS) 21e4160b2eSHans de GoedeLDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS) 22e4160b2eSHans de Goedetargets += purgatory.ro purgatory.chk 238fc5b4d4SVivek Goyal 24e2ac07c0SHans de Goede# Sanitizer, etc. runtimes are unavailable and cannot be linked here. 25e2ac07c0SHans de GoedeGCOV_PROFILE := n 2613a6798eSMike GalbraithKASAN_SANITIZE := n 27e2ac07c0SHans de GoedeUBSAN_SANITIZE := n 2840d04110SMarco ElverKCSAN_SANITIZE := n 29543c37cbSEmese RevfyKCOV_INSTRUMENT := n 30543c37cbSEmese Revfy 31e16c2983SSteve Wahl# These are adjustments to the compiler flags used for objects that 32e16c2983SSteve Wahl# make up the standalone purgatory.ro 33e16c2983SSteve Wahl 34e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE := -mcmodel=kernel 3552416ffcSPingfan LiuPURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0 36e2ac07c0SHans de GoedePURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING 37893ab004SMasahiro YamadaPURGATORY_CFLAGS += -fno-stack-protector 38e16c2983SSteve Wahl 398fc5b4d4SVivek Goyal# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That 408fc5b4d4SVivek Goyal# in turn leaves some undefined symbols like __fentry__ in purgatory and not 41b059f801SNick Desaulniers# sure how to relocate those. 42b059f801SNick Desaulniersifdef CONFIG_FUNCTION_TRACER 43e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_FTRACE) 44b059f801SNick Desaulniersendif 458fc5b4d4SVivek Goyal 46b059f801SNick Desaulniersifdef CONFIG_STACKPROTECTOR 47e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE += -fstack-protector 48b059f801SNick Desaulniersendif 49b059f801SNick Desaulniers 50b059f801SNick Desaulniersifdef CONFIG_STACKPROTECTOR_STRONG 51e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE += -fstack-protector-strong 52b059f801SNick Desaulniersendif 53b059f801SNick Desaulniers 54b059f801SNick Desaulniersifdef CONFIG_RETPOLINE 55e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE += $(RETPOLINE_CFLAGS) 56b059f801SNick Desaulniersendif 578fc5b4d4SVivek Goyal 58e16c2983SSteve WahlCFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE) 59e16c2983SSteve WahlCFLAGS_purgatory.o += $(PURGATORY_CFLAGS) 60e16c2983SSteve Wahl 61e16c2983SSteve WahlCFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE) 62e16c2983SSteve WahlCFLAGS_sha256.o += $(PURGATORY_CFLAGS) 63e16c2983SSteve Wahl 64e16c2983SSteve WahlCFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE) 65e16c2983SSteve WahlCFLAGS_string.o += $(PURGATORY_CFLAGS) 66e16c2983SSteve Wahl 6752416ffcSPingfan LiuAFLAGS_REMOVE_setup-x86_$(BITS).o += -Wa,-gdwarf-2 6852416ffcSPingfan LiuAFLAGS_REMOVE_entry64.o += -Wa,-gdwarf-2 6952416ffcSPingfan Liu 708fc5b4d4SVivek Goyal$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE 718fc5b4d4SVivek Goyal $(call if_changed,ld) 728fc5b4d4SVivek Goyal 73e4160b2eSHans de Goede$(obj)/purgatory.chk: $(obj)/purgatory.ro FORCE 74e4160b2eSHans de Goede $(call if_changed,ld) 75e4160b2eSHans de Goede 768fc5b4d4SVivek Goyaltargets += kexec-purgatory.c 778fc5b4d4SVivek Goyal 788fc5b4d4SVivek Goyalquiet_cmd_bin2c = BIN2C $@ 79c417fbceSMasahiro Yamada cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@ 808fc5b4d4SVivek Goyal 81e4160b2eSHans de Goede$(obj)/kexec-purgatory.c: $(obj)/purgatory.ro $(obj)/purgatory.chk FORCE 828fc5b4d4SVivek Goyal $(call if_changed,bin2c) 838fc5b4d4SVivek Goyal 84*61922d3fSMasahiro Yamadaobj-y += kexec-purgatory.o 85