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, EFI_ZBOOT_MACH_TYPE and 5# EFI_ZBOOT_FORWARD_CFI 6 7quiet_cmd_copy_and_pad = PAD $@ 8 cmd_copy_and_pad = cp $< $@; \ 9 truncate -s $$(hexdump -s16 -n4 -e '"%u"' $<) $@ 10 11# Pad the file to the size of the uncompressed image in memory, including BSS 12$(obj)/vmlinux.bin: $(obj)/$(EFI_ZBOOT_PAYLOAD) FORCE 13 $(call if_changed,copy_and_pad) 14 15# in GZIP, the appended le32 carrying the uncompressed size is part of the 16# format, but in other cases, we just append it at the end for convenience, 17# causing the original tools to complain when checking image integrity. 18comp-type-y := gzip 19zboot-method-y := gzip 20zboot-size-len-y := 0 21 22comp-type-$(CONFIG_KERNEL_ZSTD) := zstd 23zboot-method-$(CONFIG_KERNEL_ZSTD) := zstd22_with_size 24zboot-size-len-$(CONFIG_KERNEL_ZSTD) := 4 25 26$(obj)/vmlinuz: $(obj)/vmlinux.bin FORCE 27 $(call if_changed,$(zboot-method-y)) 28 29# avoid eager evaluation to prevent references to non-existent build artifacts 30OBJCOPYFLAGS_vmlinuz.o = -I binary -O $(EFI_ZBOOT_BFD_TARGET) $(EFI_ZBOOT_OBJCOPY_FLAGS) \ 31 --rename-section .data=.gzdata,load,alloc,readonly,contents 32$(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE 33 $(call if_changed,objcopy) 34 35aflags-zboot-header-$(EFI_ZBOOT_FORWARD_CFI) := \ 36 -DPE_DLL_CHAR_EX=IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT 37 38AFLAGS_zboot-header.o += -DMACHINE_TYPE=IMAGE_FILE_MACHINE_$(EFI_ZBOOT_MACH_TYPE) \ 39 -DZBOOT_EFI_PATH="\"$(realpath $(obj)/vmlinuz.efi.elf)\"" \ 40 -DZBOOT_SIZE_LEN=$(zboot-size-len-y) \ 41 -DCOMP_TYPE="\"$(comp-type-y)\"" \ 42 $(aflags-zboot-header-y) 43 44$(obj)/zboot-header.o: $(srctree)/drivers/firmware/efi/libstub/zboot-header.S FORCE 45 $(call if_changed_rule,as_o_S) 46 47ZBOOT_DEPS := $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/libstub/lib.a 48 49LDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds 50$(obj)/vmlinuz.efi.elf: $(obj)/vmlinuz.o $(ZBOOT_DEPS) FORCE 51 $(call if_changed,ld) 52 53OBJCOPYFLAGS_vmlinuz.efi := -O binary 54$(obj)/vmlinuz.efi: $(obj)/vmlinuz.efi.elf FORCE 55 $(call if_changed,objcopy) 56 57targets += zboot-header.o vmlinux.bin vmlinuz vmlinuz.o vmlinuz.efi.elf vmlinuz.efi 58