1 /* SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause */
3 * crt0-efi-arm.S - PE/COFF header for ARM EFI applications
5 * Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
7 * This file is taken and modified from the gnu-efi project.
10 #include <asm-generic/pe.h>
15 * Magic "MZ" signature for PE/COFF
20 .skip 58 /* 'MZ' + pad + offset == 64 */
21 .long pe_header - image_base /* Offset to the PE header */
26 .short 0x1c2 /* Mixed ARM/Thumb */
27 .short 2 /* nr_sections */
28 .long 0 /* TimeDateStamp */
29 .long 0 /* PointerToSymbolTable */
30 .long 0 /* NumberOfSymbols */
31 .short section_table - optional_header /* SizeOfOptionalHeader */
33 .short (IMAGE_FILE_EXECUTABLE_IMAGE | \
34 IMAGE_FILE_LINE_NUMS_STRIPPED | \
35 IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
36 IMAGE_FILE_32BIT_MACHINE | \
37 IMAGE_FILE_DEBUG_STRIPPED)
39 .short 0x10b /* 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 - image_base /* AddressOfEntryPoint */
46 .long _start - image_base /* BaseOfCode */
47 .long 0 /* BaseOfData */
50 .long 0 /* image_base */
51 .long 0x20 /* SectionAlignment */
52 .long 0x8 /* FileAlignment */
53 .short 0 /* MajorOperatingSystemVersion */
54 .short 0 /* MinorOperatingSystemVersion */
55 .short 0 /* MajorImageVersion */
56 .short 0 /* MinorImageVersion */
57 .short 0 /* MajorSubsystemVersion */
58 .short 0 /* MinorSubsystemVersion */
59 .long 0 /* Win32VersionValue */
61 .long _edata - image_base /* SizeOfImage */
64 * Everything before the kernel image is considered part of the header
66 .long _start - image_base /* SizeOfHeaders */
67 .long 0 /* CheckSum */
68 .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
69 .short 0 /* DllCharacteristics */
70 .long 0 /* SizeOfStackReserve */
71 .long 0 /* SizeOfStackCommit */
72 .long 0 /* SizeOfHeapReserve */
73 .long 0 /* SizeOfHeapCommit */
74 .long 0 /* LoaderFlags */
75 .long 0x6 /* NumberOfRvaAndSizes */
77 .quad 0 /* ExportTable */
78 .quad 0 /* ImportTable */
79 .quad 0 /* ResourceTable */
80 .quad 0 /* ExceptionTable */
81 .quad 0 /* CertificationTable */
82 .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) */
107 .byte 0 /* end of 0 padding of section name */
108 .long _edata - _start /* VirtualSize */
109 .long _start - image_base /* VirtualAddress */
110 .long _edata - _start /* SizeOfRawData */
111 .long _start - image_base /* PointerToRawData */
113 .long 0 /* PointerToRelocations (0 for executables) */
114 .long 0 /* PointerToLineNumbers (0 for executables) */
115 .short 0 /* NumberOfRelocations (0 for executables) */
116 .short 0 /* NumberOfLineNumbers (0 for executables) */
117 .long 0xe0500020 /* Characteristics (section flags) */
120 stmfd sp!, {r0-r2, lr}