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