1 /* SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause */
3 * crt0-efi-aarch64.S - PE/COFF header for aarch64 EFI applications
5 * Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
8 * This file is taken and modified from the gnu-efi project.
11 #include <asm-generic/pe.h>
16 * Magic "MZ" signature for PE/COFF
21 .skip 58 /* 'MZ' + pad + offset == 64 */
22 .long pe_header - ImageBase /* Offset to the PE header */
27 .short 0xaa64 /* AArch64 */
28 .short 2 /* nr_sections */
29 .long 0 /* TimeDateStamp */
30 .long 0 /* PointerToSymbolTable */
31 .long 1 /* NumberOfSymbols */
32 .short section_table - optional_header /* SizeOfOptionalHeader */
34 * Characteristics: IMAGE_FILE_DEBUG_STRIPPED |
35 * IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED
39 .short 0x20b /* PE32+ format */
40 .byte 0x02 /* MajorLinkerVersion */
41 .byte 0x14 /* MinorLinkerVersion */
42 .long _edata - _start /* SizeOfCode */
43 .long 0 /* SizeOfInitializedData */
44 .long 0 /* SizeOfUninitializedData */
45 .long _start - ImageBase /* AddressOfEntryPoint */
46 .long _start - ImageBase /* BaseOfCode */
49 .quad 0 /* ImageBase */
50 .long 0x20 /* SectionAlignment */
51 .long 0x8 /* FileAlignment */
52 .short 0 /* MajorOperatingSystemVersion */
53 .short 0 /* MinorOperatingSystemVersion */
54 .short 0 /* MajorImageVersion */
55 .short 0 /* MinorImageVersion */
56 .short 0 /* MajorSubsystemVersion */
57 .short 0 /* MinorSubsystemVersion */
58 .long 0 /* Win32VersionValue */
60 .long _edata - ImageBase /* SizeOfImage */
63 * Everything before the kernel image is considered part of the header
65 .long _start - ImageBase /* SizeOfHeaders */
66 .long 0 /* CheckSum */
67 .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
68 .short 0 /* DllCharacteristics */
69 .quad 0 /* SizeOfStackReserve */
70 .quad 0 /* SizeOfStackCommit */
71 .quad 0 /* SizeOfHeapReserve */
72 .quad 0 /* SizeOfHeapCommit */
73 .long 0 /* LoaderFlags */
74 .long 0x6 /* NumberOfRvaAndSizes */
76 .quad 0 /* ExportTable */
77 .quad 0 /* ImportTable */
78 .quad 0 /* ResourceTable */
79 .quad 0 /* ExceptionTable */
80 .quad 0 /* CertificationTable */
81 .quad 0 /* BaseRelocationTable */
87 * The EFI application loader requires a relocation section
88 * because EFI applications must be relocatable. This is a
89 * dummy section as far as we are concerned.
93 .byte 0 /* end of 0 padding of section name */
96 .long 0 /* SizeOfRawData */
97 .long 0 /* PointerToRawData */
98 .long 0 /* PointerToRelocations */
99 .long 0 /* PointerToLineNumbers */
100 .short 0 /* NumberOfRelocations */
101 .short 0 /* NumberOfLineNumbers */
102 .long 0x42100040 /* Characteristics (section flags) */
108 .byte 0 /* end of 0 padding of section name */
109 .long _edata - _start /* VirtualSize */
110 .long _start - ImageBase /* VirtualAddress */
111 .long _edata - _start /* SizeOfRawData */
112 .long _start - ImageBase /* PointerToRawData */
114 .long 0 /* PointerToRelocations (0 for executables) */
115 .long 0 /* PointerToLineNumbers (0 for executables) */
116 .short 0 /* NumberOfRelocations (0 for executables) */
117 .short 0 /* NumberOfLineNumbers (0 for executables) */
118 .long 0xe0500020 /* Characteristics (section flags) */
121 stp x29, x30, [sp, #-32]!
124 stp x0, x1, [sp, #16]
129 add x1, x1, #:lo12:_DYNAMIC
133 ldp x0, x1, [sp, #16]
136 0: ldp x29, x30, [sp], #32