1# SPDX-License-Identifier: GPL-2.0 2# 3# linux/arch/s390/boot/compressed/Makefile 4# 5# create a compressed vmlinux image from the original vmlinux 6# 7 8KCOV_INSTRUMENT := n 9GCOV_PROFILE := n 10UBSAN_SANITIZE := n 11KASAN_SANITIZE := n 12KCSAN_SANITIZE := n 13 14obj-y := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o 15obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o 16obj-all := $(obj-y) piggy.o syms.o 17targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 18targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4 19targets += vmlinux.bin.zst 20targets += info.bin syms.bin vmlinux.syms $(obj-all) 21 22KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR) 23KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR) 24OBJCOPYFLAGS := 25 26OBJECTS := $(addprefix $(obj)/,$(obj-y)) 27OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all)) 28 29LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T 30$(obj)/vmlinux: $(obj)/vmlinux.lds $(objtree)/arch/s390/boot/startup.a $(OBJECTS_ALL) FORCE 31 $(call if_changed,ld) 32 33LDFLAGS_vmlinux.syms := --oformat $(LD_BFD) -e startup -T 34$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(objtree)/arch/s390/boot/startup.a $(OBJECTS) FORCE 35 $(call if_changed,ld) 36 37quiet_cmd_dumpsyms = DUMPSYMS $< 38define cmd_dumpsyms 39 $(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' > "$@" 40endef 41 42$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE 43 $(call if_changed,dumpsyms) 44 45OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms 46$(obj)/syms.o: $(obj)/syms.bin FORCE 47 $(call if_changed,objcopy) 48 49OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load 50$(obj)/info.bin: vmlinux FORCE 51 $(call if_changed,objcopy) 52 53OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info 54$(obj)/info.o: $(obj)/info.bin FORCE 55 $(call if_changed,objcopy) 56 57OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S 58$(obj)/vmlinux.bin: vmlinux FORCE 59 $(call if_changed,objcopy) 60 61vmlinux.bin.all-y := $(obj)/vmlinux.bin 62 63suffix-$(CONFIG_KERNEL_GZIP) := .gz 64suffix-$(CONFIG_KERNEL_BZIP2) := .bz2 65suffix-$(CONFIG_KERNEL_LZ4) := .lz4 66suffix-$(CONFIG_KERNEL_LZMA) := .lzma 67suffix-$(CONFIG_KERNEL_LZO) := .lzo 68suffix-$(CONFIG_KERNEL_XZ) := .xz 69suffix-$(CONFIG_KERNEL_ZSTD) := .zst 70 71$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE 72 $(call if_changed,gzip) 73$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE 74 $(call if_changed,bzip2) 75$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE 76 $(call if_changed,lz4) 77$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE 78 $(call if_changed,lzma) 79$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE 80 $(call if_changed,lzo) 81$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE 82 $(call if_changed,xzkern) 83$(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) FORCE 84 $(call if_changed,zstd22) 85 86OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed 87$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE 88 $(call if_changed,objcopy) 89