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