1a0509109SArd Biesheuvel# SPDX-License-Identifier: GPL-2.0 2a0509109SArd Biesheuvel 3a0509109SArd Biesheuvel# to be include'd by arch/$(ARCH)/boot/Makefile after setting 4a0509109SArd Biesheuvel# EFI_ZBOOT_PAYLOAD, EFI_ZBOOT_BFD_TARGET and EFI_ZBOOT_MACH_TYPE 5a0509109SArd Biesheuvel 6a0509109SArd Biesheuvelcomp-type-$(CONFIG_KERNEL_GZIP) := gzip 7a0509109SArd Biesheuvelcomp-type-$(CONFIG_KERNEL_LZ4) := lz4 8a0509109SArd Biesheuvelcomp-type-$(CONFIG_KERNEL_LZMA) := lzma 9a0509109SArd Biesheuvelcomp-type-$(CONFIG_KERNEL_LZO) := lzo 10a0509109SArd Biesheuvelcomp-type-$(CONFIG_KERNEL_XZ) := xzkern 11a0509109SArd Biesheuvelcomp-type-$(CONFIG_KERNEL_ZSTD) := zstd22 12a0509109SArd Biesheuvel 13a0509109SArd Biesheuvel# in GZIP, the appended le32 carrying the uncompressed size is part of the 14a0509109SArd Biesheuvel# format, but in other cases, we just append it at the end for convenience, 15a0509109SArd Biesheuvel# causing the original tools to complain when checking image integrity. 16a0509109SArd Biesheuvel# So disregard it when calculating the payload size in the zimage header. 17a0509109SArd Biesheuvelzboot-method-y := $(comp-type-y)_with_size 18a0509109SArd Biesheuvelzboot-size-len-y := 4 19a0509109SArd Biesheuvel 20a0509109SArd Biesheuvelzboot-method-$(CONFIG_KERNEL_GZIP) := gzip 21a0509109SArd Biesheuvelzboot-size-len-$(CONFIG_KERNEL_GZIP) := 0 22a0509109SArd Biesheuvel 23*f57fb375SArd Biesheuvel$(obj)/vmlinuz: $(obj)/$(EFI_ZBOOT_PAYLOAD) FORCE 24a0509109SArd Biesheuvel $(call if_changed,$(zboot-method-y)) 25a0509109SArd Biesheuvel 26a0509109SArd BiesheuvelOBJCOPYFLAGS_vmlinuz.o := -I binary -O $(EFI_ZBOOT_BFD_TARGET) \ 27a0509109SArd Biesheuvel --rename-section .data=.gzdata,load,alloc,readonly,contents 28a0509109SArd Biesheuvel$(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE 29a0509109SArd Biesheuvel $(call if_changed,objcopy) 30a0509109SArd Biesheuvel 31a0509109SArd BiesheuvelAFLAGS_zboot-header.o += -DMACHINE_TYPE=IMAGE_FILE_MACHINE_$(EFI_ZBOOT_MACH_TYPE) \ 32a0509109SArd Biesheuvel -DZBOOT_EFI_PATH="\"$(realpath $(obj)/vmlinuz.efi.elf)\"" \ 33a0509109SArd Biesheuvel -DZBOOT_SIZE_LEN=$(zboot-size-len-y) \ 34a0509109SArd Biesheuvel -DCOMP_TYPE="\"$(comp-type-y)\"" 35a0509109SArd Biesheuvel 36a0509109SArd Biesheuvel$(obj)/zboot-header.o: $(srctree)/drivers/firmware/efi/libstub/zboot-header.S FORCE 37a0509109SArd Biesheuvel $(call if_changed_rule,as_o_S) 38a0509109SArd Biesheuvel 39a0509109SArd BiesheuvelZBOOT_DEPS := $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/libstub/lib.a 40a0509109SArd Biesheuvel 41a0509109SArd BiesheuvelLDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds 42a0509109SArd Biesheuvel$(obj)/vmlinuz.efi.elf: $(obj)/vmlinuz.o $(ZBOOT_DEPS) FORCE 43a0509109SArd Biesheuvel $(call if_changed,ld) 44a0509109SArd Biesheuvel 45*f57fb375SArd BiesheuvelOBJCOPYFLAGS_vmlinuz.efi := -O binary 46*f57fb375SArd Biesheuvel$(obj)/vmlinuz.efi: $(obj)/vmlinuz.efi.elf FORCE 47a0509109SArd Biesheuvel $(call if_changed,objcopy) 48a0509109SArd Biesheuvel 49a0509109SArd Biesheuveltargets += zboot-header.o vmlinuz vmlinuz.o vmlinuz.efi.elf vmlinuz.efi 50