Makefile.zboot 1.9 KB

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