1998-09-08 Jason Molenda (jsm@bugshack.cygnus.com)
[deliverable/binutils-gdb.git] / bfd / coffswap.h
CommitLineData
075caafd 1/* Generic COFF swapping routines, for BFD.
e8640d5e 2 Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
075caafd
ILT
3 Written by Cygnus Support.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
3ea928f5 19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
075caafd
ILT
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
3ea928f5
SC
29#ifndef IMAGE_BASE
30#define IMAGE_BASE 0
31#endif
32
075caafd
ILT
33#define PUTWORD bfd_h_put_32
34#define PUTHALF bfd_h_put_16
35#define PUTBYTE bfd_h_put_8
36
37#ifndef GET_FCN_LNNOPTR
38#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
39#endif
40
41#ifndef GET_FCN_ENDNDX
42#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
43#endif
44
45#ifndef PUT_FCN_LNNOPTR
46#define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
47#endif
48#ifndef PUT_FCN_ENDNDX
49#define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
50#endif
51#ifndef GET_LNSZ_LNNO
52#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
53#endif
54#ifndef GET_LNSZ_SIZE
55#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
56#endif
57#ifndef PUT_LNSZ_LNNO
58#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
59#endif
60#ifndef PUT_LNSZ_SIZE
61#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
62#endif
63#ifndef GET_SCN_SCNLEN
64#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
65#endif
66#ifndef GET_SCN_NRELOC
67#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
68#endif
69#ifndef GET_SCN_NLINNO
70#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
71#endif
72#ifndef PUT_SCN_SCNLEN
73#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
74#endif
75#ifndef PUT_SCN_NRELOC
76#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
77#endif
78#ifndef PUT_SCN_NLINNO
79#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
80#endif
81#ifndef GET_LINENO_LNNO
82#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
83#endif
84#ifndef PUT_LINENO_LNNO
85#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
86#endif
87
fbb61b50
SC
88/* The f_symptr field in the filehdr is sometimes 64 bits. */
89#ifndef GET_FILEHDR_SYMPTR
90#define GET_FILEHDR_SYMPTR bfd_h_get_32
91#endif
92#ifndef PUT_FILEHDR_SYMPTR
93#define PUT_FILEHDR_SYMPTR bfd_h_put_32
94#endif
95
96/* Some fields in the aouthdr are sometimes 64 bits. */
97#ifndef GET_AOUTHDR_TSIZE
98#define GET_AOUTHDR_TSIZE bfd_h_get_32
99#endif
100#ifndef PUT_AOUTHDR_TSIZE
101#define PUT_AOUTHDR_TSIZE bfd_h_put_32
102#endif
103#ifndef GET_AOUTHDR_DSIZE
104#define GET_AOUTHDR_DSIZE bfd_h_get_32
105#endif
106#ifndef PUT_AOUTHDR_DSIZE
107#define PUT_AOUTHDR_DSIZE bfd_h_put_32
108#endif
109#ifndef GET_AOUTHDR_BSIZE
110#define GET_AOUTHDR_BSIZE bfd_h_get_32
111#endif
112#ifndef PUT_AOUTHDR_BSIZE
113#define PUT_AOUTHDR_BSIZE bfd_h_put_32
114#endif
115#ifndef GET_AOUTHDR_ENTRY
116#define GET_AOUTHDR_ENTRY bfd_h_get_32
117#endif
118#ifndef PUT_AOUTHDR_ENTRY
119#define PUT_AOUTHDR_ENTRY bfd_h_put_32
120#endif
121#ifndef GET_AOUTHDR_TEXT_START
122#define GET_AOUTHDR_TEXT_START bfd_h_get_32
123#endif
124#ifndef PUT_AOUTHDR_TEXT_START
125#define PUT_AOUTHDR_TEXT_START bfd_h_put_32
126#endif
127#ifndef GET_AOUTHDR_DATA_START
128#define GET_AOUTHDR_DATA_START bfd_h_get_32
129#endif
130#ifndef PUT_AOUTHDR_DATA_START
131#define PUT_AOUTHDR_DATA_START bfd_h_put_32
132#endif
133
134/* Some fields in the scnhdr are sometimes 64 bits. */
135#ifndef GET_SCNHDR_PADDR
136#define GET_SCNHDR_PADDR bfd_h_get_32
137#endif
138#ifndef PUT_SCNHDR_PADDR
139#define PUT_SCNHDR_PADDR bfd_h_put_32
140#endif
141#ifndef GET_SCNHDR_VADDR
142#define GET_SCNHDR_VADDR bfd_h_get_32
143#endif
144#ifndef PUT_SCNHDR_VADDR
145#define PUT_SCNHDR_VADDR bfd_h_put_32
146#endif
147#ifndef GET_SCNHDR_SIZE
148#define GET_SCNHDR_SIZE bfd_h_get_32
149#endif
150#ifndef PUT_SCNHDR_SIZE
151#define PUT_SCNHDR_SIZE bfd_h_put_32
152#endif
153#ifndef GET_SCNHDR_SCNPTR
154#define GET_SCNHDR_SCNPTR bfd_h_get_32
155#endif
156#ifndef PUT_SCNHDR_SCNPTR
157#define PUT_SCNHDR_SCNPTR bfd_h_put_32
158#endif
159#ifndef GET_SCNHDR_RELPTR
160#define GET_SCNHDR_RELPTR bfd_h_get_32
161#endif
162#ifndef PUT_SCNHDR_RELPTR
163#define PUT_SCNHDR_RELPTR bfd_h_put_32
164#endif
165#ifndef GET_SCNHDR_LNNOPTR
166#define GET_SCNHDR_LNNOPTR bfd_h_get_32
167#endif
168#ifndef PUT_SCNHDR_LNNOPTR
169#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
170#endif
171
7f2e6854
FF
172static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
173static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
174static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
175static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
176static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
177static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR));
178#ifndef NO_COFF_RELOCS
179static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
180static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
181#endif /* NO_COFF_RELOCS */
182#ifndef NO_COFF_SYMBOLS
183static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
184static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
185static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
186static unsigned int coff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
187#endif /* NO_COFF_SYMBOLS */
188#ifndef NO_COFF_LINENOS
189static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
190static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
191#endif /* NO_COFF_LINENOS */
192
fbb61b50
SC
193#ifndef NO_COFF_RELOCS
194
075caafd 195static void
3ea928f5
SC
196coff_swap_reloc_in (abfd, src, dst)
197 bfd *abfd;
198 PTR src;
199 PTR dst;
075caafd 200{
3ea928f5
SC
201 RELOC *reloc_src = (RELOC *) src;
202 struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
203
075caafd 204 reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
fbb61b50 205 reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
075caafd
ILT
206
207#ifdef RS6000COFF_C
208 reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
209 reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
210#else
211 reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
212#endif
213
214#ifdef SWAP_IN_RELOC_OFFSET
215 reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
216 (bfd_byte *) reloc_src->r_offset);
217#endif
218}
219
075caafd 220static unsigned int
3ea928f5
SC
221coff_swap_reloc_out (abfd, src, dst)
222 bfd *abfd;
223 PTR src;
224 PTR dst;
075caafd
ILT
225{
226 struct internal_reloc *reloc_src = (struct internal_reloc *)src;
227 struct external_reloc *reloc_dst = (struct external_reloc *)dst;
228 bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
229 bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
3ea928f5
SC
230
231#ifdef RS6000COFF_C
232 bfd_h_put_8 (abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type);
233 bfd_h_put_8 (abfd, reloc_src->r_size, (bfd_byte *) reloc_dst->r_size);
234#else
075caafd
ILT
235 bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
236 reloc_dst->r_type);
3ea928f5 237#endif
075caafd
ILT
238
239#ifdef SWAP_OUT_RELOC_OFFSET
240 SWAP_OUT_RELOC_OFFSET(abfd,
241 reloc_src->r_offset,
242 (bfd_byte *) reloc_dst->r_offset);
243#endif
244#ifdef SWAP_OUT_RELOC_EXTRA
245 SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
246#endif
247
7f2e6854 248 return RELSZ;
075caafd
ILT
249}
250
fbb61b50
SC
251#endif /* NO_COFF_RELOCS */
252
075caafd 253static void
3ea928f5
SC
254coff_swap_filehdr_in (abfd, src, dst)
255 bfd *abfd;
256 PTR src;
257 PTR dst;
075caafd
ILT
258{
259 FILHDR *filehdr_src = (FILHDR *) src;
260 struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
e8640d5e
ILT
261#ifdef COFF_ADJUST_FILEHDR_IN_PRE
262 COFF_ADJUST_FILEHDR_IN_PRE (abfd, src, dst);
263#endif
075caafd
ILT
264 filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
265 filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
266 filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
fbb61b50
SC
267 filehdr_dst->f_symptr =
268 GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr);
075caafd
ILT
269 filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
270 filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
271 filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
7f2e6854
FF
272/* start-sanitize-tic80 */
273#ifdef TIC80_TARGET_ID
274 filehdr_dst->f_target_id = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_target_id);
275#endif
276/* end-sanitize-tic80 */
e8640d5e
ILT
277
278#ifdef COFF_ADJUST_FILEHDR_IN_POST
279 COFF_ADJUST_FILEHDR_IN_POST (abfd, src, dst);
280#endif
075caafd
ILT
281}
282
283static unsigned int
3ea928f5
SC
284coff_swap_filehdr_out (abfd, in, out)
285 bfd *abfd;
286 PTR in;
287 PTR out;
075caafd
ILT
288{
289 struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
290 FILHDR *filehdr_out = (FILHDR *)out;
3ea928f5 291
e8640d5e
ILT
292#ifdef COFF_ADJUST_FILEHDR_OUT_PRE
293 COFF_ADJUST_FILEHDR_OUT_PRE (abfd, in, out);
294#endif
075caafd
ILT
295 bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
296 bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
297 bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
fbb61b50
SC
298 PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
299 (bfd_byte *) filehdr_out->f_symptr);
075caafd
ILT
300 bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
301 bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
302 bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
7f2e6854
FF
303/* start-sanitize-tic80 */
304#ifdef TIC80_TARGET_ID
305 bfd_h_put_16(abfd, filehdr_in->f_target_id, (bfd_byte *) filehdr_out->f_target_id);
306#endif
307/* end-sanitize-tic80 */
3ea928f5 308
e8640d5e
ILT
309#ifdef COFF_ADJUST_FILEHDR_OUT_POST
310 COFF_ADJUST_FILEHDR_OUT_POST (abfd, in, out);
311#endif
7f2e6854 312 return FILHSZ;
075caafd
ILT
313}
314
315
316#ifndef NO_COFF_SYMBOLS
317
318static void
3ea928f5
SC
319coff_swap_sym_in (abfd, ext1, in1)
320 bfd *abfd;
321 PTR ext1;
322 PTR in1;
075caafd
ILT
323{
324 SYMENT *ext = (SYMENT *)ext1;
325 struct internal_syment *in = (struct internal_syment *)in1;
326
327 if( ext->e.e_name[0] == 0) {
328 in->_n._n_n._n_zeroes = 0;
329 in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
330 }
331 else {
332#if SYMNMLEN != E_SYMNMLEN
333 -> Error, we need to cope with truncating or extending SYMNMLEN!;
334#else
335 memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
336#endif
337 }
3ea928f5 338 in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
075caafd
ILT
339 in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
340 if (sizeof(ext->e_type) == 2){
341 in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
342 }
343 else {
344 in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
345 }
346 in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
347 in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
348}
349
350static unsigned int
3ea928f5
SC
351coff_swap_sym_out (abfd, inp, extp)
352 bfd *abfd;
353 PTR inp;
354 PTR extp;
075caafd
ILT
355{
356 struct internal_syment *in = (struct internal_syment *)inp;
357 SYMENT *ext =(SYMENT *)extp;
358 if(in->_n._n_name[0] == 0) {
359 bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
360 bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
361 }
362 else {
363#if SYMNMLEN != E_SYMNMLEN
364 -> Error, we need to cope with truncating or extending SYMNMLEN!;
365#else
366 memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
367#endif
368 }
369 bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
370 bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
371 if (sizeof(ext->e_type) == 2)
372 {
373 bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
374 }
375 else
376 {
377 bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
378 }
379 bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
380 bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
7f2e6854 381 return SYMESZ;
075caafd
ILT
382}
383
384static void
3ea928f5
SC
385coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
386 bfd *abfd;
387 PTR ext1;
388 int type;
389 int class;
390 int indx;
391 int numaux;
392 PTR in1;
075caafd
ILT
393{
394 AUXENT *ext = (AUXENT *)ext1;
395 union internal_auxent *in = (union internal_auxent *)in1;
396
e8640d5e
ILT
397#ifdef COFF_ADJUST_AUX_IN_PRE
398 COFF_ADJUST_AUX_IN_PRE (abfd, ext1, type, class, indx, numaux, in1);
399#endif
075caafd
ILT
400 switch (class) {
401 case C_FILE:
402 if (ext->x_file.x_fname[0] == 0) {
403 in->x_file.x_n.x_zeroes = 0;
404 in->x_file.x_n.x_offset =
405 bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
406 } else {
407#if FILNMLEN != E_FILNMLEN
408 -> Error, we need to cope with truncating or extending FILNMLEN!;
409#else
410 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
411#endif
412 }
e8640d5e 413 goto end;
075caafd
ILT
414
415 /* RS/6000 "csect" auxents */
416#ifdef RS6000COFF_C
417 case C_EXT:
418 case C_HIDEXT:
330595d0
ILT
419 if (indx + 1 == numaux)
420 {
3ea928f5 421 in->x_csect.x_scnlen.l = bfd_h_get_32 (abfd, ext->x_csect.x_scnlen);
330595d0
ILT
422 in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
423 ext->x_csect.x_parmhash);
424 in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
425 /* We don't have to hack bitfields in x_smtyp because it's
426 defined by shifts-and-ands, which are equivalent on all
427 byte orders. */
428 in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp);
429 in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas);
430 in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab);
431 in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab);
e8640d5e 432 goto end;
330595d0 433 }
075caafd
ILT
434 break;
435#endif
436
437 case C_STAT:
438#ifdef C_LEAFSTAT
439 case C_LEAFSTAT:
440#endif
441 case C_HIDDEN:
442 if (type == T_NULL) {
443 in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
444 in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
445 in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
8230f31c
ILT
446
447 /* PE defines some extra fields; we zero them out for
448 safety. */
449 in->x_scn.x_checksum = 0;
450 in->x_scn.x_associated = 0;
451 in->x_scn.x_comdat = 0;
452
e8640d5e 453 goto end;
075caafd 454 }
330595d0
ILT
455 break;
456 }
457
458 in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
075caafd 459#ifndef NO_TVNDX
330595d0 460 in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
075caafd
ILT
461#endif
462
7f2e6854 463 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
3ea928f5
SC
464 {
465 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
466 in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
467 }
468 else
469 {
075caafd 470#if DIMNUM != E_DIMNUM
3ea928f5
SC
471 #error we need to cope with truncating or extending DIMNUM
472#endif
473 in->x_sym.x_fcnary.x_ary.x_dimen[0] =
474 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
475 in->x_sym.x_fcnary.x_ary.x_dimen[1] =
476 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
477 in->x_sym.x_fcnary.x_ary.x_dimen[2] =
478 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
479 in->x_sym.x_fcnary.x_ary.x_dimen[3] =
480 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
481 }
075caafd 482
330595d0
ILT
483 if (ISFCN(type)) {
484 in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
485 }
486 else {
487 in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
488 in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
489 }
e8640d5e
ILT
490
491end:
492#ifdef COFF_ADJUST_AUX_IN_POST
493 COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1);
494#endif
075caafd
ILT
495}
496
497static unsigned int
3ea928f5
SC
498coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
499 bfd *abfd;
500 PTR inp;
501 int type;
502 int class;
503 int indx;
504 int numaux;
505 PTR extp;
075caafd
ILT
506{
507 union internal_auxent *in = (union internal_auxent *)inp;
508 AUXENT *ext = (AUXENT *)extp;
509
e8640d5e
ILT
510#ifdef COFF_ADJUST_AUX_OUT_PRE
511 COFF_ADJUST_AUX_OUT_PRE (abfd, inp, type, class, indx, numaux, extp);
512#endif
075caafd
ILT
513 memset((PTR)ext, 0, AUXESZ);
514 switch (class) {
515 case C_FILE:
516 if (in->x_file.x_fname[0] == 0) {
517 PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
518 PUTWORD(abfd,
519 in->x_file.x_n.x_offset,
520 (bfd_byte *) ext->x_file.x_n.x_offset);
521 }
522 else {
523#if FILNMLEN != E_FILNMLEN
524 -> Error, we need to cope with truncating or extending FILNMLEN!;
525#else
526 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
527#endif
528 }
e8640d5e 529 goto end;
075caafd
ILT
530
531#ifdef RS6000COFF_C
532 /* RS/6000 "csect" auxents */
533 case C_EXT:
534 case C_HIDEXT:
330595d0
ILT
535 if (indx + 1 == numaux)
536 {
3ea928f5 537 PUTWORD (abfd, in->x_csect.x_scnlen.l, ext->x_csect.x_scnlen);
330595d0
ILT
538 PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
539 PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
540 /* We don't have to hack bitfields in x_smtyp because it's
541 defined by shifts-and-ands, which are equivalent on all
542 byte orders. */
543 PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
544 PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
545 PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
546 PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
e8640d5e 547 goto end;
330595d0 548 }
075caafd
ILT
549 break;
550#endif
551
552 case C_STAT:
553#ifdef C_LEAFSTAT
554 case C_LEAFSTAT:
555#endif
556 case C_HIDDEN:
557 if (type == T_NULL) {
558 PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
559 PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
560 PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
e8640d5e 561 goto end;
075caafd 562 }
330595d0
ILT
563 break;
564 }
565
566 PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
075caafd 567#ifndef NO_TVNDX
330595d0 568 bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
075caafd
ILT
569#endif
570
7f2e6854 571 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
3ea928f5
SC
572 {
573 PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
574 PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
575 }
576 else
577 {
075caafd 578#if DIMNUM != E_DIMNUM
3ea928f5
SC
579 #error we need to cope with truncating or extending DIMNUM
580#endif
581 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
582 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
583 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
584 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
585 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
586 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
587 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
588 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
075caafd 589 }
3ea928f5
SC
590
591 if (ISFCN (type))
592 PUTWORD (abfd, in->x_sym.x_misc.x_fsize,
593 (bfd_byte *) ext->x_sym.x_misc.x_fsize);
594 else
595 {
596 PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
597 PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
598 }
599
e8640d5e
ILT
600end:
601#ifdef COFF_ADJUST_AUX_OUT_POST
602 COFF_ADJUST_AUX_OUT_POST (abfd, inp, type, class, indx, numaux, extp);
603#endif
7f2e6854 604 return AUXESZ;
075caafd
ILT
605}
606
607#endif /* NO_COFF_SYMBOLS */
608
609#ifndef NO_COFF_LINENOS
610
611static void
3ea928f5
SC
612coff_swap_lineno_in (abfd, ext1, in1)
613 bfd *abfd;
614 PTR ext1;
615 PTR in1;
075caafd
ILT
616{
617 LINENO *ext = (LINENO *)ext1;
618 struct internal_lineno *in = (struct internal_lineno *)in1;
619
620 in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
621 in->l_lnno = GET_LINENO_LNNO(abfd, ext);
622}
623
624static unsigned int
3ea928f5
SC
625coff_swap_lineno_out (abfd, inp, outp)
626 bfd *abfd;
627 PTR inp;
628 PTR outp;
075caafd
ILT
629{
630 struct internal_lineno *in = (struct internal_lineno *)inp;
631 struct external_lineno *ext = (struct external_lineno *)outp;
632 PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
633 ext->l_addr.l_symndx);
634
635 PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
7f2e6854 636 return LINESZ;
075caafd
ILT
637}
638
639#endif /* NO_COFF_LINENOS */
640
075caafd 641static void
3ea928f5
SC
642coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
643 bfd *abfd;
644 PTR aouthdr_ext1;
645 PTR aouthdr_int1;
075caafd
ILT
646{
647 AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
648 struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
649
650 aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
651 aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
fbb61b50
SC
652 aouthdr_int->tsize =
653 GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
654 aouthdr_int->dsize =
655 GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
656 aouthdr_int->bsize =
657 GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
658 aouthdr_int->entry =
659 GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
660 aouthdr_int->text_start =
661 GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
662 aouthdr_int->data_start =
663 GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
664
075caafd
ILT
665#ifdef I960
666 aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
667#endif
668
330595d0
ILT
669#ifdef APOLLO_M68
670 bfd_h_put_32(abfd, aouthdr_int->o_inlib, (bfd_byte *) aouthdr_ext->o_inlib);
671 bfd_h_put_32(abfd, aouthdr_int->o_sri, (bfd_byte *) aouthdr_ext->o_sri);
672 bfd_h_put_32(abfd, aouthdr_int->vid[0], (bfd_byte *) aouthdr_ext->vid);
673 bfd_h_put_32(abfd, aouthdr_int->vid[1], (bfd_byte *) aouthdr_ext->vid + 4);
674#endif
675
676
075caafd
ILT
677#ifdef RS6000COFF_C
678 aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
679 aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
680 aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
681 aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
682 aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
683 aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
684 aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
685 aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
686 aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
687 aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
919cf4b5 688 aouthdr_int->o_cputype = bfd_h_get_16(abfd, aouthdr_ext->o_cputype);
075caafd 689 aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
5f710a3a 690 aouthdr_int->o_maxdata = bfd_h_get_32(abfd, aouthdr_ext->o_maxdata);
075caafd 691#endif
fbb61b50
SC
692
693#ifdef MIPSECOFF
694 aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
695 aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
696 aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
697 aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
698 aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
699 aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
700 aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
701#endif
702
703#ifdef ALPHAECOFF
704 aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start);
705 aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value);
706 aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
707 aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask);
708#endif
075caafd
ILT
709}
710
711static unsigned int
3ea928f5
SC
712coff_swap_aouthdr_out (abfd, in, out)
713 bfd *abfd;
714 PTR in;
715 PTR out;
075caafd
ILT
716{
717 struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
718 AOUTHDR *aouthdr_out = (AOUTHDR *)out;
fbb61b50 719
075caafd
ILT
720 bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
721 bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
fbb61b50
SC
722 PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
723 PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
724 PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
725 PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
726 PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
727 (bfd_byte *) aouthdr_out->text_start);
728 PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
729 (bfd_byte *) aouthdr_out->data_start);
3ea928f5 730
075caafd
ILT
731#ifdef I960
732 bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
733#endif
fbb61b50 734
5f710a3a
ILT
735#ifdef RS6000COFF_C
736 bfd_h_put_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
737 bfd_h_put_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
738 bfd_h_put_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
739 bfd_h_put_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
740 bfd_h_put_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
741 bfd_h_put_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
742 bfd_h_put_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
743 bfd_h_put_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
744 bfd_h_put_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
745 bfd_h_put_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
919cf4b5 746 bfd_h_put_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
5f710a3a
ILT
747 bfd_h_put_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
748 bfd_h_put_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
5f710a3a
ILT
749 memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
750#endif
751
fbb61b50
SC
752#ifdef MIPSECOFF
753 bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
754 bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
755 bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
756 bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
757 bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
758 bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
759 bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
760#endif
761
762#ifdef ALPHAECOFF
330595d0
ILT
763 /* FIXME: What does bldrev mean? */
764 bfd_h_put_16(abfd, (bfd_vma) 2, (bfd_byte *) aouthdr_out->bldrev);
765 bfd_h_put_16(abfd, (bfd_vma) 0, (bfd_byte *) aouthdr_out->padding);
fbb61b50
SC
766 bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
767 bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
768 bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
769 bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask);
770#endif
771
7f2e6854 772 return AOUTSZ;
075caafd
ILT
773}
774
775static void
3ea928f5
SC
776coff_swap_scnhdr_in (abfd, ext, in)
777 bfd *abfd;
778 PTR ext;
779 PTR in;
075caafd
ILT
780{
781 SCNHDR *scnhdr_ext = (SCNHDR *) ext;
782 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
075caafd 783
e8640d5e
ILT
784#ifdef COFF_ADJUST_SCNHDR_IN_PRE
785 COFF_ADJUST_SCNHDR_IN_PRE (abfd, ext, in);
786#endif
fbb61b50
SC
787 memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
788 scnhdr_int->s_vaddr =
789 GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
790 scnhdr_int->s_paddr =
791 GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
792 scnhdr_int->s_size =
793 GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
794
795 scnhdr_int->s_scnptr =
796 GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
797 scnhdr_int->s_relptr =
798 GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
799 scnhdr_int->s_lnnoptr =
800 GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
075caafd
ILT
801 scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
802#if defined(M88)
803 scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
804 scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
805#else
806 scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
807 scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
808#endif
809#ifdef I960
810 scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
811#endif
e8640d5e
ILT
812#ifdef COFF_ADJUST_SCNHDR_IN_POST
813 COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
814#endif
075caafd
ILT
815}
816
817static unsigned int
3ea928f5
SC
818coff_swap_scnhdr_out (abfd, in, out)
819 bfd *abfd;
820 PTR in;
821 PTR out;
075caafd
ILT
822{
823 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
824 SCNHDR *scnhdr_ext = (SCNHDR *)out;
7f2e6854 825 unsigned int ret = SCNHSZ;
fbb61b50 826
e8640d5e
ILT
827#ifdef COFF_ADJUST_SCNHDR_OUT_PRE
828 COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out);
829#endif
075caafd 830 memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
3ea928f5 831
3ea928f5
SC
832 PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr,
833 (bfd_byte *) scnhdr_ext->s_vaddr);
330595d0 834
330595d0 835
3ea928f5 836 PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr,
330595d0 837 (bfd_byte *) scnhdr_ext->s_paddr);
3ea928f5 838 PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size,
330595d0 839 (bfd_byte *) scnhdr_ext->s_size);
5f710a3a 840
330595d0
ILT
841 PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
842 (bfd_byte *) scnhdr_ext->s_scnptr);
843 PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
844 (bfd_byte *) scnhdr_ext->s_relptr);
845 PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
846 (bfd_byte *) scnhdr_ext->s_lnnoptr);
847 PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags);
848#if defined(M88)
849 PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
850 PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
851#else
3ea928f5
SC
852 if (scnhdr_int->s_nlnno <= 0xffff)
853 PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
854 else
855 {
919cf4b5
ILT
856 char buf[sizeof (scnhdr_int->s_name) + 1];
857
858 memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
859 buf[sizeof (scnhdr_int->s_name)] = '\0';
7f2e6854
FF
860 (*_bfd_error_handler)
861 ("%s: warning: %s: line number overflow: 0x%lx > 0xffff",
862 bfd_get_filename (abfd),
863 buf, scnhdr_int->s_nlnno);
3ea928f5 864 PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
3ea928f5
SC
865 }
866 if (scnhdr_int->s_nreloc <= 0xffff)
867 PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
868 else
869 {
919cf4b5
ILT
870 char buf[sizeof (scnhdr_int->s_name) + 1];
871
872 memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
873 buf[sizeof (scnhdr_int->s_name)] = '\0';
874 (*_bfd_error_handler) ("%s: %s: reloc overflow: 0x%lx > 0xffff",
3ea928f5 875 bfd_get_filename (abfd),
919cf4b5 876 buf, scnhdr_int->s_nreloc);
3ea928f5
SC
877 bfd_set_error (bfd_error_file_truncated);
878 PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
879 ret = 0;
880 }
330595d0
ILT
881#endif
882
883#if defined(I960)
884 PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
e8640d5e
ILT
885#endif
886#ifdef COFF_ADJUST_SCNHDR_OUT_POST
887 COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
330595d0 888#endif
3ea928f5 889 return ret;
330595d0 890}
This page took 0.278252 seconds and 4 git commands to generate.