fix typo, added @table
[deliverable/binutils-gdb.git] / gdb / ecoff.c
1 /* Byte swap a symbol table in MIPS' format (Third-Eye).
2 Copyright 1992 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include "defs.h"
21 #include "bfd.h"
22 #define LANGUAGE_C /* Wierd MIPS crap */
23 #include "sym.h" /* MIPS symbols */
24 #include "symconst.h" /* MIPS symbols */
25 #include "coff/ecoff-ext.h" /* ECOFF external struct defns */
26
27 void
28 ecoff_swap_hdr_in (abfd, ext_copy, intern)
29 bfd *abfd;
30 struct hdr_ext *ext_copy;
31 HDRR *intern;
32 {
33 struct hdr_ext ext[1];
34
35 *ext = *ext_copy;
36
37 intern->magic = bfd_h_get_16 (abfd, (bfd_byte *)ext->h_magic);
38 intern->vstamp = bfd_h_get_16 (abfd, (bfd_byte *)ext->h_vstamp);
39 intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
40 intern->cbLine = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbLine);
41 intern->cbLineOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbLineOffset);
42 intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
43 intern->cbDnOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbDnOffset);
44 intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
45 intern->cbPdOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbPdOffset);
46 intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
47 intern->cbSymOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbSymOffset);
48 intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
49 intern->cbOptOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbOptOffset);
50 intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
51 intern->cbAuxOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbAuxOffset);
52 intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
53 intern->cbSsOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbSsOffset);
54 intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
55 intern->cbSsExtOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
56 intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
57 intern->cbFdOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbFdOffset);
58 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
59 intern->cbRfdOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbRfdOffset);
60 intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
61 intern->cbExtOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbExtOffset);
62
63 #ifdef TEST
64 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
65 abort();
66 #endif
67 }
68
69 /* Swap in the file descriptor record. */
70
71 void
72 ecoff_swap_fdr_in (abfd, ext_copy, intern)
73 bfd *abfd;
74 struct fdr_ext *ext_copy;
75 FDR *intern;
76 {
77 struct fdr_ext ext[1];
78
79 *ext = *ext_copy; /* Make it reasonable to do in-place. */
80
81 intern->adr = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_adr);
82 intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
83 intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
84 intern->cbSs = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cbSs);
85 intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
86 intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
87 intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
88 intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
89 intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
90 intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
91 intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
92 intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
93 intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
94 intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
95 intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
96 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
97
98 /* now the fun stuff... */
99 if (abfd->xvec->header_byteorder_big_p != false) {
100 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
101 >> FDR_BITS1_LANG_SH_BIG;
102 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
103 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
104 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
105 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
106 >> FDR_BITS2_GLEVEL_SH_BIG;
107 /* intern->reserved we ignore. */
108 } else {
109 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
110 >> FDR_BITS1_LANG_SH_LITTLE;
111 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
112 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
113 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
114 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
115 >> FDR_BITS2_GLEVEL_SH_LITTLE;
116 /* intern->reserved we ignore. */
117 }
118
119 intern->cbLineOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cbLineOffset);
120 intern->cbLine = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cbLine);
121
122 #ifdef TEST
123 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
124 abort();
125 #endif
126 }
127
128
129
130 /* Swap in the procedure descriptor record. */
131
132 void
133 ecoff_swap_pdr_in (abfd, ext_copy, intern)
134 bfd *abfd;
135 struct pdr_ext *ext_copy;
136 PDR *intern;
137 {
138 struct pdr_ext ext[1];
139
140 *ext = *ext_copy; /* Make it reasonable to do in-place. */
141
142 intern->adr = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_adr);
143 intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
144 intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
145 intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
146 intern->regoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regoffset);
147 intern->iopt = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iopt);
148 intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
149 intern->fregoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregoffset);
150 intern->frameoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_frameoffset);
151 intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
152 intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
153 intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
154 intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
155 intern->cbLineOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_cbLineOffset);
156
157 #ifdef TEST
158 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
159 abort();
160 #endif
161 }
162
163
164 /* Swap in a symbol record. */
165
166 void
167 ecoff_swap_sym_in (abfd, ext_copy, intern)
168 bfd *abfd;
169 struct sym_ext *ext_copy;
170 SYMR *intern;
171 {
172 struct sym_ext ext[1];
173
174 *ext = *ext_copy; /* Make it reasonable to do in-place. */
175
176 intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
177 intern->value = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_value);
178
179 /* now the fun stuff... */
180 if (abfd->xvec->header_byteorder_big_p != false) {
181 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
182 >> SYM_BITS1_ST_SH_BIG;
183 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
184 << SYM_BITS1_SC_SH_LEFT_BIG)
185 | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
186 >> SYM_BITS2_SC_SH_BIG);
187 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
188 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
189 << SYM_BITS2_INDEX_SH_LEFT_BIG)
190 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
191 | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
192 } else {
193 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
194 >> SYM_BITS1_ST_SH_LITTLE;
195 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
196 >> SYM_BITS1_SC_SH_LITTLE)
197 | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
198 << SYM_BITS2_SC_SH_LEFT_LITTLE);
199 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
200 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
201 >> SYM_BITS2_INDEX_SH_LITTLE)
202 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
203 | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
204 }
205
206 #ifdef TEST
207 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
208 abort();
209 #endif
210 }
211
212
213 /* Swap in an external symbol record. */
214
215 void
216 ecoff_swap_ext_in (abfd, ext_copy, intern)
217 bfd *abfd;
218 struct ext_ext *ext_copy;
219 EXTR *intern;
220 {
221 struct ext_ext ext[1];
222
223 *ext = *ext_copy; /* Make it reasonable to do in-place. */
224
225 /* now the fun stuff... */
226 if (abfd->xvec->header_byteorder_big_p != false) {
227 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
228 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
229 } else {
230 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
231 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
232 }
233
234 intern->ifd = bfd_h_get_16 (abfd, (bfd_byte *)ext->es_ifd);
235 ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
236
237 #ifdef TEST
238 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
239 abort();
240 #endif
241 }
242
243 /* Swap in a type information record.
244 BIGEND says whether AUX symbols are big-endian or little-endian; this
245 info comes from the file header record (fh-fBigendian). */
246
247 void
248 ecoff_swap_tir_in (bigend, ext_copy, intern)
249 int bigend;
250 struct tir_ext *ext_copy;
251 TIR *intern;
252 {
253 struct tir_ext ext[1];
254
255 *ext = *ext_copy; /* Make it reasonable to do in-place. */
256
257 /* now the fun stuff... */
258 if (bigend) {
259 intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
260 intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
261 intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
262 >> TIR_BITS1_BT_SH_BIG;
263 intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
264 >> TIR_BITS_TQ4_SH_BIG;
265 intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
266 >> TIR_BITS_TQ5_SH_BIG;
267 intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
268 >> TIR_BITS_TQ0_SH_BIG;
269 intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
270 >> TIR_BITS_TQ1_SH_BIG;
271 intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
272 >> TIR_BITS_TQ2_SH_BIG;
273 intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
274 >> TIR_BITS_TQ3_SH_BIG;
275 } else {
276 intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
277 intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
278 intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
279 >> TIR_BITS1_BT_SH_LITTLE;
280 intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
281 >> TIR_BITS_TQ4_SH_LITTLE;
282 intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
283 >> TIR_BITS_TQ5_SH_LITTLE;
284 intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
285 >> TIR_BITS_TQ0_SH_LITTLE;
286 intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
287 >> TIR_BITS_TQ1_SH_LITTLE;
288 intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
289 >> TIR_BITS_TQ2_SH_LITTLE;
290 intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
291 >> TIR_BITS_TQ3_SH_LITTLE;
292 }
293
294 #ifdef TEST
295 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
296 abort();
297 #endif
298 }
299
300 /* Swap in a relative symbol record. BIGEND says whether it is in
301 big-endian or little-endian format.*/
302
303 void
304 ecoff_swap_rndx_in (bigend, ext_copy, intern)
305 int bigend;
306 struct rndx_ext *ext_copy;
307 RNDXR *intern;
308 {
309 struct rndx_ext ext[1];
310
311 *ext = *ext_copy; /* Make it reasonable to do in-place. */
312
313 /* now the fun stuff... */
314 if (bigend) {
315 intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
316 | ((ext->r_bits[1] & RNDX_BITS1_RFD_BIG)
317 >> RNDX_BITS1_RFD_SH_BIG);
318 intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
319 << RNDX_BITS1_INDEX_SH_LEFT_BIG)
320 | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG)
321 | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG);
322 } else {
323 intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
324 | ((ext->r_bits[1] & RNDX_BITS1_RFD_LITTLE)
325 << RNDX_BITS1_RFD_SH_LEFT_LITTLE);
326 intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
327 >> RNDX_BITS1_INDEX_SH_LITTLE)
328 | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
329 | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
330 }
331
332 #ifdef TEST
333 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
334 abort();
335 #endif
336 }
This page took 0.037096 seconds and 4 git commands to generate.