Initial patches for IA-64 EFI (64-bit PE) support.
[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 */
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, 0x80 */
133   char dos_message[16][4];      /* other stuff, always follow DOS header */
134   char nt_signature[4];         /* required NT signature, 0x4550 */ 
135
136   /* From standard header */  
137
138   char f_magic[2];              /* magic number                 */
139   char f_nscns[2];              /* number of sections           */
140   char f_timdat[4];             /* time & date stamp            */
141   char f_symptr[4];             /* file pointer to symtab       */
142   char f_nsyms[4];              /* number of symtab entries     */
143   char f_opthdr[2];             /* sizeof(optional hdr)         */
144   char f_flags[2];              /* flags                        */
145 };
146
147 #ifdef COFF_IMAGE_WITH_PE
148
149 /* The filehdr is only weird in images.  */
150
151 #undef  FILHDR
152 #define FILHDR struct external_PEI_filehdr
153 #undef  FILHSZ
154 #define FILHSZ 152
155
156 #endif /* COFF_IMAGE_WITH_PE */
157
158 /* 32-bit PE a.out header: */
159
160 typedef struct 
161 {
162   AOUTHDR standard;
163
164   /* NT extra fields; see internal.h for descriptions */
165   char  ImageBase[4];
166   char  SectionAlignment[4];
167   char  FileAlignment[4];
168   char  MajorOperatingSystemVersion[2];
169   char  MinorOperatingSystemVersion[2];
170   char  MajorImageVersion[2];
171   char  MinorImageVersion[2];
172   char  MajorSubsystemVersion[2];
173   char  MinorSubsystemVersion[2];
174   char  Reserved1[4];
175   char  SizeOfImage[4];
176   char  SizeOfHeaders[4];
177   char  CheckSum[4];
178   char  Subsystem[2];
179   char  DllCharacteristics[2];
180   char  SizeOfStackReserve[4];
181   char  SizeOfStackCommit[4];
182   char  SizeOfHeapReserve[4];
183   char  SizeOfHeapCommit[4];
184   char  LoaderFlags[4];
185   char  NumberOfRvaAndSizes[4];
186   /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
187   char  DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
188 } PEAOUTHDR;
189 #undef AOUTSZ
190 #define AOUTSZ (AOUTHDRSZ + 196)
191
192 /* Like PEAOUTHDR, except that the "standard" member has no BaseOfData
193    (aka data_start) member and that some of the members are 8 instead
194    of just 4 bytes long.  */
195 typedef struct 
196 {
197   AOUTHDR standard;
198
199   /* NT extra fields; see internal.h for descriptions */
200   char  ImageBase[8];
201   char  SectionAlignment[4];
202   char  FileAlignment[4];
203   char  MajorOperatingSystemVersion[2];
204   char  MinorOperatingSystemVersion[2];
205   char  MajorImageVersion[2];
206   char  MinorImageVersion[2];
207   char  MajorSubsystemVersion[2];
208   char  MinorSubsystemVersion[2];
209   char  Reserved1[4];
210   char  SizeOfImage[4];
211   char  SizeOfHeaders[4];
212   char  CheckSum[4];
213   char  Subsystem[2];
214   char  DllCharacteristics[2];
215   char  SizeOfStackReserve[8];
216   char  SizeOfStackCommit[8];
217   char  SizeOfHeapReserve[8];
218   char  SizeOfHeapCommit[8];
219   char  LoaderFlags[4];
220   char  NumberOfRvaAndSizes[4];
221   /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
222   char  DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
223 } PEP64AOUTHDR;
224 #define PEP64AOUTSZ     240
225   
226 #undef  E_FILNMLEN
227 #define E_FILNMLEN      18      /* # characters in a file name          */
228
229 /* Import Tyoes fot ILF format object files..  */
230 #define IMPORT_CODE     0
231 #define IMPORT_DATA     1
232 #define IMPORT_CONST    2
233
234 /* Import Name Tyoes for ILF format object files.  */
235 #define IMPORT_ORDINAL          0
236 #define IMPORT_NAME             1
237 #define IMPORT_NAME_NOPREFIX    2
238 #define IMPORT_NAME_UNDECORATE  3
239
240 #endif /* _PE_H */