1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2010 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
38 * Microsoft Portable Executable and Common Object
39 * File Format Specification
41 * Revision 8.1 – February 15, 2008
47 #define IMAGE_FILE_MACHINE_UNKNOWN 0x0000
48 #define IMAGE_FILE_MACHINE_AM33 0x01d3
49 #define IMAGE_FILE_MACHINE_AMD64 0x8664
50 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
51 #define IMAGE_FILE_MACHINE_M32R 0x9041
52 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
53 #define IMAGE_FILE_MACHINE_ARM 0x01c0
54 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
55 #define IMAGE_FILE_MACHINE_I386 0x014c
56 #define IMAGE_FILE_MACHINE_IA64 0x0200
57 #define IMAGE_FILE_MACHINE_M68K 0x0268
58 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
59 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
60 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
61 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
62 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
63 #define IMAGE_FILE_MACHINE_R3000 0x0162
64 #define IMAGE_FILE_MACHINE_R4000 0x0166
65 #define IMAGE_FILE_MACHINE_R10000 0x0168
66 #define IMAGE_FILE_MACHINE_SH3 0x01a2
67 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
68 #define IMAGE_FILE_MACHINE_SH4 0x01a6
69 #define IMAGE_FILE_MACHINE_SH5 0x01a8
70 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
71 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
72 #define IMAGE_FILE_MACHINE_MASK 0xffff
77 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001
78 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
79 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
80 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
81 #define IMAGE_FILE_AGGRESSIVE_WS_TRIM 0x0010
82 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
83 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
84 #define IMAGE_FILE_32BIT_MACHINE 0x0100
85 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
86 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
87 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
88 #define IMAGE_FILE_SYSTEM 0x1000
89 #define IMAGE_FILE_DLL 0x2000
90 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
91 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
96 #define IMAGE_SUBSYSTEM_UNKNOWN 0
97 #define IMAGE_SUBSYSTEM_NATIVE 1
98 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2
99 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3
100 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
101 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
102 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
103 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
104 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
105 #define IMAGE_SUBSYSTEM_EFI_ROM 13
106 #define IMAGE_SUBSYSTEM_XBOX 14
109 * DLL characteristics
111 #define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE 0x0040
112 #define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY 0x0080
113 #define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT 0x0100
114 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
115 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
116 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
117 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
118 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
123 #define IMAGE_SCN_TYPE_REG 0x00000000
124 #define IMAGE_SCN_TYPE_DSECT 0x00000001
125 #define IMAGE_SCN_TYPE_NOLOAD 0x00000002
126 #define IMAGE_SCN_TYPE_GROUP 0x00000004
127 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008
128 #define IMAGE_SCN_TYPE_COPY 0x00000010
130 #define IMAGE_SCN_CNT_CODE 0x00000020
131 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
132 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
134 #define IMAGE_SCN_LNK_OTHER 0x00000100
135 #define IMAGE_SCN_LNK_INFO 0x00000200
136 #define IMAGE_SCN_TYPE_OVER 0x00000400
137 #define IMAGE_SCN_LNK_REMOVE 0x00000800
138 #define IMAGE_SCN_LNK_COMDAT 0x00001000
140 #define IMAGE_SCN_MAX_RELOC 0xffff
142 #define IMAGE_SCN_MEM_FARDATA 0x00008000
143 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
144 #define IMAGE_SCN_MEM_16BIT 0x00020000
145 #define IMAGE_SCN_MEM_LOCKED 0x00040000
146 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
148 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
149 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
150 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
151 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
152 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000
153 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
154 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
155 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
156 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
157 #define IMAGE_SCN_ALIGN_512BYTES 0x00a00000
158 #define IMAGE_SCN_ALIGN_1024BYTES 0x00b00000
159 #define IMAGE_SCN_ALIGN_2048BYTES 0x00c00000
160 #define IMAGE_SCN_ALIGN_4096BYTES 0x00d00000
161 #define IMAGE_SCN_ALIGN_8192BYTES 0x00e00000
162 #define IMAGE_SCN_ALIGN_MASK 0x00f00000
164 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
165 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
166 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
167 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
168 #define IMAGE_SCN_MEM_SHARED 0x10000000
169 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
170 #define IMAGE_SCN_MEM_READ 0x40000000
171 #define IMAGE_SCN_MEM_WRITE 0x80000000
174 * Relocation type x86-64
176 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
177 #define IMAGE_REL_AMD64_ADDR64 0x0001
178 #define IMAGE_REL_AMD64_ADDR32 0x0002
179 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
180 #define IMAGE_REL_AMD64_REL32 0x0004
181 #define IMAGE_REL_AMD64_REL32_1 0x0005
182 #define IMAGE_REL_AMD64_REL32_2 0x0006
183 #define IMAGE_REL_AMD64_REL32_3 0x0007
184 #define IMAGE_REL_AMD64_REL32_4 0x0008
185 #define IMAGE_REL_AMD64_REL32_5 0x0009
186 #define IMAGE_REL_AMD64_SECTION 0x000a
187 #define IMAGE_REL_AMD64_SECREL 0x000b
188 #define IMAGE_REL_AMD64_SECREL7 0x000c
189 #define IMAGE_REL_AMD64_TOKEN 0x000d
190 #define IMAGE_REL_AMD64_SREL32 0x000e
191 #define IMAGE_REL_AMD64_PAIR 0x000f
192 #define IMAGE_REL_AMD64_SSPAN32 0x0010
195 * Relocation types i386
197 #define IMAGE_REL_I386_ABSOLUTE 0x0000
198 #define IMAGE_REL_I386_DIR16 0x0001
199 #define IMAGE_REL_I386_REL16 0x0002
200 #define IMAGE_REL_I386_DIR32 0x0006
201 #define IMAGE_REL_I386_DIR32NB 0x0007
202 #define IMAGE_REL_I386_SEG12 0x0009
203 #define IMAGE_REL_I386_SECTION 0x000a
204 #define IMAGE_REL_I386_SECREL 0x000b
205 #define IMAGE_REL_I386_TOKEN 0x000c
206 #define IMAGE_REL_I386_SECREL7 0x000d
207 #define IMAGE_REL_I386_REL32 0x0014
210 * Relocation types ARM
212 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
213 #define IMAGE_REL_ARM_ADDR32 0x0001
214 #define IMAGE_REL_ARM_ADDR32NB 0x0002
215 #define IMAGE_REL_ARM_BRANCH24 0x0003
216 #define IMAGE_REL_ARM_BRANCH11 0x0004
217 #define IMAGE_REL_ARM_SECTION 0x000e
218 #define IMAGE_REL_ARM_SECREL 0x000f
221 * Relocation types Hitachi SuperH
223 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
224 #define IMAGE_REL_SH3_DIRECT16 0x0001
225 #define IMAGE_REL_SH3_DIRECT32 0x0002
226 #define IMAGE_REL_SH3_DIRECT8 0x0003
227 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
228 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
229 #define IMAGE_REL_SH3_DIRECT4 0x0006
230 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
231 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
232 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
233 #define IMAGE_REL_SH3_PCREL8_LONG 0x000a
234 #define IMAGE_REL_SH3_PCREL12_WORD 0x000b
235 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000c
236 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000d
237 #define IMAGE_REL_SH3_SECTION 0x000e
238 #define IMAGE_REL_SH3_SECREL 0x000f
239 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
240 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
241 #define IMAGE_REL_SH3_TOKEN 0x0012
242 #define IMAGE_REL_SHM_PCRELPT 0x0013
243 #define IMAGE_REL_SHM_REFLO 0x0014
244 #define IMAGE_REL_SHM_REFHALF 0x0015
245 #define IMAGE_REL_SHM_RELLO 0x0016
246 #define IMAGE_REL_SHM_RELHALF 0x0017
247 #define IMAGE_REL_SHM_PAIR 0x0018
248 #define IMAGE_REL_SHM_NOMODE 0x8000
251 * Relocation types IBM PowerPC processors
253 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
254 #define IMAGE_REL_PPC_ADDR64 0x0001
255 #define IMAGE_REL_PPC_ADDR32 0x0002
256 #define IMAGE_REL_PPC_ADDR24 0x0003
257 #define IMAGE_REL_PPC_ADDR16 0x0004
258 #define IMAGE_REL_PPC_ADDR14 0x0005
259 #define IMAGE_REL_PPC_REL24 0x0006
260 #define IMAGE_REL_PPC_REL14 0x0007
261 #define IMAGE_REL_PPC_ADDR32NB 0x000a
262 #define IMAGE_REL_PPC_SECREL 0x000b
263 #define IMAGE_REL_PPC_SECTION 0x000c
264 #define IMAGE_REL_PPC_SECREL16 0x000f
265 #define IMAGE_REL_PPC_REFHI 0x0010
266 #define IMAGE_REL_PPC_REFLO 0x0011
267 #define IMAGE_REL_PPC_PAIR 0x0012
268 #define IMAGE_REL_PPC_SECRELLO 0x0013
269 #define IMAGE_REL_PPC_GPREL 0x0015
270 #define IMAGE_REL_PPC_TOKEN 0x0016
273 * Relocation types Intel Itanium processor family (IPF)
275 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
276 #define IMAGE_REL_IA64_IMM14 0x0001
277 #define IMAGE_REL_IA64_IMM22 0x0002
278 #define IMAGE_REL_IA64_IMM64 0x0003
279 #define IMAGE_REL_IA64_DIR32 0x0004
280 #define IMAGE_REL_IA64_DIR64 0x0005
281 #define IMAGE_REL_IA64_PCREL21B 0x0006
282 #define IMAGE_REL_IA64_PCREL21M 0x0007
283 #define IMAGE_REL_IA64_PCREL21F 0x0008
284 #define IMAGE_REL_IA64_GPREL22 0x0009
285 #define IMAGE_REL_IA64_LTOFF22 0x000a
286 #define IMAGE_REL_IA64_SECTION 0x000b
287 #define IMAGE_REL_IA64_SECREL22 0x000c
288 #define IMAGE_REL_IA64_SECREL64I 0x000d
289 #define IMAGE_REL_IA64_SECREL32 0x000e
290 #define IMAGE_REL_IA64_DIR32NB 0x0010
291 #define IMAGE_REL_IA64_SREL14 0x0011
292 #define IMAGE_REL_IA64_SREL22 0x0012
293 #define IMAGE_REL_IA64_SREL32 0x0013
294 #define IMAGE_REL_IA64_UREL32 0x0014
295 #define IMAGE_REL_IA64_PCREL60X 0x0015
296 #define IMAGE_REL_IA64_PCREL 60B 0x0016
297 #define IMAGE_REL_IA64_PCREL60F 0x0017
298 #define IMAGE_REL_IA64_PCREL60I 0x0018
299 #define IMAGE_REL_IA64_PCREL60M 0x0019
300 #define IMAGE_REL_IA64_IMMGPREL64 0x001a
301 #define IMAGE_REL_IA64_TOKEN 0x001b
302 #define IMAGE_REL_IA64_GPREL32 0x001c
303 #define IMAGE_REL_IA64_ADDEND 0x001f
306 * Relocation types MIPS Processors
308 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
309 #define IMAGE_REL_MIPS_REFHALF 0x0001
310 #define IMAGE_REL_MIPS_REFWORD 0x0002
311 #define IMAGE_REL_MIPS_JMPADDR 0x0003
312 #define IMAGE_REL_MIPS_REFHI 0x0004
313 #define IMAGE_REL_MIPS_REFLO 0x0005
314 #define IMAGE_REL_MIPS_GPREL 0x0006
315 #define IMAGE_REL_MIPS_LITERAL 0x0007
316 #define IMAGE_REL_MIPS_SECTION 0x000a
317 #define IMAGE_REL_MIPS_SECREL 0x000b
318 #define IMAGE_REL_MIPS_SECRELLO 0x000c
319 #define IMAGE_REL_MIPS_SECRELHI 0x000d
320 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
321 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
322 #define IMAGE_REL_MIPS_PAIR 0x0025
325 * Relocation types Mitsubishi M32R
327 #define IMAGE_REL_M32R_ABSOLUTE 0x0000
328 #define IMAGE_REL_M32R_ADDR32 0x0001
329 #define IMAGE_REL_M32R_ADDR32NB 0x0002
330 #define IMAGE_REL_M32R_ADDR24 0x0003
331 #define IMAGE_REL_M32R_GPREL16 0x0004
332 #define IMAGE_REL_M32R_PCREL24 0x0005
333 #define IMAGE_REL_M32R_PCREL16 0x0006
334 #define IMAGE_REL_M32R_PCREL8 0x0007
335 #define IMAGE_REL_M32R_REFHALF 0x0008
336 #define IMAGE_REL_M32R_REFHI 0x0009
337 #define IMAGE_REL_M32R_REFLO 0x000a
338 #define IMAGE_REL_M32R_PAIR 0x000b
339 #define IMAGE_REL_M32R_SECTION 0x000c
340 #define IMAGE_REL_M32R_SECREL 0x000d
341 #define IMAGE_REL_M32R_TOKEN 0x000e
344 * Section number values
346 #define IMAGE_SYM_UNDEFINED 0
347 #define IMAGE_SYM_ABSOLUTE -1
348 #define IMAGE_SYM_DEBUG -2
351 * Type representation
353 #define IMAGE_SYM_TYPE_NULL 0
354 #define IMAGE_SYM_TYPE_VOID 1
355 #define IMAGE_SYM_TYPE_CHAR 2
356 #define IMAGE_SYM_TYPE_SHORT 3
357 #define IMAGE_SYM_TYPE_INT 4
358 #define IMAGE_SYM_TYPE_LONG 5
359 #define IMAGE_SYM_TYPE_FLOAT 6
360 #define IMAGE_SYM_TYPE_DOUBLE 7
361 #define IMAGE_SYM_TYPE_STRUCT 8
362 #define IMAGE_SYM_TYPE_UNION 9
363 #define IMAGE_SYM_TYPE_ENUM 10
364 #define IMAGE_SYM_TYPE_MOE 11
365 #define IMAGE_SYM_TYPE_BYTE 12
366 #define IMAGE_SYM_TYPE_WORD 13
367 #define IMAGE_SYM_TYPE_UINT 14
368 #define IMAGE_SYM_TYPE_DWORD 15
370 #define IMAGE_SYM_DTYPE_NULL 0
371 #define IMAGE_SYM_DTYPE_POINTER 1
372 #define IMAGE_SYM_DTYPE_FUNCTION 2
373 #define IMAGE_SYM_DTYPE_ARRAY 3
378 #define IMAGE_SYM_CLASS_END_OF_FUNCTION -1
379 #define IMAGE_SYM_CLASS_NULL 0
380 #define IMAGE_SYM_CLASS_AUTOMATIC 1
381 #define IMAGE_SYM_CLASS_EXTERNAL 2
382 #define IMAGE_SYM_CLASS_STATIC 3
383 #define IMAGE_SYM_CLAS S_REGISTER 4
384 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 5
385 #define IMAGE_SYM_CLASS_LABEL 6
386 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 7
387 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8
388 #define IMAGE_SYM_CLASS_ARGUMENT 9
389 #define IMAGE_SYM_CLASS_STRUCT_TAG 10
390 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 11
391 #define IMAGE_SYM_CLASS_UNION_TAG 12
392 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 13
393 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 14
394 #define IMAGE_SYM_CLASS_ENUM_TAG 15
395 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16
396 #define IMAGE_SYM_CLASS_REGISTER_PARAM 17
397 #define IMAGE_SYM_CLASS_BIT_FIELD 18
398 #define IMAGE_SYM_CLASS_BLOCK 100
399 #define IMAGE_SYM_CLASS_FUNCTION 101
400 #define IMAGE_SYM_CLASS_END_OF_STRUCT 102
401 #define IMAGE_SYM_CLASS_FILE 103
402 #define IMAGE_SYM_CLASS_SECTION 104
403 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 105
404 #define IMAGE_SYM_CLASS_CLR_TOKEN 107
409 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
410 #define IMAGE_COMDAT_SELECT_ANY 2
411 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
412 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
413 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
414 #define IMAGE_COMDAT_SELECT_LARGEST 6
417 * Attribute certificate table
419 #define WIN_CERT_REVISION_1_0 0x0100
420 #define WIN_CERT_REVISION_2_0 0x0200
421 #define WIN_CERT_TYPE_X509 0x0001
422 #define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002
423 #define WIN_CERT_TYPE_RESERVED_1 0x0003
424 #define WIN_CERT_TYPE_TS_STACK_SIGNED 0x0004
429 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
430 #define IMAGE_DEBUG_TYPE_COFF 1
431 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
432 #define IMAGE_DEBUG_TYPE_FPO 3
433 #define IMAGE_DEBUG_TYPE_MISC 4
434 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
435 #define IMAGE_DEBUG_TYPE_FIXUP 6
436 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
437 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
438 #define IMAGE_DEBUG_TYP E_BORLAND 9
439 #define IMAGE_DEBUG_TYPE_RESERVED10 10
440 #define IMAGE_DEBUG_TYPE_CLSID 11
443 * Base relocation types
445 #define IMAGE_REL_BASED_ABSOLUTE 0
446 #define IMAGE_REL_BASED_HIGH 1
447 #define IMAGE_REL_BASED_LOW 2
448 #define IMAGE_REL_BASED_HIGHLOW 3
449 #define IMAGE_REL_BASED_HIGHADJ 4
450 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
451 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
452 #define IMAGE_REL_BASED_DIR64 10
455 * TLS callback functions
457 #define DLL_PROCESS_ATTACH 1
458 #define DLL_THREAD_ATTACH 2
459 #define DLL_THREAD_DETACH 3
460 #define DLL_PROCESS_DETACH 0
465 #define IMPORT_CODE 0
466 #define IMPORT_DATA 1
467 #define IMPORT_CONST 2
472 #define IMPORT_ORDINAL 0
473 #define IMPORT_NAME 1
474 #define IMPORT_NAME_NOPREFIX 2
475 #define IMPORT_NAME_UNDECORATE 3
477 struct coff_Section
{
482 struct coff_Reloc
*head
, **tail
;
483 uint32_t flags
; /* section flags */
485 int32_t namepos
; /* Offset of name into the strings table */
490 struct coff_Reloc
*next
;
491 int32_t address
; /* relative to _start_ of section */
492 int32_t symbol
; /* symbol number */
497 } symbase
; /* relocation for symbol number :) */
503 int32_t strpos
; /* string table position of name */
504 int32_t value
; /* address, or COMMON variable size */
505 int section
; /* section number where it's defined
506 * - in COFF codes, not NASM codes */
507 bool is_global
; /* is it a global symbol or not? */
508 int16_t type
; /* 0 - notype, 0x20 - function */
509 int32_t namlen
; /* full name length */
512 struct coff_DebugInfo
{
516 struct coff_Section
*section
;
519 extern struct coff_Section
**coff_sects
;
520 extern int coff_nsects
;
521 extern struct SAA
*coff_syms
;
522 extern uint32_t coff_nsyms
;
523 extern struct SAA
*coff_strs
;
524 extern bool win32
, win64
;
526 extern char coff_infile
[FILENAME_MAX
];
527 extern char coff_outfile
[FILENAME_MAX
];
529 extern int coff_make_section(char *name
, uint32_t flags
);
532 #endif /* PECOFF_H */