1/* SPDX-License-Identifier: GPL-2.0 */ 2 3#include <linux/pe.h> 4 5#ifdef CONFIG_64BIT 6 .set .Lextra_characteristics, 0x0 7 .set .Lpe_opt_magic, PE_OPT_MAGIC_PE32PLUS 8#else 9 .set .Lextra_characteristics, IMAGE_FILE_32BIT_MACHINE 10 .set .Lpe_opt_magic, PE_OPT_MAGIC_PE32 11#endif 12 13 .section ".head", "a" 14 .globl __efistub_efi_zboot_header 15__efistub_efi_zboot_header: 16.Ldoshdr: 17 .long MZ_MAGIC 18 .ascii "zimg" // image type 19 .long __efistub__gzdata_start - .Ldoshdr // payload offset 20 .long __efistub__gzdata_size - ZBOOT_SIZE_LEN // payload size 21 .long 0, 0 // reserved 22 .asciz COMP_TYPE // compression type 23 .org .Ldoshdr + 0x38 24 .long LINUX_PE_MAGIC 25 .long .Lpehdr - .Ldoshdr // PE header offset 26 27.Lpehdr: 28 .long PE_MAGIC 29 .short MACHINE_TYPE 30 .short .Lsection_count 31 .long 0 32 .long 0 33 .long 0 34 .short .Lsection_table - .Loptional_header 35 .short IMAGE_FILE_DEBUG_STRIPPED | \ 36 IMAGE_FILE_EXECUTABLE_IMAGE | \ 37 IMAGE_FILE_LINE_NUMS_STRIPPED |\ 38 .Lextra_characteristics 39 40.Loptional_header: 41 .short .Lpe_opt_magic 42 .byte 0, 0 43 .long _etext - .Lefi_header_end 44 .long __data_size 45 .long 0 46 .long __efistub_efi_zboot_entry - .Ldoshdr 47 .long .Lefi_header_end - .Ldoshdr 48 49#ifdef CONFIG_64BIT 50 .quad 0 51#else 52 .long _etext - .Ldoshdr, 0x0 53#endif 54 .long 4096 55 .long 512 56 .short 0, 0 57 .short LINUX_EFISTUB_MAJOR_VERSION // MajorImageVersion 58 .short LINUX_EFISTUB_MINOR_VERSION // MinorImageVersion 59 .short 0, 0 60 .long 0 61 .long _end - .Ldoshdr 62 63 .long .Lefi_header_end - .Ldoshdr 64 .long 0 65 .short IMAGE_SUBSYSTEM_EFI_APPLICATION 66 .short IMAGE_DLL_CHARACTERISTICS_NX_COMPAT 67#ifdef CONFIG_64BIT 68 .quad 0, 0, 0, 0 69#else 70 .long 0, 0, 0, 0 71#endif 72 .long 0 73 .long (.Lsection_table - .) / 8 74 75 .quad 0 // ExportTable 76 .quad 0 // ImportTable 77 .quad 0 // ResourceTable 78 .quad 0 // ExceptionTable 79 .quad 0 // CertificationTable 80 .quad 0 // BaseRelocationTable 81#if defined(PE_DLL_CHAR_EX) || defined(CONFIG_DEBUG_EFI) 82 .long .Lefi_debug_table - .Ldoshdr // DebugTable 83 .long .Lefi_debug_table_size 84 85 .section ".rodata", "a" 86 .p2align 2 87.Lefi_debug_table: 88 // EFI_IMAGE_DEBUG_DIRECTORY_ENTRY[] 89#ifdef PE_DLL_CHAR_EX 90 .long 0 // Characteristics 91 .long 0 // TimeDateStamp 92 .short 0 // MajorVersion 93 .short 0 // MinorVersion 94 .long IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS // Type 95 .long 4 // SizeOfData 96 .long 0 // RVA 97 .long .Lefi_dll_characteristics_ex - .Ldoshdr // FileOffset 98#endif 99#ifdef CONFIG_DEBUG_EFI 100 .long 0 // Characteristics 101 .long 0 // TimeDateStamp 102 .short 0 // MajorVersion 103 .short 0 // MinorVersion 104 .long IMAGE_DEBUG_TYPE_CODEVIEW // Type 105 .long .Lefi_debug_entry_size // SizeOfData 106 .long 0 // RVA 107 .long .Lefi_debug_entry - .Ldoshdr // FileOffset 108#endif 109 .set .Lefi_debug_table_size, . - .Lefi_debug_table 110 .previous 111#endif 112 113.Lsection_table: 114 .ascii ".text\0\0\0" 115 .long _etext - .Lefi_header_end 116 .long .Lefi_header_end - .Ldoshdr 117 .long _etext - .Lefi_header_end 118 .long .Lefi_header_end - .Ldoshdr 119 120 .long 0, 0 121 .short 0, 0 122 .long IMAGE_SCN_CNT_CODE | \ 123 IMAGE_SCN_MEM_READ | \ 124 IMAGE_SCN_MEM_EXECUTE 125 126 .ascii ".data\0\0\0" 127 .long __data_size 128 .long _etext - .Ldoshdr 129 .long __data_rawsize 130 .long _etext - .Ldoshdr 131 132 .long 0, 0 133 .short 0, 0 134 .long IMAGE_SCN_CNT_INITIALIZED_DATA | \ 135 IMAGE_SCN_MEM_READ | \ 136 IMAGE_SCN_MEM_WRITE 137 138 .set .Lsection_count, (. - .Lsection_table) / 40 139 140#ifdef PE_DLL_CHAR_EX 141.Lefi_dll_characteristics_ex: 142 .long PE_DLL_CHAR_EX 143#endif 144#ifdef CONFIG_DEBUG_EFI 145.Lefi_debug_entry: 146 // EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY 147 .ascii "NB10" // Signature 148 .long 0 // Unknown 149 .long 0 // Unknown2 150 .long 0 // Unknown3 151 152 .asciz ZBOOT_EFI_PATH 153 154 .set .Lefi_debug_entry_size, . - .Lefi_debug_entry 155#endif 156 157 .p2align 12 158.Lefi_header_end: 159 160