1# SPDX-License-Identifier: GPL-2.0 2 3# to be include'd by arch/$(ARCH)/boot/Makefile after setting 4# EFI_ZBOOT_PAYLOAD, EFI_ZBOOT_BFD_TARGET and EFI_ZBOOT_MACH_TYPE 5 6comp-type-$(CONFIG_KERNEL_GZIP) := gzip 7comp-type-$(CONFIG_KERNEL_LZ4) := lz4 8comp-type-$(CONFIG_KERNEL_LZMA) := lzma 9comp-type-$(CONFIG_KERNEL_LZO) := lzo 10comp-type-$(CONFIG_KERNEL_XZ) := xzkern 11comp-type-$(CONFIG_KERNEL_ZSTD) := zstd22 12 13# Copy the SizeOfHeaders, SizeOfCode and SizeOfImage fields from the payload to 14# the end of the compressed image. Note that this presupposes a PE header 15# offset of 64 bytes, which is what arm64, RISC-V and LoongArch use. 16quiet_cmd_compwithsize = $(quiet_cmd_$(comp-type-y)) 17 cmd_compwithsize = $(cmd_$(comp-type-y)) && ( \ 18 dd status=none if=$< bs=4 count=1 skip=37 ; \ 19 dd status=none if=$< bs=4 count=1 skip=23 ; \ 20 dd status=none if=$< bs=4 count=1 skip=36 ) >> $@ 21 22$(obj)/vmlinuz: $(obj)/$(EFI_ZBOOT_PAYLOAD) FORCE 23 $(call if_changed,compwithsize) 24 25OBJCOPYFLAGS_vmlinuz.o := -I binary -O $(EFI_ZBOOT_BFD_TARGET) \ 26 --rename-section .data=.gzdata,load,alloc,readonly,contents 27$(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE 28 $(call if_changed,objcopy) 29 30AFLAGS_zboot-header.o += -DMACHINE_TYPE=IMAGE_FILE_MACHINE_$(EFI_ZBOOT_MACH_TYPE) \ 31 -DZBOOT_EFI_PATH="\"$(realpath $(obj)/vmlinuz.efi.elf)\"" \ 32 -DCOMP_TYPE="\"$(comp-type-y)\"" 33 34$(obj)/zboot-header.o: $(srctree)/drivers/firmware/efi/libstub/zboot-header.S FORCE 35 $(call if_changed_rule,as_o_S) 36 37ZBOOT_DEPS := $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/libstub/lib.a 38 39LDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds 40$(obj)/vmlinuz.efi.elf: $(obj)/vmlinuz.o $(ZBOOT_DEPS) FORCE 41 $(call if_changed,ld) 42 43OBJCOPYFLAGS_vmlinuz.efi := -O binary 44$(obj)/vmlinuz.efi: $(obj)/vmlinuz.efi.elf FORCE 45 $(call if_changed,objcopy) 46 47targets += zboot-header.o vmlinuz.o vmlinuz.efi.elf vmlinuz.efi 48