Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # SPDX-License-Identifier: GPL-2.0
  2. #
  3. # Makefile for the linux s390-specific parts of the memory manager.
  4. #
  5. # Tooling runtimes are unavailable and cannot be linked for early boot code
  6. KCOV_INSTRUMENT := n
  7. GCOV_PROFILE := n
  8. UBSAN_SANITIZE := n
  9. KASAN_SANITIZE := n
  10. KCSAN_SANITIZE := n
  11. KMSAN_SANITIZE := n
  12. #
  13. # Use minimum architecture level so it is possible to print an error
  14. # message if the kernel is started on a machine which is too old
  15. #
  16. CC_FLAGS_MARCH_MINIMUM := -march=z10
  17. KBUILD_AFLAGS := $(filter-out $(CC_FLAGS_MARCH),$(KBUILD_AFLAGS_DECOMPRESSOR))
  18. KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_MARCH),$(KBUILD_CFLAGS_DECOMPRESSOR))
  19. KBUILD_AFLAGS += $(CC_FLAGS_MARCH_MINIMUM) -D__DISABLE_EXPORTS
  20. KBUILD_CFLAGS += $(CC_FLAGS_MARCH_MINIMUM) -D__DISABLE_EXPORTS
  21. KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
  22. CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
  23. obj-y := head.o als.o startup.o physmem_info.o ipl_parm.o ipl_report.o vmem.o
  24. obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
  25. obj-y += version.o pgm_check.o ctype.o ipl_data.o relocs.o alternative.o
  26. obj-y += uv.o printk.o trampoline.o
  27. obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
  28. obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
  29. obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
  30. obj-$(CONFIG_KMSAN) += kmsan.o
  31. obj-$(CONFIG_STACKPROTECTOR) += stackprotector.o
  32. obj-all := $(obj-y) piggy.o syms.o
  33. targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
  34. targets += vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
  35. targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
  36. targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
  37. targets += relocs.S
  38. OBJECTS := $(addprefix $(obj)/,$(obj-y))
  39. OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
  40. clean-files += vmlinux.map
  41. quiet_cmd_section_cmp = SECTCMP $*
  42. define cmd_section_cmp
  43. s1=`$(OBJDUMP) -t "$<" | grep "\s$*\s\+" | sort | \
  44. sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
  45. s2=`$(OBJDUMP) -t "$(word 2,$^)" | grep "\s$*\s\+" | sort | \
  46. sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
  47. if [ "$$s1" != "$$s2" ]; then \
  48. echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
  49. exit 1; \
  50. fi; \
  51. touch $@
  52. endef
  53. $(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
  54. $(call if_changed,objcopy)
  55. $(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
  56. $(call if_changed,section_cmp)
  57. LDFLAGS_vmlinux-$(CONFIG_LD_ORPHAN_WARN) := --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
  58. LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup $(if $(CONFIG_VMLINUX_MAP),-Map=$(obj)/vmlinux.map) --build-id=sha1 -T
  59. $(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
  60. $(call if_changed,ld)
  61. LDFLAGS_vmlinux.syms := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup -T
  62. $(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
  63. $(call if_changed,ld)
  64. quiet_cmd_dumpsyms = DUMPSYMS $<
  65. define cmd_dumpsyms
  66. $(NM) -n -S --format=bsd "$<" | sed -nE 's/^0*([0-9a-fA-F]+) 0*([0-9a-fA-F]+) [tT] ([^ ]*)$$/\1 \2 \3/p' | tr '\n' '\0' > "$@"
  67. endef
  68. $(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
  69. $(call if_changed,dumpsyms)
  70. OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
  71. $(obj)/syms.o: $(obj)/syms.bin FORCE
  72. $(call if_changed,objcopy)
  73. OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=alloc,load
  74. $(obj)/info.bin: vmlinux FORCE
  75. $(call if_changed,objcopy)
  76. OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
  77. $(obj)/info.o: $(obj)/info.bin FORCE
  78. $(call if_changed,objcopy)
  79. OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
  80. $(obj)/vmlinux.bin: vmlinux FORCE
  81. $(call if_changed,objcopy)
  82. # relocs.S is created by the vmlinux postlink step.
  83. $(obj)/relocs.S: vmlinux
  84. @true
  85. suffix-$(CONFIG_KERNEL_GZIP) := .gz
  86. suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
  87. suffix-$(CONFIG_KERNEL_LZ4) := .lz4
  88. suffix-$(CONFIG_KERNEL_LZMA) := .lzma
  89. suffix-$(CONFIG_KERNEL_LZO) := .lzo
  90. suffix-$(CONFIG_KERNEL_XZ) := .xz
  91. suffix-$(CONFIG_KERNEL_ZSTD) := .zst
  92. $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
  93. $(call if_changed,gzip)
  94. $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
  95. $(call if_changed,bzip2_with_size)
  96. $(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
  97. $(call if_changed,lz4_with_size)
  98. $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
  99. $(call if_changed,lzma_with_size)
  100. $(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
  101. $(call if_changed,lzo_with_size)
  102. $(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
  103. $(call if_changed,xzkern_with_size)
  104. $(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
  105. $(call if_changed,zstd22_with_size)
  106. OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
  107. $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
  108. $(call if_changed,objcopy)