VirtualBox

source: vbox/trunk/src/recompiler/a.out.h@ 1816

最後變更 在這個檔案從1816是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
檔案大小: 13.8 KB
 
1/* a.out.h
2
3 Copyright 1997, 1998, 1999, 2001 Red Hat, Inc.
4
5This file is part of Cygwin.
6
7This software is a copyrighted work licensed under the terms of the
8Cygwin license. Please consult the file "CYGWIN_LICENSE" for
9details. */
10
11#ifndef _A_OUT_H_
12#define _A_OUT_H_
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17#define COFF_IMAGE_WITH_PE
18#define COFF_LONG_SECTION_NAMES
19
20/*** coff information for Intel 386/486. */
21
22
23/********************** FILE HEADER **********************/
24
25struct external_filehdr {
26 short f_magic; /* magic number */
27 short f_nscns; /* number of sections */
28 unsigned long f_timdat; /* time & date stamp */
29 unsigned long f_symptr; /* file pointer to symtab */
30 unsigned long f_nsyms; /* number of symtab entries */
31 short f_opthdr; /* sizeof(optional hdr) */
32 short f_flags; /* flags */
33};
34
35/* Bits for f_flags:
36 * F_RELFLG relocation info stripped from file
37 * F_EXEC file is executable (no unresolved external references)
38 * F_LNNO line numbers stripped from file
39 * F_LSYMS local symbols stripped from file
40 * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
41 */
42
43#define F_RELFLG (0x0001)
44#define F_EXEC (0x0002)
45#define F_LNNO (0x0004)
46#define F_LSYMS (0x0008)
47
48
49
50#define I386MAGIC 0x14c
51#define I386PTXMAGIC 0x154
52#define I386AIXMAGIC 0x175
53
54/* This is Lynx's all-platform magic number for executables. */
55
56#define LYNXCOFFMAGIC 0415
57
58#define I386BADMAG(x) (((x).f_magic != I386MAGIC) \
59 && (x).f_magic != I386AIXMAGIC \
60 && (x).f_magic != I386PTXMAGIC \
61 && (x).f_magic != LYNXCOFFMAGIC)
62
63#define FILHDR struct external_filehdr
64#define FILHSZ 20
65
66
67/********************** AOUT "OPTIONAL HEADER"=
68 **********************/
69
70
71typedef struct
72{
73 unsigned short magic; /* type of file */
74 unsigned short vstamp; /* version stamp */
75 unsigned long tsize; /* text size in bytes, padded to FW bdry*/
76 unsigned long dsize; /* initialized data " " */
77 unsigned long bsize; /* uninitialized data " " */
78 unsigned long entry; /* entry pt. */
79 unsigned long text_start; /* base of text used for this file */
80 unsigned long data_start; /* base of data used for this file=
81 */
82}
83AOUTHDR;
84
85#define AOUTSZ 28
86#define AOUTHDRSZ 28
87
88#define OMAGIC 0404 /* object files, eg as output */
89#define ZMAGIC 0413 /* demand load format, eg normal ld output */
90#define STMAGIC 0401 /* target shlib */
91#define SHMAGIC 0443 /* host shlib */
92
93
94/* define some NT default values */
95/* #define NT_IMAGE_BASE 0x400000 moved to internal.h */
96#define NT_SECTION_ALIGNMENT 0x1000
97#define NT_FILE_ALIGNMENT 0x200
98#define NT_DEF_RESERVE 0x100000
99#define NT_DEF_COMMIT 0x1000
100
101/********************** SECTION HEADER **********************/
102
103
104struct external_scnhdr {
105 char s_name[8]; /* section name */
106 unsigned long s_paddr; /* physical address, offset
107 of last addr in scn */
108 unsigned long s_vaddr; /* virtual address */
109 unsigned long s_size; /* section size */
110 unsigned long s_scnptr; /* file ptr to raw data for section */
111 unsigned long s_relptr; /* file ptr to relocation */
112 unsigned long s_lnnoptr; /* file ptr to line numbers */
113 unsigned short s_nreloc; /* number of relocation entries */
114 unsigned short s_nlnno; /* number of line number entries*/
115 unsigned long s_flags; /* flags */
116};
117
118#define SCNHDR struct external_scnhdr
119#define SCNHSZ 40
120
121/*
122 * names of "special" sections
123 */
124#define _TEXT ".text"
125#define _DATA ".data"
126#define _BSS ".bss"
127#define _COMMENT ".comment"
128#define _LIB ".lib"
129
130/********************** LINE NUMBERS **********************/
131
132/* 1 line number entry for every "breakpointable" source line in a section.
133 * Line numbers are grouped on a per function basis; first entry in a function
134 * grouping will have l_lnno = 0 and in place of physical address will be the
135 * symbol table index of the function name.
136 */
137struct external_lineno {
138 union {
139 unsigned long l_symndx; /* function name symbol index, iff l_lnno 0 */
140 unsigned long l_paddr; /* (physical) address of line number */
141 } l_addr;
142 unsigned short l_lnno; /* line number */
143};
144
145#define LINENO struct external_lineno
146#define LINESZ 6
147
148/********************** SYMBOLS **********************/
149
150#define E_SYMNMLEN 8 /* # characters in a symbol name */
151#define E_FILNMLEN 14 /* # characters in a file name */
152#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
153
154#pragma pack(1)
155
156struct external_syment
157{
158 union {
159 char e_name[E_SYMNMLEN];
160 struct {
161 unsigned long e_zeroes;
162 unsigned long e_offset;
163 } e;
164 } e;
165 unsigned long e_value;
166 unsigned short e_scnum;
167 unsigned short e_type;
168 char e_sclass[1];
169 char e_numaux[1];
170};
171
172#pragma pack()
173
174#define N_BTMASK (0xf)
175#define N_TMASK (0x30)
176#define N_BTSHFT (4)
177#define N_TSHIFT (2)
178
179union external_auxent {
180 struct {
181 unsigned long x_tagndx; /* str, un, or enum tag indx */
182 union {
183 struct {
184 unsigned short x_lnno; /* declaration line number */
185 unsigned short x_size; /* str/union/array size */
186 } x_lnsz;
187 unsigned long x_fsize; /* size of function */
188 } x_misc;
189 union {
190 struct { /* if ISFCN, tag, or .bb */
191 unsigned long x_lnnoptr;/* ptr to fcn line # */
192 unsigned long x_endndx; /* entry ndx past block end */
193 } x_fcn;
194 struct { /* if ISARY, up to 4 dimen. */
195 char x_dimen[E_DIMNUM][2];
196 } x_ary;
197 } x_fcnary;
198 unsigned short x_tvndx; /* tv index */
199 } x_sym;
200
201 union {
202 char x_fname[E_FILNMLEN];
203 struct {
204 unsigned long x_zeroes;
205 unsigned long x_offset;
206 } x_n;
207 } x_file;
208
209 struct {
210 unsigned long x_scnlen; /* section length */
211 unsigned short x_nreloc; /* # relocation entries */
212 unsigned short x_nlinno; /* # line numbers */
213 unsigned long x_checksum; /* section COMDAT checksum */
214 unsigned short x_associated;/* COMDAT associated section index */
215 char x_comdat[1]; /* COMDAT selection number */
216 } x_scn;
217
218 struct {
219 unsigned long x_tvfill; /* tv fill value */
220 unsigned short x_tvlen; /* length of .tv */
221 char x_tvran[2][2]; /* tv range */
222 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
223
224};
225
226#define SYMENT struct external_syment
227#define SYMESZ 18
228#define AUXENT union external_auxent
229#define AUXESZ 18
230
231#define _ETEXT "etext"
232
233/********************** RELOCATION DIRECTIVES **********************/
234
235struct external_reloc {
236 char r_vaddr[4];
237 char r_symndx[4];
238 char r_type[2];
239};
240
241#define RELOC struct external_reloc
242#define RELSZ 10
243
244/* end of coff/i386.h */
245
246/* PE COFF header information */
247
248#ifndef _PE_H
249#define _PE_H
250
251/* NT specific file attributes */
252#define IMAGE_FILE_RELOCS_STRIPPED 0x0001
253#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
254#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
255#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
256#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
257#define IMAGE_FILE_32BIT_MACHINE 0x0100
258#define IMAGE_FILE_DEBUG_STRIPPED 0x0200
259#define IMAGE_FILE_SYSTEM 0x1000
260#define IMAGE_FILE_DLL 0x2000
261#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
262
263/* additional flags to be set for section headers to allow the NT loader to
264 read and write to the section data (to replace the addresses of data in
265 dlls for one thing); also to execute the section in .text's case=
266 */
267#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
268#define IMAGE_SCN_MEM_EXECUTE 0x20000000
269#define IMAGE_SCN_MEM_READ 0x40000000
270#define IMAGE_SCN_MEM_WRITE 0x80000000
271
272/*
273 * Section characteristics added for ppc-nt
274 */
275
276#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved. */
277
278#define IMAGE_SCN_CNT_CODE 0x00000020 /* Section contains code. */
279#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 /* Section contains initialized data. */
280#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 /* Section contains uninitialized data. */
281
282#define IMAGE_SCN_LNK_OTHER 0x00000100 /* Reserved. */
283#define IMAGE_SCN_LNK_INFO 0x00000200 /* Section contains comments or some other type of information. */
284#define IMAGE_SCN_LNK_REMOVE 0x00000800 /* Section contents will not become part of image. */
285#define IMAGE_SCN_LNK_COMDAT 0x00001000 /* Section contents comdat. */
286
287#define IMAGE_SCN_MEM_FARDATA 0x00008000
288
289#define IMAGE_SCN_MEM_PURGEABLE 0x00020000
290#define IMAGE_SCN_MEM_16BIT 0x00020000
291#define IMAGE_SCN_MEM_LOCKED 0x00040000
292#define IMAGE_SCN_MEM_PRELOAD 0x00080000
293
294#define IMAGE_SCN_ALIGN_1BYTES 0x00100000
295#define IMAGE_SCN_ALIGN_2BYTES 0x00200000
296#define IMAGE_SCN_ALIGN_4BYTES 0x00300000
297#define IMAGE_SCN_ALIGN_8BYTES 0x00400000
298#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default alignment if no others are specified. */
299#define IMAGE_SCN_ALIGN_32BYTES 0x00600000
300#define IMAGE_SCN_ALIGN_64BYTES 0x00700000
301
302
303#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 /* Section contains extended relocations. */
304#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 /* Section is not cachable. */
305#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 /* Section is not pageable. */
306#define IMAGE_SCN_MEM_SHARED 0x10000000 /* Section is shareable. */
307
308/* COMDAT selection codes. */
309
310#define IMAGE_COMDAT_SELECT_NODUPLICATES (1) /* Warn if duplicates. */
311#define IMAGE_COMDAT_SELECT_ANY (2) /* No warning. */
312#define IMAGE_COMDAT_SELECT_SAME_SIZE (3) /* Warn if different size. */
313#define IMAGE_COMDAT_SELECT_EXACT_MATCH (4) /* Warn if different. */
314#define IMAGE_COMDAT_SELECT_ASSOCIATIVE (5) /* Base on other section. */
315
316/* Magic values that are true for all dos/nt implementations */
317#define DOSMAGIC 0x5a4d
318#define NT_SIGNATURE 0x00004550
319
320/* NT allows long filenames, we want to accommodate this. This may break
321 some of the bfd functions */
322#undef FILNMLEN
323#define FILNMLEN 18 /* # characters in a file name */
324
325
326#ifdef COFF_IMAGE_WITH_PE
327/* The filehdr is only weired in images */
328
329#undef FILHDR
330struct external_PE_filehdr
331{
332 /* DOS header fields */
333 unsigned short e_magic; /* Magic number, 0x5a4d */
334 unsigned short e_cblp; /* Bytes on last page of file, 0x90 */
335 unsigned short e_cp; /* Pages in file, 0x3 */
336 unsigned short e_crlc; /* Relocations, 0x0 */
337 unsigned short e_cparhdr; /* Size of header in paragraphs, 0x4 */
338 unsigned short e_minalloc; /* Minimum extra paragraphs needed, 0x0 */
339 unsigned short e_maxalloc; /* Maximum extra paragraphs needed, 0xFFFF */
340 unsigned short e_ss; /* Initial (relative) SS value, 0x0 */
341 unsigned short e_sp; /* Initial SP value, 0xb8 */
342 unsigned short e_csum; /* Checksum, 0x0 */
343 unsigned short e_ip; /* Initial IP value, 0x0 */
344 unsigned short e_cs; /* Initial (relative) CS value, 0x0 */
345 unsigned short e_lfarlc; /* File address of relocation table, 0x40 */
346 unsigned short e_ovno; /* Overlay number, 0x0 */
347 char e_res[4][2]; /* Reserved words, all 0x0 */
348 unsigned short e_oemid; /* OEM identifier (for e_oeminfo), 0x0 */
349 unsigned short e_oeminfo; /* OEM information; e_oemid specific, 0x0 */
350 char e_res2[10][2]; /* Reserved words, all 0x0 */
351 unsigned long e_lfanew; /* File address of new exe header, 0x80 */
352 char dos_message[16][4]; /* other stuff, always follow DOS header */
353 unsigned int nt_signature; /* required NT signature, 0x4550 */
354
355 /* From standard header */
356
357 unsigned short f_magic; /* magic number */
358 unsigned short f_nscns; /* number of sections */
359 unsigned long f_timdat; /* time & date stamp */
360 unsigned long f_symptr; /* file pointer to symtab */
361 unsigned long f_nsyms; /* number of symtab entries */
362 unsigned short f_opthdr; /* sizeof(optional hdr) */
363 unsigned short f_flags; /* flags */
364};
365
366
367#define FILHDR struct external_PE_filehdr
368#undef FILHSZ
369#define FILHSZ 152
370
371#endif
372
373typedef struct
374{
375 unsigned short magic; /* type of file */
376 unsigned short vstamp; /* version stamp */
377 unsigned long tsize; /* text size in bytes, padded to FW bdry*/
378 unsigned long dsize; /* initialized data " " */
379 unsigned long bsize; /* uninitialized data " " */
380 unsigned long entry; /* entry pt. */
381 unsigned long text_start; /* base of text used for this file */
382 unsigned long data_start; /* base of all data used for this file */
383
384 /* NT extra fields; see internal.h for descriptions */
385 unsigned long ImageBase;
386 unsigned long SectionAlignment;
387 unsigned long FileAlignment;
388 unsigned short MajorOperatingSystemVersion;
389 unsigned short MinorOperatingSystemVersion;
390 unsigned short MajorImageVersion;
391 unsigned short MinorImageVersion;
392 unsigned short MajorSubsystemVersion;
393 unsigned short MinorSubsystemVersion;
394 char Reserved1[4];
395 unsigned long SizeOfImage;
396 unsigned long SizeOfHeaders;
397 unsigned long CheckSum;
398 unsigned short Subsystem;
399 unsigned short DllCharacteristics;
400 unsigned long SizeOfStackReserve;
401 unsigned long SizeOfStackCommit;
402 unsigned long SizeOfHeapReserve;
403 unsigned long SizeOfHeapCommit;
404 unsigned long LoaderFlags;
405 unsigned long NumberOfRvaAndSizes;
406 /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
407 char DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
408
409} PEAOUTHDR;
410
411
412#undef AOUTSZ
413#define AOUTSZ (AOUTHDRSZ + 196)
414
415#undef E_FILNMLEN
416#define E_FILNMLEN 18 /* # characters in a file name */
417#endif
418
419/* end of coff/pe.h */
420
421#define DT_NON (0) /* no derived type */
422#define DT_PTR (1) /* pointer */
423#define DT_FCN (2) /* function */
424#define DT_ARY (3) /* array */
425
426#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
427#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
428#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
429
430#ifdef __cplusplus
431}
432#endif
433
434#endif /* _A_OUT_H_ */
435
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette