Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* Generic COFF swapping routines, for BFD. |
5f771d47 ILT |
2 | Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 |
3 | Free Software Foundation, Inc. | |
252b5132 RH |
4 | Written by Cygnus Support. |
5 | ||
6 | This file is part of BFD, the Binary File Descriptor library. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | /* This file contains routines used to swap COFF data. It is a header | |
23 | file because the details of swapping depend on the details of the | |
24 | structures used by each COFF implementation. This is included by | |
25 | coffcode.h, as well as by the ECOFF backend. | |
26 | ||
27 | Any file which uses this must first include "coff/internal.h" and | |
28 | "coff/CPU.h". The functions will then be correct for that CPU. */ | |
29 | ||
30 | #ifndef IMAGE_BASE | |
31 | #define IMAGE_BASE 0 | |
32 | #endif | |
33 | ||
34 | #define PUTWORD bfd_h_put_32 | |
35 | #define PUTHALF bfd_h_put_16 | |
36 | #define PUTBYTE bfd_h_put_8 | |
37 | ||
38 | #ifndef GET_FCN_LNNOPTR | |
39 | #define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr) | |
40 | #endif | |
41 | ||
42 | #ifndef GET_FCN_ENDNDX | |
43 | #define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx) | |
44 | #endif | |
45 | ||
46 | #ifndef PUT_FCN_LNNOPTR | |
47 | #define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr) | |
48 | #endif | |
49 | #ifndef PUT_FCN_ENDNDX | |
50 | #define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx) | |
51 | #endif | |
52 | #ifndef GET_LNSZ_LNNO | |
53 | #define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno) | |
54 | #endif | |
55 | #ifndef GET_LNSZ_SIZE | |
56 | #define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size) | |
57 | #endif | |
58 | #ifndef PUT_LNSZ_LNNO | |
59 | #define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno) | |
60 | #endif | |
61 | #ifndef PUT_LNSZ_SIZE | |
62 | #define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size) | |
63 | #endif | |
64 | #ifndef GET_SCN_SCNLEN | |
65 | #define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen) | |
66 | #endif | |
67 | #ifndef GET_SCN_NRELOC | |
68 | #define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc) | |
69 | #endif | |
70 | #ifndef GET_SCN_NLINNO | |
71 | #define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno) | |
72 | #endif | |
73 | #ifndef PUT_SCN_SCNLEN | |
74 | #define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen) | |
75 | #endif | |
76 | #ifndef PUT_SCN_NRELOC | |
77 | #define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc) | |
78 | #endif | |
79 | #ifndef PUT_SCN_NLINNO | |
80 | #define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno) | |
81 | #endif | |
82 | #ifndef GET_LINENO_LNNO | |
83 | #define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno)); | |
84 | #endif | |
85 | #ifndef PUT_LINENO_LNNO | |
86 | #define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno)); | |
87 | #endif | |
88 | ||
89 | /* The f_symptr field in the filehdr is sometimes 64 bits. */ | |
90 | #ifndef GET_FILEHDR_SYMPTR | |
91 | #define GET_FILEHDR_SYMPTR bfd_h_get_32 | |
92 | #endif | |
93 | #ifndef PUT_FILEHDR_SYMPTR | |
94 | #define PUT_FILEHDR_SYMPTR bfd_h_put_32 | |
95 | #endif | |
96 | ||
97 | /* Some fields in the aouthdr are sometimes 64 bits. */ | |
98 | #ifndef GET_AOUTHDR_TSIZE | |
99 | #define GET_AOUTHDR_TSIZE bfd_h_get_32 | |
100 | #endif | |
101 | #ifndef PUT_AOUTHDR_TSIZE | |
102 | #define PUT_AOUTHDR_TSIZE bfd_h_put_32 | |
103 | #endif | |
104 | #ifndef GET_AOUTHDR_DSIZE | |
105 | #define GET_AOUTHDR_DSIZE bfd_h_get_32 | |
106 | #endif | |
107 | #ifndef PUT_AOUTHDR_DSIZE | |
108 | #define PUT_AOUTHDR_DSIZE bfd_h_put_32 | |
109 | #endif | |
110 | #ifndef GET_AOUTHDR_BSIZE | |
111 | #define GET_AOUTHDR_BSIZE bfd_h_get_32 | |
112 | #endif | |
113 | #ifndef PUT_AOUTHDR_BSIZE | |
114 | #define PUT_AOUTHDR_BSIZE bfd_h_put_32 | |
115 | #endif | |
116 | #ifndef GET_AOUTHDR_ENTRY | |
117 | #define GET_AOUTHDR_ENTRY bfd_h_get_32 | |
118 | #endif | |
119 | #ifndef PUT_AOUTHDR_ENTRY | |
120 | #define PUT_AOUTHDR_ENTRY bfd_h_put_32 | |
121 | #endif | |
122 | #ifndef GET_AOUTHDR_TEXT_START | |
123 | #define GET_AOUTHDR_TEXT_START bfd_h_get_32 | |
124 | #endif | |
125 | #ifndef PUT_AOUTHDR_TEXT_START | |
126 | #define PUT_AOUTHDR_TEXT_START bfd_h_put_32 | |
127 | #endif | |
128 | #ifndef GET_AOUTHDR_DATA_START | |
129 | #define GET_AOUTHDR_DATA_START bfd_h_get_32 | |
130 | #endif | |
131 | #ifndef PUT_AOUTHDR_DATA_START | |
132 | #define PUT_AOUTHDR_DATA_START bfd_h_put_32 | |
133 | #endif | |
134 | ||
135 | /* Some fields in the scnhdr are sometimes 64 bits. */ | |
136 | #ifndef GET_SCNHDR_PADDR | |
137 | #define GET_SCNHDR_PADDR bfd_h_get_32 | |
138 | #endif | |
139 | #ifndef PUT_SCNHDR_PADDR | |
140 | #define PUT_SCNHDR_PADDR bfd_h_put_32 | |
141 | #endif | |
142 | #ifndef GET_SCNHDR_VADDR | |
143 | #define GET_SCNHDR_VADDR bfd_h_get_32 | |
144 | #endif | |
145 | #ifndef PUT_SCNHDR_VADDR | |
146 | #define PUT_SCNHDR_VADDR bfd_h_put_32 | |
147 | #endif | |
148 | #ifndef GET_SCNHDR_SIZE | |
149 | #define GET_SCNHDR_SIZE bfd_h_get_32 | |
150 | #endif | |
151 | #ifndef PUT_SCNHDR_SIZE | |
152 | #define PUT_SCNHDR_SIZE bfd_h_put_32 | |
153 | #endif | |
154 | #ifndef GET_SCNHDR_SCNPTR | |
155 | #define GET_SCNHDR_SCNPTR bfd_h_get_32 | |
156 | #endif | |
157 | #ifndef PUT_SCNHDR_SCNPTR | |
158 | #define PUT_SCNHDR_SCNPTR bfd_h_put_32 | |
159 | #endif | |
160 | #ifndef GET_SCNHDR_RELPTR | |
161 | #define GET_SCNHDR_RELPTR bfd_h_get_32 | |
162 | #endif | |
163 | #ifndef PUT_SCNHDR_RELPTR | |
164 | #define PUT_SCNHDR_RELPTR bfd_h_put_32 | |
165 | #endif | |
166 | #ifndef GET_SCNHDR_LNNOPTR | |
167 | #define GET_SCNHDR_LNNOPTR bfd_h_get_32 | |
168 | #endif | |
169 | #ifndef PUT_SCNHDR_LNNOPTR | |
170 | #define PUT_SCNHDR_LNNOPTR bfd_h_put_32 | |
171 | #endif | |
172 | #ifndef GET_SCNHDR_NRELOC | |
173 | #define GET_SCNHDR_NRELOC bfd_h_get_16 | |
174 | #endif | |
175 | #ifndef PUT_SCNHDR_NRELOC | |
176 | #define PUT_SCNHDR_NRELOC bfd_h_put_16 | |
177 | #endif | |
178 | #ifndef GET_SCNHDR_NLNNO | |
179 | #define GET_SCNHDR_NLNNO bfd_h_get_16 | |
180 | #endif | |
181 | #ifndef PUT_SCNHDR_NLNNO | |
182 | #define PUT_SCNHDR_NLNNO bfd_h_put_16 | |
183 | #endif | |
184 | #ifndef GET_SCNHDR_FLAGS | |
185 | #define GET_SCNHDR_FLAGS bfd_h_get_32 | |
186 | #endif | |
187 | #ifndef PUT_SCNHDR_FLAGS | |
188 | #define PUT_SCNHDR_FLAGS bfd_h_put_32 | |
189 | #endif | |
190 | ||
191 | ||
192 | static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR)); | |
193 | static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR)); | |
194 | static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR)); | |
195 | static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR)); | |
196 | static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR)); | |
197 | static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR)); | |
198 | #ifndef NO_COFF_RELOCS | |
199 | static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR)); | |
200 | static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR)); | |
201 | #endif /* NO_COFF_RELOCS */ | |
202 | #ifndef NO_COFF_SYMBOLS | |
203 | static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR)); | |
204 | static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR)); | |
205 | static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
206 | static unsigned int coff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
207 | #endif /* NO_COFF_SYMBOLS */ | |
208 | #ifndef NO_COFF_LINENOS | |
209 | static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR)); | |
210 | static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR)); | |
211 | #endif /* NO_COFF_LINENOS */ | |
212 | ||
213 | #ifndef NO_COFF_RELOCS | |
214 | ||
215 | static void | |
216 | coff_swap_reloc_in (abfd, src, dst) | |
217 | bfd *abfd; | |
218 | PTR src; | |
219 | PTR dst; | |
220 | { | |
221 | RELOC *reloc_src = (RELOC *) src; | |
222 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | |
223 | ||
224 | reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr); | |
225 | reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx); | |
226 | ||
227 | #ifdef RS6000COFF_C | |
228 | reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type); | |
229 | reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size); | |
230 | #else | |
231 | reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type); | |
232 | #endif | |
233 | ||
234 | #ifdef SWAP_IN_RELOC_OFFSET | |
235 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd, | |
236 | (bfd_byte *) reloc_src->r_offset); | |
237 | #endif | |
238 | } | |
239 | ||
240 | static unsigned int | |
241 | coff_swap_reloc_out (abfd, src, dst) | |
242 | bfd *abfd; | |
243 | PTR src; | |
244 | PTR dst; | |
245 | { | |
246 | struct internal_reloc *reloc_src = (struct internal_reloc *)src; | |
247 | struct external_reloc *reloc_dst = (struct external_reloc *)dst; | |
248 | bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr); | |
249 | bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx); | |
250 | ||
251 | #ifdef RS6000COFF_C | |
252 | bfd_h_put_8 (abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type); | |
253 | bfd_h_put_8 (abfd, reloc_src->r_size, (bfd_byte *) reloc_dst->r_size); | |
254 | #else | |
255 | bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *) | |
256 | reloc_dst->r_type); | |
257 | #endif | |
258 | ||
259 | #ifdef SWAP_OUT_RELOC_OFFSET | |
260 | SWAP_OUT_RELOC_OFFSET(abfd, | |
261 | reloc_src->r_offset, | |
262 | (bfd_byte *) reloc_dst->r_offset); | |
263 | #endif | |
264 | #ifdef SWAP_OUT_RELOC_EXTRA | |
265 | SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst); | |
266 | #endif | |
267 | ||
268 | return RELSZ; | |
269 | } | |
270 | ||
271 | #endif /* NO_COFF_RELOCS */ | |
272 | ||
273 | static void | |
274 | coff_swap_filehdr_in (abfd, src, dst) | |
275 | bfd *abfd; | |
276 | PTR src; | |
277 | PTR dst; | |
278 | { | |
279 | FILHDR *filehdr_src = (FILHDR *) src; | |
280 | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | |
281 | #ifdef COFF_ADJUST_FILEHDR_IN_PRE | |
282 | COFF_ADJUST_FILEHDR_IN_PRE (abfd, src, dst); | |
283 | #endif | |
284 | filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic); | |
285 | filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns); | |
286 | filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat); | |
287 | filehdr_dst->f_symptr = | |
288 | GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr); | |
289 | filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms); | |
290 | filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr); | |
291 | filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags); | |
292 | #ifdef TIC80_TARGET_ID | |
293 | filehdr_dst->f_target_id = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_target_id); | |
294 | #endif | |
295 | ||
296 | #ifdef COFF_ADJUST_FILEHDR_IN_POST | |
297 | COFF_ADJUST_FILEHDR_IN_POST (abfd, src, dst); | |
298 | #endif | |
299 | } | |
300 | ||
301 | static unsigned int | |
302 | coff_swap_filehdr_out (abfd, in, out) | |
303 | bfd *abfd; | |
304 | PTR in; | |
305 | PTR out; | |
306 | { | |
307 | struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in; | |
308 | FILHDR *filehdr_out = (FILHDR *)out; | |
309 | ||
310 | #ifdef COFF_ADJUST_FILEHDR_OUT_PRE | |
311 | COFF_ADJUST_FILEHDR_OUT_PRE (abfd, in, out); | |
312 | #endif | |
313 | bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic); | |
314 | bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns); | |
315 | bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat); | |
316 | PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr, | |
317 | (bfd_byte *) filehdr_out->f_symptr); | |
318 | bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms); | |
319 | bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr); | |
320 | bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags); | |
321 | #ifdef TIC80_TARGET_ID | |
322 | bfd_h_put_16(abfd, filehdr_in->f_target_id, (bfd_byte *) filehdr_out->f_target_id); | |
323 | #endif | |
324 | ||
325 | #ifdef COFF_ADJUST_FILEHDR_OUT_POST | |
326 | COFF_ADJUST_FILEHDR_OUT_POST (abfd, in, out); | |
327 | #endif | |
328 | return FILHSZ; | |
329 | } | |
330 | ||
331 | ||
332 | #ifndef NO_COFF_SYMBOLS | |
333 | ||
334 | static void | |
335 | coff_swap_sym_in (abfd, ext1, in1) | |
336 | bfd *abfd; | |
337 | PTR ext1; | |
338 | PTR in1; | |
339 | { | |
340 | SYMENT *ext = (SYMENT *)ext1; | |
341 | struct internal_syment *in = (struct internal_syment *)in1; | |
342 | ||
343 | if( ext->e.e_name[0] == 0) { | |
344 | in->_n._n_n._n_zeroes = 0; | |
345 | in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset); | |
346 | } | |
347 | else { | |
348 | #if SYMNMLEN != E_SYMNMLEN | |
349 | -> Error, we need to cope with truncating or extending SYMNMLEN!; | |
350 | #else | |
351 | memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN); | |
352 | #endif | |
353 | } | |
354 | in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value); | |
355 | in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum); | |
356 | if (sizeof(ext->e_type) == 2){ | |
357 | in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type); | |
358 | } | |
359 | else { | |
360 | in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type); | |
361 | } | |
362 | in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass); | |
363 | in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux); | |
364 | } | |
365 | ||
366 | static unsigned int | |
367 | coff_swap_sym_out (abfd, inp, extp) | |
368 | bfd *abfd; | |
369 | PTR inp; | |
370 | PTR extp; | |
371 | { | |
372 | struct internal_syment *in = (struct internal_syment *)inp; | |
373 | SYMENT *ext =(SYMENT *)extp; | |
374 | if(in->_n._n_name[0] == 0) { | |
375 | bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes); | |
376 | bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset); | |
377 | } | |
378 | else { | |
379 | #if SYMNMLEN != E_SYMNMLEN | |
380 | -> Error, we need to cope with truncating or extending SYMNMLEN!; | |
381 | #else | |
382 | memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN); | |
383 | #endif | |
384 | } | |
385 | bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value); | |
386 | bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum); | |
387 | if (sizeof(ext->e_type) == 2) | |
388 | { | |
389 | bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type); | |
390 | } | |
391 | else | |
392 | { | |
393 | bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type); | |
394 | } | |
395 | bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass); | |
396 | bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux); | |
397 | return SYMESZ; | |
398 | } | |
399 | ||
400 | static void | |
401 | coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) | |
402 | bfd *abfd; | |
403 | PTR ext1; | |
404 | int type; | |
405 | int class; | |
406 | int indx; | |
407 | int numaux; | |
408 | PTR in1; | |
409 | { | |
410 | AUXENT *ext = (AUXENT *)ext1; | |
411 | union internal_auxent *in = (union internal_auxent *)in1; | |
412 | ||
413 | #ifdef COFF_ADJUST_AUX_IN_PRE | |
414 | COFF_ADJUST_AUX_IN_PRE (abfd, ext1, type, class, indx, numaux, in1); | |
415 | #endif | |
416 | switch (class) { | |
417 | case C_FILE: | |
418 | if (ext->x_file.x_fname[0] == 0) { | |
419 | in->x_file.x_n.x_zeroes = 0; | |
420 | in->x_file.x_n.x_offset = | |
421 | bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset); | |
422 | } else { | |
423 | #if FILNMLEN != E_FILNMLEN | |
424 | -> Error, we need to cope with truncating or extending FILNMLEN!; | |
425 | #else | |
ec0ef80e DD |
426 | if (numaux > 1) |
427 | { | |
428 | if (indx == 0) | |
429 | memcpy (in->x_file.x_fname, ext->x_file.x_fname, | |
430 | numaux * sizeof (AUXENT)); | |
431 | } | |
432 | else | |
433 | { | |
434 | memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN); | |
435 | } | |
252b5132 RH |
436 | #endif |
437 | } | |
438 | goto end; | |
439 | ||
440 | /* RS/6000 "csect" auxents */ | |
441 | #ifdef RS6000COFF_C | |
442 | case C_EXT: | |
443 | case C_HIDEXT: | |
444 | if (indx + 1 == numaux) | |
445 | { | |
446 | in->x_csect.x_scnlen.l = bfd_h_get_32 (abfd, ext->x_csect.x_scnlen); | |
447 | in->x_csect.x_parmhash = bfd_h_get_32 (abfd, | |
448 | ext->x_csect.x_parmhash); | |
449 | in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash); | |
450 | /* We don't have to hack bitfields in x_smtyp because it's | |
451 | defined by shifts-and-ands, which are equivalent on all | |
452 | byte orders. */ | |
453 | in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp); | |
454 | in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas); | |
455 | in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab); | |
456 | in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab); | |
457 | goto end; | |
458 | } | |
459 | break; | |
460 | #endif | |
461 | ||
462 | case C_STAT: | |
463 | #ifdef C_LEAFSTAT | |
464 | case C_LEAFSTAT: | |
465 | #endif | |
466 | case C_HIDDEN: | |
467 | if (type == T_NULL) { | |
468 | in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext); | |
469 | in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext); | |
470 | in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext); | |
471 | ||
472 | /* PE defines some extra fields; we zero them out for | |
473 | safety. */ | |
474 | in->x_scn.x_checksum = 0; | |
475 | in->x_scn.x_associated = 0; | |
476 | in->x_scn.x_comdat = 0; | |
477 | ||
478 | goto end; | |
479 | } | |
480 | break; | |
481 | } | |
482 | ||
483 | in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx); | |
484 | #ifndef NO_TVNDX | |
485 | in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx); | |
486 | #endif | |
487 | ||
488 | if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class)) | |
489 | { | |
490 | in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext); | |
491 | in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext); | |
492 | } | |
493 | else | |
494 | { | |
495 | #if DIMNUM != E_DIMNUM | |
496 | #error we need to cope with truncating or extending DIMNUM | |
497 | #endif | |
498 | in->x_sym.x_fcnary.x_ary.x_dimen[0] = | |
499 | bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]); | |
500 | in->x_sym.x_fcnary.x_ary.x_dimen[1] = | |
501 | bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]); | |
502 | in->x_sym.x_fcnary.x_ary.x_dimen[2] = | |
503 | bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]); | |
504 | in->x_sym.x_fcnary.x_ary.x_dimen[3] = | |
505 | bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]); | |
506 | } | |
507 | ||
508 | if (ISFCN(type)) { | |
509 | in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize); | |
510 | } | |
511 | else { | |
512 | in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext); | |
513 | in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext); | |
514 | } | |
515 | ||
516 | end: ; | |
517 | /* the semicolon is because MSVC doesn't like labels at | |
518 | end of block. */ | |
519 | ||
520 | #ifdef COFF_ADJUST_AUX_IN_POST | |
521 | COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1); | |
522 | #endif | |
523 | } | |
524 | ||
525 | static unsigned int | |
526 | coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) | |
527 | bfd *abfd; | |
528 | PTR inp; | |
529 | int type; | |
530 | int class; | |
5f771d47 ILT |
531 | int indx ATTRIBUTE_UNUSED; |
532 | int numaux ATTRIBUTE_UNUSED; | |
252b5132 RH |
533 | PTR extp; |
534 | { | |
535 | union internal_auxent *in = (union internal_auxent *)inp; | |
536 | AUXENT *ext = (AUXENT *)extp; | |
537 | ||
538 | #ifdef COFF_ADJUST_AUX_OUT_PRE | |
539 | COFF_ADJUST_AUX_OUT_PRE (abfd, inp, type, class, indx, numaux, extp); | |
540 | #endif | |
541 | memset((PTR)ext, 0, AUXESZ); | |
542 | switch (class) { | |
543 | case C_FILE: | |
544 | if (in->x_file.x_fname[0] == 0) { | |
545 | PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes); | |
546 | PUTWORD(abfd, | |
547 | in->x_file.x_n.x_offset, | |
548 | (bfd_byte *) ext->x_file.x_n.x_offset); | |
549 | } | |
550 | else { | |
551 | #if FILNMLEN != E_FILNMLEN | |
552 | -> Error, we need to cope with truncating or extending FILNMLEN!; | |
553 | #else | |
554 | memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN); | |
555 | #endif | |
556 | } | |
557 | goto end; | |
558 | ||
559 | #ifdef RS6000COFF_C | |
560 | /* RS/6000 "csect" auxents */ | |
561 | case C_EXT: | |
562 | case C_HIDEXT: | |
563 | if (indx + 1 == numaux) | |
564 | { | |
565 | PUTWORD (abfd, in->x_csect.x_scnlen.l, ext->x_csect.x_scnlen); | |
566 | PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash); | |
567 | PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash); | |
568 | /* We don't have to hack bitfields in x_smtyp because it's | |
569 | defined by shifts-and-ands, which are equivalent on all | |
570 | byte orders. */ | |
571 | PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp); | |
572 | PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas); | |
573 | PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab); | |
574 | PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab); | |
575 | goto end; | |
576 | } | |
577 | break; | |
578 | #endif | |
579 | ||
580 | case C_STAT: | |
581 | #ifdef C_LEAFSTAT | |
582 | case C_LEAFSTAT: | |
583 | #endif | |
584 | case C_HIDDEN: | |
585 | if (type == T_NULL) { | |
586 | PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext); | |
587 | PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext); | |
588 | PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext); | |
589 | goto end; | |
590 | } | |
591 | break; | |
592 | } | |
593 | ||
594 | PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx); | |
595 | #ifndef NO_TVNDX | |
596 | bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx); | |
597 | #endif | |
598 | ||
599 | if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class)) | |
600 | { | |
601 | PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext); | |
602 | PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext); | |
603 | } | |
604 | else | |
605 | { | |
606 | #if DIMNUM != E_DIMNUM | |
607 | #error we need to cope with truncating or extending DIMNUM | |
608 | #endif | |
609 | bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], | |
610 | (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]); | |
611 | bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], | |
612 | (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]); | |
613 | bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], | |
614 | (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]); | |
615 | bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], | |
616 | (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]); | |
617 | } | |
618 | ||
619 | if (ISFCN (type)) | |
620 | PUTWORD (abfd, in->x_sym.x_misc.x_fsize, | |
621 | (bfd_byte *) ext->x_sym.x_misc.x_fsize); | |
622 | else | |
623 | { | |
624 | PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext); | |
625 | PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext); | |
626 | } | |
627 | ||
628 | end: | |
629 | #ifdef COFF_ADJUST_AUX_OUT_POST | |
630 | COFF_ADJUST_AUX_OUT_POST (abfd, inp, type, class, indx, numaux, extp); | |
631 | #endif | |
632 | return AUXESZ; | |
633 | } | |
634 | ||
635 | #endif /* NO_COFF_SYMBOLS */ | |
636 | ||
637 | #ifndef NO_COFF_LINENOS | |
638 | ||
639 | static void | |
640 | coff_swap_lineno_in (abfd, ext1, in1) | |
641 | bfd *abfd; | |
642 | PTR ext1; | |
643 | PTR in1; | |
644 | { | |
645 | LINENO *ext = (LINENO *)ext1; | |
646 | struct internal_lineno *in = (struct internal_lineno *)in1; | |
647 | ||
648 | in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx); | |
649 | in->l_lnno = GET_LINENO_LNNO(abfd, ext); | |
650 | } | |
651 | ||
652 | static unsigned int | |
653 | coff_swap_lineno_out (abfd, inp, outp) | |
654 | bfd *abfd; | |
655 | PTR inp; | |
656 | PTR outp; | |
657 | { | |
658 | struct internal_lineno *in = (struct internal_lineno *)inp; | |
659 | struct external_lineno *ext = (struct external_lineno *)outp; | |
660 | PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *) | |
661 | ext->l_addr.l_symndx); | |
662 | ||
663 | PUT_LINENO_LNNO (abfd, in->l_lnno, ext); | |
664 | return LINESZ; | |
665 | } | |
666 | ||
667 | #endif /* NO_COFF_LINENOS */ | |
668 | ||
669 | static void | |
670 | coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1) | |
671 | bfd *abfd; | |
672 | PTR aouthdr_ext1; | |
673 | PTR aouthdr_int1; | |
674 | { | |
675 | AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1; | |
676 | struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1; | |
677 | ||
678 | aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic); | |
679 | aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp); | |
680 | aouthdr_int->tsize = | |
681 | GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize); | |
682 | aouthdr_int->dsize = | |
683 | GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize); | |
684 | aouthdr_int->bsize = | |
685 | GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize); | |
686 | aouthdr_int->entry = | |
687 | GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry); | |
688 | aouthdr_int->text_start = | |
689 | GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start); | |
690 | aouthdr_int->data_start = | |
691 | GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start); | |
692 | ||
693 | #ifdef I960 | |
694 | aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries); | |
695 | #endif | |
696 | ||
697 | #ifdef APOLLO_M68 | |
698 | bfd_h_put_32(abfd, aouthdr_int->o_inlib, (bfd_byte *) aouthdr_ext->o_inlib); | |
699 | bfd_h_put_32(abfd, aouthdr_int->o_sri, (bfd_byte *) aouthdr_ext->o_sri); | |
700 | bfd_h_put_32(abfd, aouthdr_int->vid[0], (bfd_byte *) aouthdr_ext->vid); | |
701 | bfd_h_put_32(abfd, aouthdr_int->vid[1], (bfd_byte *) aouthdr_ext->vid + 4); | |
702 | #endif | |
703 | ||
704 | ||
705 | #ifdef RS6000COFF_C | |
706 | aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc); | |
707 | aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry); | |
708 | aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext); | |
709 | aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata); | |
710 | aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc); | |
711 | aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader); | |
712 | aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss); | |
713 | aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext); | |
714 | aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata); | |
715 | aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype); | |
716 | aouthdr_int->o_cputype = bfd_h_get_16(abfd, aouthdr_ext->o_cputype); | |
717 | aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack); | |
718 | aouthdr_int->o_maxdata = bfd_h_get_32(abfd, aouthdr_ext->o_maxdata); | |
719 | #endif | |
720 | ||
721 | #ifdef MIPSECOFF | |
722 | aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start); | |
723 | aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value); | |
724 | aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask); | |
725 | aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]); | |
726 | aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]); | |
727 | aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]); | |
728 | aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]); | |
729 | #endif | |
730 | ||
731 | #ifdef ALPHAECOFF | |
732 | aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start); | |
733 | aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value); | |
734 | aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask); | |
735 | aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask); | |
736 | #endif | |
737 | } | |
738 | ||
739 | static unsigned int | |
740 | coff_swap_aouthdr_out (abfd, in, out) | |
741 | bfd *abfd; | |
742 | PTR in; | |
743 | PTR out; | |
744 | { | |
745 | struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in; | |
746 | AOUTHDR *aouthdr_out = (AOUTHDR *)out; | |
747 | ||
748 | bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic); | |
749 | bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp); | |
750 | PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize); | |
751 | PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize); | |
752 | PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize); | |
753 | PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry); | |
754 | PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start, | |
755 | (bfd_byte *) aouthdr_out->text_start); | |
756 | PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start, | |
757 | (bfd_byte *) aouthdr_out->data_start); | |
758 | ||
759 | #ifdef I960 | |
760 | bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries); | |
761 | #endif | |
762 | ||
763 | #ifdef RS6000COFF_C | |
764 | bfd_h_put_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc); | |
765 | bfd_h_put_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry); | |
766 | bfd_h_put_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext); | |
767 | bfd_h_put_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata); | |
768 | bfd_h_put_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc); | |
769 | bfd_h_put_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader); | |
770 | bfd_h_put_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss); | |
771 | bfd_h_put_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext); | |
772 | bfd_h_put_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata); | |
773 | bfd_h_put_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype); | |
774 | bfd_h_put_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype); | |
775 | bfd_h_put_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack); | |
776 | bfd_h_put_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata); | |
777 | memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2); | |
778 | #endif | |
779 | ||
780 | #ifdef MIPSECOFF | |
781 | bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start); | |
782 | bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value); | |
783 | bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask); | |
784 | bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]); | |
785 | bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]); | |
786 | bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]); | |
787 | bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]); | |
788 | #endif | |
789 | ||
790 | #ifdef ALPHAECOFF | |
791 | /* FIXME: What does bldrev mean? */ | |
792 | bfd_h_put_16(abfd, (bfd_vma) 2, (bfd_byte *) aouthdr_out->bldrev); | |
793 | bfd_h_put_16(abfd, (bfd_vma) 0, (bfd_byte *) aouthdr_out->padding); | |
794 | bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start); | |
795 | bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value); | |
796 | bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask); | |
797 | bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask); | |
798 | #endif | |
799 | ||
800 | return AOUTSZ; | |
801 | } | |
802 | ||
803 | static void | |
804 | coff_swap_scnhdr_in (abfd, ext, in) | |
805 | bfd *abfd; | |
806 | PTR ext; | |
807 | PTR in; | |
808 | { | |
809 | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | |
810 | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | |
811 | ||
812 | #ifdef COFF_ADJUST_SCNHDR_IN_PRE | |
813 | COFF_ADJUST_SCNHDR_IN_PRE (abfd, ext, in); | |
814 | #endif | |
815 | memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name)); | |
816 | scnhdr_int->s_vaddr = | |
817 | GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr); | |
818 | scnhdr_int->s_paddr = | |
819 | GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr); | |
820 | scnhdr_int->s_size = | |
821 | GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size); | |
822 | ||
823 | scnhdr_int->s_scnptr = | |
824 | GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr); | |
825 | scnhdr_int->s_relptr = | |
826 | GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr); | |
827 | scnhdr_int->s_lnnoptr = | |
828 | GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr); | |
829 | scnhdr_int->s_flags = | |
830 | GET_SCNHDR_FLAGS (abfd, (bfd_byte *) scnhdr_ext->s_flags); | |
831 | scnhdr_int->s_nreloc = | |
832 | GET_SCNHDR_NRELOC (abfd, (bfd_byte *) scnhdr_ext->s_nreloc); | |
833 | scnhdr_int->s_nlnno = | |
834 | GET_SCNHDR_NLNNO (abfd, (bfd_byte *) scnhdr_ext->s_nlnno); | |
835 | #ifdef I960 | |
836 | scnhdr_int->s_align = | |
837 | GET_SCNHDR_ALIGN (abfd, (bfd_byte *) scnhdr_ext->s_align); | |
838 | #endif | |
839 | #ifdef COFF_ADJUST_SCNHDR_IN_POST | |
840 | COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in); | |
841 | #endif | |
842 | } | |
843 | ||
844 | static unsigned int | |
845 | coff_swap_scnhdr_out (abfd, in, out) | |
846 | bfd *abfd; | |
847 | PTR in; | |
848 | PTR out; | |
849 | { | |
850 | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in; | |
851 | SCNHDR *scnhdr_ext = (SCNHDR *)out; | |
852 | unsigned int ret = SCNHSZ; | |
853 | ||
854 | #ifdef COFF_ADJUST_SCNHDR_OUT_PRE | |
855 | COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out); | |
856 | #endif | |
857 | memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name)); | |
858 | ||
859 | PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr, | |
860 | (bfd_byte *) scnhdr_ext->s_vaddr); | |
861 | ||
862 | ||
863 | PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr, | |
864 | (bfd_byte *) scnhdr_ext->s_paddr); | |
865 | PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size, | |
866 | (bfd_byte *) scnhdr_ext->s_size); | |
867 | ||
868 | PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr, | |
869 | (bfd_byte *) scnhdr_ext->s_scnptr); | |
870 | PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr, | |
871 | (bfd_byte *) scnhdr_ext->s_relptr); | |
872 | PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr, | |
873 | (bfd_byte *) scnhdr_ext->s_lnnoptr); | |
874 | PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags, | |
875 | (bfd_byte *) scnhdr_ext->s_flags); | |
876 | #if defined(M88) | |
877 | PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno); | |
878 | PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc); | |
879 | #else | |
880 | if (scnhdr_int->s_nlnno <= 0xffff) | |
881 | PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno); | |
882 | else | |
883 | { | |
884 | char buf[sizeof (scnhdr_int->s_name) + 1]; | |
885 | ||
886 | memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name)); | |
887 | buf[sizeof (scnhdr_int->s_name)] = '\0'; | |
888 | (*_bfd_error_handler) | |
889 | (_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"), | |
890 | bfd_get_filename (abfd), | |
891 | buf, scnhdr_int->s_nlnno); | |
892 | PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno); | |
893 | } | |
894 | if (scnhdr_int->s_nreloc <= 0xffff) | |
895 | PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc); | |
896 | else | |
897 | { | |
898 | char buf[sizeof (scnhdr_int->s_name) + 1]; | |
899 | ||
900 | memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name)); | |
901 | buf[sizeof (scnhdr_int->s_name)] = '\0'; | |
902 | (*_bfd_error_handler) (_("%s: %s: reloc overflow: 0x%lx > 0xffff"), | |
903 | bfd_get_filename (abfd), | |
904 | buf, scnhdr_int->s_nreloc); | |
905 | bfd_set_error (bfd_error_file_truncated); | |
906 | PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc); | |
907 | ret = 0; | |
908 | } | |
909 | #endif | |
910 | ||
911 | #ifdef I960 | |
912 | PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align); | |
913 | #endif | |
914 | #ifdef COFF_ADJUST_SCNHDR_OUT_POST | |
915 | COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out); | |
916 | #endif | |
917 | return ret; | |
918 | } |