OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [utils/] [amd-udi/] [include/] [coff.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* @(#)coff.h   1.8 91/12/16 16:48:10, AMD */
2
/*
3
******************************************************************
4
**                      29K COFF Declarations                   **
5
**                                                              **
6
**                                                              **
7
** This file contains the declarations required to define       **
8
** the COFF format as proposed for use by AMD for the 29K       **
9
** family of RISC microprocessors.                              **
10
**                                                              **
11
** No attempt is made here to describe in detail those portions **
12
** of COFF which have not been modified or extended.  Pertinent **
13
** #define's and struct's are included for completeness.  Those **
14
** declarations are distributed in several System V headers.    **
15
**                                                              **
16
** For a better and more complete description of COFF with      **
17
** general and 29K Family specific clarifications, see the      **
18
** AMD's "Programmer's Guide to the Common Object File Format   **
19
** (COFF) for the Am29000" Application Note, order number 11963.**
20
**                                                              **
21
** For non-29K-Family specific COFF information, consult AT&T   **
22
** UNIX System V Release 3, Programmer's Guide, Chapter 11      **
23
** (Manual 307-225, Issue 1).                                   **
24
**                                                              **
25
**                                                              **
26
** Revision history:                                            **
27
**                                                              **
28
** 0.01 JG - first published                                    **
29
** 0.02 JG - added relocation type R_IFAR and renumbered        **
30
** 0.03 RC - COFF spec now compiles without error               **
31
** 0.04 RC - removed R_IPAIR and R_IFAR and renumbered          **
32
** 0.05 RC - added R_HWORD relocation type                      **
33
** 0.06 RC - section types                                      **
34
**              changed value of STYP_BSSREG                    **
35
**              replaced STYP_RDATA and STYP_IDATA              **
36
**               with STYP_LIT, STYP_ABS, and STYP_ENVIR        **
37
**         - relocation types                                   **
38
**              added R_IABS                                    **
39
**              replaced R_IBYTE with R_BYTE and renumbered     **
40
**         - changed comments and removed comments              **
41
** 0.07 RC - relocation types                                   **
42
**              Added R_IHCONST to support relocation offsets   **
43
**               for CONSTH instruction.  Added commentary,     **
44
**               and renumbered to make room for R_IHCONST,     **
45
**               putting the (as yet unused) global reloc       **
46
**               types at the end.                              **
47
**         - bug fix (typo)                                     **
48
**              Added slash to terminate comment field on       **
49
**               C_EXT so now C_STAT is defined.                **
50
** 0.08 RC - official magic numbers assigned by AT&T.           **
51
** 0.09 RC - support multiple address spaces by adding magic    **
52
**              a.out header numbers SASMAGIC and MASMAGIC.     **
53
** 0.10 RC - No changes.   Just added the comments below and    **
54
**              corrected comments on tsize, dsize, and bsize.  **
55
**         - All portions of the COFF file described as C       **
56
**              structs must use Host Endian byte ordering.     **
57
**              Files created on a machine with a byte          **
58
**              ordering different from the host may be         **
59
**              converted using the UNIX conv(1) command.       **
60
**         - Assemblers and compilers must create section       **
61
**              headers for .text, .data, and .bss (in that     **
62
**              order) even if they are 0 length.               **
63
**         - tsize, dsize, and bsize are the size of .text,     **
64
**              .data, and .bss respectively.   Other sections  **
65
**              of type STYP_TEXT, STYP_DATA, and STYP_BSS      **
66
**              are not included in the byte count.             **
67
**         - Assemblers and compilers must create output        **
68
**              sections to the exact byte length (and not      **
69
**              round them up).   The linker will take care     **
70
**              of rounding.                                    **
71
** 2.1.01  - Added C_STARTOF storage class for support of       **
72
**              assembler $startof(sect_name) and               **
73
**              $sizeof(sect_name) operators.                   **
74
** 2.1.02  - Added a few more defines for completeness.         **
75
** 2.1.03  - Added more magic numbers for completeness.         **
76
******************************************************************
77
*/
78
 
79
/*
80
** Overall structure of a COFF file
81
*/
82
 
83
/*
84
                *--------------------------------*
85
                |       File Header              |
86
                ----------------------------------
87
                |       Optional Information     |
88
                ----------------------------------
89
                |       Section 1 Header         |
90
                ----------------------------------
91
                |               ...              |
92
                ----------------------------------
93
                |       Section n Header         |
94
                ----------------------------------
95
                |       Raw Data for Section 1   |
96
                ----------------------------------
97
                |               ...              |
98
                ----------------------------------
99
                |       Raw Data for Section n   |
100
                ----------------------------------
101
                | Relocation Info for Section 1  |
102
                ----------------------------------
103
                |               ...              |
104
                ----------------------------------
105
                | Relocation Info for Section n  |
106
                ----------------------------------
107
                |  Line Numbers for Section 1    |
108
                ----------------------------------
109
                |               ...              |
110
                ----------------------------------
111
                |  Line Numbers for Section n    |
112
                ----------------------------------
113
                |         Symbol Table           |
114
                ----------------------------------
115
                |         String Table           |
116
                *--------------------------------*
117
*/
118
 
119
/****************************************************************/
120
 
121
 
122
/*
123
** File Header and related definitions
124
*/
125
 
126
struct filehdr
127
{
128
        unsigned short  f_magic;        /* magic number */
129
        unsigned short  f_nscns;        /* number of sections */
130
        long            f_timdat;       /* time & date stamp */
131
        long            f_symptr;       /* file pointer to symtab */
132
        long            f_nsyms;        /* number of symtab entries */
133
        unsigned short  f_opthdr;       /* sizeof(optional hdr) */
134
        unsigned short  f_flags;        /* flags */
135
};
136
 
137
#define FILHDR  struct filehdr
138
#define FILHSZ  sizeof (FILHDR)
139
 
140
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
141
 
142
/*
143
** Magic numbers currently known to us,
144
** Plus 29K magic numbers assigned by AT&T.
145
*/
146
 
147
#define M68MAGIC        0210
148
#define M68TVMAGIC      0211
149
#define B16MAGIC        0502
150
#define BTVMAGIC        0503
151
#define IAPX16          0504
152
#define IAPX16TV        0505
153
#define IAPX20          0506
154
#define IAPX20TV        0507
155
#define X86MAGIC        0510
156
#define XTVMAGIC        0511
157
#define I286SMAGIC      0512
158
#define I386MAGIC       0514
159
#define MC68MAGIC       0520
160
#define MC68KWRMAGIC    0520    /* 68K writeable text sections */
161
#define MC68TVMAGIC     0521
162
#define MC68KPGMAGIC    0522    /* 68K demand paged text (shared with i286) */
163
#define I286LMAGIC      0522    /* i286 (shared with 68K) */
164
/*                      0524     * reserved for NSC */
165
/*                      0525     * reserved for NSC */
166
/*                      0544     * reserved for Zilog */
167
/*                      0545     * reserved for Zilog */
168
#define N3BMAGIC        0550    /* 3B20S executable, no TV */    
169
#define NTVMAGIC        0551    /* 3B20 executable with TV */
170
#define FBOMAGIC        0560    /* WE*-32 (Forward Byte Ordering) */
171
#define WE32MAGIC       0560    /* WE 32000, no TV */
172
#define MTVMAGIC        0561    /* WE 32000 with TV */
173
#define RBOMAGIC        0562    /* WE-32 (Reverse Byte Ordering) */
174
#define VAXWRMAGIC      0570    /* VAX-11/750 and VAX-11/780 */
175
                                /* (writable text sections) */
176
#define VAXROMAGIC      0575    /* VAX-11/750 and VAX-11780 */
177
                                /* (read-only text sections) */
178
#define U370WRMAGIC     0530    /* IBM 370 (writable text sections) */
179
#define AMDWRMAGIC      0531    /* Amdahl 470/580 writable text sections */
180
#define AMDROMAGIC      0534    /* Amdahl 470/580 read only sharable text */
181
#define U370ROMAGIC     0535    /* IBM 370 (read-only sharable text sections) */
182
 
183
#define SIPFBOMAGIC     0572    /* 29K Family (Byte 0 is MSB - Big Endian) */
184
#define SIPRBOMAGIC     0573    /* 29K Family (Byte 0 is LSB - Little Endian) */
185
 
186
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
187
 
188
/*
189
** File header flags currently known to us.
190
**
191
** Am29000 will use the F_AR32WR and F_AR32W flags to indicate
192
** the byte ordering in the file.
193
*/
194
 
195
#define F_RELFLG        00001   /* Relocation information stripped */
196
                                /* from the file. */
197
#define F_EXEC          00002   /* File is executable (i.e. no */
198
                                /* unresolved external references). */
199
#define F_LNNO          00004   /* Line numbers stripped from */
200
                                /* the file. */
201
#define F_LSYMS         00010   /* Local symbols stripped from */
202
                                /* the file. */
203
#define F_MINMAL        00020   /* Not used by UNIX. */
204
#define F_UPDATE        00040   /* Not used by UNIX. */
205
#define F_SWABD         00100   /* Not used by UNIX. */
206
#define F_AR16WR        00200   /* File has the byte ordering used */
207
                                /* by the PDP*-11/70 processor. */
208
#define F_AR32WR        00400   /* File has 32 bits per word, */
209
                                /* least significant byte first. */
210
#define F_AR32W         01000   /* File has 32 bits per word, */
211
                                /* most significant byte first. */
212
#define F_PATCH         02000   /* Not used by UNIX. */
213
#define F_BM32BRST    0010000   /* 32100 required; has RESTORE work-around. */
214
#define F_BM32B       0020000   /* 32100 required. */
215
#define F_BM32MAU     0040000   /* MAU required. */
216
#define F_BM32ID      0160000   /* WE 32000 processor ID field. */
217
 
218
/*--------------------------------------------------------------*/
219
 
220
/*
221
** Optional (a.out) header
222
*/
223
 
224
typedef struct aouthdr
225
{
226
        short   magic;          /* magic number */
227
        short   vstamp;         /* version stamp */
228
        long    tsize;          /* size of .text in bytes */
229
        long    dsize;          /* size of .data (initialized data) */
230
        long    bsize;          /* size of .bss (uninitialized data) */
231
        long    entry;          /* entry point */
232
        long    text_start;     /* base of text used for this file */
233
        long    data_start;     /* base of data used for this file */
234
} AOUTHDR;
235
 
236
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
237
 
238
/*
239
** Magic a.out header numbers for cross development (non-UNIX),
240
** support of separate I and D address spaces.
241
*/
242
 
243
#define SASMAGIC        010000  /* Single Address Space */    
244
#define MASMAGIC        020000  /* Multiple (separate I & D) Address Spaces */
245
 
246
/*--------------------------------------------------------------*/
247
 
248
/*
249
** Section header and related definitions
250
*/
251
 
252
struct scnhdr
253
{
254
        char            s_name[8];      /* section name */
255
        long            s_paddr;        /* physical address */
256
        long            s_vaddr;        /* virtual address */
257
        long            s_size;         /* section size */
258
        long            s_scnptr;       /* file ptr to raw data for section */
259
        long            s_relptr;       /* file ptr to relocation */
260
        long            s_lnnoptr;      /* file ptr to line numbers */
261
        unsigned short  s_nreloc;       /* number of relocation entries */
262
        unsigned short  s_nlnno;        /* number of line number entries */
263
        long            s_flags;        /* flags */
264
};
265
 
266
#define SCNHDR  struct  scnhdr
267
#define SCNHSZ  sizeof  (SCNHDR)
268
 
269
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
270
 
271
/*
272
** Section types - with additional section type for global
273
** registers which will be relocatable for the Am29000.
274
**
275
** In instances where it is necessary for a linker to produce an
276
** output file which contains text or data not based at virtual
277
** address 0, e.g. for a ROM, then the linker should accept
278
** address base information as command input and use PAD sections
279
** to skip over unused addresses.
280
*/
281
 
282
#define STYP_REG        0x00    /* Regular section (allocated, */
283
                                /* relocated, loaded) */
284
#define STYP_DSECT      0x01    /* Dummy section (not allocated, */
285
                                /* relocated, not loaded) */
286
#define STYP_NOLOAD     0x02    /* Noload section (allocated, */
287
                                /* relocated, not loaded) */
288
#define STYP_GROUP      0x04    /* Grouped section (formed from */
289
                                /* input sections) */
290
#define STYP_PAD        0x08    /* Padded section (not allocated, */
291
                                /* not relocated, loaded) */
292
#define STYP_COPY       0x10    /* Copy section (for a decision */
293
                                /* function used in updating fields; */
294
                                /* not allocated, not relocated, */
295
                                /* loaded, relocation and line */
296
                                /* number entries processed */
297
                                /* normally) */
298
#define STYP_TEXT       0x20    /* Section contains executable text */
299
#define STYP_DATA       0x40    /* Section contains initialized data */
300
#define STYP_BSS        0x80    /* Section contains only uninitialized data */
301
#define STYP_INFO       0x200   /* Comment section (not allocated, */
302
                                /* not relocated, not loaded) */
303
#define STYP_OVER       0x400   /* Overlay section (relocated, */
304
                                /* not allocated, not loaded) */
305
#define STYP_LIB        0x800   /* For .lib section (like STYP_INFO) */
306
 
307
#define STYP_BSSREG     0x1200  /* Global register area (like STYP_INFO) */
308
#define STYP_ENVIR      0x2200  /* Environment (like STYP_INFO) */
309
#define STYP_ABS        0x4000  /* Absolute (allocated, not reloc, loaded) */
310
#define STYP_LIT        0x8020  /* Literal data (like STYP_TEXT) */
311
 
312
/*
313
NOTE:  The use of STYP_BSSREG for relocation is not yet defined.
314
*/
315
 
316
/*--------------------------------------------------------------*/
317
 
318
/*
319
** Relocation information declaration and related definitions
320
*/
321
 
322
struct reloc
323
{
324
        long            r_vaddr;        /* (virtual) address of reference */
325
        long            r_symndx;       /* index into symbol table */
326
        unsigned short  r_type;         /* relocation type */
327
};
328
 
329
#define RELOC           struct reloc
330
#define RELSZ           10              /* sizeof (RELOC) */ 
331
 
332
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
333
 
334
/*
335
** Relocation types for the Am29000
336
*/
337
 
338
#define R_ABS           0        /* reference is absolute */
339
 
340
#define R_IREL          030     /* instruction relative (jmp/call) */
341
#define R_IABS          031     /* instruction absolute (jmp/call) */
342
#define R_ILOHALF       032     /* instruction low half  (const)  */
343
#define R_IHIHALF       033     /* instruction high half (consth) part 1 */
344
#define R_IHCONST       034     /* instruction high half (consth) part 2 */
345
                                /* constant offset of R_IHIHALF relocation */
346
#define R_BYTE          035     /* relocatable byte value */
347
#define R_HWORD         036     /* relocatable halfword value */
348
#define R_WORD          037     /* relocatable word value */
349
 
350
#define R_IGLBLRC       040     /* instruction global register RC */
351
#define R_IGLBLRA       041     /* instruction global register RA */
352
#define R_IGLBLRB       042     /* instruction global register RB */
353
 
354
/*
355
NOTE:
356
All the "I" forms refer to Am29000 instruction formats.  The linker is
357
expected to know how the numeric information is split and/or aligned
358
within the instruction word(s).  R_BYTE works for instructions, too.
359
 
360
If the parameter to a CONSTH instruction is a relocatable type, two
361
relocation records are written.  The first has an r_type of R_IHIHALF
362
(33 octal) and a normal r_vaddr and r_symndx.  The second relocation
363
record has an r_type of R_IHCONST (34 octal), a normal r_vaddr (which
364
is redundant), and an r_symndx containing the 32-bit constant offset
365
to the relocation instead of the actual symbol table index.  This
366
second record is always written, even if the constant offset is zero.
367
The constant fields of the instruction are set to zero.
368
*/
369
 
370
/*--------------------------------------------------------------*/
371
 
372
/*
373
** Line number entry declaration and related definitions
374
*/
375
 
376
struct lineno
377
{
378
   union
379
   {
380
      long      l_symndx;       /* sym table index of function name */
381
      long      l_paddr;        /* (physical) address of line number */
382
   } l_addr;
383
   unsigned short       l_lnno;         /* line number */
384
};
385
 
386
#define LINENO          struct lineno
387
#define LINESZ          6               /* sizeof (LINENO) */
388
 
389
/*--------------------------------------------------------------*/
390
 
391
/*
392
** Symbol entry declaration and related definitions
393
*/
394
 
395
#define SYMNMLEN        8       /* Number of characters in a symbol name */
396
 
397
struct  syment
398
{
399
   union
400
   {
401
      char      _n_name [SYMNMLEN];     /* symbol name */
402
      struct
403
      {
404
         long   _n_zeroes;              /* symbol name */
405
         long   _n_offset;              /* offset into string table */
406
      } _n_n;
407
      char      *_n_nptr[2];            /* allows for overlaying */
408
   } _n;
409
#ifndef pdp11
410
   unsigned
411
#endif
412
   long                 n_value;                /* value of symbol */
413
   short                n_scnum;                /* section number */
414
   unsigned short       n_type;                 /* type and derived type */
415
   char                 n_sclass;               /* storage class */
416
   char                 n_numaux;               /* number of aux entries */
417
};
418
 
419
#define n_name          _n._n_name
420
#define n_nptr          _n._n_nptr[1]
421
#define n_zeroes        _n._n_n._n_zeroes 
422
#define n_offset        _n._n_n._n_offset
423
 
424
#define SYMENT  struct syment
425
#define SYMESZ  18
426
 
427
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
428
 
429
/*
430
** Storage class definitions - new classes for global registers.
431
*/
432
 
433
#define C_EFCN          -1              /* physical end of a function */
434
#define C_NULL          0                /* - */
435
#define C_AUTO          1               /* automatic variable */
436
#define C_EXT           2               /* external symbol */
437
#define C_STAT          3               /* static */
438
#define C_REG           4               /* (local) register variable */
439
#define C_EXTDEF        5               /* external definition */
440
#define C_LABEL         6               /* label */
441
#define C_ULABEL        7               /* undefined label */
442
#define C_MOS           8               /* member of structure */
443
#define C_ARG           9               /* function argument */
444
#define C_STRTAG        10              /* structure tag */
445
#define C_MOU           11              /* member of union */
446
#define C_UNTAG         12              /* union tag */
447
#define C_TPDEF         13              /* type definition */
448
#define C_UNSTATIC      14              /* uninitialized static  */
449
#define C_USTATIC       14              /* uninitialized static  */
450
#define C_ENTAG         15              /* enumeration tag */
451
#define C_MOE           16              /* member of enumeration */
452
#define C_REGPARM       17              /* register parameter */
453
#define C_FIELD         18              /* bit field */
454
 
455
#define C_GLBLREG       19              /* global register */
456
#define C_EXTREG        20              /* external global register */
457
#define C_DEFREG        21              /* ext. def. of global register */
458
#define C_STARTOF       22              /* as29 $SIZEOF and $STARTOF symbols */
459
 
460
 
461
#define C_BLOCK         100             /* beginning and end of block */
462
#define C_FCN           101             /* beginning and end of function */
463
#define C_EOS           102             /* end of structure */
464
#define C_FILE          103             /* file name */
465
#define C_LINE          104             /* used only by utility programs */
466
#define C_ALIAS         105             /* duplicated tag */
467
#define C_HIDDEN        106             /* like static, used to avoid name */
468
                                        /* conflicts */
469
#define C_SHADOW        107             /* shadow symbol */
470
 
471
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
472
 
473
/*
474
** Special section number definitions used in symbol entries.
475
** (Section numbers 1-65535 are used to indicate the section
476
** where the symbol was defined.)
477
*/
478
 
479
#define N_DEBUG         -2              /* special symbolic debugging symbol */
480
#define N_ABS           -1              /* absolute symbol */
481
#define N_UNDEF          0              /* undefined external symbol */
482
#define N_SCNUM    1-65535              /* section num where symbol defined */
483
 
484
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
485
 
486
/*
487
** Fundamental symbol types.
488
*/
489
 
490
#define T_NULL          0                /* type not assigned */
491
#define T_VOID          1               /* void */
492
#define T_CHAR          2               /* character */
493
#define T_SHORT         3               /* short integer */
494
#define T_INT           4               /* integer */
495
#define T_LONG          5               /* long integer */
496
#define T_FLOAT         6               /* floating point */
497
#define T_DOUBLE        7               /* double word */
498
#define T_STRUCT        8               /* structure */
499
#define T_UNION         9               /* union */
500
#define T_ENUM          10              /* enumeration */
501
#define T_MOE           11              /* member of enumeration */
502
#define T_UCHAR         12              /* unsigned character */
503
#define T_USHORT        13              /* unsigned short */
504
#define T_UINT          14              /* unsigned integer */
505
#define T_ULONG         15              /* unsigned long */
506
 
507
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
508
 
509
/*
510
** Derived symbol types.
511
*/
512
 
513
#define DT_NON          0                /* no derived type  */
514
#define DT_PTR          1               /* pointer */
515
#define DT_FCN          2               /* function */
516
#define DT_ARY          3               /* array */
517
 
518
/*--------------------------------------------------------------*/
519
 
520
/*
521
** Auxiliary symbol table entry declaration and related
522
** definitions.
523
*/
524
 
525
#define FILNMLEN        14   /* Number of characters in a file name */
526
#define DIMNUM          4    /* Number of array dimensions in auxiliary entry */
527
 
528
union auxent
529
{
530
   struct
531
   {
532
      long      x_tagndx;               /* str, un, or enum tag indx */
533
      union
534
      {
535
         struct
536
         {
537
            unsigned short      x_lnno;         /* declaration line number */
538
            unsigned short      x_size;         /* str, union, array size */
539
         } x_lnsz;
540
         long   x_size;                         /* size of functions */
541
      } x_misc;
542
      union
543
      {
544
         struct                                 /* if ISFCN, tag, or .bb */
545
         {
546
            long        x_lnnoptr;              /* ptr to fcn line # */
547
            long        x_endndx;               /* entry ndx past block end */
548
         } x_fcn;
549
         struct                                 /* if ISARY, up to 4 dimen */
550
         {
551
            unsigned short      x_dimen[DIMNUM];
552
         } x_ary;
553
      } x_fcnary;
554
      unsigned short    x_tvndx;                /* tv index */
555
   } x_sym;
556
   struct
557
   {
558
      char              x_fname[FILNMLEN];
559
   } x_file;
560
   struct
561
   {
562
      long              x_scnlen;       /* section length */
563
      unsigned short    x_nreloc;       /* number of relocation entries */
564
      unsigned short    x_nlinno;       /* number of line numbers */
565
   } x_scn;
566
   struct
567
   {
568
      long              x_tvfill;                       /* tv fill value */
569
      unsigned short    x_tvlen;                        /* length of tv */
570
      unsigned short    x_tvrna[2];                     /* tv range */
571
   } x_tv;       /* info about  tv section (in auxent of symbol  tv)) */
572
};
573
 
574
#define AUXENT          union auxent
575
#define AUXESZ          18              /* sizeof(AUXENT) */
576
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.