1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2013-2017 Linaro Ltd 4 * Authors: Roy Franz <roy.franz@linaro.org> 5 * Ard Biesheuvel <ard.biesheuvel@lina 6 */ 7 8 #include <linux/pe.h> 9 #include <linux/sizes.h> 10 11 .macro __nop 12 AR_CLASS( mov r0, r0 ) 13 M_CLASS( nop.w ) 14 .endm 15 16 .macro __initial_nops 17 #ifdef CONFIG_EFI_STUB 18 @ This is a two-instruction NO 19 @ PE/COFF signature "MZ" in th 20 @ is accepted as an EFI binary 21 @ will not execute those instr 22 @ boot protocol does, so we ne 23 .inst MZ_MAGIC | (0xe225 << 24 eor r5, r5, 0x4d000 25 #else 26 __nop 27 __nop 28 #endif 29 .endm 30 31 .macro __EFI_HEADER 32 #ifdef CONFIG_EFI_STUB 33 .set start_offset, __efi_st 34 .org start + 0x3c 35 @ 36 @ The PE header can be anywher 37 @ simplicity we keep it togeth 38 @ The offset to the PE/COFF he 39 @ 0x3C in the MSDOS header. 40 @ The only 2 fields of the MSD 41 @ PE/COFF offset, and the "MZ" 42 @ 43 .long pe_header - start 44 45 pe_header: 46 .long PE_MAGIC 47 48 coff_header: 49 .short IMAGE_FILE_MACHINE_THU 50 .short section_count 51 .long 0 52 .long 0 53 .long 0 54 .short section_table - option 55 .short IMAGE_FILE_32BIT_MACHI 56 IMAGE_FILE_DEBUG_STRIP 57 IMAGE_FILE_EXECUTABLE_ 58 IMAGE_FILE_LINE_NUMS_S 59 60 #define __pecoff_code_size (__pecoff_data_star 61 62 optional_header: 63 .short PE_OPT_MAGIC_PE32 64 .byte 0x02 65 .byte 0x14 66 .long __pecoff_code_size 67 .long __pecoff_data_size 68 .long 0 69 .long efi_pe_entry - start 70 .long start_offset 71 .long __pecoff_data_start - 72 73 extra_header_fields: 74 .long 0 75 .long SZ_4K 76 .long SZ_512 77 .short 0 78 .short 0 79 .short LINUX_EFISTUB_MAJOR_VE 80 .short LINUX_EFISTUB_MINOR_VE 81 .short 0 82 .short 0 83 .long 0 84 85 .long __pecoff_end - start 86 .long start_offset 87 .long 0 88 .short IMAGE_SUBSYSTEM_EFI_AP 89 .short 0 90 .long 0 91 .long 0 92 .long 0 93 .long 0 94 .long 0 95 .long (section_table - .) / 96 97 .quad 0 98 .quad 0 99 .quad 0 100 .quad 0 101 .quad 0 102 .quad 0 103 104 section_table: 105 .ascii ".text\0\0\0" 106 .long __pecoff_code_size 107 .long __efi_start 108 .long __pecoff_code_size 109 .long __efi_start 110 .long 0 111 .long 0 112 .short 0 113 .short 0 114 .long IMAGE_SCN_CNT_CODE | \ 115 IMAGE_SCN_MEM_READ | \ 116 IMAGE_SCN_MEM_EXECUTE 117 118 .ascii ".data\0\0\0" 119 .long __pecoff_data_size 120 .long __pecoff_data_start - 121 .long __pecoff_data_rawsize 122 .long __pecoff_data_start - 123 .long 0 124 .long 0 125 .short 0 126 .short 0 127 .long IMAGE_SCN_CNT_INITIALI 128 IMAGE_SCN_MEM_READ | \ 129 IMAGE_SCN_MEM_WRITE 130 131 .set section_count, (. - se 132 133 .align 12 134 __efi_start: 135 #endif 136 .endm
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.