2 * crt0-efi-aarch64.S - PE/COFF header for AArch64 EFI applications
4 * Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice and this list of conditions, without modification.
11 * 2. The name of the author may not be used to endorse or promote products
12 * derived from this software without specific prior written permission.
14 * Alternatively, this software may be distributed under the terms of the
15 * GNU General Public License as published by the Free Software Foundation;
16 * either version 2 of the License, or (at your option) any later version.
22 * Magic "MZ" signature for PE/COFF
27 .skip 58 // 'MZ' + pad + offset == 64
28 .long pe_header - ImageBase // Offset to the PE header.
33 .short 0xaa64 // AArch64
34 .short 2 // nr_sections
35 .long 0 // TimeDateStamp
36 .long 0 // PointerToSymbolTable
37 .long 1 // NumberOfSymbols
38 .short section_table - optional_header // SizeOfOptionalHeader
39 .short 0x206 // Characteristics.
40 // IMAGE_FILE_DEBUG_STRIPPED |
41 // IMAGE_FILE_EXECUTABLE_IMAGE |
42 // IMAGE_FILE_LINE_NUMS_STRIPPED
44 .short 0x20b // PE32+ format
45 .byte 0x02 // MajorLinkerVersion
46 .byte 0x14 // MinorLinkerVersion
47 .long _data - _start // SizeOfCode
48 .long _data_size // SizeOfInitializedData
49 .long 0 // SizeOfUninitializedData
50 .long _start - ImageBase // AddressOfEntryPoint
51 .long _start - ImageBase // BaseOfCode
55 .long 0x1000 // SectionAlignment
56 .long 0x200 // FileAlignment
57 .short 0 // MajorOperatingSystemVersion
58 .short 0 // MinorOperatingSystemVersion
59 .short 0 // MajorImageVersion
60 .short 0 // MinorImageVersion
61 .short 0 // MajorSubsystemVersion
62 .short 0 // MinorSubsystemVersion
63 .long 0 // Win32VersionValue
65 .long _edata - ImageBase // SizeOfImage
67 // Everything before the kernel image is considered part of the header
68 .long _start - ImageBase // SizeOfHeaders
70 .short EFI_SUBSYSTEM // Subsystem
71 .short 0 // DllCharacteristics
72 .quad 0 // SizeOfStackReserve
73 .quad 0 // SizeOfStackCommit
74 .quad 0 // SizeOfHeapReserve
75 .quad 0 // SizeOfHeapCommit
76 .long 0 // LoaderFlags
77 .long 0x6 // NumberOfRvaAndSizes
79 .quad 0 // ExportTable
80 .quad 0 // ImportTable
81 .quad 0 // ResourceTable
82 .quad 0 // ExceptionTable
83 .quad 0 // CertificationTable
84 .quad 0 // BaseRelocationTable
89 .long _data - _start // VirtualSize
90 .long _start - ImageBase // VirtualAddress
91 .long _data - _start // SizeOfRawData
92 .long _start - ImageBase // PointerToRawData
94 .long 0 // PointerToRelocations (0 for executables)
95 .long 0 // PointerToLineNumbers (0 for executables)
96 .short 0 // NumberOfRelocations (0 for executables)
97 .short 0 // NumberOfLineNumbers (0 for executables)
98 .long 0x60000020 // Characteristics (section flags)
101 .long _data_size // VirtualSize
102 .long _data - ImageBase // VirtualAddress
103 .long _data_size // SizeOfRawData
104 .long _data - ImageBase // PointerToRawData
106 .long 0 // PointerToRelocations (0 for executables)
107 .long 0 // PointerToLineNumbers (0 for executables)
108 .short 0 // NumberOfRelocations (0 for executables)
109 .short 0 // NumberOfLineNumbers (0 for executables)
110 .long 0xc0000040 // Characteristics (section flags)
114 stp x29, x30, [sp, #-32]!
117 stp x0, x1, [sp, #16]
122 add x1, x1, #:lo12:_DYNAMIC
126 ldp x0, x1, [sp, #16]
129 0: ldp x29, x30, [sp], #32