1 /* Generic ECOFF swapping routines, for BFD.
2 Copyright 1992, 1993, 1994, 1995, 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 ecofflink.c. */
57 extern void _bfd_ecoff_swap_tir_in
58 PARAMS ((int, const struct tir_ext
*, TIR
*));
59 extern void _bfd_ecoff_swap_tir_out
60 PARAMS ((int, const TIR
*, struct tir_ext
*));
61 extern void _bfd_ecoff_swap_rndx_in
62 PARAMS ((int, const struct rndx_ext
*, RNDXR
*));
63 extern void _bfd_ecoff_swap_rndx_out
64 PARAMS ((int, const RNDXR
*, struct rndx_ext
*));
66 /* Prototypes for functions defined in this file. */
68 static void ecoff_swap_hdr_in
PARAMS ((bfd
*, PTR
, HDRR
*));
69 static void ecoff_swap_hdr_out
PARAMS ((bfd
*, const HDRR
*, PTR
));
70 static void ecoff_swap_fdr_in
PARAMS ((bfd
*, PTR
, FDR
*));
71 static void ecoff_swap_fdr_out
PARAMS ((bfd
*, const FDR
*, PTR
));
72 static void ecoff_swap_pdr_in
PARAMS ((bfd
*, PTR
, PDR
*));
73 static void ecoff_swap_pdr_out
PARAMS ((bfd
*, const PDR
*, PTR
));
74 static void ecoff_swap_sym_in
PARAMS ((bfd
*, PTR
, SYMR
*));
75 static void ecoff_swap_sym_out
PARAMS ((bfd
*, const SYMR
*, PTR
));
76 static void ecoff_swap_ext_in
PARAMS ((bfd
*, PTR
, EXTR
*));
77 static void ecoff_swap_ext_out
PARAMS ((bfd
*, const EXTR
*, PTR
));
78 static void ecoff_swap_rfd_in
PARAMS ((bfd
*, PTR
, RFDT
*));
79 static void ecoff_swap_rfd_out
PARAMS ((bfd
*, const RFDT
*, PTR
));
80 static void ecoff_swap_opt_in
PARAMS ((bfd
*, PTR
, OPTR
*));
81 static void ecoff_swap_opt_out
PARAMS ((bfd
*, const OPTR
*, PTR
));
82 static void ecoff_swap_dnr_in
PARAMS ((bfd
*, PTR
, DNR
*));
83 static void ecoff_swap_dnr_out
PARAMS ((bfd
*, const DNR
*, PTR
));
85 /* Swap in the symbolic header. */
88 ecoff_swap_hdr_in (abfd
, ext_copy
, intern
)
93 struct hdr_ext ext
[1];
95 *ext
= *(struct hdr_ext
*) ext_copy
;
97 intern
->magic
= bfd_h_get_signed_16 (abfd
, (bfd_byte
*)ext
->h_magic
);
98 intern
->vstamp
= bfd_h_get_signed_16 (abfd
, (bfd_byte
*)ext
->h_vstamp
);
99 intern
->ilineMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_ilineMax
);
100 intern
->cbLine
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbLine
);
101 intern
->cbLineOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbLineOffset
);
102 intern
->idnMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_idnMax
);
103 intern
->cbDnOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbDnOffset
);
104 intern
->ipdMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_ipdMax
);
105 intern
->cbPdOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbPdOffset
);
106 intern
->isymMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_isymMax
);
107 intern
->cbSymOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbSymOffset
);
108 intern
->ioptMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_ioptMax
);
109 intern
->cbOptOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbOptOffset
);
110 intern
->iauxMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_iauxMax
);
111 intern
->cbAuxOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbAuxOffset
);
112 intern
->issMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_issMax
);
113 intern
->cbSsOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbSsOffset
);
114 intern
->issExtMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_issExtMax
);
115 intern
->cbSsExtOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbSsExtOffset
);
116 intern
->ifdMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_ifdMax
);
117 intern
->cbFdOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbFdOffset
);
118 intern
->crfd
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_crfd
);
119 intern
->cbRfdOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbRfdOffset
);
120 intern
->iextMax
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->h_iextMax
);
121 intern
->cbExtOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->h_cbExtOffset
);
124 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
129 /* Swap out the symbolic header. */
132 ecoff_swap_hdr_out (abfd
, intern_copy
, ext_ptr
)
134 const HDRR
*intern_copy
;
137 struct hdr_ext
*ext
= (struct hdr_ext
*) ext_ptr
;
140 *intern
= *intern_copy
;
142 bfd_h_put_signed_16 (abfd
, intern
->magic
, (bfd_byte
*)ext
->h_magic
);
143 bfd_h_put_signed_16 (abfd
, intern
->vstamp
, (bfd_byte
*)ext
->h_vstamp
);
144 bfd_h_put_32 (abfd
, intern
->ilineMax
, (bfd_byte
*)ext
->h_ilineMax
);
145 ecoff_put_off (abfd
, intern
->cbLine
, (bfd_byte
*)ext
->h_cbLine
);
146 ecoff_put_off (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->h_cbLineOffset
);
147 bfd_h_put_32 (abfd
, intern
->idnMax
, (bfd_byte
*)ext
->h_idnMax
);
148 ecoff_put_off (abfd
, intern
->cbDnOffset
, (bfd_byte
*)ext
->h_cbDnOffset
);
149 bfd_h_put_32 (abfd
, intern
->ipdMax
, (bfd_byte
*)ext
->h_ipdMax
);
150 ecoff_put_off (abfd
, intern
->cbPdOffset
, (bfd_byte
*)ext
->h_cbPdOffset
);
151 bfd_h_put_32 (abfd
, intern
->isymMax
, (bfd_byte
*)ext
->h_isymMax
);
152 ecoff_put_off (abfd
, intern
->cbSymOffset
, (bfd_byte
*)ext
->h_cbSymOffset
);
153 bfd_h_put_32 (abfd
, intern
->ioptMax
, (bfd_byte
*)ext
->h_ioptMax
);
154 ecoff_put_off (abfd
, intern
->cbOptOffset
, (bfd_byte
*)ext
->h_cbOptOffset
);
155 bfd_h_put_32 (abfd
, intern
->iauxMax
, (bfd_byte
*)ext
->h_iauxMax
);
156 ecoff_put_off (abfd
, intern
->cbAuxOffset
, (bfd_byte
*)ext
->h_cbAuxOffset
);
157 bfd_h_put_32 (abfd
, intern
->issMax
, (bfd_byte
*)ext
->h_issMax
);
158 ecoff_put_off (abfd
, intern
->cbSsOffset
, (bfd_byte
*)ext
->h_cbSsOffset
);
159 bfd_h_put_32 (abfd
, intern
->issExtMax
, (bfd_byte
*)ext
->h_issExtMax
);
160 ecoff_put_off (abfd
, intern
->cbSsExtOffset
, (bfd_byte
*)ext
->h_cbSsExtOffset
);
161 bfd_h_put_32 (abfd
, intern
->ifdMax
, (bfd_byte
*)ext
->h_ifdMax
);
162 ecoff_put_off (abfd
, intern
->cbFdOffset
, (bfd_byte
*)ext
->h_cbFdOffset
);
163 bfd_h_put_32 (abfd
, intern
->crfd
, (bfd_byte
*)ext
->h_crfd
);
164 ecoff_put_off (abfd
, intern
->cbRfdOffset
, (bfd_byte
*)ext
->h_cbRfdOffset
);
165 bfd_h_put_32 (abfd
, intern
->iextMax
, (bfd_byte
*)ext
->h_iextMax
);
166 ecoff_put_off (abfd
, intern
->cbExtOffset
, (bfd_byte
*)ext
->h_cbExtOffset
);
169 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
174 /* Swap in the file descriptor record. */
177 ecoff_swap_fdr_in (abfd
, ext_copy
, intern
)
182 struct fdr_ext ext
[1];
184 *ext
= *(struct fdr_ext
*) ext_copy
;
186 intern
->adr
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->f_adr
);
187 intern
->rss
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_rss
);
189 if (intern
->rss
== 0xffffffff)
192 intern
->issBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_issBase
);
193 intern
->cbSs
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->f_cbSs
);
194 intern
->isymBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_isymBase
);
195 intern
->csym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_csym
);
196 intern
->ilineBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_ilineBase
);
197 intern
->cline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cline
);
198 intern
->ioptBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_ioptBase
);
199 intern
->copt
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_copt
);
201 intern
->ipdFirst
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->f_ipdFirst
);
202 intern
->cpd
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->f_cpd
);
205 intern
->ipdFirst
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_ipdFirst
);
206 intern
->cpd
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cpd
);
208 intern
->iauxBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_iauxBase
);
209 intern
->caux
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_caux
);
210 intern
->rfdBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_rfdBase
);
211 intern
->crfd
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_crfd
);
213 /* now the fun stuff... */
214 if (bfd_header_big_endian (abfd
)) {
215 intern
->lang
= (ext
->f_bits1
[0] & FDR_BITS1_LANG_BIG
)
216 >> FDR_BITS1_LANG_SH_BIG
;
217 intern
->fMerge
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FMERGE_BIG
);
218 intern
->fReadin
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FREADIN_BIG
);
219 intern
->fBigendian
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FBIGENDIAN_BIG
);
220 intern
->glevel
= (ext
->f_bits2
[0] & FDR_BITS2_GLEVEL_BIG
)
221 >> FDR_BITS2_GLEVEL_SH_BIG
;
223 intern
->lang
= (ext
->f_bits1
[0] & FDR_BITS1_LANG_LITTLE
)
224 >> FDR_BITS1_LANG_SH_LITTLE
;
225 intern
->fMerge
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FMERGE_LITTLE
);
226 intern
->fReadin
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FREADIN_LITTLE
);
227 intern
->fBigendian
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FBIGENDIAN_LITTLE
);
228 intern
->glevel
= (ext
->f_bits2
[0] & FDR_BITS2_GLEVEL_LITTLE
)
229 >> FDR_BITS2_GLEVEL_SH_LITTLE
;
231 intern
->reserved
= 0;
233 intern
->cbLineOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->f_cbLineOffset
);
234 intern
->cbLine
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->f_cbLine
);
237 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
242 /* Swap out the file descriptor record. */
245 ecoff_swap_fdr_out (abfd
, intern_copy
, ext_ptr
)
247 const FDR
*intern_copy
;
250 struct fdr_ext
*ext
= (struct fdr_ext
*) ext_ptr
;
253 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
255 ecoff_put_off (abfd
, intern
->adr
, (bfd_byte
*)ext
->f_adr
);
256 bfd_h_put_32 (abfd
, intern
->rss
, (bfd_byte
*)ext
->f_rss
);
257 bfd_h_put_32 (abfd
, intern
->issBase
, (bfd_byte
*)ext
->f_issBase
);
258 ecoff_put_off (abfd
, intern
->cbSs
, (bfd_byte
*)ext
->f_cbSs
);
259 bfd_h_put_32 (abfd
, intern
->isymBase
, (bfd_byte
*)ext
->f_isymBase
);
260 bfd_h_put_32 (abfd
, intern
->csym
, (bfd_byte
*)ext
->f_csym
);
261 bfd_h_put_32 (abfd
, intern
->ilineBase
, (bfd_byte
*)ext
->f_ilineBase
);
262 bfd_h_put_32 (abfd
, intern
->cline
, (bfd_byte
*)ext
->f_cline
);
263 bfd_h_put_32 (abfd
, intern
->ioptBase
, (bfd_byte
*)ext
->f_ioptBase
);
264 bfd_h_put_32 (abfd
, intern
->copt
, (bfd_byte
*)ext
->f_copt
);
266 bfd_h_put_16 (abfd
, intern
->ipdFirst
, (bfd_byte
*)ext
->f_ipdFirst
);
267 bfd_h_put_16 (abfd
, intern
->cpd
, (bfd_byte
*)ext
->f_cpd
);
270 bfd_h_put_32 (abfd
, intern
->ipdFirst
, (bfd_byte
*)ext
->f_ipdFirst
);
271 bfd_h_put_32 (abfd
, intern
->cpd
, (bfd_byte
*)ext
->f_cpd
);
273 bfd_h_put_32 (abfd
, intern
->iauxBase
, (bfd_byte
*)ext
->f_iauxBase
);
274 bfd_h_put_32 (abfd
, intern
->caux
, (bfd_byte
*)ext
->f_caux
);
275 bfd_h_put_32 (abfd
, intern
->rfdBase
, (bfd_byte
*)ext
->f_rfdBase
);
276 bfd_h_put_32 (abfd
, intern
->crfd
, (bfd_byte
*)ext
->f_crfd
);
278 /* now the fun stuff... */
279 if (bfd_header_big_endian (abfd
)) {
280 ext
->f_bits1
[0] = (((intern
->lang
<< FDR_BITS1_LANG_SH_BIG
)
281 & FDR_BITS1_LANG_BIG
)
282 | (intern
->fMerge
? FDR_BITS1_FMERGE_BIG
: 0)
283 | (intern
->fReadin
? FDR_BITS1_FREADIN_BIG
: 0)
284 | (intern
->fBigendian
? FDR_BITS1_FBIGENDIAN_BIG
: 0));
285 ext
->f_bits2
[0] = ((intern
->glevel
<< FDR_BITS2_GLEVEL_SH_BIG
)
286 & FDR_BITS2_GLEVEL_BIG
);
290 ext
->f_bits1
[0] = (((intern
->lang
<< FDR_BITS1_LANG_SH_LITTLE
)
291 & FDR_BITS1_LANG_LITTLE
)
292 | (intern
->fMerge
? FDR_BITS1_FMERGE_LITTLE
: 0)
293 | (intern
->fReadin
? FDR_BITS1_FREADIN_LITTLE
: 0)
294 | (intern
->fBigendian
? FDR_BITS1_FBIGENDIAN_LITTLE
: 0));
295 ext
->f_bits2
[0] = ((intern
->glevel
<< FDR_BITS2_GLEVEL_SH_LITTLE
)
296 & FDR_BITS2_GLEVEL_LITTLE
);
301 ecoff_put_off (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->f_cbLineOffset
);
302 ecoff_put_off (abfd
, intern
->cbLine
, (bfd_byte
*)ext
->f_cbLine
);
305 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
312 /* Swap in the procedure descriptor record. */
315 ecoff_swap_pdr_in (abfd
, ext_copy
, intern
)
320 struct pdr_ext ext
[1];
322 *ext
= *(struct pdr_ext
*) ext_copy
;
324 memset ((PTR
) intern
, 0, sizeof (*intern
));
326 intern
->adr
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->p_adr
);
327 intern
->isym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_isym
);
328 intern
->iline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_iline
);
329 intern
->regmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_regmask
);
330 intern
->regoffset
= bfd_h_get_signed_32 (abfd
,
331 (bfd_byte
*)ext
->p_regoffset
);
332 intern
->iopt
= bfd_h_get_signed_32 (abfd
, (bfd_byte
*)ext
->p_iopt
);
333 intern
->fregmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_fregmask
);
334 intern
->fregoffset
= bfd_h_get_signed_32 (abfd
,
335 (bfd_byte
*)ext
->p_fregoffset
);
336 intern
->frameoffset
= bfd_h_get_signed_32 (abfd
,
337 (bfd_byte
*)ext
->p_frameoffset
);
338 intern
->framereg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_framereg
);
339 intern
->pcreg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_pcreg
);
340 intern
->lnLow
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnLow
);
341 intern
->lnHigh
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnHigh
);
342 intern
->cbLineOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->p_cbLineOffset
);
345 intern
->gp_prologue
= bfd_h_get_8 (abfd
, (bfd_byte
*) ext
->p_gp_prologue
);
346 if (bfd_header_big_endian (abfd
))
348 intern
->gp_used
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_GP_USED_BIG
);
349 intern
->reg_frame
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_REG_FRAME_BIG
);
350 intern
->prof
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_PROF_BIG
);
351 intern
->reserved
= (((ext
->p_bits1
[0] & PDR_BITS1_RESERVED_BIG
)
352 << PDR_BITS1_RESERVED_SH_LEFT_BIG
)
353 | ((ext
->p_bits2
[0] & PDR_BITS2_RESERVED_BIG
)
354 >> PDR_BITS2_RESERVED_SH_BIG
));
358 intern
->gp_used
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_GP_USED_LITTLE
);
359 intern
->reg_frame
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_REG_FRAME_LITTLE
);
360 intern
->prof
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_PROF_LITTLE
);
361 intern
->reserved
= (((ext
->p_bits1
[0] & PDR_BITS1_RESERVED_LITTLE
)
362 >> PDR_BITS1_RESERVED_SH_LITTLE
)
363 | ((ext
->p_bits2
[0] & PDR_BITS2_RESERVED_LITTLE
)
364 << PDR_BITS2_RESERVED_SH_LEFT_LITTLE
));
366 intern
->localoff
= bfd_h_get_8 (abfd
, (bfd_byte
*) ext
->p_localoff
);
370 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
375 /* Swap out the procedure descriptor record. */
378 ecoff_swap_pdr_out (abfd
, intern_copy
, ext_ptr
)
380 const PDR
*intern_copy
;
383 struct pdr_ext
*ext
= (struct pdr_ext
*) ext_ptr
;
386 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
388 ecoff_put_off (abfd
, intern
->adr
, (bfd_byte
*)ext
->p_adr
);
389 bfd_h_put_32 (abfd
, intern
->isym
, (bfd_byte
*)ext
->p_isym
);
390 bfd_h_put_32 (abfd
, intern
->iline
, (bfd_byte
*)ext
->p_iline
);
391 bfd_h_put_32 (abfd
, intern
->regmask
, (bfd_byte
*)ext
->p_regmask
);
392 bfd_h_put_32 (abfd
, intern
->regoffset
, (bfd_byte
*)ext
->p_regoffset
);
393 bfd_h_put_32 (abfd
, intern
->iopt
, (bfd_byte
*)ext
->p_iopt
);
394 bfd_h_put_32 (abfd
, intern
->fregmask
, (bfd_byte
*)ext
->p_fregmask
);
395 bfd_h_put_32 (abfd
, intern
->fregoffset
, (bfd_byte
*)ext
->p_fregoffset
);
396 bfd_h_put_32 (abfd
, intern
->frameoffset
, (bfd_byte
*)ext
->p_frameoffset
);
397 bfd_h_put_16 (abfd
, intern
->framereg
, (bfd_byte
*)ext
->p_framereg
);
398 bfd_h_put_16 (abfd
, intern
->pcreg
, (bfd_byte
*)ext
->p_pcreg
);
399 bfd_h_put_32 (abfd
, intern
->lnLow
, (bfd_byte
*)ext
->p_lnLow
);
400 bfd_h_put_32 (abfd
, intern
->lnHigh
, (bfd_byte
*)ext
->p_lnHigh
);
401 ecoff_put_off (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->p_cbLineOffset
);
404 bfd_h_put_8 (abfd
, intern
->gp_prologue
, (bfd_byte
*) ext
->p_gp_prologue
);
405 if (bfd_header_big_endian (abfd
))
407 ext
->p_bits1
[0] = ((intern
->gp_used
? PDR_BITS1_GP_USED_BIG
: 0)
408 | (intern
->reg_frame
? PDR_BITS1_REG_FRAME_BIG
: 0)
409 | (intern
->prof
? PDR_BITS1_PROF_BIG
: 0)
411 >> PDR_BITS1_RESERVED_SH_LEFT_BIG
)
412 & PDR_BITS1_RESERVED_BIG
));
413 ext
->p_bits2
[0] = ((intern
->reserved
<< PDR_BITS2_RESERVED_SH_BIG
)
414 & PDR_BITS2_RESERVED_BIG
);
418 ext
->p_bits1
[0] = ((intern
->gp_used
? PDR_BITS1_GP_USED_LITTLE
: 0)
419 | (intern
->reg_frame
? PDR_BITS1_REG_FRAME_LITTLE
: 0)
420 | (intern
->prof
? PDR_BITS1_PROF_LITTLE
: 0)
421 | ((intern
->reserved
<< PDR_BITS1_RESERVED_SH_LITTLE
)
422 & PDR_BITS1_RESERVED_LITTLE
));
423 ext
->p_bits2
[0] = ((intern
->reserved
>>
424 PDR_BITS2_RESERVED_SH_LEFT_LITTLE
)
425 & PDR_BITS2_RESERVED_LITTLE
);
427 bfd_h_put_8 (abfd
, intern
->localoff
, (bfd_byte
*) ext
->p_localoff
);
431 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
437 /* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't
438 corrupt itself and then freak out. */
439 /* Swap in the procedure descriptor record. */
442 ecoff_swap_pdr_in (abfd
, ext_copy
, intern
)
447 struct pdr_ext ext
[1];
449 *ext
= *(struct pdr_ext
*) ext_copy
;
451 intern
->adr
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->p_adr
);
452 intern
->isym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_isym
);
453 intern
->iline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_iline
);
454 intern
->regmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_regmask
);
455 intern
->regoffset
= bfd_h_get_signed_32 (abfd
,
456 (bfd_byte
*)ext
->p_regoffset
);
457 intern
->iopt
= bfd_h_get_signed_32 (abfd
, (bfd_byte
*)ext
->p_iopt
);
458 intern
->fregmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_fregmask
);
459 intern
->fregoffset
= bfd_h_get_signed_32 (abfd
,
460 (bfd_byte
*)ext
->p_fregoffset
);
461 intern
->frameoffset
= bfd_h_get_signed_32 (abfd
,
462 (bfd_byte
*)ext
->p_frameoffset
);
463 intern
->framereg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_framereg
);
464 intern
->pcreg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_pcreg
);
465 intern
->lnLow
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnLow
);
466 intern
->lnHigh
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnHigh
);
467 intern
->cbLineOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->p_cbLineOffset
);
470 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
475 /* Swap out the procedure descriptor record. */
478 ecoff_swap_pdr_out (abfd
, intern_copy
, ext_ptr
)
480 const PDR
*intern_copy
;
483 struct pdr_ext
*ext
= (struct pdr_ext
*) ext_ptr
;
486 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
488 ecoff_put_off (abfd
, intern
->adr
, (bfd_byte
*)ext
->p_adr
);
489 bfd_h_put_32 (abfd
, intern
->isym
, (bfd_byte
*)ext
->p_isym
);
490 bfd_h_put_32 (abfd
, intern
->iline
, (bfd_byte
*)ext
->p_iline
);
491 bfd_h_put_32 (abfd
, intern
->regmask
, (bfd_byte
*)ext
->p_regmask
);
492 bfd_h_put_32 (abfd
, intern
->regoffset
, (bfd_byte
*)ext
->p_regoffset
);
493 bfd_h_put_32 (abfd
, intern
->iopt
, (bfd_byte
*)ext
->p_iopt
);
494 bfd_h_put_32 (abfd
, intern
->fregmask
, (bfd_byte
*)ext
->p_fregmask
);
495 bfd_h_put_32 (abfd
, intern
->fregoffset
, (bfd_byte
*)ext
->p_fregoffset
);
496 bfd_h_put_32 (abfd
, intern
->frameoffset
, (bfd_byte
*)ext
->p_frameoffset
);
497 bfd_h_put_16 (abfd
, intern
->framereg
, (bfd_byte
*)ext
->p_framereg
);
498 bfd_h_put_16 (abfd
, intern
->pcreg
, (bfd_byte
*)ext
->p_pcreg
);
499 bfd_h_put_32 (abfd
, intern
->lnLow
, (bfd_byte
*)ext
->p_lnLow
);
500 bfd_h_put_32 (abfd
, intern
->lnHigh
, (bfd_byte
*)ext
->p_lnHigh
);
501 ecoff_put_off (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->p_cbLineOffset
);
504 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
510 /* Swap in a symbol record. */
513 ecoff_swap_sym_in (abfd
, ext_copy
, intern
)
518 struct sym_ext ext
[1];
520 *ext
= *(struct sym_ext
*) ext_copy
;
522 intern
->iss
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->s_iss
);
523 intern
->value
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->s_value
);
525 /* now the fun stuff... */
526 if (bfd_header_big_endian (abfd
)) {
527 intern
->st
= (ext
->s_bits1
[0] & SYM_BITS1_ST_BIG
)
528 >> SYM_BITS1_ST_SH_BIG
;
529 intern
->sc
= ((ext
->s_bits1
[0] & SYM_BITS1_SC_BIG
)
530 << SYM_BITS1_SC_SH_LEFT_BIG
)
531 | ((ext
->s_bits2
[0] & SYM_BITS2_SC_BIG
)
532 >> SYM_BITS2_SC_SH_BIG
);
533 intern
->reserved
= 0 != (ext
->s_bits2
[0] & SYM_BITS2_RESERVED_BIG
);
534 intern
->index
= ((ext
->s_bits2
[0] & SYM_BITS2_INDEX_BIG
)
535 << SYM_BITS2_INDEX_SH_LEFT_BIG
)
536 | (ext
->s_bits3
[0] << SYM_BITS3_INDEX_SH_LEFT_BIG
)
537 | (ext
->s_bits4
[0] << SYM_BITS4_INDEX_SH_LEFT_BIG
);
539 intern
->st
= (ext
->s_bits1
[0] & SYM_BITS1_ST_LITTLE
)
540 >> SYM_BITS1_ST_SH_LITTLE
;
541 intern
->sc
= ((ext
->s_bits1
[0] & SYM_BITS1_SC_LITTLE
)
542 >> SYM_BITS1_SC_SH_LITTLE
)
543 | ((ext
->s_bits2
[0] & SYM_BITS2_SC_LITTLE
)
544 << SYM_BITS2_SC_SH_LEFT_LITTLE
);
545 intern
->reserved
= 0 != (ext
->s_bits2
[0] & SYM_BITS2_RESERVED_LITTLE
);
546 intern
->index
= ((ext
->s_bits2
[0] & SYM_BITS2_INDEX_LITTLE
)
547 >> SYM_BITS2_INDEX_SH_LITTLE
)
548 | (ext
->s_bits3
[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE
)
549 | ((unsigned int) ext
->s_bits4
[0]
550 << SYM_BITS4_INDEX_SH_LEFT_LITTLE
);
554 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
559 /* Swap out a symbol record. */
562 ecoff_swap_sym_out (abfd
, intern_copy
, ext_ptr
)
564 const SYMR
*intern_copy
;
567 struct sym_ext
*ext
= (struct sym_ext
*) ext_ptr
;
570 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
572 bfd_h_put_32 (abfd
, intern
->iss
, (bfd_byte
*)ext
->s_iss
);
573 ecoff_put_off (abfd
, intern
->value
, (bfd_byte
*)ext
->s_value
);
575 /* now the fun stuff... */
576 if (bfd_header_big_endian (abfd
)) {
577 ext
->s_bits1
[0] = (((intern
->st
<< SYM_BITS1_ST_SH_BIG
)
579 | ((intern
->sc
>> SYM_BITS1_SC_SH_LEFT_BIG
)
580 & SYM_BITS1_SC_BIG
));
581 ext
->s_bits2
[0] = (((intern
->sc
<< SYM_BITS2_SC_SH_BIG
)
583 | (intern
->reserved
? SYM_BITS2_RESERVED_BIG
: 0)
584 | ((intern
->index
>> SYM_BITS2_INDEX_SH_LEFT_BIG
)
585 & SYM_BITS2_INDEX_BIG
));
586 ext
->s_bits3
[0] = (intern
->index
>> SYM_BITS3_INDEX_SH_LEFT_BIG
) & 0xff;
587 ext
->s_bits4
[0] = (intern
->index
>> SYM_BITS4_INDEX_SH_LEFT_BIG
) & 0xff;
589 ext
->s_bits1
[0] = (((intern
->st
<< SYM_BITS1_ST_SH_LITTLE
)
590 & SYM_BITS1_ST_LITTLE
)
591 | ((intern
->sc
<< SYM_BITS1_SC_SH_LITTLE
)
592 & SYM_BITS1_SC_LITTLE
));
593 ext
->s_bits2
[0] = (((intern
->sc
>> SYM_BITS2_SC_SH_LEFT_LITTLE
)
594 & SYM_BITS2_SC_LITTLE
)
595 | (intern
->reserved
? SYM_BITS2_RESERVED_LITTLE
: 0)
596 | ((intern
->index
<< SYM_BITS2_INDEX_SH_LITTLE
)
597 & SYM_BITS2_INDEX_LITTLE
));
598 ext
->s_bits3
[0] = (intern
->index
>> SYM_BITS3_INDEX_SH_LEFT_LITTLE
) & 0xff;
599 ext
->s_bits4
[0] = (intern
->index
>> SYM_BITS4_INDEX_SH_LEFT_LITTLE
) & 0xff;
603 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
608 /* Swap in an external symbol record. */
611 ecoff_swap_ext_in (abfd
, ext_copy
, intern
)
616 struct ext_ext ext
[1];
618 *ext
= *(struct ext_ext
*) ext_copy
;
620 /* now the fun stuff... */
621 if (bfd_header_big_endian (abfd
)) {
622 intern
->jmptbl
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_JMPTBL_BIG
);
623 intern
->cobol_main
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_COBOL_MAIN_BIG
);
624 intern
->weakext
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_WEAKEXT_BIG
);
626 intern
->jmptbl
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_JMPTBL_LITTLE
);
627 intern
->cobol_main
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_COBOL_MAIN_LITTLE
);
628 intern
->weakext
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_WEAKEXT_LITTLE
);
630 intern
->reserved
= 0;
633 intern
->ifd
= bfd_h_get_signed_16 (abfd
, (bfd_byte
*)ext
->es_ifd
);
636 intern
->ifd
= bfd_h_get_signed_32 (abfd
, (bfd_byte
*)ext
->es_ifd
);
639 ecoff_swap_sym_in (abfd
, &ext
->es_asym
, &intern
->asym
);
642 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
647 /* Swap out an external symbol record. */
650 ecoff_swap_ext_out (abfd
, intern_copy
, ext_ptr
)
652 const EXTR
*intern_copy
;
655 struct ext_ext
*ext
= (struct ext_ext
*) ext_ptr
;
658 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
660 /* now the fun stuff... */
661 if (bfd_header_big_endian (abfd
)) {
662 ext
->es_bits1
[0] = ((intern
->jmptbl
? EXT_BITS1_JMPTBL_BIG
: 0)
663 | (intern
->cobol_main
? EXT_BITS1_COBOL_MAIN_BIG
: 0)
664 | (intern
->weakext
? EXT_BITS1_WEAKEXT_BIG
: 0));
665 ext
->es_bits2
[0] = 0;
667 ext
->es_bits2
[1] = 0;
668 ext
->es_bits2
[2] = 0;
671 ext
->es_bits1
[0] = ((intern
->jmptbl
? EXT_BITS1_JMPTBL_LITTLE
: 0)
672 | (intern
->cobol_main
? EXT_BITS1_COBOL_MAIN_LITTLE
: 0)
673 | (intern
->weakext
? EXT_BITS1_WEAKEXT_LITTLE
: 0));
674 ext
->es_bits2
[0] = 0;
676 ext
->es_bits2
[1] = 0;
677 ext
->es_bits2
[2] = 0;
682 bfd_h_put_signed_16 (abfd
, intern
->ifd
, (bfd_byte
*)ext
->es_ifd
);
685 bfd_h_put_signed_32 (abfd
, intern
->ifd
, (bfd_byte
*)ext
->es_ifd
);
688 ecoff_swap_sym_out (abfd
, &intern
->asym
, &ext
->es_asym
);
691 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
696 /* Swap in a relative file descriptor. */
699 ecoff_swap_rfd_in (abfd
, ext_ptr
, intern
)
704 struct rfd_ext
*ext
= (struct rfd_ext
*) ext_ptr
;
706 *intern
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->rfd
);
709 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
714 /* Swap out a relative file descriptor. */
717 ecoff_swap_rfd_out (abfd
, intern
, ext_ptr
)
722 struct rfd_ext
*ext
= (struct rfd_ext
*) ext_ptr
;
724 bfd_h_put_32 (abfd
, *intern
, (bfd_byte
*)ext
->rfd
);
727 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
732 /* Swap in an optimization symbol. */
735 ecoff_swap_opt_in (abfd
, ext_copy
, intern
)
740 struct opt_ext ext
[1];
742 *ext
= *(struct opt_ext
*) ext_copy
;
744 if (bfd_header_big_endian (abfd
))
746 intern
->ot
= ext
->o_bits1
[0];
747 intern
->value
= (((unsigned int) ext
->o_bits2
[0]
748 << OPT_BITS2_VALUE_SH_LEFT_BIG
)
749 | ((unsigned int) ext
->o_bits3
[0]
750 << OPT_BITS2_VALUE_SH_LEFT_BIG
)
751 | ((unsigned int) ext
->o_bits4
[0]
752 << OPT_BITS2_VALUE_SH_LEFT_BIG
));
756 intern
->ot
= ext
->o_bits1
[0];
757 intern
->value
= ((ext
->o_bits2
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
)
758 | (ext
->o_bits3
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
)
759 | (ext
->o_bits4
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
));
762 _bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd
),
763 &ext
->o_rndx
, &intern
->rndx
);
765 intern
->offset
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->o_offset
);
768 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
773 /* Swap out an optimization symbol. */
776 ecoff_swap_opt_out (abfd
, intern_copy
, ext_ptr
)
778 const OPTR
*intern_copy
;
781 struct opt_ext
*ext
= (struct opt_ext
*) ext_ptr
;
784 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
786 if (bfd_header_big_endian (abfd
))
788 ext
->o_bits1
[0] = intern
->ot
;
789 ext
->o_bits2
[0] = intern
->value
>> OPT_BITS2_VALUE_SH_LEFT_BIG
;
790 ext
->o_bits3
[0] = intern
->value
>> OPT_BITS3_VALUE_SH_LEFT_BIG
;
791 ext
->o_bits4
[0] = intern
->value
>> OPT_BITS4_VALUE_SH_LEFT_BIG
;
795 ext
->o_bits1
[0] = intern
->ot
;
796 ext
->o_bits2
[0] = intern
->value
>> OPT_BITS2_VALUE_SH_LEFT_LITTLE
;
797 ext
->o_bits3
[0] = intern
->value
>> OPT_BITS3_VALUE_SH_LEFT_LITTLE
;
798 ext
->o_bits4
[0] = intern
->value
>> OPT_BITS4_VALUE_SH_LEFT_LITTLE
;
801 _bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd
),
802 &intern
->rndx
, &ext
->o_rndx
);
804 bfd_h_put_32 (abfd
, intern
->value
, (bfd_byte
*) ext
->o_offset
);
807 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
812 /* Swap in a dense number. */
815 ecoff_swap_dnr_in (abfd
, ext_copy
, intern
)
820 struct dnr_ext ext
[1];
822 *ext
= *(struct dnr_ext
*) ext_copy
;
824 intern
->rfd
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->d_rfd
);
825 intern
->index
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->d_index
);
828 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
833 /* Swap out a dense number. */
836 ecoff_swap_dnr_out (abfd
, intern_copy
, ext_ptr
)
838 const DNR
*intern_copy
;
841 struct dnr_ext
*ext
= (struct dnr_ext
*) ext_ptr
;
844 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
846 bfd_h_put_32 (abfd
, intern
->rfd
, (bfd_byte
*) ext
->d_rfd
);
847 bfd_h_put_32 (abfd
, intern
->index
, (bfd_byte
*) ext
->d_index
);
850 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)