iPXE
PeImage.h
Go to the documentation of this file.
1/** @file
2 EFI image format for PE32, PE32+ and TE. Please note some data structures are
3 different for PE32 and PE32+. EFI_IMAGE_NT_HEADERS32 is for PE32 and
4 EFI_IMAGE_NT_HEADERS64 is for PE32+.
5
6 This file is coded to the Visual Studio, Microsoft Portable Executable and
7 Common Object File Format Specification, Revision 9.3 - December 29, 2015.
8 This file also includes some definitions in PI Specification, Revision 1.0.
9
10Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
11Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
12Portions Copyright (c) 2016 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
13Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
14
15SPDX-License-Identifier: BSD-2-Clause-Patent
16
17**/
18
19#ifndef __PE_IMAGE_H__
20#define __PE_IMAGE_H__
21
22FILE_LICENCE ( BSD2_PATENT );
23FILE_SECBOOT ( PERMITTED );
24
25//
26// PE32+ Subsystem type for EFI images
27//
28#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10
29#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
30#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
31
32//
33// PE32+ Machine type for EFI images
34//
35#define IMAGE_FILE_MACHINE_I386 0x014c
36#define IMAGE_FILE_MACHINE_IA64 0x0200
37#define IMAGE_FILE_MACHINE_EBC 0x0EBC
38#define IMAGE_FILE_MACHINE_X64 0x8664
39#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x01c2
40#define IMAGE_FILE_MACHINE_ARM64 0xAA64
41#define IMAGE_FILE_MACHINE_RISCV32 0x5032
42#define IMAGE_FILE_MACHINE_RISCV64 0x5064
43#define IMAGE_FILE_MACHINE_RISCV128 0x5128
44#define IMAGE_FILE_MACHINE_LOONGARCH32 0x6232
45#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264
46
47//
48// EXE file formats
49//
50#define EFI_IMAGE_DOS_SIGNATURE SIGNATURE_16('M', 'Z')
51#define EFI_IMAGE_OS2_SIGNATURE SIGNATURE_16('N', 'E')
52#define EFI_IMAGE_OS2_SIGNATURE_LE SIGNATURE_16('L', 'E')
53#define EFI_IMAGE_NT_SIGNATURE SIGNATURE_32('P', 'E', '\0', '\0')
54
55///
56/// PE images can start with an optional DOS header, so if an image is run
57/// under DOS it can print an error message.
58///
59typedef struct {
60 UINT16 e_magic; ///< Magic number.
61 UINT16 e_cblp; ///< Bytes on last page of file.
62 UINT16 e_cp; ///< Pages in file.
63 UINT16 e_crlc; ///< Relocations.
64 UINT16 e_cparhdr; ///< Size of header in paragraphs.
65 UINT16 e_minalloc; ///< Minimum extra paragraphs needed.
66 UINT16 e_maxalloc; ///< Maximum extra paragraphs needed.
67 UINT16 e_ss; ///< Initial (relative) SS value.
68 UINT16 e_sp; ///< Initial SP value.
69 UINT16 e_csum; ///< Checksum.
70 UINT16 e_ip; ///< Initial IP value.
71 UINT16 e_cs; ///< Initial (relative) CS value.
72 UINT16 e_lfarlc; ///< File address of relocation table.
73 UINT16 e_ovno; ///< Overlay number.
74 UINT16 e_res[4]; ///< Reserved words.
75 UINT16 e_oemid; ///< OEM identifier (for e_oeminfo).
76 UINT16 e_oeminfo; ///< OEM information; e_oemid specific.
77 UINT16 e_res2[10]; ///< Reserved words.
78 UINT32 e_lfanew; ///< File address of new exe header.
80
81///
82/// COFF File Header (Object and Image).
83///
93
94///
95/// Size of EFI_IMAGE_FILE_HEADER.
96///
97#define EFI_IMAGE_SIZEOF_FILE_HEADER 20
98
99//
100// Characteristics
101//
102#define EFI_IMAGE_FILE_RELOCS_STRIPPED BIT0 ///< 0x0001 Relocation info stripped from file.
103#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE BIT1 ///< 0x0002 File is executable (i.e. no unresolved externel references).
104#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED BIT2 ///< 0x0004 Line numbers stripped from file.
105#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED BIT3 ///< 0x0008 Local symbols stripped from file.
106#define EFI_IMAGE_FILE_LARGE_ADDRESS_AWARE BIT5 ///< 0x0020 Supports addresses > 2-GB
107#define EFI_IMAGE_FILE_BYTES_REVERSED_LO BIT7 ///< 0x0080 Bytes of machine word are reversed.
108#define EFI_IMAGE_FILE_32BIT_MACHINE BIT8 ///< 0x0100 32 bit word machine.
109#define EFI_IMAGE_FILE_DEBUG_STRIPPED BIT9 ///< 0x0200 Debugging info stripped from file in .DBG file.
110#define EFI_IMAGE_FILE_SYSTEM BIT12 ///< 0x1000 System File.
111#define EFI_IMAGE_FILE_DLL BIT13 ///< 0x2000 File is a DLL.
112#define EFI_IMAGE_FILE_BYTES_REVERSED_HI BIT15 ///< 0x8000 Bytes of machine word are reversed.
113
114///
115/// Header Data Directories.
116///
121
122//
123// Directory Entries
124//
125#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT 0
126#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT 1
127#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE 2
128#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
129#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY 4
130#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC 5
131#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG 6
132#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
133#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8
134#define EFI_IMAGE_DIRECTORY_ENTRY_TLS 9
135#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
136
137#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16
138
139///
140/// @attention
141/// EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC means PE32 and
142/// EFI_IMAGE_OPTIONAL_HEADER32 must be used. The data structures only vary
143/// after NT additional fields.
144///
145#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
146
147///
148/// Optional Header Standard Fields for PE32.
149///
189
190///
191/// @attention
192/// EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC means PE32+ and
193/// EFI_IMAGE_OPTIONAL_HEADER64 must be used. The data structures only vary
194/// after NT additional fields.
195///
196#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
197
198///
199/// Optional Header Standard Fields for PE32+.
200///
239
240///
241/// @attention
242/// EFI_IMAGE_NT_HEADERS32 is for use ONLY by tools.
243///
249
250#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)
251
252///
253/// @attention
254/// EFI_IMAGE_HEADERS64 is for use ONLY by tools.
255///
261
262#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)
263
264//
265// Other Windows Subsystem Values
266//
267#define EFI_IMAGE_SUBSYSTEM_UNKNOWN 0
268#define EFI_IMAGE_SUBSYSTEM_NATIVE 1
269#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2
270#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3
271#define EFI_IMAGE_SUBSYSTEM_OS2_CUI 5
272#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI 7
273
274//
275// DLL Characteristics
276//
277#define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
278#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
279#define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
280#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
281#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
282#define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
283#define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
284#define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
285#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
286#define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
287#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
288
289///
290/// Length of ShortName.
291///
292#define EFI_IMAGE_SIZEOF_SHORT_NAME 8
293
294///
295/// Section Table. This table immediately follows the optional header.
296///
312
313///
314/// Size of EFI_IMAGE_SECTION_HEADER.
315///
316#define EFI_IMAGE_SIZEOF_SECTION_HEADER 40
317
318//
319// Section Flags Values
320//
321#define EFI_IMAGE_SCN_TYPE_NO_PAD BIT3 ///< 0x00000008 ///< Reserved.
322#define EFI_IMAGE_SCN_CNT_CODE BIT5 ///< 0x00000020
323#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA BIT6 ///< 0x00000040
324#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA BIT7 ///< 0x00000080
325
326#define EFI_IMAGE_SCN_LNK_OTHER BIT8 ///< 0x00000100 ///< Reserved.
327#define EFI_IMAGE_SCN_LNK_INFO BIT9 ///< 0x00000200 ///< Section contains comments or some other type of information.
328#define EFI_IMAGE_SCN_LNK_REMOVE BIT11 ///< 0x00000800 ///< Section contents will not become part of image.
329#define EFI_IMAGE_SCN_LNK_COMDAT BIT12 ///< 0x00001000
330
331#define EFI_IMAGE_SCN_ALIGN_1BYTES BIT20 ///< 0x00100000
332#define EFI_IMAGE_SCN_ALIGN_2BYTES BIT21 ///< 0x00200000
333#define EFI_IMAGE_SCN_ALIGN_4BYTES (BIT20|BIT21) ///< 0x00300000
334#define EFI_IMAGE_SCN_ALIGN_8BYTES BIT22 ///< 0x00400000
335#define EFI_IMAGE_SCN_ALIGN_16BYTES (BIT20|BIT22) ///< 0x00500000
336#define EFI_IMAGE_SCN_ALIGN_32BYTES (BIT21|BIT22) ///< 0x00600000
337#define EFI_IMAGE_SCN_ALIGN_64BYTES (BIT20|BIT21|BIT22) ///< 0x00700000
338
339#define EFI_IMAGE_SCN_MEM_DISCARDABLE BIT25 ///< 0x02000000
340#define EFI_IMAGE_SCN_MEM_NOT_CACHED BIT26 ///< 0x04000000
341#define EFI_IMAGE_SCN_MEM_NOT_PAGED BIT27 ///< 0x08000000
342#define EFI_IMAGE_SCN_MEM_SHARED BIT28 ///< 0x10000000
343#define EFI_IMAGE_SCN_MEM_EXECUTE BIT29 ///< 0x20000000
344#define EFI_IMAGE_SCN_MEM_READ BIT30 ///< 0x40000000
345#define EFI_IMAGE_SCN_MEM_WRITE BIT31 ///< 0x80000000
346
347///
348/// Size of a Symbol Table Record.
349///
350#define EFI_IMAGE_SIZEOF_SYMBOL 18
351
352//
353// Symbols have a section number of the section in which they are
354// defined. Otherwise, section numbers have the following meanings:
355//
356#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0 ///< Symbol is undefined or is common.
357#define EFI_IMAGE_SYM_ABSOLUTE (UINT16) -1 ///< Symbol is an absolute value.
358#define EFI_IMAGE_SYM_DEBUG (UINT16) -2 ///< Symbol is a special debug item.
359
360//
361// Symbol Type (fundamental) values.
362//
363#define EFI_IMAGE_SYM_TYPE_NULL 0 ///< no type.
364#define EFI_IMAGE_SYM_TYPE_VOID 1 ///< no valid type.
365#define EFI_IMAGE_SYM_TYPE_CHAR 2 ///< type character.
366#define EFI_IMAGE_SYM_TYPE_SHORT 3 ///< type short integer.
367#define EFI_IMAGE_SYM_TYPE_INT 4
368#define EFI_IMAGE_SYM_TYPE_LONG 5
369#define EFI_IMAGE_SYM_TYPE_FLOAT 6
370#define EFI_IMAGE_SYM_TYPE_DOUBLE 7
371#define EFI_IMAGE_SYM_TYPE_STRUCT 8
372#define EFI_IMAGE_SYM_TYPE_UNION 9
373#define EFI_IMAGE_SYM_TYPE_ENUM 10 ///< enumeration.
374#define EFI_IMAGE_SYM_TYPE_MOE 11 ///< member of enumeration.
375#define EFI_IMAGE_SYM_TYPE_BYTE 12
376#define EFI_IMAGE_SYM_TYPE_WORD 13
377#define EFI_IMAGE_SYM_TYPE_UINT 14
378#define EFI_IMAGE_SYM_TYPE_DWORD 15
379
380//
381// Symbol Type (derived) values.
382//
383#define EFI_IMAGE_SYM_DTYPE_NULL 0 ///< no derived type.
384#define EFI_IMAGE_SYM_DTYPE_POINTER 1
385#define EFI_IMAGE_SYM_DTYPE_FUNCTION 2
386#define EFI_IMAGE_SYM_DTYPE_ARRAY 3
387
388//
389// Storage classes.
390//
391#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION ((UINT8) -1)
392#define EFI_IMAGE_SYM_CLASS_NULL 0
393#define EFI_IMAGE_SYM_CLASS_AUTOMATIC 1
394#define EFI_IMAGE_SYM_CLASS_EXTERNAL 2
395#define EFI_IMAGE_SYM_CLASS_STATIC 3
396#define EFI_IMAGE_SYM_CLASS_REGISTER 4
397#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF 5
398#define EFI_IMAGE_SYM_CLASS_LABEL 6
399#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL 7
400#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8
401#define EFI_IMAGE_SYM_CLASS_ARGUMENT 9
402#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG 10
403#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION 11
404#define EFI_IMAGE_SYM_CLASS_UNION_TAG 12
405#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION 13
406#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC 14
407#define EFI_IMAGE_SYM_CLASS_ENUM_TAG 15
408#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16
409#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM 17
410#define EFI_IMAGE_SYM_CLASS_BIT_FIELD 18
411#define EFI_IMAGE_SYM_CLASS_BLOCK 100
412#define EFI_IMAGE_SYM_CLASS_FUNCTION 101
413#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT 102
414#define EFI_IMAGE_SYM_CLASS_FILE 103
415#define EFI_IMAGE_SYM_CLASS_SECTION 104
416#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL 105
417
418//
419// type packing constants
420//
421#define EFI_IMAGE_N_BTMASK 017
422#define EFI_IMAGE_N_TMASK 060
423#define EFI_IMAGE_N_TMASK1 0300
424#define EFI_IMAGE_N_TMASK2 0360
425#define EFI_IMAGE_N_BTSHFT 4
426#define EFI_IMAGE_N_TSHIFT 2
427
428//
429// Communal selection types.
430//
431#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES 1
432#define EFI_IMAGE_COMDAT_SELECT_ANY 2
433#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3
434#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4
435#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
436
437//
438// the following values only be referred in PeCoff, not defined in PECOFF.
439//
440#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
441#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
442#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
443
444///
445/// Relocation format.
446///
452
453///
454/// Size of EFI_IMAGE_RELOCATION
455///
456#define EFI_IMAGE_SIZEOF_RELOCATION 10
457
458//
459// I386 relocation types.
460//
461#define EFI_IMAGE_REL_I386_ABSOLUTE 0x0000 ///< Reference is absolute, no relocation is necessary.
462#define EFI_IMAGE_REL_I386_DIR16 0x0001 ///< Direct 16-bit reference to the symbols virtual address.
463#define EFI_IMAGE_REL_I386_REL16 0x0002 ///< PC-relative 16-bit reference to the symbols virtual address.
464#define EFI_IMAGE_REL_I386_DIR32 0x0006 ///< Direct 32-bit reference to the symbols virtual address.
465#define EFI_IMAGE_REL_I386_DIR32NB 0x0007 ///< Direct 32-bit reference to the symbols virtual address, base not included.
466#define EFI_IMAGE_REL_I386_SEG12 0x0009 ///< Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address.
467#define EFI_IMAGE_REL_I386_SECTION 0x000A
468#define EFI_IMAGE_REL_I386_SECREL 0x000B
469#define EFI_IMAGE_REL_I386_REL32 0x0014 ///< PC-relative 32-bit reference to the symbols virtual address.
470
471//
472// x64 processor relocation types.
473//
474#define IMAGE_REL_AMD64_ABSOLUTE 0x0000
475#define IMAGE_REL_AMD64_ADDR64 0x0001
476#define IMAGE_REL_AMD64_ADDR32 0x0002
477#define IMAGE_REL_AMD64_ADDR32NB 0x0003
478#define IMAGE_REL_AMD64_REL32 0x0004
479#define IMAGE_REL_AMD64_REL32_1 0x0005
480#define IMAGE_REL_AMD64_REL32_2 0x0006
481#define IMAGE_REL_AMD64_REL32_3 0x0007
482#define IMAGE_REL_AMD64_REL32_4 0x0008
483#define IMAGE_REL_AMD64_REL32_5 0x0009
484#define IMAGE_REL_AMD64_SECTION 0x000A
485#define IMAGE_REL_AMD64_SECREL 0x000B
486#define IMAGE_REL_AMD64_SECREL7 0x000C
487#define IMAGE_REL_AMD64_TOKEN 0x000D
488#define IMAGE_REL_AMD64_SREL32 0x000E
489#define IMAGE_REL_AMD64_PAIR 0x000F
490#define IMAGE_REL_AMD64_SSPAN32 0x0010
491
492///
493/// Based relocation format.
494///
499
500///
501/// Size of EFI_IMAGE_BASE_RELOCATION.
502///
503#define EFI_IMAGE_SIZEOF_BASE_RELOCATION 8
504
505//
506// Based relocation types.
507//
508#define EFI_IMAGE_REL_BASED_ABSOLUTE 0
509#define EFI_IMAGE_REL_BASED_HIGH 1
510#define EFI_IMAGE_REL_BASED_LOW 2
511#define EFI_IMAGE_REL_BASED_HIGHLOW 3
512#define EFI_IMAGE_REL_BASED_HIGHADJ 4
513#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5
514#define EFI_IMAGE_REL_BASED_ARM_MOV32A 5
515#define EFI_IMAGE_REL_BASED_ARM_MOV32T 7
516#define EFI_IMAGE_REL_BASED_IA64_IMM64 9
517#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR16 9
518#define EFI_IMAGE_REL_BASED_DIR64 10
519
520///
521/// Relocation types of RISC-V processor.
522///
523#define EFI_IMAGE_REL_BASED_RISCV_HI20 5
524#define EFI_IMAGE_REL_BASED_RISCV_LOW12I 7
525#define EFI_IMAGE_REL_BASED_RISCV_LOW12S 8
526
527//
528// Relocation types of LoongArch processor.
529//
530#define EFI_IMAGE_REL_BASED_LOONGARCH32_MARK_LA 8
531#define EFI_IMAGE_REL_BASED_LOONGARCH64_MARK_LA 8
532
533///
534/// Line number format.
535///
536typedef struct {
537 union {
538 UINT32 SymbolTableIndex; ///< Symbol table index of function name if Linenumber is 0.
539 UINT32 VirtualAddress; ///< Virtual address of line number.
541 UINT16 Linenumber; ///< Line number.
543
544///
545/// Size of EFI_IMAGE_LINENUMBER.
546///
547#define EFI_IMAGE_SIZEOF_LINENUMBER 6
548
549//
550// Archive format.
551//
552#define EFI_IMAGE_ARCHIVE_START_SIZE 8
553#define EFI_IMAGE_ARCHIVE_START "!<arch>\n"
554#define EFI_IMAGE_ARCHIVE_END "`\n"
555#define EFI_IMAGE_ARCHIVE_PAD "\n"
556#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER "/ "
557#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
558
559///
560/// Archive Member Headers
561///
562typedef struct {
563 UINT8 Name[16]; ///< File member name - `/' terminated.
564 UINT8 Date[12]; ///< File member date - decimal.
565 UINT8 UserID[6]; ///< File member user id - decimal.
566 UINT8 GroupID[6]; ///< File member group id - decimal.
567 UINT8 Mode[8]; ///< File member mode - octal.
568 UINT8 Size[10]; ///< File member size - decimal.
569 UINT8 EndHeader[2]; ///< String to end header. (0x60 0x0A).
571
572///
573/// Size of EFI_IMAGE_ARCHIVE_MEMBER_HEADER.
574///
575#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
576
577//
578// DLL Support
579//
580
581///
582/// Export Directory Table.
583///
597
598//
599// Based export types.
600//
601#define EFI_IMAGE_EXPORT_ORDINAL_BASE 1
602#define EFI_IMAGE_EXPORT_ADDR_SIZE 4
603#define EFI_IMAGE_EXPORT_ORDINAL_SIZE 2
604
605///
606/// Hint/Name Table.
607///
612
613///
614/// Import Address Table RVA (Thunk Table).
615///
623
624#define EFI_IMAGE_ORDINAL_FLAG BIT31 ///< Flag for PE32.
625#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)
626#define EFI_IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
627
628///
629/// Import Directory Table
630///
638
639///
640/// Debug Directory Format.
641///
642typedef struct {
649 UINT32 RVA; ///< The address of the debug data when loaded, relative to the image base.
650 UINT32 FileOffset; ///< The file pointer to the debug data.
652
653#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information.
654#define EFI_IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS 20
655
656///
657/// Debug Data Structure defined in Microsoft C++.
658///
659#define CODEVIEW_SIGNATURE_NB10 SIGNATURE_32('N', 'B', '1', '0')
660typedef struct {
661 UINT32 Signature; ///< "NB10"
665 //
666 // Filename of .PDB goes here
667 //
669
670///
671/// Debug Data Structure defined in Microsoft C++.
672///
673#define CODEVIEW_SIGNATURE_RSDS SIGNATURE_32('R', 'S', 'D', 'S')
674typedef struct {
675 UINT32 Signature; ///< "RSDS".
681 //
682 // Filename of .PDB goes here
683 //
685
686///
687/// Debug Data Structure defined by Apple Mach-O to Coff utility.
688///
689#define CODEVIEW_SIGNATURE_MTOC SIGNATURE_32('M', 'T', 'O', 'C')
690typedef struct {
691 UINT32 Signature; ///< "MTOC".
693 //
694 // Filename of .DLL (Mach-O with debug info) goes here
695 //
697
698//
699// .pdata entries for X64
700//
706
715
716///
717/// Extended DLL Characteristics
718///
719#define EFI_IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT 0x0001
720#define EFI_IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT 0x0040
721
725
726///
727/// Resource format.
728///
729typedef struct {
736 //
737 // Array of EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY entries goes here.
738 //
740
741///
742/// Resource directory entry format.
743///
744typedef struct {
745 union {
746 struct {
749 } s;
751 } u1;
752 union {
754 struct {
757 } s;
758 } u2;
760
761///
762/// Resource directory entry for string.
763///
768
769///
770/// Resource directory entry for data array.
771///
778
779///
780/// Header format for TE images, defined in the PI Specification, 1.0.
781///
782typedef struct {
783 UINT16 Signature; ///< The signature for TE format = "VZ".
784 UINT16 Machine; ///< From the original file header.
785 UINT8 NumberOfSections; ///< From the original file header.
786 UINT8 Subsystem; ///< From original optional header.
787 UINT16 StrippedSize; ///< Number of bytes we removed from the header.
788 UINT32 AddressOfEntryPoint; ///< Offset to entry point -- from original optional header.
789 UINT32 BaseOfCode; ///< From original image -- required for ITP debug.
790 UINT64 ImageBase; ///< From original file header.
791 EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; ///< Only base relocation and debug directory.
793
794#define EFI_TE_IMAGE_HEADER_SIGNATURE SIGNATURE_16('V', 'Z')
795
796//
797// Data directory indexes in our TE image header
798//
799#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0
800#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1
801
802///
803/// Union of PE32, PE32+, and TE headers.
804///
810
817
818#endif
unsigned short UINT16
2-byte unsigned value.
unsigned long long UINT64
8-byte unsigned value.
unsigned short CHAR16
2-byte Character.
unsigned char UINT8
1-byte unsigned value.
unsigned int UINT32
4-byte unsigned value.
UINT8 Type
Definition Acpi10.h:137
#define EFI_IMAGE_SIZEOF_SHORT_NAME
Length of ShortName.
Definition PeImage.h:292
#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES
Definition PeImage.h:137
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
Archive Member Headers.
Definition PeImage.h:562
UINT8 Size[10]
File member size - decimal.
Definition PeImage.h:568
UINT8 GroupID[6]
File member group id - decimal.
Definition PeImage.h:566
UINT8 Name[16]
File member name - ‘/’ terminated.
Definition PeImage.h:563
UINT8 Mode[8]
File member mode - octal.
Definition PeImage.h:567
UINT8 UserID[6]
File member user id - decimal.
Definition PeImage.h:565
UINT8 Date[12]
File member date - decimal.
Definition PeImage.h:564
UINT8 EndHeader[2]
String to end header. (0x60 0x0A).
Definition PeImage.h:569
Based relocation format.
Definition PeImage.h:495
Header Data Directories.
Definition PeImage.h:117
Definition PeImage.h:690
GUID MachOUuid
Definition PeImage.h:692
UINT32 Signature
"MTOC".
Definition PeImage.h:691
Definition PeImage.h:660
UINT32 Unknown3
Definition PeImage.h:664
UINT32 Unknown
Definition PeImage.h:662
UINT32 Signature
"NB10"
Definition PeImage.h:661
UINT32 Unknown2
Definition PeImage.h:663
Definition PeImage.h:674
UINT32 Unknown2
Definition PeImage.h:677
UINT32 Unknown4
Definition PeImage.h:679
UINT32 Signature
"RSDS".
Definition PeImage.h:675
UINT32 Unknown3
Definition PeImage.h:678
UINT32 Unknown
Definition PeImage.h:676
UINT32 Unknown5
Definition PeImage.h:680
Debug Directory Format.
Definition PeImage.h:642
UINT32 Type
Definition PeImage.h:647
UINT32 Characteristics
Definition PeImage.h:643
UINT16 MajorVersion
Definition PeImage.h:645
UINT32 SizeOfData
Definition PeImage.h:648
UINT32 TimeDateStamp
Definition PeImage.h:644
UINT16 MinorVersion
Definition PeImage.h:646
UINT32 FileOffset
The file pointer to the debug data.
Definition PeImage.h:650
UINT32 RVA
The address of the debug data when loaded, relative to the image base.
Definition PeImage.h:649
Definition PeImage.h:722
UINT32 DllCharacteristicsEx
Definition PeImage.h:723
PE images can start with an optional DOS header, so if an image is run under DOS it can print an erro...
Definition PeImage.h:59
UINT16 e_oemid
OEM identifier (for e_oeminfo).
Definition PeImage.h:75
UINT16 e_oeminfo
OEM information; e_oemid specific.
Definition PeImage.h:76
UINT16 e_maxalloc
Maximum extra paragraphs needed.
Definition PeImage.h:66
UINT32 e_lfanew
File address of new exe header.
Definition PeImage.h:78
UINT16 e_crlc
Relocations.
Definition PeImage.h:63
UINT16 e_ip
Initial IP value.
Definition PeImage.h:70
UINT16 e_cparhdr
Size of header in paragraphs.
Definition PeImage.h:64
UINT16 e_magic
Magic number.
Definition PeImage.h:60
UINT16 e_minalloc
Minimum extra paragraphs needed.
Definition PeImage.h:65
UINT16 e_csum
Checksum.
Definition PeImage.h:69
UINT16 e_sp
Initial SP value.
Definition PeImage.h:68
UINT16 e_cblp
Bytes on last page of file.
Definition PeImage.h:61
UINT16 e_res[4]
Reserved words.
Definition PeImage.h:74
UINT16 e_ss
Initial (relative) SS value.
Definition PeImage.h:67
UINT16 e_ovno
Overlay number.
Definition PeImage.h:73
UINT16 e_cp
Pages in file.
Definition PeImage.h:62
UINT16 e_lfarlc
File address of relocation table.
Definition PeImage.h:72
UINT16 e_cs
Initial (relative) CS value.
Definition PeImage.h:71
UINT16 e_res2[10]
Reserved words.
Definition PeImage.h:77
Export Directory Table.
Definition PeImage.h:584
COFF File Header (Object and Image).
Definition PeImage.h:84
UINT32 PointerToSymbolTable
Definition PeImage.h:88
UINT16 SizeOfOptionalHeader
Definition PeImage.h:90
UINT16 NumberOfSections
Definition PeImage.h:86
Hint/Name Table.
Definition PeImage.h:608
Import Directory Table.
Definition PeImage.h:631
EFI_IMAGE_THUNK_DATA * FirstThunk
Definition PeImage.h:636
Line number format.
Definition PeImage.h:536
UINT32 SymbolTableIndex
Symbol table index of function name if Linenumber is 0.
Definition PeImage.h:538
UINT32 VirtualAddress
Virtual address of line number.
Definition PeImage.h:539
UINT16 Linenumber
Line number.
Definition PeImage.h:541
EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition PeImage.h:247
EFI_IMAGE_FILE_HEADER FileHeader
Definition PeImage.h:246
EFI_IMAGE_FILE_HEADER FileHeader
Definition PeImage.h:258
EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader
Definition PeImage.h:259
Optional Header Standard Fields for PE32.
Definition PeImage.h:150
UINT32 BaseOfData
PE32 contains this additional field, which is absent in PE32+.
Definition PeImage.h:162
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition PeImage.h:187
UINT32 ImageBase
Optional Header Windows-Specific Fields.
Definition PeImage.h:166
UINT16 Magic
Standard fields.
Definition PeImage.h:154
Optional Header Standard Fields for PE32+.
Definition PeImage.h:201
UINT64 ImageBase
Optional Header Windows-Specific Fields.
Definition PeImage.h:216
UINT16 Magic
Standard fields.
Definition PeImage.h:205
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition PeImage.h:237
Relocation format.
Definition PeImage.h:447
UINT32 SymbolTableIndex
Definition PeImage.h:449
Resource directory entry for data array.
Definition PeImage.h:772
UINT32 CodePage
Definition PeImage.h:775
UINT32 Reserved
Definition PeImage.h:776
UINT32 Size
Definition PeImage.h:774
UINT32 OffsetToData
Definition PeImage.h:773
Resource directory entry format.
Definition PeImage.h:744
UINT32 DataIsDirectory
Definition PeImage.h:756
UINT32 OffsetToDirectory
Definition PeImage.h:755
UINT32 NameIsString
Definition PeImage.h:748
UINT32 NameOffset
Definition PeImage.h:747
UINT32 OffsetToData
Definition PeImage.h:753
UINT32 Id
Definition PeImage.h:750
Resource directory entry for string.
Definition PeImage.h:764
Section Table.
Definition PeImage.h:297
UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME]
Definition PeImage.h:298
Import Address Table RVA (Thunk Table).
Definition PeImage.h:616
EFI_IMAGE_IMPORT_BY_NAME * AddressOfData
Definition PeImage.h:620
Header format for TE images, defined in the PI Specification, 1.0.
Definition PeImage.h:782
UINT32 AddressOfEntryPoint
Offset to entry point – from original optional header.
Definition PeImage.h:788
UINT16 Signature
The signature for TE format = "VZ".
Definition PeImage.h:783
UINT8 Subsystem
From original optional header.
Definition PeImage.h:786
UINT64 ImageBase
From original file header.
Definition PeImage.h:790
UINT32 BaseOfCode
From original image – required for ITP debug.
Definition PeImage.h:789
EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]
Only base relocation and debug directory.
Definition PeImage.h:791
UINT16 StrippedSize
Number of bytes we removed from the header.
Definition PeImage.h:787
UINT8 NumberOfSections
From the original file header.
Definition PeImage.h:785
UINT16 Machine
From the original file header.
Definition PeImage.h:784
128 bit buffer containing a unique identifier value.
Definition Base.h:216
UINT32 UnwindInfoAddress
Definition PeImage.h:704
UINT32 FunctionStartAddress
Definition PeImage.h:702
UINT32 FunctionEndAddress
Definition PeImage.h:703
UINT8 FrameRegister
Definition PeImage.h:712
UINT8 SizeOfProlog
Definition PeImage.h:710
UINT8 Flags
Definition PeImage.h:709
UINT8 Version
Definition PeImage.h:708
UINT8 CountOfUnwindCodes
Definition PeImage.h:711
UINT8 FrameRegisterOffset
Definition PeImage.h:713
EFI_TE_IMAGE_HEADER * Te
Definition PeImage.h:814
EFI_IMAGE_OPTIONAL_HEADER_UNION * Union
Definition PeImage.h:815
EFI_IMAGE_NT_HEADERS32 * Pe32
Definition PeImage.h:812
EFI_IMAGE_NT_HEADERS64 * Pe32Plus
Definition PeImage.h:813
Union of PE32, PE32+, and TE headers.
Definition PeImage.h:805
EFI_IMAGE_NT_HEADERS64 Pe32Plus
Definition PeImage.h:807
EFI_TE_IMAGE_HEADER Te
Definition PeImage.h:808
EFI_IMAGE_NT_HEADERS32 Pe32
Definition PeImage.h:806