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 /* Swap in the symbolic header. */
57 ecoff_swap_hdr_in (abfd, ext_copy, intern)
62 struct hdr_ext ext[1];
64 *ext = *(struct hdr_ext *) ext_copy;
66 intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic);
67 intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp);
68 intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
69 intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine);
70 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset);
71 intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
72 intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset);
73 intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
74 intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset);
75 intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
76 intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset);
77 intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
78 intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset);
79 intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
80 intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset);
81 intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
82 intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset);
83 intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
84 intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
85 intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
86 intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset);
87 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
88 intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset);
89 intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
90 intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset);
93 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
98 /* Swap out the symbolic header. */
101 ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr)
103 const HDRR *intern_copy;
106 struct hdr_ext *ext = (struct hdr_ext *) ext_ptr;
109 *intern = *intern_copy;
111 bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
112 bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
113 bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
114 ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
115 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
116 bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
117 ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
118 bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
119 ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
120 bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
121 ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
122 bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
123 ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
124 bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
125 ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
126 bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
127 ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
128 bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
129 ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
130 bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
131 ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
132 bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
133 ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
134 bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
135 ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
138 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
143 /* Swap in the file descriptor record. */
146 ecoff_swap_fdr_in (abfd, ext_copy, intern)
151 struct fdr_ext ext[1];
153 *ext = *(struct fdr_ext *) ext_copy;
155 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr);
156 intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
157 intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
158 intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs);
159 intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
160 intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
161 intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
162 intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
163 intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
164 intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
166 intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
167 intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
170 intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst);
171 intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd);
173 intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
174 intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
175 intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
176 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
178 /* now the fun stuff... */
179 if (abfd->xvec->header_byteorder_big_p != false) {
180 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
181 >> FDR_BITS1_LANG_SH_BIG;
182 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
183 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
184 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
185 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
186 >> FDR_BITS2_GLEVEL_SH_BIG;
188 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
189 >> FDR_BITS1_LANG_SH_LITTLE;
190 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
191 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
192 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
193 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
194 >> FDR_BITS2_GLEVEL_SH_LITTLE;
196 intern->reserved = 0;
198 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset);
199 intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine);
202 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
207 /* Swap out the file descriptor record. */
210 ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr)
215 struct fdr_ext *ext = (struct fdr_ext *) ext_ptr;
218 *intern = *intern_copy; /* Make it reasonable to do in-place. */
220 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr);
221 bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
222 bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
223 ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
224 bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
225 bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
226 bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
227 bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
228 bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
229 bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
231 bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
232 bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
235 bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
236 bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
238 bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
239 bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
240 bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
241 bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
243 /* now the fun stuff... */
244 if (abfd->xvec->header_byteorder_big_p != false) {
245 ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
246 & FDR_BITS1_LANG_BIG)
247 | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
248 | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
249 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
250 ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
251 & FDR_BITS2_GLEVEL_BIG);
255 ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
256 & FDR_BITS1_LANG_LITTLE)
257 | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
258 | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
259 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
260 ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
261 & FDR_BITS2_GLEVEL_LITTLE);
266 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
267 ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
270 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
275 /* Swap in the procedure descriptor record. */
278 ecoff_swap_pdr_in (abfd, ext_copy, intern)
283 struct pdr_ext ext[1];
285 *ext = *(struct pdr_ext *) ext_copy;
287 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
288 intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
289 intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
290 intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
291 intern->regoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regoffset);
292 intern->iopt = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iopt);
293 intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
294 intern->fregoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregoffset);
295 intern->frameoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_frameoffset);
296 intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
297 intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
298 intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
299 intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
300 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
303 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
308 /* Swap out the procedure descriptor record. */
311 ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
316 struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
319 *intern = *intern_copy; /* Make it reasonable to do in-place. */
321 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
322 bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
323 bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
324 bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
325 bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
326 bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
327 bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
328 bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
329 bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
330 bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
331 bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
332 bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
333 bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
334 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
337 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
342 /* Swap in a symbol record. */
345 ecoff_swap_sym_in (abfd, ext_copy, intern)
350 struct sym_ext ext[1];
352 *ext = *(struct sym_ext *) ext_copy;
354 intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
355 intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value);
357 /* now the fun stuff... */
358 if (abfd->xvec->header_byteorder_big_p != false) {
359 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
360 >> SYM_BITS1_ST_SH_BIG;
361 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
362 << SYM_BITS1_SC_SH_LEFT_BIG)
363 | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
364 >> SYM_BITS2_SC_SH_BIG);
365 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
366 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
367 << SYM_BITS2_INDEX_SH_LEFT_BIG)
368 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
369 | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
371 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
372 >> SYM_BITS1_ST_SH_LITTLE;
373 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
374 >> SYM_BITS1_SC_SH_LITTLE)
375 | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
376 << SYM_BITS2_SC_SH_LEFT_LITTLE);
377 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
378 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
379 >> SYM_BITS2_INDEX_SH_LITTLE)
380 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
381 | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
385 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
390 /* Swap out a symbol record. */
393 ecoff_swap_sym_out (abfd, intern_copy, ext_ptr)
398 struct sym_ext *ext = (struct sym_ext *) ext_ptr;
401 *intern = *intern_copy; /* Make it reasonable to do in-place. */
403 bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
404 ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value);
406 /* now the fun stuff... */
407 if (abfd->xvec->header_byteorder_big_p != false) {
408 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
410 | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
411 & SYM_BITS1_SC_BIG));
412 ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
414 | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
415 | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
416 & SYM_BITS2_INDEX_BIG));
417 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
418 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
420 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
421 & SYM_BITS1_ST_LITTLE)
422 | ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
423 & SYM_BITS1_SC_LITTLE));
424 ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
425 & SYM_BITS2_SC_LITTLE)
426 | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
427 | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
428 & SYM_BITS2_INDEX_LITTLE));
429 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
430 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
434 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
439 /* Swap in an external symbol record. */
442 ecoff_swap_ext_in (abfd, ext_copy, intern)
447 struct ext_ext ext[1];
449 *ext = *(struct ext_ext *) ext_copy;
451 /* now the fun stuff... */
452 if (abfd->xvec->header_byteorder_big_p != false) {
453 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
454 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
455 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
457 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
458 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
459 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
461 intern->reserved = 0;
464 intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd);
467 intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd);
470 ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
473 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
478 /* Swap out an external symbol record. */
481 ecoff_swap_ext_out (abfd, intern_copy, ext_ptr)
486 struct ext_ext *ext = (struct ext_ext *) ext_ptr;
489 *intern = *intern_copy; /* Make it reasonable to do in-place. */
491 /* now the fun stuff... */
492 if (abfd->xvec->header_byteorder_big_p != false) {
493 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
494 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
495 | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
496 ext->es_bits2[0] = 0;
498 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
499 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
500 | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
501 ext->es_bits2[0] = 0;
505 bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
508 bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
511 ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
514 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
519 /* Swap in a relative file descriptor. */
522 ecoff_swap_rfd_in (abfd, ext_ptr, intern)
527 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
529 *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
532 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
537 /* Swap out a relative file descriptor. */
540 ecoff_swap_rfd_out (abfd, intern, ext_ptr)
545 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
547 bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
550 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
555 /* Swap in an optimization symbol. */
558 ecoff_swap_opt_in (abfd, ext_copy, intern)
563 struct opt_ext ext[1];
565 *ext = *(struct opt_ext *) ext_copy;
567 if (abfd->xvec->header_byteorder_big_p != false)
569 intern->ot = ext->o_bits1[0];
570 intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_BIG)
571 | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_BIG)
572 | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_BIG));
576 intern->ot = ext->o_bits1[0];
577 intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
578 | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
579 | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
582 ecoff_swap_rndx_in (abfd->xvec->header_byteorder_big_p != false,
583 &ext->o_rndx, &intern->rndx);
585 intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
588 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
593 /* Swap out an optimization symbol. */
596 ecoff_swap_opt_out (abfd, intern_copy, ext_ptr)
601 struct opt_ext *ext = (struct opt_ext *) ext_ptr;
604 *intern = *intern_copy; /* Make it reasonable to do in-place. */
606 if (abfd->xvec->header_byteorder_big_p != false)
608 ext->o_bits1[0] = intern->ot;
609 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
610 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
611 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
615 ext->o_bits1[0] = intern->ot;
616 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
617 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
618 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
621 ecoff_swap_rndx_out (abfd->xvec->header_byteorder_big_p != false,
622 &intern->rndx, &ext->o_rndx);
624 bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
627 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
632 /* Swap in a dense number. */
635 ecoff_swap_dnr_in (abfd, ext_copy, intern)
640 struct dnr_ext ext[1];
642 *ext = *(struct dnr_ext *) ext_copy;
644 intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
645 intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
648 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
653 /* Swap out a dense number. */
656 ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr)
661 struct dnr_ext *ext = (struct dnr_ext *) ext_ptr;
664 *intern = *intern_copy; /* Make it reasonable to do in-place. */
666 bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
667 bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
670 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)