Makefile.zboot (38c87827ffd3c7e1dd61eee9a7dea13d487dc2ed) | Makefile.zboot (45dd403da851124412d32e3193c21de4a51d29da) |
---|---|
1# SPDX-License-Identifier: GPL-2.0 2 3# to be include'd by arch/$(ARCH)/boot/Makefile after setting | 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 | 4# EFI_ZBOOT_PAYLOAD, EFI_ZBOOT_BFD_TARGET, EFI_ZBOOT_MACH_TYPE and 5# EFI_ZBOOT_FORWARD_CFI |
5 | 6 |
7quiet_cmd_copy_and_pad = PAD $@ 8 cmd_copy_and_pad = cp $< $@ && \ 9 truncate -s $(shell 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 |
|
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 | 15comp-type-$(CONFIG_KERNEL_GZIP) := gzip 16comp-type-$(CONFIG_KERNEL_LZ4) := lz4 17comp-type-$(CONFIG_KERNEL_LZMA) := lzma 18comp-type-$(CONFIG_KERNEL_LZO) := lzo 19comp-type-$(CONFIG_KERNEL_XZ) := xzkern 20comp-type-$(CONFIG_KERNEL_ZSTD) := zstd22 21 |
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)) && ( \ | 22# in GZIP, the appended le32 carrying the uncompressed size is part of the 23# format, but in other cases, we just append it at the end for convenience, 24# causing the original tools to complain when checking image integrity. 25# So disregard it when calculating the payload size in the zimage header. 26zboot-method-y := $(comp-type-y)_with_size 27zboot-size-len-y := 12 28 29zboot-method-$(CONFIG_KERNEL_GZIP) := gzip 30zboot-size-len-$(CONFIG_KERNEL_GZIP) := 8 31 32# Copy the SizeOfHeaders and SizeOfCode fields from the payload to the end of 33# the compressed image. Note that this presupposes a PE header offset of 64 34# bytes, which is what arm64, RISC-V and LoongArch use. 35quiet_cmd_compwithsize = $(quiet_cmd_$(zboot-method-y)) 36 cmd_compwithsize = $(cmd_$(zboot-method-y)) && ( \ |
18 dd status=none if=$< bs=4 count=1 skip=37 ; \ | 37 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 ) >> $@ | 38 dd status=none if=$< bs=4 count=1 skip=23 ) >> $@ |
21 | 39 |
22$(obj)/vmlinuz: $(obj)/$(EFI_ZBOOT_PAYLOAD) FORCE | 40$(obj)/vmlinuz: $(obj)/vmlinux.bin FORCE |
23 $(call if_changed,compwithsize) 24 | 41 $(call if_changed,compwithsize) 42 |
25OBJCOPYFLAGS_vmlinuz.o := -I binary -O $(EFI_ZBOOT_BFD_TARGET) \ | 43OBJCOPYFLAGS_vmlinuz.o := -I binary -O $(EFI_ZBOOT_BFD_TARGET) $(EFI_ZBOOT_OBJCOPY_FLAGS) \ |
26 --rename-section .data=.gzdata,load,alloc,readonly,contents 27$(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE 28 $(call if_changed,objcopy) 29 | 44 --rename-section .data=.gzdata,load,alloc,readonly,contents 45$(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE 46 $(call if_changed,objcopy) 47 |
48aflags-zboot-header-$(EFI_ZBOOT_FORWARD_CFI) := \ 49 -DPE_DLL_CHAR_EX=IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT 50 |
|
30AFLAGS_zboot-header.o += -DMACHINE_TYPE=IMAGE_FILE_MACHINE_$(EFI_ZBOOT_MACH_TYPE) \ 31 -DZBOOT_EFI_PATH="\"$(realpath $(obj)/vmlinuz.efi.elf)\"" \ | 51AFLAGS_zboot-header.o += -DMACHINE_TYPE=IMAGE_FILE_MACHINE_$(EFI_ZBOOT_MACH_TYPE) \ 52 -DZBOOT_EFI_PATH="\"$(realpath $(obj)/vmlinuz.efi.elf)\"" \ |
32 -DCOMP_TYPE="\"$(comp-type-y)\"" | 53 -DZBOOT_SIZE_LEN=$(zboot-size-len-y) \ 54 -DCOMP_TYPE="\"$(comp-type-y)\"" \ 55 $(aflags-zboot-header-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 | 56 57$(obj)/zboot-header.o: $(srctree)/drivers/firmware/efi/libstub/zboot-header.S FORCE 58 $(call if_changed_rule,as_o_S) 59 60ZBOOT_DEPS := $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/libstub/lib.a 61 62LDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds 63$(obj)/vmlinuz.efi.elf: $(obj)/vmlinuz.o $(ZBOOT_DEPS) FORCE 64 $(call if_changed,ld) 65 66OBJCOPYFLAGS_vmlinuz.efi := -O binary 67$(obj)/vmlinuz.efi: $(obj)/vmlinuz.efi.elf FORCE 68 $(call if_changed,objcopy) 69 |
47targets += zboot-header.o vmlinuz vmlinuz.o vmlinuz.efi.elf vmlinuz.efi | 70targets += zboot-header.o vmlinux.bin vmlinuz vmlinuz.o vmlinuz.efi.elf vmlinuz.efi |