1 /* Generic COFF swapping routines, for BFD.
2 Copyright 1990, 1991, 1992 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));
85 DEFUN(bfd_swap_reloc_in,(abfd, reloc_src, reloc_dst),
88 struct internal_reloc *reloc_dst)
90 reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
91 reloc_dst->r_symndx = bfd_h_get_32(abfd, (bfd_byte *) reloc_src->r_symndx);
94 reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
95 reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
97 reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
100 #ifdef SWAP_IN_RELOC_OFFSET
101 reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
102 (bfd_byte *) reloc_src->r_offset);
108 DEFUN(coff_swap_reloc_out,(abfd, src, dst),
113 struct internal_reloc *reloc_src = (struct internal_reloc *)src;
114 struct external_reloc *reloc_dst = (struct external_reloc *)dst;
115 bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
116 bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
117 bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
120 #ifdef SWAP_OUT_RELOC_OFFSET
121 SWAP_OUT_RELOC_OFFSET(abfd,
123 (bfd_byte *) reloc_dst->r_offset);
125 #ifdef SWAP_OUT_RELOC_EXTRA
126 SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
129 return sizeof(struct external_reloc);
133 DEFUN(coff_swap_filehdr_in,(abfd, src, dst),
138 FILHDR *filehdr_src = (FILHDR *) src;
139 struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
140 filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
141 filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
142 filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
143 filehdr_dst->f_symptr = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_symptr);
144 filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
145 filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
146 filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
150 DEFUN(coff_swap_filehdr_out,(abfd, in, out),
155 struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
156 FILHDR *filehdr_out = (FILHDR *)out;
157 bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
158 bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
159 bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
160 bfd_h_put_32(abfd, filehdr_in->f_symptr, (bfd_byte *) filehdr_out->f_symptr);
161 bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
162 bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
163 bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
164 return sizeof(FILHDR);
168 #ifndef NO_COFF_SYMBOLS
171 DEFUN(coff_swap_sym_in,(abfd, ext1, in1),
176 SYMENT *ext = (SYMENT *)ext1;
177 struct internal_syment *in = (struct internal_syment *)in1;
179 if( ext->e.e_name[0] == 0) {
180 in->_n._n_n._n_zeroes = 0;
181 in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
184 #if SYMNMLEN != E_SYMNMLEN
185 -> Error, we need to cope with truncating or extending SYMNMLEN!;
187 memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
190 in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
191 in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
192 if (sizeof(ext->e_type) == 2){
193 in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
196 in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
198 in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
199 in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
203 DEFUN(coff_swap_sym_out,(abfd, inp, extp),
208 struct internal_syment *in = (struct internal_syment *)inp;
209 SYMENT *ext =(SYMENT *)extp;
210 if(in->_n._n_name[0] == 0) {
211 bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
212 bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
215 #if SYMNMLEN != E_SYMNMLEN
216 -> Error, we need to cope with truncating or extending SYMNMLEN!;
218 memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
221 bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
222 bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
223 if (sizeof(ext->e_type) == 2)
225 bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
229 bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
231 bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
232 bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
233 return sizeof(SYMENT);
237 DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
244 AUXENT *ext = (AUXENT *)ext1;
245 union internal_auxent *in = (union internal_auxent *)in1;
249 if (ext->x_file.x_fname[0] == 0) {
250 in->x_file.x_n.x_zeroes = 0;
251 in->x_file.x_n.x_offset =
252 bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
254 #if FILNMLEN != E_FILNMLEN
255 -> Error, we need to cope with truncating or extending FILNMLEN!;
257 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
262 /* RS/6000 "csect" auxents */
266 in->x_csect.x_scnlen = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_scnlen);
267 in->x_csect.x_parmhash = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_parmhash);
268 in->x_csect.x_snhash = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snhash);
269 /* We don't have to hack bitfields in x_smtyp because it's defined by
270 shifts-and-ands, which are equivalent on all byte orders. */
271 in->x_csect.x_smtyp = bfd_h_get_8 (abfd, (bfd_byte *) ext->x_csect.x_smtyp);
272 in->x_csect.x_smclas = bfd_h_get_8 (abfd, (bfd_byte *) ext->x_csect.x_smclas);
273 in->x_csect.x_stab = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_stab);
274 in->x_csect.x_snstab = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snstab);
283 if (type == T_NULL) {
284 in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
285 in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
286 in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
290 in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
292 in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
296 #if DIMNUM != E_DIMNUM
297 -> Error, we need to cope with truncating or extending DIMNUM!;
299 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]);
300 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]);
301 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]);
302 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]);
305 if (class == C_BLOCK || ISFCN(type) || ISTAG(class)) {
306 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR(abfd, ext);
307 in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX(abfd, ext);
311 in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
314 in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
315 in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
321 DEFUN(coff_swap_aux_out,(abfd, inp, type, class, extp),
328 union internal_auxent *in = (union internal_auxent *)inp;
329 AUXENT *ext = (AUXENT *)extp;
331 memset((PTR)ext, 0, AUXESZ);
334 if (in->x_file.x_fname[0] == 0) {
335 PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
337 in->x_file.x_n.x_offset,
338 (bfd_byte *) ext->x_file.x_n.x_offset);
341 #if FILNMLEN != E_FILNMLEN
342 -> Error, we need to cope with truncating or extending FILNMLEN!;
344 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
350 /* RS/6000 "csect" auxents */
353 PUTWORD (abfd, in->x_csect.x_scnlen, ext->x_csect.x_scnlen);
354 PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
355 PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
356 /* We don't have to hack bitfields in x_smtyp because it's defined by
357 shifts-and-ands, which are equivalent on all byte orders. */
358 PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
359 PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
360 PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
361 PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
370 if (type == T_NULL) {
371 PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
372 PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
373 PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
377 PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
379 bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
382 if (class == C_BLOCK || ISFCN(type) || ISTAG(class)) {
383 PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
384 PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
388 PUTWORD(abfd, in->x_sym.x_misc.x_fsize, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
392 #if DIMNUM != E_DIMNUM
393 -> Error, we need to cope with truncating or extending DIMNUM!;
395 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]);
396 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]);
397 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]);
398 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]);
401 PUT_LNSZ_LNNO(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
402 PUT_LNSZ_SIZE(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
405 return sizeof(AUXENT);
408 #endif /* NO_COFF_SYMBOLS */
410 #ifndef NO_COFF_LINENOS
413 DEFUN(coff_swap_lineno_in,(abfd, ext1, in1),
418 LINENO *ext = (LINENO *)ext1;
419 struct internal_lineno *in = (struct internal_lineno *)in1;
421 in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
422 in->l_lnno = GET_LINENO_LNNO(abfd, ext);
426 DEFUN(coff_swap_lineno_out,(abfd, inp, outp),
431 struct internal_lineno *in = (struct internal_lineno *)inp;
432 struct external_lineno *ext = (struct external_lineno *)outp;
433 PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
434 ext->l_addr.l_symndx);
436 PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
437 return sizeof(struct external_lineno);
440 #endif /* NO_COFF_LINENOS */
444 DEFUN(coff_swap_aouthdr_in,(abfd, aouthdr_ext1, aouthdr_int1),
449 AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
450 struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
452 aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
453 aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
454 aouthdr_int->tsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tsize);
455 aouthdr_int->dsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->dsize);
456 aouthdr_int->bsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->bsize);
457 aouthdr_int->entry = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->entry);
458 aouthdr_int->text_start = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->text_start);
459 aouthdr_int->data_start = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->data_start);
461 aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
465 aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
466 aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
467 aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
468 aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
469 aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
470 aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
471 aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
472 aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
473 aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
474 aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
475 aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
480 DEFUN(coff_swap_aouthdr_out,(abfd, in, out),
485 struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
486 AOUTHDR *aouthdr_out = (AOUTHDR *)out;
487 bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
488 bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
489 bfd_h_put_32(abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
490 bfd_h_put_32(abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
491 bfd_h_put_32(abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
492 bfd_h_put_32(abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
493 bfd_h_put_32(abfd, aouthdr_in->text_start,
494 (bfd_byte *) aouthdr_out->text_start);
495 bfd_h_put_32(abfd, aouthdr_in->data_start, (bfd_byte *) aouthdr_out->data_start);
497 bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
499 return sizeof(AOUTHDR);
503 DEFUN(coff_swap_scnhdr_in,(abfd, ext, in),
508 SCNHDR *scnhdr_ext = (SCNHDR *) ext;
509 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
510 memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
511 scnhdr_int->s_vaddr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
512 scnhdr_int->s_paddr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_paddr);
513 scnhdr_int->s_size = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_size);
515 scnhdr_int->s_scnptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
516 scnhdr_int->s_relptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_relptr);
517 scnhdr_int->s_lnnoptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
518 scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
520 scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
521 scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
523 scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
524 scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
527 scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
532 DEFUN(coff_swap_scnhdr_out,(abfd, in, out),
537 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
538 SCNHDR *scnhdr_ext = (SCNHDR *)out;
539 memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
540 PUTWORD(abfd, scnhdr_int->s_vaddr, (bfd_byte *) scnhdr_ext->s_vaddr);
541 PUTWORD(abfd, scnhdr_int->s_paddr, (bfd_byte *) scnhdr_ext->s_paddr);
542 PUTWORD(abfd, scnhdr_int->s_size, (bfd_byte *) scnhdr_ext->s_size);
543 PUTWORD(abfd, scnhdr_int->s_scnptr, (bfd_byte *) scnhdr_ext->s_scnptr);
544 PUTWORD(abfd, scnhdr_int->s_relptr, (bfd_byte *) scnhdr_ext->s_relptr);
545 PUTWORD(abfd, scnhdr_int->s_lnnoptr, (bfd_byte *) scnhdr_ext->s_lnnoptr);
546 PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags);
548 PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
549 PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
551 PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
552 PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
556 PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
558 return sizeof(SCNHDR);