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