Makefile 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # SPDX-License-Identifier: GPL-2.0
  2. OBJECT_FILES_NON_STANDARD := y
  3. purgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string.o
  4. targets += $(purgatory-y)
  5. PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
  6. $(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE
  7. $(call if_changed_rule,cc_o_c)
  8. $(obj)/sha256.o: $(srctree)/lib/sha256.c FORCE
  9. $(call if_changed_rule,cc_o_c)
  10. LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
  11. targets += purgatory.ro
  12. # Sanitizer, etc. runtimes are unavailable and cannot be linked here.
  13. GCOV_PROFILE := n
  14. KASAN_SANITIZE := n
  15. UBSAN_SANITIZE := n
  16. KCOV_INSTRUMENT := n
  17. # These are adjustments to the compiler flags used for objects that
  18. # make up the standalone purgatory.ro
  19. PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
  20. PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss
  21. PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
  22. # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
  23. # in turn leaves some undefined symbols like __fentry__ in purgatory and not
  24. # sure how to relocate those.
  25. ifdef CONFIG_FUNCTION_TRACER
  26. PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_FTRACE)
  27. endif
  28. ifdef CONFIG_STACKPROTECTOR
  29. PURGATORY_CFLAGS_REMOVE += -fstack-protector
  30. endif
  31. ifdef CONFIG_STACKPROTECTOR_STRONG
  32. PURGATORY_CFLAGS_REMOVE += -fstack-protector-strong
  33. endif
  34. ifdef CONFIG_RETPOLINE
  35. PURGATORY_CFLAGS_REMOVE += $(RETPOLINE_CFLAGS)
  36. endif
  37. CFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE)
  38. CFLAGS_purgatory.o += $(PURGATORY_CFLAGS)
  39. CFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE)
  40. CFLAGS_sha256.o += $(PURGATORY_CFLAGS)
  41. CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE)
  42. CFLAGS_string.o += $(PURGATORY_CFLAGS)
  43. $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
  44. $(call if_changed,ld)
  45. targets += kexec-purgatory.c
  46. quiet_cmd_bin2c = BIN2C $@
  47. cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@
  48. $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
  49. $(call if_changed,bin2c)
  50. obj-$(CONFIG_KEXEC_FILE) += kexec-purgatory.o