summaryrefslogtreecommitdiffstats
path: root/src/arch/x86_64/prefix/efiprefix.S
blob: a3b503b826f996c3dacaa371943e8b5ac76a4ccc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
	.text
	.code32
	.arch i386
	.section ".prefix", "a", @progbits
	.org 0x00

	/* DOS (.com) header
	 *
	 * EFI executables seem to leave most of this empty
	 */
mzhdr:
	.ascii	"MZ"		/* Magic number */
	.word	0		/* Bytes on last page of file */
	.word	0		/* Pages in file */
	.word	0		/* Relocations */
	.word	0		/* Size of header in paragraphs */
	.word	0		/* Minimum extra paragraphs needed */
	.word	0		/* Maximum extra paragraphs needed */
	.word	0		/* Initial (relative) SS value */
	.word	0		/* Initial SP value */
	.word	0		/* "Checksum" */
	.word	0		/* Initial IP value */
	.word	0		/* Initial (relative) CS value */
	.word	0		/* File address of relocation table */
	.word	0		/* Ovesrlay number */
	.word	0, 0, 0, 0	/* Reserved words */
	.word	0		/* OEM identifier (for e_oeminfo) */
	.word	0		/* OEM information; e_oemid specific */
	.word	0, 0, 0, 0, 0	/* Reserved words */
	.word	0, 0, 0, 0, 0	/* Reserved words */
	.long	pehdr_lma	/* File address of new exe header */
	.size	mzhdr, . - mzhdr

	/* PE header */
	.org	0xc0 /* For compatibility with MS toolchain */
pehdr:
	.ascii	"PE\0\0"	/* Magic number */
	.word	0x8664		/* CPU architecture: x86_64 */
	.word	num_pe_sections	/* Number of sections */
	.long	0x10d1a884	/* Timestamp */
	.long	0		/* Symbol table */
	.long	0		/* Number of symbols */
	.word	opthdr_size	/* Size of optional header */
	.word	0x2002		/* Characteristics */
	.size	pehdr, . - pehdr
	.equ	pehdr_lma, pehdr - mzhdr

	/* "Optional" header */
opthdr:
	.word	0x020b		/* Magic number */
	.byte	0		/* Linker major version number */
	.byte	0		/* Linker minor version number */
	.long	_text_filesz	/* Size of text section */
	.long	_data_filesz	/* Size of data section */
	.long	_bss_filesz	/* Size of bss section */
	.long	efi_entry_lma	/* Entry point */
	.long	_text_lma	/* Text section start RVA */
	.quad	0		/* Image base address */
	.long	_max_align	/* Section alignment */
	.long	_max_align	/* File alignment */
	.word	0		/* Operating system major version number */
	.word	0		/* Operating system minor version number */
	.word	0		/* Image major version number */
	.word	0		/* Image minor version number */
	.word	0		/* Subsystem major version number */
	.word	0		/* Subsystem minor version number */
	.long	0		/* Reserved */
	.long	_filesz		/* Total image size */
	.long	_prefix_filesz	/* Total header size */
	.long	0		/* "Checksum" */
	.word	0x0a		/* Subsystem: EFI */
	.word	0		/* DLL characteristics */
	.quad	0		/* Size of stack reserve */
	.quad	0		/* Size of stack commit */
	.quad	0		/* Size of heap reserve */
	.quad	0		/* Size of heap commit */
	.long	0		/* Loader flags */
	.long	16		/* Number of data directory entries */
	.long	0, 0		/* Export directory */
	.long	0, 0		/* Import directory */
	.long	0, 0		/* Resource directory */
	.long	0, 0		/* Exception directory */
	.long	0, 0		/* Security directory */
	.long	_reloc_lma, _reloc_filesz /* Base relocation directory */
	.long	debugdir_lma, debugdir_size /* Debug directory */
	.long	0, 0		/* Description directory */
	.long	0, 0		/* Special directory */
	.long	0, 0		/* Thread storage directory */
	.long	0, 0		/* Load configuration directory */
	.long	0, 0		/* Bound import directory */
	.long	0, 0		/* Import address table directory */
	.long	0, 0		/* Delay import directory */
	.long	0, 0		/* Reserved */
	.long	0, 0		/* Reserved */
	.size	opthdr, . - opthdr
	.equ	opthdr_size, . - opthdr

	/* PE sections */
pe_sections:
text_section:
	.asciz	".text"		/* Section name */
	.align	8
	.long	_text_filesz	/* Section size */
	.long	_text_lma	/* Relative Virtual Address */
	.long	_text_filesz	/* Section size (rounded up) */
	.long	_text_lma	/* Pointer to raw data */
	.long	0		/* Link-time relocations */
	.long	0		/* Line numbers */
	.word	0		/* Number of link-time relocations */
	.word	0		/* Number of line numbers */
	.long	0x68000020	/* Characteristics */
rodata_section:
	.asciz	".rodata"	/* Section name */
	.align	8
	.long	_rodata_filesz	/* Section size */
	.long	_rodata_lma	/* Relative Virtual Address */
	.long	_rodata_filesz	/* Section size (rounded up) */
	.long	_rodata_lma	/* Pointer to raw data */
	.long	0		/* Link-time relocations */
	.long	0		/* Line numbers */
	.word	0		/* Number of link-time relocations */
	.word	0		/* Number of line numbers */
	.long	0x48000040	/* Characteristics */
data_section:
	.asciz	".data"		/* Section name */
	.align	8
	.long	_data_filesz	/* Section size */
	.long	_data_lma	/* Relative Virtual Address */
	.long	_data_filesz	/* Section size (rounded up) */
	.long	_data_lma	/* Pointer to raw data */
	.long	0		/* Link-time relocations */
	.long	0		/* Line numbers */
	.word	0		/* Number of link-time relocations */
	.word	0		/* Number of line numbers */
	.long	0xc8000040	/* Characteristics */
reloc_section:
	.asciz	".reloc"	/* Section name */
	.align	8
	.long	_reloc_filesz	/* Section size */
	.long	_reloc_lma	/* Relative Virtual Address */
	.long	_reloc_filesz	/* Section size (rounded up) */
	.long	_reloc_lma	/* Pointer to raw data */
	.long	0		/* Link-time relocations */
	.long	0		/* Line numbers */
	.word	0		/* Number of link-time relocations */
	.word	0		/* Number of line numbers */
	.long	0x42000040	/* Characteristics */

pe_sections_end:
	.size	pe_sections, . - pe_sections
	.equ	num_pe_sections, ( ( . - pe_sections ) / 0x28 )

	/* Debug directory */
	.section ".rodata"
	.globl	debugdir
debugdir:
	.long	0		/* Characteristics */
	.long	0x10d1a884	/* Timestamp */
	.word	0		/* Major version */
	.word	0		/* Minor version */
	.long	0x02		/* RSDS? */
	.long	codeview_rsds_size /* Size of data */
	.long	codeview_rsds_lma /* RVA */
	.long	codeview_rsds_lma /* File offset */
	.size	debugdir, . - debugdir
	.equ	debugdir_size, . - debugdir
	/* Codeview structure */
	.globl	codeview_rsds
codeview_rsds:
	.ascii	"RSDS"		/* Magic number */
	.long	0, 0, 0, 0, 0	/* Unused by EFI */
	.asciz	"efiprefix.pdb"
	.size	codeview_rsds, . - codeview_rsds
	.equ	codeview_rsds_size, . - codeview_rsds