use bootstrap for check
[deliverable/binutils-gdb.git] / bfd / coffswap.c
CommitLineData
ff37ea55
JG
1/* Byte-swapping routines for COFF files */
2
3/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
4
5This file is part of BFD, the Binary File Diddler.
6
7BFD is free software; you can redistribute it and/or modify it under the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation; either version 1, or (at your option) any later version.
10
11BFD is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 details.
15
16You should have received a copy of the GNU General Public License along with
17 BFD; see the file COPYING. If not, write to the Free Software Foundation,
18 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21/* Most of this hacked by Steve Chamberlain, steve@cygnus.com */
19b03b7a 22#if 0
ff37ea55
JG
23#include <ansidecl.h>
24#include "intel-coff.h"
25#include "bfd.h"
26#include "libcoff.h" /* to allow easier abstraction-breaking */
27
28#define sp(x) bfd_h_put_x(abfd, x, &x)
19b03b7a 29
e5b919b1 30/* All the generic swapping routines:
ff37ea55 31
e5b919b1
SC
32FIXME
33 These routines cater for the sizes and alignments and offsets of
34 all the contained fields. Because of this, the fields can change
35 size, so these should be phased out to use the ones specific to the
36 file format.
37 */
ff37ea55
JG
38
39void
40DEFUN(bfd_coff_swap_name,(abfd, ptr),
41 bfd *abfd AND
42 long *ptr)
43{
44 if (ptr[0] == 0) {
45 /* There is an index which needs to be swapped */
46 bfd_h_put_x(abfd, ptr[1], (ptr + 1));
47 }
48 else {
49 /* This is a string .. leave it alone */
50 }
51}
52
53void
54DEFUN(bfd_coff_swap_sym,(abfd, se),
55 bfd *abfd AND
e5b919b1 56 struct internal_syment *se)
ff37ea55
JG
57{
58 bfd_coff_swap_name(abfd, (long*)(se->n_name));
59 bfd_h_put_x(abfd, se->n_value, &se->n_value);
60 bfd_h_put_x(abfd, se->n_scnum, &se->n_scnum);
61 bfd_h_put_x(abfd, se->n_type, &se->n_type);
62 bfd_h_put_x(abfd, se->n_sclass, &se->n_sclass);
63 bfd_h_put_x(abfd, se->n_numaux, &se->n_numaux);
64}
65
66void
67DEFUN(bfd_coff_swap_aux,(abfd, au, type, class),
68 bfd *abfd AND
e5b919b1 69 struct internal_auxent *au AND
ff37ea55
JG
70 int type AND
71 int class)
72{
73 switch (class) {
74 case C_FILE:
75 bfd_coff_swap_name(abfd, (long *)(&au->x_file.x_n));
76 break;
77 case C_STAT:
78#ifdef C_LEAFSTAT
79 case C_LEAFSTAT:
80#endif
81 case C_HIDDEN:
82 if (type == T_NULL) {
83 sp(au->x_scn.x_scnlen);
84 sp(au->x_scn.x_nreloc);
85 sp(au->x_scn.x_nlinno);
86 break;
87 }
88 default:
89 sp(au->x_sym.x_tagndx);
90 sp(au->x_sym.x_tvndx);
91
92 if (ISARY(type) || class == C_BLOCK) {
93 sp(au->x_sym.x_fcnary.x_ary.x_dimen[0]);
94 sp(au->x_sym.x_fcnary.x_ary.x_dimen[1]);
95 sp(au->x_sym.x_fcnary.x_ary.x_dimen[2]);
96 sp(au->x_sym.x_fcnary.x_ary.x_dimen[3]);
97 }
98 else {
99 sp(au->x_sym.x_fcnary.x_fcn.x_lnnoptr);
100 sp(au->x_sym.x_fcnary.x_fcn.x_endndx);
101 }
102 if (ISFCN(type)) {
103 sp(au->x_sym.x_misc.x_fsize);
104 }
105 else {
106 sp(au->x_sym.x_misc.x_lnsz.x_lnno);
107 sp(au->x_sym.x_misc.x_lnsz.x_size);
108 }
109 }
110}
111
112void
113DEFUN(bfd_coff_swap_lineno,(abfd, lineno),
114 bfd *abfd AND
e5b919b1 115 struct internal_lineno *lineno)
ff37ea55
JG
116{
117 sp(lineno->l_addr.l_symndx);
118 sp(lineno->l_lnno);
119}
120
121
e5b919b1
SC
122
123#endif
This page took 0.046535 seconds and 4 git commands to generate.