xref: /linux/arch/x86/purgatory/Makefile (revision e16c2983fba0fa6763e43ad10916be35e3d8dc05)
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
12fa8cbda8SPhilipp Rudo$(obj)/sha256.o: $(srctree)/lib/sha256.c FORCE
13df6f2801SPhilipp Rudo	$(call if_changed_rule,cc_o_c)
14df6f2801SPhilipp Rudo
158fc5b4d4SVivek GoyalLDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
168fc5b4d4SVivek Goyaltargets += purgatory.ro
178fc5b4d4SVivek Goyal
1813a6798eSMike GalbraithKASAN_SANITIZE	:= n
19543c37cbSEmese RevfyKCOV_INSTRUMENT := n
20543c37cbSEmese Revfy
21*e16c2983SSteve Wahl# These are adjustments to the compiler flags used for objects that
22*e16c2983SSteve Wahl# make up the standalone purgatory.ro
23*e16c2983SSteve Wahl
24*e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
25*e16c2983SSteve WahlPURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss
26*e16c2983SSteve Wahl
278fc5b4d4SVivek Goyal# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
288fc5b4d4SVivek Goyal# in turn leaves some undefined symbols like __fentry__ in purgatory and not
29b059f801SNick Desaulniers# sure how to relocate those.
30b059f801SNick Desaulniersifdef CONFIG_FUNCTION_TRACER
31*e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE		+= $(CC_FLAGS_FTRACE)
32b059f801SNick Desaulniersendif
338fc5b4d4SVivek Goyal
34b059f801SNick Desaulniersifdef CONFIG_STACKPROTECTOR
35*e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE		+= -fstack-protector
36b059f801SNick Desaulniersendif
37b059f801SNick Desaulniers
38b059f801SNick Desaulniersifdef CONFIG_STACKPROTECTOR_STRONG
39*e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE		+= -fstack-protector-strong
40b059f801SNick Desaulniersendif
41b059f801SNick Desaulniers
42b059f801SNick Desaulniersifdef CONFIG_RETPOLINE
43*e16c2983SSteve WahlPURGATORY_CFLAGS_REMOVE		+= $(RETPOLINE_CFLAGS)
44b059f801SNick Desaulniersendif
458fc5b4d4SVivek Goyal
46*e16c2983SSteve WahlCFLAGS_REMOVE_purgatory.o	+= $(PURGATORY_CFLAGS_REMOVE)
47*e16c2983SSteve WahlCFLAGS_purgatory.o		+= $(PURGATORY_CFLAGS)
48*e16c2983SSteve Wahl
49*e16c2983SSteve WahlCFLAGS_REMOVE_sha256.o		+= $(PURGATORY_CFLAGS_REMOVE)
50*e16c2983SSteve WahlCFLAGS_sha256.o			+= $(PURGATORY_CFLAGS)
51*e16c2983SSteve Wahl
52*e16c2983SSteve WahlCFLAGS_REMOVE_string.o		+= $(PURGATORY_CFLAGS_REMOVE)
53*e16c2983SSteve WahlCFLAGS_string.o			+= $(PURGATORY_CFLAGS)
54*e16c2983SSteve Wahl
558fc5b4d4SVivek Goyal$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
568fc5b4d4SVivek Goyal		$(call if_changed,ld)
578fc5b4d4SVivek Goyal
588fc5b4d4SVivek Goyaltargets += kexec-purgatory.c
598fc5b4d4SVivek Goyal
608fc5b4d4SVivek Goyalquiet_cmd_bin2c = BIN2C   $@
61c417fbceSMasahiro Yamada      cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@
628fc5b4d4SVivek Goyal
638fc5b4d4SVivek Goyal$(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
648fc5b4d4SVivek Goyal	$(call if_changed,bin2c)
658fc5b4d4SVivek Goyal
6674ca317cSVivek Goyalobj-$(CONFIG_KEXEC_FILE)	+= kexec-purgatory.o
67