Add data structured for X64 unwind info
[mirror_edk2.git] / Tools / Source / TianoTools / Include / Common / EfiImage.h
CommitLineData
21b50a27 1/** @file\r
2 EFI image format for PE32+. Please note some data structures are different\r
3 for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64\r
4\r
5 @bug Fix text - doc as defined in MSFT EFI specification.\r
6\r
7 Copyright (c) 2006, Intel Corporation \r
8 All rights reserved. This program and the accompanying materials \r
9 are licensed and made available under the terms and conditions of the BSD License \r
10 which accompanies this distribution. The full text of the license may be found at \r
11 http://opensource.org/licenses/bsd-license.php \r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15\r
16 Module Name: EfiImage.h\r
17\r
18**/\r
19\r
20#ifndef __EFI_IMAGE_H__\r
21#define __EFI_IMAGE_H__\r
22\r
23//\r
24// PE32+ Subsystem type for EFI images\r
25//\r
26#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10\r
27#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11\r
28#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12\r
29#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13\r
30\r
31//\r
32// BugBug: Need to get a real answer for this problem. This is not in the\r
33// PE specification.\r
34//\r
35// A SAL runtime driver does not get fixed up when a transition to\r
36// virtual mode is made. In all other cases it should be treated\r
37// like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image\r
38//\r
39#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13\r
40\r
41//\r
42// PE32+ Machine type for EFI images\r
43//\r
44#define IMAGE_FILE_MACHINE_I386 0x014c\r
45#define IMAGE_FILE_MACHINE_IA64 0x0200\r
46#define IMAGE_FILE_MACHINE_EBC 0x0EBC\r
47#define IMAGE_FILE_MACHINE_X64 0x8664\r
48//\r
49// Support old names for backward compatible\r
50//\r
51#define EFI_IMAGE_MACHINE_IA32 IMAGE_FILE_MACHINE_I386 \r
52#define EFI_IMAGE_MACHINE_IA64 IMAGE_FILE_MACHINE_IA64 \r
53#define EFI_IMAGE_MACHINE_IPF IMAGE_FILE_MACHINE_IA64 \r
54#define EFI_IMAGE_MACHINE_EBC IMAGE_FILE_MACHINE_EBC \r
55#define EFI_IMAGE_MACHINE_X64 IMAGE_FILE_MACHINE_X64\r
56\r
57#define EFI_IMAGE_DOS_SIGNATURE 0x5A4D // MZ\r
58#define EFI_IMAGE_OS2_SIGNATURE 0x454E // NE\r
59#define EFI_IMAGE_OS2_SIGNATURE_LE 0x454C // LE\r
60#define EFI_IMAGE_NT_SIGNATURE 0x00004550 // PE00\r
61#define EFI_IMAGE_EDOS_SIGNATURE 0x44454550 // PEED\r
62\r
63///\r
64/// PE images can start with an optional DOS header, so if an image is run\r
65/// under DOS it can print an error message.\r
66///\r
67typedef struct {\r
68 UINT16 e_magic; // Magic number\r
69 UINT16 e_cblp; // Bytes on last page of file\r
70 UINT16 e_cp; // Pages in file\r
71 UINT16 e_crlc; // Relocations\r
72 UINT16 e_cparhdr; // Size of header in paragraphs\r
73 UINT16 e_minalloc; // Minimum extra paragraphs needed\r
74 UINT16 e_maxalloc; // Maximum extra paragraphs needed\r
75 UINT16 e_ss; // Initial (relative) SS value\r
76 UINT16 e_sp; // Initial SP value\r
77 UINT16 e_csum; // Checksum\r
78 UINT16 e_ip; // Initial IP value\r
79 UINT16 e_cs; // Initial (relative) CS value\r
80 UINT16 e_lfarlc; // File address of relocation table\r
81 UINT16 e_ovno; // Overlay number\r
82 UINT16 e_res[4]; // Reserved words\r
83 UINT16 e_oemid; // OEM identifier (for e_oeminfo)\r
84 UINT16 e_oeminfo; // OEM information; e_oemid specific\r
85 UINT16 e_res2[10]; // Reserved words\r
86 UINT32 e_lfanew; // File address of new exe header\r
87} EFI_IMAGE_DOS_HEADER;\r
88\r
89///\r
90/// File header format.\r
91///\r
92typedef struct {\r
93 UINT16 Machine;\r
94 UINT16 NumberOfSections;\r
95 UINT32 TimeDateStamp;\r
96 UINT32 PointerToSymbolTable;\r
97 UINT32 NumberOfSymbols;\r
98 UINT16 SizeOfOptionalHeader;\r
99 UINT16 Characteristics;\r
100} EFI_IMAGE_FILE_HEADER;\r
101\r
102#define EFI_IMAGE_SIZEOF_FILE_HEADER 20\r
103\r
104#define EFI_IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file.\r
105#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references).\r
106#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file.\r
107#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file.\r
108#define EFI_IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed.\r
109#define EFI_IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine.\r
110#define EFI_IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file\r
111#define EFI_IMAGE_FILE_SYSTEM 0x1000 // System File.\r
112#define EFI_IMAGE_FILE_DLL 0x2000 // File is a DLL.\r
113#define EFI_IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed.\r
114#define EFI_IMAGE_FILE_MACHINE_UNKNOWN 0\r
115#define EFI_IMAGE_FILE_MACHINE_I386 0x14c // Intel 386.\r
116#define EFI_IMAGE_FILE_MACHINE_R3000 0x162 // MIPS* little-endian, 0540 big-endian\r
117#define EFI_IMAGE_FILE_MACHINE_R4000 0x166 // MIPS* little-endian\r
118#define EFI_IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP*\r
119#define EFI_IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM* PowerPC Little-Endian\r
120#define EFI_IMAGE_FILE_MACHINE_TAHOE 0x7cc // Intel EM machine\r
121//\r
122// * Other names and brands may be claimed as the property of others.\r
123//\r
124\r
125///\r
126/// Directory format.\r
127///\r
128typedef struct {\r
129 UINT32 VirtualAddress;\r
130 UINT32 Size;\r
131} EFI_IMAGE_DATA_DIRECTORY;\r
132\r
133#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16\r
134\r
135typedef struct {\r
136 UINT16 Magic;\r
137 UINT8 MajorLinkerVersion;\r
138 UINT8 MinorLinkerVersion;\r
139 UINT32 SizeOfCode;\r
140 UINT32 SizeOfInitializedData;\r
141 UINT32 SizeOfUninitializedData;\r
142 UINT32 AddressOfEntryPoint;\r
143 UINT32 BaseOfCode;\r
144 UINT32 BaseOfData;\r
145 UINT32 BaseOfBss;\r
146 UINT32 GprMask;\r
147 UINT32 CprMask[4];\r
148 UINT32 GpValue;\r
149} EFI_IMAGE_ROM_OPTIONAL_HEADER;\r
150\r
151#define EFI_IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107\r
152#define EFI_IMAGE_SIZEOF_ROM_OPTIONAL_HEADER sizeof (EFI_IMAGE_ROM_OPTIONAL_HEADER)\r
153\r
154typedef struct {\r
155 EFI_IMAGE_FILE_HEADER FileHeader;\r
156 EFI_IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;\r
157} EFI_IMAGE_ROM_HEADERS;\r
158\r
159///\r
160/// @attention\r
161/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
162/// are for use ONLY by tools. All proper EFI code MUST use\r
163/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
164///\r
165#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b\r
166\r
167typedef struct {\r
168 //\r
169 // Standard fields.\r
170 //\r
171 UINT16 Magic;\r
172 UINT8 MajorLinkerVersion;\r
173 UINT8 MinorLinkerVersion;\r
174 UINT32 SizeOfCode;\r
175 UINT32 SizeOfInitializedData;\r
176 UINT32 SizeOfUninitializedData;\r
177 UINT32 AddressOfEntryPoint;\r
178 UINT32 BaseOfCode;\r
179 UINT32 BaseOfData;\r
180 //\r
181 // NT additional fields.\r
182 //\r
183 UINT32 ImageBase;\r
184 UINT32 SectionAlignment;\r
185 UINT32 FileAlignment;\r
186 UINT16 MajorOperatingSystemVersion;\r
187 UINT16 MinorOperatingSystemVersion;\r
188 UINT16 MajorImageVersion;\r
189 UINT16 MinorImageVersion;\r
190 UINT16 MajorSubsystemVersion;\r
191 UINT16 MinorSubsystemVersion;\r
192 UINT32 Win32VersionValue;\r
193 UINT32 SizeOfImage;\r
194 UINT32 SizeOfHeaders;\r
195 UINT32 CheckSum;\r
196 UINT16 Subsystem;\r
197 UINT16 DllCharacteristics;\r
198 UINT32 SizeOfStackReserve;\r
199 UINT32 SizeOfStackCommit;\r
200 UINT32 SizeOfHeapReserve;\r
201 UINT32 SizeOfHeapCommit;\r
202 UINT32 LoaderFlags;\r
203 UINT32 NumberOfRvaAndSizes;\r
204 EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
205} EFI_IMAGE_OPTIONAL_HEADER32;\r
206\r
207///\r
208/// @attention\r
209/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
210/// are for use ONLY by tools. All proper EFI code MUST use\r
211/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
212///\r
213#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b\r
214\r
215typedef struct {\r
216 //\r
217 // Standard fields.\r
218 //\r
219 UINT16 Magic;\r
220 UINT8 MajorLinkerVersion;\r
221 UINT8 MinorLinkerVersion;\r
222 UINT32 SizeOfCode;\r
223 UINT32 SizeOfInitializedData;\r
224 UINT32 SizeOfUninitializedData;\r
225 UINT32 AddressOfEntryPoint;\r
226 UINT32 BaseOfCode;\r
227 //\r
228 // NT additional fields.\r
229 //\r
230 UINT64 ImageBase;\r
231 UINT32 SectionAlignment;\r
232 UINT32 FileAlignment;\r
233 UINT16 MajorOperatingSystemVersion;\r
234 UINT16 MinorOperatingSystemVersion;\r
235 UINT16 MajorImageVersion;\r
236 UINT16 MinorImageVersion;\r
237 UINT16 MajorSubsystemVersion;\r
238 UINT16 MinorSubsystemVersion;\r
239 UINT32 Win32VersionValue;\r
240 UINT32 SizeOfImage;\r
241 UINT32 SizeOfHeaders;\r
242 UINT32 CheckSum;\r
243 UINT16 Subsystem;\r
244 UINT16 DllCharacteristics;\r
245 UINT64 SizeOfStackReserve;\r
246 UINT64 SizeOfStackCommit;\r
247 UINT64 SizeOfHeapReserve;\r
248 UINT64 SizeOfHeapCommit;\r
249 UINT32 LoaderFlags;\r
250 UINT32 NumberOfRvaAndSizes;\r
251 EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
252} EFI_IMAGE_OPTIONAL_HEADER64;\r
253\r
254///\r
255/// @attention\r
256/// EFI_IMAGE_NT_HEADERS32 and EFI_IMAGE_HEADERS64 are for use ONLY\r
257/// by tools. All proper EFI code MUST use EFI_IMAGE_NT_HEADERS ONLY!!!\r
258///\r
259typedef struct {\r
260 UINT32 Signature;\r
261 EFI_IMAGE_FILE_HEADER FileHeader;\r
262 EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader;\r
263} EFI_IMAGE_NT_HEADERS32;\r
264\r
265#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)\r
266\r
267typedef struct {\r
268 UINT32 Signature;\r
269 EFI_IMAGE_FILE_HEADER FileHeader;\r
270 EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader;\r
271} EFI_IMAGE_NT_HEADERS64;\r
272\r
273#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)\r
274\r
275//\r
276// Processor specific definition of EFI_IMAGE_OPTIONAL_HEADER so the\r
277// type name EFI_IMAGE_OPTIONAL_HEADER is appropriate to the build. Same for\r
278// EFI_IMAGE_NT_HEADERS. These definitions MUST be used by ALL EFI code.\r
279//\r
280#if defined (MDE_CPU_IA32)\r
281\r
282typedef EFI_IMAGE_OPTIONAL_HEADER32 EFI_IMAGE_OPTIONAL_HEADER;\r
283typedef EFI_IMAGE_NT_HEADERS32 EFI_IMAGE_NT_HEADERS;\r
284\r
285#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
286#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
287 (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
288\r
289#elif defined (MDE_CPU_IPF)\r
290\r
291typedef EFI_IMAGE_OPTIONAL_HEADER64 EFI_IMAGE_OPTIONAL_HEADER;\r
292typedef EFI_IMAGE_NT_HEADERS64 EFI_IMAGE_NT_HEADERS;\r
293\r
294#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
295#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
296 (((Machine) == EFI_IMAGE_MACHINE_IPF) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
297\r
298#elif defined (MDE_CPU_X64)\r
299\r
300typedef EFI_IMAGE_OPTIONAL_HEADER64 EFI_IMAGE_OPTIONAL_HEADER;\r
301typedef EFI_IMAGE_NT_HEADERS64 EFI_IMAGE_NT_HEADERS;\r
302\r
303#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
304#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
305 (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
306\r
307#elif defined (MDE_CPU_EBC)\r
308\r
309//\r
310// This is just to make sure you can cross compile with the EBC compiiler.\r
311// It does not make sense to have a PE loader coded in EBC. You need to \r
312// understand the basic \r
313//\r
314typedef EFI_IMAGE_OPTIONAL_HEADER64 EFI_IMAGE_OPTIONAL_HEADER;\r
315typedef EFI_IMAGE_NT_HEADERS64 EFI_IMAGE_NT_HEADERS;\r
316\r
317#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
318#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)\r
319\r
320#else\r
321#error Unknown Processor Type\r
322#endif\r
323\r
324\r
325#define EFI_IMAGE_FIRST_SECTION(ntheader) \\r
326 ( \\r
327 (EFI_IMAGE_SECTION_HEADER *) \\r
328 ( \\r
329 (UINT32) ntheader + \\r
330 FIELD_OFFSET (EFI_IMAGE_NT_HEADERS, OptionalHeader) + \\r
331 ((EFI_IMAGE_NT_HEADERS *) (ntheader))->FileHeader.SizeOfOptionalHeader \\r
332 ) \\r
333 )\r
334\r
335//\r
336// Subsystem Values\r
337//\r
338#define EFI_IMAGE_SUBSYSTEM_UNKNOWN 0\r
339#define EFI_IMAGE_SUBSYSTEM_NATIVE 1\r
340#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2\r
341#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3.\r
342#define EFI_IMAGE_SUBSYSTEM_OS2_CUI 5\r
343#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI 7\r
344\r
345//\r
346// Directory Entries\r
347//\r
348#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT 0\r
349#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT 1\r
350#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE 2\r
351#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3\r
352#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY 4\r
353#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC 5\r
354#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG 6\r
355#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7\r
356#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8\r
357#define EFI_IMAGE_DIRECTORY_ENTRY_TLS 9\r
358#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10\r
359\r
360//\r
361// Section header format.\r
362//\r
363#define EFI_IMAGE_SIZEOF_SHORT_NAME 8\r
364\r
365typedef struct {\r
366 UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];\r
367 union {\r
368 UINT32 PhysicalAddress;\r
369 UINT32 VirtualSize;\r
370 } Misc;\r
371 UINT32 VirtualAddress;\r
372 UINT32 SizeOfRawData;\r
373 UINT32 PointerToRawData;\r
374 UINT32 PointerToRelocations;\r
375 UINT32 PointerToLinenumbers;\r
376 UINT16 NumberOfRelocations;\r
377 UINT16 NumberOfLinenumbers;\r
378 UINT32 Characteristics;\r
379} EFI_IMAGE_SECTION_HEADER;\r
380\r
381#define EFI_IMAGE_SIZEOF_SECTION_HEADER 40\r
382\r
383#define EFI_IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved.\r
384#define EFI_IMAGE_SCN_CNT_CODE 0x00000020\r
385#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040\r
386#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080\r
387\r
388#define EFI_IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved.\r
389#define EFI_IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information.\r
390#define EFI_IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image.\r
391#define EFI_IMAGE_SCN_LNK_COMDAT 0x00001000\r
392\r
393#define EFI_IMAGE_SCN_ALIGN_1BYTES 0x00100000\r
394#define EFI_IMAGE_SCN_ALIGN_2BYTES 0x00200000\r
395#define EFI_IMAGE_SCN_ALIGN_4BYTES 0x00300000\r
396#define EFI_IMAGE_SCN_ALIGN_8BYTES 0x00400000\r
397#define EFI_IMAGE_SCN_ALIGN_16BYTES 0x00500000\r
398#define EFI_IMAGE_SCN_ALIGN_32BYTES 0x00600000\r
399#define EFI_IMAGE_SCN_ALIGN_64BYTES 0x00700000\r
400\r
401#define EFI_IMAGE_SCN_MEM_DISCARDABLE 0x02000000\r
402#define EFI_IMAGE_SCN_MEM_NOT_CACHED 0x04000000\r
403#define EFI_IMAGE_SCN_MEM_NOT_PAGED 0x08000000\r
404#define EFI_IMAGE_SCN_MEM_SHARED 0x10000000\r
405#define EFI_IMAGE_SCN_MEM_EXECUTE 0x20000000\r
406#define EFI_IMAGE_SCN_MEM_READ 0x40000000\r
407#define EFI_IMAGE_SCN_MEM_WRITE 0x80000000\r
408\r
409///\r
410/// Symbol format.\r
411///\r
412#define EFI_IMAGE_SIZEOF_SYMBOL 18\r
413\r
414//\r
415// Section values.\r
416//\r
417// Symbols have a section number of the section in which they are\r
418// defined. Otherwise, section numbers have the following meanings:\r
419//\r
420#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0 // Symbol is undefined or is common.\r
421#define EFI_IMAGE_SYM_ABSOLUTE (UINT16) -1 // Symbol is an absolute value.\r
422#define EFI_IMAGE_SYM_DEBUG (UINT16) -2 // Symbol is a special debug item.\r
423//\r
424// Type (fundamental) values.\r
425//\r
426#define EFI_IMAGE_SYM_TYPE_NULL 0 // no type.\r
427#define EFI_IMAGE_SYM_TYPE_VOID 1 //\r
428#define EFI_IMAGE_SYM_TYPE_CHAR 2 // type character.\r
429#define EFI_IMAGE_SYM_TYPE_SHORT 3 // type short integer.\r
430#define EFI_IMAGE_SYM_TYPE_INT 4\r
431#define EFI_IMAGE_SYM_TYPE_LONG 5\r
432#define EFI_IMAGE_SYM_TYPE_FLOAT 6\r
433#define EFI_IMAGE_SYM_TYPE_DOUBLE 7\r
434#define EFI_IMAGE_SYM_TYPE_STRUCT 8\r
435#define EFI_IMAGE_SYM_TYPE_UNION 9\r
436#define EFI_IMAGE_SYM_TYPE_ENUM 10 // enumeration.\r
437#define EFI_IMAGE_SYM_TYPE_MOE 11 // member of enumeration.\r
438#define EFI_IMAGE_SYM_TYPE_BYTE 12\r
439#define EFI_IMAGE_SYM_TYPE_WORD 13\r
440#define EFI_IMAGE_SYM_TYPE_UINT 14\r
441#define EFI_IMAGE_SYM_TYPE_DWORD 15\r
442\r
443//\r
444// Type (derived) values.\r
445//\r
446#define EFI_IMAGE_SYM_DTYPE_NULL 0 // no derived type.\r
447#define EFI_IMAGE_SYM_DTYPE_POINTER 1\r
448#define EFI_IMAGE_SYM_DTYPE_FUNCTION 2\r
449#define EFI_IMAGE_SYM_DTYPE_ARRAY 3\r
450\r
451//\r
452// Storage classes.\r
453//\r
454#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION (UINT8) -1\r
455#define EFI_IMAGE_SYM_CLASS_NULL 0\r
456#define EFI_IMAGE_SYM_CLASS_AUTOMATIC 1\r
457#define EFI_IMAGE_SYM_CLASS_EXTERNAL 2\r
458#define EFI_IMAGE_SYM_CLASS_STATIC 3\r
459#define EFI_IMAGE_SYM_CLASS_REGISTER 4\r
460#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF 5\r
461#define EFI_IMAGE_SYM_CLASS_LABEL 6\r
462#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL 7\r
463#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8\r
464#define EFI_IMAGE_SYM_CLASS_ARGUMENT 9\r
465#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG 10\r
466#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION 11\r
467#define EFI_IMAGE_SYM_CLASS_UNION_TAG 12\r
468#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION 13\r
469#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC 14\r
470#define EFI_IMAGE_SYM_CLASS_ENUM_TAG 15\r
471#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16\r
472#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM 17\r
473#define EFI_IMAGE_SYM_CLASS_BIT_FIELD 18\r
474#define EFI_IMAGE_SYM_CLASS_BLOCK 100\r
475#define EFI_IMAGE_SYM_CLASS_FUNCTION 101\r
476#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT 102\r
477#define EFI_IMAGE_SYM_CLASS_FILE 103\r
478#define EFI_IMAGE_SYM_CLASS_SECTION 104\r
479#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL 105\r
480\r
481//\r
482// type packing constants\r
483//\r
484#define EFI_IMAGE_N_BTMASK 017\r
485#define EFI_IMAGE_N_TMASK 060\r
486#define EFI_IMAGE_N_TMASK1 0300\r
487#define EFI_IMAGE_N_TMASK2 0360\r
488#define EFI_IMAGE_N_BTSHFT 4\r
489#define EFI_IMAGE_N_TSHIFT 2\r
490\r
491//\r
492// Communal selection types.\r
493//\r
494#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES 1\r
495#define EFI_IMAGE_COMDAT_SELECT_ANY 2\r
496#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3\r
497#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4\r
498#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5\r
499\r
500#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1\r
501#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2\r
502#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3\r
503\r
504///\r
505/// Relocation format.\r
506///\r
507typedef struct {\r
508 UINT32 VirtualAddress;\r
509 UINT32 SymbolTableIndex;\r
510 UINT16 Type;\r
511} EFI_IMAGE_RELOCATION;\r
512\r
513#define EFI_IMAGE_SIZEOF_RELOCATION 10\r
514\r
515//\r
516// I386 relocation types.\r
517//\r
518#define EFI_IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary\r
519#define EFI_IMAGE_REL_I386_DIR16 01 // Direct 16-bit reference to the symbols virtual address\r
520#define EFI_IMAGE_REL_I386_REL16 02 // PC-relative 16-bit reference to the symbols virtual address\r
521#define EFI_IMAGE_REL_I386_DIR32 06 // Direct 32-bit reference to the symbols virtual address\r
522#define EFI_IMAGE_REL_I386_DIR32NB 07 // Direct 32-bit reference to the symbols virtual address, base not included\r
523#define EFI_IMAGE_REL_I386_SEG12 011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address\r
524#define EFI_IMAGE_REL_I386_SECTION 012\r
525#define EFI_IMAGE_REL_I386_SECREL 013\r
526#define EFI_IMAGE_REL_I386_REL32 024 // PC-relative 32-bit reference to the symbols virtual address\r
527\r
528///\r
529/// Based relocation format.\r
530///\r
531typedef struct {\r
532 UINT32 VirtualAddress;\r
533 UINT32 SizeOfBlock;\r
534} EFI_IMAGE_BASE_RELOCATION;\r
535\r
536#define EFI_IMAGE_SIZEOF_BASE_RELOCATION 8\r
537\r
538//\r
539// Based relocation types.\r
540//\r
541#define EFI_IMAGE_REL_BASED_ABSOLUTE 0\r
542#define EFI_IMAGE_REL_BASED_HIGH 1\r
543#define EFI_IMAGE_REL_BASED_LOW 2\r
544#define EFI_IMAGE_REL_BASED_HIGHLOW 3\r
545#define EFI_IMAGE_REL_BASED_HIGHADJ 4\r
546#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5\r
547#define EFI_IMAGE_REL_BASED_IA64_IMM64 9\r
548#define EFI_IMAGE_REL_BASED_DIR64 10\r
549\r
550///\r
551/// Line number format.\r
552///\r
553typedef struct {\r
554 union {\r
555 UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.\r
556 UINT32 VirtualAddress; // Virtual address of line number.\r
557 } Type;\r
558 UINT16 Linenumber; // Line number.\r
559} EFI_IMAGE_LINENUMBER;\r
560\r
561#define EFI_IMAGE_SIZEOF_LINENUMBER 6\r
562\r
563//\r
564// Archive format.\r
565//\r
566#define EFI_IMAGE_ARCHIVE_START_SIZE 8\r
567#define EFI_IMAGE_ARCHIVE_START "!<arch>\n"\r
568#define EFI_IMAGE_ARCHIVE_END "`\n"\r
569#define EFI_IMAGE_ARCHIVE_PAD "\n"\r
570#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER "/ "\r
571#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "\r
572\r
573typedef struct {\r
574 UINT8 Name[16]; // File member name - `/' terminated.\r
575 UINT8 Date[12]; // File member date - decimal.\r
576 UINT8 UserID[6]; // File member user id - decimal.\r
577 UINT8 GroupID[6]; // File member group id - decimal.\r
578 UINT8 Mode[8]; // File member mode - octal.\r
579 UINT8 Size[10]; // File member size - decimal.\r
580 UINT8 EndHeader[2]; // String to end header.\r
581} EFI_IMAGE_ARCHIVE_MEMBER_HEADER;\r
582\r
583#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60\r
584\r
585//\r
586// DLL support.\r
587//\r
588\r
589///\r
590/// DLL Export Format\r
591///\r
592typedef struct {\r
593 UINT32 Characteristics;\r
594 UINT32 TimeDateStamp;\r
595 UINT16 MajorVersion;\r
596 UINT16 MinorVersion;\r
597 UINT32 Name;\r
598 UINT32 Base;\r
599 UINT32 NumberOfFunctions;\r
600 UINT32 NumberOfNames;\r
601 UINT32 AddressOfFunctions;\r
602 UINT32 AddressOfNames;\r
603 UINT32 AddressOfNameOrdinals;\r
604} EFI_IMAGE_EXPORT_DIRECTORY;\r
605\r
606///\r
607/// DLL support.\r
608/// Import Format\r
609///\r
610typedef struct {\r
611 UINT16 Hint;\r
612 UINT8 Name[1];\r
613} EFI_IMAGE_IMPORT_BY_NAME;\r
614\r
615typedef struct {\r
616 union {\r
617 UINT32 Function;\r
618 UINT32 Ordinal;\r
619 EFI_IMAGE_IMPORT_BY_NAME *AddressOfData;\r
620 } u1;\r
621} EFI_IMAGE_THUNK_DATA;\r
622\r
623#define EFI_IMAGE_ORDINAL_FLAG 0x80000000\r
624#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)\r
625#define EFI_IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)\r
626\r
627typedef struct {\r
628 UINT32 Characteristics;\r
629 UINT32 TimeDateStamp;\r
630 UINT32 ForwarderChain;\r
631 UINT32 Name;\r
632 EFI_IMAGE_THUNK_DATA *FirstThunk;\r
633} EFI_IMAGE_IMPORT_DESCRIPTOR;\r
634\r
635///\r
636/// Debug Format\r
637///\r
638#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2\r
639\r
640typedef struct {\r
641 UINT32 Characteristics;\r
642 UINT32 TimeDateStamp;\r
643 UINT16 MajorVersion;\r
644 UINT16 MinorVersion;\r
645 UINT32 Type;\r
646 UINT32 SizeOfData;\r
647 UINT32 RVA;\r
648 UINT32 FileOffset;\r
649} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;\r
650\r
651#define CODEVIEW_SIGNATURE_NB10 0x3031424E // "NB10"\r
652typedef struct {\r
653 UINT32 Signature; // "NB10"\r
654 UINT32 Unknown;\r
655 UINT32 Unknown2;\r
656 UINT32 Unknown3;\r
657 //\r
658 // Filename of .PDB goes here\r
659 //\r
660} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;\r
661\r
662#define CODEVIEW_SIGNATURE_RSDS 0x53445352 // "RSDS"\r
663typedef struct {\r
664 UINT32 Signature; // "RSDS"\r
665 UINT32 Unknown;\r
666 UINT32 Unknown2;\r
667 UINT32 Unknown3;\r
668 UINT32 Unknown4;\r
669 UINT32 Unknown5;\r
670 //\r
671 // Filename of .PDB goes here\r
672 //\r
673} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;\r
674\r
9bae46a5 675//\r
676// .pdata entries for X64\r
677//\r
678typedef struct {\r
679 UINT32 FunctionStartAddress;\r
680 UINT32 FunctionEndAddress;\r
681 UINT32 UnwindInfoAddress;\r
682} RUNTIME_FUNCTION;\r
683\r
684typedef struct {\r
685 UINT8 Version:3;\r
686 UINT8 Flags:5;\r
687 UINT8 SizeOfProlog;\r
688 UINT8 CountOfUnwindCodes;\r
689 UINT8 FrameRegister:4;\r
690 UINT8 FrameRegisterOffset:4;\r
691} UNWIND_INFO;\r
692\r
21b50a27 693///\r
694/// Header format for TE images\r
695///\r
696typedef struct {\r
697 UINT16 Signature; // signature for TE format = "VZ"\r
698 UINT16 Machine; // from the original file header\r
699 UINT8 NumberOfSections; // from the original file header\r
700 UINT8 Subsystem; // from original optional header\r
701 UINT16 StrippedSize; // how many bytes we removed from the header\r
702 UINT32 AddressOfEntryPoint; // offset to entry point -- from original optional header\r
703 UINT32 BaseOfCode; // from original image -- required for ITP debug\r
704 UINT64 ImageBase; // from original file header\r
705 EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; // only base relocation and debug directory\r
706} EFI_TE_IMAGE_HEADER;\r
707\r
708#define EFI_TE_IMAGE_HEADER_SIGNATURE 0x5A56 // "VZ"\r
709\r
710//\r
711// Data directory indexes in our TE image header\r
712//\r
713#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0\r
714#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1\r
715\r
716#endif\r