Commit | Line | Data |
---|---|---|
9e1cd294 | 1 | /* MIPS `ECOFF' symbol table external format. |
57486089 | 2 | Copyright 1992, 1993 Free Software Foundation. |
a0b23459 JG |
3 | Contributed by Cygnus Support. Written by John Gilmore. |
4 | ||
5 | This file is part of GDB. | |
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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
9e1cd294 JG |
21 | /* ECOFF uses COFF-like section structures, but its own symbol format. |
22 | This file defines the symbol format in fields whose size and alignment | |
23 | will not vary on different host systems. The bfd module coff-msym.c | |
24 | converts between external and internal forms of this information, | |
25 | deals with byte order issues, etc. */ | |
26 | ||
a0b23459 JG |
27 | /* File header as a set of bytes */ |
28 | ||
29 | struct hdr_ext { | |
6b6cc3fd JG |
30 | unsigned char h_magic[2]; |
31 | unsigned char h_vstamp[2]; | |
32 | unsigned char h_ilineMax[4]; | |
33 | unsigned char h_cbLine[4]; | |
34 | unsigned char h_cbLineOffset[4]; | |
35 | unsigned char h_idnMax[4]; | |
36 | unsigned char h_cbDnOffset[4]; | |
37 | unsigned char h_ipdMax[4]; | |
38 | unsigned char h_cbPdOffset[4]; | |
39 | unsigned char h_isymMax[4]; | |
40 | unsigned char h_cbSymOffset[4]; | |
41 | unsigned char h_ioptMax[4]; | |
42 | unsigned char h_cbOptOffset[4]; | |
43 | unsigned char h_iauxMax[4]; | |
44 | unsigned char h_cbAuxOffset[4]; | |
45 | unsigned char h_issMax[4]; | |
46 | unsigned char h_cbSsOffset[4]; | |
47 | unsigned char h_issExtMax[4]; | |
48 | unsigned char h_cbSsExtOffset[4]; | |
49 | unsigned char h_ifdMax[4]; | |
50 | unsigned char h_cbFdOffset[4]; | |
51 | unsigned char h_crfd[4]; | |
52 | unsigned char h_cbRfdOffset[4]; | |
53 | unsigned char h_iextMax[4]; | |
54 | unsigned char h_cbExtOffset[4]; | |
a0b23459 JG |
55 | }; |
56 | ||
57 | /* File descriptor external record */ | |
58 | ||
59 | struct fdr_ext { | |
6b6cc3fd JG |
60 | unsigned char f_adr[4]; |
61 | unsigned char f_rss[4]; | |
62 | unsigned char f_issBase[4]; | |
63 | unsigned char f_cbSs[4]; | |
64 | unsigned char f_isymBase[4]; | |
65 | unsigned char f_csym[4]; | |
66 | unsigned char f_ilineBase[4]; | |
67 | unsigned char f_cline[4]; | |
68 | unsigned char f_ioptBase[4]; | |
69 | unsigned char f_copt[4]; | |
70 | unsigned char f_ipdFirst[2]; | |
71 | unsigned char f_cpd[2]; | |
72 | unsigned char f_iauxBase[4]; | |
73 | unsigned char f_caux[4]; | |
74 | unsigned char f_rfdBase[4]; | |
75 | unsigned char f_crfd[4]; | |
76 | unsigned char f_bits1[1]; | |
77 | unsigned char f_bits2[3]; | |
78 | unsigned char f_cbLineOffset[4]; | |
79 | unsigned char f_cbLine[4]; | |
a0b23459 JG |
80 | }; |
81 | ||
82 | #define FDR_BITS1_LANG_BIG 0xF8 | |
83 | #define FDR_BITS1_LANG_SH_BIG 3 | |
84 | #define FDR_BITS1_LANG_LITTLE 0x1F | |
85 | #define FDR_BITS1_LANG_SH_LITTLE 0 | |
86 | ||
87 | #define FDR_BITS1_FMERGE_BIG 0x04 | |
88 | #define FDR_BITS1_FMERGE_LITTLE 0x20 | |
89 | ||
90 | #define FDR_BITS1_FREADIN_BIG 0x02 | |
91 | #define FDR_BITS1_FREADIN_LITTLE 0x40 | |
92 | ||
93 | #define FDR_BITS1_FBIGENDIAN_BIG 0x01 | |
94 | #define FDR_BITS1_FBIGENDIAN_LITTLE 0x80 | |
95 | ||
96 | #define FDR_BITS2_GLEVEL_BIG 0xC0 | |
97 | #define FDR_BITS2_GLEVEL_SH_BIG 6 | |
98 | #define FDR_BITS2_GLEVEL_LITTLE 0x03 | |
99 | #define FDR_BITS2_GLEVEL_SH_LITTLE 0 | |
100 | ||
101 | /* We ignore the `reserved' field in bits2. */ | |
102 | ||
103 | ||
104 | /* Procedure descriptor external record */ | |
105 | ||
106 | struct pdr_ext { | |
6b6cc3fd JG |
107 | unsigned char p_adr[4]; |
108 | unsigned char p_isym[4]; | |
109 | unsigned char p_iline[4]; | |
110 | unsigned char p_regmask[4]; | |
111 | unsigned char p_regoffset[4]; | |
112 | unsigned char p_iopt[4]; | |
113 | unsigned char p_fregmask[4]; | |
114 | unsigned char p_fregoffset[4]; | |
115 | unsigned char p_frameoffset[4]; | |
116 | unsigned char p_framereg[2]; | |
117 | unsigned char p_pcreg[2]; | |
118 | unsigned char p_lnLow[4]; | |
119 | unsigned char p_lnHigh[4]; | |
120 | unsigned char p_cbLineOffset[4]; | |
a0b23459 JG |
121 | }; |
122 | ||
123 | /* Line numbers */ | |
124 | ||
125 | struct line_ext { | |
6b6cc3fd | 126 | unsigned char l_line[4]; |
a0b23459 JG |
127 | }; |
128 | ||
129 | /* Symbol external record */ | |
130 | ||
131 | struct sym_ext { | |
6b6cc3fd JG |
132 | unsigned char s_iss[4]; |
133 | unsigned char s_value[4]; | |
134 | unsigned char s_bits1[1]; | |
135 | unsigned char s_bits2[1]; | |
136 | unsigned char s_bits3[1]; | |
137 | unsigned char s_bits4[1]; | |
a0b23459 JG |
138 | }; |
139 | ||
140 | #define SYM_BITS1_ST_BIG 0xFC | |
141 | #define SYM_BITS1_ST_SH_BIG 2 | |
142 | #define SYM_BITS1_ST_LITTLE 0x3F | |
143 | #define SYM_BITS1_ST_SH_LITTLE 0 | |
144 | ||
145 | #define SYM_BITS1_SC_BIG 0x03 | |
146 | #define SYM_BITS1_SC_SH_LEFT_BIG 3 | |
147 | #define SYM_BITS1_SC_LITTLE 0xC0 | |
148 | #define SYM_BITS1_SC_SH_LITTLE 6 | |
149 | ||
150 | #define SYM_BITS2_SC_BIG 0xE0 | |
151 | #define SYM_BITS2_SC_SH_BIG 5 | |
152 | #define SYM_BITS2_SC_LITTLE 0x07 | |
153 | #define SYM_BITS2_SC_SH_LEFT_LITTLE 2 | |
154 | ||
155 | #define SYM_BITS2_RESERVED_BIG 0x10 | |
156 | #define SYM_BITS2_RESERVED_LITTLE 0x08 | |
157 | ||
158 | #define SYM_BITS2_INDEX_BIG 0x0F | |
159 | #define SYM_BITS2_INDEX_SH_LEFT_BIG 16 | |
160 | #define SYM_BITS2_INDEX_LITTLE 0xF0 | |
161 | #define SYM_BITS2_INDEX_SH_LITTLE 4 | |
162 | ||
163 | #define SYM_BITS3_INDEX_SH_LEFT_BIG 8 | |
164 | #define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4 | |
165 | ||
166 | #define SYM_BITS4_INDEX_SH_LEFT_BIG 0 | |
167 | #define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12 | |
168 | ||
169 | /* External symbol external record */ | |
170 | ||
171 | struct ext_ext { | |
6b6cc3fd JG |
172 | unsigned char es_bits1[1]; |
173 | unsigned char es_bits2[1]; | |
174 | unsigned char es_ifd[2]; | |
a0b23459 JG |
175 | struct sym_ext es_asym; |
176 | }; | |
177 | ||
178 | #define EXT_BITS1_JMPTBL_BIG 0x80 | |
179 | #define EXT_BITS1_JMPTBL_LITTLE 0x01 | |
180 | ||
181 | #define EXT_BITS1_COBOL_MAIN_BIG 0x40 | |
182 | #define EXT_BITS1_COBOL_MAIN_LITTLE 0x02 | |
183 | ||
9e1cd294 JG |
184 | #define EXT_BITS1_WEAKEXT_BIG 0x20 |
185 | #define EXT_BITS1_WEAKEXT_LITTLE 0x04 | |
186 | ||
a0b23459 JG |
187 | /* Type information external record */ |
188 | ||
189 | struct tir_ext { | |
6b6cc3fd JG |
190 | unsigned char t_bits1[1]; |
191 | unsigned char t_tq45[1]; | |
192 | unsigned char t_tq01[1]; | |
193 | unsigned char t_tq23[1]; | |
a0b23459 JG |
194 | }; |
195 | ||
196 | #define TIR_BITS1_FBITFIELD_BIG 0x80 | |
197 | #define TIR_BITS1_FBITFIELD_LITTLE 0x01 | |
198 | ||
199 | #define TIR_BITS1_CONTINUED_BIG 0x40 | |
200 | #define TIR_BITS1_CONTINUED_LITTLE 0x02 | |
201 | ||
202 | #define TIR_BITS1_BT_BIG 0x3F | |
203 | #define TIR_BITS1_BT_SH_BIG 0 | |
204 | #define TIR_BITS1_BT_LITTLE 0xFC | |
205 | #define TIR_BITS1_BT_SH_LITTLE 2 | |
206 | ||
207 | #define TIR_BITS_TQ4_BIG 0xF0 | |
208 | #define TIR_BITS_TQ4_SH_BIG 4 | |
209 | #define TIR_BITS_TQ5_BIG 0x0F | |
210 | #define TIR_BITS_TQ5_SH_BIG 0 | |
211 | #define TIR_BITS_TQ4_LITTLE 0x0F | |
212 | #define TIR_BITS_TQ4_SH_LITTLE 0 | |
213 | #define TIR_BITS_TQ5_LITTLE 0xF0 | |
214 | #define TIR_BITS_TQ5_SH_LITTLE 4 | |
215 | ||
216 | #define TIR_BITS_TQ0_BIG 0xF0 | |
217 | #define TIR_BITS_TQ0_SH_BIG 4 | |
218 | #define TIR_BITS_TQ1_BIG 0x0F | |
219 | #define TIR_BITS_TQ1_SH_BIG 0 | |
220 | #define TIR_BITS_TQ0_LITTLE 0x0F | |
221 | #define TIR_BITS_TQ0_SH_LITTLE 0 | |
222 | #define TIR_BITS_TQ1_LITTLE 0xF0 | |
223 | #define TIR_BITS_TQ1_SH_LITTLE 4 | |
224 | ||
225 | #define TIR_BITS_TQ2_BIG 0xF0 | |
226 | #define TIR_BITS_TQ2_SH_BIG 4 | |
227 | #define TIR_BITS_TQ3_BIG 0x0F | |
228 | #define TIR_BITS_TQ3_SH_BIG 0 | |
229 | #define TIR_BITS_TQ2_LITTLE 0x0F | |
230 | #define TIR_BITS_TQ2_SH_LITTLE 0 | |
231 | #define TIR_BITS_TQ3_LITTLE 0xF0 | |
232 | #define TIR_BITS_TQ3_SH_LITTLE 4 | |
233 | ||
234 | ||
235 | /* Relative symbol external record */ | |
236 | ||
237 | struct rndx_ext { | |
6b6cc3fd | 238 | unsigned char r_bits[4]; |
a0b23459 JG |
239 | }; |
240 | ||
241 | #define RNDX_BITS0_RFD_SH_LEFT_BIG 4 | |
242 | #define RNDX_BITS1_RFD_BIG 0xF0 | |
243 | #define RNDX_BITS1_RFD_SH_BIG 4 | |
244 | ||
245 | #define RNDX_BITS0_RFD_SH_LEFT_LITTLE 0 | |
246 | #define RNDX_BITS1_RFD_LITTLE 0x0F | |
247 | #define RNDX_BITS1_RFD_SH_LEFT_LITTLE 8 | |
248 | ||
249 | #define RNDX_BITS1_INDEX_BIG 0x0F | |
250 | #define RNDX_BITS1_INDEX_SH_LEFT_BIG 16 | |
251 | #define RNDX_BITS2_INDEX_SH_LEFT_BIG 8 | |
252 | #define RNDX_BITS3_INDEX_SH_LEFT_BIG 0 | |
253 | ||
254 | #define RNDX_BITS1_INDEX_LITTLE 0xF0 | |
255 | #define RNDX_BITS1_INDEX_SH_LITTLE 4 | |
256 | #define RNDX_BITS2_INDEX_SH_LEFT_LITTLE 4 | |
257 | #define RNDX_BITS3_INDEX_SH_LEFT_LITTLE 12 | |
258 | ||
259 | ||
260 | /* Dense numbers external record */ | |
261 | ||
262 | struct dnr_ext { | |
6b6cc3fd JG |
263 | unsigned char d_rfd[4]; |
264 | unsigned char d_index[4]; | |
a0b23459 JG |
265 | }; |
266 | ||
267 | /* Auxliliary symbol information external record */ | |
268 | ||
269 | union aux_ext { | |
270 | struct tir_ext a_ti; | |
271 | struct rndx_ext a_rndx; | |
6b6cc3fd JG |
272 | unsigned char a_dnLow[4]; |
273 | unsigned char a_dnHigh[4]; | |
274 | unsigned char a_isym[4]; | |
275 | unsigned char a_iss[4]; | |
276 | unsigned char a_width[4]; | |
277 | unsigned char a_count[4]; | |
a0b23459 JG |
278 | }; |
279 | ||
280 | /* FIXME! These are copied from ../bfd/libbfd.h */ | |
57115f09 ILT |
281 | extern bfd_vma _do_getb32 PARAMS ((unsigned char *addr)); |
282 | extern bfd_vma _do_getl32 PARAMS ((unsigned char *addr)); | |
9387f834 ILT |
283 | extern void _do_putb32 PARAMS ((bfd_vma data, unsigned char *addr)); |
284 | extern void _do_putl32 PARAMS ((bfd_vma data, unsigned char *addr)); | |
285 | ||
286 | #define AUX_GET_ANY(bigend, ax, field) \ | |
287 | ((bigend) ? _do_getb32 ((ax)->field) : _do_getl32 ((ax)->field)) | |
288 | ||
289 | #define AUX_GET_DNLOW(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnLow) | |
290 | #define AUX_GET_DNHIGH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_dnHigh) | |
291 | #define AUX_GET_ISYM(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_isym) | |
292 | #define AUX_GET_ISS(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_iss) | |
293 | #define AUX_GET_WIDTH(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_width) | |
294 | #define AUX_GET_COUNT(bigend, ax) AUX_GET_ANY ((bigend), (ax), a_count) | |
295 | ||
296 | #define AUX_PUT_ANY(bigend, val, ax, field) \ | |
297 | ((bigend) \ | |
298 | ? _do_putb32 ((val), (ax)->field) \ | |
299 | : _do_putl32 ((val), (ax)->field)) | |
300 | ||
301 | #define AUX_PUT_DNLOW(bigend, val, ax) \ | |
302 | AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow) | |
303 | #define AUX_PUT_DNHIGH(bigend, val, ax) \ | |
304 | AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh) | |
305 | #define AUX_PUT_ISYM(bigend, val, ax) \ | |
306 | AUX_PUT_ANY ((bigend), (val), (ax), a_isym) | |
307 | #define AUX_PUT_ISS(bigend, val, ax) \ | |
308 | AUX_PUT_ANY ((bigend), (val), (ax), a_iss) | |
309 | #define AUX_PUT_WIDTH(bigend, val, ax) \ | |
310 | AUX_PUT_ANY ((bigend), (val), (ax), a_width) | |
311 | #define AUX_PUT_COUNT(bigend, val, ax) \ | |
312 | AUX_PUT_ANY ((bigend), (val), (ax), a_count) | |
bfa48904 JG |
313 | |
314 | /* Relative file descriptor */ | |
315 | ||
316 | struct rfd_ext { | |
6b6cc3fd | 317 | unsigned char rfd[4]; |
bfa48904 | 318 | }; |
57115f09 | 319 | |
9dcfbb67 ILT |
320 | /* Optimizer symbol external record */ |
321 | ||
322 | struct opt_ext { | |
323 | unsigned char o_bits1[1]; | |
324 | unsigned char o_bits2[1]; | |
325 | unsigned char o_bits3[1]; | |
326 | unsigned char o_bits4[1]; | |
327 | struct rndx_ext o_rndx; | |
328 | unsigned char o_offset[4]; | |
329 | }; | |
330 | ||
331 | #define OPT_BITS2_VALUE_SH_LEFT_BIG 16 | |
332 | #define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0 | |
333 | ||
334 | #define OPT_BITS3_VALUE_SH_LEFT_BIG 8 | |
335 | #define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8 | |
336 | ||
337 | #define OPT_BITS4_VALUE_SH_LEFT_BIG 0 | |
338 | #define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16 | |
339 | ||
57115f09 ILT |
340 | /* Prototypes for the swapping functions. These require that sym.h be |
341 | included before this file. */ | |
342 | extern void ecoff_swap_hdr_in PARAMS ((bfd *, struct hdr_ext *, HDRR *)); | |
9dcfbb67 | 343 | extern void ecoff_swap_hdr_out PARAMS ((bfd *, HDRR *, struct hdr_ext *)); |
57115f09 | 344 | extern void ecoff_swap_fdr_in PARAMS ((bfd *, struct fdr_ext *, FDR *)); |
9dcfbb67 | 345 | extern void ecoff_swap_fdr_out PARAMS ((bfd *, FDR *, struct fdr_ext *)); |
57115f09 | 346 | extern void ecoff_swap_pdr_in PARAMS ((bfd *, struct pdr_ext *, PDR *)); |
9dcfbb67 | 347 | extern void ecoff_swap_pdr_out PARAMS ((bfd *, PDR *, struct pdr_ext *)); |
57115f09 | 348 | extern void ecoff_swap_sym_in PARAMS ((bfd *, struct sym_ext *, SYMR *)); |
9dcfbb67 | 349 | extern void ecoff_swap_sym_out PARAMS ((bfd *, SYMR *, struct sym_ext *)); |
57115f09 | 350 | extern void ecoff_swap_ext_in PARAMS ((bfd *, struct ext_ext *, EXTR *)); |
9dcfbb67 ILT |
351 | extern void ecoff_swap_ext_out PARAMS ((bfd *, EXTR *, struct ext_ext *)); |
352 | extern void ecoff_swap_dnr_in PARAMS ((bfd *, struct dnr_ext *, DNR *)); | |
353 | extern void ecoff_swap_dnr_out PARAMS ((bfd *, DNR *, struct dnr_ext *)); | |
57115f09 | 354 | extern void ecoff_swap_tir_in PARAMS ((int bigend, struct tir_ext *, TIR *)); |
9387f834 | 355 | extern void ecoff_swap_tir_out PARAMS ((int bigend, TIR *, struct tir_ext *)); |
57115f09 ILT |
356 | extern void ecoff_swap_rndx_in PARAMS ((int bigend, struct rndx_ext *, |
357 | RNDXR *)); | |
9dcfbb67 ILT |
358 | extern void ecoff_swap_rndx_out PARAMS ((int bigend, RNDXR *, |
359 | struct rndx_ext *)); | |
57115f09 | 360 | extern void ecoff_swap_rfd_in PARAMS ((bfd *, struct rfd_ext *, RFDT *)); |
9dcfbb67 ILT |
361 | extern void ecoff_swap_rfd_out PARAMS ((bfd *, RFDT *, struct rfd_ext *)); |
362 | extern void ecoff_swap_opt_in PARAMS ((bfd *, struct opt_ext *, OPTR *)); | |
363 | extern void ecoff_swap_opt_out PARAMS ((bfd *, OPTR *, struct opt_ext *)); |