1 |
106 |
markom |
/* 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 |
|
|
/* Magic values that are true for all dos/nt implementations */
|
93 |
|
|
#define DOSMAGIC 0x5a4d
|
94 |
|
|
#define NT_SIGNATURE 0x00004550
|
95 |
|
|
|
96 |
|
|
/* NT allows long filenames, we want to accommodate this. This may break
|
97 |
|
|
some of the bfd functions */
|
98 |
|
|
#undef FILNMLEN
|
99 |
|
|
#define FILNMLEN 18 /* # characters in a file name */
|
100 |
|
|
|
101 |
|
|
struct external_PEI_filehdr
|
102 |
|
|
{
|
103 |
|
|
/* DOS header fields */
|
104 |
|
|
char e_magic[2]; /* Magic number, 0x5a4d */
|
105 |
|
|
char e_cblp[2]; /* Bytes on last page of file, 0x90 */
|
106 |
|
|
char e_cp[2]; /* Pages in file, 0x3 */
|
107 |
|
|
char e_crlc[2]; /* Relocations, 0x0 */
|
108 |
|
|
char e_cparhdr[2]; /* Size of header in paragraphs, 0x4 */
|
109 |
|
|
char e_minalloc[2]; /* Minimum extra paragraphs needed, 0x0 */
|
110 |
|
|
char e_maxalloc[2]; /* Maximum extra paragraphs needed, 0xFFFF */
|
111 |
|
|
char e_ss[2]; /* Initial (relative) SS value, 0x0 */
|
112 |
|
|
char e_sp[2]; /* Initial SP value, 0xb8 */
|
113 |
|
|
char e_csum[2]; /* Checksum, 0x0 */
|
114 |
|
|
char e_ip[2]; /* Initial IP value, 0x0 */
|
115 |
|
|
char e_cs[2]; /* Initial (relative) CS value, 0x0 */
|
116 |
|
|
char e_lfarlc[2]; /* File address of relocation table, 0x40 */
|
117 |
|
|
char e_ovno[2]; /* Overlay number, 0x0 */
|
118 |
|
|
char e_res[4][2]; /* Reserved words, all 0x0 */
|
119 |
|
|
char e_oemid[2]; /* OEM identifier (for e_oeminfo), 0x0 */
|
120 |
|
|
char e_oeminfo[2]; /* OEM information; e_oemid specific, 0x0 */
|
121 |
|
|
char e_res2[10][2]; /* Reserved words, all 0x0 */
|
122 |
|
|
char e_lfanew[4]; /* File address of new exe header, 0x80 */
|
123 |
|
|
char dos_message[16][4]; /* other stuff, always follow DOS header */
|
124 |
|
|
char nt_signature[4]; /* required NT signature, 0x4550 */
|
125 |
|
|
|
126 |
|
|
/* From standard header */
|
127 |
|
|
|
128 |
|
|
char f_magic[2]; /* magic number */
|
129 |
|
|
char f_nscns[2]; /* number of sections */
|
130 |
|
|
char f_timdat[4]; /* time & date stamp */
|
131 |
|
|
char f_symptr[4]; /* file pointer to symtab */
|
132 |
|
|
char f_nsyms[4]; /* number of symtab entries */
|
133 |
|
|
char f_opthdr[2]; /* sizeof(optional hdr) */
|
134 |
|
|
char f_flags[2]; /* flags */
|
135 |
|
|
|
136 |
|
|
};
|
137 |
|
|
|
138 |
|
|
#ifdef COFF_IMAGE_WITH_PE
|
139 |
|
|
|
140 |
|
|
/* The filehdr is only weird in images. */
|
141 |
|
|
|
142 |
|
|
#undef FILHDR
|
143 |
|
|
#define FILHDR struct external_PEI_filehdr
|
144 |
|
|
#undef FILHSZ
|
145 |
|
|
#define FILHSZ 152
|
146 |
|
|
|
147 |
|
|
#endif /* COFF_IMAGE_WITH_PE */
|
148 |
|
|
|
149 |
|
|
typedef struct
|
150 |
|
|
{
|
151 |
|
|
AOUTHDR standard;
|
152 |
|
|
|
153 |
|
|
/* NT extra fields; see internal.h for descriptions */
|
154 |
|
|
char ImageBase[4];
|
155 |
|
|
char SectionAlignment[4];
|
156 |
|
|
char FileAlignment[4];
|
157 |
|
|
char MajorOperatingSystemVersion[2];
|
158 |
|
|
char MinorOperatingSystemVersion[2];
|
159 |
|
|
char MajorImageVersion[2];
|
160 |
|
|
char MinorImageVersion[2];
|
161 |
|
|
char MajorSubsystemVersion[2];
|
162 |
|
|
char MinorSubsystemVersion[2];
|
163 |
|
|
char Reserved1[4];
|
164 |
|
|
char SizeOfImage[4];
|
165 |
|
|
char SizeOfHeaders[4];
|
166 |
|
|
char CheckSum[4];
|
167 |
|
|
char Subsystem[2];
|
168 |
|
|
char DllCharacteristics[2];
|
169 |
|
|
char SizeOfStackReserve[4];
|
170 |
|
|
char SizeOfStackCommit[4];
|
171 |
|
|
char SizeOfHeapReserve[4];
|
172 |
|
|
char SizeOfHeapCommit[4];
|
173 |
|
|
char LoaderFlags[4];
|
174 |
|
|
char NumberOfRvaAndSizes[4];
|
175 |
|
|
/* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
|
176 |
|
|
char DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
|
177 |
|
|
|
178 |
|
|
} PEAOUTHDR;
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
#undef AOUTSZ
|
182 |
|
|
#define AOUTSZ (AOUTHDRSZ + 196)
|
183 |
|
|
|
184 |
|
|
#undef E_FILNMLEN
|
185 |
|
|
#define E_FILNMLEN 18 /* # characters in a file name */
|
186 |
|
|
|
187 |
|
|
/* Import Tyoes fot ILF format object files.. */
|
188 |
|
|
#define IMPORT_CODE 0
|
189 |
|
|
#define IMPORT_DATA 1
|
190 |
|
|
#define IMPORT_CONST 2
|
191 |
|
|
|
192 |
|
|
/* Import Name Tyoes for ILF format object files. */
|
193 |
|
|
#define IMPORT_ORDINAL 0
|
194 |
|
|
#define IMPORT_NAME 1
|
195 |
|
|
#define IMPORT_NAME_NOPREFIX 2
|
196 |
|
|
#define IMPORT_NAME_UNDECORATE 3
|
197 |
|
|
|
198 |
|
|
#endif /* _PE_H */
|