2 * Copyright (C) 2013 - 2017 Linaro, Ltd.
3 * Copyright (C) 2013, 2014 Red Hat, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
10 .macro __EFI_PE_HEADER
14 .short 0xaa64 // AArch64
15 .short 1 // nr_sections
16 .long 0 // TimeDateStamp
17 .long 0 // PointerToSymbolTable
18 .long 0 // NumberOfSymbols
19 .short section_table - optional_header // SizeOfOptionalHeader
20 .short 0x206 // Characteristics.
21 // IMAGE_FILE_DEBUG_STRIPPED |
22 // IMAGE_FILE_EXECUTABLE_IMAGE |
23 // IMAGE_FILE_LINE_NUMS_STRIPPED
25 .short 0x20b // PE32+ format
26 .byte 0x02 // MajorLinkerVersion
27 .byte 0x14 // MinorLinkerVersion
28 .long _end - efi_header_end // SizeOfCode
29 .long 0 // SizeOfInitializedData
30 .long 0 // SizeOfUninitializedData
31 .long __efistub_entry - _head // AddressOfEntryPoint
32 .long efi_header_end - _head // BaseOfCode
36 .long 0x1000 // SectionAlignment
37 .long PECOFF_FILE_ALIGNMENT // FileAlignment
38 .short 0 // MajorOperatingSystemVersion
39 .short 0 // MinorOperatingSystemVersion
40 .short 0 // MajorImageVersion
41 .short 0 // MinorImageVersion
42 .short 0 // MajorSubsystemVersion
43 .short 0 // MinorSubsystemVersion
44 .long 0 // Win32VersionValue
46 .long _end - _head // SizeOfImage
48 // Everything before the kernel image is considered part of the header
49 .long efi_header_end - _head // SizeOfHeaders
51 .short 0xa // Subsystem (EFI application)
52 .short 0 // DllCharacteristics
53 .quad 0 // SizeOfStackReserve
54 .quad 0 // SizeOfStackCommit
55 .quad 0 // SizeOfHeapReserve
56 .quad 0 // SizeOfHeapCommit
57 .long 0 // LoaderFlags
58 .long (section_table - .) / 8 // NumberOfRvaAndSizes
60 .quad 0 // ExportTable
61 .quad 0 // ImportTable
62 .quad 0 // ResourceTable
63 .quad 0 // ExceptionTable
64 .quad 0 // CertificationTable
65 .quad 0 // BaseRelocationTable
67 #ifdef CONFIG_DEBUG_EFI
68 .long efi_debug_table - _head // DebugTable
69 .long efi_debug_table_size
77 .byte 0 // end of 0 padding of section name
78 .long _end - efi_header_end // VirtualSize
79 .long efi_header_end - _head // VirtualAddress
80 .long _edata - efi_header_end // SizeOfRawData
81 .long efi_header_end - _head // PointerToRawData
83 .long 0 // PointerToRelocations
84 .long 0 // PointerToLineNumbers
85 .short 0 // NumberOfRelocations
86 .short 0 // NumberOfLineNumbers
87 .long 0xe0000020 // Characteristics
89 #ifdef CONFIG_DEBUG_EFI
91 * The debug table is referenced via its Relative Virtual Address (RVA),
92 * which is only defined for those parts of the image that are covered
93 * by a section declaration. Since this header is not covered by any
94 * section, the debug table must be emitted elsewhere. So stick it in
95 * the .init.rodata section instead.
97 * Note that the EFI debug entry itself may legally have a zero RVA,
98 * which means we can simply put it right after the section headers.
104 // EFI_IMAGE_DEBUG_DIRECTORY_ENTRY
105 .long 0 // Characteristics
106 .long 0 // TimeDateStamp
107 .short 0 // MajorVersion
108 .short 0 // MinorVersion
109 .long 2 // Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW
110 .long efi_debug_entry_size // SizeOfData
112 .long efi_debug_entry - _head // FileOffset
114 .set efi_debug_table_size, . - efi_debug_table
118 // EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY
119 .ascii "NB10" // Signature
126 .set efi_debug_entry_size, . - efi_debug_entry
130 * EFI will load .text onwards at the 4k section alignment
131 * described in the PE/COFF header. To ensure that instruction
132 * sequences using an adrp and a :lo12: immediate will function
133 * correctly at this alignment, we must ensure that .text is
134 * placed at a 4k boundary in the Image to begin with.