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