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