Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # SPDX-License-Identifier: GPL-2.0
  2. #
  3. # Makefile for the linux s390-specific parts of the memory manager.
  4. #
  5. KCOV_INSTRUMENT := n
  6. GCOV_PROFILE := n
  7. UBSAN_SANITIZE := n
  8. KASAN_SANITIZE := n
  9. KCSAN_SANITIZE := n
  10. KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
  11. KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
  12. #
  13. # Use minimum architecture for als.c to be able to print an error
  14. # message if the kernel is started on a machine which is too old
  15. #
  16. ifndef CONFIG_CC_IS_CLANG
  17. CC_FLAGS_MARCH_MINIMUM := -march=z900
  18. else
  19. CC_FLAGS_MARCH_MINIMUM := -march=z10
  20. endif
  21. ifneq ($(CC_FLAGS_MARCH),$(CC_FLAGS_MARCH_MINIMUM))
  22. AFLAGS_REMOVE_head.o += $(CC_FLAGS_MARCH)
  23. AFLAGS_head.o += $(CC_FLAGS_MARCH_MINIMUM)
  24. AFLAGS_REMOVE_mem.o += $(CC_FLAGS_MARCH)
  25. AFLAGS_mem.o += $(CC_FLAGS_MARCH_MINIMUM)
  26. CFLAGS_REMOVE_als.o += $(CC_FLAGS_MARCH)
  27. CFLAGS_als.o += $(CC_FLAGS_MARCH_MINIMUM)
  28. CFLAGS_REMOVE_sclp_early_core.o += $(CC_FLAGS_MARCH)
  29. CFLAGS_sclp_early_core.o += $(CC_FLAGS_MARCH_MINIMUM)
  30. endif
  31. CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
  32. obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o
  33. obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
  34. obj-y += version.o pgm_check_info.o ctype.o ipl_data.o machine_kexec_reloc.o
  35. obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
  36. obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
  37. obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
  38. obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
  39. obj-all := $(obj-y) piggy.o syms.o
  40. targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
  41. targets += vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
  42. targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
  43. targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
  44. OBJECTS := $(addprefix $(obj)/,$(obj-y))
  45. OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
  46. quiet_cmd_section_cmp = SECTCMP $*
  47. define cmd_section_cmp
  48. s1=`$(OBJDUMP) -t -j "$*" "$<" | sort | \
  49. sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
  50. s2=`$(OBJDUMP) -t -j "$*" "$(word 2,$^)" | sort | \
  51. sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
  52. if [ "$$s1" != "$$s2" ]; then \
  53. echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
  54. exit 1; \
  55. fi; \
  56. touch $@
  57. endef
  58. $(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
  59. $(call if_changed,objcopy)
  60. $(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
  61. $(call if_changed,section_cmp)
  62. LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T
  63. $(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
  64. $(call if_changed,ld)
  65. LDFLAGS_vmlinux.syms := --oformat $(LD_BFD) -e startup -T
  66. $(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
  67. $(call if_changed,ld)
  68. quiet_cmd_dumpsyms = DUMPSYMS $<
  69. define cmd_dumpsyms
  70. $(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' > "$@"
  71. endef
  72. $(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
  73. $(call if_changed,dumpsyms)
  74. OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
  75. $(obj)/syms.o: $(obj)/syms.bin FORCE
  76. $(call if_changed,objcopy)
  77. OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
  78. $(obj)/info.bin: vmlinux FORCE
  79. $(call if_changed,objcopy)
  80. OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
  81. $(obj)/info.o: $(obj)/info.bin FORCE
  82. $(call if_changed,objcopy)
  83. OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
  84. $(obj)/vmlinux.bin: vmlinux FORCE
  85. $(call if_changed,objcopy)
  86. suffix-$(CONFIG_KERNEL_GZIP) := .gz
  87. suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
  88. suffix-$(CONFIG_KERNEL_LZ4) := .lz4
  89. suffix-$(CONFIG_KERNEL_LZMA) := .lzma
  90. suffix-$(CONFIG_KERNEL_LZO) := .lzo
  91. suffix-$(CONFIG_KERNEL_XZ) := .xz
  92. suffix-$(CONFIG_KERNEL_ZSTD) := .zst
  93. $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
  94. $(call if_changed,gzip)
  95. $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
  96. $(call if_changed,bzip2_with_size)
  97. $(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
  98. $(call if_changed,lz4_with_size)
  99. $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
  100. $(call if_changed,lzma_with_size)
  101. $(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
  102. $(call if_changed,lzo_with_size)
  103. $(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
  104. $(call if_changed,xzkern_with_size)
  105. $(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
  106. $(call if_changed,zstd22_with_size)
  107. OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
  108. $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
  109. $(call if_changed,objcopy)