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