OSDN Git Service

* ecoff.c (_bfd_ecoff_write_armap): give the symtab element a
[pf3gnuchains/pf3gnuchains3x.git] / bfd / coffswap.h
1 /* Generic COFF swapping routines, for BFD.
2    Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 #ifndef IMAGE_BASE
30 #define IMAGE_BASE 0
31 #endif
32
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
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 #ifndef GET_SCNHDR_NRELOC
172 #define GET_SCNHDR_NRELOC bfd_h_get_16
173 #endif
174 #ifndef PUT_SCNHDR_NRELOC
175 #define PUT_SCNHDR_NRELOC bfd_h_put_16
176 #endif
177 #ifndef GET_SCNHDR_NLNNO
178 #define GET_SCNHDR_NLNNO bfd_h_get_16
179 #endif
180 #ifndef PUT_SCNHDR_NLNNO
181 #define PUT_SCNHDR_NLNNO bfd_h_put_16
182 #endif
183 #ifndef GET_SCNHDR_FLAGS
184 #define GET_SCNHDR_FLAGS bfd_h_get_32
185 #endif
186 #ifndef PUT_SCNHDR_FLAGS
187 #define PUT_SCNHDR_FLAGS bfd_h_put_32
188 #endif
189
190
191 static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
192 static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
193 static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
194 static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
195 static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
196 static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR));
197 #ifndef NO_COFF_RELOCS
198 static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
199 static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
200 #endif /* NO_COFF_RELOCS */
201 #ifndef NO_COFF_SYMBOLS
202 static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
203 static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
204 static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
205 static unsigned int coff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
206 #endif /* NO_COFF_SYMBOLS */
207 #ifndef NO_COFF_LINENOS
208 static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
209 static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
210 #endif /* NO_COFF_LINENOS */
211
212 #ifndef NO_COFF_RELOCS
213
214 static void
215 coff_swap_reloc_in (abfd, src, dst)
216      bfd *abfd;
217      PTR src;
218      PTR dst;
219 {
220   RELOC *reloc_src = (RELOC *) src;
221   struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
222
223   reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
224   reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
225
226 #ifdef RS6000COFF_C
227   reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
228   reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
229 #else
230   reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
231 #endif
232
233 #ifdef SWAP_IN_RELOC_OFFSET
234   reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
235                                              (bfd_byte *) reloc_src->r_offset);
236 #endif
237 }
238
239 static unsigned int
240 coff_swap_reloc_out (abfd, src, dst)
241      bfd       *abfd;
242      PTR        src;
243      PTR        dst;
244 {
245   struct internal_reloc *reloc_src = (struct internal_reloc *)src;
246   struct external_reloc *reloc_dst = (struct external_reloc *)dst;
247   bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
248   bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
249
250 #ifdef RS6000COFF_C
251   bfd_h_put_8 (abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type);
252   bfd_h_put_8 (abfd, reloc_src->r_size, (bfd_byte *) reloc_dst->r_size);
253 #else
254   bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
255                reloc_dst->r_type);
256 #endif
257
258 #ifdef SWAP_OUT_RELOC_OFFSET
259   SWAP_OUT_RELOC_OFFSET(abfd,
260                         reloc_src->r_offset,
261                         (bfd_byte *) reloc_dst->r_offset);
262 #endif
263 #ifdef SWAP_OUT_RELOC_EXTRA
264   SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
265 #endif
266
267   return RELSZ;
268 }
269
270 #endif /* NO_COFF_RELOCS */
271
272 static void
273 coff_swap_filehdr_in (abfd, src, dst)
274      bfd            *abfd;
275      PTR             src;
276      PTR             dst;
277 {
278   FILHDR *filehdr_src = (FILHDR *) src;
279   struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
280 #ifdef COFF_ADJUST_FILEHDR_IN_PRE
281   COFF_ADJUST_FILEHDR_IN_PRE (abfd, src, dst);
282 #endif
283   filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
284   filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
285   filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
286   filehdr_dst->f_symptr =
287     GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr);
288   filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
289   filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
290   filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
291 #ifdef TIC80_TARGET_ID
292   filehdr_dst->f_target_id = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_target_id);
293 #endif
294
295 #ifdef COFF_ADJUST_FILEHDR_IN_POST
296   COFF_ADJUST_FILEHDR_IN_POST (abfd, src, dst);
297 #endif
298 }
299
300 static  unsigned int
301 coff_swap_filehdr_out (abfd, in, out)
302      bfd       *abfd;
303      PTR        in;
304      PTR        out;
305 {
306   struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
307   FILHDR *filehdr_out = (FILHDR *)out;
308
309 #ifdef COFF_ADJUST_FILEHDR_OUT_PRE
310   COFF_ADJUST_FILEHDR_OUT_PRE (abfd, in, out);
311 #endif
312   bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
313   bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
314   bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
315   PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
316                       (bfd_byte *) filehdr_out->f_symptr);
317   bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
318   bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
319   bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
320 #ifdef TIC80_TARGET_ID
321   bfd_h_put_16(abfd, filehdr_in->f_target_id, (bfd_byte *) filehdr_out->f_target_id);
322 #endif
323
324 #ifdef COFF_ADJUST_FILEHDR_OUT_POST
325   COFF_ADJUST_FILEHDR_OUT_POST (abfd, in, out);
326 #endif
327   return FILHSZ;
328 }
329
330
331 #ifndef NO_COFF_SYMBOLS
332
333 static void
334 coff_swap_sym_in (abfd, ext1, in1)
335      bfd            *abfd;
336      PTR ext1;
337      PTR in1;
338 {
339   SYMENT *ext = (SYMENT *)ext1;
340   struct internal_syment      *in = (struct internal_syment *)in1;
341
342   if( ext->e.e_name[0] == 0) {
343     in->_n._n_n._n_zeroes = 0;
344     in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
345   }
346   else {
347 #if SYMNMLEN != E_SYMNMLEN
348    -> Error, we need to cope with truncating or extending SYMNMLEN!;
349 #else
350     memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
351 #endif
352   }
353   in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value); 
354   in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
355   if (sizeof(ext->e_type) == 2){
356     in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
357   }
358   else {
359     in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
360   }
361   in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
362   in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
363 }
364
365 static unsigned int
366 coff_swap_sym_out (abfd, inp, extp)
367      bfd       *abfd;
368      PTR        inp;
369      PTR        extp;
370 {
371   struct internal_syment *in = (struct internal_syment *)inp;
372   SYMENT *ext =(SYMENT *)extp;
373   if(in->_n._n_name[0] == 0) {
374     bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
375     bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *)  ext->e.e.e_offset);
376   }
377   else {
378 #if SYMNMLEN != E_SYMNMLEN
379     -> Error, we need to cope with truncating or extending SYMNMLEN!;
380 #else
381     memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
382 #endif
383   }
384   bfd_h_put_32(abfd,  in->n_value , (bfd_byte *) ext->e_value);
385   bfd_h_put_16(abfd,  in->n_scnum , (bfd_byte *) ext->e_scnum);
386   if (sizeof(ext->e_type) == 2)
387       {
388         bfd_h_put_16(abfd,  in->n_type , (bfd_byte *) ext->e_type);
389       }
390   else
391       {
392         bfd_h_put_32(abfd,  in->n_type , (bfd_byte *) ext->e_type);
393       }
394   bfd_h_put_8(abfd,  in->n_sclass , ext->e_sclass);
395   bfd_h_put_8(abfd,  in->n_numaux , ext->e_numaux);
396   return SYMESZ;
397 }
398
399 static void
400 coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
401      bfd            *abfd;
402      PTR              ext1;
403      int             type;
404      int             class;
405      int              indx;
406      int              numaux;
407      PTR              in1;
408 {
409   AUXENT    *ext = (AUXENT *)ext1;
410   union internal_auxent *in = (union internal_auxent *)in1;
411
412 #ifdef COFF_ADJUST_AUX_IN_PRE
413   COFF_ADJUST_AUX_IN_PRE (abfd, ext1, type, class, indx, numaux, in1);
414 #endif
415   switch (class) {
416     case C_FILE:
417       if (ext->x_file.x_fname[0] == 0) {
418           in->x_file.x_n.x_zeroes = 0;
419           in->x_file.x_n.x_offset = 
420            bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
421         } else {
422 #if FILNMLEN != E_FILNMLEN
423             -> Error, we need to cope with truncating or extending FILNMLEN!;
424 #else
425             if (numaux > 1)
426               {
427                 if (indx == 0)
428                   memcpy (in->x_file.x_fname, ext->x_file.x_fname,
429                           numaux * sizeof (AUXENT));
430               }
431             else
432               {
433                 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
434               }
435 #endif
436           }
437       goto end;
438
439       /* RS/6000 "csect" auxents */
440 #ifdef RS6000COFF_C
441     case C_EXT:
442     case C_HIDEXT:
443       if (indx + 1 == numaux)
444         {
445           in->x_csect.x_scnlen.l = bfd_h_get_32 (abfd, ext->x_csect.x_scnlen);
446           in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
447                                                  ext->x_csect.x_parmhash);
448           in->x_csect.x_snhash   = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
449           /* We don't have to hack bitfields in x_smtyp because it's
450              defined by shifts-and-ands, which are equivalent on all
451              byte orders.  */
452           in->x_csect.x_smtyp    = bfd_h_get_8  (abfd, ext->x_csect.x_smtyp);
453           in->x_csect.x_smclas   = bfd_h_get_8  (abfd, ext->x_csect.x_smclas);
454           in->x_csect.x_stab     = bfd_h_get_32 (abfd, ext->x_csect.x_stab);
455           in->x_csect.x_snstab   = bfd_h_get_16 (abfd, ext->x_csect.x_snstab);
456           goto end;
457         }
458       break;
459 #endif
460
461     case C_STAT:
462 #ifdef C_LEAFSTAT
463     case C_LEAFSTAT:
464 #endif
465     case C_HIDDEN:
466       if (type == T_NULL) {
467           in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
468           in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
469           in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
470
471           /* PE defines some extra fields; we zero them out for
472              safety.  */
473           in->x_scn.x_checksum = 0;
474           in->x_scn.x_associated = 0;
475           in->x_scn.x_comdat = 0;
476
477           goto end;
478         }
479       break;
480     }
481
482   in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
483 #ifndef NO_TVNDX
484   in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
485 #endif
486
487   if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
488     {
489       in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
490       in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
491     }
492   else
493     {
494 #if DIMNUM != E_DIMNUM
495  #error we need to cope with truncating or extending DIMNUM
496 #endif
497       in->x_sym.x_fcnary.x_ary.x_dimen[0] =
498         bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
499       in->x_sym.x_fcnary.x_ary.x_dimen[1] =
500         bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
501       in->x_sym.x_fcnary.x_ary.x_dimen[2] =
502         bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
503       in->x_sym.x_fcnary.x_ary.x_dimen[3] =
504         bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
505     }
506
507   if (ISFCN(type)) {
508     in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
509   }
510   else {
511     in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
512     in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
513   }
514
515 end: ;
516   /* the semicolon is because MSVC doesn't like labels at
517      end of block. */
518
519 #ifdef COFF_ADJUST_AUX_IN_POST
520   COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1);
521 #endif
522 }
523
524 static unsigned int
525 coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
526      bfd   *abfd;
527      PTR        inp;
528      int   type;
529      int   class;
530      int   indx;
531      int   numaux;
532      PTR        extp;
533 {
534   union internal_auxent *in = (union internal_auxent *)inp;
535   AUXENT *ext = (AUXENT *)extp;
536
537 #ifdef COFF_ADJUST_AUX_OUT_PRE
538   COFF_ADJUST_AUX_OUT_PRE (abfd, inp, type, class, indx, numaux, extp);
539 #endif
540   memset((PTR)ext, 0, AUXESZ);
541   switch (class) {
542   case C_FILE:
543     if (in->x_file.x_fname[0] == 0) {
544       PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
545       PUTWORD(abfd,
546               in->x_file.x_n.x_offset,
547               (bfd_byte *) ext->x_file.x_n.x_offset);
548     }
549     else {
550 #if FILNMLEN != E_FILNMLEN
551       -> Error, we need to cope with truncating or extending FILNMLEN!;
552 #else
553       memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
554 #endif
555     }
556     goto end;
557
558 #ifdef RS6000COFF_C
559   /* RS/6000 "csect" auxents */
560   case C_EXT:
561   case C_HIDEXT:
562     if (indx + 1 == numaux)
563       {
564         PUTWORD (abfd, in->x_csect.x_scnlen.l,  ext->x_csect.x_scnlen);
565         PUTWORD (abfd, in->x_csect.x_parmhash,  ext->x_csect.x_parmhash);
566         PUTHALF (abfd, in->x_csect.x_snhash,    ext->x_csect.x_snhash);
567         /* We don't have to hack bitfields in x_smtyp because it's
568            defined by shifts-and-ands, which are equivalent on all
569            byte orders.  */
570         PUTBYTE (abfd, in->x_csect.x_smtyp,     ext->x_csect.x_smtyp);
571         PUTBYTE (abfd, in->x_csect.x_smclas,    ext->x_csect.x_smclas);
572         PUTWORD (abfd, in->x_csect.x_stab,      ext->x_csect.x_stab);
573         PUTHALF (abfd, in->x_csect.x_snstab,    ext->x_csect.x_snstab);
574         goto end;
575       }
576     break;
577 #endif
578
579   case C_STAT:
580 #ifdef C_LEAFSTAT
581   case C_LEAFSTAT:
582 #endif
583   case C_HIDDEN:
584     if (type == T_NULL) {
585       PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
586       PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
587       PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
588       goto end;
589     }
590     break;
591   }
592
593   PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
594 #ifndef NO_TVNDX
595   bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
596 #endif
597
598   if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
599     {
600       PUT_FCN_LNNOPTR(abfd,  in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
601       PUT_FCN_ENDNDX(abfd,  in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
602     }
603   else
604     {
605 #if DIMNUM != E_DIMNUM
606  #error we need to cope with truncating or extending DIMNUM
607 #endif
608       bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
609                     (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
610       bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
611                     (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
612       bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
613                     (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
614       bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
615                     (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
616     }
617
618   if (ISFCN (type))
619     PUTWORD (abfd, in->x_sym.x_misc.x_fsize,
620              (bfd_byte *)  ext->x_sym.x_misc.x_fsize);
621   else
622     {
623       PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
624       PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
625     }
626
627 end:
628 #ifdef COFF_ADJUST_AUX_OUT_POST
629   COFF_ADJUST_AUX_OUT_POST (abfd, inp, type, class, indx, numaux, extp);
630 #endif
631   return AUXESZ;
632 }
633
634 #endif /* NO_COFF_SYMBOLS */
635
636 #ifndef NO_COFF_LINENOS
637
638 static void
639 coff_swap_lineno_in (abfd, ext1, in1)
640      bfd            *abfd;
641      PTR ext1;
642      PTR in1;
643 {
644   LINENO *ext = (LINENO *)ext1;
645   struct internal_lineno      *in = (struct internal_lineno *)in1;
646
647   in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
648   in->l_lnno = GET_LINENO_LNNO(abfd, ext);
649 }
650
651 static unsigned int
652 coff_swap_lineno_out (abfd, inp, outp)
653      bfd       *abfd;
654      PTR        inp;
655      PTR        outp;
656 {
657   struct internal_lineno *in = (struct internal_lineno *)inp;
658   struct external_lineno *ext = (struct external_lineno *)outp;
659   PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
660           ext->l_addr.l_symndx);
661
662   PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
663   return LINESZ;
664 }
665
666 #endif /* NO_COFF_LINENOS */
667
668 static void
669 coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
670      bfd            *abfd;
671      PTR aouthdr_ext1;
672      PTR aouthdr_int1;
673 {
674   AOUTHDR        *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
675   struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
676
677   aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
678   aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
679   aouthdr_int->tsize =
680     GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
681   aouthdr_int->dsize =
682     GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
683   aouthdr_int->bsize =
684     GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
685   aouthdr_int->entry =
686     GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
687   aouthdr_int->text_start =
688     GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
689   aouthdr_int->data_start =
690     GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
691
692 #ifdef I960
693   aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
694 #endif
695
696 #ifdef APOLLO_M68
697   bfd_h_put_32(abfd, aouthdr_int->o_inlib, (bfd_byte *) aouthdr_ext->o_inlib);
698   bfd_h_put_32(abfd, aouthdr_int->o_sri, (bfd_byte *) aouthdr_ext->o_sri);
699   bfd_h_put_32(abfd, aouthdr_int->vid[0], (bfd_byte *) aouthdr_ext->vid);
700   bfd_h_put_32(abfd, aouthdr_int->vid[1], (bfd_byte *) aouthdr_ext->vid + 4);
701 #endif
702
703
704 #ifdef RS6000COFF_C
705   aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
706   aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
707   aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
708   aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
709   aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
710   aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
711   aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
712   aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
713   aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
714   aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
715   aouthdr_int->o_cputype = bfd_h_get_16(abfd, aouthdr_ext->o_cputype);
716   aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
717   aouthdr_int->o_maxdata = bfd_h_get_32(abfd, aouthdr_ext->o_maxdata);
718 #endif
719
720 #ifdef MIPSECOFF
721   aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
722   aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
723   aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
724   aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
725   aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
726   aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
727   aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
728 #endif
729
730 #ifdef ALPHAECOFF
731   aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start);
732   aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value);
733   aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
734   aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask);
735 #endif
736 }
737
738 static unsigned int
739 coff_swap_aouthdr_out (abfd, in, out)
740      bfd       *abfd;
741      PTR        in;
742      PTR        out;
743 {
744   struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
745   AOUTHDR *aouthdr_out = (AOUTHDR *)out;
746
747   bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
748   bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
749   PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
750   PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
751   PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
752   PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
753   PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
754                           (bfd_byte *) aouthdr_out->text_start);
755   PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
756                           (bfd_byte *) aouthdr_out->data_start);
757
758 #ifdef I960
759   bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
760 #endif
761
762 #ifdef RS6000COFF_C
763   bfd_h_put_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
764   bfd_h_put_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
765   bfd_h_put_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
766   bfd_h_put_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
767   bfd_h_put_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
768   bfd_h_put_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
769   bfd_h_put_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
770   bfd_h_put_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
771   bfd_h_put_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
772   bfd_h_put_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
773   bfd_h_put_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
774   bfd_h_put_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
775   bfd_h_put_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
776   memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
777 #endif
778
779 #ifdef MIPSECOFF
780   bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
781   bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
782   bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
783   bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
784   bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
785   bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
786   bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
787 #endif
788
789 #ifdef ALPHAECOFF
790   /* FIXME: What does bldrev mean?  */
791   bfd_h_put_16(abfd, (bfd_vma) 2, (bfd_byte *) aouthdr_out->bldrev);
792   bfd_h_put_16(abfd, (bfd_vma) 0, (bfd_byte *) aouthdr_out->padding);
793   bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
794   bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
795   bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
796   bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask);
797 #endif
798
799   return AOUTSZ;
800 }
801
802 static void
803 coff_swap_scnhdr_in (abfd, ext, in)
804      bfd            *abfd;
805      PTR             ext;
806      PTR             in;
807 {
808   SCNHDR *scnhdr_ext = (SCNHDR *) ext;
809   struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
810
811 #ifdef COFF_ADJUST_SCNHDR_IN_PRE
812   COFF_ADJUST_SCNHDR_IN_PRE (abfd, ext, in);
813 #endif
814   memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
815   scnhdr_int->s_vaddr =
816     GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
817   scnhdr_int->s_paddr =
818     GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
819   scnhdr_int->s_size =
820     GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
821
822   scnhdr_int->s_scnptr =
823     GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
824   scnhdr_int->s_relptr =
825     GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
826   scnhdr_int->s_lnnoptr =
827     GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
828   scnhdr_int->s_flags =
829     GET_SCNHDR_FLAGS (abfd, (bfd_byte *) scnhdr_ext->s_flags);
830   scnhdr_int->s_nreloc =
831     GET_SCNHDR_NRELOC (abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
832   scnhdr_int->s_nlnno =
833     GET_SCNHDR_NLNNO (abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
834 #ifdef I960
835   scnhdr_int->s_align =
836     GET_SCNHDR_ALIGN (abfd, (bfd_byte *) scnhdr_ext->s_align);
837 #endif
838 #ifdef COFF_ADJUST_SCNHDR_IN_POST
839   COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
840 #endif
841 }
842
843 static unsigned int
844 coff_swap_scnhdr_out (abfd, in, out)
845      bfd       *abfd;
846      PTR        in;
847      PTR        out;
848 {
849   struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
850   SCNHDR *scnhdr_ext = (SCNHDR *)out;
851   unsigned int ret = SCNHSZ;
852
853 #ifdef COFF_ADJUST_SCNHDR_OUT_PRE
854   COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out);
855 #endif
856   memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
857
858   PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr,
859                     (bfd_byte *) scnhdr_ext->s_vaddr);
860
861
862   PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr,
863                     (bfd_byte *) scnhdr_ext->s_paddr);
864   PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size,
865                    (bfd_byte *) scnhdr_ext->s_size);
866
867   PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
868                      (bfd_byte *) scnhdr_ext->s_scnptr);
869   PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
870                      (bfd_byte *) scnhdr_ext->s_relptr);
871   PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
872                       (bfd_byte *) scnhdr_ext->s_lnnoptr);
873   PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags,
874                     (bfd_byte *) scnhdr_ext->s_flags);
875 #if defined(M88)
876   PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
877   PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
878 #else
879   if (scnhdr_int->s_nlnno <= 0xffff)
880     PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
881   else
882     {
883       char buf[sizeof (scnhdr_int->s_name) + 1];
884
885       memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
886       buf[sizeof (scnhdr_int->s_name)] = '\0';
887       (*_bfd_error_handler)
888         (_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
889          bfd_get_filename (abfd),
890          buf, scnhdr_int->s_nlnno);
891       PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
892     }
893   if (scnhdr_int->s_nreloc <= 0xffff)
894     PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
895   else
896     {
897       char buf[sizeof (scnhdr_int->s_name) + 1];
898
899       memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
900       buf[sizeof (scnhdr_int->s_name)] = '\0';
901       (*_bfd_error_handler) (_("%s: %s: reloc overflow: 0x%lx > 0xffff"),
902                              bfd_get_filename (abfd),
903                              buf, scnhdr_int->s_nreloc);
904       bfd_set_error (bfd_error_file_truncated);
905       PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
906       ret = 0;
907     }
908 #endif
909
910 #ifdef I960
911   PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
912 #endif
913 #ifdef COFF_ADJUST_SCNHDR_OUT_POST
914   COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
915 #endif
916   return ret;
917 }