~ubuntu-branches/ubuntu/hoary/binutils/hoary

« back to all changes in this revision

Viewing changes to include/coff/ecoff.h

  • Committer: Bazaar Package Importer
  • Author(s): James Troup
  • Date: 2004-05-19 10:35:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040519103544-17h3o6e8pwndydrg
Tags: 2.14.90.0.7-8
debian/rules: don't use gcc-2.95 on m68k.  Thanks to Adam Conrad for
pointing this out.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Generic ECOFF support.
 
2
   This does not include symbol information, found in sym.h and
 
3
   symconst.h.
 
4
 
 
5
   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
 
6
 
 
7
   This program is free software; you can redistribute it and/or modify
 
8
   it under the terms of the GNU General Public License as published by
 
9
   the Free Software Foundation; either version 2 of the License, or
 
10
   (at your option) any later version.
 
11
 
 
12
   This program is distributed in the hope that it will be useful,
 
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
   GNU General Public License for more details.
 
16
 
 
17
   You should have received a copy of the GNU General Public License
 
18
   along with this program; if not, write to the Free Software
 
19
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
20
 
 
21
#ifndef ECOFF_H
 
22
#define ECOFF_H
 
23
 
 
24
/* Mips magic numbers used in filehdr.  MIPS_MAGIC_LITTLE is used on
 
25
   little endian machines.  MIPS_MAGIC_BIG is used on big endian
 
26
   machines.  Where is MIPS_MAGIC_1 from?  */
 
27
#define MIPS_MAGIC_1 0x0180
 
28
#define MIPS_MAGIC_LITTLE 0x0162
 
29
#define MIPS_MAGIC_BIG 0x0160
 
30
 
 
31
/* These are the magic numbers used for MIPS code compiled at ISA
 
32
   level 2.  */
 
33
#define MIPS_MAGIC_LITTLE2 0x0166
 
34
#define MIPS_MAGIC_BIG2 0x0163
 
35
 
 
36
/* These are the magic numbers used for MIPS code compiled at ISA
 
37
   level 3.  */
 
38
#define MIPS_MAGIC_LITTLE3 0x142
 
39
#define MIPS_MAGIC_BIG3 0x140
 
40
 
 
41
/* Alpha magic numbers used in filehdr.  */
 
42
#define ALPHA_MAGIC 0x183
 
43
#define ALPHA_MAGIC_BSD 0x185
 
44
 
 
45
/* Magic numbers used in a.out header.  */
 
46
#define ECOFF_AOUT_OMAGIC 0407  /* not demand paged (ld -N).  */
 
47
#define ECOFF_AOUT_ZMAGIC 0413  /* demand load format, eg normal ld output */
 
48
 
 
49
/* Names of special sections.  */
 
50
#define _TEXT   ".text"
 
51
#define _DATA   ".data"
 
52
#define _BSS    ".bss"
 
53
#define _RDATA  ".rdata"
 
54
#define _SDATA  ".sdata"
 
55
#define _SBSS   ".sbss"
 
56
#define _LITA   ".lita"
 
57
#define _LIT4   ".lit4"
 
58
#define _LIT8   ".lit8"
 
59
#define _LIB    ".lib"
 
60
#define _INIT   ".init"
 
61
#define _FINI   ".fini"
 
62
#define _PDATA  ".pdata"
 
63
#define _XDATA  ".xdata"
 
64
#define _GOT    ".got"
 
65
#define _HASH   ".hash"
 
66
#define _DYNSYM ".dynsym"
 
67
#define _DYNSTR ".dynstr"
 
68
#define _RELDYN ".rel.dyn"
 
69
#define _CONFLIC ".conflic"
 
70
#define _COMMENT ".comment"
 
71
#define _LIBLIST ".liblist"
 
72
#define _DYNAMIC ".dynamic"
 
73
#define _RCONST ".rconst"
 
74
 
 
75
/* ECOFF uses some additional section flags.  */
 
76
#define STYP_RDATA           0x100
 
77
#define STYP_SDATA           0x200
 
78
#define STYP_SBSS            0x400
 
79
#define STYP_GOT            0x1000
 
80
#define STYP_DYNAMIC        0x2000
 
81
#define STYP_DYNSYM         0x4000
 
82
#define STYP_RELDYN         0x8000
 
83
#define STYP_DYNSTR        0x10000
 
84
#define STYP_HASH          0x20000
 
85
#define STYP_LIBLIST       0x40000
 
86
#define STYP_CONFLIC      0x100000
 
87
#define STYP_ECOFF_FINI  0x1000000
 
88
#define STYP_EXTENDESC   0x2000000 /* 0x02FFF000 bits => scn type, rest clr */
 
89
#define STYP_LITA        0x4000000
 
90
#define STYP_LIT8        0x8000000
 
91
#define STYP_LIT4       0x10000000
 
92
#define STYP_ECOFF_LIB  0x40000000
 
93
#define STYP_ECOFF_INIT 0x80000000
 
94
#define STYP_OTHER_LOAD (STYP_ECOFF_INIT | STYP_ECOFF_FINI)
 
95
 
 
96
/* extended section types */
 
97
#define STYP_COMMENT     0x2100000
 
98
#define STYP_RCONST      0x2200000
 
99
#define STYP_XDATA       0x2400000
 
100
#define STYP_PDATA       0x2800000
 
101
 
 
102
/* The linker needs a section to hold small common variables while
 
103
   linking.  There is no convenient way to create it when the linker
 
104
   needs it, so we always create one for each BFD.  We then avoid
 
105
   writing it out.  */
 
106
#define SCOMMON ".scommon"
 
107
 
 
108
/* If the extern bit in a reloc is 1, then r_symndx is an index into
 
109
   the external symbol table.  If the extern bit is 0, then r_symndx
 
110
   indicates a section, and is one of the following values.  */
 
111
#define RELOC_SECTION_NONE      0
 
112
#define RELOC_SECTION_TEXT      1
 
113
#define RELOC_SECTION_RDATA     2
 
114
#define RELOC_SECTION_DATA      3
 
115
#define RELOC_SECTION_SDATA     4
 
116
#define RELOC_SECTION_SBSS      5
 
117
#define RELOC_SECTION_BSS       6
 
118
#define RELOC_SECTION_INIT      7
 
119
#define RELOC_SECTION_LIT8      8
 
120
#define RELOC_SECTION_LIT4      9
 
121
#define RELOC_SECTION_XDATA    10
 
122
#define RELOC_SECTION_PDATA    11
 
123
#define RELOC_SECTION_FINI     12
 
124
#define RELOC_SECTION_LITA     13
 
125
#define RELOC_SECTION_ABS      14
 
126
#define RELOC_SECTION_RCONST   15
 
127
 
 
128
#define NUM_RELOC_SECTIONS     16
 
129
 
 
130
/********************** STABS **********************/
 
131
 
 
132
/* gcc uses mips-tfile to output type information in special stabs
 
133
   entries.  These must match the corresponding definition in
 
134
   gcc/config/mips.h.  At some point, these should probably go into a
 
135
   shared include file, but currently gcc and gdb do not share any
 
136
   directories. */
 
137
#define CODE_MASK 0x8F300
 
138
#define ECOFF_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
 
139
#define ECOFF_MARK_STAB(code) ((code)+CODE_MASK)
 
140
#define ECOFF_UNMARK_STAB(code) ((code)-CODE_MASK)
 
141
#define STABS_SYMBOL "@stabs"
 
142
 
 
143
/********************** COFF **********************/
 
144
 
 
145
/* gcc also uses mips-tfile to output COFF debugging information.
 
146
   These are the values it uses when outputting the .type directive.
 
147
   These should also be in a shared include file.  */
 
148
#define N_BTMASK        (017)
 
149
#define N_TMASK         (060)
 
150
#define N_BTSHFT        (4)
 
151
#define N_TSHIFT        (2)
 
152
 
 
153
/********************** AUX **********************/
 
154
 
 
155
/* The auxiliary type information is the same on all known ECOFF
 
156
   targets.  I can't see any reason that it would ever change, so I am
 
157
   going to gamble and define the external structures here, in the
 
158
   target independent ECOFF header file.  The internal forms are
 
159
   defined in coff/sym.h, which was originally donated by MIPS
 
160
   Computer Systems.  */
 
161
 
 
162
/* Type information external record */
 
163
 
 
164
struct tir_ext {
 
165
        unsigned char   t_bits1[1];
 
166
        unsigned char   t_tq45[1];
 
167
        unsigned char   t_tq01[1];
 
168
        unsigned char   t_tq23[1];
 
169
};
 
170
 
 
171
#define TIR_BITS1_FBITFIELD_BIG         ((unsigned int) 0x80)
 
172
#define TIR_BITS1_FBITFIELD_LITTLE      ((unsigned int) 0x01)
 
173
 
 
174
#define TIR_BITS1_CONTINUED_BIG         ((unsigned int) 0x40)
 
175
#define TIR_BITS1_CONTINUED_LITTLE      ((unsigned int) 0x02)
 
176
 
 
177
#define TIR_BITS1_BT_BIG                ((unsigned int) 0x3F)
 
178
#define TIR_BITS1_BT_SH_BIG             0
 
179
#define TIR_BITS1_BT_LITTLE             ((unsigned int) 0xFC)
 
180
#define TIR_BITS1_BT_SH_LITTLE          2
 
181
 
 
182
#define TIR_BITS_TQ4_BIG                ((unsigned int) 0xF0)
 
183
#define TIR_BITS_TQ4_SH_BIG             4
 
184
#define TIR_BITS_TQ5_BIG                ((unsigned int) 0x0F)
 
185
#define TIR_BITS_TQ5_SH_BIG             0
 
186
#define TIR_BITS_TQ4_LITTLE             ((unsigned int) 0x0F)
 
187
#define TIR_BITS_TQ4_SH_LITTLE          0
 
188
#define TIR_BITS_TQ5_LITTLE             ((unsigned int) 0xF0)
 
189
#define TIR_BITS_TQ5_SH_LITTLE          4
 
190
 
 
191
#define TIR_BITS_TQ0_BIG                ((unsigned int) 0xF0)
 
192
#define TIR_BITS_TQ0_SH_BIG             4
 
193
#define TIR_BITS_TQ1_BIG                ((unsigned int) 0x0F)
 
194
#define TIR_BITS_TQ1_SH_BIG             0
 
195
#define TIR_BITS_TQ0_LITTLE             ((unsigned int) 0x0F)
 
196
#define TIR_BITS_TQ0_SH_LITTLE          0
 
197
#define TIR_BITS_TQ1_LITTLE             ((unsigned int) 0xF0)
 
198
#define TIR_BITS_TQ1_SH_LITTLE          4
 
199
 
 
200
#define TIR_BITS_TQ2_BIG                ((unsigned int) 0xF0)
 
201
#define TIR_BITS_TQ2_SH_BIG             4
 
202
#define TIR_BITS_TQ3_BIG                ((unsigned int) 0x0F)
 
203
#define TIR_BITS_TQ3_SH_BIG             0
 
204
#define TIR_BITS_TQ2_LITTLE             ((unsigned int) 0x0F)
 
205
#define TIR_BITS_TQ2_SH_LITTLE          0
 
206
#define TIR_BITS_TQ3_LITTLE             ((unsigned int) 0xF0)
 
207
#define TIR_BITS_TQ3_SH_LITTLE          4
 
208
 
 
209
/* Relative symbol external record */
 
210
 
 
211
struct rndx_ext {
 
212
        unsigned char   r_bits[4];
 
213
};
 
214
 
 
215
#define RNDX_BITS0_RFD_SH_LEFT_BIG      4
 
216
#define RNDX_BITS1_RFD_BIG              ((unsigned int) 0xF0)
 
217
#define RNDX_BITS1_RFD_SH_BIG           4
 
218
 
 
219
#define RNDX_BITS0_RFD_SH_LEFT_LITTLE   0
 
220
#define RNDX_BITS1_RFD_LITTLE           ((unsigned int) 0x0F)
 
221
#define RNDX_BITS1_RFD_SH_LEFT_LITTLE   8
 
222
 
 
223
#define RNDX_BITS1_INDEX_BIG            ((unsigned int) 0x0F)
 
224
#define RNDX_BITS1_INDEX_SH_LEFT_BIG    16
 
225
#define RNDX_BITS2_INDEX_SH_LEFT_BIG    8
 
226
#define RNDX_BITS3_INDEX_SH_LEFT_BIG    0
 
227
 
 
228
#define RNDX_BITS1_INDEX_LITTLE         ((unsigned int) 0xF0)
 
229
#define RNDX_BITS1_INDEX_SH_LITTLE      4
 
230
#define RNDX_BITS2_INDEX_SH_LEFT_LITTLE 4
 
231
#define RNDX_BITS3_INDEX_SH_LEFT_LITTLE 12
 
232
 
 
233
/* Auxiliary symbol information external record */
 
234
 
 
235
union aux_ext {
 
236
        struct tir_ext  a_ti;
 
237
        struct rndx_ext a_rndx;
 
238
        unsigned char   a_dnLow[4];
 
239
        unsigned char   a_dnHigh[4];
 
240
        unsigned char   a_isym[4];
 
241
        unsigned char   a_iss[4];
 
242
        unsigned char   a_width[4];
 
243
        unsigned char   a_count[4];
 
244
};
 
245
 
 
246
#define AUX_GET_ANY(bigend, ax, field) \
 
247
  ((bigend) ? bfd_getb32 ((ax)->field) : bfd_getl32 ((ax)->field))
 
248
 
 
249
#define AUX_GET_DNLOW(bigend, ax)       AUX_GET_ANY ((bigend), (ax), a_dnLow)
 
250
#define AUX_GET_DNHIGH(bigend, ax)      AUX_GET_ANY ((bigend), (ax), a_dnHigh)
 
251
#define AUX_GET_ISYM(bigend, ax)        AUX_GET_ANY ((bigend), (ax), a_isym)
 
252
#define AUX_GET_ISS(bigend, ax)         AUX_GET_ANY ((bigend), (ax), a_iss)
 
253
#define AUX_GET_WIDTH(bigend, ax)       AUX_GET_ANY ((bigend), (ax), a_width)
 
254
#define AUX_GET_COUNT(bigend, ax)       AUX_GET_ANY ((bigend), (ax), a_count)
 
255
 
 
256
#define AUX_PUT_ANY(bigend, val, ax, field) \
 
257
  ((bigend) \
 
258
   ? (bfd_putb32 ((bfd_vma) (val), (ax)->field), 0) \
 
259
   : (bfd_putl32 ((bfd_vma) (val), (ax)->field), 0))
 
260
 
 
261
#define AUX_PUT_DNLOW(bigend, val, ax) \
 
262
  AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow)
 
263
#define AUX_PUT_DNHIGH(bigend, val, ax) \
 
264
  AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh)
 
265
#define AUX_PUT_ISYM(bigend, val, ax) \
 
266
  AUX_PUT_ANY ((bigend), (val), (ax), a_isym)
 
267
#define AUX_PUT_ISS(bigend, val, ax) \
 
268
  AUX_PUT_ANY ((bigend), (val), (ax), a_iss)
 
269
#define AUX_PUT_WIDTH(bigend, val, ax) \
 
270
  AUX_PUT_ANY ((bigend), (val), (ax), a_width)
 
271
#define AUX_PUT_COUNT(bigend, val, ax) \
 
272
  AUX_PUT_ANY ((bigend), (val), (ax), a_count)
 
273
 
 
274
/********************** SYMBOLS **********************/
 
275
 
 
276
/* For efficiency, gdb deals directly with the unswapped symbolic
 
277
   information (that way it only takes the time to swap information
 
278
   that it really needs to read).  gdb originally retrieved the
 
279
   information directly from the BFD backend information, but that
 
280
   strategy, besides being sort of ugly, does not work for MIPS ELF,
 
281
   which also uses ECOFF debugging information.  This structure holds
 
282
   pointers to the (mostly) unswapped symbolic information.  */
 
283
 
 
284
struct ecoff_debug_info
 
285
{
 
286
  /* The swapped ECOFF symbolic header.  */
 
287
  HDRR symbolic_header;
 
288
 
 
289
  /* Pointers to the unswapped symbolic information.  Note that the
 
290
     pointers to external structures point to different sorts of
 
291
     information on different ECOFF targets.  The ecoff_debug_swap
 
292
     structure provides the sizes of the structures and the functions
 
293
     needed to swap the information in and out.  These pointers are
 
294
     all pointers to arrays, not single structures.  They will be NULL
 
295
     if there are no instances of the relevant structure.  These
 
296
     fields are also used by the assembler to output ECOFF debugging
 
297
     information.  */
 
298
  unsigned char *line;
 
299
  void *external_dnr;   /* struct dnr_ext */
 
300
  void *external_pdr;   /* struct pdr_ext */
 
301
  void *external_sym;   /* struct sym_ext */
 
302
  void *external_opt;   /* struct opt_ext */
 
303
  union aux_ext *external_aux;
 
304
  char *ss;
 
305
  char *ssext;
 
306
  void *external_fdr;   /* struct fdr_ext */
 
307
  void *external_rfd;   /* struct rfd_ext */
 
308
  void *external_ext;   /* struct ext_ext */
 
309
 
 
310
  /* These fields are used when linking.  They may disappear at some
 
311
     point.  */
 
312
  char *ssext_end;
 
313
  void *external_ext_end;
 
314
 
 
315
  /* When linking, this field holds a mapping from the input FDR
 
316
     numbers to the output numbers, and is used when writing out the
 
317
     external symbols.  It is NULL if no mapping is required.  */
 
318
  RFDT *ifdmap;
 
319
 
 
320
  /* The swapped FDR information.  Currently this is never NULL, but
 
321
     code using this structure should probably double-check in case
 
322
     this changes in the future.  This is a pointer to an array, not a
 
323
     single structure.  */
 
324
  FDR *fdr;
 
325
 
 
326
  /* When relaxing MIPS embedded PIC code, we may need to adjust
 
327
     symbol values when they are output.  This is a linked list of
 
328
     structures indicating how values should be adjusted.  There is no
 
329
     requirement that the entries be in any order, or that they not
 
330
     overlap.  This field is normally NULL, in which case no
 
331
     adjustments need to be made.  */
 
332
  struct ecoff_value_adjust *adjust;
 
333
};
 
334
 
 
335
/* This structure describes how to adjust symbol values when
 
336
   outputting MIPS embedded PIC code.  These adjustments only apply to
 
337
   the internal symbols, as the external symbol values will come from
 
338
   the hash table and have already been adjusted.  */
 
339
 
 
340
struct ecoff_value_adjust
 
341
{
 
342
  /* Next entry on adjustment list.  */
 
343
  struct ecoff_value_adjust *next;
 
344
  /* Starting VMA of adjustment.  This is the VMA in the ECOFF file,
 
345
     not the offset from the start of the section.  Thus it should
 
346
     indicate a particular section.  */
 
347
  bfd_vma start;
 
348
  /* Ending VMA of adjustment.  */
 
349
  bfd_vma end;
 
350
  /* Adjustment.  This should be added to the value of the symbol, or
 
351
     FDR.  This is zero for the last entry in the array.  */
 
352
  long adjust;
 
353
};
 
354
 
 
355
/* These structures are used by the ECOFF find_nearest_line function.  */
 
356
 
 
357
struct ecoff_fdrtab_entry
 
358
{
 
359
  /* Base address in .text of this FDR.  */
 
360
  bfd_vma base_addr;
 
361
  FDR *fdr;
 
362
};
 
363
 
 
364
struct ecoff_find_line
 
365
{
 
366
  /* Allocated memory to hold function and file names.  */
 
367
  char *find_buffer;
 
368
 
 
369
  /* FDR table, sorted by address: */
 
370
  long fdrtab_len;
 
371
  struct ecoff_fdrtab_entry *fdrtab;
 
372
 
 
373
  /* Cache entry for most recently found line information.  The sect
 
374
     field is NULL if this cache does not contain valid information.  */
 
375
  struct
 
376
    {
 
377
      asection *sect;
 
378
      bfd_vma start;
 
379
      bfd_vma stop;
 
380
      const char *filename;
 
381
      const char *functionname;
 
382
      unsigned int line_num;
 
383
    } cache;
 
384
};
 
385
 
 
386
/********************** SWAPPING **********************/
 
387
 
 
388
/* The generic ECOFF code needs to be able to swap debugging
 
389
   information in and out in the specific format used by a particular
 
390
   ECOFF implementation.  This structure provides the information
 
391
   needed to do this.  */
 
392
 
 
393
struct ecoff_debug_swap
 
394
{
 
395
  /* Symbol table magic number.  */
 
396
  int sym_magic;
 
397
  /* Alignment of debugging information.  E.g., 4.  */
 
398
  bfd_size_type debug_align;
 
399
  /* Sizes of external symbolic information.  */
 
400
  bfd_size_type external_hdr_size;
 
401
  bfd_size_type external_dnr_size;
 
402
  bfd_size_type external_pdr_size;
 
403
  bfd_size_type external_sym_size;
 
404
  bfd_size_type external_opt_size;
 
405
  bfd_size_type external_fdr_size;
 
406
  bfd_size_type external_rfd_size;
 
407
  bfd_size_type external_ext_size;
 
408
  /* Functions to swap in external symbolic data.  */
 
409
  void (*swap_hdr_in) (bfd *, void *, HDRR *);
 
410
  void (*swap_dnr_in) (bfd *, void *, DNR *);
 
411
  void (*swap_pdr_in) (bfd *, void *, PDR *);
 
412
  void (*swap_sym_in) (bfd *, void *, SYMR *);
 
413
  void (*swap_opt_in) (bfd *, void *, OPTR *);
 
414
  void (*swap_fdr_in) (bfd *, void *, FDR *);
 
415
  void (*swap_rfd_in) (bfd *, void *, RFDT *);
 
416
  void (*swap_ext_in) (bfd *, void *, EXTR *);
 
417
  void (*swap_tir_in) (int, const struct tir_ext *, TIR *);
 
418
  void (*swap_rndx_in) (int, const struct rndx_ext *, RNDXR *);
 
419
  /* Functions to swap out external symbolic data.  */
 
420
  void (*swap_hdr_out) (bfd *, const HDRR *, void *);
 
421
  void (*swap_dnr_out) (bfd *, const DNR *, void *);
 
422
  void (*swap_pdr_out) (bfd *, const PDR *, void *);
 
423
  void (*swap_sym_out) (bfd *, const SYMR *, void *);
 
424
  void (*swap_opt_out) (bfd *, const OPTR *, void *);
 
425
  void (*swap_fdr_out) (bfd *, const FDR *, void *);
 
426
  void (*swap_rfd_out) (bfd *, const RFDT *, void *);
 
427
  void (*swap_ext_out) (bfd *, const EXTR *, void *);
 
428
  void (*swap_tir_out) (int, const TIR *, struct tir_ext *);
 
429
  void (*swap_rndx_out) (int, const RNDXR *, struct rndx_ext *);
 
430
  /* Function to read symbol data and set up pointers in
 
431
     ecoff_debug_info structure.  The section argument is used for
 
432
     ELF, not straight ECOFF.  */
 
433
  bfd_boolean (*read_debug_info) (bfd *, asection *, struct ecoff_debug_info *);
 
434
};
 
435
 
 
436
#endif /* ! defined (ECOFF_H) */