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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [include/] [coff.h] - Blame information for rev 740

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 51 julius
 
2
/* This file is derived from the GAS 2.1.4 assembler control file.
3
   The GAS product is under the GNU Public License, version 2 or later.
4
   As such, this file is also under that license.
5
 
6
   If the file format changes in the COFF object, this file should be
7
   subsequently updated to reflect the changes.
8
 
9
   The actual loader module only uses a few of these structures. The full
10
   set is documented here because I received the full set. If you wish
11
   more information about COFF, then O'Reilly has a very excellent book.
12
*/
13
 
14 462 julius
#define  E_SYMNMLEN  8          /* Number of characters in a symbol name         */
15
#define  E_FILNMLEN 14          /* Number of characters in a file name           */
16
#define  E_DIMNUM    4          /* Number of array dimensions in auxiliary entry */
17 51 julius
 
18
/*
19
 * These defines are byte order independent. There is no alignment of fields
20
 * permitted in the structures. Therefore they are declared as characters
21
 * and the values loaded from the character positions. It also makes it
22
 * nice to have it "endian" independent.
23
 */
24
#if !defined(WORDS_BIGENDIAN)
25
/* Load a short int from the following tables with little-endian formats */
26
#define COFF_SHORT_L SWAP_ENDIAN_SHORT
27
/* Load a long int from the following tables with little-endian formats */
28
#define COFF_LONG_L SWAP_ENDIAN_LONG
29
/* Load a short int from the following tables with big-endian formats */
30
#define COFF_SHORT_H KEEP_ENDIAN_SHORT
31
/* Load a long int from the following tables with big-endian formats */
32
#define COFF_LONG_H KEEP_ENDIAN_LONG
33
#else
34
#define COFF_SHORT_L KEEP_ENDIAN_SHORT
35
#define COFF_LONG_L KEEP_ENDIAN_LONG
36
#define COFF_SHORT_H SWAP_ENDIAN_SHORT
37
#define COFF_LONG_H SWAP_ENDIAN_LONG
38
#endif
39
 
40
#define SWAP_ENDIAN_SHORT(ps) ((short)(((unsigned short)((unsigned char)ps[1])<<8)|\
41
                                  ((unsigned short)((unsigned char)ps[0]))))
42
 
43
#define SWAP_ENDIAN_LONG(ps) (((long)(((unsigned long)((unsigned char)ps[3])<<24) |\
44
                                 ((unsigned long)((unsigned char)ps[2])<<16) |\
45
                                 ((unsigned long)((unsigned char)ps[1])<<8)  |\
46
                                 ((unsigned long)((unsigned char)ps[0])))))
47 462 julius
 
48 51 julius
#define KEEP_ENDIAN_SHORT(ps) ((short)(((unsigned short)((unsigned char)ps[0])<<8)|\
49
                                  ((unsigned short)((unsigned char)ps[1]))))
50
 
51
#define KEEP_ENDIAN_LONG(ps) (((long)(((unsigned long)((unsigned char)ps[0])<<24) |\
52
                                 ((unsigned long)((unsigned char)ps[1])<<16) |\
53
                                 ((unsigned long)((unsigned char)ps[2])<<8)  |\
54
                                 ((unsigned long)((unsigned char)ps[3])))))
55
 
56
/* These may be overridden later by brain dead implementations which generate
57
   a big-endian header with little-endian data. In that case, generate a
58
   replacement macro which tests a flag and uses either of the two above
59
   as appropriate. */
60
 
61
#define COFF_LONG(v)   COFF_LONG_L(v)
62
#define COFF_SHORT(v)  COFF_SHORT_L(v)
63
 
64
/*** coff information for Intel 386/486.  */
65
 
66
/*
67
 *   Bits for f_flags:
68
 *
69
 *      F_RELFLG        relocation info stripped from file
70
 *      F_EXEC          file is executable  (i.e. no unresolved external
71
 *                      references)
72
 *      F_LNNO          line numbers stripped from file
73
 *      F_LSYMS         local symbols stripped from file
74
 *      F_MINMAL        this is a minimal object file (".m") output of fextract
75
 *      F_UPDATE        this is a fully bound update file, output of ogen
76
 *      F_SWABD         this file has had its bytes swabbed (in names)
77
 *      F_AR16WR        this file has the byte ordering of an AR16WR
78
 *                      (e.g. 11/70) machine
79
 *      F_AR32WR        this file has the byte ordering of an AR32WR machine
80
 *                      (e.g. vax and iNTEL 386)
81
 *      F_AR32W         this file has the byte ordering of an AR32W machine
82
 *                      (e.g. 3b,maxi)
83
 *      F_PATCH         file contains "patch" list in optional header
84
 *      F_NODF          (minimal file only) no decision functions for
85
 *                      replaced functions
86
 */
87
 
88
#define  COFF_F_RELFLG          0000001
89
#define  COFF_F_EXEC            0000002
90
#define  COFF_F_LNNO            0000004
91
#define  COFF_F_LSYMS           0000010
92
#define  COFF_F_MINMAL          0000020
93
#define  COFF_F_UPDATE          0000040
94
#define  COFF_F_SWABD           0000100
95
#define  COFF_F_AR16WR          0000200
96
#define  COFF_F_AR32WR          0000400
97
#define  COFF_F_AR32W           0001000
98
#define  COFF_F_PATCH           0002000
99
#define  COFF_F_NODF            0002000
100
 
101 462 julius
#define COFF_I386MAGIC          0x14c   /* Linux's system    */
102 51 julius
 
103 462 julius
#if 0                           /* Perhaps, someday, these formats may be used.      */
104 51 julius
#define COFF_I386PTXMAGIC       0x154
105 462 julius
#define COFF_I386AIXMAGIC       0x175   /* IBM's AIX system  */
106 51 julius
#define COFF_I386BADMAG(x) ((COFF_SHORT((x).f_magic) != COFF_I386MAGIC) \
107
                          && COFF_SHORT((x).f_magic) != COFF_I386PTXMAGIC \
108
                          && COFF_SHORT((x).f_magic) != COFF_I386AIXMAGIC)
109
#else
110
#define COFF_I386BADMAG(x) (COFF_SHORT((x).f_magic) != COFF_I386MAGIC)
111
#endif
112
 
113
/********************** FILE HEADER **********************/
114
 
115 462 julius
struct coff_filehdr {
116
        char f_magic[2];        // magic number                 
117
        char f_nscns[2];        // number of sections           
118
        char f_timdat[4];       // time & date stamp            
119
        char f_symptr[4];       // file pointer to symtab       
120
        char f_nsyms[4];        // number of symtab entries     
121
        char f_opthdr[2];       // sizeof(optional hdr)         
122
        char f_flags[2];        // flags                        
123 51 julius
};
124
 
125
#define COFF_FILHDR     struct coff_filehdr
126
#define COFF_FILHSZ     sizeof(COFF_FILHDR)
127
 
128
/********************** AOUT "OPTIONAL HEADER" **********************/
129
 
130
/* Linux COFF must have this "optional" header. Standard COFF has no entry
131
   location for the "entry" point. They normally would start with the first
132
   location of the .text section. This is not a good idea for linux. So,
133
   the use of this "optional" header is not optional. It is required.
134
 
135
   Do not be tempted to assume that the size of the optional header is
136
   a constant and simply index the next byte by the size of this structure.
137
   Use the 'f_opthdr' field in the main coff header for the size of the
138
   structure actually written to the file!!
139
*/
140
 
141
//typedef struct 
142 462 julius
struct COFF_aouthdr {
143
        char magic[2];          /* type of file                          */
144
        char vstamp[2];         /* version stamp                         */
145
        char tsize[4];          /* text size in bytes, padded to FW bdry */
146
        char dsize[4];          /* initialized   data "   "              */
147
        char bsize[4];          /* uninitialized data "   "              */
148
        char entry[4];          /* entry pt.                             */
149
        char text_start[4];     /* base of text used for this file       */
150
        char data_start[4];     /* base of data used for this file       */
151 51 julius
};
152
 
153
#define COFF_AOUTHDR COFF_aouthdr
154
#define COFF_AOUTSZ (sizeof(COFF_AOUTHDR))
155
 
156
#define COFF_STMAGIC    0401
157
#define COFF_OMAGIC     0404
158 462 julius
#define COFF_JMAGIC     0407    /* dirty text and data image, can't share  */
159
#define COFF_DMAGIC     0410    /* dirty text segment, data aligned        */
160
#define COFF_ZMAGIC     0413    /* The proper magic number for executables  */
161 51 julius
#define COFF_SHMAGIC    0443    /* shared library header                   */
162
 
163
/********************** STORAGE CLASSES **********************/
164
 
165
/* This used to be defined as -1, but now n_sclass is unsigned.  */
166 462 julius
#define C_EFCN          0xff    /* physical end of function     */
167 51 julius
#define C_NULL          0
168 462 julius
#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
#define C_AUTOARG       19      /* auto argument                */
187
#define C_LASTENT       20      /* dummy entry (end of block)   */
188
#define C_BLOCK         100     /* ".bb" or ".eb"               */
189
#define C_FCN           101     /* ".bf" or ".ef"               */
190
#define C_EOS           102     /* end of structure             */
191
#define C_FILE          103     /* file name                    */
192 51 julius
#define C_LINE          104     /* line # reformatted as symbol table entry */
193 462 julius
#define C_ALIAS         105     /* duplicate tag                */
194 51 julius
#define C_HIDDEN        106     /* ext symbol in dmert public lib */
195
 
196
#define C_WEAKEXT       127     /* weak symbol -- GNU extension */
197
 
198
/* New storage classes for TI COFF */
199
#define C_UEXT          19      /* Tentative external definition */
200
#define C_STATLAB       20      /* Static load time label */
201
#define C_EXTLAB        21      /* External load time label */
202
#define C_SYSTEM        23      /* System Wide variable */
203
 
204
/* New storage classes for WINDOWS_NT   */
205 462 julius
#define C_SECTION       104     /* section name */
206 51 julius
#define C_NT_WEAK       105     /* weak external */
207
 
208
 /* New storage classes for 80960 */
209
 
210
/* C_LEAFPROC is obsolete.  Use C_LEAFEXT or C_LEAFSTAT */
211
#define C_LEAFPROC      108     /* Leaf procedure, "call" via BAL */
212
 
213
#define C_SCALL         107     /* Procedure reachable via system call */
214
#define C_LEAFEXT       108     /* External leaf */
215
#define C_LEAFSTAT      113     /* Static leaf */
216 462 julius
#define C_OPTVAR        109     /* Optimized variable           */
217
#define C_DEFINE        110     /* Preprocessor #define         */
218
#define C_PRAGMA        111     /* Advice to compiler or linker */
219
#define C_SEGMENT       112     /* 80960 segment name           */
220 51 julius
 
221
  /* Storage classes for m88k */
222 462 julius
#define C_SHADOW        107     /* shadow symbol                */
223
#define C_VERSION       108     /* coff version symbol          */
224 51 julius
 
225
 /* New storage classes for RS/6000 */
226
#define C_HIDEXT        107     /* Un-named external symbol */
227
#define C_BINCL         108     /* Marks beginning of include file */
228
#define C_EINCL         109     /* Marks ending of include file */
229
 
230
 /* storage classes for stab symbols for RS/6000 */
231
#define C_GSYM          (0x80)
232
#define C_LSYM          (0x81)
233
#define C_PSYM          (0x82)
234
#define C_RSYM          (0x83)
235
#define C_RPSYM         (0x84)
236
#define C_STSYM         (0x85)
237
#define C_TCSYM         (0x86)
238
#define C_BCOMM         (0x87)
239
#define C_ECOML         (0x88)
240
#define C_ECOMM         (0x89)
241
#define C_DECL          (0x8c)
242
#define C_ENTRY         (0x8d)
243
#define C_FUN           (0x8e)
244
#define C_BSTAT         (0x8f)
245
#define C_ESTAT         (0x90)
246
 
247
/* Storage classes for Thumb symbols */
248 462 julius
#define C_THUMBEXT      (128 + C_EXT)   /* 130 */
249
#define C_THUMBSTAT     (128 + C_STAT)  /* 131 */
250
#define C_THUMBLABEL    (128 + C_LABEL) /* 134 */
251 51 julius
#define C_THUMBEXTFUNC  (C_THUMBEXT  + 20)      /* 150 */
252
#define C_THUMBSTATFUNC (C_THUMBSTAT + 20)      /* 151 */
253
 
254
/********************** SECTION HEADER **********************/
255
 
256
struct COFF_scnhdr {
257 462 julius
        char s_name[8];         /* section name                     */
258
        char s_paddr[4];        /* physical address, aliased s_nlib */
259
        char s_vaddr[4];        /* virtual address                  */
260
        char s_size[4];         /* section size                     */
261
        char s_scnptr[4];       /* file ptr to raw data for section */
262
        char s_relptr[4];       /* file ptr to relocation           */
263
        char s_lnnoptr[4];      /* file ptr to line numbers         */
264
        char s_nreloc[2];       /* number of relocation entries     */
265
        char s_nlnno[2];        /* number of line number entries    */
266
        char s_flags[4];        /* flags                            */
267 51 julius
};
268
 
269
#define COFF_SCNHDR     struct COFF_scnhdr
270
#define COFF_SCNHSZ     sizeof(COFF_SCNHDR)
271
 
272
/*
273
 * names of "special" sections
274
 */
275
 
276
#define COFF_TEXT       ".text"
277
#define COFF_DATA       ".data"
278
#define COFF_BSS        ".bss"
279
#define COFF_COMMENT    ".comment"
280
#define COFF_LIB        ".lib"
281
 
282 462 julius
#define COFF_SECT_TEXT  0       /* Section for instruction code             */
283
#define COFF_SECT_DATA  1       /* Section for initialized globals          */
284
#define COFF_SECT_BSS   2       /* Section for un-initialized globals       */
285
#define COFF_SECT_REQD  3       /* Minimum number of sections for good file */
286 51 julius
 
287 462 julius
#define COFF_STYP_REG     0x00  /* regular segment                          */
288
#define COFF_STYP_DSECT   0x01  /* dummy segment                            */
289
#define COFF_STYP_NOLOAD  0x02  /* no-load segment                          */
290
#define COFF_STYP_GROUP   0x04  /* group segment                            */
291
#define COFF_STYP_PAD     0x08  /* .pad segment                             */
292
#define COFF_STYP_COPY    0x10  /* copy section                             */
293
#define COFF_STYP_TEXT    0x20  /* .text segment                            */
294
#define COFF_STYP_DATA    0x40  /* .data segment                            */
295
#define COFF_STYP_BSS     0x80  /* .bss segment                             */
296
#define COFF_STYP_INFO   0x200  /* .comment section                         */
297
#define COFF_STYP_OVER   0x400  /* overlay section                          */
298
#define COFF_STYP_LIB    0x800  /* library section                          */
299 51 julius
 
300
/*
301
 * Shared libraries have the following section header in the data field for
302
 * each library.
303
 */
304
 
305
struct COFF_slib {
306 462 julius
        char sl_entsz[4];       /* Size of this entry               */
307
        char sl_pathndx[4];     /* size of the header field         */
308 51 julius
};
309
 
310
#define COFF_SLIBHD     struct COFF_slib
311
#define COFF_SLIBSZ     sizeof(COFF_SLIBHD)
312
 
313
/********************** LINE NUMBERS **********************/
314
 
315
/* 1 line number entry for every "breakpointable" source line in a section.
316
 * Line numbers are grouped on a per function basis; first entry in a function
317
 * grouping will have l_lnno = 0 and in place of physical address will be the
318
 * symbol table index of the function name.
319
 */
320
 
321
struct COFF_lineno {
322 462 julius
        union {
323
                char l_symndx[4];       /* function name symbol index, iff l_lnno == 0 */
324
                char l_paddr[4];        /* (physical) address of line number    */
325
        } l_addr;
326
        char l_lnno[2];         /* line number          */
327 51 julius
};
328
 
329
#define COFF_LINENO     struct COFF_lineno
330
#define COFF_LINESZ     6
331
 
332
/********************** SYMBOLS **********************/
333
 
334 462 julius
#define COFF_E_SYMNMLEN  8      /* # characters in a short symbol name  */
335
#define COFF_E_FILNMLEN 14      /* # characters in a file name          */
336 51 julius
#define COFF_E_DIMNUM    4      /* # array dimensions in auxiliary entry */
337
 
338
/*
339
 *  All symbols and sections have the following definition
340
 */
341
 
342 462 julius
struct COFF_syment {
343
        union {
344
                char e_name[E_SYMNMLEN];        /* Symbol name (first 8 characters) */
345
                struct {
346
                        char e_zeroes[4];       /* Leading zeros */
347
                        char e_offset[4];       /* Offset if this is a header section */
348
                } e;
349
        } e;
350 51 julius
 
351 462 julius
        char e_value[4];        /* Value (address) of the segment */
352
        char e_scnum[2];        /* Section number */
353
        char e_type[2];         /* Type of section */
354
        char e_sclass[1];       /* Loader class */
355
        char e_numaux[1];       /* Number of auxiliary entries which follow */
356 51 julius
};
357
 
358 462 julius
#define COFF_N_BTMASK   (0xf)   /* Mask for important class bits */
359
#define COFF_N_TMASK    (0x30)  /* Mask for important type bits  */
360
#define COFF_N_BTSHFT   (4)     /* # bits to shift class field   */
361
#define COFF_N_TSHIFT   (2)     /* # bits to shift type field    */
362 51 julius
 
363
/*
364
 *  Auxiliary entries because the main table is too limiting.
365
 */
366 462 julius
 
367 51 julius
union COFF_auxent {
368
 
369
/*
370
 *  Debugger information
371
 */
372
 
373 462 julius
        struct {
374
                char x_tagndx[4];       /* str, un, or enum tag indx */
375
                union {
376
                        struct {
377
                                char x_lnno[2]; /* declaration line number */
378
                                char x_size[2]; /* str/union/array size */
379
                        } x_lnsz;
380
                        char x_fsize[4];        /* size of function */
381
                } x_misc;
382 51 julius
 
383 462 julius
                union {
384
                        struct {        /* if ISFCN, tag, or .bb */
385
                                char x_lnnoptr[4];      /* ptr to fcn line # */
386
                                char x_endndx[4];       /* entry ndx past block end */
387
                        } x_fcn;
388 51 julius
 
389 462 julius
                        struct {        /* if ISARY, up to 4 dimen. */
390
                                char x_dimen[E_DIMNUM][2];
391
                        } x_ary;
392
                } x_fcnary;
393 51 julius
 
394 462 julius
                char x_tvndx[2];        /* tv index */
395
        } x_sym;
396 51 julius
 
397
/*
398
 *   Source file names (debugger information)
399
 */
400
 
401 462 julius
        union {
402
                char x_fname[E_FILNMLEN];
403
                struct {
404
                        char x_zeroes[4];
405
                        char x_offset[4];
406
                } x_n;
407
        } x_file;
408 51 julius
 
409
/*
410
 *   Section information
411
 */
412
 
413 462 julius
        struct {
414
                char x_scnlen[4];       /* section length */
415
                char x_nreloc[2];       /* # relocation entries */
416
                char x_nlinno[2];       /* # line numbers */
417
        } x_scn;
418 51 julius
 
419
/*
420
 *   Transfer vector (branch table)
421
 */
422 462 julius
 
423
        struct {
424
                char x_tvfill[4];       /* tv fill value */
425
                char x_tvlen[2];        /* length of .tv */
426
                char x_tvran[2][2];     /* tv range */
427
        } x_tv;                 /* info about .tv section (in auxent of symbol .tv)) */
428 51 julius
};
429
 
430
#define COFF_SYMENT     struct COFF_syment
431 462 julius
#define COFF_SYMESZ     18
432 51 julius
#define COFF_AUXENT     union COFF_auxent
433
#define COFF_AUXESZ     18
434
 
435
#define COFF_ETEXT      "etext"
436
 
437
/********************** RELOCATION DIRECTIVES **********************/
438
 
439
struct COFF_reloc {
440 462 julius
        char r_vaddr[4];        /* Virtual address of item    */
441
        char r_symndx[4];       /* Symbol index in the symtab */
442
        char r_type[2];         /* Relocation type            */
443 51 julius
};
444
 
445
#define COFF_RELOC struct COFF_reloc
446
#define COFF_RELSZ 10
447
 
448
#define COFF_DEF_DATA_SECTION_ALIGNMENT  4
449
#define COFF_DEF_BSS_SECTION_ALIGNMENT   4
450
#define COFF_DEF_TEXT_SECTION_ALIGNMENT  4
451
 
452
/* For new sections we haven't heard of before */
453
#define COFF_DEF_SECTION_ALIGNMENT       4

powered by: WebSVN 2.1.0

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