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., 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
);
188 intern
->issBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_issBase
);
189 intern
->cbSs
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->f_cbSs
);
190 intern
->isymBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_isymBase
);
191 intern
->csym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_csym
);
192 intern
->ilineBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_ilineBase
);
193 intern
->cline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cline
);
194 intern
->ioptBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_ioptBase
);
195 intern
->copt
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_copt
);
197 intern
->ipdFirst
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->f_ipdFirst
);
198 intern
->cpd
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->f_cpd
);
201 intern
->ipdFirst
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_ipdFirst
);
202 intern
->cpd
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_cpd
);
204 intern
->iauxBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_iauxBase
);
205 intern
->caux
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_caux
);
206 intern
->rfdBase
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_rfdBase
);
207 intern
->crfd
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->f_crfd
);
209 /* now the fun stuff... */
210 if (bfd_header_big_endian (abfd
)) {
211 intern
->lang
= (ext
->f_bits1
[0] & FDR_BITS1_LANG_BIG
)
212 >> FDR_BITS1_LANG_SH_BIG
;
213 intern
->fMerge
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FMERGE_BIG
);
214 intern
->fReadin
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FREADIN_BIG
);
215 intern
->fBigendian
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FBIGENDIAN_BIG
);
216 intern
->glevel
= (ext
->f_bits2
[0] & FDR_BITS2_GLEVEL_BIG
)
217 >> FDR_BITS2_GLEVEL_SH_BIG
;
219 intern
->lang
= (ext
->f_bits1
[0] & FDR_BITS1_LANG_LITTLE
)
220 >> FDR_BITS1_LANG_SH_LITTLE
;
221 intern
->fMerge
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FMERGE_LITTLE
);
222 intern
->fReadin
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FREADIN_LITTLE
);
223 intern
->fBigendian
= 0 != (ext
->f_bits1
[0] & FDR_BITS1_FBIGENDIAN_LITTLE
);
224 intern
->glevel
= (ext
->f_bits2
[0] & FDR_BITS2_GLEVEL_LITTLE
)
225 >> FDR_BITS2_GLEVEL_SH_LITTLE
;
227 intern
->reserved
= 0;
229 intern
->cbLineOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->f_cbLineOffset
);
230 intern
->cbLine
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->f_cbLine
);
233 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
238 /* Swap out the file descriptor record. */
241 ecoff_swap_fdr_out (abfd
, intern_copy
, ext_ptr
)
243 const FDR
*intern_copy
;
246 struct fdr_ext
*ext
= (struct fdr_ext
*) ext_ptr
;
249 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
251 ecoff_put_off (abfd
, intern
->adr
, (bfd_byte
*)ext
->f_adr
);
252 bfd_h_put_32 (abfd
, intern
->rss
, (bfd_byte
*)ext
->f_rss
);
253 bfd_h_put_32 (abfd
, intern
->issBase
, (bfd_byte
*)ext
->f_issBase
);
254 ecoff_put_off (abfd
, intern
->cbSs
, (bfd_byte
*)ext
->f_cbSs
);
255 bfd_h_put_32 (abfd
, intern
->isymBase
, (bfd_byte
*)ext
->f_isymBase
);
256 bfd_h_put_32 (abfd
, intern
->csym
, (bfd_byte
*)ext
->f_csym
);
257 bfd_h_put_32 (abfd
, intern
->ilineBase
, (bfd_byte
*)ext
->f_ilineBase
);
258 bfd_h_put_32 (abfd
, intern
->cline
, (bfd_byte
*)ext
->f_cline
);
259 bfd_h_put_32 (abfd
, intern
->ioptBase
, (bfd_byte
*)ext
->f_ioptBase
);
260 bfd_h_put_32 (abfd
, intern
->copt
, (bfd_byte
*)ext
->f_copt
);
262 bfd_h_put_16 (abfd
, intern
->ipdFirst
, (bfd_byte
*)ext
->f_ipdFirst
);
263 bfd_h_put_16 (abfd
, intern
->cpd
, (bfd_byte
*)ext
->f_cpd
);
266 bfd_h_put_32 (abfd
, intern
->ipdFirst
, (bfd_byte
*)ext
->f_ipdFirst
);
267 bfd_h_put_32 (abfd
, intern
->cpd
, (bfd_byte
*)ext
->f_cpd
);
269 bfd_h_put_32 (abfd
, intern
->iauxBase
, (bfd_byte
*)ext
->f_iauxBase
);
270 bfd_h_put_32 (abfd
, intern
->caux
, (bfd_byte
*)ext
->f_caux
);
271 bfd_h_put_32 (abfd
, intern
->rfdBase
, (bfd_byte
*)ext
->f_rfdBase
);
272 bfd_h_put_32 (abfd
, intern
->crfd
, (bfd_byte
*)ext
->f_crfd
);
274 /* now the fun stuff... */
275 if (bfd_header_big_endian (abfd
)) {
276 ext
->f_bits1
[0] = (((intern
->lang
<< FDR_BITS1_LANG_SH_BIG
)
277 & FDR_BITS1_LANG_BIG
)
278 | (intern
->fMerge
? FDR_BITS1_FMERGE_BIG
: 0)
279 | (intern
->fReadin
? FDR_BITS1_FREADIN_BIG
: 0)
280 | (intern
->fBigendian
? FDR_BITS1_FBIGENDIAN_BIG
: 0));
281 ext
->f_bits2
[0] = ((intern
->glevel
<< FDR_BITS2_GLEVEL_SH_BIG
)
282 & FDR_BITS2_GLEVEL_BIG
);
286 ext
->f_bits1
[0] = (((intern
->lang
<< FDR_BITS1_LANG_SH_LITTLE
)
287 & FDR_BITS1_LANG_LITTLE
)
288 | (intern
->fMerge
? FDR_BITS1_FMERGE_LITTLE
: 0)
289 | (intern
->fReadin
? FDR_BITS1_FREADIN_LITTLE
: 0)
290 | (intern
->fBigendian
? FDR_BITS1_FBIGENDIAN_LITTLE
: 0));
291 ext
->f_bits2
[0] = ((intern
->glevel
<< FDR_BITS2_GLEVEL_SH_LITTLE
)
292 & FDR_BITS2_GLEVEL_LITTLE
);
297 ecoff_put_off (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->f_cbLineOffset
);
298 ecoff_put_off (abfd
, intern
->cbLine
, (bfd_byte
*)ext
->f_cbLine
);
301 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
308 /* Swap in the procedure descriptor record. */
311 ecoff_swap_pdr_in (abfd
, ext_copy
, intern
)
316 struct pdr_ext ext
[1];
318 *ext
= *(struct pdr_ext
*) ext_copy
;
320 memset ((PTR
) intern
, 0, sizeof (*intern
));
322 intern
->adr
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->p_adr
);
323 intern
->isym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_isym
);
324 intern
->iline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_iline
);
325 intern
->regmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_regmask
);
326 intern
->regoffset
= bfd_h_get_signed_32 (abfd
,
327 (bfd_byte
*)ext
->p_regoffset
);
328 intern
->iopt
= bfd_h_get_signed_32 (abfd
, (bfd_byte
*)ext
->p_iopt
);
329 intern
->fregmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_fregmask
);
330 intern
->fregoffset
= bfd_h_get_signed_32 (abfd
,
331 (bfd_byte
*)ext
->p_fregoffset
);
332 intern
->frameoffset
= bfd_h_get_signed_32 (abfd
,
333 (bfd_byte
*)ext
->p_frameoffset
);
334 intern
->framereg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_framereg
);
335 intern
->pcreg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_pcreg
);
336 intern
->lnLow
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnLow
);
337 intern
->lnHigh
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnHigh
);
338 intern
->cbLineOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->p_cbLineOffset
);
341 intern
->gp_prologue
= bfd_h_get_8 (abfd
, (bfd_byte
*) ext
->p_gp_prologue
);
342 if (bfd_header_big_endian (abfd
))
344 intern
->gp_used
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_GP_USED_BIG
);
345 intern
->reg_frame
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_REG_FRAME_BIG
);
346 intern
->prof
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_PROF_BIG
);
347 intern
->reserved
= (((ext
->p_bits1
[0] & PDR_BITS1_RESERVED_BIG
)
348 << PDR_BITS1_RESERVED_SH_LEFT_BIG
)
349 | ((ext
->p_bits2
[0] & PDR_BITS2_RESERVED_BIG
)
350 >> PDR_BITS2_RESERVED_SH_BIG
));
354 intern
->gp_used
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_GP_USED_LITTLE
);
355 intern
->reg_frame
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_REG_FRAME_LITTLE
);
356 intern
->prof
= 0 != (ext
->p_bits1
[0] & PDR_BITS1_PROF_LITTLE
);
357 intern
->reserved
= (((ext
->p_bits1
[0] & PDR_BITS1_RESERVED_LITTLE
)
358 >> PDR_BITS1_RESERVED_SH_LITTLE
)
359 | ((ext
->p_bits2
[0] & PDR_BITS2_RESERVED_LITTLE
)
360 << PDR_BITS2_RESERVED_SH_LEFT_LITTLE
));
362 intern
->localoff
= bfd_h_get_8 (abfd
, (bfd_byte
*) ext
->p_localoff
);
366 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
371 /* Swap out the procedure descriptor record. */
374 ecoff_swap_pdr_out (abfd
, intern_copy
, ext_ptr
)
376 const PDR
*intern_copy
;
379 struct pdr_ext
*ext
= (struct pdr_ext
*) ext_ptr
;
382 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
384 ecoff_put_off (abfd
, intern
->adr
, (bfd_byte
*)ext
->p_adr
);
385 bfd_h_put_32 (abfd
, intern
->isym
, (bfd_byte
*)ext
->p_isym
);
386 bfd_h_put_32 (abfd
, intern
->iline
, (bfd_byte
*)ext
->p_iline
);
387 bfd_h_put_32 (abfd
, intern
->regmask
, (bfd_byte
*)ext
->p_regmask
);
388 bfd_h_put_32 (abfd
, intern
->regoffset
, (bfd_byte
*)ext
->p_regoffset
);
389 bfd_h_put_32 (abfd
, intern
->iopt
, (bfd_byte
*)ext
->p_iopt
);
390 bfd_h_put_32 (abfd
, intern
->fregmask
, (bfd_byte
*)ext
->p_fregmask
);
391 bfd_h_put_32 (abfd
, intern
->fregoffset
, (bfd_byte
*)ext
->p_fregoffset
);
392 bfd_h_put_32 (abfd
, intern
->frameoffset
, (bfd_byte
*)ext
->p_frameoffset
);
393 bfd_h_put_16 (abfd
, intern
->framereg
, (bfd_byte
*)ext
->p_framereg
);
394 bfd_h_put_16 (abfd
, intern
->pcreg
, (bfd_byte
*)ext
->p_pcreg
);
395 bfd_h_put_32 (abfd
, intern
->lnLow
, (bfd_byte
*)ext
->p_lnLow
);
396 bfd_h_put_32 (abfd
, intern
->lnHigh
, (bfd_byte
*)ext
->p_lnHigh
);
397 ecoff_put_off (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->p_cbLineOffset
);
400 bfd_h_put_8 (abfd
, intern
->gp_prologue
, (bfd_byte
*) ext
->p_gp_prologue
);
401 if (bfd_header_big_endian (abfd
))
403 ext
->p_bits1
[0] = ((intern
->gp_used
? PDR_BITS1_GP_USED_BIG
: 0)
404 | (intern
->reg_frame
? PDR_BITS1_REG_FRAME_BIG
: 0)
405 | (intern
->prof
? PDR_BITS1_PROF_BIG
: 0)
407 >> PDR_BITS1_RESERVED_SH_LEFT_BIG
)
408 & PDR_BITS1_RESERVED_BIG
));
409 ext
->p_bits2
[0] = ((intern
->reserved
<< PDR_BITS2_RESERVED_SH_BIG
)
410 & PDR_BITS2_RESERVED_BIG
);
414 ext
->p_bits1
[0] = ((intern
->gp_used
? PDR_BITS1_GP_USED_LITTLE
: 0)
415 | (intern
->reg_frame
? PDR_BITS1_REG_FRAME_LITTLE
: 0)
416 | (intern
->prof
? PDR_BITS1_PROF_LITTLE
: 0)
417 | ((intern
->reserved
<< PDR_BITS1_RESERVED_SH_LITTLE
)
418 & PDR_BITS1_RESERVED_LITTLE
));
419 ext
->p_bits2
[0] = ((intern
->reserved
>>
420 PDR_BITS2_RESERVED_SH_LEFT_LITTLE
)
421 & PDR_BITS2_RESERVED_LITTLE
);
423 bfd_h_put_8 (abfd
, intern
->localoff
, (bfd_byte
*) ext
->p_localoff
);
427 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
433 /* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't
434 corrupt itself and then freak out. */
435 /* Swap in the procedure descriptor record. */
438 ecoff_swap_pdr_in (abfd
, ext_copy
, intern
)
443 struct pdr_ext ext
[1];
445 *ext
= *(struct pdr_ext
*) ext_copy
;
447 intern
->adr
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->p_adr
);
448 intern
->isym
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_isym
);
449 intern
->iline
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_iline
);
450 intern
->regmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_regmask
);
451 intern
->regoffset
= bfd_h_get_signed_32 (abfd
,
452 (bfd_byte
*)ext
->p_regoffset
);
453 intern
->iopt
= bfd_h_get_signed_32 (abfd
, (bfd_byte
*)ext
->p_iopt
);
454 intern
->fregmask
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_fregmask
);
455 intern
->fregoffset
= bfd_h_get_signed_32 (abfd
,
456 (bfd_byte
*)ext
->p_fregoffset
);
457 intern
->frameoffset
= bfd_h_get_signed_32 (abfd
,
458 (bfd_byte
*)ext
->p_frameoffset
);
459 intern
->framereg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_framereg
);
460 intern
->pcreg
= bfd_h_get_16 (abfd
, (bfd_byte
*)ext
->p_pcreg
);
461 intern
->lnLow
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnLow
);
462 intern
->lnHigh
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->p_lnHigh
);
463 intern
->cbLineOffset
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->p_cbLineOffset
);
466 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
471 /* Swap out the procedure descriptor record. */
474 ecoff_swap_pdr_out (abfd
, intern_copy
, ext_ptr
)
476 const PDR
*intern_copy
;
479 struct pdr_ext
*ext
= (struct pdr_ext
*) ext_ptr
;
482 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
484 ecoff_put_off (abfd
, intern
->adr
, (bfd_byte
*)ext
->p_adr
);
485 bfd_h_put_32 (abfd
, intern
->isym
, (bfd_byte
*)ext
->p_isym
);
486 bfd_h_put_32 (abfd
, intern
->iline
, (bfd_byte
*)ext
->p_iline
);
487 bfd_h_put_32 (abfd
, intern
->regmask
, (bfd_byte
*)ext
->p_regmask
);
488 bfd_h_put_32 (abfd
, intern
->regoffset
, (bfd_byte
*)ext
->p_regoffset
);
489 bfd_h_put_32 (abfd
, intern
->iopt
, (bfd_byte
*)ext
->p_iopt
);
490 bfd_h_put_32 (abfd
, intern
->fregmask
, (bfd_byte
*)ext
->p_fregmask
);
491 bfd_h_put_32 (abfd
, intern
->fregoffset
, (bfd_byte
*)ext
->p_fregoffset
);
492 bfd_h_put_32 (abfd
, intern
->frameoffset
, (bfd_byte
*)ext
->p_frameoffset
);
493 bfd_h_put_16 (abfd
, intern
->framereg
, (bfd_byte
*)ext
->p_framereg
);
494 bfd_h_put_16 (abfd
, intern
->pcreg
, (bfd_byte
*)ext
->p_pcreg
);
495 bfd_h_put_32 (abfd
, intern
->lnLow
, (bfd_byte
*)ext
->p_lnLow
);
496 bfd_h_put_32 (abfd
, intern
->lnHigh
, (bfd_byte
*)ext
->p_lnHigh
);
497 ecoff_put_off (abfd
, intern
->cbLineOffset
, (bfd_byte
*)ext
->p_cbLineOffset
);
500 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
506 /* Swap in a symbol record. */
509 ecoff_swap_sym_in (abfd
, ext_copy
, intern
)
514 struct sym_ext ext
[1];
516 *ext
= *(struct sym_ext
*) ext_copy
;
518 intern
->iss
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->s_iss
);
519 intern
->value
= ecoff_get_off (abfd
, (bfd_byte
*)ext
->s_value
);
521 /* now the fun stuff... */
522 if (bfd_header_big_endian (abfd
)) {
523 intern
->st
= (ext
->s_bits1
[0] & SYM_BITS1_ST_BIG
)
524 >> SYM_BITS1_ST_SH_BIG
;
525 intern
->sc
= ((ext
->s_bits1
[0] & SYM_BITS1_SC_BIG
)
526 << SYM_BITS1_SC_SH_LEFT_BIG
)
527 | ((ext
->s_bits2
[0] & SYM_BITS2_SC_BIG
)
528 >> SYM_BITS2_SC_SH_BIG
);
529 intern
->reserved
= 0 != (ext
->s_bits2
[0] & SYM_BITS2_RESERVED_BIG
);
530 intern
->index
= ((ext
->s_bits2
[0] & SYM_BITS2_INDEX_BIG
)
531 << SYM_BITS2_INDEX_SH_LEFT_BIG
)
532 | (ext
->s_bits3
[0] << SYM_BITS3_INDEX_SH_LEFT_BIG
)
533 | (ext
->s_bits4
[0] << SYM_BITS4_INDEX_SH_LEFT_BIG
);
535 intern
->st
= (ext
->s_bits1
[0] & SYM_BITS1_ST_LITTLE
)
536 >> SYM_BITS1_ST_SH_LITTLE
;
537 intern
->sc
= ((ext
->s_bits1
[0] & SYM_BITS1_SC_LITTLE
)
538 >> SYM_BITS1_SC_SH_LITTLE
)
539 | ((ext
->s_bits2
[0] & SYM_BITS2_SC_LITTLE
)
540 << SYM_BITS2_SC_SH_LEFT_LITTLE
);
541 intern
->reserved
= 0 != (ext
->s_bits2
[0] & SYM_BITS2_RESERVED_LITTLE
);
542 intern
->index
= ((ext
->s_bits2
[0] & SYM_BITS2_INDEX_LITTLE
)
543 >> SYM_BITS2_INDEX_SH_LITTLE
)
544 | (ext
->s_bits3
[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE
)
545 | ((unsigned int) ext
->s_bits4
[0]
546 << SYM_BITS4_INDEX_SH_LEFT_LITTLE
);
550 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
555 /* Swap out a symbol record. */
558 ecoff_swap_sym_out (abfd
, intern_copy
, ext_ptr
)
560 const SYMR
*intern_copy
;
563 struct sym_ext
*ext
= (struct sym_ext
*) ext_ptr
;
566 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
568 bfd_h_put_32 (abfd
, intern
->iss
, (bfd_byte
*)ext
->s_iss
);
569 ecoff_put_off (abfd
, intern
->value
, (bfd_byte
*)ext
->s_value
);
571 /* now the fun stuff... */
572 if (bfd_header_big_endian (abfd
)) {
573 ext
->s_bits1
[0] = (((intern
->st
<< SYM_BITS1_ST_SH_BIG
)
575 | ((intern
->sc
>> SYM_BITS1_SC_SH_LEFT_BIG
)
576 & SYM_BITS1_SC_BIG
));
577 ext
->s_bits2
[0] = (((intern
->sc
<< SYM_BITS2_SC_SH_BIG
)
579 | (intern
->reserved
? SYM_BITS2_RESERVED_BIG
: 0)
580 | ((intern
->index
>> SYM_BITS2_INDEX_SH_LEFT_BIG
)
581 & SYM_BITS2_INDEX_BIG
));
582 ext
->s_bits3
[0] = (intern
->index
>> SYM_BITS3_INDEX_SH_LEFT_BIG
) & 0xff;
583 ext
->s_bits4
[0] = (intern
->index
>> SYM_BITS4_INDEX_SH_LEFT_BIG
) & 0xff;
585 ext
->s_bits1
[0] = (((intern
->st
<< SYM_BITS1_ST_SH_LITTLE
)
586 & SYM_BITS1_ST_LITTLE
)
587 | ((intern
->sc
<< SYM_BITS1_SC_SH_LITTLE
)
588 & SYM_BITS1_SC_LITTLE
));
589 ext
->s_bits2
[0] = (((intern
->sc
>> SYM_BITS2_SC_SH_LEFT_LITTLE
)
590 & SYM_BITS2_SC_LITTLE
)
591 | (intern
->reserved
? SYM_BITS2_RESERVED_LITTLE
: 0)
592 | ((intern
->index
<< SYM_BITS2_INDEX_SH_LITTLE
)
593 & SYM_BITS2_INDEX_LITTLE
));
594 ext
->s_bits3
[0] = (intern
->index
>> SYM_BITS3_INDEX_SH_LEFT_LITTLE
) & 0xff;
595 ext
->s_bits4
[0] = (intern
->index
>> SYM_BITS4_INDEX_SH_LEFT_LITTLE
) & 0xff;
599 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
604 /* Swap in an external symbol record. */
607 ecoff_swap_ext_in (abfd
, ext_copy
, intern
)
612 struct ext_ext ext
[1];
614 *ext
= *(struct ext_ext
*) ext_copy
;
616 /* now the fun stuff... */
617 if (bfd_header_big_endian (abfd
)) {
618 intern
->jmptbl
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_JMPTBL_BIG
);
619 intern
->cobol_main
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_COBOL_MAIN_BIG
);
620 intern
->weakext
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_WEAKEXT_BIG
);
622 intern
->jmptbl
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_JMPTBL_LITTLE
);
623 intern
->cobol_main
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_COBOL_MAIN_LITTLE
);
624 intern
->weakext
= 0 != (ext
->es_bits1
[0] & EXT_BITS1_WEAKEXT_LITTLE
);
626 intern
->reserved
= 0;
629 intern
->ifd
= bfd_h_get_signed_16 (abfd
, (bfd_byte
*)ext
->es_ifd
);
632 intern
->ifd
= bfd_h_get_signed_32 (abfd
, (bfd_byte
*)ext
->es_ifd
);
635 ecoff_swap_sym_in (abfd
, &ext
->es_asym
, &intern
->asym
);
638 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
643 /* Swap out an external symbol record. */
646 ecoff_swap_ext_out (abfd
, intern_copy
, ext_ptr
)
648 const EXTR
*intern_copy
;
651 struct ext_ext
*ext
= (struct ext_ext
*) ext_ptr
;
654 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
656 /* now the fun stuff... */
657 if (bfd_header_big_endian (abfd
)) {
658 ext
->es_bits1
[0] = ((intern
->jmptbl
? EXT_BITS1_JMPTBL_BIG
: 0)
659 | (intern
->cobol_main
? EXT_BITS1_COBOL_MAIN_BIG
: 0)
660 | (intern
->weakext
? EXT_BITS1_WEAKEXT_BIG
: 0));
661 ext
->es_bits2
[0] = 0;
663 ext
->es_bits2
[1] = 0;
664 ext
->es_bits2
[2] = 0;
667 ext
->es_bits1
[0] = ((intern
->jmptbl
? EXT_BITS1_JMPTBL_LITTLE
: 0)
668 | (intern
->cobol_main
? EXT_BITS1_COBOL_MAIN_LITTLE
: 0)
669 | (intern
->weakext
? EXT_BITS1_WEAKEXT_LITTLE
: 0));
670 ext
->es_bits2
[0] = 0;
672 ext
->es_bits2
[1] = 0;
673 ext
->es_bits2
[2] = 0;
678 bfd_h_put_signed_16 (abfd
, intern
->ifd
, (bfd_byte
*)ext
->es_ifd
);
681 bfd_h_put_signed_32 (abfd
, intern
->ifd
, (bfd_byte
*)ext
->es_ifd
);
684 ecoff_swap_sym_out (abfd
, &intern
->asym
, &ext
->es_asym
);
687 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
692 /* Swap in a relative file descriptor. */
695 ecoff_swap_rfd_in (abfd
, ext_ptr
, intern
)
700 struct rfd_ext
*ext
= (struct rfd_ext
*) ext_ptr
;
702 *intern
= bfd_h_get_32 (abfd
, (bfd_byte
*)ext
->rfd
);
705 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
710 /* Swap out a relative file descriptor. */
713 ecoff_swap_rfd_out (abfd
, intern
, ext_ptr
)
718 struct rfd_ext
*ext
= (struct rfd_ext
*) ext_ptr
;
720 bfd_h_put_32 (abfd
, *intern
, (bfd_byte
*)ext
->rfd
);
723 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
728 /* Swap in an optimization symbol. */
731 ecoff_swap_opt_in (abfd
, ext_copy
, intern
)
736 struct opt_ext ext
[1];
738 *ext
= *(struct opt_ext
*) ext_copy
;
740 if (bfd_header_big_endian (abfd
))
742 intern
->ot
= ext
->o_bits1
[0];
743 intern
->value
= (((unsigned int) ext
->o_bits2
[0]
744 << OPT_BITS2_VALUE_SH_LEFT_BIG
)
745 | ((unsigned int) ext
->o_bits3
[0]
746 << OPT_BITS2_VALUE_SH_LEFT_BIG
)
747 | ((unsigned int) ext
->o_bits4
[0]
748 << OPT_BITS2_VALUE_SH_LEFT_BIG
));
752 intern
->ot
= ext
->o_bits1
[0];
753 intern
->value
= ((ext
->o_bits2
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
)
754 | (ext
->o_bits3
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
)
755 | (ext
->o_bits4
[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE
));
758 _bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd
),
759 &ext
->o_rndx
, &intern
->rndx
);
761 intern
->offset
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->o_offset
);
764 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
769 /* Swap out an optimization symbol. */
772 ecoff_swap_opt_out (abfd
, intern_copy
, ext_ptr
)
774 const OPTR
*intern_copy
;
777 struct opt_ext
*ext
= (struct opt_ext
*) ext_ptr
;
780 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
782 if (bfd_header_big_endian (abfd
))
784 ext
->o_bits1
[0] = intern
->ot
;
785 ext
->o_bits2
[0] = intern
->value
>> OPT_BITS2_VALUE_SH_LEFT_BIG
;
786 ext
->o_bits3
[0] = intern
->value
>> OPT_BITS3_VALUE_SH_LEFT_BIG
;
787 ext
->o_bits4
[0] = intern
->value
>> OPT_BITS4_VALUE_SH_LEFT_BIG
;
791 ext
->o_bits1
[0] = intern
->ot
;
792 ext
->o_bits2
[0] = intern
->value
>> OPT_BITS2_VALUE_SH_LEFT_LITTLE
;
793 ext
->o_bits3
[0] = intern
->value
>> OPT_BITS3_VALUE_SH_LEFT_LITTLE
;
794 ext
->o_bits4
[0] = intern
->value
>> OPT_BITS4_VALUE_SH_LEFT_LITTLE
;
797 _bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd
),
798 &intern
->rndx
, &ext
->o_rndx
);
800 bfd_h_put_32 (abfd
, intern
->value
, (bfd_byte
*) ext
->o_offset
);
803 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
808 /* Swap in a dense number. */
811 ecoff_swap_dnr_in (abfd
, ext_copy
, intern
)
816 struct dnr_ext ext
[1];
818 *ext
= *(struct dnr_ext
*) ext_copy
;
820 intern
->rfd
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->d_rfd
);
821 intern
->index
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->d_index
);
824 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)
829 /* Swap out a dense number. */
832 ecoff_swap_dnr_out (abfd
, intern_copy
, ext_ptr
)
834 const DNR
*intern_copy
;
837 struct dnr_ext
*ext
= (struct dnr_ext
*) ext_ptr
;
840 *intern
= *intern_copy
; /* Make it reasonable to do in-place. */
842 bfd_h_put_32 (abfd
, intern
->rfd
, (bfd_byte
*) ext
->d_rfd
);
843 bfd_h_put_32 (abfd
, intern
->index
, (bfd_byte
*) ext
->d_index
);
846 if (memcmp ((char *)ext
, (char *)intern
, sizeof (*intern
)) != 0)