4 #define MSDOS_SIGNATURE 0x5a4d
5 #define PE_SIGNATURE 0x4550
6 #define PE32_FORMAT 0x10b
7 #define PE32P_FORMAT 0x20b /* PE32+ */
9 #define IMAGE_FILE_MACHINE_I386 0x14c
10 #define IMAGE_FILE_MACHINE_X86_64 0x8664
11 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
12 #define IMAGE_FILE_LINE_NUMBERS_STRIPPED 0x0004
13 #define IMAGE_FILE_32BIT_MACHINE 0x0100
14 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
16 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 0x0a
18 #define IMAGE_SCN_CNT_CODE 0x00000020
19 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
20 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
21 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000
22 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
23 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
24 #define IMAGE_SCN_MEM_READ 0x40000000
26 #define __packed __attribute__((packed))
27 #define OFFSETOF(t,m) ((size_t)&((t *)0)->m)
30 __uint16_t msdos_signature
;
31 __uint8_t _pad1
[0x16];
32 __uint16_t relocs_ptr
;
33 __uint8_t __pad2
[0x3c - 0x1a];
35 __uint16_t pe_signature
;
39 /* FIXME: when setting up coff_hdr, set up optional_hdr_sz
40 * based on PE32 or PE32+ format
47 __uint16_t nr_sections
;
48 __uint32_t timedatestamp
;
51 __uint16_t optional_hdr_sz
;
52 __uint16_t characteristics
;
57 __uint8_t major_linker_version
;
58 __uint8_t minor_linker_version
;
60 __uint32_t initialized_data_sz
;
61 __uint32_t uninitialized_data_sz
;
62 __uint32_t entry_point
;
67 /* For PE32+, the optional_header does NOT have
68 * data after base_code
70 struct optional_hdr_pe32p
{
72 __uint8_t major_linker_version
;
73 __uint8_t minor_linker_version
;
75 __uint32_t initialized_data_sz
;
76 __uint32_t uninitialized_data_sz
;
77 __uint32_t entry_point
;
84 __uint32_t image_base
;
85 __uint32_t section_align
;
86 __uint32_t file_align
;
87 __uint16_t major_os_version
;
88 __uint16_t minor_os_version
;
89 __uint16_t major_image_version
;
90 __uint16_t minor_image_version
;
91 __uint16_t major_subsystem_version
;
92 __uint16_t minor_subsystem_version
;
93 __uint32_t win32_version
;
95 __uint32_t headers_sz
;
98 __uint16_t dll_characteristics
;
99 __uint32_t stack_reserve_sz
;
100 __uint32_t stack_commit_sz
;
101 __uint32_t heap_reserve_sz
;
102 __uint32_t heap_commit_sz
;
103 __uint32_t loader_flags
;
104 __uint32_t rva_and_sizes_nr
;
106 __uint64_t export_table
;
107 __uint64_t import_table
;
108 __uint64_t resource_table
;
109 __uint64_t exception_table
;
110 __uint64_t certification_table
;
111 __uint64_t base_relocation_table
;
115 /* Extra header for PE32+ format
116 * FIXME: There are additional fields in Microsoft PE COFF v8
119 struct extra_hdr_pe32p
{
120 __uint64_t image_base
;
121 __uint32_t section_align
;
122 __uint32_t file_align
;
123 __uint16_t major_os_version
;
124 __uint16_t minor_os_version
;
125 __uint16_t major_image_version
;
126 __uint16_t minor_image_version
;
127 __uint16_t major_subsystem_version
;
128 __uint16_t minor_subsystem_version
;
129 __uint32_t win32_version
;
131 __uint32_t headers_sz
;
133 __uint16_t subsystem
;
134 __uint16_t dll_characteristics
;
135 __uint64_t stack_reserve_sz
;
136 __uint64_t stack_commit_sz
;
137 __uint64_t heap_reserve_sz
;
138 __uint64_t heap_commit_sz
;
139 __uint32_t loader_flags
;
140 __uint32_t rva_and_sizes_nr
;
142 __uint64_t export_table
;
143 __uint64_t import_table
;
144 __uint64_t resource_table
;
145 __uint64_t exception_table
;
146 __uint64_t certification_table
;
147 __uint64_t base_relocation_table
;
153 __uint32_t virtual_sz
;
154 __uint32_t virtual_address
;
155 __uint32_t raw_data_sz
;
158 __uint32_t line_numbers
;
159 __uint16_t relocs_nr
;
160 __uint16_t line_numbers_nr
;
161 __uint32_t characteristics
;
165 __uint32_t virtual_address
;
166 __uint32_t symtab_index
;
170 #endif /* EFI_WRAPPER_H */