blob: d04e0e7de0b3d01c38e11ab37ba5b099f4071a55 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +01002#
3# linux/arch/s390/boot/compressed/Makefile
4#
5# create a compressed vmlinux image from the original vmlinux
6#
7
Heiko Carstens907fa062016-06-20 14:08:32 +02008KCOV_INSTRUMENT := n
Vasily Gorbik76bf9d62018-06-15 12:28:05 +02009GCOV_PROFILE := n
10UBSAN_SANITIZE := n
Vasily Gorbik0a9b4092017-11-17 13:10:33 +010011KASAN_SANITIZE := n
Ilya Leoshkeviche37b3dd2021-07-28 13:59:04 +020012KCSAN_SANITIZE := n
Heiko Carstens907fa062016-06-20 14:08:32 +020013
Vasily Gorbik24621892020-11-11 10:59:40 +010014obj-y := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
Vasily Gorbik88731c82021-07-29 15:29:19 +020015obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
Vasily Gorbik24621892020-11-11 10:59:40 +010016obj-all := $(obj-y) piggy.o syms.o
Heiko Carstens8e2872c2013-07-18 15:18:24 +020017targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
18targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
Dimitri John Ledkov7b034d92021-06-15 12:41:50 +010019targets += vmlinux.bin.zst
Vasily Gorbik24621892020-11-11 10:59:40 +010020targets += info.bin syms.bin vmlinux.syms $(obj-all)
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010021
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020022KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
23KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
Vasily Gorbik369f91c2018-07-19 16:51:25 +020024OBJCOPYFLAGS :=
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010025
Vasily Gorbik4560ff12018-06-12 21:52:45 +020026OBJECTS := $(addprefix $(obj)/,$(obj-y))
Vasily Gorbik24621892020-11-11 10:59:40 +010027OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010028
Philipp Rudo7a84ffc2020-11-25 19:08:23 +010029LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T
Vasily Gorbik24621892020-11-11 10:59:40 +010030$(obj)/vmlinux: $(obj)/vmlinux.lds $(objtree)/arch/s390/boot/startup.a $(OBJECTS_ALL) FORCE
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010031 $(call if_changed,ld)
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010032
Vasily Gorbik24621892020-11-11 10:59:40 +010033LDFLAGS_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
Rob Landley113af8e2021-05-17 23:46:44 -050039 $(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' > "$@"
Vasily Gorbik24621892020-11-11 10:59:40 +010040endef
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
Vasily Gorbik5a2e1852018-10-17 13:59:46 +020049OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
Vasily Gorbik369f91c2018-07-19 16:51:25 +020050$(obj)/info.bin: vmlinux FORCE
51 $(call if_changed,objcopy)
Vasily Gorbik81796a32018-03-05 09:58:00 +010052
Vasily Gorbik369f91c2018-07-19 16:51:25 +020053OBJCOPYFLAGS_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)
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010056
Vasily Gorbik369f91c2018-07-19 16:51:25 +020057OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
58$(obj)/vmlinux.bin: vmlinux FORCE
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010059 $(call if_changed,objcopy)
60
Vasily Gorbikc98b6c62018-06-13 06:34:45 +020061suffix-$(CONFIG_KERNEL_GZIP) := .gz
62suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
63suffix-$(CONFIG_KERNEL_LZ4) := .lz4
64suffix-$(CONFIG_KERNEL_LZMA) := .lzma
65suffix-$(CONFIG_KERNEL_LZO) := .lzo
66suffix-$(CONFIG_KERNEL_XZ) := .xz
Dimitri John Ledkov7b034d92021-06-15 12:41:50 +010067suffix-$(CONFIG_KERNEL_ZSTD) := .zst
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010068
Masahiro Yamada53e7b5d2022-01-10 03:15:28 +090069$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010070 $(call if_changed,gzip)
Masahiro Yamada53e7b5d2022-01-10 03:15:28 +090071$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
Masahiro Yamada7ce7e982022-01-10 03:15:27 +090072 $(call if_changed,bzip2_with_size)
Masahiro Yamada53e7b5d2022-01-10 03:15:28 +090073$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
Masahiro Yamada7ce7e982022-01-10 03:15:27 +090074 $(call if_changed,lz4_with_size)
Masahiro Yamada53e7b5d2022-01-10 03:15:28 +090075$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
Masahiro Yamada7ce7e982022-01-10 03:15:27 +090076 $(call if_changed,lzma_with_size)
Masahiro Yamada53e7b5d2022-01-10 03:15:28 +090077$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
Masahiro Yamada7ce7e982022-01-10 03:15:27 +090078 $(call if_changed,lzo_with_size)
Masahiro Yamada53e7b5d2022-01-10 03:15:28 +090079$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
Masahiro Yamada7ce7e982022-01-10 03:15:27 +090080 $(call if_changed,xzkern_with_size)
Masahiro Yamada53e7b5d2022-01-10 03:15:28 +090081$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
Masahiro Yamada7ce7e982022-01-10 03:15:27 +090082 $(call if_changed,zstd22_with_size)
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010083
Vasily Gorbik369f91c2018-07-19 16:51:25 +020084OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
85$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
86 $(call if_changed,objcopy)