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