source: trunk/src/binutils/bfd/coff64-rs6000.c@ 10

Last change on this file since 10 was 10, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 10.8 KB
Line 
1/* BFD back-end for IBM RS/6000 "XCOFF64" files.
2 Copyright 2000, 2001
3 Free Software Foundation, Inc.
4 Written Clinton Popetz.
5 Contributed 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/* Internalcoff.h and coffcode.h modify themselves based on these flags. */
24#define XCOFF64
25#define RS6000COFF_C 1
26
27#include "bfd.h"
28#include "sysdep.h"
29#include "libbfd.h"
30#include "coff/internal.h"
31#include "coff/rs6k64.h"
32#include "libcoff.h"
33
34#define GET_FILEHDR_SYMPTR bfd_h_get_64
35#define PUT_FILEHDR_SYMPTR bfd_h_put_64
36#define GET_AOUTHDR_DATA_START bfd_h_get_64
37#define PUT_AOUTHDR_DATA_START bfd_h_put_64
38#define GET_AOUTHDR_TEXT_START bfd_h_get_64
39#define PUT_AOUTHDR_TEXT_START bfd_h_put_64
40#define GET_AOUTHDR_TSIZE bfd_h_get_64
41#define PUT_AOUTHDR_TSIZE bfd_h_put_64
42#define GET_AOUTHDR_DSIZE bfd_h_get_64
43#define PUT_AOUTHDR_DSIZE bfd_h_put_64
44#define GET_AOUTHDR_BSIZE bfd_h_get_64
45#define PUT_AOUTHDR_BSIZE bfd_h_put_64
46#define GET_AOUTHDR_ENTRY bfd_h_get_64
47#define PUT_AOUTHDR_ENTRY bfd_h_put_64
48#define GET_SCNHDR_PADDR bfd_h_get_64
49#define PUT_SCNHDR_PADDR bfd_h_put_64
50#define GET_SCNHDR_VADDR bfd_h_get_64
51#define PUT_SCNHDR_VADDR bfd_h_put_64
52#define GET_SCNHDR_SIZE bfd_h_get_64
53#define PUT_SCNHDR_SIZE bfd_h_put_64
54#define GET_SCNHDR_SCNPTR bfd_h_get_64
55#define PUT_SCNHDR_SCNPTR bfd_h_put_64
56#define GET_SCNHDR_RELPTR bfd_h_get_64
57#define PUT_SCNHDR_RELPTR bfd_h_put_64
58#define GET_SCNHDR_LNNOPTR bfd_h_get_64
59#define PUT_SCNHDR_LNNOPTR bfd_h_put_64
60#define GET_SCNHDR_NRELOC bfd_h_get_32
61#define MAX_SCNHDR_NRELOC 0xffffffff
62#define PUT_SCNHDR_NRELOC bfd_h_put_32
63#define GET_SCNHDR_NLNNO bfd_h_get_32
64#define MAX_SCNHDR_NLNNO 0xffffffff
65#define PUT_SCNHDR_NLNNO bfd_h_put_32
66#define GET_RELOC_VADDR bfd_h_get_64
67#define PUT_RELOC_VADDR bfd_h_put_64
68
69#define COFF_FORCE_SYMBOLS_IN_STRINGS
70#define COFF_DEBUG_STRING_WIDE_PREFIX
71
72#define COFF_ADJUST_SCNHDR_OUT_POST(ABFD,INT,EXT) \
73do { \
74 memset (((SCNHDR *)EXT)->s_pad, 0, sizeof (((SCNHDR *)EXT)->s_pad));\
75} while (0)
76
77#define NO_COFF_LINENOS
78
79#define coff_SWAP_lineno_in xcoff64_swap_lineno_in
80#define coff_SWAP_lineno_out xcoff64_swap_lineno_out
81
82#define PUTWORD bfd_h_put_32
83#define PUTHALF bfd_h_put_16
84#define PUTBYTE bfd_h_put_8
85#define GETWORD bfd_h_get_32
86#define GETHALF bfd_h_get_16
87#define GETBYTE bfd_h_get_8
88
89/* For XCOFF64, the effective width of symndx changes depending on
90 whether we are the first entry. Sigh. */
91static void
92xcoff64_swap_lineno_in (abfd, ext1, in1)
93 bfd *abfd;
94 PTR ext1;
95 PTR in1;
96{
97 LINENO *ext = (LINENO *)ext1;
98 struct internal_lineno *in = (struct internal_lineno *)in1;
99
100 in->l_lnno = bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
101 if (in->l_lnno == 0)
102 in->l_addr.l_symndx =
103 bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
104 else
105 in->l_addr.l_symndx =
106 bfd_h_get_64(abfd, (bfd_byte *) ext->l_addr.l_symndx);
107}
108
109static unsigned int
110xcoff64_swap_lineno_out (abfd, inp, outp)
111 bfd *abfd;
112 PTR inp;
113 PTR outp;
114{
115 struct internal_lineno *in = (struct internal_lineno *)inp;
116 struct external_lineno *ext = (struct external_lineno *)outp;
117 PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
118 ext->l_addr.l_symndx);
119
120 bfd_h_put_32 (abfd, in->l_lnno, (bfd_byte *) (ext->l_lnno));
121 if (in->l_lnno == 0)
122 bfd_h_put_32 (abfd, in->l_addr.l_symndx, (bfd_byte *)ext->l_addr.l_symndx);
123 else
124 bfd_h_put_64 (abfd, in->l_addr.l_symndx, (bfd_byte *)ext->l_addr.l_symndx);
125
126 return bfd_coff_linesz (abfd);
127}
128
129static void xcoff64_swap_sym_in PARAMS ((bfd *, PTR, PTR));
130static unsigned int xcoff64_swap_sym_out PARAMS ((bfd *, PTR, PTR));
131static void xcoff64_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
132static unsigned int xcoff64_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
133
134static void
135xcoff64_swap_sym_in (abfd, ext1, in1)
136 bfd *abfd;
137 PTR ext1;
138 PTR in1;
139{
140 SYMENT *ext = (SYMENT *)ext1;
141 struct internal_syment *in = (struct internal_syment *)in1;
142
143 in->_n._n_n._n_zeroes = 0;
144 in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e_offset);
145 in->n_value = bfd_h_get_64(abfd, (bfd_byte *) ext->e.e_value);
146 in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
147 in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
148 in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
149 in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
150}
151
152static unsigned int
153xcoff64_swap_sym_out (abfd, inp, extp)
154 bfd *abfd;
155 PTR inp;
156 PTR extp;
157{
158 struct internal_syment *in = (struct internal_syment *)inp;
159 SYMENT *ext =(SYMENT *)extp;
160
161 bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e_offset);
162 bfd_h_put_64(abfd, in->n_value , (bfd_byte *) ext->e.e_value);
163 bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
164 bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
165 bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
166 bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
167 return bfd_coff_symesz (abfd);