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 _bfd_ecoff_swap_tir_in
57 PARAMS ((int, const struct tir_ext *, TIR *));
58 extern void _bfd_ecoff_swap_tir_out
59 PARAMS ((int, const TIR *, struct tir_ext *));
60 extern void _bfd_ecoff_swap_rndx_in
61 PARAMS ((int, const struct rndx_ext *, RNDXR *));
62 extern void _bfd_ecoff_swap_rndx_out
63 PARAMS ((int, const RNDXR *, struct rndx_ext *));
65 /* Swap in the symbolic header. */
68 ecoff_swap_hdr_in (abfd, ext_copy, intern)
73 struct hdr_ext ext[1];
75 *ext = *(struct hdr_ext *) ext_copy;
77 intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic);
78 intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp);
79 intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
80 intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine);
81 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset);
82 intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
83 intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset);
84 intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
85 intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset);
86 intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
87 intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset);
88 intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
89 intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset);
90 intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
91 intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset);
92 intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
93 intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset);
94 intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
95 intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
96 intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
97 intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset);
98 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
99 intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset);
100 intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
101 intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset);
104 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
109 /* Swap out the symbolic header. */
112 ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr)
114 const HDRR *intern_copy;
117 struct hdr_ext *ext = (struct hdr_ext *) ext_ptr;
120 *intern = *intern_copy;
122 bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
123 bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
124 bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
125 ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
126 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
127 bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
128 ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
129 bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
130 ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
131 bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
132 ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
133 bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
134 ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
135 bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
136 ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
137 bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
138 ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
139 bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
140 ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
141 bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
142 ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
143 bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
144 ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
145 bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
146 ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
149 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
154 /* Swap in the file descriptor record. */
157 ecoff_swap_fdr_in (abfd, ext_copy, intern)
162 struct fdr_ext ext[1];
164 *ext = *(struct fdr_ext *) ext_copy;
166 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr);
167 intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
168 intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
169 intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs);
170 intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
171 intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
172 intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
173 intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
174 intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
175 intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
177 intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
178 intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
181 intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst);
182 intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd);
184 intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
185 intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
186 intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
187 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
189 /* now the fun stuff... */
190 if (abfd->xvec->header_byteorder_big_p != false) {
191 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
192 >> FDR_BITS1_LANG_SH_BIG;
193 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
194 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
195 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
196 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
197 >> FDR_BITS2_GLEVEL_SH_BIG;
199 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
200 >> FDR_BITS1_LANG_SH_LITTLE;
201 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
202 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
203 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
204 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
205 >> FDR_BITS2_GLEVEL_SH_LITTLE;
207 intern->reserved = 0;
209 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset);
210 intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine);
213 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
218 /* Swap out the file descriptor record. */
221 ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr)
223 const FDR *intern_copy;
226 struct fdr_ext *ext = (struct fdr_ext *) ext_ptr;
229 *intern = *intern_copy; /* Make it reasonable to do in-place. */
231 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr);
232 bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
233 bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
234 ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
235 bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
236 bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
237 bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
238 bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
239 bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
240 bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
242 bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
243 bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
246 bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
247 bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
249 bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
250 bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
251 bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
252 bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
254 /* now the fun stuff... */
255 if (abfd->xvec->header_byteorder_big_p != false) {
256 ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
257 & FDR_BITS1_LANG_BIG)
258 | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
259 | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
260 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
261 ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
262 & FDR_BITS2_GLEVEL_BIG);
266 ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
267 & FDR_BITS1_LANG_LITTLE)
268 | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
269 | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
270 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
271 ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
272 & FDR_BITS2_GLEVEL_LITTLE);
277 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
278 ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
281 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
286 /* start-sanitize-mpw */
288 /* end-sanitize-mpw */
289 /* Swap in the procedure descriptor record. */
292 ecoff_swap_pdr_in (abfd, ext_copy, intern)
297 struct pdr_ext ext[1];
299 *ext = *(struct pdr_ext *) ext_copy;
301 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
302 intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
303 intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
304 intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
305 intern->regoffset = bfd_h_get_signed_32 (abfd,
306 (bfd_byte *)ext->p_regoffset);
307 intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
308 intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
309 intern->fregoffset = bfd_h_get_signed_32 (abfd,
310 (bfd_byte *)ext->p_fregoffset);
311 intern->frameoffset = bfd_h_get_signed_32 (abfd,
312 (bfd_byte *)ext->p_frameoffset);
313 intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
314 intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
315 intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
316 intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
317 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
320 intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue);
321 if (abfd->xvec->header_byteorder_big_p != false)
323 intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG);
324 intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG);
325 intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_BIG);
326 intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG)
327 << PDR_BITS1_RESERVED_SH_LEFT_BIG)
328 | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG)
329 >> PDR_BITS2_RESERVED_SH_BIG));
333 intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE);
334 intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE);
335 intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_LITTLE);
336 intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE)
337 >> PDR_BITS1_RESERVED_SH_LITTLE)
338 | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE)
339 << PDR_BITS2_RESERVED_SH_LEFT_LITTLE));
341 intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff);
345 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
350 /* Swap out the procedure descriptor record. */
353 ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
355 const PDR *intern_copy;
358 struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
361 *intern = *intern_copy; /* Make it reasonable to do in-place. */
363 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
364 bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
365 bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
366 bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
367 bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
368 bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
369 bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
370 bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
371 bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
372 bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
373 bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
374 bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
375 bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
376 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
379 bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue);
380 if (abfd->xvec->header_byteorder_big_p != false)
382 ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0)
383 | (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0)
384 | (intern->prof ? PDR_BITS1_PROF_BIG : 0)
386 >> PDR_BITS1_RESERVED_SH_LEFT_BIG)
387 & PDR_BITS1_RESERVED_BIG));
388 ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG)
389 & PDR_BITS2_RESERVED_BIG);
393 ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0)
394 | (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0)
395 | (intern->prof ? PDR_BITS1_PROF_LITTLE : 0)
396 | ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE)
397 & PDR_BITS1_RESERVED_LITTLE));
398 ext->p_bits2[0] = ((intern->reserved >>
399 PDR_BITS2_RESERVED_SH_LEFT_LITTLE)
400 & PDR_BITS2_RESERVED_LITTLE);
402 bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff);
406 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
410 /* start-sanitize-mpw */
412 /* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't
413 corrupt itself and then freak out. */
414 /* Swap in the procedure descriptor record. */
417 ecoff_swap_pdr_in (abfd, ext_copy, intern)
422 struct pdr_ext ext[1];
424 *ext = *(struct pdr_ext *) ext_copy;
426 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
427 intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
428 intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
429 intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
430 intern->regoffset = bfd_h_get_signed_32 (abfd,
431 (bfd_byte *)ext->p_regoffset);
432 intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
433 intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
434 intern->fregoffset = bfd_h_get_signed_32 (abfd,
435 (bfd_byte *)ext->p_fregoffset);
436 intern->frameoffset = bfd_h_get_signed_32 (abfd,
437 (bfd_byte *)ext->p_frameoffset);
438 intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
439 intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
440 intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
441 intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
442 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
445 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
450 /* Swap out the procedure descriptor record. */
453 ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
455 const PDR *intern_copy;
458 struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
461 *intern = *intern_copy; /* Make it reasonable to do in-place. */
463 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
464 bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
465 bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
466 bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
467 bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
468 bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
469 bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
470 bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
471 bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
472 bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
473 bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
474 bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
475 bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
476 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
479 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
484 /* end-sanitize-mpw */
486 /* Swap in a symbol record. */
489 ecoff_swap_sym_in (abfd, ext_copy, intern)
494 struct sym_ext ext[1];
496 *ext = *(struct sym_ext *) ext_copy;
498 intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
499 intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value);
501 /* now the fun stuff... */
502 if (abfd->xvec->header_byteorder_big_p != false) {
503 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
504 >> SYM_BITS1_ST_SH_BIG;
505 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
506 << SYM_BITS1_SC_SH_LEFT_BIG)
507 | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
508 >> SYM_BITS2_SC_SH_BIG);
509 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
510 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
511 << SYM_BITS2_INDEX_SH_LEFT_BIG)
512 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
513 | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
515 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
516 >> SYM_BITS1_ST_SH_LITTLE;
517 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
518 >> SYM_BITS1_SC_SH_LITTLE)
519 | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
520 << SYM_BITS2_SC_SH_LEFT_LITTLE);
521 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
522 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
523 >> SYM_BITS2_INDEX_SH_LITTLE)
524 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
525 | ((unsigned int) ext->s_bits4[0]
526 << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
530 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
535 /* Swap out a symbol record. */
538 ecoff_swap_sym_out (abfd, intern_copy, ext_ptr)
540 const SYMR *intern_copy;
543 struct sym_ext *ext = (struct sym_ext *) ext_ptr;
546 *intern = *intern_copy; /* Make it reasonable to do in-place. */
548 bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
549 ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value);
551 /* now the fun stuff... */
552 if (abfd->xvec->header_byteorder_big_p != false) {
553 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
555 | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
556 & SYM_BITS1_SC_BIG));
557 ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
559 | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
560 | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
561 & SYM_BITS2_INDEX_BIG));
562 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
563 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
565 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
566 & SYM_BITS1_ST_LITTLE)
567 | ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
568 & SYM_BITS1_SC_LITTLE));
569 ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
570 & SYM_BITS2_SC_LITTLE)
571 | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
572 | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
573 & SYM_BITS2_INDEX_LITTLE));
574 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
575 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
579 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
584 /* Swap in an external symbol record. */
587 ecoff_swap_ext_in (abfd, ext_copy, intern)
592 struct ext_ext ext[1];
594 *ext = *(struct ext_ext *) ext_copy;
596 /* now the fun stuff... */
597 if (abfd->xvec->header_byteorder_big_p != false) {
598 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
599 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
600 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
602 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
603 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
604 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
606 intern->reserved = 0;
609 intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd);
612 intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd);
615 ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
618 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
623 /* Swap out an external symbol record. */
626 ecoff_swap_ext_out (abfd, intern_copy, ext_ptr)
628 const EXTR *intern_copy;
631 struct ext_ext *ext = (struct ext_ext *) ext_ptr;
634 *intern = *intern_copy; /* Make it reasonable to do in-place. */
636 /* now the fun stuff... */
637 if (abfd->xvec->header_byteorder_big_p != false) {
638 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
639 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
640 | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
641 ext->es_bits2[0] = 0;
643 ext->es_bits2[1] = 0;
644 ext->es_bits2[2] = 0;
647 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
648 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
649 | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
650 ext->es_bits2[0] = 0;
652 ext->es_bits2[1] = 0;
653 ext->es_bits2[2] = 0;
658 bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
661 bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
664 ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
667 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
672 /* Swap in a relative file descriptor. */
675 ecoff_swap_rfd_in (abfd, ext_ptr, intern)
680 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
682 *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
685 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
690 /* Swap out a relative file descriptor. */
693 ecoff_swap_rfd_out (abfd, intern, ext_ptr)
698 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
700 bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
703 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
708 /* Swap in an optimization symbol. */
711 ecoff_swap_opt_in (abfd, ext_copy, intern)
716 struct opt_ext ext[1];
718 *ext = *(struct opt_ext *) ext_copy;
720 if (abfd->xvec->header_byteorder_big_p != false)
722 intern->ot = ext->o_bits1[0];
723 intern->value = (((unsigned int) ext->o_bits2[0]
724 << OPT_BITS2_VALUE_SH_LEFT_BIG)
725 | ((unsigned int) ext->o_bits3[0]
726 << OPT_BITS2_VALUE_SH_LEFT_BIG)
727 | ((unsigned int) ext->o_bits4[0]
728 << OPT_BITS2_VALUE_SH_LEFT_BIG));
732 intern->ot = ext->o_bits1[0];
733 intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
734 | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
735 | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
738 _bfd_ecoff_swap_rndx_in (abfd->xvec->header_byteorder_big_p != false,
739 &ext->o_rndx, &intern->rndx);
741 intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
744 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
749 /* Swap out an optimization symbol. */
752 ecoff_swap_opt_out (abfd, intern_copy, ext_ptr)
754 const OPTR *intern_copy;
757 struct opt_ext *ext = (struct opt_ext *) ext_ptr;
760 *intern = *intern_copy; /* Make it reasonable to do in-place. */
762 if (abfd->xvec->header_byteorder_big_p != false)
764 ext->o_bits1[0] = intern->ot;
765 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
766 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
767 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
771 ext->o_bits1[0] = intern->ot;
772 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
773 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
774 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
777 _bfd_ecoff_swap_rndx_out (abfd->xvec->header_byteorder_big_p != false,
778 &intern->rndx, &ext->o_rndx);
780 bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
783 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
788 /* Swap in a dense number. */
791 ecoff_swap_dnr_in (abfd, ext_copy, intern)
796 struct dnr_ext ext[1];
798 *ext = *(struct dnr_ext *) ext_copy;
800 intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
801 intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
804 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
809 /* Swap out a dense number. */
812 ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr)
814 const DNR *intern_copy;
817 struct dnr_ext *ext = (struct dnr_ext *) ext_ptr;
820 *intern = *intern_copy; /* Make it reasonable to do in-place. */
822 bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
823 bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
826 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)