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