1 /* Generic COFF swapping routines, for BFD.
2 Copyright 1990, 1991, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This file contains routines used to swap COFF data. It is a header
22 file because the details of swapping depend on the details of the
23 structures used by each COFF implementation. This is included by
24 coffcode.h, as well as by the ECOFF backend.
26 Any file which uses this must first include "coff/internal.h" and
27 "coff/CPU.h". The functions will then be correct for that CPU. */
29 #define PUTWORD bfd_h_put_32
30 #define PUTHALF bfd_h_put_16
31 #define PUTBYTE bfd_h_put_8
33 #ifndef GET_FCN_LNNOPTR
34 #define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
37 #ifndef GET_FCN_ENDNDX
38 #define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
41 #ifndef PUT_FCN_LNNOPTR
42 #define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
44 #ifndef PUT_FCN_ENDNDX
45 #define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
48 #define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
51 #define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
54 #define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
57 #define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
59 #ifndef GET_SCN_SCNLEN
60 #define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
62 #ifndef GET_SCN_NRELOC
63 #define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
65 #ifndef GET_SCN_NLINNO
66 #define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
68 #ifndef PUT_SCN_SCNLEN
69 #define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
71 #ifndef PUT_SCN_NRELOC
72 #define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
74 #ifndef PUT_SCN_NLINNO
75 #define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
77 #ifndef GET_LINENO_LNNO
78 #define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
80 #ifndef PUT_LINENO_LNNO
81 #define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
84 /* The f_symptr field in the filehdr is sometimes 64 bits. */
85 #ifndef GET_FILEHDR_SYMPTR
86 #define GET_FILEHDR_SYMPTR bfd_h_get_32
88 #ifndef PUT_FILEHDR_SYMPTR
89 #define PUT_FILEHDR_SYMPTR bfd_h_put_32
92 /* Some fields in the aouthdr are sometimes 64 bits. */
93 #ifndef GET_AOUTHDR_TSIZE
94 #define GET_AOUTHDR_TSIZE bfd_h_get_32
96 #ifndef PUT_AOUTHDR_TSIZE
97 #define PUT_AOUTHDR_TSIZE bfd_h_put_32
99 #ifndef GET_AOUTHDR_DSIZE
100 #define GET_AOUTHDR_DSIZE bfd_h_get_32
102 #ifndef PUT_AOUTHDR_DSIZE
103 #define PUT_AOUTHDR_DSIZE bfd_h_put_32
105 #ifndef GET_AOUTHDR_BSIZE
106 #define GET_AOUTHDR_BSIZE bfd_h_get_32
108 #ifndef PUT_AOUTHDR_BSIZE
109 #define PUT_AOUTHDR_BSIZE bfd_h_put_32
111 #ifndef GET_AOUTHDR_ENTRY
112 #define GET_AOUTHDR_ENTRY bfd_h_get_32
114 #ifndef PUT_AOUTHDR_ENTRY
115 #define PUT_AOUTHDR_ENTRY bfd_h_put_32
117 #ifndef GET_AOUTHDR_TEXT_START
118 #define GET_AOUTHDR_TEXT_START bfd_h_get_32
120 #ifndef PUT_AOUTHDR_TEXT_START
121 #define PUT_AOUTHDR_TEXT_START bfd_h_put_32
123 #ifndef GET_AOUTHDR_DATA_START
124 #define GET_AOUTHDR_DATA_START bfd_h_get_32
126 #ifndef PUT_AOUTHDR_DATA_START
127 #define PUT_AOUTHDR_DATA_START bfd_h_put_32
130 /* Some fields in the scnhdr are sometimes 64 bits. */
131 #ifndef GET_SCNHDR_PADDR
132 #define GET_SCNHDR_PADDR bfd_h_get_32
134 #ifndef PUT_SCNHDR_PADDR
135 #define PUT_SCNHDR_PADDR bfd_h_put_32
137 #ifndef GET_SCNHDR_VADDR
138 #define GET_SCNHDR_VADDR bfd_h_get_32
140 #ifndef PUT_SCNHDR_VADDR
141 #define PUT_SCNHDR_VADDR bfd_h_put_32
143 #ifndef GET_SCNHDR_SIZE
144 #define GET_SCNHDR_SIZE bfd_h_get_32
146 #ifndef PUT_SCNHDR_SIZE
147 #define PUT_SCNHDR_SIZE bfd_h_put_32
149 #ifndef GET_SCNHDR_SCNPTR
150 #define GET_SCNHDR_SCNPTR bfd_h_get_32
152 #ifndef PUT_SCNHDR_SCNPTR
153 #define PUT_SCNHDR_SCNPTR bfd_h_put_32
155 #ifndef GET_SCNHDR_RELPTR
156 #define GET_SCNHDR_RELPTR bfd_h_get_32
158 #ifndef PUT_SCNHDR_RELPTR
159 #define PUT_SCNHDR_RELPTR bfd_h_put_32
161 #ifndef GET_SCNHDR_LNNOPTR
162 #define GET_SCNHDR_LNNOPTR bfd_h_get_32
164 #ifndef PUT_SCNHDR_LNNOPTR
165 #define PUT_SCNHDR_LNNOPTR bfd_h_put_32
168 #ifndef NO_COFF_RELOCS
171 DEFUN(bfd_swap_reloc_in,(abfd, reloc_src, reloc_dst),
174 struct internal_reloc *reloc_dst)
176 reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
177 reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
180 reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
181 reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
183 reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
186 #ifdef SWAP_IN_RELOC_OFFSET
187 reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
188 (bfd_byte *) reloc_src->r_offset);
194 DEFUN(coff_swap_reloc_out,(abfd, src, dst),
199 struct internal_reloc *reloc_src = (struct internal_reloc *)src;
200 struct external_reloc *reloc_dst = (struct external_reloc *)dst;
201 bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
202 bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
203 bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
206 #ifdef SWAP_OUT_RELOC_OFFSET
207 SWAP_OUT_RELOC_OFFSET(abfd,
209 (bfd_byte *) reloc_dst->r_offset);
211 #ifdef SWAP_OUT_RELOC_EXTRA
212 SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
215 return sizeof(struct external_reloc);
218 #endif /* NO_COFF_RELOCS */
221 DEFUN(coff_swap_filehdr_in,(abfd, src, dst),
226 FILHDR *filehdr_src = (FILHDR *) src;
227 struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
228 filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
229 filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
230 filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
231 filehdr_dst->f_symptr =
232 GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr);
233 filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
234 filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
235 filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
239 DEFUN(coff_swap_filehdr_out,(abfd, in, out),
244 struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
245 FILHDR *filehdr_out = (FILHDR *)out;
246 bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
247 bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
248 bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
249 PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
250 (bfd_byte *) filehdr_out->f_symptr);
251 bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
252 bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
253 bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
254 return sizeof(FILHDR);
258 #ifndef NO_COFF_SYMBOLS
261 DEFUN(coff_swap_sym_in,(abfd, ext1, in1),
266 SYMENT *ext = (SYMENT *)ext1;
267 struct internal_syment *in = (struct internal_syment *)in1;
269 if( ext->e.e_name[0] == 0) {
270 in->_n._n_n._n_zeroes = 0;
271 in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
274 #if SYMNMLEN != E_SYMNMLEN
275 -> Error, we need to cope with truncating or extending SYMNMLEN!;
277 memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
280 in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
281 in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
282 if (sizeof(ext->e_type) == 2){
283 in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
286 in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
288 in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
289 in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
293 DEFUN(coff_swap_sym_out,(abfd, inp, extp),
298 struct internal_syment *in = (struct internal_syment *)inp;
299 SYMENT *ext =(SYMENT *)extp;
300 if(in->_n._n_name[0] == 0) {
301 bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
302 bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
305 #if SYMNMLEN != E_SYMNMLEN
306 -> Error, we need to cope with truncating or extending SYMNMLEN!;
308 memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
311 bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
312 bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
313 if (sizeof(ext->e_type) == 2)
315 bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
319 bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
321 bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
322 bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
323 return sizeof(SYMENT);
327 DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
334 AUXENT *ext = (AUXENT *)ext1;
335 union internal_auxent *in = (union internal_auxent *)in1;
339 if (ext->x_file.x_fname[0] == 0) {
340 in->x_file.x_n.x_zeroes = 0;
341 in->x_file.x_n.x_offset =
342 bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
344 #if FILNMLEN != E_FILNMLEN
345 -> Error, we need to cope with truncating or extending FILNMLEN!;
347 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
352 /* RS/6000 "csect" auxents */
356 in->x_csect.x_scnlen = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_scnlen);
357 in->x_csect.x_parmhash = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_parmhash);
358 in->x_csect.x_snhash = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snhash);
359 /* We don't have to hack bitfields in x_smtyp because it's defined by
360 shifts-and-ands, which are equivalent on all byte orders. */
361 in->x_csect.x_smtyp = bfd_h_get_8 (abfd, (bfd_byte *) ext->x_csect.x_smtyp);
362 in->x_csect.x_smclas = bfd_h_get_8 (abfd, (bfd_byte *) ext->x_csect.x_smclas);
363 in->x_csect.x_stab = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_stab);
364 in->x_csect.x_snstab = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snstab);
373 if (type == T_NULL) {
374 in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
375 in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
376 in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
380 in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
382 in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
386 #if DIMNUM != E_DIMNUM
387 -> Error, we need to cope with truncating or extending DIMNUM!;
389 in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
390 in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
391 in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
392 in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
395 if (class == C_BLOCK || ISFCN(type) || ISTAG(class)) {
396 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR(abfd, ext);
397 in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX(abfd, ext);
401 in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
404 in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
405 in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
411 DEFUN(coff_swap_aux_out,(abfd, inp, type, class, extp),
418 union internal_auxent *in = (union internal_auxent *)inp;
419 AUXENT *ext = (AUXENT *)extp;
421 memset((PTR)ext, 0, AUXESZ);
424 if (in->x_file.x_fname[0] == 0) {
425 PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
427 in->x_file.x_n.x_offset,
428 (bfd_byte *) ext->x_file.x_n.x_offset);
431 #if FILNMLEN != E_FILNMLEN
432 -> Error, we need to cope with truncating or extending FILNMLEN!;
434 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
440 /* RS/6000 "csect" auxents */
443 PUTWORD (abfd, in->x_csect.x_scnlen, ext->x_csect.x_scnlen);
444 PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
445 PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
446 /* We don't have to hack bitfields in x_smtyp because it's defined by
447 shifts-and-ands, which are equivalent on all byte orders. */
448 PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
449 PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
450 PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
451 PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
460 if (type == T_NULL) {
461 PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
462 PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
463 PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
467 PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
469 bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
472 if (class == C_BLOCK || ISFCN(type) || ISTAG(class)) {
473 PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
474 PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
478 PUTWORD(abfd, in->x_sym.x_misc.x_fsize, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
482 #if DIMNUM != E_DIMNUM
483 -> Error, we need to cope with truncating or extending DIMNUM!;
485 bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
486 bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
487 bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
488 bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
491 PUT_LNSZ_LNNO(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
492 PUT_LNSZ_SIZE(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
495 return sizeof(AUXENT);
498 #endif /* NO_COFF_SYMBOLS */
500 #ifndef NO_COFF_LINENOS
503 DEFUN(coff_swap_lineno_in,(abfd, ext1, in1),
508 LINENO *ext = (LINENO *)ext1;
509 struct internal_lineno *in = (struct internal_lineno *)in1;
511 in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
512 in->l_lnno = GET_LINENO_LNNO(abfd, ext);
516 DEFUN(coff_swap_lineno_out,(abfd, inp, outp),
521 struct internal_lineno *in = (struct internal_lineno *)inp;
522 struct external_lineno *ext = (struct external_lineno *)outp;
523 PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
524 ext->l_addr.l_symndx);
526 PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
527 return sizeof(struct external_lineno);
530 #endif /* NO_COFF_LINENOS */
534 DEFUN(coff_swap_aouthdr_in,(abfd, aouthdr_ext1, aouthdr_int1),
539 AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
540 struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
542 aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
543 aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
545 GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
547 GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
549 GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
551 GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
552 aouthdr_int->text_start =
553 GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
554 aouthdr_int->data_start =
555 GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
558 aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
562 aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
563 aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
564 aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
565 aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
566 aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
567 aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
568 aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
569 aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
570 aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
571 aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
572 aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
576 aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
577 aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
578 aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
579 aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
580 aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
581 aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
582 aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
586 aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start);
587 aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value);
588 aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
589 aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask);
594 DEFUN(coff_swap_aouthdr_out,(abfd, in, out),
599 struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
600 AOUTHDR *aouthdr_out = (AOUTHDR *)out;
602 bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
603 bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
604 PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
605 PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
606 PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
607 PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
608 PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
609 (bfd_byte *) aouthdr_out->text_start);
610 PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
611 (bfd_byte *) aouthdr_out->data_start);
613 bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
617 bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
618 bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
619 bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
620 bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
621 bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
622 bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
623 bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
627 bfd_h_put_32(abfd, 0, (bfd_byte *) aouthdr_out->padding);
628 bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
629 bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
630 bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
631 bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask);
634 return sizeof(AOUTHDR);
638 DEFUN(coff_swap_scnhdr_in,(abfd, ext, in),
643 SCNHDR *scnhdr_ext = (SCNHDR *) ext;
644 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
646 memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
647 scnhdr_int->s_vaddr =
648 GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
649 scnhdr_int->s_paddr =
650 GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
652 GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
654 scnhdr_int->s_scnptr =
655 GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
656 scnhdr_int->s_relptr =
657 GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
658 scnhdr_int->s_lnnoptr =
659 GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
660 scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
662 scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
663 scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
665 scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
666 scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
669 scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
674 DEFUN(coff_swap_scnhdr_out,(abfd, in, out),
679 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
680 SCNHDR *scnhdr_ext = (SCNHDR *)out;
682 memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
683 PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr,
684 (bfd_byte *) scnhdr_ext->s_vaddr);
685 PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr,
686 (bfd_byte *) scnhdr_ext->s_paddr);
687 PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size,
688 (bfd_byte *) scnhdr_ext->s_size);
689 PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
690 (bfd_byte *) scnhdr_ext->s_scnptr);
691 PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
692 (bfd_byte *) scnhdr_ext->s_relptr);
693 PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
694 (bfd_byte *) scnhdr_ext->s_lnnoptr);
695 PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags);
697 PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
698 PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
700 PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
701 PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
705 PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
707 return sizeof(SCNHDR);