0001
0002
0003
0004
0005
0006 KCOV_INSTRUMENT := n
0007 GCOV_PROFILE := n
0008 UBSAN_SANITIZE := n
0009 KASAN_SANITIZE := n
0010 KCSAN_SANITIZE := n
0011
0012 KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
0013 KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
0014
0015
0016
0017
0018
0019 ifndef CONFIG_CC_IS_CLANG
0020 CC_FLAGS_MARCH_MINIMUM := -march=z900
0021 else
0022 CC_FLAGS_MARCH_MINIMUM := -march=z10
0023 endif
0024
0025 ifneq ($(CC_FLAGS_MARCH),$(CC_FLAGS_MARCH_MINIMUM))
0026 AFLAGS_REMOVE_head.o += $(CC_FLAGS_MARCH)
0027 AFLAGS_head.o += $(CC_FLAGS_MARCH_MINIMUM)
0028 AFLAGS_REMOVE_mem.o += $(CC_FLAGS_MARCH)
0029 AFLAGS_mem.o += $(CC_FLAGS_MARCH_MINIMUM)
0030 CFLAGS_REMOVE_als.o += $(CC_FLAGS_MARCH)
0031 CFLAGS_als.o += $(CC_FLAGS_MARCH_MINIMUM)
0032 CFLAGS_REMOVE_sclp_early_core.o += $(CC_FLAGS_MARCH)
0033 CFLAGS_sclp_early_core.o += $(CC_FLAGS_MARCH_MINIMUM)
0034 endif
0035
0036 CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
0037
0038 obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o
0039 obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
0040 obj-y += version.o pgm_check_info.o ctype.o ipl_data.o
0041 obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
0042 obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o
0043 obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
0044 obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
0045 obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
0046 obj-all := $(obj-y) piggy.o syms.o
0047
0048 targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
0049 targets += vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
0050 targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
0051 targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
0052
0053 OBJECTS := $(addprefix $(obj)/,$(obj-y))
0054 OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
0055
0056 quiet_cmd_section_cmp = SECTCMP $*
0057 define cmd_section_cmp
0058 s1=`$(OBJDUMP) -t -j "$*" "$<" | sort | \
0059 sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
0060 s2=`$(OBJDUMP) -t -j "$*" "$(word 2,$^)" | sort | \
0061 sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
0062 if [ "$$s1" != "$$s2" ]; then \
0063 echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
0064 exit 1; \
0065 fi; \
0066 touch $@
0067 endef
0068
0069 $(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
0070 $(call if_changed,objcopy)
0071
0072 $(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
0073 $(call if_changed,section_cmp)
0074
0075 LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T
0076 $(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
0077 $(call if_changed,ld)
0078
0079 LDFLAGS_vmlinux.syms := --oformat $(LD_BFD) -e startup -T
0080 $(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
0081 $(call if_changed,ld)
0082
0083 quiet_cmd_dumpsyms = DUMPSYMS $<
0084 define cmd_dumpsyms
0085 $(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' > "$@"
0086 endef
0087
0088 $(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
0089 $(call if_changed,dumpsyms)
0090
0091 OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
0092 $(obj)/syms.o: $(obj)/syms.bin FORCE
0093 $(call if_changed,objcopy)
0094
0095 OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
0096 $(obj)/info.bin: vmlinux FORCE
0097 $(call if_changed,objcopy)
0098
0099 OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
0100 $(obj)/info.o: $(obj)/info.bin FORCE
0101 $(call if_changed,objcopy)
0102
0103 OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
0104 $(obj)/vmlinux.bin: vmlinux FORCE
0105 $(call if_changed,objcopy)
0106
0107 suffix-$(CONFIG_KERNEL_GZIP) := .gz
0108 suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
0109 suffix-$(CONFIG_KERNEL_LZ4) := .lz4
0110 suffix-$(CONFIG_KERNEL_LZMA) := .lzma
0111 suffix-$(CONFIG_KERNEL_LZO) := .lzo
0112 suffix-$(CONFIG_KERNEL_XZ) := .xz
0113 suffix-$(CONFIG_KERNEL_ZSTD) := .zst
0114
0115 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
0116 $(call if_changed,gzip)
0117 $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
0118 $(call if_changed,bzip2_with_size)
0119 $(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
0120 $(call if_changed,lz4_with_size)
0121 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
0122 $(call if_changed,lzma_with_size)
0123 $(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
0124 $(call if_changed,lzo_with_size)
0125 $(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
0126 $(call if_changed,xzkern_with_size)
0127 $(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
0128 $(call if_changed,zstd22_with_size)
0129
0130 OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
0131 $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
0132 $(call if_changed,objcopy)