OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [bfd/] [coffswap.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.