]>
Commit | Line | Data |
---|---|---|
fbffaf55 ILT |
1 | /* Generic ECOFF swapping routines, for BFD. |
2 | Copyright 1992, 1993 Free Software Foundation, Inc. | |
3 | Written by Cygnus Support. | |
4 | ||
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
1ec02944 | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
fbffaf55 ILT |
20 | |
21 | /* NOTE: This is a header file, but it contains executable routines. | |
22 | This is done this way because these routines are substantially | |
23 | similar, but are not identical, for all ECOFF targets. | |
24 | ||
25 | These are routines to swap the ECOFF symbolic information in and | |
26 | out. The routines are defined statically. You can set breakpoints | |
27 | on them in gdb by naming the including source file; e.g., | |
28 | 'coff-mips.c':ecoff_swap_hdr_in. | |
29 | ||
30 | Before including this header file, one of ECOFF_32 or ECOFF_64 must | |
31 | be defined. These are checked when swapping information that | |
32 | depends upon the target size. This code works for 32 bit and 64 | |
33 | bit ECOFF, but may need to be generalized in the future. | |
34 | ||
35 | Some header file which defines the external forms of these | |
36 | structures must also be included before including this header file. | |
37 | Currently this is either coff/mips.h or coff/alpha.h. | |
38 | ||
39 | If the symbol TEST is defined when this file is compiled, a | |
40 | comparison is made to ensure that, in fact, the output is | |
41 | bit-for-bit the same as the input. Of course, this symbol should | |
42 | only be defined when deliberately testing the code on a machine | |
43 | with the proper byte sex and such. */ | |
44 | ||
45 | #ifdef ECOFF_32 | |
46 | #define ecoff_get_off bfd_h_get_32 | |
47 | #define ecoff_put_off bfd_h_put_32 | |
48 | #endif | |
49 | #ifdef ECOFF_64 | |
50 | #define ecoff_get_off bfd_h_get_64 | |
51 | #define ecoff_put_off bfd_h_put_64 | |
52 | #endif | |
53 | ||
aac6b32f | 54 | /* ECOFF auxiliary information swapping routines. These are the same |
1ec02944 ILT |
55 | for all ECOFF targets, so they are defined in ecofflink.c. */ |
56 | ||
97d5a149 KR |
57 | extern void _bfd_ecoff_swap_tir_in |
58 | PARAMS ((int, const struct tir_ext *, TIR *)); | |
59 | extern void _bfd_ecoff_swap_tir_out | |
60 | PARAMS ((int, const TIR *, struct tir_ext *)); | |
61 | extern void _bfd_ecoff_swap_rndx_in | |
62 | PARAMS ((int, const struct rndx_ext *, RNDXR *)); | |
63 | extern void _bfd_ecoff_swap_rndx_out | |
64 | PARAMS ((int, const RNDXR *, struct rndx_ext *)); | |
aac6b32f | 65 | |
1ec02944 ILT |
66 | /* Prototypes for functions defined in this file. */ |
67 | ||
68 | static void ecoff_swap_hdr_in PARAMS ((bfd *, PTR, HDRR *)); | |
69 | static void ecoff_swap_hdr_out PARAMS ((bfd *, const HDRR *, PTR)); | |
70 | static void ecoff_swap_fdr_in PARAMS ((bfd *, PTR, FDR *)); | |
71 | static void ecoff_swap_fdr_out PARAMS ((bfd *, const FDR *, PTR)); | |
72 | static void ecoff_swap_pdr_in PARAMS ((bfd *, PTR, PDR *)); | |
73 | static void ecoff_swap_pdr_out PARAMS ((bfd *, const PDR *, PTR)); | |
74 | static void ecoff_swap_sym_in PARAMS ((bfd *, PTR, SYMR *)); | |
75 | static void ecoff_swap_sym_out PARAMS ((bfd *, const SYMR *, PTR)); | |
76 | static void ecoff_swap_ext_in PARAMS ((bfd *, PTR, EXTR *)); | |
77 | static void ecoff_swap_ext_out PARAMS ((bfd *, const EXTR *, PTR)); | |
78 | static void ecoff_swap_rfd_in PARAMS ((bfd *, PTR, RFDT *)); | |
79 | static void ecoff_swap_rfd_out PARAMS ((bfd *, const RFDT *, PTR)); | |
80 | static void ecoff_swap_opt_in PARAMS ((bfd *, PTR, OPTR *)); | |
81 | static void ecoff_swap_opt_out PARAMS ((bfd *, const OPTR *, PTR)); | |
82 | static void ecoff_swap_dnr_in PARAMS ((bfd *, PTR, DNR *)); | |
83 | static void ecoff_swap_dnr_out PARAMS ((bfd *, const DNR *, PTR)); | |
84 | ||
fbffaf55 ILT |
85 | /* Swap in the symbolic header. */ |
86 | ||
87 | static void | |
88 | ecoff_swap_hdr_in (abfd, ext_copy, intern) | |
89 | bfd *abfd; | |
90 | PTR ext_copy; | |
91 | HDRR *intern; | |
92 | { | |
93 | struct hdr_ext ext[1]; | |
94 | ||
95 | *ext = *(struct hdr_ext *) ext_copy; | |
96 | ||
97 | intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic); | |
98 | intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp); | |
99 | intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax); | |
100 | intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine); | |
101 | intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset); | |
102 | intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax); | |
103 | intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset); | |
104 | intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax); | |
105 | intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset); | |
106 | intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax); | |
107 | intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset); | |
108 | intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax); | |
109 | intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset); | |
110 | intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax); | |
111 | intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset); | |
112 | intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax); | |
113 | intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset); | |
114 | intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax); | |
115 | intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset); | |
116 | intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax); | |
117 | intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset); | |
118 | intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd); | |
119 | intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset); | |
120 | intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax); | |
121 | intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset); | |
122 | ||
123 | #ifdef TEST | |
124 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
125 | abort(); | |
126 | #endif | |
127 | } | |
128 | ||
129 | /* Swap out the symbolic header. */ | |
130 | ||
131 | static void | |
132 | ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr) | |
133 | bfd *abfd; | |
134 | const HDRR *intern_copy; | |
135 | PTR ext_ptr; | |
136 | { | |
137 | struct hdr_ext *ext = (struct hdr_ext *) ext_ptr; | |
138 | HDRR intern[1]; | |
139 | ||
140 | *intern = *intern_copy; | |
141 | ||
142 | bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic); | |
143 | bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp); | |
144 | bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax); | |
145 | ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine); | |
146 | ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset); | |
147 | bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax); | |
148 | ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset); | |
149 | bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax); | |
150 | ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset); | |
151 | bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax); | |
152 | ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset); | |
153 | bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax); | |
154 | ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset); | |
155 | bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax); | |
156 | ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset); | |
157 | bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax); | |
158 | ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset); | |
159 | bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax); | |
160 | ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset); | |
161 | bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax); | |
162 | ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset); | |
163 | bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd); | |
164 | ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset); | |
165 | bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax); | |
166 | ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset); | |
167 | ||
168 | #ifdef TEST | |
169 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
170 | abort(); | |
171 | #endif | |
172 | } | |
173 | ||
174 | /* Swap in the file descriptor record. */ | |
175 | ||
176 | static void | |
177 | ecoff_swap_fdr_in (abfd, ext_copy, intern) | |
178 | bfd *abfd; | |
179 | PTR ext_copy; | |
180 | FDR *intern; | |
181 | { | |
182 | struct fdr_ext ext[1]; | |
183 | ||
184 | *ext = *(struct fdr_ext *) ext_copy; | |
185 | ||
186 | intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr); | |
187 | intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss); | |
188 | intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase); | |
189 | intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs); | |
190 | intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase); | |
191 | intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym); | |
192 | intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase); | |
193 | intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline); | |
194 | intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase); | |
195 | intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt); | |
196 | #ifdef ECOFF_32 | |
197 | intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst); | |
198 | intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd); | |
199 | #endif | |
200 | #ifdef ECOFF_64 | |
201 | intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst); | |
202 | intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd); | |
203 | #endif | |
204 | intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase); | |
205 | intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux); | |
206 | intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase); | |
207 | intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd); | |
208 | ||
209 | /* now the fun stuff... */ | |
1ec02944 | 210 | if (bfd_header_big_endian (abfd)) { |
fbffaf55 ILT |
211 | intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG) |
212 | >> FDR_BITS1_LANG_SH_BIG; | |
213 | intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG); | |
214 | intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG); | |
215 | intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG); | |
216 | intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG) | |
217 | >> FDR_BITS2_GLEVEL_SH_BIG; | |
218 | } else { | |
219 | intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE) | |
220 | >> FDR_BITS1_LANG_SH_LITTLE; | |
221 | intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE); | |
222 | intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE); | |
223 | intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE); | |
224 | intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE) | |
225 | >> FDR_BITS2_GLEVEL_SH_LITTLE; | |
226 | } | |
227 | intern->reserved = 0; | |
228 | ||
229 | intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset); | |
230 | intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine); | |
231 | ||
232 | #ifdef TEST | |
233 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
234 | abort(); | |
235 | #endif | |
236 | } | |
237 | ||
238 | /* Swap out the file descriptor record. */ | |
239 | ||
240 | static void | |
241 | ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr) | |
242 | bfd *abfd; | |
aac6b32f | 243 | const FDR *intern_copy; |
fbffaf55 ILT |
244 | PTR ext_ptr; |
245 | { | |
246 | struct fdr_ext *ext = (struct fdr_ext *) ext_ptr; | |
247 | FDR intern[1]; | |
248 | ||
249 | *intern = *intern_copy; /* Make it reasonable to do in-place. */ | |
250 | ||
251 | ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr); | |
252 | bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss); | |
253 | bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase); | |
254 | ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs); | |
255 | bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase); | |
256 | bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym); | |
257 | bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase); | |
258 | bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline); | |
259 | bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase); | |
260 | bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt); | |
261 | #ifdef ECOFF_32 | |
262 | bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst); | |
263 | bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd); | |
264 | #endif | |
265 | #ifdef ECOFF_64 | |
266 | bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst); | |
267 | bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd); | |
268 | #endif | |
269 | bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase); | |
270 | bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux); | |
271 | bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase); | |
272 | bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd); | |
273 | ||
274 | /* now the fun stuff... */ | |
1ec02944 | 275 | if (bfd_header_big_endian (abfd)) { |
fbffaf55 ILT |
276 | ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG) |
277 | & FDR_BITS1_LANG_BIG) | |
278 | | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0) | |
279 | | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0) | |
280 | | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0)); | |
281 | ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG) | |
282 | & FDR_BITS2_GLEVEL_BIG); | |
283 | ext->f_bits2[1] = 0; | |
284 | ext->f_bits2[2] = 0; | |
285 | } else { | |
286 | ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE) | |
287 | & FDR_BITS1_LANG_LITTLE) | |
288 | | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0) | |
289 | | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0) | |
290 | | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0)); | |
291 | ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE) | |
292 | & FDR_BITS2_GLEVEL_LITTLE); | |
293 | ext->f_bits2[1] = 0; | |
294 | ext->f_bits2[2] = 0; | |
295 | } | |
296 | ||
297 | ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset); | |
298 | ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine); | |
299 | ||
300 | #ifdef TEST | |
301 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
302 | abort(); | |
303 | #endif | |
304 | } | |
305 | ||
97d5a149 | 306 | #ifndef MPW_C |
1ec02944 | 307 | |
fbffaf55 ILT |
308 | /* Swap in the procedure descriptor record. */ |
309 | ||
310 | static void | |
311 | ecoff_swap_pdr_in (abfd, ext_copy, intern) | |
312 | bfd *abfd; | |
313 | PTR ext_copy; | |
314 | PDR *intern; | |
315 | { | |
316 | struct pdr_ext ext[1]; | |
317 | ||
318 | *ext = *(struct pdr_ext *) ext_copy; | |
1ec02944 ILT |
319 | |
320 | memset ((PTR) intern, 0, sizeof (*intern)); | |
321 | ||
fbffaf55 ILT |
322 | intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr); |
323 | intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym); | |
324 | intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline); | |
325 | intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask); | |
aac6b32f ILT |
326 | intern->regoffset = bfd_h_get_signed_32 (abfd, |
327 | (bfd_byte *)ext->p_regoffset); | |
328 | intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt); | |
fbffaf55 | 329 | intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask); |
aac6b32f ILT |
330 | intern->fregoffset = bfd_h_get_signed_32 (abfd, |
331 | (bfd_byte *)ext->p_fregoffset); | |
332 | intern->frameoffset = bfd_h_get_signed_32 (abfd, | |
333 | (bfd_byte *)ext->p_frameoffset); | |
fbffaf55 ILT |
334 | intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg); |
335 | intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg); | |
336 | intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow); | |
337 | intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh); | |
338 | intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset); | |
339 | ||
aac6b32f ILT |
340 | #ifdef ECOFF_64 |
341 | intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue); | |
1ec02944 | 342 | if (bfd_header_big_endian (abfd)) |
aac6b32f ILT |
343 | { |
344 | intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG); | |
345 | intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG); | |
97d5a149 | 346 | intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_BIG); |
aac6b32f ILT |
347 | intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG) |
348 | << PDR_BITS1_RESERVED_SH_LEFT_BIG) | |
349 | | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG) | |
350 | >> PDR_BITS2_RESERVED_SH_BIG)); | |
351 | } | |
352 | else | |
353 | { | |
354 | intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE); | |
355 | intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE); | |
97d5a149 | 356 | intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_LITTLE); |
aac6b32f ILT |
357 | intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE) |
358 | >> PDR_BITS1_RESERVED_SH_LITTLE) | |
359 | | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE) | |
360 | << PDR_BITS2_RESERVED_SH_LEFT_LITTLE)); | |
361 | } | |
362 | intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff); | |
363 | #endif | |
364 | ||
fbffaf55 ILT |
365 | #ifdef TEST |
366 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
367 | abort(); | |
368 | #endif | |
369 | } | |
370 | ||
371 | /* Swap out the procedure descriptor record. */ | |
372 | ||
373 | static void | |
374 | ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr) | |
375 | bfd *abfd; | |
aac6b32f | 376 | const PDR *intern_copy; |
fbffaf55 ILT |
377 | PTR ext_ptr; |
378 | { | |
379 | struct pdr_ext *ext = (struct pdr_ext *) ext_ptr; | |
380 | PDR intern[1]; | |
381 | ||
382 | *intern = *intern_copy; /* Make it reasonable to do in-place. */ | |
383 | ||
384 | ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr); | |
385 | bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym); | |
386 | bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline); | |
387 | bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask); | |
388 | bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset); | |
389 | bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt); | |
390 | bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask); | |
391 | bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset); | |
392 | bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset); | |
393 | bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg); | |
394 | bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg); | |
395 | bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow); | |
396 | bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh); | |
397 | ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset); | |
398 | ||
aac6b32f ILT |
399 | #ifdef ECOFF_64 |
400 | bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue); | |
1ec02944 | 401 | if (bfd_header_big_endian (abfd)) |
aac6b32f ILT |
402 | { |
403 | ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0) | |
404 | | (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0) | |
97d5a149 | 405 | | (intern->prof ? PDR_BITS1_PROF_BIG : 0) |
aac6b32f ILT |
406 | | ((intern->reserved |
407 | >> PDR_BITS1_RESERVED_SH_LEFT_BIG) | |
408 | & PDR_BITS1_RESERVED_BIG)); | |
409 | ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG) | |
410 | & PDR_BITS2_RESERVED_BIG); | |
411 | } | |
412 | else | |
413 | { | |
414 | ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0) | |
415 | | (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0) | |
97d5a149 | 416 | | (intern->prof ? PDR_BITS1_PROF_LITTLE : 0) |
aac6b32f ILT |
417 | | ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE) |
418 | & PDR_BITS1_RESERVED_LITTLE)); | |
419 | ext->p_bits2[0] = ((intern->reserved >> | |
420 | PDR_BITS2_RESERVED_SH_LEFT_LITTLE) | |
421 | & PDR_BITS2_RESERVED_LITTLE); | |
422 | } | |
423 | bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff); | |
424 | #endif | |
425 | ||
fbffaf55 ILT |
426 | #ifdef TEST |
427 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
428 | abort(); | |
429 | #endif | |
430 | } | |
1ec02944 | 431 | |
97d5a149 KR |
432 | #else /* MPW_C */ |
433 | /* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't | |
434 | corrupt itself and then freak out. */ | |
435 | /* Swap in the procedure descriptor record. */ | |
436 | ||
437 | static void | |
438 | ecoff_swap_pdr_in (abfd, ext_copy, intern) | |
439 | bfd *abfd; | |
440 | PTR ext_copy; | |
441 | PDR *intern; | |
442 | { | |
443 | struct pdr_ext ext[1]; | |
444 | ||
445 | *ext = *(struct pdr_ext *) ext_copy; | |
446 | ||
447 | intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr); | |
448 | intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym); | |
449 | intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline); | |
450 | intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask); | |
451 | intern->regoffset = bfd_h_get_signed_32 (abfd, | |
452 | (bfd_byte *)ext->p_regoffset); | |
453 | intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt); | |
454 | intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask); | |
455 | intern->fregoffset = bfd_h_get_signed_32 (abfd, | |
456 | (bfd_byte *)ext->p_fregoffset); | |
457 | intern->frameoffset = bfd_h_get_signed_32 (abfd, | |
458 | (bfd_byte *)ext->p_frameoffset); | |
459 | intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg); | |
460 | intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg); | |
461 | intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow); | |
462 | intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh); | |
463 | intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset); | |
464 | ||
465 | #ifdef TEST | |
466 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
467 | abort(); | |
468 | #endif | |
469 | } | |
470 | ||
471 | /* Swap out the procedure descriptor record. */ | |
472 | ||
473 | static void | |
474 | ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr) | |
475 | bfd *abfd; | |
476 | const PDR *intern_copy; | |
477 | PTR ext_ptr; | |
478 | { | |
479 | struct pdr_ext *ext = (struct pdr_ext *) ext_ptr; | |
480 | PDR intern[1]; | |
481 | ||
482 | *intern = *intern_copy; /* Make it reasonable to do in-place. */ | |
483 | ||
484 | ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr); | |
485 | bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym); | |
486 | bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline); | |
487 | bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask); | |
488 | bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset); | |
489 | bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt); | |
490 | bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask); | |
491 | bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset); | |
492 | bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset); | |
493 | bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg); | |
494 | bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg); | |
495 | bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow); | |
496 | bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh); | |
497 | ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset); | |
498 | ||
499 | #ifdef TEST | |
500 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
501 | abort(); | |
502 | #endif | |
503 | } | |
504 | #endif /* MPW_C */ | |
fbffaf55 ILT |
505 | |
506 | /* Swap in a symbol record. */ | |
507 | ||
508 | static void | |
509 | ecoff_swap_sym_in (abfd, ext_copy, intern) | |
510 | bfd *abfd; | |
511 | PTR ext_copy; | |
512 | SYMR *intern; | |
513 | { | |
514 | struct sym_ext ext[1]; | |
515 | ||
516 | *ext = *(struct sym_ext *) ext_copy; | |
517 | ||
518 | intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss); | |
519 | intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value); | |
520 | ||
521 | /* now the fun stuff... */ | |
1ec02944 | 522 | if (bfd_header_big_endian (abfd)) { |
fbffaf55 ILT |
523 | intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG) |
524 | >> SYM_BITS1_ST_SH_BIG; | |
525 | intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG) | |
526 | << SYM_BITS1_SC_SH_LEFT_BIG) | |
527 | | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG) | |
528 | >> SYM_BITS2_SC_SH_BIG); | |
529 | intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG); | |
530 | intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG) | |
531 | << SYM_BITS2_INDEX_SH_LEFT_BIG) | |
532 | | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG) | |
533 | | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG); | |
534 | } else { | |
535 | intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE) | |
536 | >> SYM_BITS1_ST_SH_LITTLE; | |
537 | intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE) | |
538 | >> SYM_BITS1_SC_SH_LITTLE) | |
539 | | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE) | |
540 | << SYM_BITS2_SC_SH_LEFT_LITTLE); | |
541 | intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE); | |
542 | intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE) | |
543 | >> SYM_BITS2_INDEX_SH_LITTLE) | |
544 | | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE) | |
aac6b32f ILT |
545 | | ((unsigned int) ext->s_bits4[0] |
546 | << SYM_BITS4_INDEX_SH_LEFT_LITTLE); | |
fbffaf55 ILT |
547 | } |
548 | ||
549 | #ifdef TEST | |
550 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
551 | abort(); | |
552 | #endif | |
553 | } | |
554 | ||
555 | /* Swap out a symbol record. */ | |
556 | ||
557 | static void | |
558 | ecoff_swap_sym_out (abfd, intern_copy, ext_ptr) | |
559 | bfd *abfd; | |
aac6b32f | 560 | const SYMR *intern_copy; |
fbffaf55 ILT |
561 | PTR ext_ptr; |
562 | { | |
563 | struct sym_ext *ext = (struct sym_ext *) ext_ptr; | |
564 | SYMR intern[1]; | |
565 | ||
566 | *intern = *intern_copy; /* Make it reasonable to do in-place. */ | |
567 | ||
568 | bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss); | |
569 | ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value); | |
570 | ||
571 | /* now the fun stuff... */ | |
1ec02944 | 572 | if (bfd_header_big_endian (abfd)) { |
fbffaf55 ILT |
573 | ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG) |
574 | & SYM_BITS1_ST_BIG) | |
575 | | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG) | |
576 | & SYM_BITS1_SC_BIG)); | |
577 | ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG) | |
578 | & SYM_BITS2_SC_BIG) | |
579 | | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0) | |
580 | | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG) | |
581 | & SYM_BITS2_INDEX_BIG)); | |
582 | ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff; | |
583 | ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff; | |
584 | } else { | |
585 | ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE) | |
586 | & SYM_BITS1_ST_LITTLE) | |
587 | | ((intern->sc << SYM_BITS1_SC_SH_LITTLE) | |
588 | & SYM_BITS1_SC_LITTLE)); | |
589 | ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE) | |
590 | & SYM_BITS2_SC_LITTLE) | |
591 | | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0) | |
592 | | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE) | |
593 | & SYM_BITS2_INDEX_LITTLE)); | |
594 | ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff; | |
595 | ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff; | |
596 | } | |
597 | ||
598 | #ifdef TEST | |
599 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
600 | abort(); | |
601 | #endif | |
602 | } | |
603 | ||
604 | /* Swap in an external symbol record. */ | |
605 | ||
606 | static void | |
607 | ecoff_swap_ext_in (abfd, ext_copy, intern) | |
608 | bfd *abfd; | |
609 | PTR ext_copy; | |
610 | EXTR *intern; | |
611 | { | |
612 | struct ext_ext ext[1]; | |
613 | ||
614 | *ext = *(struct ext_ext *) ext_copy; | |
615 | ||
616 | /* now the fun stuff... */ | |
1ec02944 | 617 | if (bfd_header_big_endian (abfd)) { |
fbffaf55 ILT |
618 | intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG); |
619 | intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG); | |
620 | intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG); | |
621 | } else { | |
622 | intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE); | |
623 | intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE); | |
624 | intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE); | |
625 | } | |
626 | intern->reserved = 0; | |
627 | ||
628 | #ifdef ECOFF_32 | |
629 | intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd); | |
630 | #endif | |
631 | #ifdef ECOFF_64 | |
632 | intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd); | |
633 | #endif | |
634 | ||
635 | ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym); | |
636 | ||
637 | #ifdef TEST | |
638 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
639 | abort(); | |
640 | #endif | |
641 | } | |
642 | ||
643 | /* Swap out an external symbol record. */ | |
644 | ||
645 | static void | |
646 | ecoff_swap_ext_out (abfd, intern_copy, ext_ptr) | |
647 | bfd *abfd; | |
aac6b32f | 648 | const EXTR *intern_copy; |
fbffaf55 ILT |
649 | PTR ext_ptr; |
650 | { | |
651 | struct ext_ext *ext = (struct ext_ext *) ext_ptr; | |
652 | EXTR intern[1]; | |
653 | ||
654 | *intern = *intern_copy; /* Make it reasonable to do in-place. */ | |
655 | ||
656 | /* now the fun stuff... */ | |
1ec02944 | 657 | if (bfd_header_big_endian (abfd)) { |
fbffaf55 ILT |
658 | ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0) |
659 | | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0) | |
660 | | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0)); | |
661 | ext->es_bits2[0] = 0; | |
97d5a149 KR |
662 | #ifdef ECOFF_64 |
663 | ext->es_bits2[1] = 0; | |
664 | ext->es_bits2[2] = 0; | |
665 | #endif | |
fbffaf55 ILT |
666 | } else { |
667 | ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0) | |
668 | | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0) | |
669 | | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0)); | |
670 | ext->es_bits2[0] = 0; | |
97d5a149 KR |
671 | #ifdef ECOFF_64 |
672 | ext->es_bits2[1] = 0; | |
673 | ext->es_bits2[2] = 0; | |
674 | #endif | |
fbffaf55 ILT |
675 | } |
676 | ||
677 | #ifdef ECOFF_32 | |
678 | bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd); | |
679 | #endif | |
680 | #ifdef ECOFF_64 | |
681 | bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd); | |
682 | #endif | |
683 | ||
684 | ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym); | |
685 | ||
686 | #ifdef TEST | |
687 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
688 | abort(); | |
689 | #endif | |
690 | } | |
691 | ||
692 | /* Swap in a relative file descriptor. */ | |
693 | ||
694 | static void | |
695 | ecoff_swap_rfd_in (abfd, ext_ptr, intern) | |
696 | bfd *abfd; | |
697 | PTR ext_ptr; | |
698 | RFDT *intern; | |
699 | { | |
700 | struct rfd_ext *ext = (struct rfd_ext *) ext_ptr; | |
701 | ||
702 | *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd); | |
703 | ||
704 | #ifdef TEST | |
705 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
706 | abort(); | |
707 | #endif | |
708 | } | |
709 | ||
710 | /* Swap out a relative file descriptor. */ | |
711 | ||
712 | static void | |
713 | ecoff_swap_rfd_out (abfd, intern, ext_ptr) | |
714 | bfd *abfd; | |
aac6b32f | 715 | const RFDT *intern; |
fbffaf55 ILT |
716 | PTR ext_ptr; |
717 | { | |
718 | struct rfd_ext *ext = (struct rfd_ext *) ext_ptr; | |
719 | ||
720 | bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd); | |
721 | ||
722 | #ifdef TEST | |
723 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
724 | abort(); | |
725 | #endif | |
726 | } | |
727 | ||
728 | /* Swap in an optimization symbol. */ | |
729 | ||
730 | static void | |
731 | ecoff_swap_opt_in (abfd, ext_copy, intern) | |
732 | bfd *abfd; | |
733 | PTR ext_copy; | |
734 | OPTR *intern; | |
735 | { | |
736 | struct opt_ext ext[1]; | |
737 | ||
738 | *ext = *(struct opt_ext *) ext_copy; | |
739 | ||
1ec02944 | 740 | if (bfd_header_big_endian (abfd)) |
fbffaf55 ILT |
741 | { |
742 | intern->ot = ext->o_bits1[0]; | |
aac6b32f ILT |
743 | intern->value = (((unsigned int) ext->o_bits2[0] |
744 | << OPT_BITS2_VALUE_SH_LEFT_BIG) | |
745 | | ((unsigned int) ext->o_bits3[0] | |
746 | << OPT_BITS2_VALUE_SH_LEFT_BIG) | |
747 | | ((unsigned int) ext->o_bits4[0] | |
748 | << OPT_BITS2_VALUE_SH_LEFT_BIG)); | |
fbffaf55 ILT |
749 | } |
750 | else | |
751 | { | |
752 | intern->ot = ext->o_bits1[0]; | |
753 | intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE) | |
754 | | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE) | |
755 | | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)); | |
756 | } | |
757 | ||
1ec02944 | 758 | _bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd), |
97d5a149 | 759 | &ext->o_rndx, &intern->rndx); |
fbffaf55 ILT |
760 | |
761 | intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset); | |
762 | ||
763 | #ifdef TEST | |
764 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
765 | abort(); | |
766 | #endif | |
767 | } | |
768 | ||
769 | /* Swap out an optimization symbol. */ | |
770 | ||
771 | static void | |
772 | ecoff_swap_opt_out (abfd, intern_copy, ext_ptr) | |
773 | bfd *abfd; | |
aac6b32f | 774 | const OPTR *intern_copy; |
fbffaf55 ILT |
775 | PTR ext_ptr; |
776 | { | |
777 | struct opt_ext *ext = (struct opt_ext *) ext_ptr; | |
778 | OPTR intern[1]; | |
779 | ||
780 | *intern = *intern_copy; /* Make it reasonable to do in-place. */ | |
781 | ||
1ec02944 | 782 | if (bfd_header_big_endian (abfd)) |
fbffaf55 ILT |
783 | { |
784 | ext->o_bits1[0] = intern->ot; | |
785 | ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG; | |
786 | ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG; | |
787 | ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG; | |
788 | } | |
789 | else | |
790 | { | |
791 | ext->o_bits1[0] = intern->ot; | |
792 | ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE; | |
793 | ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE; | |
794 | ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE; | |
795 | } | |
796 | ||
1ec02944 | 797 | _bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd), |
97d5a149 | 798 | &intern->rndx, &ext->o_rndx); |
fbffaf55 ILT |
799 | |
800 | bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset); | |
801 | ||
802 | #ifdef TEST | |
803 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
804 | abort(); | |
805 | #endif | |
806 | } | |
807 | ||
808 | /* Swap in a dense number. */ | |
809 | ||
810 | static void | |
811 | ecoff_swap_dnr_in (abfd, ext_copy, intern) | |
812 | bfd *abfd; | |
813 | PTR ext_copy; | |
814 | DNR *intern; | |
815 | { | |
816 | struct dnr_ext ext[1]; | |
817 | ||
818 | *ext = *(struct dnr_ext *) ext_copy; | |
819 | ||
820 | intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd); | |
821 | intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index); | |
822 | ||
823 | #ifdef TEST | |
824 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
825 | abort(); | |
826 | #endif | |
827 | } | |
828 | ||
829 | /* Swap out a dense number. */ | |
830 | ||
831 | static void | |
832 | ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr) | |
833 | bfd *abfd; | |
aac6b32f | 834 | const DNR *intern_copy; |
fbffaf55 ILT |
835 | PTR ext_ptr; |
836 | { | |
837 | struct dnr_ext *ext = (struct dnr_ext *) ext_ptr; | |
838 | DNR intern[1]; | |
839 | ||
840 | *intern = *intern_copy; /* Make it reasonable to do in-place. */ | |
841 | ||
842 | bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd); | |
843 | bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index); | |
844 | ||
845 | #ifdef TEST | |
846 | if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) | |
847 | abort(); | |
848 | #endif | |
849 | } |