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