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