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_BYTES_REVERSED_LO         0x0080
12 #define IMAGE_FILE_32BIT_MACHINE             0x0100
13 #define IMAGE_FILE_DEBUG_STRIPPED            0x0200
14 #define IMAGE_FILE_SYSTEM                    0x1000
15 #define IMAGE_FILE_DLL                       0x2000
16 #define IMAGE_FILE_BYTES_REVERSED_HI         0x8000
17
18 /* additional flags to be set for section headers to allow the NT loader to
19    read and write to the section data (to replace the addresses of data in
20    dlls for one thing); also to execute the section in .text's case */
21 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
22 #define IMAGE_SCN_MEM_EXECUTE     0x20000000
23 #define IMAGE_SCN_MEM_READ        0x40000000
24 #define IMAGE_SCN_MEM_WRITE       0x80000000
25
26 /*
27  * Section characteristics added for ppc-nt
28  */
29
30 #define IMAGE_SCN_TYPE_NO_PAD                0x00000008  /* Reserved. */
31
32 #define IMAGE_SCN_CNT_CODE                   0x00000020  /* Section contains code. */
33 #define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  /* Section contains initialized data. */
34 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  /* Section contains uninitialized data. */
35
36 #define IMAGE_SCN_LNK_OTHER                  0x00000100  /* Reserved. */
37 #define IMAGE_SCN_LNK_INFO                   0x00000200  /* Section contains comments or some other type of information. */
38 #define IMAGE_SCN_LNK_REMOVE                 0x00000800  /* Section contents will not become part of image. */
39 #define IMAGE_SCN_LNK_COMDAT                 0x00001000  /* Section contents comdat. */
40
41 #define IMAGE_SCN_MEM_FARDATA                0x00008000
42
43 #define IMAGE_SCN_MEM_PURGEABLE              0x00020000
44 #define IMAGE_SCN_MEM_16BIT                  0x00020000
45 #define IMAGE_SCN_MEM_LOCKED                 0x00040000
46 #define IMAGE_SCN_MEM_PRELOAD                0x00080000
47
48 #define IMAGE_SCN_ALIGN_1BYTES               0x00100000
49 #define IMAGE_SCN_ALIGN_2BYTES               0x00200000
50 #define IMAGE_SCN_ALIGN_4BYTES               0x00300000
51 #define IMAGE_SCN_ALIGN_8BYTES               0x00400000
52 #define IMAGE_SCN_ALIGN_16BYTES              0x00500000  /* Default alignment if no others are specified. */
53 #define IMAGE_SCN_ALIGN_32BYTES              0x00600000
54 #define IMAGE_SCN_ALIGN_64BYTES              0x00700000
55
56
57 #define IMAGE_SCN_LNK_NRELOC_OVFL            0x01000000  /* Section contains extended relocations. */
58 #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  /* Section is not cachable.               */
59 #define IMAGE_SCN_MEM_NOT_PAGED              0x08000000  /* Section is not pageable.               */
60 #define IMAGE_SCN_MEM_SHARED                 0x10000000  /* Section is shareable.                  */
61
62 /* COMDAT selection codes.  */
63
64 #define IMAGE_COMDAT_SELECT_NODUPLICATES     (1) /* Warn if duplicates.  */
65 #define IMAGE_COMDAT_SELECT_ANY              (2) /* No warning.  */
66 #define IMAGE_COMDAT_SELECT_SAME_SIZE        (3) /* Warn if different size.  */
67 #define IMAGE_COMDAT_SELECT_EXACT_MATCH      (4) /* Warn if different.  */
68 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE      (5) /* Base on other section.  */
69
70 /* Magic values that are true for all dos/nt implementations */
71 #define DOSMAGIC       0x5a4d  
72 #define NT_SIGNATURE   0x00004550
73
74   /* NT allows long filenames, we want to accommodate this.  This may break
75      some of the bfd functions */
76 #undef  FILNMLEN
77 #define FILNMLEN        18      /* # characters in a file name          */
78
79
80 #ifdef COFF_IMAGE_WITH_PE
81 /* The filehdr is only weired in images */
82
83 #undef FILHDR
84 struct external_PE_filehdr
85 {
86   /* DOS header fields */
87   char e_magic[2];              /* Magic number, 0x5a4d */
88   char e_cblp[2];               /* Bytes on last page of file, 0x90 */
89   char e_cp[2];                 /* Pages in file, 0x3 */
90   char e_crlc[2];               /* Relocations, 0x0 */
91   char e_cparhdr[2];            /* Size of header in paragraphs, 0x4 */
92   char e_minalloc[2];           /* Minimum extra paragraphs needed, 0x0 */
93   char e_maxalloc[2];           /* Maximum extra paragraphs needed, 0xFFFF */
94   char e_ss[2];                 /* Initial (relative) SS value, 0x0 */
95   char e_sp[2];                 /* Initial SP value, 0xb8 */
96   char e_csum[2];               /* Checksum, 0x0 */
97   char e_ip[2];                 /* Initial IP value, 0x0 */
98   char e_cs[2];                 /* Initial (relative) CS value, 0x0 */
99   char e_lfarlc[2];             /* File address of relocation table, 0x40 */
100   char e_ovno[2];               /* Overlay number, 0x0 */
101   char e_res[4][2];             /* Reserved words, all 0x0 */
102   char e_oemid[2];              /* OEM identifier (for e_oeminfo), 0x0 */
103   char e_oeminfo[2];            /* OEM information; e_oemid specific, 0x0 */
104   char e_res2[10][2];           /* Reserved words, all 0x0 */
105   char e_lfanew[4];             /* File address of new exe header, 0x80 */
106   char dos_message[16][4];      /* other stuff, always follow DOS header */
107   char nt_signature[4];         /* required NT signature, 0x4550 */ 
108
109   /* From standard header */  
110
111
112   char f_magic[2];              /* magic number                 */
113   char f_nscns[2];              /* number of sections           */
114   char f_timdat[4];             /* time & date stamp            */
115   char f_symptr[4];             /* file pointer to symtab       */
116   char f_nsyms[4];              /* number of symtab entries     */
117   char f_opthdr[2];             /* sizeof(optional hdr)         */
118   char f_flags[2];              /* flags                        */
119
120 };
121
122
123 #define FILHDR struct external_PE_filehdr
124 #undef FILHSZ
125 #define FILHSZ 152
126
127 #endif
128
129 typedef struct 
130 {
131   AOUTHDR standard;
132
133   /* NT extra fields; see internal.h for descriptions */
134   char  ImageBase[4];
135   char  SectionAlignment[4];
136   char  FileAlignment[4];
137   char  MajorOperatingSystemVersion[2];
138   char  MinorOperatingSystemVersion[2];
139   char  MajorImageVersion[2];
140   char  MinorImageVersion[2];
141   char  MajorSubsystemVersion[2];
142   char  MinorSubsystemVersion[2];
143   char  Reserved1[4];
144   char  SizeOfImage[4];
145   char  SizeOfHeaders[4];
146   char  CheckSum[4];
147   char  Subsystem[2];
148   char  DllCharacteristics[2];
149   char  SizeOfStackReserve[4];
150   char  SizeOfStackCommit[4];
151   char  SizeOfHeapReserve[4];
152   char  SizeOfHeapCommit[4];
153   char  LoaderFlags[4];
154   char  NumberOfRvaAndSizes[4];
155   /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
156   char  DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
157
158 } PEAOUTHDR;
159
160
161 #undef AOUTSZ
162 #define AOUTSZ (AOUTHDRSZ + 196)
163
164 #undef  E_FILNMLEN
165 #define E_FILNMLEN      18      /* # characters in a file name          */
166 #endif
167
168
169