2 * Copyright (C) 2013-2015 Linaro Ltd
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #ifdef CONFIG_EFI_STUB
13 @ This is almost but not quite a NOP, since it does clobber the
14 @ condition flags. But it is the best we can do for EFI, since
15 @ PE/COFF expects the magic string "MZ" at offset 0, while the
16 @ ARM/Linux boot protocol expects an executable instruction
18 .inst 'M' | ('Z' << 8) | (0x1310 << 16) @ tstne r0, #0x4d000
20 AR_CLASS( mov r0, r0 )
26 #ifdef CONFIG_EFI_STUB
27 .set start_offset, __efi_start - start
30 @ The PE header can be anywhere in the file, but for
31 @ simplicity we keep it together with the MSDOS header
32 @ The offset to the PE/COFF header needs to be at offset
33 @ 0x3C in the MSDOS header.
34 @ The only 2 fields of the MSDOS header that are used are this
35 @ PE/COFF offset, and the "MZ" bytes at offset 0x0.
37 .long pe_header - start @ Offset to the PE header.
43 .short 0x01c2 @ ARM or Thumb
44 .short 2 @ nr_sections
45 .long 0 @ TimeDateStamp
46 .long 0 @ PointerToSymbolTable
47 .long 1 @ NumberOfSymbols
48 .short section_table - optional_header
49 @ SizeOfOptionalHeader
50 .short 0x306 @ Characteristics.
51 @ IMAGE_FILE_32BIT_MACHINE |
52 @ IMAGE_FILE_DEBUG_STRIPPED |
53 @ IMAGE_FILE_EXECUTABLE_IMAGE |
54 @ IMAGE_FILE_LINE_NUMS_STRIPPED
57 .short 0x10b @ PE32 format
58 .byte 0x02 @ MajorLinkerVersion
59 .byte 0x14 @ MinorLinkerVersion
60 .long _end - __efi_start @ SizeOfCode
61 .long 0 @ SizeOfInitializedData
62 .long 0 @ SizeOfUninitializedData
63 .long efi_stub_entry - start @ AddressOfEntryPoint
64 .long start_offset @ BaseOfCode
69 .long 0x200 @ SectionAlignment
70 .long 0x200 @ FileAlignment
71 .short 0 @ MajorOperatingSystemVersion
72 .short 0 @ MinorOperatingSystemVersion
73 .short 0 @ MajorImageVersion
74 .short 0 @ MinorImageVersion
75 .short 0 @ MajorSubsystemVersion
76 .short 0 @ MinorSubsystemVersion
77 .long 0 @ Win32VersionValue
79 .long _end - start @ SizeOfImage
80 .long start_offset @ SizeOfHeaders
82 .short 0xa @ Subsystem (EFI application)
83 .short 0 @ DllCharacteristics
84 .long 0 @ SizeOfStackReserve
85 .long 0 @ SizeOfStackCommit
86 .long 0 @ SizeOfHeapReserve
87 .long 0 @ SizeOfHeapCommit
89 .long 0x6 @ NumberOfRvaAndSizes
93 .quad 0 @ ResourceTable
94 .quad 0 @ ExceptionTable
95 .quad 0 @ CertificationTable
96 .quad 0 @ BaseRelocationTable
100 @ The EFI application loader requires a relocation section
101 @ because EFI applications must be relocatable. This is a
102 @ dummy section as far as we are concerned.
105 .long 0 @ VirtualSize
106 .long 0 @ VirtualAddress
107 .long 0 @ SizeOfRawData
108 .long 0 @ PointerToRawData
109 .long 0 @ PointerToRelocations
110 .long 0 @ PointerToLineNumbers
111 .short 0 @ NumberOfRelocations
112 .short 0 @ NumberOfLineNumbers
113 .long 0x42100040 @ Characteristics
116 .long _end - __efi_start @ VirtualSize
117 .long __efi_start @ VirtualAddress
118 .long _edata - __efi_start @ SizeOfRawData
119 .long __efi_start @ PointerToRawData
120 .long 0 @ PointerToRelocations
121 .long 0 @ PointerToLineNumbers
122 .short 0 @ NumberOfRelocations
123 .short 0 @ NumberOfLineNumbers
124 .long 0xe0500020 @ Characteristics