Change GDB over to GNU General Public License version 2.
[deliverable/binutils-gdb.git] / include / coff-i960.h
1 /*** coff information for 80960. Origins: Intel corp, natch. */
2
3 /* This include file is also used for rudimentary ECOFF support on MIPS
4 machines. Such differences as are needed are #ifdef MIPS. */
5
6 /* NOTE: Tagentries (cf TAGBITS) are not used by the 960 */
7
8 /********************** FILE HEADER **********************/
9
10 struct external_filehdr {
11 char f_magic[2]; /* magic number */
12 char f_nscns[2]; /* number of sections */
13 char f_timdat[4]; /* time & date stamp */
14 char f_symptr[4]; /* file pointer to symtab */
15 char f_nsyms[4]; /* number of symtab entries */
16 char f_opthdr[2]; /* sizeof(optional hdr) */
17 char f_flags[2]; /* flags */
18 };
19
20 struct internal_filehdr
21 {
22 unsigned short f_magic; /* magic number */
23 unsigned short f_nscns; /* number of sections */
24 long f_timdat; /* time & date stamp */
25 long f_symptr; /* file pointer to symtab */
26 long f_nsyms; /* number of symtab entries */
27 unsigned short f_opthdr; /* sizeof(optional hdr) */
28 unsigned short f_flags; /* flags */
29 };
30
31 /* Bits for f_flags:
32 * F_RELFLG relocation info stripped from file
33 * F_EXEC file is executable (no unresolved external references)
34 * F_LNNO line numbers stripped from file
35 * F_LSYMS local symbols stripped from file
36 * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
37 */
38
39 #define F_RELFLG (0x0001)
40 #define F_EXEC (0x0002)
41 #define F_LNNO (0x0004)
42 #define F_LSYMS (0x0008)
43 #define F_AR32WR (0x0010)
44
45 /*
46 * Intel 80960 (I960) processor flags.
47 * F_I960TYPE == mask for processor type field.
48 */
49
50 #define F_I960TYPE (0xf000)
51 #define F_I960CORE (0x1000)
52 #define F_I960KB (0x2000)
53 #define F_I960SB (0x2000)
54 #define F_I960MC (0x3000)
55 #define F_I960XA (0x4000)
56 #define F_I960CA (0x5000)
57 #define F_I960KA (0x6000)
58 #define F_I960SA (0x6000)
59
60
61 /* Mips magics */
62 #define MIPS_MAGIC_1 0x0180
63 #define MIPS_MAGIC_2 0x0162
64 #define MIPS_MAGIC_3 0x0160
65
66
67
68 #define ECOFFBADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \
69 ((x).f_magic!=MIPS_MAGIC_2) &&\
70 ((x).f_magic!=MIPS_MAGIC_3))
71
72
73 /** i80960 Magic Numbers
74 */
75
76 #define I960ROMAGIC (0x160) /* read-only text segments */
77 #define I960RWMAGIC (0x161) /* read-write text segments */
78
79 #define I960BADMAG(x) (((x).f_magic!=I960ROMAGIC) && ((x).f_magic!=I960RWMAGIC))
80
81 #define FILHDR struct external_filehdr
82 #define FILHSZ 20
83
84 /********************** AOUT "OPTIONAL HEADER" **********************/
85
86 typedef struct {
87 unsigned long phys_addr;
88 unsigned long bitarray;
89 } TAGBITS;
90
91
92 /* These appear to be used only by exec(2). I don't know who cares
93 about them in a cross development environment. In any case, this
94 is my collection after researching the issue for a few hours.
95 Apparently, most have these have remained essentially unchanged
96 since v7 days, although a few new ones have been added. xoxorich.
97 Could we have a little more teleology please? -- Gumby */
98
99 #define BAD0MAGIC (0401) /* (?) "lpd (UNIX/RT)" */
100 #define BAD1MAGIC (0405) /* (?) overlay */
101 #define OMAGIC (0407) /* old impure format. data immediately
102 follows text. both sections are rw. */
103 #define NMAGIC (0410) /* split i&d, read-only text */
104 #define A_MAGIC3 (0411) /* (?) "separated I&D" */
105 #define ZMAGIC (0413) /* like NMAGIC, but demand loaded */
106 #define PAGEMAGIC2 (0414) /* (?) like ZMAGIC, but address zero
107 explicitly unmapped. */ /* */
108 #define REGMAGIC (0414) /* (?) a PAGEMAGIC2 alias? */
109 #define PAGEMAGIC3 (0415) /* (?) like ZMAGIC, but address zero mapped. */
110 #define A_MAGIC5 (0437) /* (?) "system overlay, separated I&D" */
111 #define SASMAGIC (010000) /* (?) "Single Address Space" */
112 #define MASMAGIC (020000) /* (?) "Multiple (separate I/D) Addr. Spaces" */
113
114 struct internal_aouthdr {
115 short magic; /* type of file */
116 short vstamp; /* version stamp */
117 unsigned long tsize; /* text size in bytes, padded to FW bdry*/
118 unsigned long dsize; /* initialized data " " */
119 unsigned long bsize; /* uninitialized data " " */
120 #if U3B
121 unsigned long dum1;
122 unsigned long dum2; /* pad to entry point */
123 #endif
124 unsigned long entry; /* entry pt. */
125 unsigned long text_start; /* base of text used for this file */
126 unsigned long data_start; /* base of data used for this
127 file */
128 #ifndef MIPS
129 unsigned long tagentries; /* number of tag entries to
130 follow */
131 #endif
132
133 } ;
134
135
136 typedef struct
137 {
138 char magic[2]; /* type of file */
139 char vstamp[2]; /* version stamp */
140 char tsize[4]; /* text size in bytes, padded to FW bdry*/
141 char dsize[4]; /* initialized data " " */
142 char bsize[4]; /* uninitialized data " " */
143 char entry[4]; /* entry pt. */
144 char text_start[4]; /* base of text used for this file */
145 char data_start[4]; /* base of data used for this file */
146 #ifndef MIPS
147 char tagentries[4]; /* number of tag entries to follow */
148 #endif
149 }
150 AOUTHDR;
151
152 /* return a pointer to the tag bits array */
153
154 #define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1))
155
156 /* compute size of a header */
157
158 /*#define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))*/
159 #define AOUTSZ (sizeof(AOUTHDR))
160
161
162 /********************** STORAGE CLASSES **********************/
163
164 #define C_EFCN -1 /* physical end of function */
165 #define C_NULL 0
166 #define C_AUTO 1 /* automatic variable */
167 #define C_EXT 2 /* external symbol */
168 #define C_STAT 3 /* static */
169 #define C_REG 4 /* register variable */
170 #define C_EXTDEF 5 /* external definition */
171 #define C_LABEL 6 /* label */
172 #define C_ULABEL 7 /* undefined label */
173 #define C_MOS 8 /* member of structure */
174 #define C_ARG 9 /* function argument */
175 #define C_STRTAG 10 /* structure tag */
176 #define C_MOU 11 /* member of union */
177 #define C_UNTAG 12 /* union tag */
178 #define C_TPDEF 13 /* type definition */
179 #define C_USTATIC 14 /* undefined static */
180 #define C_ENTAG 15 /* enumeration tag */
181 #define C_MOE 16 /* member of enumeration */
182 #define C_REGPARM 17 /* register parameter */
183 #define C_FIELD 18 /* bit field */
184 /* #define C_REGARG 19 */ /* My guess - but Intel specific*/
185 #define C_AUTOARG 19 /* auto argument */
186 #define C_LASTENT 20 /* dummy entry (end of block) */
187 #define C_BLOCK 100 /* ".bb" or ".eb" */
188 #define C_FCN 101 /* ".bf" or ".ef" */
189 #define C_EOS 102 /* end of structure */
190 #define C_FILE 103 /* file name */
191 #define C_LINE 104 /* line # reformatted as symbol table entry */
192 #define C_ALIAS 105 /* duplicate tag */
193 #define C_HIDDEN 106 /* ext symbol in dmert public lib */
194
195 /* New storage classes for 80960 */
196
197 /* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */
198 #define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */
199
200 #define C_SCALL 107 /* Procedure reachable via system call */
201 #define C_LEAFEXT 108 /* External leaf */
202 #define C_LEAFSTAT 113 /* Static leaf */
203 #define C_OPTVAR 109 /* Optimized variable */
204 #define C_DEFINE 110 /* Preprocessor #define */
205 #define C_PRAGMA 111 /* Advice to compiler or linker */
206 #define C_SEGMENT 112 /* 80960 segment name */
207
208 /********************** SECTION HEADER **********************/
209
210 struct internal_scnhdr {
211 char s_name[8]; /* section name */
212 long s_paddr; /* physical address, aliased s_nlib */
213 long s_vaddr; /* virtual address */
214 long s_size; /* section size */
215 long s_scnptr; /* file ptr to raw data for section */
216 long s_relptr; /* file ptr to relocation */
217 long s_lnnoptr; /* file ptr to line numbers */
218 unsigned short s_nreloc; /* number of relocation entries */
219 unsigned short s_nlnno; /* number of line number entries*/
220 long s_flags; /* flags */
221 #ifndef MIPS
222 /* This field exists in Intel COFF, not in Mips ECOFF. */
223 unsigned long s_align; /* section alignment */
224 #endif
225 };
226
227 struct external_scnhdr {
228 char s_name[8]; /* section name */
229 char s_paddr[4]; /* physical address, aliased s_nlib */
230 char s_vaddr[4]; /* virtual address */
231 char s_size[4]; /* section size */
232 char s_scnptr[4]; /* file ptr to raw data for section */
233 char s_relptr[4]; /* file ptr to relocation */
234 char s_lnnoptr[4]; /* file ptr to line numbers */
235 char s_nreloc[2]; /* number of relocation entries */
236 char s_nlnno[2]; /* number of line number entries*/
237 char s_flags[4]; /* flags */
238 #ifndef MIPS
239 /* This field exists in Intel COFF, not in Mips ECOFF. */
240 char s_align[4]; /* section alignment */
241 #endif
242 };
243
244 /*
245 * names of "special" sections
246 */
247 #define _TEXT ".text"
248 #define _DATA ".data"
249 #define _BSS ".bss"
250
251 /*
252 * s_flags "type"
253 */
254 #define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */
255 #define STYP_DSECT (0x0001) /* "dummy": relocated only*/
256 #define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */
257 #define STYP_GROUP (0x0004) /* "grouped": formed of input sections */
258 #define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */
259 #define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated,
260 loaded; reloc & lineno entries processed normally */
261 #define STYP_TEXT (0x0020) /* section contains text only */
262 #define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
263 will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
264 update all process invocations. */
265 #define STYP_DATA (0x0040) /* section contains data only */
266 #define STYP_BSS (0x0080) /* section contains bss only */
267 #define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
268 #define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */
269 #define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */
270 #define STYP_LIB (0x0800) /* for .lib: same as INFO */
271 #define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */
272 #define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a
273 word of contiguous bytes beginning on a word boundary. */
274
275 #define SCNHDR struct external_scnhdr
276 #define SCNHSZ sizeof(SCNHDR)
277
278
279 /********************** LINE NUMBERS **********************/
280
281 /* 1 line number entry for every "breakpointable" source line in a section.
282 * Line numbers are grouped on a per function basis; first entry in a function
283 * grouping will have l_lnno = 0 and in place of physical address will be the
284 * symbol table index of the function name.
285 */
286 struct external_lineno {
287 union {
288 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
289 char l_paddr[4]; /* (physical) address of line number */
290 } l_addr;
291 char l_lnno[2]; /* line number */
292 char padding[2]; /* force alignment */
293 };
294
295 struct internal_lineno {
296 union {
297 long l_symndx; /* function name symbol index, iff l_lnno == 0*/
298 long l_paddr; /* (physical) address of line number */
299 } l_addr;
300 unsigned short l_lnno; /* line number */
301 };
302
303 #define LINENO struct external_lineno
304 #define LINESZ 8
305
306
307 /********************** SYMBOLS **********************/
308
309 #define SYMNMLEN 8 /* # characters in a symbol name */
310 #define FILNMLEN 14 /* # characters in a file name */
311 #define DIMNUM 4 /* # array dimensions in auxiliary entry */
312
313 struct external_syment
314 {
315 union {
316 char e_name[SYMNMLEN];
317 struct {
318 char e_zeroes[4];
319 char e_offset[4];
320 } e;
321 } e;
322 char e_value[4];
323 char e_scnum[2];
324 char e_flags[2];
325 char e_type[4];
326 char e_sclass[1];
327 char e_numaux[1];
328 char pad2[2];
329 };
330
331
332 struct internal_syment {
333 union {
334 char _n_name[SYMNMLEN]; /* old COFF version */
335 struct {
336 long _n_zeroes; /* new == 0 */
337 long _n_offset; /* offset into string table */
338 } _n_n;
339 char *_n_nptr[2]; /* allows for overlaying */
340 } _n;
341 long n_value; /* value of symbol */
342 short n_scnum; /* section number */
343 unsigned short n_flags; /* copy of flags from filhdr */
344 unsigned long n_type; /* type and derived type */
345 char n_sclass; /* storage class */
346 char n_numaux; /* number of aux. entries */
347 };
348
349 /*
350 * Relocatable symbols have number of the section in which they are defined,
351 * or one of the following:
352 */
353 #define N_UNDEF ((short)0) /* undefined symbol */
354 #define N_ABS ((short)-1) /* value of symbol is absolute */
355 #define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
356 #define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
357 #define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/
358
359 /*
360 * Type of a symbol, in low 4 bits of the word
361 */
362 #define T_NULL 0
363 #define T_VOID 1 /* function argument (only used by compiler) */
364 #define T_CHAR 2 /* character */
365 #define T_SHORT 3 /* short integer */
366 #define T_INT 4 /* integer */
367 #define T_LONG 5 /* long integer */
368 #define T_FLOAT 6 /* floating point */
369 #define T_DOUBLE 7 /* double word */
370 #define T_STRUCT 8 /* structure */
371 #define T_UNION 9 /* union */
372 #define T_ENUM 10 /* enumeration */
373 #define T_MOE 11 /* member of enumeration*/
374 #define T_UCHAR 12 /* unsigned character */
375 #define T_USHORT 13 /* unsigned short */
376 #define T_UINT 14 /* unsigned integer */
377 #define T_ULONG 15 /* unsigned long */
378 #define T_LNGDBL 16 /* long double */
379
380 /*
381 * derived types, in n_type
382 */
383 #define DT_NON (0) /* no derived type */
384 #define DT_PTR (1) /* pointer */
385 #define DT_FCN (2) /* function */
386 #define DT_ARY (3) /* array */
387
388 #define N_BTMASK (0x1f)
389 #define N_TMASK (0x60)
390 #define N_BTSHFT (5)
391 #define N_TSHIFT (2)
392
393 #define BTYPE(x) ((x) & N_BTMASK)
394
395 #define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
396 #define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
397 #define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
398
399 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
400 union external_auxent {
401 struct {
402 char x_tagndx[4]; /* str, un, or enum tag indx */
403 union {
404 struct {
405 char x_lnno[2]; /* declaration line number */
406 char x_size[2]; /* str/union/array size */
407 } x_lnsz;
408 char x_fsize[4]; /* size of function */
409 } x_misc;
410 union {
411 struct { /* if ISFCN, tag, or .bb */
412 char x_lnnoptr[4]; /* ptr to fcn line # */
413 char x_endndx[4]; /* entry ndx past block end */
414 } x_fcn;
415 struct { /* if ISARY, up to 4 dimen. */
416 char x_dimen[DIMNUM][2];
417 } x_ary;
418 } x_fcnary;
419 char x_tvndx[2]; /* tv index */
420 } x_sym;
421
422 union {
423 char x_fname[FILNMLEN];
424 struct {
425 char x_zeroes[4];
426 char x_offset[4];
427 } x_n;
428 } x_file;
429
430 struct {
431 char x_scnlen[4]; /* section length */
432 char x_nreloc[2]; /* # relocation entries */
433 char x_nlinno[2]; /* # line numbers */
434 } x_scn;
435
436 struct {
437 char x_tvfill[4]; /* tv fill value */
438 char x_tvlen[2]; /* length of .tv */
439 char x_tvran[2][2]; /* tv range */
440 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
441
442 /******************************************
443 * I960-specific *2nd* aux. entry formats
444 ******************************************/
445 struct {
446 /* This is a very old typo that keeps getting propagated. */
447 #define x_stdindx x_stindx
448 char x_stindx[4]; /* sys. table entry */
449 } x_sc; /* system call entry */
450
451 struct {
452 char x_balntry[4]; /* BAL entry point */
453 } x_bal; /* BAL-callable function */
454
455 struct {
456 char x_timestamp[4]; /* time stamp */
457 char x_idstring[20]; /* producer identity string */
458 } x_ident; /* Producer ident info */
459
460 };
461
462 union internal_auxent {
463 struct {
464 long x_tagndx; /* str, un, or enum tag indx */
465 union {
466 struct {
467 unsigned short x_lnno; /* declaration line number */
468 unsigned short x_size; /* str/union/array size */
469 } x_lnsz;
470 long x_fsize; /* size of function */
471 } x_misc;
472 union {
473 struct { /* if ISFCN, tag, or .bb */
474 long x_lnnoptr; /* ptr to fcn line # */
475 long x_endndx; /* entry ndx past block end */
476 } x_fcn;
477 struct { /* if ISARY, up to 4 dimen. */
478 unsigned short x_dimen[DIMNUM];
479 } x_ary;
480 } x_fcnary;
481 unsigned short x_tvndx; /* tv index */
482 } x_sym;
483
484 union {
485 char x_fname[FILNMLEN];
486 struct {
487 long x_zeroes;
488 long x_offset;
489 } x_n;
490 } x_file;
491
492 struct {
493 long x_scnlen; /* section length */
494 unsigned short x_nreloc; /* # relocation entries */
495 unsigned short x_nlinno; /* # line numbers */
496 } x_scn;
497
498 struct {
499 long x_tvfill; /* tv fill value */
500 unsigned short x_tvlen; /* length of .tv */
501 unsigned short x_tvran[2]; /* tv range */
502 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
503
504 /******************************************
505 * I960-specific *2nd* aux. entry formats
506 ******************************************/
507 struct {
508 /* This is a very old typo that keeps getting propagated. */
509 #define x_stdindx x_stindx
510 long x_stindx; /* sys. table entry */
511 } x_sc; /* system call entry */
512
513 struct {
514 unsigned long x_balntry; /* BAL entry point */
515 } x_bal; /* BAL-callable function */
516
517 struct {
518 unsigned long x_timestamp; /* time stamp */
519 char x_idstring[20]; /* producer identity string */
520 } x_ident; /* Producer ident info */
521
522
523 };
524
525 #define SYMENT struct external_syment
526 #define SYMESZ sizeof(SYMENT) /* FIXME - calc by hand */
527 #define AUXENT union external_auxent
528 #define AUXESZ sizeof(AUXENT) /* FIXME - calc by hand */
529
530 # define _ETEXT "_etext"
531
532 /********************** RELOCATION DIRECTIVES **********************/
533
534 struct external_reloc {
535 char r_vaddr[4];
536 char r_symndx[4];
537 char r_type[2];
538 char pad[2];
539 };
540
541 struct internal_reloc {
542 long r_vaddr; /* Virtual address of reference */
543 long r_symndx; /* Index into symbol table */
544 unsigned short r_type; /* Relocation type */
545 };
546
547 /* Relevent values for r_type and i960. Would someone please document them */
548
549 #define R_RELLONG (0x11) /* Direct 32-bit relocation */
550 #define R_IPRSHORT (0x18)
551 #define R_IPRMED (0x19) /* 24-bit ip-relative relocation */
552 #define R_IPRLONG (0x1a)
553 #define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */
554 #define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */
555 #define R_GETSEG (0x1d)
556 #define R_GETPA (0x1e)
557 #define R_TAGWORD (0x1f)
558
559 #define RELOC struct external_reloc
560 #define RELSZ 12
561
562 #define DEFAULT_DATA_SECTION_ALIGNMENT 4
563 #define DEFAULT_BSS_SECTION_ALIGNMENT 4
564 #define DEFAULT_TEXT_SECTION_ALIGNMENT 16
565 /* For new sections we havn't heard of before */
566 #define DEFAULT_SECTION_ALIGNMENT 4
This page took 0.040692 seconds and 4 git commands to generate.