1 /* BFD support to byte-swap a symbol table in MIPS (Third-Eye, `ecoff') format.
2 Copyright 1992 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
20 /* The routines in this file convert the external representation of
21 ECOFF symbol tables to the internal (usual struct) representation.
22 On a machine with the same byte-order and the same basic type
23 sizes and alignments as a MIPS machine, this is a no-op.
24 If the symbol TEST is defined when this file is compiled, a comparison
25 is made to ensure that, in fact, the output is bit-for-bit the same as
26 the input. Of course, this symbol should only be defined when
27 deliberately testing the code on a machine with the proper byte sex
31 #include "coff/sym.h" /* MIPS symbols */
32 #include "coff/symconst.h" /* MIPS symbols */
33 #include "coff/ecoff-ext.h" /* ECOFF external struct defns */
35 /* Swap in the symbolic header. */
38 DEFUN (ecoff_swap_hdr_in
, (abfd
, ext_copy
, intern
),
40 struct hdr_ext
*ext_copy AND
43 struct hdr_ext ext
[1];
47 intern
->magic
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->h_magic
);
48 intern
->vstamp
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->h_vstamp
);
49 intern
->ilineMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_ilineMax
);
50 intern
->cbLine
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbLine
);
51 intern
->cbLineOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbLineOffset
);
52 intern
->idnMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_idnMax
);
53 intern
->cbDnOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbDnOffset
);
54 intern
->ipdMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_ipdMax
);
55 intern
->cbPdOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbPdOffset
);
56 intern
->isymMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_isymMax
);
57 intern
->cbSymOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbSymOffset
);
58 intern
->ioptMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_ioptMax
);
59 intern
->cbOptOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbOptOffset
);
60 intern
->iauxMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_iauxMax
);
61 intern
->cbAuxOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbAuxOffset
);
62 intern
->issMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_issMax
);
63 intern
->cbSsOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbSsOffset
);
64 intern
->issExtMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_issExtMax
);
65 intern
->cbSsExtOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbSsExtOffset
);
66 intern
->ifdMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_ifdMax
);
67 intern
->cbFdOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbFdOffset
);
68 intern
->crfd
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_crfd
);
69 intern
->cbRfdOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbRfdOffset
);
70 intern
->iextMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_iextMax
);
71 intern
->cbExtOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_cbExtOffset
);
74 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
79 /* Swap out the symbolic header. */
82 DEFUN (ecoff_swap_hdr_out
, (abfd
, intern_copy
, ext
),
89 *intern
= *intern_copy
;
91 bfd_h_put_16 (abfd
, intern
->magic
, (bfd_byte
*)ext
->h_magic
);
92 bfd_h_put_16 (abfd
, intern
->vstamp
, (bfd_byte
*)ext
->h_vstamp
);
93 bfd_h_put_32 (abfd
, intern
->ilineMax
, (bfd_byte
*)ext
->h_ilineMax
);
94 bfd_h_put_32 (abfd
, intern
->cbLine
, (bfd_byte
*)ext
->h_cbLine
);
95 bfd_h_put_32 (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->h_cbLineOffset
);
96 bfd_h_put_32 (abfd
, intern
->idnMax
, (bfd_byte
*)ext
->h_idnMax
);
97 bfd_h_put_32 (abfd
, intern
->cbDnOffset
, (bfd_byte
*)ext
->h_cbDnOffset
);
98 bfd_h_put_32 (abfd
, intern
->ipdMax
, (bfd_byte
*)ext
->h_ipdMax
);
99 bfd_h_put_32 (abfd
, intern
->cbPdOffset
, (bfd_byte
*)ext
->h_cbPdOffset
);
100 bfd_h_put_32 (abfd
, intern
->isymMax
, (bfd_byte
*)ext
->h_isymMax
);
101 bfd_h_put_32 (abfd
, intern
->cbSymOffset
, (bfd_byte
*)ext
->h_cbSymOffset
);
102 bfd_h_put_32 (abfd
, intern
->ioptMax
, (bfd_byte
*)ext
->h_ioptMax
);
103 bfd_h_put_32 (abfd
, intern
->cbOptOffset
, (bfd_byte
*)ext
->h_cbOptOffset
);
104 bfd_h_put_32 (abfd
, intern
->iauxMax
, (bfd_byte
*)ext
->h_iauxMax
);
105 bfd_h_put_32 (abfd
, intern
->cbAuxOffset
, (bfd_byte
*)ext
->h_cbAuxOffset
);
106 bfd_h_put_32 (abfd
, intern
->issMax
, (bfd_byte
*)ext
->h_issMax
);
107 bfd_h_put_32 (abfd
, intern
->cbSsOffset
, (bfd_byte
*)ext
->h_cbSsOffset
);
108 bfd_h_put_32 (abfd
, intern
->issExtMax
, (bfd_byte
*)ext
->h_issExtMax
);
109 bfd_h_put_32 (abfd
, intern
->cbSsExtOffset
, (bfd_byte
*)ext
->h_cbSsExtOffset
);
110 bfd_h_put_32 (abfd
, intern
->ifdMax
, (bfd_byte
*)ext
->h_ifdMax
);
111 bfd_h_put_32 (abfd
, intern
->cbFdOffset
, (bfd_byte
*)ext
->h_cbFdOffset
);
112 bfd_h_put_32 (abfd
, intern
->crfd
, (bfd_byte
*)ext
->h_crfd
);
113 bfd_h_put_32 (abfd
, intern
->cbRfdOffset
, (bfd_byte
*)ext
->h_cbRfdOffset
);
114 bfd_h_put_32 (abfd
, intern
->iextMax
, (bfd_byte
*)ext
->h_iextMax
);
115 bfd_h_put_32 (abfd
, intern
->cbExtOffset
, (bfd_byte
*)ext
->h_cbExtOffset
);
118 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
123 /* Swap in the file descriptor record. */
126 DEFUN (ecoff_swap_fdr_in
, (abfd
, ext_copy
, intern
),
128 struct fdr_ext
*ext_copy AND
131 struct fdr_ext ext
[1];
133 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
135 intern
->adr
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_adr
);
136 intern
->rss
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_rss
);
137 intern
->issBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_issBase
);
138 intern
->cbSs
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cbSs
);
139 intern
->isymBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_isymBase
);
140 intern
->csym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_csym
);
141 intern
->ilineBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_ilineBase
);
142 intern
->cline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cline
);
143 intern
->ioptBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_ioptBase
);
144 intern
->copt
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_copt
);
145 intern
->ipdFirst
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->f_ipdFirst
);
146 intern
->cpd
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->f_cpd
);
147 intern
->iauxBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_iauxBase
);
148 intern
->caux
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_caux
);
149 intern
->rfdBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_rfdBase
);
150 intern
->crfd
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_crfd
);
152 /* now the fun stuff... */
153 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
154 intern
->lang
= (ext
->f_bits1
[0] & FDR_BITS1_LANG_BIG
)
155 >> FDR_BITS1_LANG_SH_BIG
;
156 intern
->fMerge
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FMERGE_BIG
);
157 intern
->fReadin
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FREADIN_BIG
);
158 intern
->fBigendian
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FBIGENDIAN_BIG
);
159 intern
->glevel
= (ext
->f_bits2
[0] & FDR_BITS2_GLEVEL_BIG
)
160 >> FDR_BITS2_GLEVEL_SH_BIG
;
161 /* intern->reserved we ignore. */
163 intern
->lang
= (ext
->f_bits1
[0] & FDR_BITS1_LANG_LITTLE
)
164 >> FDR_BITS1_LANG_SH_LITTLE
;
165 intern
->fMerge
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FMERGE_LITTLE
);
166 intern
->fReadin
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FREADIN_LITTLE
);
167 intern
->fBigendian
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FBIGENDIAN_LITTLE
);
168 intern
->glevel
= (ext
->f_bits2
[0] & FDR_BITS2_GLEVEL_LITTLE
)
169 >> FDR_BITS2_GLEVEL_SH_LITTLE
;
170 /* intern->reserved we ignore. */
173 intern
->cbLineOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cbLineOffset
);
174 intern
->cbLine
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cbLine
);
177 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
182 /* Swap out the file descriptor record. */
185 DEFUN (ecoff_swap_fdr_out
, (abfd
, intern_copy
, ext
),
192 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
194 bfd_h_put_32 (abfd
, intern
->adr
, (bfd_byte
*)ext
->f_adr
);
195 bfd_h_put_32 (abfd
, intern
->rss
, (bfd_byte
*)ext
->f_rss
);
196 bfd_h_put_32 (abfd
, intern
->issBase
, (bfd_byte
*)ext
->f_issBase
);
197 bfd_h_put_32 (abfd
, intern
->cbSs
, (bfd_byte
*)ext
->f_cbSs
);
198 bfd_h_put_32 (abfd
, intern
->isymBase
, (bfd_byte
*)ext
->f_isymBase
);
199 bfd_h_put_32 (abfd
, intern
->csym
, (bfd_byte
*)ext
->f_csym
);
200 bfd_h_put_32 (abfd
, intern
->ilineBase
, (bfd_byte
*)ext
->f_ilineBase
);
201 bfd_h_put_32 (abfd
, intern
->cline
, (bfd_byte
*)ext
->f_cline
);
202 bfd_h_put_32 (abfd
, intern
->ioptBase
, (bfd_byte
*)ext
->f_ioptBase
);
203 bfd_h_put_32 (abfd
, intern
->copt
, (bfd_byte
*)ext
->f_copt
);
204 bfd_h_put_16 (abfd
, intern
->ipdFirst
, (bfd_byte
*)ext
->f_ipdFirst
);
205 bfd_h_put_16 (abfd
, intern
->cpd
, (bfd_byte
*)ext
->f_cpd
);
206 bfd_h_put_32 (abfd
, intern
->iauxBase
, (bfd_byte
*)ext
->f_iauxBase
);
207 bfd_h_put_32 (abfd
, intern
->caux
, (bfd_byte
*)ext
->f_caux
);
208 bfd_h_put_32 (abfd
, intern
->rfdBase
, (bfd_byte
*)ext
->f_rfdBase
);
209 bfd_h_put_32 (abfd
, intern
->crfd
, (bfd_byte
*)ext
->f_crfd
);
211 /* now the fun stuff... */
212 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
213 ext
->f_bits1
[0] = (((intern
->lang
<< FDR_BITS1_LANG_SH_BIG
)
214 & FDR_BITS1_LANG_BIG
)
215 | (intern
->fMerge
? FDR_BITS1_FMERGE_BIG
: 0)
216 | (intern
->fReadin
? FDR_BITS1_FREADIN_BIG
: 0)
217 | (intern
->fBigendian
? FDR_BITS1_FBIGENDIAN_BIG
: 0));
218 ext
->f_bits2
[0] = ((intern
->glevel
<< FDR_BITS2_GLEVEL_SH_BIG
)
219 & FDR_BITS2_GLEVEL_BIG
);
223 ext
->f_bits1
[0] = (((intern
->lang
<< FDR_BITS1_LANG_SH_LITTLE
)
224 & FDR_BITS1_LANG_LITTLE
)
225 | (intern
->fMerge
? FDR_BITS1_FMERGE_LITTLE
: 0)
226 | (intern
->fReadin
? FDR_BITS1_FREADIN_LITTLE
: 0)
227 | (intern
->fBigendian
? FDR_BITS1_FBIGENDIAN_LITTLE
: 0));
228 ext
->f_bits2
[0] = ((intern
->glevel
<< FDR_BITS2_GLEVEL_SH_LITTLE
)
229 & FDR_BITS2_GLEVEL_LITTLE
);
234 bfd_h_put_32 (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->f_cbLineOffset
);
235 bfd_h_put_32 (abfd
, intern
->cbLine
, (bfd_byte
*)ext
->f_cbLine
);
238 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
243 /* Swap in the procedure descriptor record. */
246 DEFUN (ecoff_swap_pdr_in
, (abfd
, ext_copy
, intern
),
248 struct pdr_ext
*ext_copy AND
251 struct pdr_ext ext
[1];
253 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
255 intern
->adr
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_adr
);
256 intern
->isym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_isym
);
257 intern
->iline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_iline
);
258 intern
->regmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_regmask
);
259 intern
->regoffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_regoffset
);
260 intern
->iopt
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_iopt
);
261 intern
->fregmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_fregmask
);
262 intern
->fregoffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_fregoffset
);
263 intern
->frameoffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_frameoffset
);
264 intern
->framereg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_framereg
);
265 intern
->pcreg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_pcreg
);
266 intern
->lnLow
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnLow
);
267 intern
->lnHigh
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnHigh
);
268 intern
->cbLineOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_cbLineOffset
);
271 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
276 /* Swap out the procedure descriptor record. */
279 DEFUN (ecoff_swap_pdr_out
, (abfd
, intern_copy
, ext
),
286 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
288 bfd_h_put_32 (abfd
, intern
->adr
, (bfd_byte
*)ext
->p_adr
);
289 bfd_h_put_32 (abfd
, intern
->isym
, (bfd_byte
*)ext
->p_isym
);
290 bfd_h_put_32 (abfd
, intern
->iline
, (bfd_byte
*)ext
->p_iline
);
291 bfd_h_put_32 (abfd
, intern
->regmask
, (bfd_byte
*)ext
->p_regmask
);
292 bfd_h_put_32 (abfd
, intern
->regoffset
, (bfd_byte
*)ext
->p_regoffset
);
293 bfd_h_put_32 (abfd
, intern
->iopt
, (bfd_byte
*)ext
->p_iopt
);
294 bfd_h_put_32 (abfd
, intern
->fregmask
, (bfd_byte
*)ext
->p_fregmask
);
295 bfd_h_put_32 (abfd
, intern
->fregoffset
, (bfd_byte
*)ext
->p_fregoffset
);
296 bfd_h_put_32 (abfd
, intern
->frameoffset
, (bfd_byte
*)ext
->p_frameoffset
);
297 bfd_h_put_16 (abfd
, intern
->framereg
, (bfd_byte
*)ext
->p_framereg
);
298 bfd_h_put_16 (abfd
, intern
->pcreg
, (bfd_byte
*)ext
->p_pcreg
);
299 bfd_h_put_32 (abfd
, intern
->lnLow
, (bfd_byte
*)ext
->p_lnLow
);
300 bfd_h_put_32 (abfd
, intern
->lnHigh
, (bfd_byte
*)ext
->p_lnHigh
);
301 bfd_h_put_32 (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->p_cbLineOffset
);
304 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
309 /* Swap in a symbol record. */
312 DEFUN (ecoff_swap_sym_in
, (abfd
, ext_copy
, intern
),
314 struct sym_ext
*ext_copy AND
317 struct sym_ext ext
[1];
319 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
321 intern
->iss
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->s_iss
);
322 intern
->value
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->s_value
);
324 /* now the fun stuff... */
325 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
326 intern
->st
= (ext
->s_bits1
[0] & SYM_BITS1_ST_BIG
)
327 >> SYM_BITS1_ST_SH_BIG
;
328 intern
->sc
= ((ext
->s_bits1
[0] & SYM_BITS1_SC_BIG
)
329 << SYM_BITS1_SC_SH_LEFT_BIG
)
330 | ((ext
->s_bits2
[0] & SYM_BITS2_SC_BIG
)
331 >> SYM_BITS2_SC_SH_BIG
);
332 intern
->reserved
= 0 != (ext
->s_bits2
[0] & SYM_BITS2_RESERVED_BIG
);
333 intern
->index
= (((int) ext
->s_bits2
[0] & SYM_BITS2_INDEX_BIG
)
334 << SYM_BITS2_INDEX_SH_LEFT_BIG
)
335 | ((int) ext
->s_bits3
[0]
336 << SYM_BITS3_INDEX_SH_LEFT_BIG
)
337 | ((int) ext
->s_bits4
[0]
338 << SYM_BITS4_INDEX_SH_LEFT_BIG
);
340 intern
->st
= (ext
->s_bits1
[0] & SYM_BITS1_ST_LITTLE
)
341 >> SYM_BITS1_ST_SH_LITTLE
;
342 intern
->sc
= ((ext
->s_bits1
[0] & SYM_BITS1_SC_LITTLE
)
343 >> SYM_BITS1_SC_SH_LITTLE
)
344 | ((ext
->s_bits2
[0] & SYM_BITS2_SC_LITTLE
)
345 << SYM_BITS2_SC_SH_LEFT_LITTLE
);
346 intern
->reserved
= 0 != (ext
->s_bits2
[0] & SYM_BITS2_RESERVED_LITTLE
);
347 intern
->index
= (((int) ext
->s_bits2
[0] & SYM_BITS2_INDEX_LITTLE
)
348 >> SYM_BITS2_INDEX_SH_LITTLE
)
349 | ((int) ext
->s_bits3
[0]
350 << SYM_BITS3_INDEX_SH_LEFT_LITTLE
)
351 | ((int) ext
->s_bits4
[0]
352 << SYM_BITS4_INDEX_SH_LEFT_LITTLE
);
356 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
361 /* Swap out a symbol record. */
364 DEFUN (ecoff_swap_sym_out
, (abfd
, intern_copy
, ext
),
366 SYMR
*intern_copy AND
371 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
373 bfd_h_put_32 (abfd
, intern
->iss
, (bfd_byte
*)ext
->s_iss
);
374 bfd_h_put_32 (abfd
, intern
->value
, (bfd_byte
*)ext
->s_value
);
376 /* now the fun stuff... */
377 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
378 ext
->s_bits1
[0] = (((intern
->st
<< SYM_BITS1_ST_SH_BIG
)
380 | ((intern
->sc
>> SYM_BITS1_SC_SH_LEFT_BIG
)
381 & SYM_BITS1_SC_BIG
));
382 ext
->s_bits2
[0] = (((intern
->sc
<< SYM_BITS2_SC_SH_BIG
)
384 | (intern
->reserved
? SYM_BITS2_RESERVED_BIG
: 0)
385 | ((intern
->index
>> SYM_BITS2_INDEX_SH_LEFT_BIG
)
386 & SYM_BITS2_INDEX_BIG
));
387 ext
->s_bits3
[0] = (intern
->index
>> SYM_BITS3_INDEX_SH_LEFT_BIG
) & 0xff;
388 ext
->s_bits4
[0] = (intern
->index
>> SYM_BITS4_INDEX_SH_LEFT_BIG
) & 0xff;
390 ext
->s_bits1
[0] = (((intern
->st
<< SYM_BITS1_ST_SH_LITTLE
)
391 & SYM_BITS1_ST_LITTLE
)
392 | ((intern
->sc
<< SYM_BITS1_SC_SH_LITTLE
)
393 & SYM_BITS1_SC_LITTLE
));
394 ext
->s_bits2
[0] = (((intern
->sc
>> SYM_BITS2_SC_SH_LEFT_LITTLE
)
395 & SYM_BITS2_SC_LITTLE
)
396 | (intern
->reserved
? SYM_BITS2_RESERVED_LITTLE
: 0)
397 | ((intern
->index
<< SYM_BITS2_INDEX_SH_LITTLE
)
398 & SYM_BITS2_INDEX_LITTLE
));
399 ext
->s_bits3
[0] = (intern
->index
>> SYM_BITS3_INDEX_SH_LEFT_LITTLE
) & 0xff;
400 ext
->s_bits4
[0] = (intern
->index
>> SYM_BITS4_INDEX_SH_LEFT_LITTLE
) & 0xff;
404 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
409 /* Swap in an external symbol record. */
412 DEFUN (ecoff_swap_ext_in
, (abfd
, ext_copy
, intern
),
414 struct ext_ext
*ext_copy AND
417 struct ext_ext ext
[1];
419 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
421 /* now the fun stuff... */
422 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
423 intern
->jmptbl
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_JMPTBL_BIG
);
424 intern
->cobol_main
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_COBOL_MAIN_BIG
);
425 intern
->weakext
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_WEAKEXT_BIG
);
427 intern
->jmptbl
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_JMPTBL_LITTLE
);
428 intern
->cobol_main
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_COBOL_MAIN_LITTLE
);
429 intern
->weakext
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_WEAKEXT_LITTLE
);
432 intern
->ifd
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->es_ifd
);
433 ecoff_swap_sym_in (abfd
, &ext
->es_asym
, &intern
->asym
);
436 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
441 /* Swap out an external symbol record. */
444 DEFUN (ecoff_swap_ext_out
, (abfd
, intern_copy
, ext
),
446 EXTR
*intern_copy AND
451 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
453 /* now the fun stuff... */
454 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
455 ext
->es_bits1
[0] = ((intern
->jmptbl
? EXT_BITS1_JMPTBL_BIG
: 0)
456 | (intern
->cobol_main
? EXT_BITS1_COBOL_MAIN_BIG
: 0)
457 | (intern
->weakext
? EXT_BITS1_WEAKEXT_BIG
: 0));
458 ext
->es_bits2
[0] = 0;
460 ext
->es_bits1
[0] = ((intern
->jmptbl
? EXT_BITS1_JMPTBL_LITTLE
: 0)
461 | (intern
->cobol_main
? EXT_BITS1_COBOL_MAIN_LITTLE
: 0)
462 | (intern
->weakext
? EXT_BITS1_WEAKEXT_LITTLE
: 0));
463 ext
->es_bits2
[0] = 0;
466 bfd_h_put_16 (abfd
, intern
->ifd
, (bfd_byte
*)ext
->es_ifd
);
467 ecoff_swap_sym_out (abfd
, &intern
->asym
, &ext
->es_asym
);
470 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
475 /* Swap in a type information record.
476 BIGEND says whether AUX symbols are big-endian or little-endian; this
477 info comes from the file header record (fh-fBigendian). */
480 DEFUN (ecoff_swap_tir_in
, (bigend
, ext_copy
, intern
),
482 struct tir_ext
*ext_copy AND
485 struct tir_ext ext
[1];
487 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
489 /* now the fun stuff... */
491 intern
->fBitfield
= 0 != (ext
->t_bits1
[0] & TIR_BITS1_FBITFIELD_BIG
);
492 intern
->continued
= 0 != (ext
->t_bits1
[0] & TIR_BITS1_CONTINUED_BIG
);
493 intern
->bt
= (ext
->t_bits1
[0] & TIR_BITS1_BT_BIG
)
494 >> TIR_BITS1_BT_SH_BIG
;
495 intern
->tq4
= (ext
->t_tq45
[0] & TIR_BITS_TQ4_BIG
)
496 >> TIR_BITS_TQ4_SH_BIG
;
497 intern
->tq5
= (ext
->t_tq45
[0] & TIR_BITS_TQ5_BIG
)
498 >> TIR_BITS_TQ5_SH_BIG
;
499 intern
->tq0
= (ext
->t_tq01
[0] & TIR_BITS_TQ0_BIG
)
500 >> TIR_BITS_TQ0_SH_BIG
;
501 intern
->tq1
= (ext
->t_tq01
[0] & TIR_BITS_TQ1_BIG
)
502 >> TIR_BITS_TQ1_SH_BIG
;
503 intern
->tq2
= (ext
->t_tq23
[0] & TIR_BITS_TQ2_BIG
)
504 >> TIR_BITS_TQ2_SH_BIG
;
505 intern
->tq3
= (ext
->t_tq23
[0] & TIR_BITS_TQ3_BIG
)
506 >> TIR_BITS_TQ3_SH_BIG
;
508 intern
->fBitfield
= 0 != (ext
->t_bits1
[0] & TIR_BITS1_FBITFIELD_LITTLE
);
509 intern
->continued
= 0 != (ext
->t_bits1
[0] & TIR_BITS1_CONTINUED_LITTLE
);
510 intern
->bt
= (ext
->t_bits1
[0] & TIR_BITS1_BT_LITTLE
)
511 >> TIR_BITS1_BT_SH_LITTLE
;
512 intern
->tq4
= (ext
->t_tq45
[0] & TIR_BITS_TQ4_LITTLE
)
513 >> TIR_BITS_TQ4_SH_LITTLE
;
514 intern
->tq5
= (ext
->t_tq45
[0] & TIR_BITS_TQ5_LITTLE
)
515 >> TIR_BITS_TQ5_SH_LITTLE
;
516 intern
->tq0
= (ext
->t_tq01
[0] & TIR_BITS_TQ0_LITTLE
)
517 >> TIR_BITS_TQ0_SH_LITTLE
;
518 intern
->tq1
= (ext
->t_tq01
[0] & TIR_BITS_TQ1_LITTLE
)
519 >> TIR_BITS_TQ1_SH_LITTLE
;
520 intern
->tq2
= (ext
->t_tq23
[0] & TIR_BITS_TQ2_LITTLE
)
521 >> TIR_BITS_TQ2_SH_LITTLE
;
522 intern
->tq3
= (ext
->t_tq23
[0] & TIR_BITS_TQ3_LITTLE
)
523 >> TIR_BITS_TQ3_SH_LITTLE
;
527 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
532 /* Swap in a relative symbol record. BIGEND says whether it is in
533 big-endian or little-endian format.*/
536 DEFUN (ecoff_swap_rndx_in
, (bigend
, ext_copy
, intern
),
538 struct rndx_ext
*ext_copy AND
541 struct rndx_ext ext
[1];
543 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
545 /* now the fun stuff... */
547 intern
->rfd
= (ext
->r_bits
[0] << RNDX_BITS0_RFD_SH_LEFT_BIG
)
548 | ((ext
->r_bits
[1] & RNDX_BITS1_RFD_BIG
)
549 >> RNDX_BITS1_RFD_SH_BIG
);
550 intern
->index
= (((int) ext
->r_bits
[1] & RNDX_BITS1_INDEX_BIG
)
551 << RNDX_BITS1_INDEX_SH_LEFT_BIG
)
552 | ((int) ext
->r_bits
[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG
)
553 | ((int) ext
->r_bits
[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG
);
555 intern
->rfd
= (ext
->r_bits
[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE
)
556 | ((ext
->r_bits
[1] & RNDX_BITS1_RFD_LITTLE
)
557 << RNDX_BITS1_RFD_SH_LEFT_LITTLE
);
558 intern
->index
= (((int) ext
->r_bits
[1] & RNDX_BITS1_INDEX_LITTLE
)
559 >> RNDX_BITS1_INDEX_SH_LITTLE
)
560 | ((int) ext
->r_bits
[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE
)
561 | ((int) ext
->r_bits
[3] << RNDX_BITS3_INDEX_SH_LEFT_LITTLE
);
565 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
570 /* Swap out a relative symbol record. BIGEND says whether it is in
571 big-endian or little-endian format.*/
574 DEFUN (ecoff_swap_rndx_out
, (bigend
, intern_copy
, ext
),
576 RNDXR
*intern_copy AND
577 struct rndx_ext
*ext
)
581 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
583 /* now the fun stuff... */
585 ext
->r_bits
[0] = intern
->rfd
>> RNDX_BITS0_RFD_SH_LEFT_BIG
;
586 ext
->r_bits
[1] = (((intern
->rfd
<< RNDX_BITS1_RFD_SH_BIG
)
587 & RNDX_BITS1_RFD_BIG
)
588 | ((intern
->index
>> RNDX_BITS1_INDEX_SH_LEFT_BIG
)
589 & RNDX_BITS1_INDEX_BIG
));
590 ext
->r_bits
[2] = intern
->index
>> RNDX_BITS2_INDEX_SH_LEFT_BIG
;
591 ext
->r_bits
[3] = intern
->index
>> RNDX_BITS3_INDEX_SH_LEFT_BIG
;
593 ext
->r_bits
[0] = intern
->rfd
>> RNDX_BITS0_RFD_SH_LEFT_LITTLE
;
594 ext
->r_bits
[1] = (((intern
->rfd
>> RNDX_BITS1_RFD_SH_LEFT_LITTLE
)
595 & RNDX_BITS1_RFD_LITTLE
)
596 | ((intern
->index
<< RNDX_BITS1_INDEX_SH_LITTLE
)
597 & RNDX_BITS1_INDEX_LITTLE
));
598 ext
->r_bits
[2] = intern
->index
>> RNDX_BITS2_INDEX_SH_LEFT_LITTLE
;
599 ext
->r_bits
[3] = intern
->index
>> RNDX_BITS3_INDEX_SH_LEFT_LITTLE
;
603 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
608 /* Swap in a relative file descriptor. */
611 DEFUN (ecoff_swap_rfd_in
, (abfd
, ext
, intern
),
613 struct rfd_ext
*ext AND
617 *intern
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->rfd
);
620 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
625 /* Swap out a relative file descriptor. */
628 DEFUN (ecoff_swap_rfd_out
, (abfd
, intern
, ext
),
633 bfd_h_put_32 (abfd
, *intern
, (bfd_byte
*)ext
->rfd
);
636 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
641 /* Swap in an optimization symbol. */
644 DEFUN (ecoff_swap_opt_in
, (abfd
, ext_copy
, intern
),
646 struct opt_ext
*ext_copy AND
649 struct opt_ext ext
[1];
651 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
653 if (abfd
->xvec
->header_byteorder_big_p
!= false)
655 intern
->ot
= ext
->o_bits1
[0];
656 intern
->value
= (((int) ext
->o_bits2
[0]
657 << OPT_BITS2_VALUE_SH_LEFT_BIG
)
658 | ((int) ext
->o_bits3
[0]
659 << OPT_BITS2_VALUE_SH_LEFT_BIG
)
660 | ((int) ext
->o_bits4
[0]
661 << OPT_BITS2_VALUE_SH_LEFT_BIG
));
665 intern
->ot
= ext
->o_bits1
[0];
666 intern
->value
= (((int) ext
->o_bits2
[0]
667 << OPT_BITS2_VALUE_SH_LEFT_LITTLE
)
668 | ((int) ext
->o_bits3
[0]
669 << OPT_BITS2_VALUE_SH_LEFT_LITTLE
)
670 | ((int) ext
->o_bits4
[0]
671 << OPT_BITS2_VALUE_SH_LEFT_LITTLE
));
674 ecoff_swap_rndx_in (abfd
->xvec
->header_byteorder_big_p
!= false,
675 &ext
->o_rndx
, &intern
->rndx
);
677 intern
->offset
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->o_offset
);
680 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
685 /* Swap out an optimization symbol. */
688 DEFUN (ecoff_swap_opt_out
, (abfd
, intern_copy
, ext
),
690 OPTR
*intern_copy AND
695 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
697 if (abfd
->xvec
->header_byteorder_big_p
!= false)
699 ext
->o_bits1
[0] = intern
->ot
;
700 ext
->o_bits2
[0] = intern
->value
>> OPT_BITS2_VALUE_SH_LEFT_BIG
;
701 ext
->o_bits3
[0] = intern
->value
>> OPT_BITS3_VALUE_SH_LEFT_BIG
;
702 ext
->o_bits4
[0] = intern
->value
>> OPT_BITS4_VALUE_SH_LEFT_BIG
;
706 ext
->o_bits1
[0] = intern
->ot
;
707 ext
->o_bits2
[0] = intern
->value
>> OPT_BITS2_VALUE_SH_LEFT_LITTLE
;
708 ext
->o_bits3
[0] = intern
->value
>> OPT_BITS3_VALUE_SH_LEFT_LITTLE
;
709 ext
->o_bits4
[0] = intern
->value
>> OPT_BITS4_VALUE_SH_LEFT_LITTLE
;
712 ecoff_swap_rndx_out (abfd
->xvec
->header_byteorder_big_p
!= false,
713 &intern
->rndx
, &ext
->o_rndx
);
715 bfd_h_put_32 (abfd
, intern
->value
, (bfd_byte
*) ext
->o_offset
);
718 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
723 /* Swap in a dense number. */
726 DEFUN (ecoff_swap_dnr_in
, (abfd
, ext_copy
, intern
),
728 struct dnr_ext
*ext_copy AND
731 struct dnr_ext ext
[1];
733 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
735 intern
->rfd
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->d_rfd
);
736 intern
->index
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->d_index
);
739 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
744 /* Swap out a dense number. */
747 DEFUN (ecoff_swap_dnr_out
, (abfd
, intern_copy
, ext
),
754 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
756 bfd_h_put_32 (abfd
, intern
->rfd
, (bfd_byte
*) ext
->d_rfd
);
757 bfd_h_put_32 (abfd
, intern
->index
, (bfd_byte
*) ext
->d_index
);
760 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)