1 /* Generic ECOFF swapping routines, for BFD.
2 Copyright 1992, 1993, 1994, 1995, 1996, 2000, 2001
3 Free Software Foundation, Inc.
4 Written by Cygnus Support.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 /* NOTE: This is a header file, but it contains executable routines.
23 This is done this way because these routines are substantially
24 similar, but are not identical, for all ECOFF targets.
26 These are routines to swap the ECOFF symbolic information in and
27 out. The routines are defined statically. You can set breakpoints
28 on them in gdb by naming the including source file; e.g.,
29 'coff-mips.c':ecoff_swap_hdr_in.
31 Before including this header file, one of ECOFF_32, ECOFF_64,
32 ECOFF_SIGNED_32 or ECOFF_SIGNED_64 must be defined. These are
33 checked when swapping information that depends upon the target
34 size. This code works for 32 bit and 64 bit ECOFF, but may need to
35 be generalized in the future.
37 Some header file which defines the external forms of these
38 structures must also be included before including this header file.
39 Currently this is either coff/mips.h or coff/alpha.h.
41 If the symbol TEST is defined when this file is compiled, a
42 comparison is made to ensure that, in fact, the output is
43 bit-for-bit the same as the input. Of course, this symbol should
44 only be defined when deliberately testing the code on a machine
45 with the proper byte sex and such. */
48 #define ecoff_get_off bfd_h_get_32
49 #define ecoff_put_off bfd_h_put_32
52 #define ecoff_get_off bfd_h_get_64
53 #define ecoff_put_off bfd_h_put_64
55 #ifdef ECOFF_SIGNED_32
56 #define ecoff_get_off bfd_h_get_signed_32
57 #define ecoff_put_off bfd_h_put_signed_32
59 #ifdef ECOFF_SIGNED_64
60 #define ecoff_get_off bfd_h_get_signed_64
61 #define ecoff_put_off bfd_h_put_signed_64
64 /* ECOFF auxiliary information swapping routines. These are the same
65 for all ECOFF targets, so they are defined in ecofflink.c. */
67 extern void _bfd_ecoff_swap_tir_in
68 PARAMS ((int, const struct tir_ext *, TIR *));
69 extern void _bfd_ecoff_swap_tir_out
70 PARAMS ((int, const TIR *, struct tir_ext *));
71 extern void _bfd_ecoff_swap_rndx_in
72 PARAMS ((int, const struct rndx_ext *, RNDXR *));
73 extern void _bfd_ecoff_swap_rndx_out
74 PARAMS ((int, const RNDXR *, struct rndx_ext *));
76 /* Prototypes for functions defined in this file. */
78 static void ecoff_swap_hdr_in PARAMS ((bfd *, PTR, HDRR *));
79 static void ecoff_swap_hdr_out PARAMS ((bfd *, const HDRR *, PTR));
80 static void ecoff_swap_fdr_in PARAMS ((bfd *, PTR, FDR *));
81 static void ecoff_swap_fdr_out PARAMS ((bfd *, const FDR *, PTR));
82 static void ecoff_swap_pdr_in PARAMS ((bfd *, PTR, PDR *));
83 static void ecoff_swap_pdr_out PARAMS ((bfd *, const PDR *, PTR));
84 static void ecoff_swap_sym_in PARAMS ((bfd *, PTR, SYMR *));
85 static void ecoff_swap_sym_out PARAMS ((bfd *, const SYMR *, PTR));
86 static void ecoff_swap_ext_in PARAMS ((bfd *, PTR, EXTR *));
87 static void ecoff_swap_ext_out PARAMS ((bfd *, const EXTR *, PTR));
88 static void ecoff_swap_rfd_in PARAMS ((bfd *, PTR, RFDT *));
89 static void ecoff_swap_rfd_out PARAMS ((bfd *, const RFDT *, PTR));
90 static void ecoff_swap_opt_in PARAMS ((bfd *, PTR, OPTR *));
91 static void ecoff_swap_opt_out PARAMS ((bfd *, const OPTR *, PTR));
92 static void ecoff_swap_dnr_in PARAMS ((bfd *, PTR, DNR *));
93 static void ecoff_swap_dnr_out PARAMS ((bfd *, const DNR *, PTR));
95 /* Swap in the symbolic header. */
98 ecoff_swap_hdr_in (abfd, ext_copy, intern)
103 struct hdr_ext ext[1];
105 *ext = *(struct hdr_ext *) ext_copy;
107 intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic);
108 intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp);
109 intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
110 intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine);
111 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset);
112 intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
113 intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset);
114 intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
115 intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset);
116 intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
117 intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset);
118 intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
119 intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset);
120 intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
121 intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset);
122 intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
123 intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset);
124 intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
125 intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
126 intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
127 intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset);
128 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
129 intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset);
130 intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
131 intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset);
134 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
139 /* Swap out the symbolic header. */
142 ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr)
144 const HDRR *intern_copy;
147 struct hdr_ext *ext = (struct hdr_ext *) ext_ptr;
150 *intern = *intern_copy;
152 bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
153 bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
154 bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
155 ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
156 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
157 bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
158 ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
159 bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
160 ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
161 bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
162 ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
163 bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
164 ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
165 bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
166 ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
167 bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
168 ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
169 bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
170 ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
171 bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
172 ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
173 bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
174 ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
175 bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
176 ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
179 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
184 /* Swap in the file descriptor record. */
187 ecoff_swap_fdr_in (abfd, ext_copy, intern)
192 struct fdr_ext ext[1];
194 *ext = *(struct fdr_ext *) ext_copy;
196 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr);
197 intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
198 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
199 if (intern->rss == (signed long) 0xffffffff)
202 intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
203 intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs);
204 intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
205 intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
206 intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
207 intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
208 intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
209 intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
210 #if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
211 intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
212 intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
214 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
215 intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst);
216 intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd);
218 intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
219 intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
220 intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
221 intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
223 /* now the fun stuff... */
224 if (bfd_header_big_endian (abfd)) {
225 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
226 >> FDR_BITS1_LANG_SH_BIG;
227 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
228 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
229 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
230 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
231 >> FDR_BITS2_GLEVEL_SH_BIG;
233 intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
234 >> FDR_BITS1_LANG_SH_LITTLE;
235 intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
236 intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
237 intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
238 intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
239 >> FDR_BITS2_GLEVEL_SH_LITTLE;
241 intern->reserved = 0;
243 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset);
244 intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine);
247 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
252 /* Swap out the file descriptor record. */
255 ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr)
257 const FDR *intern_copy;
260 struct fdr_ext *ext = (struct fdr_ext *) ext_ptr;
263 *intern = *intern_copy; /* Make it reasonable to do in-place. */
265 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr);
266 bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
267 bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
268 ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
269 bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
270 bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
271 bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
272 bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
273 bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
274 bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
275 #if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
276 bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
277 bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
279 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
280 bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
281 bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
283 bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
284 bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
285 bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
286 bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
288 /* now the fun stuff... */
289 if (bfd_header_big_endian (abfd)) {
290 ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
291 & FDR_BITS1_LANG_BIG)
292 | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
293 | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
294 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
295 ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
296 & FDR_BITS2_GLEVEL_BIG);
300 ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
301 & FDR_BITS1_LANG_LITTLE)
302 | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
303 | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
304 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
305 ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
306 & FDR_BITS2_GLEVEL_LITTLE);
311 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
312 ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
315 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
322 /* Swap in the procedure descriptor record. */
325 ecoff_swap_pdr_in (abfd, ext_copy, intern)
330 struct pdr_ext ext[1];
332 *ext = *(struct pdr_ext *) ext_copy;
334 memset ((PTR) intern, 0, sizeof (*intern));
336 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
337 intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
338 intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
339 intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
340 intern->regoffset = bfd_h_get_signed_32 (abfd,
341 (bfd_byte *)ext->p_regoffset);
342 intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
343 intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
344 intern->fregoffset = bfd_h_get_signed_32 (abfd,
345 (bfd_byte *)ext->p_fregoffset);
346 intern->frameoffset = bfd_h_get_signed_32 (abfd,
347 (bfd_byte *)ext->p_frameoffset);
348 intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
349 intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
350 intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
351 intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
352 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
354 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
355 intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue);
356 if (bfd_header_big_endian (abfd))
358 intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG);
359 intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG);
360 intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_BIG);
361 intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG)
362 << PDR_BITS1_RESERVED_SH_LEFT_BIG)
363 | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG)
364 >> PDR_BITS2_RESERVED_SH_BIG));
368 intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE);
369 intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE);
370 intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_LITTLE);
371 intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE)
372 >> PDR_BITS1_RESERVED_SH_LITTLE)
373 | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE)
374 << PDR_BITS2_RESERVED_SH_LEFT_LITTLE));
376 intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff);
380 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
385 /* Swap out the procedure descriptor record. */
388 ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
390 const PDR *intern_copy;
393 struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
396 *intern = *intern_copy; /* Make it reasonable to do in-place. */
398 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
399 bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
400 bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
401 bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
402 bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
403 bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
404 bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
405 bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
406 bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
407 bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
408 bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
409 bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
410 bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
411 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
413 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
414 bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue);
415 if (bfd_header_big_endian (abfd))
417 ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0)
418 | (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0)
419 | (intern->prof ? PDR_BITS1_PROF_BIG : 0)
421 >> PDR_BITS1_RESERVED_SH_LEFT_BIG)
422 & PDR_BITS1_RESERVED_BIG));
423 ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG)
424 & PDR_BITS2_RESERVED_BIG);
428 ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0)
429 | (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0)
430 | (intern->prof ? PDR_BITS1_PROF_LITTLE : 0)
431 | ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE)
432 & PDR_BITS1_RESERVED_LITTLE));
433 ext->p_bits2[0] = ((intern->reserved >>
434 PDR_BITS2_RESERVED_SH_LEFT_LITTLE)
435 & PDR_BITS2_RESERVED_LITTLE);
437 bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff);
441 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
447 /* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't
448 corrupt itself and then freak out. */
449 /* Swap in the procedure descriptor record. */
452 ecoff_swap_pdr_in (abfd, ext_copy, intern)
457 struct pdr_ext ext[1];
459 *ext = *(struct pdr_ext *) ext_copy;
461 intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
462 intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
463 intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
464 intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
465 intern->regoffset = bfd_h_get_signed_32 (abfd,
466 (bfd_byte *)ext->p_regoffset);
467 intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
468 intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
469 intern->fregoffset = bfd_h_get_signed_32 (abfd,
470 (bfd_byte *)ext->p_fregoffset);
471 intern->frameoffset = bfd_h_get_signed_32 (abfd,
472 (bfd_byte *)ext->p_frameoffset);
473 intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
474 intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
475 intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
476 intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
477 intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
480 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
485 /* Swap out the procedure descriptor record. */
488 ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
490 const PDR *intern_copy;
493 struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
496 *intern = *intern_copy; /* Make it reasonable to do in-place. */
498 ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
499 bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
500 bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
501 bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
502 bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
503 bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
504 bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
505 bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
506 bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
507 bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
508 bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
509 bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
510 bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
511 ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
514 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
520 /* Swap in a symbol record. */
523 ecoff_swap_sym_in (abfd, ext_copy, intern)
528 struct sym_ext ext[1];
530 *ext = *(struct sym_ext *) ext_copy;
532 intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
533 intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value);
535 /* now the fun stuff... */
536 if (bfd_header_big_endian (abfd)) {
537 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
538 >> SYM_BITS1_ST_SH_BIG;
539 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
540 << SYM_BITS1_SC_SH_LEFT_BIG)
541 | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
542 >> SYM_BITS2_SC_SH_BIG);
543 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
544 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
545 << SYM_BITS2_INDEX_SH_LEFT_BIG)
546 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
547 | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
549 intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
550 >> SYM_BITS1_ST_SH_LITTLE;
551 intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
552 >> SYM_BITS1_SC_SH_LITTLE)
553 | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
554 << SYM_BITS2_SC_SH_LEFT_LITTLE);
555 intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
556 intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
557 >> SYM_BITS2_INDEX_SH_LITTLE)
558 | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
559 | ((unsigned int) ext->s_bits4[0]
560 << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
564 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
569 /* Swap out a symbol record. */
572 ecoff_swap_sym_out (abfd, intern_copy, ext_ptr)
574 const SYMR *intern_copy;
577 struct sym_ext *ext = (struct sym_ext *) ext_ptr;
580 *intern = *intern_copy; /* Make it reasonable to do in-place. */
582 bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
583 ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value);
585 /* now the fun stuff... */
586 if (bfd_header_big_endian (abfd)) {
587 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
589 | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
590 & SYM_BITS1_SC_BIG));
591 ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
593 | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
594 | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
595 & SYM_BITS2_INDEX_BIG));
596 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
597 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
599 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
600 & SYM_BITS1_ST_LITTLE)
601 | ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
602 & SYM_BITS1_SC_LITTLE));
603 ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
604 & SYM_BITS2_SC_LITTLE)
605 | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
606 | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
607 & SYM_BITS2_INDEX_LITTLE));
608 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
609 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
613 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
618 /* Swap in an external symbol record. */
621 ecoff_swap_ext_in (abfd, ext_copy, intern)
626 struct ext_ext ext[1];
628 *ext = *(struct ext_ext *) ext_copy;
630 /* now the fun stuff... */
631 if (bfd_header_big_endian (abfd)) {
632 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
633 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
634 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
636 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
637 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
638 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
640 intern->reserved = 0;
642 #if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
643 intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd);
645 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
646 intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd);
649 ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
652 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
657 /* Swap out an external symbol record. */
660 ecoff_swap_ext_out (abfd, intern_copy, ext_ptr)
662 const EXTR *intern_copy;
665 struct ext_ext *ext = (struct ext_ext *) ext_ptr;
668 *intern = *intern_copy; /* Make it reasonable to do in-place. */
670 /* now the fun stuff... */
671 if (bfd_header_big_endian (abfd)) {
672 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
673 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
674 | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
675 ext->es_bits2[0] = 0;
676 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
677 ext->es_bits2[1] = 0;
678 ext->es_bits2[2] = 0;
681 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
682 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
683 | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
684 ext->es_bits2[0] = 0;
685 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
686 ext->es_bits2[1] = 0;
687 ext->es_bits2[2] = 0;
691 #if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
692 bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
694 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
695 bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
698 ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
701 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
706 /* Swap in a relative file descriptor. */
709 ecoff_swap_rfd_in (abfd, ext_ptr, intern)
714 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
716 *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
719 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
724 /* Swap out a relative file descriptor. */
727 ecoff_swap_rfd_out (abfd, intern, ext_ptr)
732 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
734 bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
737 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
742 /* Swap in an optimization symbol. */
745 ecoff_swap_opt_in (abfd, ext_copy, intern)
750 struct opt_ext ext[1];
752 *ext = *(struct opt_ext *) ext_copy;
754 if (bfd_header_big_endian (abfd))
756 intern->ot = ext->o_bits1[0];
757 intern->value = (((unsigned int) ext->o_bits2[0]
758 << OPT_BITS2_VALUE_SH_LEFT_BIG)
759 | ((unsigned int) ext->o_bits3[0]
760 << OPT_BITS2_VALUE_SH_LEFT_BIG)
761 | ((unsigned int) ext->o_bits4[0]
762 << OPT_BITS2_VALUE_SH_LEFT_BIG));
766 intern->ot = ext->o_bits1[0];
767 intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
768 | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
769 | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
772 _bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd),
773 &ext->o_rndx, &intern->rndx);
775 intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
778 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
783 /* Swap out an optimization symbol. */
786 ecoff_swap_opt_out (abfd, intern_copy, ext_ptr)
788 const OPTR *intern_copy;
791 struct opt_ext *ext = (struct opt_ext *) ext_ptr;
794 *intern = *intern_copy; /* Make it reasonable to do in-place. */
796 if (bfd_header_big_endian (abfd))
798 ext->o_bits1[0] = intern->ot;
799 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
800 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
801 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
805 ext->o_bits1[0] = intern->ot;
806 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
807 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
808 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
811 _bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd),
812 &intern->rndx, &ext->o_rndx);
814 bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
817 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
822 /* Swap in a dense number. */
825 ecoff_swap_dnr_in (abfd, ext_copy, intern)
830 struct dnr_ext ext[1];
832 *ext = *(struct dnr_ext *) ext_copy;
834 intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
835 intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
838 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
843 /* Swap out a dense number. */
846 ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr)
848 const DNR *intern_copy;
851 struct dnr_ext *ext = (struct dnr_ext *) ext_ptr;
854 *intern = *intern_copy; /* Make it reasonable to do in-place. */
856 bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
857 bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
860 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)