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