* mips.h (struct ecoff_debug_info): Define.
[deliverable/binutils-gdb.git] / include / coff / ecoff.h
1 #ifndef ECOFF_H
2 #define ECOFF_H
3
4 /* Generic ECOFF support.
5 This does not include symbol information, found in sym.h and
6 symconst.h. */
7
8 /* Mips magic numbers used in filehdr. MIPS_MAGIC_LITTLE is used on
9 little endian machines. MIPS_MAGIC_BIG is used on big endian
10 machines. Where is MIPS_MAGIC_1 from? */
11 #define MIPS_MAGIC_1 0x0180
12 #define MIPS_MAGIC_LITTLE 0x0162
13 #define MIPS_MAGIC_BIG 0x0160
14
15 /* These are the magic numbers used for MIPS code compiled at ISA
16 level 2. */
17 #define MIPS_MAGIC_LITTLE2 0x0166
18 #define MIPS_MAGIC_BIG2 0x0163
19
20 /* These are the magic numbers used for MIPS code compiled at ISA
21 level 3. */
22 #define MIPS_MAGIC_LITTLE3 0x142
23 #define MIPS_MAGIC_BIG3 0x140
24
25 /* Alpha magic numbers used in filehdr. */
26 #define ALPHA_MAGIC 0x183
27
28 /* Magic numbers used in a.out header. */
29 #define ECOFF_AOUT_OMAGIC 0407 /* not demand paged (ld -N). */
30 #define ECOFF_AOUT_ZMAGIC 0413 /* demand load format, eg normal ld output */
31
32 /* Names of special sections. */
33 #define _TEXT ".text"
34 #define _DATA ".data"
35 #define _BSS ".bss"
36 #define _RDATA ".rdata"
37 #define _SDATA ".sdata"
38 #define _SBSS ".sbss"
39 #define _LITA ".lita"
40 #define _LIT4 ".lit4"
41 #define _LIT8 ".lit8"
42 #define _LIB ".lib"
43 #define _INIT ".init"
44 #define _FINI ".fini"
45 #define _PDATA ".pdata"
46 #define _XDATA ".xdata"
47
48 /* ECOFF uses some additional section flags. */
49 #define STYP_RDATA 0x100
50 #define STYP_SDATA 0x200
51 #define STYP_SBSS 0x400
52 #define STYP_ECOFF_FINI 0x1000000
53 #define STYP_LITA 0x4000000
54 #define STYP_LIT8 0x8000000
55 #define STYP_LIT4 0x10000000
56 #define STYP_ECOFF_INIT 0x80000000
57 #define STYP_OTHER_LOAD (STYP_ECOFF_INIT | STYP_ECOFF_FINI)
58
59 /* The linker needs a section to hold small common variables while
60 linking. There is no convenient way to create it when the linker
61 needs it, so we always create one for each BFD. We then avoid
62 writing it out. */
63 #define SCOMMON ".scommon"
64
65 /* The ECOFF a.out header carries information about register masks and
66 the gp value. The assembler needs to be able to write out this
67 information, and objcopy needs to be able to copy it from one file
68 to another. To handle this in BFD, we use a dummy section to hold
69 the information. We call this section .reginfo, since MIPS ELF has
70 a .reginfo section which serves a similar purpose. When BFD
71 recognizes an ECOFF object, it copies the information into a
72 private data structure. When the .reginfo section is read, the
73 information is retrieved from the private data structure. When the
74 .reginfo section is written, the information in the private data
75 structure is updated. The contents of the .reginfo section, as
76 seen by programs outside BFD, is a ecoff_reginfo structure. The
77 contents of the structure are as seen on the host, so no swapping
78 issues arise.
79
80 The assembler used to update the private BFD data structures
81 directly. With this approach, it instead just creates a .reginfo
82 section and updates that. The real advantage of this approach is
83 that objcopy works automatically. */
84 #define REGINFO ".reginfo"
85 struct ecoff_reginfo
86 {
87 bfd_vma gp_value; /* GP register value. */
88 unsigned long gprmask; /* General registers used. */
89 unsigned long cprmask[4]; /* Coprocessor registers used. */
90 unsigned long fprmask; /* Floating pointer registers used. */
91 };
92
93 /* If the extern bit in a reloc is 1, then r_symndx is an index into
94 the external symbol table. If the extern bit is 0, then r_symndx
95 indicates a section, and is one of the following values. */
96 #define RELOC_SECTION_NONE 0
97 #define RELOC_SECTION_TEXT 1
98 #define RELOC_SECTION_RDATA 2
99 #define RELOC_SECTION_DATA 3
100 #define RELOC_SECTION_SDATA 4
101 #define RELOC_SECTION_SBSS 5
102 #define RELOC_SECTION_BSS 6
103 #define RELOC_SECTION_INIT 7
104 #define RELOC_SECTION_LIT8 8
105 #define RELOC_SECTION_LIT4 9
106 #define RELOC_SECTION_XDATA 10
107 #define RELOC_SECTION_PDATA 11
108 #define RELOC_SECTION_FINI 12
109 #define RELOC_SECTION_LITA 13
110 #define RELOC_SECTION_ABS 14
111
112 /********************** STABS **********************/
113
114 /* gcc uses mips-tfile to output type information in special stabs
115 entries. These must match the corresponding definition in
116 gcc/config/mips.h. At some point, these should probably go into a
117 shared include file, but currently gcc and gdb do not share any
118 directories. */
119 #define CODE_MASK 0x8F300
120 #define ECOFF_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
121 #define ECOFF_MARK_STAB(code) ((code)+CODE_MASK)
122 #define ECOFF_UNMARK_STAB(code) ((code)-CODE_MASK)
123 #define STABS_SYMBOL "@stabs"
124
125 /********************** COFF **********************/
126
127 /* gcc also uses mips-tfile to output COFF debugging information.
128 These are the values it uses when outputting the .type directive.
129 These should also be in a shared include file. */
130 #define N_BTMASK (017)
131 #define N_TMASK (060)
132 #define N_BTSHFT (4)
133 #define N_TSHIFT (2)
134
135 /********************** AUX **********************/
136
137 /* The auxiliary type information is the same on all known ECOFF
138 targets. I can't see any reason that it would ever change, so I am
139 going to gamble and define the external structures here, in the
140 target independent ECOFF header file. The internal forms are
141 defined in coff/sym.h, which was originally donated by MIPS
142 Computer Systems. */
143
144 /* Type information external record */
145
146 struct tir_ext {
147 unsigned char t_bits1[1];
148 unsigned char t_tq45[1];
149 unsigned char t_tq01[1];
150 unsigned char t_tq23[1];
151 };
152
153 #define TIR_BITS1_FBITFIELD_BIG 0x80
154 #define TIR_BITS1_FBITFIELD_LITTLE 0x01
155
156 #define TIR_BITS1_CONTINUED_BIG 0x40
157 #define TIR_BITS1_CONTINUED_LITTLE 0x02
158
159 #define TIR_BITS1_BT_BIG 0x3F
160 #define TIR_BITS1_BT_SH_BIG 0
161 #define TIR_BITS1_BT_LITTLE 0xFC
162 #define TIR_BITS1_BT_SH_LITTLE 2
163
164 #define TIR_BITS_TQ4_BIG 0xF0
165 #define TIR_BITS_TQ4_SH_BIG 4
166 #define TIR_BITS_TQ5_BIG 0x0F
167 #define TIR_BITS_TQ5_SH_BIG 0
168 #define TIR_BITS_TQ4_LITTLE 0x0F
169 #define TIR_BITS_TQ4_SH_LITTLE 0
170 #define TIR_BITS_TQ5_LITTLE 0xF0
171 #define TIR_BITS_TQ5_SH_LITTLE 4
172
173 #define TIR_BITS_TQ0_BIG 0xF0
174 #define TIR_BITS_TQ0_SH_BIG 4
175 #define TIR_BITS_TQ1_BIG 0x0F
176 #define TIR_BITS_TQ1_SH_BIG 0
177 #define TIR_BITS_TQ0_LITTLE 0x0F
178 #define TIR_BITS_TQ0_SH_LITTLE 0
179 #define TIR_BITS_TQ1_LITTLE 0xF0
180 #define TIR_BITS_TQ1_SH_LITTLE 4
181
182 #define TIR_BITS_TQ2_BIG 0xF0
183 #define TIR_BITS_TQ2_SH_BIG 4
184 #define TIR_BITS_TQ3_BIG 0x0F
185 #define TIR_BITS_TQ3_SH_BIG 0
186 #define TIR_BITS_TQ2_LITTLE 0x0F
187 #define TIR_BITS_TQ2_SH_LITTLE 0
188 #define TIR_BITS_TQ3_LITTLE 0xF0
189 #define TIR_BITS_TQ3_SH_LITTLE 4
190
191 /* Relative symbol external record */
192
193 struct rndx_ext {
194 unsigned char r_bits[4];
195 };
196
197 #define RNDX_BITS0_RFD_SH_LEFT_BIG 4
198 #define RNDX_BITS1_RFD_BIG 0xF0
199 #define RNDX_BITS1_RFD_SH_BIG 4
200
201 #define RNDX_BITS0_RFD_SH_LEFT_LITTLE 0
202 #define RNDX_BITS1_RFD_LITTLE 0x0F
203 #define RNDX_BITS1_RFD_SH_LEFT_LITTLE 8
204
205 #define RNDX_BITS1_INDEX_BIG 0x0F
206 #define RNDX_BITS1_INDEX_SH_LEFT_BIG 16
207 #define RNDX_BITS2_INDEX_SH_LEFT_BIG 8
208 #define RNDX_BITS3_INDEX_SH_LEFT_BIG 0
209
210 #define RNDX_BITS1_INDEX_LITTLE 0xF0
211 #define RNDX_BITS1_INDEX_SH_LITTLE 4
212 #define RNDX_BITS2_INDEX_SH_LEFT_LITTLE 4
213 #define RNDX_BITS3_INDEX_SH_LEFT_LITTLE 12
214
215 /* Auxiliary symbol information external record */
216
217 union aux_ext {
218 struct tir_ext a_ti;
219 struct rndx_ext a_rndx;
220 unsigned char a_dnLow[4];
221 unsigned char a_dnHigh[4];
222 unsigned char a_isym[4];
223 unsigned char a_iss[4];
224 unsigned char a_width[4];
225 unsigned char a_count[4];
226 };
227
228 #define AUX_GET_ANY(bigend, ax, field) \
229 ((bigend) ? bfd_getb32 ((ax)->field) : bfd_getl32 ((ax)->field))
230
231 #define AUX_GET_DNLOW(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnLow)
232 #define AUX_GET_DNHIGH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnHigh)
233 #define AUX_GET_ISYM(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_isym)
234 #define AUX_GET_ISS(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_iss)
235 #define AUX_GET_WIDTH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_width)
236 #define AUX_GET_COUNT(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_count)
237
238 #define AUX_PUT_ANY(bigend, val, ax, field) \
239 ((bigend) \
240 ? (bfd_putb32 ((bfd_vma) (val), (ax)->field), 0) \
241 : (bfd_putl32 ((bfd_vma) (val), (ax)->field), 0))
242
243 #define AUX_PUT_DNLOW(bigend, val, ax) \
244 AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow)
245 #define AUX_PUT_DNHIGH(bigend, val, ax) \
246 AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh)
247 #define AUX_PUT_ISYM(bigend, val, ax) \
248 AUX_PUT_ANY ((bigend), (val), (ax), a_isym)
249 #define AUX_PUT_ISS(bigend, val, ax) \
250 AUX_PUT_ANY ((bigend), (val), (ax), a_iss)
251 #define AUX_PUT_WIDTH(bigend, val, ax) \
252 AUX_PUT_ANY ((bigend), (val), (ax), a_width)
253 #define AUX_PUT_COUNT(bigend, val, ax) \
254 AUX_PUT_ANY ((bigend), (val), (ax), a_count)
255
256 /* Prototypes for the swapping functions. These require that sym.h be
257 included before this file. */
258
259 extern void ecoff_swap_tir_in PARAMS ((int bigend, struct tir_ext *, TIR *));
260 extern void ecoff_swap_tir_out PARAMS ((int bigend, TIR *, struct tir_ext *));
261 extern void ecoff_swap_rndx_in PARAMS ((int bigend, struct rndx_ext *,
262 RNDXR *));
263 extern void ecoff_swap_rndx_out PARAMS ((int bigend, RNDXR *,
264 struct rndx_ext *));
265
266 /********************** SWAPPING **********************/
267
268 /* The generic ECOFF code needs to be able to swap debugging
269 information in and out in the specific format used by a particular
270 ECOFF implementation. This structure provides the information
271 needed to do this. */
272
273 struct ecoff_debug_swap
274 {
275 /* Symbol table magic number. */
276 int sym_magic;
277 /* Alignment of debugging information. E.g., 4. */
278 bfd_size_type debug_align;
279 /* Sizes of external symbolic information. */
280 bfd_size_type external_hdr_size;
281 bfd_size_type external_dnr_size;
282 bfd_size_type external_pdr_size;
283 bfd_size_type external_sym_size;
284 bfd_size_type external_opt_size;
285 bfd_size_type external_fdr_size;
286 bfd_size_type external_rfd_size;
287 bfd_size_type external_ext_size;
288 /* Functions to swap in external symbolic data. */
289 void (*swap_hdr_in) PARAMS ((bfd *, PTR, HDRR *));
290 void (*swap_dnr_in) PARAMS ((bfd *, PTR, DNR *));
291 void (*swap_pdr_in) PARAMS ((bfd *, PTR, PDR *));
292 void (*swap_sym_in) PARAMS ((bfd *, PTR, SYMR *));
293 void (*swap_opt_in) PARAMS ((bfd *, PTR, OPTR *));
294 void (*swap_fdr_in) PARAMS ((bfd *, PTR, FDR *));
295 void (*swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *));
296 void (*swap_ext_in) PARAMS ((bfd *, PTR, EXTR *));
297 /* Functions to swap out external symbolic data. */
298 void (*swap_hdr_out) PARAMS ((bfd *, const HDRR *, PTR));
299 void (*swap_dnr_out) PARAMS ((bfd *, const DNR *, PTR));
300 void (*swap_pdr_out) PARAMS ((bfd *, const PDR *, PTR));
301 void (*swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR));
302 void (*swap_opt_out) PARAMS ((bfd *, const OPTR *, PTR));
303 void (*swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR));
304 void (*swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR));
305 void (*swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR));
306 /* As noted above, it so happens that the auxiliary type information
307 has the same type and format for all known ECOFF targets. I don't
308 see any reason that that should change, so at least for now the
309 auxiliary swapping information is not in this table. */
310 };
311
312 /********************** SYMBOLS **********************/
313
314 /* For efficiency, gdb deals directly with the unswapped symbolic
315 information (that way it only takes the time to swap information
316 that it really needs to read). gdb originally retrieved the
317 information directly from the BFD backend information, but that
318 strategy, besides being sort of ugly, does not work for MIPS ELF,
319 which also uses ECOFF debugging information. This structure holds
320 pointers to the (mostly) unswapped symbolic information. */
321
322 struct ecoff_debug_info
323 {
324 /* The swapped ECOFF symbolic header. */
325 HDRR symbolic_header;
326
327 /* Pointers to the unswapped symbolic information. Note that the
328 pointers to external structures point to different sorts of
329 information on different ECOFF targets. The ecoff_debug_swap
330 structure provides the sizes of the structures and the functions
331 needed to swap the information in and out. These pointers are
332 all pointers to arrays, not single structures. They will be NULL
333 if there are no instances of the relevant structure. */
334 unsigned char *line;
335 PTR external_dnr; /* struct dnr_ext */
336 PTR external_pdr; /* struct pdr_ext */
337 PTR external_sym; /* struct sym_ext */
338 PTR external_opt; /* struct opt_ext */
339 union aux_ext *external_aux;
340 char *ss;
341 char *ssext;
342 PTR external_fdr; /* struct fdr_ext */
343 PTR external_rfd; /* struct rfd_ext */
344 PTR external_ext; /* struct ext_ext */
345
346 /* The swapped FDR information. Currently this is never NULL, but
347 code using this structure should probably double-check in case
348 this changes in the future. This is a pointer to an array, not a
349 single structure. */
350 FDR *fdr;
351 };
352
353 #endif /* ! defined (ECOFF_H) */
This page took 0.036476 seconds and 4 git commands to generate.