Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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)
  20. KBUILD_CFLAGS += $(CC_FLAGS_MARCH_MINIMUM)
  21. CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
  22. obj-y := head.o als.o startup.o physmem_info.o ipl_parm.o ipl_report.o vmem.o
  23. obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
  24. obj-y += version.o pgm_check_info.o ctype.o ipl_data.o relocs.o alternative.o
  25. obj-y += uv.o printk.o
  26. obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
  27. obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
  28. obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
  29. obj-$(CONFIG_KMSAN) += kmsan.o
  30. obj-all := $(obj-y) piggy.o syms.o
  31. targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
  32. targets += vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
  33. targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
  34. targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
  35. targets += relocs.S
  36. OBJECTS := $(addprefix $(obj)/,$(obj-y))
  37. OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
  38. clean-files += vmlinux.map
  39. quiet_cmd_section_cmp = SECTCMP $*
  40. define cmd_section_cmp
  41. s1=`$(OBJDUMP) -t "$<" | grep "\s$*\s\+" | sort | \
  42. sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
  43. s2=`$(OBJDUMP) -t "$(word 2,$^)" | grep "\s$*\s\+" | sort | \
  44. sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
  45. if [ "$$s1" != "$$s2" ]; then \
  46. echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
  47. exit 1; \
  48. fi; \
  49. touch $@
  50. endef
  51. $(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
  52. $(call if_changed,objcopy)
  53. $(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
  54. $(call if_changed,section_cmp)
  55. LDFLAGS_vmlinux-$(CONFIG_LD_ORPHAN_WARN) := --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
  56. LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup $(if $(CONFIG_VMLINUX_MAP),-Map=$(obj)/vmlinux.map) --build-id=sha1 -T
  57. $(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
  58. $(call if_changed,ld)
  59. LDFLAGS_vmlinux.syms := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup -T
  60. $(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
  61. $(call if_changed,ld)
  62. quiet_cmd_dumpsyms = DUMPSYMS $<
  63. define cmd_dumpsyms
  64. $(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' > "$@"
  65. endef
  66. $(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
  67. $(call if_changed,dumpsyms)
  68. OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
  69. $(obj)/syms.o: $(obj)/syms.bin FORCE
  70. $(call if_changed,objcopy)
  71. OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=alloc,load
  72. $(obj)/info.bin: vmlinux FORCE
  73. $(call if_changed,objcopy)
  74. OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
  75. $(obj)/info.o: $(obj)/info.bin FORCE
  76. $(call if_changed,objcopy)
  77. OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
  78. $(obj)/vmlinux.bin: vmlinux FORCE
  79. $(call if_changed,objcopy)
  80. # relocs.S is created by the vmlinux postlink step.
  81. $(obj)/relocs.S: vmlinux
  82. @true
  83. suffix-$(CONFIG_KERNEL_GZIP) := .gz
  84. suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
  85. suffix-$(CONFIG_KERNEL_LZ4) := .lz4
  86. suffix-$(CONFIG_KERNEL_LZMA) := .lzma
  87. suffix-$(CONFIG_KERNEL_LZO) := .lzo
  88. suffix-$(CONFIG_KERNEL_XZ) := .xz
  89. suffix-$(CONFIG_KERNEL_ZSTD) := .zst
  90. $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
  91. $(call if_changed,gzip)
  92. $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
  93. $(call if_changed,bzip2_with_size)
  94. $(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
  95. $(call if_changed,lz4_with_size)
  96. $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
  97. $(call if_changed,lzma_with_size)
  98. $(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
  99. $(call if_changed,lzo_with_size)
  100. $(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
  101. $(call if_changed,xzkern_with_size)
  102. $(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
  103. $(call if_changed,zstd22_with_size)
  104. OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
  105. $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
  106. $(call if_changed,objcopy)