This commit was generated by cvs2svn to track changes on a CVS vendor
[external/binutils.git] / include / coff / pe.h
1 /* PE COFF header information */
2
3 #ifndef _PE_H
4 #define _PE_H
5
6 /* NT specific file attributes.  */
7 #define IMAGE_FILE_RELOCS_STRIPPED           0x0001
8 #define IMAGE_FILE_EXECUTABLE_IMAGE          0x0002
9 #define IMAGE_FILE_LINE_NUMS_STRIPPED        0x0004
10 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED       0x0008
11 #define IMAGE_FILE_AGGRESSIVE_WS_TRIM        0x0010
12 #define IMAGE_FILE_LARGE_ADDRESS_AWARE       0x0020
13 #define IMAGE_FILE_16BIT_MACHINE             0x0040
14 #define IMAGE_FILE_BYTES_REVERSED_LO         0x0080
15 #define IMAGE_FILE_32BIT_MACHINE             0x0100
16 #define IMAGE_FILE_DEBUG_STRIPPED            0x0200
17 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP   0x0400
18 #define IMAGE_FILE_SYSTEM                    0x1000
19 #define IMAGE_FILE_DLL                       0x2000
20 #define IMAGE_FILE_UP_SYSTEM_ONLY            0x4000
21 #define IMAGE_FILE_BYTES_REVERSED_HI         0x8000
22
23 /* Additional flags to be set for section headers to allow the NT loader to
24    read and write to the section data (to replace the addresses of data in
25    dlls for one thing); also to execute the section in .text's case.  */
26 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
27 #define IMAGE_SCN_MEM_EXECUTE     0x20000000
28 #define IMAGE_SCN_MEM_READ        0x40000000
29 #define IMAGE_SCN_MEM_WRITE       0x80000000
30
31 /* Section characteristics added for ppc-nt.  */
32
33 #define IMAGE_SCN_TYPE_NO_PAD                0x00000008  /* Reserved. */
34
35 #define IMAGE_SCN_CNT_CODE                   0x00000020  /* Section contains code. */
36 #define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  /* Section contains initialized data. */
37 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  /* Section contains uninitialized data. */
38
39 #define IMAGE_SCN_LNK_OTHER                  0x00000100  /* Reserved. */
40 #define IMAGE_SCN_LNK_INFO                   0x00000200  /* Section contains comments or some other type of information. */
41 #define IMAGE_SCN_LNK_REMOVE                 0x00000800  /* Section contents will not become part of image. */
42 #define IMAGE_SCN_LNK_COMDAT                 0x00001000  /* Section contents comdat. */
43
44 #define IMAGE_SCN_MEM_FARDATA                0x00008000
45
46 #define IMAGE_SCN_MEM_PURGEABLE              0x00020000
47 #define IMAGE_SCN_MEM_16BIT                  0x00020000
48 #define IMAGE_SCN_MEM_LOCKED                 0x00040000
49 #define IMAGE_SCN_MEM_PRELOAD                0x00080000
50
51 #define IMAGE_SCN_ALIGN_1BYTES               0x00100000
52 #define IMAGE_SCN_ALIGN_2BYTES               0x00200000
53 #define IMAGE_SCN_ALIGN_4BYTES               0x00300000
54 #define IMAGE_SCN_ALIGN_8BYTES               0x00400000
55 #define IMAGE_SCN_ALIGN_16BYTES              0x00500000  /* Default alignment if no others are specified. */
56 #define IMAGE_SCN_ALIGN_32BYTES              0x00600000
57 #define IMAGE_SCN_ALIGN_64BYTES              0x00700000
58
59 #define IMAGE_SCN_LNK_NRELOC_OVFL            0x01000000  /* Section contains extended relocations. */
60 #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  /* Section is not cachable.               */
61 #define IMAGE_SCN_MEM_NOT_PAGED              0x08000000  /* Section is not pageable.               */
62 #define IMAGE_SCN_MEM_SHARED                 0x10000000  /* Section is shareable.                  */
63
64 /* COMDAT selection codes.  */
65
66 #define IMAGE_COMDAT_SELECT_NODUPLICATES     (1) /* Warn if duplicates.  */
67 #define IMAGE_COMDAT_SELECT_ANY              (2) /* No warning.  */
68 #define IMAGE_COMDAT_SELECT_SAME_SIZE        (3) /* Warn if different size.  */
69 #define IMAGE_COMDAT_SELECT_EXACT_MATCH      (4) /* Warn if different.  */
70 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE      (5) /* Base on other section.  */
71
72 /* Machine numbers.  */
73
74 #define IMAGE_FILE_MACHINE_UNKNOWN           0x0
75 #define IMAGE_FILE_MACHINE_ALPHA             0x184
76 #define IMAGE_FILE_MACHINE_ARM               0x1c0
77 #define IMAGE_FILE_MACHINE_ALPHA64           0x284
78 #define IMAGE_FILE_MACHINE_I386              0x14c
79 #define IMAGE_FILE_MACHINE_IA64              0x200
80 #define IMAGE_FILE_MACHINE_M68K              0x268
81 #define IMAGE_FILE_MACHINE_MIPS16            0x266
82 #define IMAGE_FILE_MACHINE_MIPSFPU           0x366
83 #define IMAGE_FILE_MACHINE_MIPSFPU16         0x466
84 #define IMAGE_FILE_MACHINE_POWERPC           0x1f0
85 #define IMAGE_FILE_MACHINE_R3000             0x162
86 #define IMAGE_FILE_MACHINE_R4000             0x166
87 #define IMAGE_FILE_MACHINE_R10000            0x168
88 #define IMAGE_FILE_MACHINE_SH3               0x1a2
89 #define IMAGE_FILE_MACHINE_SH4               0x1a6
90 #define IMAGE_FILE_MACHINE_THUMB             0x1c2
91                                                                            
92 #define IMAGE_SUBSYSTEM_UNKNOWN                  0
93 #define IMAGE_SUBSYSTEM_NATIVE                   1
94 #define IMAGE_SUBSYSTEM_WINDOWS_GUI              2
95 #define IMAGE_SUBSYSTEM_WINDOWS_CUI              3
96 #define IMAGE_SUBSYSTEM_POSIX_CUI                7
97 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI           9
98 #define IMAGE_SUBSYSTEM_EFI_APPLICATION         10
99 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
100 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER      12
101   
102 /* Magic values that are true for all dos/nt implementations */
103 #define DOSMAGIC       0x5a4d  
104 #define NT_SIGNATURE   0x00004550
105
106 /* NT allows long filenames, we want to accommodate this.  This may break
107    some of the bfd functions */
108 #undef  FILNMLEN
109 #define FILNMLEN        18      /* # characters in a file name          */
110
111 struct external_PEI_filehdr
112 {
113   /* DOS header fields - always at offset zero in the EXE file */
114   char e_magic[2];              /* Magic number, 0x5a4d */
115   char e_cblp[2];               /* Bytes on last page of file, 0x90 */
116   char e_cp[2];                 /* Pages in file, 0x3 */
117   char e_crlc[2];               /* Relocations, 0x0 */
118   char e_cparhdr[2];            /* Size of header in paragraphs, 0x4 */
119   char e_minalloc[2];           /* Minimum extra paragraphs needed, 0x0 */
120   char e_maxalloc[2];           /* Maximum extra paragraphs needed, 0xFFFF */
121   char e_ss[2];                 /* Initial (relative) SS value, 0x0 */
122   char e_sp[2];                 /* Initial SP value, 0xb8 */
123   char e_csum[2];               /* Checksum, 0x0 */
124   char e_ip[2];                 /* Initial IP value, 0x0 */
125   char e_cs[2];                 /* Initial (relative) CS value, 0x0 */
126   char e_lfarlc[2];             /* File address of relocation table, 0x40 */
127   char e_ovno[2];               /* Overlay number, 0x0 */
128   char e_res[4][2];             /* Reserved words, all 0x0 */
129   char e_oemid[2];              /* OEM identifier (for e_oeminfo), 0x0 */
130   char e_oeminfo[2];            /* OEM information; e_oemid specific, 0x0 */
131   char e_res2[10][2];           /* Reserved words, all 0x0 */
132   char e_lfanew[4];             /* File address of new exe header, usually 0x80 */
133   char dos_message[16][4];      /* other stuff, always follow DOS header */
134
135   /* Note: additional bytes may be inserted before the signature.  Use
136    the e_lfanew field to find the actual location of the NT signature */
137
138   char nt_signature[4];         /* required NT signature, 0x4550 */ 
139
140   /* From standard header */  
141
142   char f_magic[2];              /* magic number                 */
143   char f_nscns[2];              /* number of sections           */
144   char f_timdat[4];             /* time & date stamp            */
145   char f_symptr[4];             /* file pointer to symtab       */
146   char f_nsyms[4];              /* number of symtab entries     */
147   char f_opthdr[2];             /* sizeof(optional hdr)         */
148   char f_flags[2];              /* flags                        */
149 };
150
151 #ifdef COFF_IMAGE_WITH_PE
152
153 /* The filehdr is only weird in images.  */
154
155 #undef  FILHDR
156 #define FILHDR struct external_PEI_filehdr
157 #undef  FILHSZ
158 #define FILHSZ 152
159
160 #endif /* COFF_IMAGE_WITH_PE */
161
162 /* 32-bit PE a.out header: */
163
164 typedef struct 
165 {
166   AOUTHDR standard;
167
168   /* NT extra fields; see internal.h for descriptions */
169   char  ImageBase[4];
170   char  SectionAlignment[4];
171   char  FileAlignment[4];
172   char  MajorOperatingSystemVersion[2];
173   char  MinorOperatingSystemVersion[2];
174   char  MajorImageVersion[2];
175   char  MinorImageVersion[2];
176   char  MajorSubsystemVersion[2];
177   char  MinorSubsystemVersion[2];
178   char  Reserved1[4];
179   char  SizeOfImage[4];
180   char  SizeOfHeaders[4];
181   char  CheckSum[4];
182   char  Subsystem[2];
183   char  DllCharacteristics[2];
184   char  SizeOfStackReserve[4];
185   char  SizeOfStackCommit[4];
186   char  SizeOfHeapReserve[4];
187   char  SizeOfHeapCommit[4];
188   char  LoaderFlags[4];
189   char  NumberOfRvaAndSizes[4];
190   /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
191   char  DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
192 } PEAOUTHDR;
193 #undef AOUTSZ
194 #define AOUTSZ (AOUTHDRSZ + 196)
195
196 /* Like PEAOUTHDR, except that the "standard" member has no BaseOfData
197    (aka data_start) member and that some of the members are 8 instead
198    of just 4 bytes long.  */
199 typedef struct 
200 {
201   AOUTHDR standard;
202
203   /* NT extra fields; see internal.h for descriptions */
204   char  ImageBase[8];
205   char  SectionAlignment[4];
206   char  FileAlignment[4];
207   char  MajorOperatingSystemVersion[2];
208   char  MinorOperatingSystemVersion[2];
209   char  MajorImageVersion[2];
210   char  MinorImageVersion[2];
211   char  MajorSubsystemVersion[2];
212   char  MinorSubsystemVersion[2];
213   char  Reserved1[4];
214   char  SizeOfImage[4];
215   char  SizeOfHeaders[4];
216   char  CheckSum[4];
217   char  Subsystem[2];
218   char  DllCharacteristics[2];
219   char  SizeOfStackReserve[8];
220   char  SizeOfStackCommit[8];
221   char  SizeOfHeapReserve[8];
222   char  SizeOfHeapCommit[8];
223   char  LoaderFlags[4];
224   char  NumberOfRvaAndSizes[4];
225   /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
226   char  DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
227 } PEP64AOUTHDR;
228 #define PEP64AOUTSZ     240
229   
230 #undef  E_FILNMLEN
231 #define E_FILNMLEN      18      /* # characters in a file name          */
232
233 /* Import Tyoes fot ILF format object files..  */
234 #define IMPORT_CODE     0
235 #define IMPORT_DATA     1
236 #define IMPORT_CONST    2
237
238 /* Import Name Tyoes for ILF format object files.  */
239 #define IMPORT_ORDINAL          0
240 #define IMPORT_NAME             1
241 #define IMPORT_NAME_NOPREFIX    2
242 #define IMPORT_NAME_UNDECORATE  3
243
244 #endif /* _PE_H */