Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 2 | # |
| 3 | # linux/arch/s390/boot/compressed/Makefile |
| 4 | # |
| 5 | # create a compressed vmlinux image from the original vmlinux |
| 6 | # |
| 7 | |
Heiko Carstens | 907fa06 | 2016-06-20 14:08:32 +0200 | [diff] [blame] | 8 | KCOV_INSTRUMENT := n |
Vasily Gorbik | 76bf9d6 | 2018-06-15 12:28:05 +0200 | [diff] [blame] | 9 | GCOV_PROFILE := n |
| 10 | UBSAN_SANITIZE := n |
Vasily Gorbik | 0a9b409 | 2017-11-17 13:10:33 +0100 | [diff] [blame] | 11 | KASAN_SANITIZE := n |
Ilya Leoshkevich | e37b3dd | 2021-07-28 13:59:04 +0200 | [diff] [blame] | 12 | KCSAN_SANITIZE := n |
Heiko Carstens | 907fa06 | 2016-06-20 14:08:32 +0200 | [diff] [blame] | 13 | |
Vasily Gorbik | 2462189 | 2020-11-11 10:59:40 +0100 | [diff] [blame] | 14 | obj-y := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o |
Vasily Gorbik | 88731c8 | 2021-07-29 15:29:19 +0200 | [diff] [blame] | 15 | obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o |
Vasily Gorbik | 2462189 | 2020-11-11 10:59:40 +0100 | [diff] [blame] | 16 | obj-all := $(obj-y) piggy.o syms.o |
Heiko Carstens | 8e2872c | 2013-07-18 15:18:24 +0200 | [diff] [blame] | 17 | targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 |
| 18 | targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4 |
Dimitri John Ledkov | 7b034d9 | 2021-06-15 12:41:50 +0100 | [diff] [blame] | 19 | targets += vmlinux.bin.zst |
Vasily Gorbik | 2462189 | 2020-11-11 10:59:40 +0100 | [diff] [blame] | 20 | targets += info.bin syms.bin vmlinux.syms $(obj-all) |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 21 | |
Vasily Gorbik | 76bf9d6 | 2018-06-15 12:28:05 +0200 | [diff] [blame] | 22 | KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR) |
| 23 | KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR) |
Vasily Gorbik | 369f91c | 2018-07-19 16:51:25 +0200 | [diff] [blame] | 24 | OBJCOPYFLAGS := |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 25 | |
Vasily Gorbik | 4560ff1 | 2018-06-12 21:52:45 +0200 | [diff] [blame] | 26 | OBJECTS := $(addprefix $(obj)/,$(obj-y)) |
Vasily Gorbik | 2462189 | 2020-11-11 10:59:40 +0100 | [diff] [blame] | 27 | OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all)) |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 28 | |
Philipp Rudo | 7a84ffc | 2020-11-25 19:08:23 +0100 | [diff] [blame] | 29 | LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T |
Vasily Gorbik | 2462189 | 2020-11-11 10:59:40 +0100 | [diff] [blame] | 30 | $(obj)/vmlinux: $(obj)/vmlinux.lds $(objtree)/arch/s390/boot/startup.a $(OBJECTS_ALL) FORCE |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 31 | $(call if_changed,ld) |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 32 | |
Vasily Gorbik | 2462189 | 2020-11-11 10:59:40 +0100 | [diff] [blame] | 33 | LDFLAGS_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 | |
| 37 | quiet_cmd_dumpsyms = DUMPSYMS $< |
| 38 | define cmd_dumpsyms |
Rob Landley | 113af8e | 2021-05-17 23:46:44 -0500 | [diff] [blame] | 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' > "$@" |
Vasily Gorbik | 2462189 | 2020-11-11 10:59:40 +0100 | [diff] [blame] | 40 | endef |
| 41 | |
| 42 | $(obj)/syms.bin: $(obj)/vmlinux.syms FORCE |
| 43 | $(call if_changed,dumpsyms) |
| 44 | |
| 45 | OBJCOPYFLAGS_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 Gorbik | 5a2e185 | 2018-10-17 13:59:46 +0200 | [diff] [blame] | 49 | OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load |
Vasily Gorbik | 369f91c | 2018-07-19 16:51:25 +0200 | [diff] [blame] | 50 | $(obj)/info.bin: vmlinux FORCE |
| 51 | $(call if_changed,objcopy) |
Vasily Gorbik | 81796a3 | 2018-03-05 09:58:00 +0100 | [diff] [blame] | 52 | |
Vasily Gorbik | 369f91c | 2018-07-19 16:51:25 +0200 | [diff] [blame] | 53 | OBJCOPYFLAGS_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 Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 56 | |
Vasily Gorbik | 369f91c | 2018-07-19 16:51:25 +0200 | [diff] [blame] | 57 | OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S |
| 58 | $(obj)/vmlinux.bin: vmlinux FORCE |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 59 | $(call if_changed,objcopy) |
| 60 | |
Vasily Gorbik | c98b6c6 | 2018-06-13 06:34:45 +0200 | [diff] [blame] | 61 | suffix-$(CONFIG_KERNEL_GZIP) := .gz |
| 62 | suffix-$(CONFIG_KERNEL_BZIP2) := .bz2 |
| 63 | suffix-$(CONFIG_KERNEL_LZ4) := .lz4 |
| 64 | suffix-$(CONFIG_KERNEL_LZMA) := .lzma |
| 65 | suffix-$(CONFIG_KERNEL_LZO) := .lzo |
| 66 | suffix-$(CONFIG_KERNEL_XZ) := .xz |
Dimitri John Ledkov | 7b034d9 | 2021-06-15 12:41:50 +0100 | [diff] [blame] | 67 | suffix-$(CONFIG_KERNEL_ZSTD) := .zst |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 68 | |
Masahiro Yamada | 53e7b5d | 2022-01-10 03:15:28 +0900 | [diff] [blame] | 69 | $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 70 | $(call if_changed,gzip) |
Masahiro Yamada | 53e7b5d | 2022-01-10 03:15:28 +0900 | [diff] [blame] | 71 | $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE |
Masahiro Yamada | 7ce7e98 | 2022-01-10 03:15:27 +0900 | [diff] [blame] | 72 | $(call if_changed,bzip2_with_size) |
Masahiro Yamada | 53e7b5d | 2022-01-10 03:15:28 +0900 | [diff] [blame] | 73 | $(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE |
Masahiro Yamada | 7ce7e98 | 2022-01-10 03:15:27 +0900 | [diff] [blame] | 74 | $(call if_changed,lz4_with_size) |
Masahiro Yamada | 53e7b5d | 2022-01-10 03:15:28 +0900 | [diff] [blame] | 75 | $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE |
Masahiro Yamada | 7ce7e98 | 2022-01-10 03:15:27 +0900 | [diff] [blame] | 76 | $(call if_changed,lzma_with_size) |
Masahiro Yamada | 53e7b5d | 2022-01-10 03:15:28 +0900 | [diff] [blame] | 77 | $(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE |
Masahiro Yamada | 7ce7e98 | 2022-01-10 03:15:27 +0900 | [diff] [blame] | 78 | $(call if_changed,lzo_with_size) |
Masahiro Yamada | 53e7b5d | 2022-01-10 03:15:28 +0900 | [diff] [blame] | 79 | $(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE |
Masahiro Yamada | 7ce7e98 | 2022-01-10 03:15:27 +0900 | [diff] [blame] | 80 | $(call if_changed,xzkern_with_size) |
Masahiro Yamada | 53e7b5d | 2022-01-10 03:15:28 +0900 | [diff] [blame] | 81 | $(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE |
Masahiro Yamada | 7ce7e98 | 2022-01-10 03:15:27 +0900 | [diff] [blame] | 82 | $(call if_changed,zstd22_with_size) |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 83 | |
Vasily Gorbik | 369f91c | 2018-07-19 16:51:25 +0200 | [diff] [blame] | 84 | OBJCOPYFLAGS_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) |