Makefile.zboot 2.2 KB

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