]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/gdb/include/coff/pe.h
This file was not part of the GDB 5.2.1 import and should have been
[FreeBSD/FreeBSD.git] / contrib / gdb / 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
63 /* Magic values that are true for all dos/nt implementations */
64 #define DOSMAGIC       0x5a4d  
65 #define NT_SIGNATURE   0x00004550
66
67   /* NT allows long filenames, we want to accommodate this.  This may break
68      some of the bfd functions */
69 #undef  FILNMLEN
70 #define FILNMLEN        18      /* # characters in a file name          */
71
72
73 #ifdef COFF_IMAGE_WITH_PE
74 /* The filehdr is only weired in images */
75
76 #undef FILHDR
77 struct external_PE_filehdr
78 {
79   /* DOS header fields */
80   char e_magic[2];              /* Magic number, 0x5a4d */
81   char e_cblp[2];               /* Bytes on last page of file, 0x90 */
82   char e_cp[2];                 /* Pages in file, 0x3 */
83   char e_crlc[2];               /* Relocations, 0x0 */
84   char e_cparhdr[2];            /* Size of header in paragraphs, 0x4 */
85   char e_minalloc[2];           /* Minimum extra paragraphs needed, 0x0 */
86   char e_maxalloc[2];           /* Maximum extra paragraphs needed, 0xFFFF */
87   char e_ss[2];                 /* Initial (relative) SS value, 0x0 */
88   char e_sp[2];                 /* Initial SP value, 0xb8 */
89   char e_csum[2];               /* Checksum, 0x0 */
90   char e_ip[2];                 /* Initial IP value, 0x0 */
91   char e_cs[2];                 /* Initial (relative) CS value, 0x0 */
92   char e_lfarlc[2];             /* File address of relocation table, 0x40 */
93   char e_ovno[2];               /* Overlay number, 0x0 */
94   char e_res[4][2];             /* Reserved words, all 0x0 */
95   char e_oemid[2];              /* OEM identifier (for e_oeminfo), 0x0 */
96   char e_oeminfo[2];            /* OEM information; e_oemid specific, 0x0 */
97   char e_res2[10][2];           /* Reserved words, all 0x0 */
98   char e_lfanew[4];             /* File address of new exe header, 0x80 */
99   char dos_message[16][4];      /* other stuff, always follow DOS header */
100   char nt_signature[4];         /* required NT signature, 0x4550 */ 
101
102   /* From standard header */  
103
104
105   char f_magic[2];              /* magic number                 */
106   char f_nscns[2];              /* number of sections           */
107   char f_timdat[4];             /* time & date stamp            */
108   char f_symptr[4];             /* file pointer to symtab       */
109   char f_nsyms[4];              /* number of symtab entries     */
110   char f_opthdr[2];             /* sizeof(optional hdr)         */
111   char f_flags[2];              /* flags                        */
112
113 };
114
115
116 #define FILHDR struct external_PE_filehdr
117
118
119 #endif
120
121 typedef struct 
122 {
123   AOUTHDR standard;
124
125   /* NT extra fields; see internal.h for descriptions */
126   char  ImageBase[4];
127   char  SectionAlignment[4];
128   char  FileAlignment[4];
129   char  MajorOperatingSystemVersion[2];
130   char  MinorOperatingSystemVersion[2];
131   char  MajorImageVersion[2];
132   char  MinorImageVersion[2];
133   char  MajorSubsystemVersion[2];
134   char  MinorSubsystemVersion[2];
135   char  Reserved1[4];
136   char  SizeOfImage[4];
137   char  SizeOfHeaders[4];
138   char  CheckSum[4];
139   char  Subsystem[2];
140   char  DllCharacteristics[2];
141   char  SizeOfStackReserve[4];
142   char  SizeOfStackCommit[4];
143   char  SizeOfHeapReserve[4];
144   char  SizeOfHeapCommit[4];
145   char  LoaderFlags[4];
146   char  NumberOfRvaAndSizes[4];
147   /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
148   char  DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
149
150 } PEAOUTHDR;
151
152
153 #undef AOUTSZ
154 #define AOUTSZ sizeof(PEAOUTHDR)
155
156 #undef  E_FILNMLEN
157 #define E_FILNMLEN      18      /* # characters in a file name          */
158 #endif
159
160
161