]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/boot/efi/include/ia64/pe.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / boot / efi / include / ia64 / pe.h
1 /* $FreeBSD$ */
2 /* 
3     PE32+ header file
4  */
5 #ifndef _PE_H
6 #define _PE_H
7
8 #define IMAGE_DOS_SIGNATURE                 0x5A4D      // MZ
9 #define IMAGE_OS2_SIGNATURE                 0x454E      // NE
10 #define IMAGE_OS2_SIGNATURE_LE              0x454C      // LE
11 #define IMAGE_NT_SIGNATURE                  0x00004550  // PE00  
12 #define IMAGE_EDOS_SIGNATURE                0x44454550  // PEED
13
14 /*****************************************************************************
15  * The following stuff comes from winnt.h from the ia64sdk, plus the Plabel for
16  * loading EM executables.
17  *****************************************************************************/
18 //
19 // Intel IA64 specific
20 //
21
22 #define IMAGE_REL_BASED_IA64_IMM64            9
23 #define IMAGE_REL_BASED_IA64_DIR64            10
24
25 struct Plabel { 
26     UINT64  EntryPoint;
27     UINT64  NewGP;
28 };
29
30 typedef struct _IMAGE_DOS_HEADER {      // DOS .EXE header
31     UINT16   e_magic;                     // Magic number
32     UINT16   e_cblp;                      // Bytes on last page of file
33     UINT16   e_cp;                        // Pages in file
34     UINT16   e_crlc;                      // Relocations
35     UINT16   e_cparhdr;                   // Size of header in paragraphs
36     UINT16   e_minalloc;                  // Minimum extra paragraphs needed
37     UINT16   e_maxalloc;                  // Maximum extra paragraphs needed
38     UINT16   e_ss;                        // Initial (relative) SS value
39     UINT16   e_sp;                        // Initial SP value
40     UINT16   e_csum;                      // Checksum
41     UINT16   e_ip;                        // Initial IP value
42     UINT16   e_cs;                        // Initial (relative) CS value
43     UINT16   e_lfarlc;                    // File address of relocation table
44     UINT16   e_ovno;                      // Overlay number
45     UINT16   e_res[4];                    // Reserved words
46     UINT16   e_oemid;                     // OEM identifier (for e_oeminfo)
47     UINT16   e_oeminfo;                   // OEM information; e_oemid specific
48     UINT16   e_res2[10];                  // Reserved words
49     UINT32   e_lfanew;                    // File address of new exe header
50   } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
51
52 typedef struct _IMAGE_OS2_HEADER {      // OS/2 .EXE header
53     UINT16   ne_magic;                    // Magic number
54     UINT8    ne_ver;                      // Version number
55     UINT8    ne_rev;                      // Revision number
56     UINT16   ne_enttab;                   // Offset of Entry Table
57     UINT16   ne_cbenttab;                 // Number of bytes in Entry Table
58     UINT32   ne_crc;                      // Checksum of whole file
59     UINT16   ne_flags;                    // Flag UINT16
60     UINT16   ne_autodata;                 // Automatic data segment number
61     UINT16   ne_heap;                     // Initial heap allocation
62     UINT16   ne_stack;                    // Initial stack allocation
63     UINT32   ne_csip;                     // Initial CS:IP setting
64     UINT32   ne_sssp;                     // Initial SS:SP setting
65     UINT16   ne_cseg;                     // Count of file segments
66     UINT16   ne_cmod;                     // Entries in Module Reference Table
67     UINT16   ne_cbnrestab;                // Size of non-resident name table
68     UINT16   ne_segtab;                   // Offset of Segment Table
69     UINT16   ne_rsrctab;                  // Offset of Resource Table
70     UINT16   ne_restab;                   // Offset of resident name table
71     UINT16   ne_modtab;                   // Offset of Module Reference Table
72     UINT16   ne_imptab;                   // Offset of Imported Names Table
73     UINT32   ne_nrestab;                  // Offset of Non-resident Names Table
74     UINT16   ne_cmovent;                  // Count of movable entries
75     UINT16   ne_align;                    // Segment alignment shift count
76     UINT16   ne_cres;                     // Count of resource segments
77     UINT8    ne_exetyp;                   // Target Operating system
78     UINT8    ne_flagsothers;              // Other .EXE flags
79     UINT16   ne_pretthunks;               // offset to return thunks
80     UINT16   ne_psegrefbytes;             // offset to segment ref. bytes
81     UINT16   ne_swaparea;                 // Minimum code swap area size
82     UINT16   ne_expver;                   // Expected Windows version number
83   } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
84
85 //
86 // File header format.
87 //
88
89 typedef struct _IMAGE_FILE_HEADER {
90     UINT16   Machine;
91     UINT16   NumberOfSections;
92     UINT32   TimeDateStamp;
93     UINT32   PointerToSymbolTable;
94     UINT32   NumberOfSymbols;
95     UINT16   SizeOfOptionalHeader;
96     UINT16   Characteristics;
97 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
98
99 #define IMAGE_SIZEOF_FILE_HEADER             20
100
101 #define IMAGE_FILE_RELOCS_STRIPPED           0x0001  // Relocation info stripped from file.
102 #define IMAGE_FILE_EXECUTABLE_IMAGE          0x0002  // File is executable  (i.e. no unresolved externel references).
103 #define IMAGE_FILE_LINE_NUMS_STRIPPED        0x0004  // Line nunbers stripped from file.
104 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED       0x0008  // Local symbols stripped from file.
105 #define IMAGE_FILE_BYTES_REVERSED_LO         0x0080  // Bytes of machine word are reversed.
106 #define IMAGE_FILE_32BIT_MACHINE             0x0100  // 32 bit word machine.
107 #define IMAGE_FILE_DEBUG_STRIPPED            0x0200  // Debugging info stripped from file in .DBG file
108 #define IMAGE_FILE_SYSTEM                    0x1000  // System File.
109 #define IMAGE_FILE_DLL                       0x2000  // File is a DLL.
110 #define IMAGE_FILE_BYTES_REVERSED_HI         0x8000  // Bytes of machine word are reversed.
111
112 #define IMAGE_FILE_MACHINE_UNKNOWN           0
113 #define IMAGE_FILE_MACHINE_I386              0x14c   // Intel 386.
114 #define IMAGE_FILE_MACHINE_R3000             0x162   // MIPS little-endian, 0540 big-endian
115 #define IMAGE_FILE_MACHINE_R4000             0x166   // MIPS little-endian
116 #define IMAGE_FILE_MACHINE_ALPHA             0x184   // Alpha_AXP
117 #define IMAGE_FILE_MACHINE_POWERPC           0x1F0   // IBM PowerPC Little-Endian
118 #define IMAGE_FILE_MACHINE_TAHOE             0x7cc   // Intel EM machine
119 //
120 // Directory format.
121 //
122
123 typedef struct _IMAGE_DATA_DIRECTORY {
124     UINT32   VirtualAddress;
125     UINT32   Size;
126 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
127
128 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES    16
129
130
131 typedef struct _IMAGE_ROM_OPTIONAL_HEADER {
132     UINT16  Magic;
133     UINT8   MajorLinkerVersion;
134     UINT8   MinorLinkerVersion;
135     UINT32  SizeOfCode;
136     UINT32  SizeOfInitializedData;
137     UINT32  SizeOfUninitializedData;
138     UINT32  AddressOfEntryPoint;
139     UINT32  BaseOfCode;
140     UINT32  BaseOfData;
141     UINT32  BaseOfBss;
142     UINT32  GprMask;
143     UINT32  CprMask[4];
144     UINT32  GpValue;
145 } IMAGE_ROM_OPTIONAL_HEADER, *PIMAGE_ROM_OPTIONAL_HEADER;
146
147 typedef struct _IMAGE_OPTIONAL_HEADER {
148     UINT16      Magic;
149     UINT8       MajorLinkerVersion;
150     UINT8       MinorLinkerVersion;
151     UINT32      SizeOfCode;
152     UINT32      SizeOfInitializedData;
153     UINT32      SizeOfUninitializedData;
154     UINT32      AddressOfEntryPoint;
155     UINT32      BaseOfCode;
156     // UINT32       BaseOfData;
157     UINT64      ImageBase;
158     UINT32      SectionAlignment;
159     UINT32      FileAlignment;
160     UINT16      MajorOperatingSystemVersion;
161     UINT16      MinorOperatingSystemVersion;
162     UINT16      MajorImageVersion;
163     UINT16      MinorImageVersion;
164     UINT16      MajorSubsystemVersion;
165     UINT16      MinorSubsystemVersion;
166     UINT32      Win32VersionValue;
167     UINT32      SizeOfImage;
168     UINT32      SizeOfHeaders;
169     UINT32      CheckSum;
170     UINT16      Subsystem;
171     UINT16      DllCharacteristics;
172     UINT64      SizeOfStackReserve;
173     UINT64      SizeOfStackCommit;
174     UINT64      SizeOfHeapReserve;
175     UINT64      SizeOfHeapCommit;
176     UINT32      LoaderFlags;
177     UINT32      NumberOfRvaAndSizes;
178     IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
179 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
180
181
182 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER      56
183 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER      28
184 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER      224
185 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER    244
186
187 #define IMAGE_NT_OPTIONAL_HDR_MAGIC        0x10b
188 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC      0x20b
189 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC       0x107
190
191 typedef struct _IMAGE_NT_HEADERS {
192     UINT32 Signature;
193     IMAGE_FILE_HEADER FileHeader;
194     IMAGE_OPTIONAL_HEADER OptionalHeader;
195 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
196
197 typedef struct _IMAGE_ROM_HEADERS {
198     IMAGE_FILE_HEADER FileHeader;
199     IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
200 } IMAGE_ROM_HEADERS, *PIMAGE_ROM_HEADERS;
201
202 #define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER)        \
203     ((UINT32)ntheader +                                                  \
204      FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) +                 \
205      ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader   \
206     ))
207
208
209 // Subsystem Values
210
211 #define IMAGE_SUBSYSTEM_UNKNOWN              0   // Unknown subsystem.
212 #define IMAGE_SUBSYSTEM_NATIVE               1   // Image doesn't require a subsystem.
213 #define IMAGE_SUBSYSTEM_WINDOWS_GUI          2   // Image runs in the Windows GUI subsystem.
214 #define IMAGE_SUBSYSTEM_WINDOWS_CUI          3   // Image runs in the Windows character subsystem.
215 #define IMAGE_SUBSYSTEM_OS2_CUI              5   // image runs in the OS/2 character subsystem.
216 #define IMAGE_SUBSYSTEM_POSIX_CUI            7   // image run  in the Posix character subsystem.
217
218
219 // Directory Entries
220
221 #define IMAGE_DIRECTORY_ENTRY_EXPORT         0   // Export Directory
222 #define IMAGE_DIRECTORY_ENTRY_IMPORT         1   // Import Directory
223 #define IMAGE_DIRECTORY_ENTRY_RESOURCE       2   // Resource Directory
224 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION      3   // Exception Directory
225 #define IMAGE_DIRECTORY_ENTRY_SECURITY       4   // Security Directory
226 #define IMAGE_DIRECTORY_ENTRY_BASERELOC      5   // Base Relocation Table
227 #define IMAGE_DIRECTORY_ENTRY_DEBUG          6   // Debug Directory
228 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT      7   // Description String
229 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR      8   // Machine Value (MIPS GP)
230 #define IMAGE_DIRECTORY_ENTRY_TLS            9   // TLS Directory
231 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG   10   // Load Configuration Directory
232
233 //
234 // Section header format.
235 //
236
237 #define IMAGE_SIZEOF_SHORT_NAME              8
238
239 typedef struct _IMAGE_SECTION_HEADER {
240     UINT8   Name[IMAGE_SIZEOF_SHORT_NAME];
241     union {
242             UINT32   PhysicalAddress;
243             UINT32   VirtualSize;
244     } Misc;
245     UINT32   VirtualAddress;
246     UINT32   SizeOfRawData;
247     UINT32   PointerToRawData;
248     UINT32   PointerToRelocations;
249     UINT32   PointerToLinenumbers;
250     UINT16   NumberOfRelocations;
251     UINT16   NumberOfLinenumbers;
252     UINT32   Characteristics;
253 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
254
255 #define IMAGE_SIZEOF_SECTION_HEADER          40
256
257 #define IMAGE_SCN_TYPE_NO_PAD                0x00000008  // Reserved.
258
259 #define IMAGE_SCN_CNT_CODE                   0x00000020  // Section contains code.
260 #define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  // Section contains initialized data.
261 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  // Section contains uninitialized data.
262
263 #define IMAGE_SCN_LNK_OTHER                  0x00000100  // Reserved.
264 #define IMAGE_SCN_LNK_INFO                   0x00000200  // Section contains comments or some other type of information.
265 #define IMAGE_SCN_LNK_REMOVE                 0x00000800  // Section contents will not become part of image.
266 #define IMAGE_SCN_LNK_COMDAT                 0x00001000  // Section contents comdat.
267
268 #define IMAGE_SCN_ALIGN_1BYTES               0x00100000  //
269 #define IMAGE_SCN_ALIGN_2BYTES               0x00200000  //
270 #define IMAGE_SCN_ALIGN_4BYTES               0x00300000  //
271 #define IMAGE_SCN_ALIGN_8BYTES               0x00400000  //
272 #define IMAGE_SCN_ALIGN_16BYTES              0x00500000  // Default alignment if no others are specified.
273 #define IMAGE_SCN_ALIGN_32BYTES              0x00600000  //
274 #define IMAGE_SCN_ALIGN_64BYTES              0x00700000  //
275
276 #define IMAGE_SCN_MEM_DISCARDABLE            0x02000000  // Section can be discarded.
277 #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  // Section is not cachable.
278 #define IMAGE_SCN_MEM_NOT_PAGED              0x08000000  // Section is not pageable.
279 #define IMAGE_SCN_MEM_SHARED                 0x10000000  // Section is shareable.
280 #define IMAGE_SCN_MEM_EXECUTE                0x20000000  // Section is executable.
281 #define IMAGE_SCN_MEM_READ                   0x40000000  // Section is readable.
282 #define IMAGE_SCN_MEM_WRITE                  0x80000000  // Section is writeable.
283
284 //
285 // Symbol format.
286 //
287
288
289 #define IMAGE_SIZEOF_SYMBOL                  18
290
291 //
292 // Section values.
293 //
294 // Symbols have a section number of the section in which they are
295 // defined. Otherwise, section numbers have the following meanings:
296 //
297
298 #define IMAGE_SYM_UNDEFINED           (UINT16)0           // Symbol is undefined or is common.
299 #define IMAGE_SYM_ABSOLUTE            (UINT16)-1          // Symbol is an absolute value.
300 #define IMAGE_SYM_DEBUG               (UINT16)-2          // Symbol is a special debug item.
301
302 //
303 // Type (fundamental) values.
304 //
305
306 #define IMAGE_SYM_TYPE_NULL                  0           // no type.
307 #define IMAGE_SYM_TYPE_VOID                  1           //
308 #define IMAGE_SYM_TYPE_CHAR                  2           // type character.
309 #define IMAGE_SYM_TYPE_SHORT                 3           // type short integer.
310 #define IMAGE_SYM_TYPE_INT                   4           //
311 #define IMAGE_SYM_TYPE_LONG                  5           //
312 #define IMAGE_SYM_TYPE_FLOAT                 6           //
313 #define IMAGE_SYM_TYPE_DOUBLE                7           //
314 #define IMAGE_SYM_TYPE_STRUCT                8           //
315 #define IMAGE_SYM_TYPE_UNION                 9           //
316 #define IMAGE_SYM_TYPE_ENUM                  10          // enumeration.
317 #define IMAGE_SYM_TYPE_MOE                   11          // member of enumeration.
318 #define IMAGE_SYM_TYPE_BYTE                  12          //
319 #define IMAGE_SYM_TYPE_WORD                  13          //
320 #define IMAGE_SYM_TYPE_UINT                  14          //
321 #define IMAGE_SYM_TYPE_DWORD                 15          //
322
323 //
324 // Type (derived) values.
325 //
326
327 #define IMAGE_SYM_DTYPE_NULL                 0           // no derived type.
328 #define IMAGE_SYM_DTYPE_POINTER              1           // pointer.
329 #define IMAGE_SYM_DTYPE_FUNCTION             2           // function.
330 #define IMAGE_SYM_DTYPE_ARRAY                3           // array.
331
332 //
333 // Storage classes.
334 //
335
336 #define IMAGE_SYM_CLASS_END_OF_FUNCTION      (BYTE )-1
337 #define IMAGE_SYM_CLASS_NULL                 0
338 #define IMAGE_SYM_CLASS_AUTOMATIC            1
339 #define IMAGE_SYM_CLASS_EXTERNAL             2
340 #define IMAGE_SYM_CLASS_STATIC               3
341 #define IMAGE_SYM_CLASS_REGISTER             4
342 #define IMAGE_SYM_CLASS_EXTERNAL_DEF         5
343 #define IMAGE_SYM_CLASS_LABEL                6
344 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL      7
345 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT     8
346 #define IMAGE_SYM_CLASS_ARGUMENT             9
347 #define IMAGE_SYM_CLASS_STRUCT_TAG           10
348 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION      11
349 #define IMAGE_SYM_CLASS_UNION_TAG            12
350 #define IMAGE_SYM_CLASS_TYPE_DEFINITION      13
351 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC     14
352 #define IMAGE_SYM_CLASS_ENUM_TAG             15
353 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM       16
354 #define IMAGE_SYM_CLASS_REGISTER_PARAM       17
355 #define IMAGE_SYM_CLASS_BIT_FIELD            18
356 #define IMAGE_SYM_CLASS_BLOCK                100
357 #define IMAGE_SYM_CLASS_FUNCTION             101
358 #define IMAGE_SYM_CLASS_END_OF_STRUCT        102
359 #define IMAGE_SYM_CLASS_FILE                 103
360 // new
361 #define IMAGE_SYM_CLASS_SECTION              104
362 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL        105
363
364 // type packing constants
365
366 #define N_BTMASK                            017
367 #define N_TMASK                             060
368 #define N_TMASK1                            0300
369 #define N_TMASK2                            0360
370 #define N_BTSHFT                            4
371 #define N_TSHIFT                            2
372
373 // MACROS
374
375 //
376 // Communal selection types.
377 //
378
379 #define IMAGE_COMDAT_SELECT_NODUPLICATES   1
380 #define IMAGE_COMDAT_SELECT_ANY            2
381 #define IMAGE_COMDAT_SELECT_SAME_SIZE      3
382 #define IMAGE_COMDAT_SELECT_EXACT_MATCH    4
383 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE    5
384
385 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
386 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY   2
387 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS     3
388
389
390 //
391 // Relocation format.
392 //
393
394 typedef struct _IMAGE_RELOCATION {
395     UINT32   VirtualAddress;
396     UINT32   SymbolTableIndex;
397     UINT16   Type;
398 } IMAGE_RELOCATION;
399
400 #define IMAGE_SIZEOF_RELOCATION              10
401
402 //
403 // I386 relocation types.
404 //
405
406 #define IMAGE_REL_I386_ABSOLUTE              0           // Reference is absolute, no relocation is necessary
407 #define IMAGE_REL_I386_DIR16                 01          // Direct 16-bit reference to the symbols virtual address
408 #define IMAGE_REL_I386_REL16                 02          // PC-relative 16-bit reference to the symbols virtual address
409 #define IMAGE_REL_I386_DIR32                 06          // Direct 32-bit reference to the symbols virtual address
410 #define IMAGE_REL_I386_DIR32NB               07          // Direct 32-bit reference to the symbols virtual address, base not included
411 #define IMAGE_REL_I386_SEG12                 011         // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
412 #define IMAGE_REL_I386_SECTION               012
413 #define IMAGE_REL_I386_SECREL                013
414 #define IMAGE_REL_I386_REL32                 024         // PC-relative 32-bit reference to the symbols virtual address
415
416 //
417 // MIPS relocation types.
418 //
419
420 #define IMAGE_REL_MIPS_ABSOLUTE              0           // Reference is absolute, no relocation is necessary
421 #define IMAGE_REL_MIPS_REFHALF               01
422 #define IMAGE_REL_MIPS_REFWORD               02
423 #define IMAGE_REL_MIPS_JMPADDR               03
424 #define IMAGE_REL_MIPS_REFHI                 04
425 #define IMAGE_REL_MIPS_REFLO                 05
426 #define IMAGE_REL_MIPS_GPREL                 06
427 #define IMAGE_REL_MIPS_LITERAL               07
428 #define IMAGE_REL_MIPS_SECTION               012
429 #define IMAGE_REL_MIPS_SECREL                013
430 #define IMAGE_REL_MIPS_REFWORDNB             042
431 #define IMAGE_REL_MIPS_PAIR                  045
432
433 //
434 // Alpha Relocation types.
435 //
436
437 #define IMAGE_REL_ALPHA_ABSOLUTE             0x0
438 #define IMAGE_REL_ALPHA_REFLONG              0x1
439 #define IMAGE_REL_ALPHA_REFQUAD              0x2
440 #define IMAGE_REL_ALPHA_GPREL32              0x3
441 #define IMAGE_REL_ALPHA_LITERAL              0x4
442 #define IMAGE_REL_ALPHA_LITUSE               0x5
443 #define IMAGE_REL_ALPHA_GPDISP               0x6
444 #define IMAGE_REL_ALPHA_BRADDR               0x7
445 #define IMAGE_REL_ALPHA_HINT                 0x8
446 #define IMAGE_REL_ALPHA_INLINE_REFLONG       0x9
447 #define IMAGE_REL_ALPHA_REFHI                0xA
448 #define IMAGE_REL_ALPHA_REFLO                0xB
449 #define IMAGE_REL_ALPHA_PAIR                 0xC
450 #define IMAGE_REL_ALPHA_MATCH                0xD
451 #define IMAGE_REL_ALPHA_SECTION              0xE
452 #define IMAGE_REL_ALPHA_SECREL               0xF
453 #define IMAGE_REL_ALPHA_REFLONGNB            0x10
454
455 //
456 // IBM PowerPC relocation types.
457 //
458
459 #define IMAGE_REL_PPC_ABSOLUTE 0x0000  // NOP
460 #define IMAGE_REL_PPC_ADDR64   0x0001  // 64-bit address
461 #define IMAGE_REL_PPC_ADDR32   0x0002  // 32-bit address
462 #define IMAGE_REL_PPC_ADDR24   0x0003  // 26-bit address, shifted left 2 (branch absolute)
463 #define IMAGE_REL_PPC_ADDR16   0x0004  // 16-bit address
464 #define IMAGE_REL_PPC_ADDR14   0x0005  // 16-bit address, shifted left 2 (load doubleword)
465 #define IMAGE_REL_PPC_REL24    0x0006  // 26-bit PC-relative offset, shifted left 2 (branch relative)
466 #define IMAGE_REL_PPC_REL14    0x0007  // 16-bit PC-relative offset, shifted left 2 (br cond relative)
467 #define IMAGE_REL_PPC_TOCREL16 0x0008  // 16-bit offset from TOC base
468 #define IMAGE_REL_PPC_TOCREL14 0x0009  // 16-bit offset from TOC base, shifted left 2 (load doubleword)
469
470 #define IMAGE_REL_PPC_ADDR32NB 0x000A  // 32-bit addr w/o image base
471 #define IMAGE_REL_PPC_SECREL   0x000B  // va of containing section (as in an image sectionhdr)
472 #define IMAGE_REL_PPC_SECTION  0x000C  // sectionheader number
473 #define IMAGE_REL_PPC_IFGLUE   0x000D  // substitute TOC restore instruction iff symbol is glue code
474 #define IMAGE_REL_PPC_IMGLUE   0x000E  // symbol is glue code; virtual address is TOC restore instruction
475
476 #define IMAGE_REL_PPC_TYPEMASK 0x00FF  // mask to isolate above values in IMAGE_RELOCATION.Type
477
478 // Flag bits in IMAGE_RELOCATION.TYPE
479
480 #define IMAGE_REL_PPC_NEG      0x0100  // subtract reloc value rather than adding it
481 #define IMAGE_REL_PPC_BRTAKEN  0x0200  // fix branch prediction bit to predict branch taken
482 #define IMAGE_REL_PPC_BRNTAKEN 0x0400  // fix branch prediction bit to predict branch not taken
483 #define IMAGE_REL_PPC_TOCDEFN  0x0800  // toc slot defined in file (or, data in toc)
484
485 //
486 // Based relocation format.
487 //
488
489 typedef struct _IMAGE_BASE_RELOCATION {
490     UINT32   VirtualAddress;
491     UINT32   SizeOfBlock;
492 //  UINT16    TypeOffset[1];
493 } IMAGE_BASE_RELOCATION, *PIMAGE_BASE_RELOCATION;
494
495 #define IMAGE_SIZEOF_BASE_RELOCATION         8
496
497 //
498 // Based relocation types.
499 //
500
501 #define IMAGE_REL_BASED_ABSOLUTE              0
502 #define IMAGE_REL_BASED_HIGH                  1
503 #define IMAGE_REL_BASED_LOW                   2
504 #define IMAGE_REL_BASED_HIGHLOW               3
505 #define IMAGE_REL_BASED_HIGHADJ               4
506 #define IMAGE_REL_BASED_MIPS_JMPADDR          5
507 #define IMAGE_REL_BASED_IA64_IMM64            9
508 #define IMAGE_REL_BASED_DIR64                 10
509
510 //
511 // Line number format.
512 //
513
514 typedef struct _IMAGE_LINENUMBER {
515     union {
516         UINT32   SymbolTableIndex;               // Symbol table index of function name if Linenumber is 0.
517         UINT32   VirtualAddress;                 // Virtual address of line number.
518     } Type;
519     UINT16    Linenumber;                         // Line number.
520 } IMAGE_LINENUMBER;
521
522 #define IMAGE_SIZEOF_LINENUMBER              6
523
524 //
525 // Archive format.
526 //
527
528 #define IMAGE_ARCHIVE_START_SIZE             8
529 #define IMAGE_ARCHIVE_START                  "!<arch>\n"
530 #define IMAGE_ARCHIVE_END                    "`\n"
531 #define IMAGE_ARCHIVE_PAD                    "\n"
532 #define IMAGE_ARCHIVE_LINKER_MEMBER          "/               "
533 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER       "//              "
534
535 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
536     UINT8     Name[16];                          // File member name - `/' terminated.
537     UINT8     Date[12];                          // File member date - decimal.
538     UINT8     UserID[6];                         // File member user id - decimal.
539     UINT8     GroupID[6];                        // File member group id - decimal.
540     UINT8     Mode[8];                           // File member mode - octal.
541     UINT8     Size[10];                          // File member size - decimal.
542     UINT8     EndHeader[2];                      // String to end header.
543 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
544
545 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR      60
546
547 //
548 // DLL support.
549 //
550
551 //
552 // Export Format
553 //
554
555 typedef struct _IMAGE_EXPORT_DIRECTORY {
556     UINT32   Characteristics;
557     UINT32   TimeDateStamp;
558     UINT16   MajorVersion;
559     UINT16   MinorVersion;
560     UINT32   Name;
561     UINT32   Base;
562     UINT32   NumberOfFunctions;
563     UINT32   NumberOfNames;
564     UINT32   AddressOfFunctions;
565     UINT32   AddressOfNames;
566     UINT32   AddressOfNameOrdinals;
567 } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
568
569 //
570 // Import Format
571 //
572
573 typedef struct _IMAGE_IMPORT_BY_NAME {
574     UINT16    Hint;
575     UINT8     Name[1];
576 } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME;
577
578 typedef struct _IMAGE_THUNK_DATA {
579     union {
580         UINT32 Function;
581         UINT32 Ordinal;
582         PIMAGE_IMPORT_BY_NAME AddressOfData;
583     } u1;
584 } IMAGE_THUNK_DATA, *PIMAGE_THUNK_DATA;
585
586 #define IMAGE_ORDINAL_FLAG 0x80000000
587 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
588 #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
589
590 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
591     UINT32   Characteristics;
592     UINT32   TimeDateStamp;
593     UINT32   ForwarderChain;
594     UINT32   Name;
595     PIMAGE_THUNK_DATA FirstThunk;
596 } IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR;
597
598 #define IMAGE_DEBUG_TYPE_CODEVIEW   2
599
600 typedef struct {
601   UINT32    Characteristics;
602   UINT32    TimeDateStamp;
603   UINT16    MajorVersion;
604   UINT16    MinorVersion;
605   UINT32    Type;
606   UINT32    SizeOfData;
607   UINT32    RVA;
608   UINT32    FileOffset;
609 } IMAGE_DEBUG_DIRECTORY_ENTRY;
610
611 #define CODEVIEW_SIGNATURE_NB10  0x3031424E // "NB10"
612
613 typedef struct {
614   UINT32    Signature; // "NB10"
615   UINT32    Unknown;
616   UINT32    Unknown2;
617   UINT32    Unknown3;     
618   //
619   // Filename of .PDB goes here
620   //
621 } EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;
622
623 #define CODEVIEW_SIGNATURE_RSDS  0x53445352 // "RSDS"
624
625 typedef struct {
626   UINT32    Signature; // "RSDS"
627   UINT32    Unknown;
628   UINT32    Unknown2;
629   UINT32    Unknown3;     
630   UINT32    Unknown4;     
631   UINT32    Unknown5;     
632   //
633   // Filename of .PDB goes here
634   //
635 } EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;
636
637 #endif