1 /* BFD support to byte-swap a symbol table in MIPS (Third-Eye, `ecoff') format.
2 Copyright 1992, 1993 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
;
162 intern
->lang
= (ext
->f_bits1
[0] & FDR_BITS1_LANG_LITTLE
)
163 >> FDR_BITS1_LANG_SH_LITTLE
;
164 intern
->fMerge
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FMERGE_LITTLE
);
165 intern
->fReadin
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FREADIN_LITTLE
);
166 intern
->fBigendian
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FBIGENDIAN_LITTLE
);
167 intern
->glevel
= (ext
->f_bits2
[0] & FDR_BITS2_GLEVEL_LITTLE
)
168 >> FDR_BITS2_GLEVEL_SH_LITTLE
;
170 intern
->reserved
= 0;
172 intern
->cbLineOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cbLineOffset
);
173 intern
->cbLine
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cbLine
);
176 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
181 /* Swap out the file descriptor record. */
184 DEFUN (ecoff_swap_fdr_out
, (abfd
, intern_copy
, ext
),
191 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
193 bfd_h_put_32 (abfd
, intern
->adr
, (bfd_byte
*)ext
->f_adr
);
194 bfd_h_put_32 (abfd
, intern
->rss
, (bfd_byte
*)ext
->f_rss
);
195 bfd_h_put_32 (abfd
, intern
->issBase
, (bfd_byte
*)ext
->f_issBase
);
196 bfd_h_put_32 (abfd
, intern
->cbSs
, (bfd_byte
*)ext
->f_cbSs
);
197 bfd_h_put_32 (abfd
, intern
->isymBase
, (bfd_byte
*)ext
->f_isymBase
);
198 bfd_h_put_32 (abfd
, intern
->csym
, (bfd_byte
*)ext
->f_csym
);
199 bfd_h_put_32 (abfd
, intern
->ilineBase
, (bfd_byte
*)ext
->f_ilineBase
);
200 bfd_h_put_32 (abfd
, intern
->cline
, (bfd_byte
*)ext
->f_cline
);
201 bfd_h_put_32 (abfd
, intern
->ioptBase
, (bfd_byte
*)ext
->f_ioptBase
);
202 bfd_h_put_32 (abfd
, intern
->copt
, (bfd_byte
*)ext
->f_copt
);
203 bfd_h_put_16 (abfd
, intern
->ipdFirst
, (bfd_byte
*)ext
->f_ipdFirst
);
204 bfd_h_put_16 (abfd
, intern
->cpd
, (bfd_byte
*)ext
->f_cpd
);
205 bfd_h_put_32 (abfd
, intern
->iauxBase
, (bfd_byte
*)ext
->f_iauxBase
);
206 bfd_h_put_32 (abfd
, intern
->caux
, (bfd_byte
*)ext
->f_caux
);
207 bfd_h_put_32 (abfd
, intern
->rfdBase
, (bfd_byte
*)ext
->f_rfdBase
);
208 bfd_h_put_32 (abfd
, intern
->crfd
, (bfd_byte
*)ext
->f_crfd
);
210 /* now the fun stuff... */
211 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
212 ext
->f_bits1
[0] = (((intern
->lang
<< FDR_BITS1_LANG_SH_BIG
)
213 & FDR_BITS1_LANG_BIG
)
214 | (intern
->fMerge
? FDR_BITS1_FMERGE_BIG
: 0)
215 | (intern
->fReadin
? FDR_BITS1_FREADIN_BIG
: 0)
216 | (intern
->fBigendian
? FDR_BITS1_FBIGENDIAN_BIG
: 0));
217 ext
->f_bits2
[0] = ((intern
->glevel
<< FDR_BITS2_GLEVEL_SH_BIG
)
218 & FDR_BITS2_GLEVEL_BIG
);
222 ext
->f_bits1
[0] = (((intern
->lang
<< FDR_BITS1_LANG_SH_LITTLE
)
223 & FDR_BITS1_LANG_LITTLE
)
224 | (intern
->fMerge
? FDR_BITS1_FMERGE_LITTLE
: 0)
225 | (intern
->fReadin
? FDR_BITS1_FREADIN_LITTLE
: 0)
226 | (intern
->fBigendian
? FDR_BITS1_FBIGENDIAN_LITTLE
: 0));
227 ext
->f_bits2
[0] = ((intern
->glevel
<< FDR_BITS2_GLEVEL_SH_LITTLE
)
228 & FDR_BITS2_GLEVEL_LITTLE
);
233 bfd_h_put_32 (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->f_cbLineOffset
);
234 bfd_h_put_32 (abfd
, intern
->cbLine
, (bfd_byte
*)ext
->f_cbLine
);
237 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
242 /* Swap in the procedure descriptor record. */
245 DEFUN (ecoff_swap_pdr_in
, (abfd
, ext_copy
, intern
),
247 struct pdr_ext
*ext_copy AND
250 struct pdr_ext ext
[1];
252 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
254 intern
->adr
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_adr
);
255 intern
->isym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_isym
);
256 intern
->iline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_iline
);
257 intern
->regmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_regmask
);
258 intern
->regoffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_regoffset
);
259 intern
->iopt
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_iopt
);
260 intern
->fregmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_fregmask
);
261 intern
->fregoffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_fregoffset
);
262 intern
->frameoffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_frameoffset
);
263 intern
->framereg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_framereg
);
264 intern
->pcreg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_pcreg
);
265 intern
->lnLow
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnLow
);
266 intern
->lnHigh
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnHigh
);
267 intern
->cbLineOffset
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_cbLineOffset
);
270 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
275 /* Swap out the procedure descriptor record. */
278 DEFUN (ecoff_swap_pdr_out
, (abfd
, intern_copy
, ext
),
285 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
287 bfd_h_put_32 (abfd
, intern
->adr
, (bfd_byte
*)ext
->p_adr
);
288 bfd_h_put_32 (abfd
, intern
->isym
, (bfd_byte
*)ext
->p_isym
);
289 bfd_h_put_32 (abfd
, intern
->iline
, (bfd_byte
*)ext
->p_iline
);
290 bfd_h_put_32 (abfd
, intern
->regmask
, (bfd_byte
*)ext
->p_regmask
);
291 bfd_h_put_32 (abfd
, intern
->regoffset
, (bfd_byte
*)ext
->p_regoffset
);
292 bfd_h_put_32 (abfd
, intern
->iopt
, (bfd_byte
*)ext
->p_iopt
);
293 bfd_h_put_32 (abfd
, intern
->fregmask
, (bfd_byte
*)ext
->p_fregmask
);
294 bfd_h_put_32 (abfd
, intern
->fregoffset
, (bfd_byte
*)ext
->p_fregoffset
);
295 bfd_h_put_32 (abfd
, intern
->frameoffset
, (bfd_byte
*)ext
->p_frameoffset
);
296 bfd_h_put_16 (abfd
, intern
->framereg
, (bfd_byte
*)ext
->p_framereg
);
297 bfd_h_put_16 (abfd
, intern
->pcreg
, (bfd_byte
*)ext
->p_pcreg
);
298 bfd_h_put_32 (abfd
, intern
->lnLow
, (bfd_byte
*)ext
->p_lnLow
);
299 bfd_h_put_32 (abfd
, intern
->lnHigh
, (bfd_byte
*)ext
->p_lnHigh
);
300 bfd_h_put_32 (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->p_cbLineOffset
);
303 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
308 /* Swap in a symbol record. */
311 DEFUN (ecoff_swap_sym_in
, (abfd
, ext_copy
, intern
),
313 struct sym_ext
*ext_copy AND
316 struct sym_ext ext
[1];
318 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
320 intern
->iss
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->s_iss
);
321 intern
->value
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->s_value
);
323 /* now the fun stuff... */
324 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
325 intern
->st
= (ext
->s_bits1
[0] & SYM_BITS1_ST_BIG
)
326 >> SYM_BITS1_ST_SH_BIG
;
327 intern
->sc
= ((ext
->s_bits1
[0] & SYM_BITS1_SC_BIG
)
328 << SYM_BITS1_SC_SH_LEFT_BIG
)
329 | ((ext
->s_bits2
[0] & SYM_BITS2_SC_BIG
)
330 >> SYM_BITS2_SC_SH_BIG
);
331 intern
->reserved
= 0 != (ext
->s_bits2
[0] & SYM_BITS2_RESERVED_BIG
);
332 intern
->index
= ((ext
->s_bits2
[0] & SYM_BITS2_INDEX_BIG
)
333 << SYM_BITS2_INDEX_SH_LEFT_BIG
)
334 | (ext
->s_bits3
[0] << SYM_BITS3_INDEX_SH_LEFT_BIG
)
335 | (ext
->s_bits4
[0] << SYM_BITS4_INDEX_SH_LEFT_BIG
);
337 intern
->st
= (ext
->s_bits1
[0] & SYM_BITS1_ST_LITTLE
)
338 >> SYM_BITS1_ST_SH_LITTLE
;
339 intern
->sc
= ((ext
->s_bits1
[0] & SYM_BITS1_SC_LITTLE
)
340 >> SYM_BITS1_SC_SH_LITTLE
)
341 | ((ext
->s_bits2
[0] & SYM_BITS2_SC_LITTLE
)
342 << SYM_BITS2_SC_SH_LEFT_LITTLE
);
343 intern
->reserved
= 0 != (ext
->s_bits2
[0] & SYM_BITS2_RESERVED_LITTLE
);
344 intern
->index
= ((ext
->s_bits2
[0] & SYM_BITS2_INDEX_LITTLE
)
345 >> SYM_BITS2_INDEX_SH_LITTLE
)
346 | (ext
->s_bits3
[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE
)
347 | (ext
->s_bits4
[0] << SYM_BITS4_INDEX_SH_LEFT_LITTLE
);
351 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
356 /* Swap out a symbol record. */
359 DEFUN (ecoff_swap_sym_out
, (abfd
, intern_copy
, ext
),
361 SYMR
*intern_copy AND
366 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
368 bfd_h_put_32 (abfd
, intern
->iss
, (bfd_byte
*)ext
->s_iss
);
369 bfd_h_put_32 (abfd
, intern
->value
, (bfd_byte
*)ext
->s_value
);
371 /* now the fun stuff... */
372 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
373 ext
->s_bits1
[0] = (((intern
->st
<< SYM_BITS1_ST_SH_BIG
)
375 | ((intern
->sc
>> SYM_BITS1_SC_SH_LEFT_BIG
)
376 & SYM_BITS1_SC_BIG
));
377 ext
->s_bits2
[0] = (((intern
->sc
<< SYM_BITS2_SC_SH_BIG
)
379 | (intern
->reserved
? SYM_BITS2_RESERVED_BIG
: 0)
380 | ((intern
->index
>> SYM_BITS2_INDEX_SH_LEFT_BIG
)
381 & SYM_BITS2_INDEX_BIG
));
382 ext
->s_bits3
[0] = (intern
->index
>> SYM_BITS3_INDEX_SH_LEFT_BIG
) & 0xff;
383 ext
->s_bits4
[0] = (intern
->index
>> SYM_BITS4_INDEX_SH_LEFT_BIG
) & 0xff;
385 ext
->s_bits1
[0] = (((intern
->st
<< SYM_BITS1_ST_SH_LITTLE
)
386 & SYM_BITS1_ST_LITTLE
)
387 | ((intern
->sc
<< SYM_BITS1_SC_SH_LITTLE
)
388 & SYM_BITS1_SC_LITTLE
));
389 ext
->s_bits2
[0] = (((intern
->sc
>> SYM_BITS2_SC_SH_LEFT_LITTLE
)
390 & SYM_BITS2_SC_LITTLE
)
391 | (intern
->reserved
? SYM_BITS2_RESERVED_LITTLE
: 0)
392 | ((intern
->index
<< SYM_BITS2_INDEX_SH_LITTLE
)
393 & SYM_BITS2_INDEX_LITTLE
));
394 ext
->s_bits3
[0] = (intern
->index
>> SYM_BITS3_INDEX_SH_LEFT_LITTLE
) & 0xff;
395 ext
->s_bits4
[0] = (intern
->index
>> SYM_BITS4_INDEX_SH_LEFT_LITTLE
) & 0xff;
399 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
404 /* Swap in an external symbol record. */
407 DEFUN (ecoff_swap_ext_in
, (abfd
, ext_copy
, intern
),
409 struct ext_ext
*ext_copy AND
412 struct ext_ext ext
[1];
414 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
416 /* now the fun stuff... */
417 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
418 intern
->jmptbl
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_JMPTBL_BIG
);
419 intern
->cobol_main
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_COBOL_MAIN_BIG
);
420 intern
->weakext
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_WEAKEXT_BIG
);
422 intern
->jmptbl
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_JMPTBL_LITTLE
);
423 intern
->cobol_main
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_COBOL_MAIN_LITTLE
);
424 intern
->weakext
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_WEAKEXT_LITTLE
);
426 intern
->reserved
= 0;
428 intern
->ifd
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->es_ifd
);
429 ecoff_swap_sym_in (abfd
, &ext
->es_asym
, &intern
->asym
);
432 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
437 /* Swap out an external symbol record. */
440 DEFUN (ecoff_swap_ext_out
, (abfd
, intern_copy
, ext
),
442 EXTR
*intern_copy AND
447 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
449 /* now the fun stuff... */
450 if (abfd
->xvec
->header_byteorder_big_p
!= false) {
451 ext
->es_bits1
[0] = ((intern
->jmptbl
? EXT_BITS1_JMPTBL_BIG
: 0)
452 | (intern
->cobol_main
? EXT_BITS1_COBOL_MAIN_BIG
: 0)
453 | (intern
->weakext
? EXT_BITS1_WEAKEXT_BIG
: 0));
454 ext
->es_bits2
[0] = 0;
456 ext
->es_bits1
[0] = ((intern
->jmptbl
? EXT_BITS1_JMPTBL_LITTLE
: 0)
457 | (intern
->cobol_main
? EXT_BITS1_COBOL_MAIN_LITTLE
: 0)
458 | (intern
->weakext
? EXT_BITS1_WEAKEXT_LITTLE
: 0));
459 ext
->es_bits2
[0] = 0;
462 bfd_h_put_16 (abfd
, intern
->ifd
, (bfd_byte
*)ext
->es_ifd
);
463 ecoff_swap_sym_out (abfd
, &intern
->asym
, &ext
->es_asym
);
466 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
471 /* Swap in a type information record.
472 BIGEND says whether AUX symbols are big-endian or little-endian; this
473 info comes from the file header record (fh-fBigendian). */
476 DEFUN (ecoff_swap_tir_in
, (bigend
, ext_copy
, intern
),
478 struct tir_ext
*ext_copy AND
481 struct tir_ext ext
[1];
483 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
485 /* now the fun stuff... */
487 intern
->fBitfield
= 0 != (ext
->t_bits1
[0] & TIR_BITS1_FBITFIELD_BIG
);
488 intern
->continued
= 0 != (ext
->t_bits1
[0] & TIR_BITS1_CONTINUED_BIG
);
489 intern
->bt
= (ext
->t_bits1
[0] & TIR_BITS1_BT_BIG
)
490 >> TIR_BITS1_BT_SH_BIG
;
491 intern
->tq4
= (ext
->t_tq45
[0] & TIR_BITS_TQ4_BIG
)
492 >> TIR_BITS_TQ4_SH_BIG
;
493 intern
->tq5
= (ext
->t_tq45
[0] & TIR_BITS_TQ5_BIG
)
494 >> TIR_BITS_TQ5_SH_BIG
;
495 intern
->tq0
= (ext
->t_tq01
[0] & TIR_BITS_TQ0_BIG
)
496 >> TIR_BITS_TQ0_SH_BIG
;
497 intern
->tq1
= (ext
->t_tq01
[0] & TIR_BITS_TQ1_BIG
)
498 >> TIR_BITS_TQ1_SH_BIG
;
499 intern
->tq2
= (ext
->t_tq23
[0] & TIR_BITS_TQ2_BIG
)
500 >> TIR_BITS_TQ2_SH_BIG
;
501 intern
->tq3
= (ext
->t_tq23
[0] & TIR_BITS_TQ3_BIG
)
502 >> TIR_BITS_TQ3_SH_BIG
;
504 intern
->fBitfield
= 0 != (ext
->t_bits1
[0] & TIR_BITS1_FBITFIELD_LITTLE
);
505 intern
->continued
= 0 != (ext
->t_bits1
[0] & TIR_BITS1_CONTINUED_LITTLE
);
506 intern
->bt
= (ext
->t_bits1
[0] & TIR_BITS1_BT_LITTLE
)
507 >> TIR_BITS1_BT_SH_LITTLE
;
508 intern
->tq4
= (ext
->t_tq45
[0] & TIR_BITS_TQ4_LITTLE
)
509 >> TIR_BITS_TQ4_SH_LITTLE
;
510 intern
->tq5
= (ext
->t_tq45
[0] & TIR_BITS_TQ5_LITTLE
)
511 >> TIR_BITS_TQ5_SH_LITTLE
;
512 intern
->tq0
= (ext
->t_tq01
[0] & TIR_BITS_TQ0_LITTLE
)
513 >> TIR_BITS_TQ0_SH_LITTLE
;
514 intern
->tq1
= (ext
->t_tq01
[0] & TIR_BITS_TQ1_LITTLE
)
515 >> TIR_BITS_TQ1_SH_LITTLE
;
516 intern
->tq2
= (ext
->t_tq23
[0] & TIR_BITS_TQ2_LITTLE
)
517 >> TIR_BITS_TQ2_SH_LITTLE
;
518 intern
->tq3
= (ext
->t_tq23
[0] & TIR_BITS_TQ3_LITTLE
)
519 >> TIR_BITS_TQ3_SH_LITTLE
;
523 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
528 /* Swap in a relative symbol record. BIGEND says whether it is in
529 big-endian or little-endian format.*/
532 DEFUN (ecoff_swap_rndx_in
, (bigend
, ext_copy
, intern
),
534 struct rndx_ext
*ext_copy AND
537 struct rndx_ext ext
[1];
539 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
541 /* now the fun stuff... */
543 intern
->rfd
= (ext
->r_bits
[0] << RNDX_BITS0_RFD_SH_LEFT_BIG
)
544 | ((ext
->r_bits
[1] & RNDX_BITS1_RFD_BIG
)
545 >> RNDX_BITS1_RFD_SH_BIG
);
546 intern
->index
= ((ext
->r_bits
[1] & RNDX_BITS1_INDEX_BIG
)
547 << RNDX_BITS1_INDEX_SH_LEFT_BIG
)
548 | (ext
->r_bits
[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG
)
549 | (ext
->r_bits
[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG
);
551 intern
->rfd
= (ext
->r_bits
[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE
)
552 | ((ext
->r_bits
[1] & RNDX_BITS1_RFD_LITTLE
)
553 << RNDX_BITS1_RFD_SH_LEFT_LITTLE
);
554 intern
->index
= ((ext
->r_bits
[1] & RNDX_BITS1_INDEX_LITTLE
)
555 >> RNDX_BITS1_INDEX_SH_LITTLE
)
556 | (ext
->r_bits
[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE
)
557 | (ext
->r_bits
[3] << RNDX_BITS3_INDEX_SH_LEFT_LITTLE
);
561 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
566 /* Swap out a relative symbol record. BIGEND says whether it is in
567 big-endian or little-endian format.*/
570 DEFUN (ecoff_swap_rndx_out
, (bigend
, intern_copy
, ext
),
572 RNDXR
*intern_copy AND
573 struct rndx_ext
*ext
)
577 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
579 /* now the fun stuff... */
581 ext
->r_bits
[0] = intern
->rfd
>> RNDX_BITS0_RFD_SH_LEFT_BIG
;
582 ext
->r_bits
[1] = (((intern
->rfd
<< RNDX_BITS1_RFD_SH_BIG
)
583 & RNDX_BITS1_RFD_BIG
)
584 | ((intern
->index
>> RNDX_BITS1_INDEX_SH_LEFT_BIG
)
585 & RNDX_BITS1_INDEX_BIG
));
586 ext
->r_bits
[2] = intern
->index
>> RNDX_BITS2_INDEX_SH_LEFT_BIG
;
587 ext
->r_bits
[3] = intern
->index
>> RNDX_BITS3_INDEX_SH_LEFT_BIG
;
589 ext
->r_bits
[0] = intern
->rfd
>> RNDX_BITS0_RFD_SH_LEFT_LITTLE
;
590 ext
->r_bits
[1] = (((intern
->rfd
>> RNDX_BITS1_RFD_SH_LEFT_LITTLE
)
591 & RNDX_BITS1_RFD_LITTLE
)
592 | ((intern
->index
<< RNDX_BITS1_INDEX_SH_LITTLE
)
593 & RNDX_BITS1_INDEX_LITTLE
));
594 ext
->r_bits
[2] = intern
->index
>> RNDX_BITS2_INDEX_SH_LEFT_LITTLE
;
595 ext
->r_bits
[3] = intern
->index
>> RNDX_BITS3_INDEX_SH_LEFT_LITTLE
;
599 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
604 /* Swap in a relative file descriptor. */
607 DEFUN (ecoff_swap_rfd_in
, (abfd
, ext
, intern
),
609 struct rfd_ext
*ext AND
613 *intern
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->rfd
);
616 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
621 /* Swap out a relative file descriptor. */
624 DEFUN (ecoff_swap_rfd_out
, (abfd
, intern
, ext
),
629 bfd_h_put_32 (abfd
, *intern
, (bfd_byte
*)ext
->rfd
);
632 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
637 /* Swap in an optimization symbol. */
640 DEFUN (ecoff_swap_opt_in
, (abfd
, ext_copy
, intern
),
642 struct opt_ext
*ext_copy AND
645 struct opt_ext ext
[1];
647 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
649 if (abfd
->xvec
->header_byteorder_big_p
!= false)
651 intern
->ot
= ext
->o_bits1
[0];
652 intern
->value
= ((ext
->o_bits2
[0] << OPT_BITS2_VALUE_SH_LEFT_BIG
)
653 | (ext
->o_bits3
[0] << OPT_BITS2_VALUE_SH_LEFT_BIG
)
654 | (ext
->o_bits4
[0] << OPT_BITS2_VALUE_SH_LEFT_BIG
));
658 intern
->ot
= ext
->o_bits1
[0];
659 intern
->value
= ((ext
->o_bits2
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
)
660 | (ext
->o_bits3
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
)
661 | (ext
->o_bits4
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
));
664 ecoff_swap_rndx_in (abfd
->xvec
->header_byteorder_big_p
!= false,
665 &ext
->o_rndx
, &intern
->rndx
);
667 intern
->offset
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->o_offset
);
670 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
675 /* Swap out an optimization symbol. */
678 DEFUN (ecoff_swap_opt_out
, (abfd
, intern_copy
, ext
),
680 OPTR
*intern_copy AND
685 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
687 if (abfd
->xvec
->header_byteorder_big_p
!= false)
689 ext
->o_bits1
[0] = intern
->ot
;
690 ext
->o_bits2
[0] = intern
->value
>> OPT_BITS2_VALUE_SH_LEFT_BIG
;
691 ext
->o_bits3
[0] = intern
->value
>> OPT_BITS3_VALUE_SH_LEFT_BIG
;
692 ext
->o_bits4
[0] = intern
->value
>> OPT_BITS4_VALUE_SH_LEFT_BIG
;
696 ext
->o_bits1
[0] = intern
->ot
;
697 ext
->o_bits2
[0] = intern
->value
>> OPT_BITS2_VALUE_SH_LEFT_LITTLE
;
698 ext
->o_bits3
[0] = intern
->value
>> OPT_BITS3_VALUE_SH_LEFT_LITTLE
;
699 ext
->o_bits4
[0] = intern
->value
>> OPT_BITS4_VALUE_SH_LEFT_LITTLE
;
702 ecoff_swap_rndx_out (abfd
->xvec
->header_byteorder_big_p
!= false,
703 &intern
->rndx
, &ext
->o_rndx
);
705 bfd_h_put_32 (abfd
, intern
->value
, (bfd_byte
*) ext
->o_offset
);
708 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
713 /* Swap in a dense number. */
716 DEFUN (ecoff_swap_dnr_in
, (abfd
, ext_copy
, intern
),
718 struct dnr_ext
*ext_copy AND
721 struct dnr_ext ext
[1];
723 *ext
= *ext_copy
; /* Make it reasonable to do in-place. */
725 intern
->rfd
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->d_rfd
);
726 intern
->index
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->d_index
);
729 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
734 /* Swap out a dense number. */
737 DEFUN (ecoff_swap_dnr_out
, (abfd
, intern_copy
, ext
),
744 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
746 bfd_h_put_32 (abfd
, intern
->rfd
, (bfd_byte
*) ext
->d_rfd
);
747 bfd_h_put_32 (abfd
, intern
->index
, (bfd_byte
*) ext
->d_index
);
750 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)