Fixed the shapes of external things some more.
[deliverable/binutils-gdb.git] / include / coff-m68k.h
1 /*** coff information for M68K */
2
3
4 /********************** FILE HEADER **********************/
5
6 struct external_filehdr {
7 char f_magic[2]; /* magic number */
8 char f_nscns[2]; /* number of sections */
9 char f_timdat[4]; /* time & date stamp */
10 char f_symptr[4]; /* file pointer to symtab */
11 char f_nsyms[4]; /* number of symtab entries */
12 char f_opthdr[2]; /* sizeof(optional hdr) */
13 char f_flags[2]; /* flags */
14 };
15
16 struct internal_filehdr
17 {
18 unsigned short f_magic; /* magic number */
19 unsigned short f_nscns; /* number of sections */
20 long f_timdat; /* time & date stamp */
21 long f_symptr; /* file pointer to symtab */
22 long f_nsyms; /* number of symtab entries */
23 unsigned short f_opthdr; /* sizeof(optional hdr) */
24 unsigned short f_flags; /* flags */
25 };
26
27 /* Bits for f_flags:
28 * F_RELFLG relocation info stripped from file
29 * F_EXEC file is executable (no unresolved external references)
30 * F_LNNO line numbers stripped from file
31 * F_LSYMS local symbols stripped from file
32 * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
33 */
34
35 #define F_RELFLG (0x0001)
36 #define F_EXEC (0x0002)
37 #define F_LNNO (0x0004)
38 #define F_LSYMS (0x0008)
39 #define F_AR32WR (0x0010)
40
41 /* Motorola 68000/68008/68010/68020 */
42 #define MC68MAGIC 0520
43 #define MC68KWRMAGIC 0520 /* writeable text segments */
44 #define MC68TVMAGIC 0521
45 #define MC68KROMAGIC 0521 /* readonly shareable text segments */
46 #define MC68KPGMAGIC 0522 /* demand paged text segments */
47 #define M68MAGIC 0210
48 #define M68TVMAGIC 0211
49
50 #define M68KBADMAG(x) (((x).f_magic!=MC68MAGIC) && ((x).f_magic!=MC68KWRMAGIC) && ((x).f_magic!=MC68TVMAGIC) && \
51 ((x).f_magic!=MC68KROMAGIC) && ((x).f_magic!=MC68KPGMAGIC) && ((x).f_magic!=M68MAGIC) && ((x).f_magic!=M68TVMAGIC) )
52
53
54
55 #define FILHDR struct external_filehdr
56 #define FILHSZ sizeof(FILHDR)
57
58
59 /********************** AOUT "OPTIONAL HEADER" **********************/
60 struct internal_aouthdr {
61 short magic; /* type of file */
62 short vstamp; /* version stamp */
63 unsigned long tsize; /* text size in bytes, padded to FW bdry*/
64 unsigned long dsize; /* initialized data " " */
65 unsigned long bsize; /* uninitialized data " " */
66 #if U3B
67 unsigned long dum1;
68 unsigned long dum2; /* pad to entry point */
69 #endif
70 unsigned long entry; /* entry pt. */
71 unsigned long text_start; /* base of text used for this file */
72 unsigned long data_start; /* base of data used for this file */
73 unsigned long tagentries; /* number of tag entries to follow */
74 } ;
75
76
77 typedef struct
78 {
79 char magic[2]; /* type of file */
80 char vstamp[2]; /* version stamp */
81 char tsize[4]; /* text size in bytes, padded to FW bdry*/
82 char dsize[4]; /* initialized data " " */
83 char bsize[4]; /* uninitialized data " " */
84 char entry[4]; /* entry pt. */
85 char text_start[4]; /* base of text used for this file */
86 char data_start[4]; /* base of data used for this file */
87 char tagentries[4]; /* number of tag entries to follow */
88 }
89 AOUTHDR;
90
91 #define AOUTSZ (sizeof(AOUTHDR))
92
93
94 /********************** STORAGE CLASSES **********************/
95
96 #define C_EFCN -1 /* physical end of function */
97 #define C_NULL 0
98 #define C_AUTO 1 /* automatic variable */
99 #define C_EXT 2 /* external symbol */
100 #define C_STAT 3 /* static */
101 #define C_REG 4 /* register variable */
102 #define C_EXTDEF 5 /* external definition */
103 #define C_LABEL 6 /* label */
104 #define C_ULABEL 7 /* undefined label */
105 #define C_MOS 8 /* member of structure */
106 #define C_ARG 9 /* function argument */
107 #define C_STRTAG 10 /* structure tag */
108 #define C_MOU 11 /* member of union */
109 #define C_UNTAG 12 /* union tag */
110 #define C_TPDEF 13 /* type definition */
111 #define C_USTATIC 14 /* undefined static */
112 #define C_ENTAG 15 /* enumeration tag */
113 #define C_MOE 16 /* member of enumeration */
114 #define C_REGPARM 17 /* register parameter */
115 #define C_FIELD 18 /* bit field */
116 #define C_AUTOARG 19 /* auto argument */
117 #define C_LASTENT 20 /* dummy entry (end of block) */
118 #define C_BLOCK 100 /* ".bb" or ".eb" */
119 #define C_FCN 101 /* ".bf" or ".ef" */
120 #define C_EOS 102 /* end of structure */
121 #define C_FILE 103 /* file name */
122 #define C_LINE 104 /* line # reformatted as symbol table entry */
123 #define C_ALIAS 105 /* duplicate tag */
124 #define C_HIDDEN 106 /* ext symbol in dmert public lib */
125
126 /********************** SECTION HEADER **********************/
127
128 struct internal_scnhdr {
129 char s_name[8]; /* section name */
130 long s_paddr; /* physical address, aliased s_nlib */
131 long s_vaddr; /* virtual address */
132 long s_size; /* section size */
133 long s_scnptr; /* file ptr to raw data for section */
134 long s_relptr; /* file ptr to relocation */
135 long s_lnnoptr; /* file ptr to line numbers */
136 unsigned short s_nreloc; /* number of relocation entries */
137 unsigned short s_nlnno; /* number of line number entries*/
138 long s_flags; /* flags */
139 };
140
141 struct external_scnhdr {
142 char s_name[8]; /* section name */
143 char s_paddr[4]; /* physical address, aliased s_nlib */
144 char s_vaddr[4]; /* virtual address */
145 char s_size[4]; /* section size */
146 char s_scnptr[4]; /* file ptr to raw data for section */
147 char s_relptr[4]; /* file ptr to relocation */
148 char s_lnnoptr[4]; /* file ptr to line numbers */
149 char s_nreloc[2]; /* number of relocation entries */
150 char s_nlnno[2]; /* number of line number entries*/
151 char s_flags[4]; /* flags */
152 };
153
154 /*
155 * names of "special" sections
156 */
157 #define _TEXT ".text"
158 #define _DATA ".data"
159 #define _BSS ".bss"
160
161 /*
162 * s_flags "type"
163 */
164 #define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */
165 #define STYP_DSECT (0x0001) /* "dummy": relocated only*/
166 #define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */
167 #define STYP_GROUP (0x0004) /* "grouped": formed of input sections */
168 #define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */
169 #define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated,
170 loaded; reloc & lineno entries processed normally */
171 #define STYP_TEXT (0x0020) /* section contains text only */
172 #define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
173 will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
174 update all process invocations. */
175 #define STYP_DATA (0x0040) /* section contains data only */
176 #define STYP_BSS (0x0080) /* section contains bss only */
177 #define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
178 #define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */
179 #define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */
180 #define STYP_LIB (0x0800) /* for .lib: same as INFO */
181 #define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */
182 #define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a
183 word of contiguous bytes beginning on a word boundary. */
184
185 #define SCNHDR struct external_scnhdr
186 #define SCNHSZ sizeof(SCNHDR)
187
188
189 /********************** LINE NUMBERS **********************/
190
191 /* 1 line number entry for every "breakpointable" source line in a section.
192 * Line numbers are grouped on a per function basis; first entry in a function
193 * grouping will have l_lnno = 0 and in place of physical address will be the
194 * symbol table index of the function name.
195 */
196 struct external_lineno {
197 union {
198 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
199 char l_paddr[4]; /* (physical) address of line number */
200 } l_addr;
201 char l_lnno[2]; /* line number */
202 };
203
204 struct internal_lineno {
205 union {
206 long l_symndx; /* function name symbol index, iff l_lnno == 0*/
207 long l_paddr; /* (physical) address of line number */
208 } l_addr;
209 unsigned short l_lnno; /* line number */
210 };
211
212 #define LINENO struct external_lineno
213 #define LINESZ sizeof(LINENO)
214
215
216 /********************** SYMBOLS **********************/
217
218 #define SYMNMLEN 8 /* # characters in a symbol name */
219 #define FILNMLEN 14 /* # characters in a file name */
220 #define DIMNUM 4 /* # array dimensions in auxiliary entry */
221
222 struct external_syment
223 {
224 union {
225 char e_name[SYMNMLEN];
226 struct {
227 char e_zeroes[4];
228 char e_offset[4];
229 } e;
230 } e;
231 char e_value[4];
232 char e_scnum[2];
233 char e_type[2];
234 char e_sclass[1];
235 char e_numaux[1];
236 };
237
238 struct internal_syment {
239 union {
240 char _n_name[SYMNMLEN]; /* old COFF version */
241 struct {
242 long _n_zeroes; /* new == 0 */
243 long _n_offset; /* offset into string table */
244 } _n_n;
245 char *_n_nptr[2]; /* allows for overlaying */
246 } _n;
247 long n_value; /* value of symbol */
248 short n_scnum; /* section number */
249 unsigned short n_flags; /* copy of flags from filhdr */
250 unsigned short n_type; /* type and derived type */
251 char n_sclass; /* storage class */
252 char n_numaux; /* number of aux. entries */
253 };
254
255 /*#define n_name _n._n_name
256 #define n_ptr _n._n_nptr[1]
257 #define n_zeroes _n._n_n._n_zeroes
258 #define n_offset _n._n_n._n_offset
259 */
260
261 /*
262 * Relocatable symbols have number of the section in which they are defined,
263 * or one of the following:
264 */
265 #define N_UNDEF ((short)0) /* undefined symbol */
266 #define N_ABS ((short)-1) /* value of symbol is absolute */
267 #define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
268 #define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
269 #define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/
270
271 /*
272 * Type of a symbol, in low 4 bits of the word
273 */
274 #define T_NULL 0
275 #define T_VOID 1 /* function argument (only used by compiler) */
276 #define T_CHAR 2 /* character */
277 #define T_SHORT 3 /* short integer */
278 #define T_INT 4 /* integer */
279 #define T_LONG 5 /* long integer */
280 #define T_FLOAT 6 /* floating point */
281 #define T_DOUBLE 7 /* double word */
282 #define T_STRUCT 8 /* structure */
283 #define T_UNION 9 /* union */
284 #define T_ENUM 10 /* enumeration */
285 #define T_MOE 11 /* member of enumeration*/
286 #define T_UCHAR 12 /* unsigned character */
287 #define T_USHORT 13 /* unsigned short */
288 #define T_UINT 14 /* unsigned integer */
289 #define T_ULONG 15 /* unsigned long */
290 #define T_LNGDBL 16 /* long double */
291
292 /*
293 * derived types, in n_type
294 */
295 #define DT_NON (0) /* no derived type */
296 #define DT_PTR (1) /* pointer */
297 #define DT_FCN (2) /* function */
298 #define DT_ARY (3) /* array */
299
300 #define N_BTMASK (0x1f)
301 #define N_TMASK (0x60)
302 #define N_BTSHFT (5)
303 #define N_TSHIFT (2)
304
305 #define BTYPE(x) ((x) & N_BTMASK)
306
307 #define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
308 #define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
309 #define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
310
311 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
312
313 union external_auxent {
314 struct {
315 char x_tagndx[4]; /* str, un, or enum tag indx */
316 union {
317 struct {
318 char x_lnno[2]; /* declaration line number */
319 char x_size[2]; /* str/union/array size */
320 } x_lnsz;
321 char x_fsize[4]; /* size of function */
322 } x_misc;
323 union {
324 struct { /* if ISFCN, tag, or .bb */
325 char x_lnnoptr[4]; /* ptr to fcn line # */
326 char x_endndx[4]; /* entry ndx past block end */
327 } x_fcn;
328 struct { /* if ISARY, up to 4 dimen. */
329 char x_dimen[DIMNUM][2];
330 } x_ary;
331 } x_fcnary;
332 char x_tvndx[2]; /* tv index */
333 } x_sym;
334
335 union {
336 char x_fname[FILNMLEN];
337 struct {
338 char x_zeroes[4];
339 char x_offset[4];
340 } x_n;
341 } x_file;
342
343 struct {
344 char x_scnlen[4]; /* section length */
345 char x_nreloc[2]; /* # relocation entries */
346 char x_nlinno[2]; /* # line numbers */
347 } x_scn;
348
349 struct {
350 char x_tvfill[4]; /* tv fill value */
351 char x_tvlen[2]; /* length of .tv */
352 char x_tvran[2][2]; /* tv range */
353 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
354
355
356 };
357 union internal_auxent {
358 struct {
359 long x_tagndx; /* str, un, or enum tag indx */
360 union {
361 struct {
362 unsigned short x_lnno; /* declaration line number */
363 unsigned short x_size; /* str/union/array size */
364 } x_lnsz;
365 long x_fsize; /* size of function */
366 } x_misc;
367 union {
368 struct { /* if ISFCN, tag, or .bb */
369 long x_lnnoptr; /* ptr to fcn line # */
370 long x_endndx; /* entry ndx past block end */
371 } x_fcn;
372 struct { /* if ISARY, up to 4 dimen. */
373 unsigned short x_dimen[DIMNUM];
374 } x_ary;
375 } x_fcnary;
376 unsigned short x_tvndx; /* tv index */
377 } x_sym;
378
379 union {
380 char x_fname[FILNMLEN];
381 struct {
382 long x_zeroes;
383 long x_offset;
384 } x_n;
385 } x_file;
386
387 struct {
388 long x_scnlen; /* section length */
389 unsigned short x_nreloc; /* # relocation entries */
390 unsigned short x_nlinno; /* # line numbers */
391 } x_scn;
392
393 struct {
394 long x_tvfill; /* tv fill value */
395 unsigned short x_tvlen; /* length of .tv */
396 unsigned short x_tvran[2]; /* tv range */
397 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
398
399 /******************************************
400 * I960-specific *2nd* aux. entry formats
401 ******************************************/
402 struct {
403 /* This is a very old typo that keeps getting propagated. */
404 #define x_stdindx x_stindx
405 long x_stindx; /* sys. table entry */
406 } x_sc; /* system call entry */
407
408 struct {
409 unsigned long x_balntry; /* BAL entry point */
410 } x_bal; /* BAL-callable function */
411
412 struct {
413 unsigned long x_timestamp; /* time stamp */
414 char x_idstring[20]; /* producer identity string */
415 } x_ident; /* Producer ident info */
416
417
418 };
419
420 #define SYMENT struct external_syment
421 #define SYMESZ 18
422 #define AUXENT union external_auxent
423 #define AUXESZ 18
424
425
426 # define _ETEXT "etext"
427
428
429 /********************** RELOCATION DIRECTIVES **********************/
430
431 struct internal_reloc {
432 long r_vaddr; /* Virtual address of reference */
433 long r_symndx; /* Index into symbol table */
434 unsigned short r_type; /* Relocation type */
435 };
436
437
438 struct external_reloc {
439 char r_vaddr[4];
440 char r_symndx[4];
441 char r_type[2];
442 };
443
444 #define R_RELBYTE 017
445 #define R_RELWORD 020
446 #define R_RELLONG 021
447 #define R_PCRBYTE 022
448 #define R_PCRWORD 023
449 #define R_PCRLONG 024
450
451 #define RELOC struct external_reloc
452 #define RELSZ 10
453
454 #define DEFAULT_DATA_SECTION_ALIGNMENT 4
455 #define DEFAULT_BSS_SECTION_ALIGNMENT 4
456 #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
457 /* For new sections we havn't heard of before */
458 #define DEFAULT_SECTION_ALIGNMENT 4
This page took 0.05484 seconds and 5 git commands to generate.