These changes cut the size of libbfd.a on a Sun4 by about 11%.
[deliverable/binutils-gdb.git] / bfd / coffswap.h
1 /* Generic COFF swapping routines, for BFD.
2 Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
3 Written by Cygnus Support.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
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.
11
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.
16
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. */
20
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.
25
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. */
28
29 #define PUTWORD bfd_h_put_32
30 #define PUTHALF bfd_h_put_16
31 #define PUTBYTE bfd_h_put_8
32
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)
35 #endif
36
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)
39 #endif
40
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)
43 #endif
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)
46 #endif
47 #ifndef GET_LNSZ_LNNO
48 #define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
49 #endif
50 #ifndef GET_LNSZ_SIZE
51 #define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
52 #endif
53 #ifndef PUT_LNSZ_LNNO
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)
55 #endif
56 #ifndef PUT_LNSZ_SIZE
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)
58 #endif
59 #ifndef GET_SCN_SCNLEN
60 #define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
61 #endif
62 #ifndef GET_SCN_NRELOC
63 #define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
64 #endif
65 #ifndef GET_SCN_NLINNO
66 #define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
67 #endif
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)
70 #endif
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)
73 #endif
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)
76 #endif
77 #ifndef GET_LINENO_LNNO
78 #define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
79 #endif
80 #ifndef PUT_LINENO_LNNO
81 #define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
82 #endif
83
84 static void
85 DEFUN(bfd_swap_reloc_in,(abfd, reloc_src, reloc_dst),
86 bfd *abfd AND
87 RELOC *reloc_src AND
88 struct internal_reloc *reloc_dst)
89 {
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);
92
93 #ifdef RS6000COFF_C
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);
96 #else
97 reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
98 #endif
99
100 #ifdef SWAP_IN_RELOC_OFFSET
101 reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
102 (bfd_byte *) reloc_src->r_offset);
103 #endif
104 }
105
106
107 static unsigned int
108 DEFUN(coff_swap_reloc_out,(abfd, src, dst),
109 bfd *abfd AND
110 PTR src AND
111 PTR dst)
112 {
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 *)
118 reloc_dst->r_type);
119
120 #ifdef SWAP_OUT_RELOC_OFFSET
121 SWAP_OUT_RELOC_OFFSET(abfd,
122 reloc_src->r_offset,
123 (bfd_byte *) reloc_dst->r_offset);
124 #endif
125 #ifdef SWAP_OUT_RELOC_EXTRA
126 SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
127 #endif
128
129 return sizeof(struct external_reloc);
130 }
131
132 static void
133 DEFUN(coff_swap_filehdr_in,(abfd, src, dst),
134 bfd *abfd AND
135 PTR src AND
136 PTR dst)
137 {
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);
147 }
148
149 static unsigned int
150 DEFUN(coff_swap_filehdr_out,(abfd, in, out),
151 bfd *abfd AND
152 PTR in AND
153 PTR out)
154 {
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);
165 }
166
167
168 #ifndef NO_COFF_SYMBOLS
169
170 static void
171 DEFUN(coff_swap_sym_in,(abfd, ext1, in1),
172 bfd *abfd AND
173 PTR ext1 AND
174 PTR in1)
175 {
176 SYMENT *ext = (SYMENT *)ext1;
177 struct internal_syment *in = (struct internal_syment *)in1;
178
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);
182 }
183 else {
184 #if SYMNMLEN != E_SYMNMLEN
185 -> Error, we need to cope with truncating or extending SYMNMLEN!;
186 #else
187 memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
188 #endif
189 }
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);
194 }
195 else {
196 in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
197 }
198 in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
199 in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
200 }
201
202 static unsigned int
203 DEFUN(coff_swap_sym_out,(abfd, inp, extp),
204 bfd *abfd AND
205 PTR inp AND
206 PTR extp)
207 {
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);
213 }
214 else {
215 #if SYMNMLEN != E_SYMNMLEN
216 -> Error, we need to cope with truncating or extending SYMNMLEN!;
217 #else
218 memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
219 #endif
220 }
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)
224 {
225 bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
226 }
227 else
228 {
229 bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
230 }
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);
234 }
235
236 static void
237 DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
238 bfd *abfd AND
239 PTR ext1 AND
240 int type AND
241 int class AND
242 PTR in1)
243 {
244 AUXENT *ext = (AUXENT *)ext1;
245 union internal_auxent *in = (union internal_auxent *)in1;
246
247 switch (class) {
248 case C_FILE:
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);
253 } else {
254 #if FILNMLEN != E_FILNMLEN
255 -> Error, we need to cope with truncating or extending FILNMLEN!;
256 #else
257 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
258 #endif
259 }
260 break;
261
262 /* RS/6000 "csect" auxents */
263 #ifdef RS6000COFF_C
264 case C_EXT:
265 case C_HIDEXT:
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);
275 break;
276 #endif
277
278 case C_STAT:
279 #ifdef C_LEAFSTAT
280 case C_LEAFSTAT:
281 #endif
282 case C_HIDDEN:
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);
287 break;
288 }
289 default:
290 in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
291 #ifndef NO_TVNDX
292 in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
293 #endif
294
295 if (ISARY(type)) {
296 #if DIMNUM != E_DIMNUM
297 -> Error, we need to cope with truncating or extending DIMNUM!;
298 #else
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]);
303 #endif
304 }
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);
308 }
309
310 if (ISFCN(type)) {
311 in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
312 }
313 else {
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);
316 }
317 }
318 }
319
320 static unsigned int
321 DEFUN(coff_swap_aux_out,(abfd, inp, type, class, extp),
322 bfd *abfd AND
323 PTR inp AND
324 int type AND
325 int class AND
326 PTR extp)
327 {
328 union internal_auxent *in = (union internal_auxent *)inp;
329 AUXENT *ext = (AUXENT *)extp;
330
331 memset((PTR)ext, 0, AUXESZ);
332 switch (class) {
333 case C_FILE:
334 if (in->x_file.x_fname[0] == 0) {
335 PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
336 PUTWORD(abfd,
337 in->x_file.x_n.x_offset,
338 (bfd_byte *) ext->x_file.x_n.x_offset);
339 }
340 else {
341 #if FILNMLEN != E_FILNMLEN
342 -> Error, we need to cope with truncating or extending FILNMLEN!;
343 #else
344 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
345 #endif
346 }
347 break;
348
349 #ifdef RS6000COFF_C
350 /* RS/6000 "csect" auxents */
351 case C_EXT:
352 case C_HIDEXT:
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);
362 break;
363 #endif
364
365 case C_STAT:
366 #ifdef C_LEAFSTAT
367 case C_LEAFSTAT:
368 #endif
369 case C_HIDDEN:
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);
374 break;
375 }
376 default:
377 PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
378 #ifndef NO_TVNDX
379 bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
380 #endif
381
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);
385 }
386
387 if (ISFCN(type)) {
388 PUTWORD(abfd, in->x_sym.x_misc.x_fsize, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
389 }
390 else {
391 if (ISARY(type)) {
392 #if DIMNUM != E_DIMNUM
393 -> Error, we need to cope with truncating or extending DIMNUM!;
394 #else
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]);
399 #endif
400 }
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);
403 }
404 }
405 return sizeof(AUXENT);
406 }
407
408 #endif /* NO_COFF_SYMBOLS */
409
410 #ifndef NO_COFF_LINENOS
411
412 static void
413 DEFUN(coff_swap_lineno_in,(abfd, ext1, in1),
414 bfd *abfd AND
415 PTR ext1 AND
416 PTR in1)
417 {
418 LINENO *ext = (LINENO *)ext1;
419 struct internal_lineno *in = (struct internal_lineno *)in1;
420
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);
423 }
424
425 static unsigned int
426 DEFUN(coff_swap_lineno_out,(abfd, inp, outp),
427 bfd *abfd AND
428 PTR inp AND
429 PTR outp)
430 {
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);
435
436 PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
437 return sizeof(struct external_lineno);
438 }
439
440 #endif /* NO_COFF_LINENOS */
441
442
443 static void
444 DEFUN(coff_swap_aouthdr_in,(abfd, aouthdr_ext1, aouthdr_int1),
445 bfd *abfd AND
446 PTR aouthdr_ext1 AND
447 PTR aouthdr_int1)
448 {
449 AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
450 struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
451
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);
460 #ifdef I960
461 aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
462 #endif
463
464 #ifdef RS6000COFF_C
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);
476 #endif
477 }
478
479 static unsigned int
480 DEFUN(coff_swap_aouthdr_out,(abfd, in, out),
481 bfd *abfd AND
482 PTR in AND
483 PTR out)
484 {
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);
496 #ifdef I960
497 bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
498 #endif
499 return sizeof(AOUTHDR);
500 }
501
502 static void
503 DEFUN(coff_swap_scnhdr_in,(abfd, ext, in),
504 bfd *abfd AND
505 PTR ext AND
506 PTR in)
507 {
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);
514
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);
519 #if defined(M88)
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);
522 #else
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);
525 #endif
526 #ifdef I960
527 scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
528 #endif
529 }
530
531 static unsigned int
532 DEFUN(coff_swap_scnhdr_out,(abfd, in, out),
533 bfd *abfd AND
534 PTR in AND
535 PTR out)
536 {
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);
547 #if defined(M88)
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);
550 #else
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);
553 #endif
554
555 #if defined(I960)
556 PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
557 #endif
558 return sizeof(SCNHDR);
559 }
This page took 0.068854 seconds and 5 git commands to generate.