Fix hp300bsd entry point problem.
[deliverable/binutils-gdb.git] / bfd / coffswap.c
1 /* Byte-swapping routines for COFF files */
2
3 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
4
5 This file is part of BFD, the Binary File Diddler.
6
7 BFD 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
11 BFD 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
16 You 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 */
22 #if 0
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)
29
30 /* All the generic swapping routines:
31
32 FIXME
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 */
38
39 void
40 DEFUN(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
53 void
54 DEFUN(bfd_coff_swap_sym,(abfd, se),
55 bfd *abfd AND
56 struct internal_syment *se)
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
66 void
67 DEFUN(bfd_coff_swap_aux,(abfd, au, type, class),
68 bfd *abfd AND
69 struct internal_auxent *au AND
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
112 void
113 DEFUN(bfd_coff_swap_lineno,(abfd, lineno),
114 bfd *abfd AND
115 struct internal_lineno *lineno)
116 {
117 sp(lineno->l_addr.l_symndx);
118 sp(lineno->l_lnno);
119 }
120
121
122
123 #endif
This page took 0.033895 seconds and 4 git commands to generate.