1 /* Generic ECOFF swapping routines, for BFD.
2 Copyright 1992, 1993 Free Software Foundation, Inc.
3 Written by Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
21 /* NOTE: This is a header file, but it contains executable routines.
22 This is done this way because these routines are substantially
23 similar, but are not identical, for all ECOFF targets.
25 These are routines to swap the ECOFF symbolic information in and
26 out. The routines are defined statically. You can set breakpoints
27 on them in gdb by naming the including source file; e.g.,
28 'coff-mips.c':ecoff_swap_hdr_in.
30 Before including this header file, one of ECOFF_32 or ECOFF_64 must
31 be defined. These are checked when swapping information that
32 depends upon the target size. This code works for 32 bit and 64
33 bit ECOFF, but may need to be generalized in the future.
35 Some header file which defines the external forms of these
36 structures must also be included before including this header file.
37 Currently this is either coff/mips.h or coff/alpha.h.
39 If the symbol TEST is defined when this file is compiled, a
40 comparison is made to ensure that, in fact, the output is
41 bit-for-bit the same as the input. Of course, this symbol should
42 only be defined when deliberately testing the code on a machine
43 with the proper byte sex and such. */
46 #define ecoff_get_off bfd_h_get_32
47 #define ecoff_put_off bfd_h_put_32
50 #define ecoff_get_off bfd_h_get_64
51 #define ecoff_put_off bfd_h_put_64
54 /* ECOFF auxiliary information swapping routines. These are the same
55 for all ECOFF targets, so they are defined in ecoff.c. */
56 extern void ecoff_swap_tir_in PARAMS ((int, const struct tir_ext *, TIR *));
57 extern void ecoff_swap_tir_out PARAMS ((int, const TIR *, struct tir_ext *));
58 extern void ecoff_swap_rndx_in PARAMS ((int, const struct rndx_ext *,
60 extern void ecoff_swap_rndx_out PARAMS ((int, const RNDXR *,
63 /* Swap in the symbolic header. */
66 ecoff_swap_hdr_in (abfd, ext_copy, intern)
71 struct hdr_ext ext[1];
73 *ext = *(struct hdr_ext *) ext_copy;
75 intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic);
76 intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp);
77 intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
78 intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine);
79 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset);
80 intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
81 intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset);
82 intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
83 intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset);
84 intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
85 intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset);
86 intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
87 intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset);
88 intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
89 intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset);
90 intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
91 intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset);
92 intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
93 intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
94 intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
95 intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset);
96 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
97 intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset);
98 intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
99 intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset);
102 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
107 /* Swap out the symbolic header. */
110 ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr)
112 const HDRR *intern_copy;
115 struct hdr_ext *ext = (struct hdr_ext *) ext_ptr;
118 *intern = *intern_copy;
120 bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
121 bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
122 bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
123 ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
124 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
125 bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
126 ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
127 bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
128 ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
129 bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
130 ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
131 bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
132 ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
133 bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
134 ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
135 bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
136 ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
137 bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
138 ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
139 bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
140 ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
141 bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
142 ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
143 bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
144 ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
147 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
152 /* Swap in the file descriptor record. */
155 ecoff_swap_fdr_in (abfd, ext_copy, intern)
160 struct fdr_ext ext[1];
162 *ext = *(struct fdr_ext *) ext_copy;
164 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr);
165 intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
166 intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
167 intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs);
168 intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
169 intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
170 intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
171 intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
172 intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
173 intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
175 intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
176 intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
179 intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst);
180 intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd);
182 intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
183 intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
184 intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
185 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
187 /* now the fun stuff... */
188 if (abfd->xvec->header_byteorder_big_p != false) {
189 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
190 >> FDR_BITS1_LANG_SH_BIG;
191 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
192 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
193 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
194 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
195 >> FDR_BITS2_GLEVEL_SH_BIG;
197 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
198 >> FDR_BITS1_LANG_SH_LITTLE;
199 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
200 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
201 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
202 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
203 >> FDR_BITS2_GLEVEL_SH_LITTLE;
205 intern->reserved = 0;
207 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset);
208 intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine);
211 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
216 /* Swap out the file descriptor record. */
219 ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr)
221 const FDR *intern_copy;
224 struct fdr_ext *ext = (struct fdr_ext *) ext_ptr;
227 *intern = *intern_copy; /* Make it reasonable to do in-place. */
229 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr);
230 bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
231 bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
232 ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
233 bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
234 bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
235 bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
236 bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
237 bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
238 bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
240 bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
241 bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
244 bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
245 bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
247 bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
248 bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
249 bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
250 bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
252 /* now the fun stuff... */
253 if (abfd->xvec->header_byteorder_big_p != false) {
254 ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
255 & FDR_BITS1_LANG_BIG)
256 | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
257 | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
258 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
259 ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
260 & FDR_BITS2_GLEVEL_BIG);
264 ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
265 & FDR_BITS1_LANG_LITTLE)
266 | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
267 | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
268 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
269 ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
270 & FDR_BITS2_GLEVEL_LITTLE);
275 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
276 ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
279 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
284 /* Swap in the procedure descriptor record. */
287 ecoff_swap_pdr_in (abfd, ext_copy, intern)
292 struct pdr_ext ext[1];
294 *ext = *(struct pdr_ext *) ext_copy;
296 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
297 intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
298 intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
299 intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
300 intern->regoffset = bfd_h_get_signed_32 (abfd,
301 (bfd_byte *)ext->p_regoffset);
302 intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
303 intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
304 intern->fregoffset = bfd_h_get_signed_32 (abfd,
305 (bfd_byte *)ext->p_fregoffset);
306 intern->frameoffset = bfd_h_get_signed_32 (abfd,
307 (bfd_byte *)ext->p_frameoffset);
308 intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
309 intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
310 intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
311 intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
312 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
315 intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue);
316 if (abfd->xvec->header_byteorder_big_p != false)
318 intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG);
319 intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG);
320 intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG)
321 << PDR_BITS1_RESERVED_SH_LEFT_BIG)
322 | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG)
323 >> PDR_BITS2_RESERVED_SH_BIG));
327 intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE);
328 intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE);
329 intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE)
330 >> PDR_BITS1_RESERVED_SH_LITTLE)
331 | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE)
332 << PDR_BITS2_RESERVED_SH_LEFT_LITTLE));
334 intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff);
338 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
343 /* Swap out the procedure descriptor record. */
346 ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
348 const PDR *intern_copy;
351 struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
354 *intern = *intern_copy; /* Make it reasonable to do in-place. */
356 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
357 bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
358 bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
359 bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
360 bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
361 bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
362 bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
363 bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
364 bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
365 bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
366 bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
367 bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
368 bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
369 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
372 bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue);
373 if (abfd->xvec->header_byteorder_big_p != false)
375 ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0)
376 | (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0)
378 >> PDR_BITS1_RESERVED_SH_LEFT_BIG)
379 & PDR_BITS1_RESERVED_BIG));
380 ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG)
381 & PDR_BITS2_RESERVED_BIG);
385 ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0)
386 | (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0)
387 | ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE)
388 & PDR_BITS1_RESERVED_LITTLE));
389 ext->p_bits2[0] = ((intern->reserved >>
390 PDR_BITS2_RESERVED_SH_LEFT_LITTLE)
391 & PDR_BITS2_RESERVED_LITTLE);
393 bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff);
397 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
402 /* Swap in a symbol record. */
405 ecoff_swap_sym_in (abfd, ext_copy, intern)
410 struct sym_ext ext[1];
412 *ext = *(struct sym_ext *) ext_copy;
414 intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
415 intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value);
417 /* now the fun stuff... */
418 if (abfd->xvec->header_byteorder_big_p != false) {
419 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
420 >> SYM_BITS1_ST_SH_BIG;
421 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
422 << SYM_BITS1_SC_SH_LEFT_BIG)
423 | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
424 >> SYM_BITS2_SC_SH_BIG);
425 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
426 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
427 << SYM_BITS2_INDEX_SH_LEFT_BIG)
428 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
429 | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
431 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
432 >> SYM_BITS1_ST_SH_LITTLE;
433 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
434 >> SYM_BITS1_SC_SH_LITTLE)
435 | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
436 << SYM_BITS2_SC_SH_LEFT_LITTLE);
437 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
438 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
439 >> SYM_BITS2_INDEX_SH_LITTLE)
440 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
441 | ((unsigned int) ext->s_bits4[0]
442 << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
446 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
451 /* Swap out a symbol record. */
454 ecoff_swap_sym_out (abfd, intern_copy, ext_ptr)
456 const SYMR *intern_copy;
459 struct sym_ext *ext = (struct sym_ext *) ext_ptr;
462 *intern = *intern_copy; /* Make it reasonable to do in-place. */
464 bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
465 ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value);
467 /* now the fun stuff... */
468 if (abfd->xvec->header_byteorder_big_p != false) {
469 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
471 | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
472 & SYM_BITS1_SC_BIG));
473 ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
475 | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
476 | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
477 & SYM_BITS2_INDEX_BIG));
478 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
479 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
481 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
482 & SYM_BITS1_ST_LITTLE)
483 | ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
484 & SYM_BITS1_SC_LITTLE));
485 ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
486 & SYM_BITS2_SC_LITTLE)
487 | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
488 | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
489 & SYM_BITS2_INDEX_LITTLE));
490 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
491 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
495 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
500 /* Swap in an external symbol record. */
503 ecoff_swap_ext_in (abfd, ext_copy, intern)
508 struct ext_ext ext[1];
510 *ext = *(struct ext_ext *) ext_copy;
512 /* now the fun stuff... */
513 if (abfd->xvec->header_byteorder_big_p != false) {
514 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
515 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
516 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
518 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
519 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
520 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
522 intern->reserved = 0;
525 intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd);
528 intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd);
531 ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
534 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
539 /* Swap out an external symbol record. */
542 ecoff_swap_ext_out (abfd, intern_copy, ext_ptr)
544 const EXTR *intern_copy;
547 struct ext_ext *ext = (struct ext_ext *) ext_ptr;
550 *intern = *intern_copy; /* Make it reasonable to do in-place. */
552 /* now the fun stuff... */
553 if (abfd->xvec->header_byteorder_big_p != false) {
554 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
555 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
556 | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
557 ext->es_bits2[0] = 0;
559 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
560 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
561 | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
562 ext->es_bits2[0] = 0;
566 bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
569 bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
572 ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
575 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
580 /* Swap in a relative file descriptor. */
583 ecoff_swap_rfd_in (abfd, ext_ptr, intern)
588 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
590 *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
593 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
598 /* Swap out a relative file descriptor. */
601 ecoff_swap_rfd_out (abfd, intern, ext_ptr)
606 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
608 bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
611 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
616 /* Swap in an optimization symbol. */
619 ecoff_swap_opt_in (abfd, ext_copy, intern)
624 struct opt_ext ext[1];
626 *ext = *(struct opt_ext *) ext_copy;
628 if (abfd->xvec->header_byteorder_big_p != false)
630 intern->ot = ext->o_bits1[0];
631 intern->value = (((unsigned int) ext->o_bits2[0]
632 << OPT_BITS2_VALUE_SH_LEFT_BIG)
633 | ((unsigned int) ext->o_bits3[0]
634 << OPT_BITS2_VALUE_SH_LEFT_BIG)
635 | ((unsigned int) ext->o_bits4[0]
636 << OPT_BITS2_VALUE_SH_LEFT_BIG));
640 intern->ot = ext->o_bits1[0];
641 intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
642 | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
643 | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
646 ecoff_swap_rndx_in (abfd->xvec->header_byteorder_big_p != false,
647 &ext->o_rndx, &intern->rndx);
649 intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
652 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
657 /* Swap out an optimization symbol. */
660 ecoff_swap_opt_out (abfd, intern_copy, ext_ptr)
662 const OPTR *intern_copy;
665 struct opt_ext *ext = (struct opt_ext *) ext_ptr;
668 *intern = *intern_copy; /* Make it reasonable to do in-place. */
670 if (abfd->xvec->header_byteorder_big_p != false)
672 ext->o_bits1[0] = intern->ot;
673 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
674 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
675 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
679 ext->o_bits1[0] = intern->ot;
680 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
681 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
682 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
685 ecoff_swap_rndx_out (abfd->xvec->header_byteorder_big_p != false,
686 &intern->rndx, &ext->o_rndx);
688 bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
691 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
696 /* Swap in a dense number. */
699 ecoff_swap_dnr_in (abfd, ext_copy, intern)
704 struct dnr_ext ext[1];
706 *ext = *(struct dnr_ext *) ext_copy;
708 intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
709 intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
712 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
717 /* Swap out a dense number. */
720 ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr)
722 const DNR *intern_copy;
725 struct dnr_ext *ext = (struct dnr_ext *) ext_ptr;
728 *intern = *intern_copy; /* Make it reasonable to do in-place. */
730 bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
731 bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
734 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)