ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/kpx_cpu/include/a.out-defs.h
Revision: 1.3
Committed: 2005-03-17T23:44:48Z (19 years, 2 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +12 -0 lines
Log Message:
fix when cross-compiling or using cygwin

File Contents

# Content
1 /* a.out.h
2
3 Copyright 1997, 1998, 1999, 2001 Red Hat, Inc.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 #ifndef _A_OUT_H_
12 #define _A_OUT_H_
13
14 #ifdef __cplusplus
15 extern "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
25 struct external_filehdr {
26 int16_t f_magic; /* magic number */
27 int16_t f_nscns; /* number of sections */
28 uint32_t f_timdat; /* time & date stamp */
29 uint32_t f_symptr; /* file pointer to symtab */
30 uint32_t f_nsyms; /* number of symtab entries */
31 int16_t f_opthdr; /* sizeof(optional hdr) */
32 int16_t 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
71 typedef struct
72 {
73 uint16_t magic; /* type of file */
74 uint16_t vstamp; /* version stamp */
75 uint32_t tsize; /* text size in bytes, padded to FW bdry*/
76 uint32_t dsize; /* initialized data " " */
77 uint32_t bsize; /* uninitialized data " " */
78 uint32_t entry; /* entry pt. */
79 uint32_t text_start; /* base of text used for this file */
80 uint32_t data_start; /* base of data used for this file=
81 */
82 }
83 AOUTHDR;
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
104 struct external_scnhdr {
105 char s_name[8]; /* section name */
106 uint32_t s_paddr; /* physical address, offset
107 of last addr in scn */
108 uint32_t s_vaddr; /* virtual address */
109 uint32_t s_size; /* section size */
110 uint32_t s_scnptr; /* file ptr to raw data for section */
111 uint32_t s_relptr; /* file ptr to relocation */
112 uint32_t s_lnnoptr; /* file ptr to line numbers */
113 uint16_t s_nreloc; /* number of relocation entries */
114 uint16_t s_nlnno; /* number of line number entries*/
115 uint32_t 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 */
137 struct external_lineno {
138 union {
139 uint32_t l_symndx; /* function name symbol index, iff l_lnno 0 */
140 uint32_t l_paddr; /* (physical) address of line number */
141 } l_addr;
142 uint16_t 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 struct external_syment
155 {
156 union {
157 char e_name[E_SYMNMLEN];
158 struct {
159 uint32_t e_zeroes;
160 uint32_t e_offset;
161 } e;
162 } e;
163 uint32_t e_value;
164 uint16_t e_scnum;
165 uint16_t e_type;
166 char e_sclass[1];
167 char e_numaux[1];
168 } __attribute__((packed));
169
170 #ifndef _WIN32
171 #define N_BTMASK (0xf)
172 #define N_TMASK (0x30)
173 #define N_BTSHFT (4)
174 #define N_TSHIFT (2)
175 #endif
176
177 union external_auxent {
178 struct {
179 uint32_t x_tagndx; /* str, un, or enum tag indx */
180 union {
181 struct {
182 uint16_t x_lnno; /* declaration line number */
183 uint16_t x_size; /* str/union/array size */
184 } x_lnsz;
185 uint32_t x_fsize; /* size of function */
186 } x_misc;
187 union {
188 struct { /* if ISFCN, tag, or .bb */
189 uint32_t x_lnnoptr; /* ptr to fcn line # */
190 uint32_t x_endndx; /* entry ndx past block end */
191 } x_fcn;
192 struct { /* if ISARY, up to 4 dimen. */
193 char x_dimen[E_DIMNUM][2];
194 } x_ary;
195 } x_fcnary;
196 uint16_t x_tvndx; /* tv index */
197 } x_sym;
198
199 union {
200 char x_fname[E_FILNMLEN];
201 struct {
202 uint32_t x_zeroes;
203 uint32_t x_offset;
204 } x_n;
205 } x_file;
206
207 struct {
208 uint32_t x_scnlen; /* section length */
209 uint16_t x_nreloc; /* # relocation entries */
210 uint16_t x_nlinno; /* # line numbers */
211 uint32_t x_checksum; /* section COMDAT checksum */
212 uint16_t x_associated;/* COMDAT associated section index */
213 char x_comdat[1]; /* COMDAT selection number */
214 } x_scn;
215
216 struct {
217 uint32_t x_tvfill; /* tv fill value */
218 uint16_t x_tvlen; /* length of .tv */
219 char x_tvran[2][2]; /* tv range */
220 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
221
222 };
223
224 #define SYMENT struct external_syment
225 #define SYMESZ 18
226 #define AUXENT union external_auxent
227 #define AUXESZ 18
228
229 #define _ETEXT "etext"
230
231 /********************** RELOCATION DIRECTIVES **********************/
232
233 struct external_reloc {
234 char r_vaddr[4];
235 char r_symndx[4];
236 char r_type[2];
237 };
238
239 #define RELOC struct external_reloc
240 #define RELSZ 10
241
242 /* end of coff/i386.h */
243
244 /* PE COFF header information */
245
246 #ifndef _PE_H
247 #define _PE_H
248
249 /* NT specific file attributes */
250 #ifndef _WIN32
251 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001
252 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
253 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
254 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
255 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
256 #define IMAGE_FILE_32BIT_MACHINE 0x0100
257 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
258 #define IMAGE_FILE_SYSTEM 0x1000
259 #define IMAGE_FILE_DLL 0x2000
260 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
261 #endif
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 #ifndef _WIN32
268 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
269 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
270 #define IMAGE_SCN_MEM_READ 0x40000000
271 #define IMAGE_SCN_MEM_WRITE 0x80000000
272 #endif
273
274 /*
275 * Section characteristics added for ppc-nt
276 */
277
278 #ifndef _WIN32
279 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved. */
280
281 #define IMAGE_SCN_CNT_CODE 0x00000020 /* Section contains code. */
282 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 /* Section contains initialized data. */
283 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 /* Section contains uninitialized data. */
284
285 #define IMAGE_SCN_LNK_OTHER 0x00000100 /* Reserved. */
286 #define IMAGE_SCN_LNK_INFO 0x00000200 /* Section contains comments or some other type of information. */
287 #define IMAGE_SCN_LNK_REMOVE 0x00000800 /* Section contents will not become part of image. */
288 #define IMAGE_SCN_LNK_COMDAT 0x00001000 /* Section contents comdat. */
289
290 #define IMAGE_SCN_MEM_FARDATA 0x00008000
291
292 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
293 #define IMAGE_SCN_MEM_16BIT 0x00020000
294 #define IMAGE_SCN_MEM_LOCKED 0x00040000
295 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
296
297 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
298 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
299 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
300 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
301 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default alignment if no others are specified. */
302 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
303 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
304
305
306 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 /* Section contains extended relocations. */
307 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 /* Section is not cachable. */
308 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 /* Section is not pageable. */
309 #define IMAGE_SCN_MEM_SHARED 0x10000000 /* Section is shareable. */
310 #endif
311
312 /* COMDAT selection codes. */
313
314 #ifndef _WIN32
315 #define IMAGE_COMDAT_SELECT_NODUPLICATES (1) /* Warn if duplicates. */
316 #define IMAGE_COMDAT_SELECT_ANY (2) /* No warning. */
317 #define IMAGE_COMDAT_SELECT_SAME_SIZE (3) /* Warn if different size. */
318 #define IMAGE_COMDAT_SELECT_EXACT_MATCH (4) /* Warn if different. */
319 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE (5) /* Base on other section. */
320 #endif
321
322 /* Magic values that are true for all dos/nt implementations */
323 #define DOSMAGIC 0x5a4d
324 #define NT_SIGNATURE 0x00004550
325
326 /* NT allows long filenames, we want to accommodate this. This may break
327 some of the bfd functions */
328 #undef FILNMLEN
329 #define FILNMLEN 18 /* # characters in a file name */
330
331
332 #ifdef COFF_IMAGE_WITH_PE
333 /* The filehdr is only weired in images */
334
335 #undef FILHDR
336 struct external_PE_filehdr
337 {
338 /* DOS header fields */
339 uint16_t e_magic; /* Magic number, 0x5a4d */
340 uint16_t e_cblp; /* Bytes on last page of file, 0x90 */
341 uint16_t e_cp; /* Pages in file, 0x3 */
342 uint16_t e_crlc; /* Relocations, 0x0 */
343 uint16_t e_cparhdr; /* Size of header in paragraphs, 0x4 */
344 uint16_t e_minalloc; /* Minimum extra paragraphs needed, 0x0 */
345 uint16_t e_maxalloc; /* Maximum extra paragraphs needed, 0xFFFF */
346 uint16_t e_ss; /* Initial (relative) SS value, 0x0 */
347 uint16_t e_sp; /* Initial SP value, 0xb8 */
348 uint16_t e_csum; /* Checksum, 0x0 */
349 uint16_t e_ip; /* Initial IP value, 0x0 */
350 uint16_t e_cs; /* Initial (relative) CS value, 0x0 */
351 uint16_t e_lfarlc; /* File address of relocation table, 0x40 */
352 uint16_t e_ovno; /* Overlay number, 0x0 */
353 char e_res[4][2]; /* Reserved words, all 0x0 */
354 uint16_t e_oemid; /* OEM identifier (for e_oeminfo), 0x0 */
355 uint16_t e_oeminfo; /* OEM information; e_oemid specific, 0x0 */
356 char e_res2[10][2]; /* Reserved words, all 0x0 */
357 uint32_t e_lfanew; /* File address of new exe header, 0x80 */
358 char dos_message[16][4]; /* other stuff, always follow DOS header */
359 unsigned int nt_signature; /* required NT signature, 0x4550 */
360
361 /* From standard header */
362
363 uint16_t f_magic; /* magic number */
364 uint16_t f_nscns; /* number of sections */
365 uint32_t f_timdat; /* time & date stamp */
366 uint32_t f_symptr; /* file pointer to symtab */
367 uint32_t f_nsyms; /* number of symtab entries */
368 uint16_t f_opthdr; /* sizeof(optional hdr) */
369 uint16_t f_flags; /* flags */
370 };
371
372
373 #define FILHDR struct external_PE_filehdr
374 #undef FILHSZ
375 #define FILHSZ 152
376
377 #endif
378
379 typedef struct
380 {
381 uint16_t magic; /* type of file */
382 uint16_t vstamp; /* version stamp */
383 uint32_t tsize; /* text size in bytes, padded to FW bdry*/
384 uint32_t dsize; /* initialized data " " */
385 uint32_t bsize; /* uninitialized data " " */
386 uint32_t entry; /* entry pt. */
387 uint32_t text_start; /* base of text used for this file */
388 uint32_t data_start; /* base of all data used for this file */
389
390 /* NT extra fields; see internal.h for descriptions */
391 uint32_t ImageBase;
392 uint32_t SectionAlignment;
393 uint32_t FileAlignment;
394 uint16_t MajorOperatingSystemVersion;
395 uint16_t MinorOperatingSystemVersion;
396 uint16_t MajorImageVersion;
397 uint16_t MinorImageVersion;
398 uint16_t MajorSubsystemVersion;
399 uint16_t MinorSubsystemVersion;
400 char Reserved1[4];
401 uint32_t SizeOfImage;
402 uint32_t SizeOfHeaders;
403 uint32_t CheckSum;
404 uint16_t Subsystem;
405 uint16_t DllCharacteristics;
406 uint32_t SizeOfStackReserve;
407 uint32_t SizeOfStackCommit;
408 uint32_t SizeOfHeapReserve;
409 uint32_t SizeOfHeapCommit;
410 uint32_t LoaderFlags;
411 uint32_t NumberOfRvaAndSizes;
412 /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
413 char DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
414
415 } PEAOUTHDR;
416
417
418 #undef AOUTSZ
419 #define AOUTSZ (AOUTHDRSZ + 196)
420
421 #undef E_FILNMLEN
422 #define E_FILNMLEN 18 /* # characters in a file name */
423 #endif
424
425 /* end of coff/pe.h */
426
427 #define DT_NON (0) /* no derived type */
428 #define DT_PTR (1) /* pointer */
429 #define DT_FCN (2) /* function */
430 #define DT_ARY (3) /* array */
431
432 #ifndef _WIN32
433 #define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
434 #define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
435 #define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
436 #endif
437
438 #ifdef __cplusplus
439 }
440 #endif
441
442 #endif /* _A_OUT_H_ */
443