]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* BFD back-end for IBM RS/6000 "XCOFF" files. |
7898deda NC |
2 | Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
3 | 2000, 2001 | |
5f771d47 | 4 | Free Software Foundation, Inc. |
252b5132 RH |
5 | FIXME: Can someone provide a transliteration of this name into ASCII? |
6 | Using the following chars caused a compiler warning on HIUX (so I replaced | |
7 | them with octal escapes), and isn't useful without an understanding of what | |
8 | character set it is. | |
c5930ee6 | 9 | Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365, |
252b5132 RH |
10 | and John Gilmore. |
11 | Archive support from Damon A. Permezel. | |
12 | Contributed by IBM Corporation and Cygnus Support. | |
13 | ||
14 | This file is part of BFD, the Binary File Descriptor library. | |
15 | ||
16 | This program is free software; you can redistribute it and/or modify | |
17 | it under the terms of the GNU General Public License as published by | |
18 | the Free Software Foundation; either version 2 of the License, or | |
19 | (at your option) any later version. | |
20 | ||
21 | This program is distributed in the hope that it will be useful, | |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 | GNU General Public License for more details. | |
25 | ||
26 | You should have received a copy of the GNU General Public License | |
27 | along with this program; if not, write to the Free Software | |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
29 | ||
252b5132 RH |
30 | #include "bfd.h" |
31 | #include "sysdep.h" | |
beb1bf64 | 32 | #include "bfdlink.h" |
252b5132 RH |
33 | #include "libbfd.h" |
34 | #include "coff/internal.h" | |
beb1bf64 | 35 | #include "coff/xcoff.h" |
252b5132 RH |
36 | #include "coff/rs6000.h" |
37 | #include "libcoff.h" | |
beb1bf64 TR |
38 | #include "libxcoff.h" |
39 | ||
beb1bf64 TR |
40 | extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *)); |
41 | extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *)); | |
42 | extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *)); | |
43 | extern reloc_howto_type *_bfd_xcoff_reloc_type_lookup | |
44 | PARAMS ((bfd *, bfd_reloc_code_real_type)); | |
45 | extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *)); | |
46 | extern const bfd_target *_bfd_xcoff_archive_p PARAMS ((bfd *)); | |
47 | extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *)); | |
48 | extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *)); | |
49 | extern int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *)); | |
50 | extern boolean _bfd_xcoff_write_armap | |
51 | PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int)); | |
52 | extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *)); | |
53 | extern int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean)); | |
54 | extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR)); | |
55 | extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR)); | |
56 | extern void _bfd_xcoff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
57 | extern unsigned int _bfd_xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
58 | ||
59 | /* Forward declare _bfd_xcoff_rtype2howto for coffcode.h macro */ | |
60 | void _bfd_xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *)); | |
61 | ||
62 | /* coffcode.h needs these to be defined */ | |
63 | #define RS6000COFF_C 1 | |
64 | ||
65 | #define SELECT_RELOC(internal, howto) \ | |
66 | { \ | |
67 | internal.r_type = howto->type; \ | |
68 | internal.r_size = \ | |
69 | ((howto->complain_on_overflow == complain_overflow_signed \ | |
70 | ? 0x80 \ | |
71 | : 0) \ | |
72 | | (howto->bitsize - 1)); \ | |
73 | } | |
74 | ||
75 | #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3) | |
76 | #define COFF_LONG_FILENAMES | |
77 | #define NO_COFF_SYMBOLS | |
78 | #define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst) | |
79 | #define coff_mkobject _bfd_xcoff_mkobject | |
80 | #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data | |
81 | #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name | |
82 | #define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup | |
b55039f4 L |
83 | #ifdef AIX_CORE |
84 | extern const bfd_target * rs6000coff_core_p (); | |
85 | extern boolean rs6000coff_core_file_matches_executable_p (); | |
86 | extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd)); | |
87 | extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd)); | |
beb1bf64 | 88 | #define CORE_FILE_P rs6000coff_core_p |
b55039f4 L |
89 | #define coff_core_file_failing_command \ |
90 | rs6000coff_core_file_failing_command | |
91 | #define coff_core_file_failing_signal \ | |
92 | rs6000coff_core_file_failing_signal | |
93 | #define coff_core_file_matches_executable_p \ | |
94 | rs6000coff_core_file_matches_executable_p | |
95 | #else | |
96 | #define CORE_FILE_P _bfd_dummy_target | |
97 | #define coff_core_file_failing_command \ | |
98 | _bfd_nocore_core_file_failing_command | |
99 | #define coff_core_file_failing_signal \ | |
100 | _bfd_nocore_core_file_failing_signal | |
101 | #define coff_core_file_matches_executable_p \ | |
102 | _bfd_nocore_core_file_matches_executable_p | |
103 | #endif | |
beb1bf64 TR |
104 | #define coff_SWAP_sym_in _bfd_xcoff_swap_sym_in |
105 | #define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out | |
106 | #define coff_SWAP_aux_in _bfd_xcoff_swap_aux_in | |
107 | #define coff_SWAP_aux_out _bfd_xcoff_swap_aux_out | |
108 | ||
109 | #include "coffcode.h" | |
14958a43 | 110 | |
252b5132 RH |
111 | /* The main body of code is in coffcode.h. */ |
112 | ||
252b5132 | 113 | static const char *normalize_filename PARAMS ((bfd *)); |
14958a43 | 114 | |
252b5132 RH |
115 | /* We use our own tdata type. Its first field is the COFF tdata type, |
116 | so the COFF routines are compatible. */ | |
117 | ||
7f6d05e8 CP |
118 | boolean |
119 | _bfd_xcoff_mkobject (abfd) | |
252b5132 RH |
120 | bfd *abfd; |
121 | { | |
122 | coff_data_type *coff; | |
123 | ||
124 | abfd->tdata.xcoff_obj_data = | |
125 | ((struct xcoff_tdata *) | |
126 | bfd_zalloc (abfd, sizeof (struct xcoff_tdata))); | |
127 | if (abfd->tdata.xcoff_obj_data == NULL) | |
128 | return false; | |
129 | coff = coff_data (abfd); | |
130 | coff->symbols = (coff_symbol_type *) NULL; | |
131 | coff->conversion_table = (unsigned int *) NULL; | |
132 | coff->raw_syments = (struct coff_ptr_struct *) NULL; | |
133 | coff->relocbase = 0; | |
134 | ||
135 | xcoff_data (abfd)->modtype = ('1' << 8) | 'L'; | |
136 | ||
137 | /* We set cputype to -1 to indicate that it has not been | |
138 | initialized. */ | |
139 | xcoff_data (abfd)->cputype = -1; | |
140 | ||
141 | xcoff_data (abfd)->csects = NULL; | |
142 | xcoff_data (abfd)->debug_indices = NULL; | |
143 | ||
beb1bf64 TR |
144 | /* text section alignment is different than the default */ |
145 | /* xcoff_data (abfd)->text_align_power = 5; */ | |
146 | ||
252b5132 RH |
147 | return true; |
148 | } | |
149 | ||
150 | /* Copy XCOFF data from one BFD to another. */ | |
151 | ||
7f6d05e8 CP |
152 | boolean |
153 | _bfd_xcoff_copy_private_bfd_data (ibfd, obfd) | |
252b5132 RH |
154 | bfd *ibfd; |
155 | bfd *obfd; | |
156 | { | |
157 | struct xcoff_tdata *ix, *ox; | |
158 | asection *sec; | |
159 | ||
160 | if (ibfd->xvec != obfd->xvec) | |
161 | return true; | |
162 | ix = xcoff_data (ibfd); | |
163 | ox = xcoff_data (obfd); | |
164 | ox->full_aouthdr = ix->full_aouthdr; | |
165 | ox->toc = ix->toc; | |
166 | if (ix->sntoc == 0) | |
167 | ox->sntoc = 0; | |
168 | else | |
169 | { | |
170 | sec = coff_section_from_bfd_index (ibfd, ix->sntoc); | |
171 | if (sec == NULL) | |
172 | ox->sntoc = 0; | |
173 | else | |
174 | ox->sntoc = sec->output_section->target_index; | |
175 | } | |
176 | if (ix->snentry == 0) | |
177 | ox->snentry = 0; | |
178 | else | |
179 | { | |
180 | sec = coff_section_from_bfd_index (ibfd, ix->snentry); | |
181 | if (sec == NULL) | |
182 | ox->snentry = 0; | |
183 | else | |
184 | ox->snentry = sec->output_section->target_index; | |
185 | } | |
186 | ox->text_align_power = ix->text_align_power; | |
187 | ox->data_align_power = ix->data_align_power; | |
188 | ox->modtype = ix->modtype; | |
189 | ox->cputype = ix->cputype; | |
190 | ox->maxdata = ix->maxdata; | |
191 | ox->maxstack = ix->maxstack; | |
192 | return true; | |
193 | } | |
194 | ||
195 | /* I don't think XCOFF really has a notion of local labels based on | |
196 | name. This will mean that ld -X doesn't actually strip anything. | |
197 | The AIX native linker does not have a -X option, and it ignores the | |
198 | -x option. */ | |
199 | ||
7f6d05e8 CP |
200 | boolean |
201 | _bfd_xcoff_is_local_label_name (abfd, name) | |
5f771d47 ILT |
202 | bfd *abfd ATTRIBUTE_UNUSED; |
203 | const char *name ATTRIBUTE_UNUSED; | |
252b5132 RH |
204 | { |
205 | return false; | |
206 | } | |
7f6d05e8 | 207 | \f |
beb1bf64 TR |
208 | |
209 | ||
14958a43 CP |
210 | void |
211 | _bfd_xcoff_swap_sym_in (abfd, ext1, in1) | |
7f6d05e8 CP |
212 | bfd *abfd; |
213 | PTR ext1; | |
214 | PTR in1; | |
215 | { | |
216 | SYMENT *ext = (SYMENT *)ext1; | |
217 | struct internal_syment *in = (struct internal_syment *)in1; | |
218 | ||
beb1bf64 TR |
219 | if(ext->e.e_name[0] != 0) { |
220 | memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN); | |
221 | } else { | |
222 | in->_n._n_n._n_zeroes = 0; | |
223 | in->_n._n_n._n_offset = | |
224 | bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset); | |
225 | } | |
7f6d05e8 | 226 | |
beb1bf64 | 227 | in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value); |
7f6d05e8 CP |
228 | in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum); |
229 | in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type); | |
230 | in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass); | |
231 | in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux); | |
232 | } | |
233 | ||
14958a43 CP |
234 | unsigned int |
235 | _bfd_xcoff_swap_sym_out (abfd, inp, extp) | |
7f6d05e8 CP |
236 | bfd *abfd; |
237 | PTR inp; | |
238 | PTR extp; | |
239 | { | |
240 | struct internal_syment *in = (struct internal_syment *)inp; | |
241 | SYMENT *ext =(SYMENT *)extp; | |
242 | ||
beb1bf64 TR |
243 | if(in->_n._n_name[0] != 0) { |
244 | memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN); | |
245 | } else { | |
246 | bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes); | |
247 | bfd_h_put_32(abfd, in->_n._n_n._n_offset, | |
248 | (bfd_byte *) ext->e.e.e_offset); | |
249 | } | |
7f6d05e8 CP |
250 | |
251 | bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value); | |
252 | bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum); | |
253 | bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type); | |
254 | bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass); | |
255 | bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux); | |
256 | return bfd_coff_symesz (abfd); | |
257 | } | |
258 | ||
259 | #define PUTWORD bfd_h_put_32 | |
260 | #define PUTHALF bfd_h_put_16 | |
261 | #define PUTBYTE bfd_h_put_8 | |
262 | #define GETWORD bfd_h_get_32 | |
263 | #define GETHALF bfd_h_get_16 | |
264 | #define GETBYTE bfd_h_get_8 | |
265 | ||
14958a43 CP |
266 | void |
267 | _bfd_xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) | |
7f6d05e8 CP |
268 | bfd *abfd; |
269 | PTR ext1; | |
270 | int type; | |
271 | int class; | |
272 | int indx; | |
273 | int numaux; | |
274 | PTR in1; | |
275 | { | |
276 | AUXENT *ext = (AUXENT *)ext1; | |
277 | union internal_auxent *in = (union internal_auxent *)in1; | |
278 | ||
279 | switch (class) { | |
280 | case C_FILE: | |
281 | if (ext->x_file.x_fname[0] == 0) { | |
282 | in->x_file.x_n.x_zeroes = 0; | |
beb1bf64 | 283 | in->x_file.x_n.x_offset = |
7f6d05e8 CP |
284 | bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset); |
285 | } else { | |
286 | if (numaux > 1) | |
287 | { | |
288 | if (indx == 0) | |
289 | memcpy (in->x_file.x_fname, ext->x_file.x_fname, | |
290 | numaux * sizeof (AUXENT)); | |
291 | } | |
292 | else | |
293 | { | |
294 | memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN); | |
295 | } | |
296 | } | |
297 | goto end; | |
298 | ||
299 | /* RS/6000 "csect" auxents */ | |
300 | case C_EXT: | |
301 | case C_HIDEXT: | |
302 | if (indx + 1 == numaux) | |
303 | { | |
beb1bf64 | 304 | in->x_csect.x_scnlen.l = |
7f6d05e8 CP |
305 | bfd_h_get_32 (abfd, ext->x_csect.x_scnlen); |
306 | in->x_csect.x_parmhash = bfd_h_get_32 (abfd, | |
307 | ext->x_csect.x_parmhash); | |
308 | in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash); | |
309 | /* We don't have to hack bitfields in x_smtyp because it's | |
310 | defined by shifts-and-ands, which are equivalent on all | |
311 | byte orders. */ | |
312 | in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp); | |
313 | in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas); | |
314 | in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab); | |
315 | in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab); | |
316 | goto end; | |
317 | } | |
318 | break; | |
319 | ||
320 | case C_STAT: | |
321 | case C_LEAFSTAT: | |
322 | case C_HIDDEN: | |
323 | if (type == T_NULL) { | |
beb1bf64 | 324 | in->x_scn.x_scnlen = bfd_h_get_32(abfd, |
7f6d05e8 | 325 | (bfd_byte *) ext->x_scn.x_scnlen); |
beb1bf64 | 326 | in->x_scn.x_nreloc = bfd_h_get_16(abfd, |
7f6d05e8 | 327 | (bfd_byte *) ext->x_scn.x_nreloc); |
beb1bf64 | 328 | in->x_scn.x_nlinno = bfd_h_get_16(abfd, |
7f6d05e8 CP |
329 | (bfd_byte *) ext->x_scn.x_nlinno); |
330 | /* PE defines some extra fields; we zero them out for | |
331 | safety. */ | |
332 | in->x_scn.x_checksum = 0; | |
333 | in->x_scn.x_associated = 0; | |
334 | in->x_scn.x_comdat = 0; | |
335 | ||
336 | goto end; | |
337 | } | |
338 | break; | |
339 | } | |
340 | ||
341 | in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx); | |
342 | in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx); | |
343 | ||
344 | if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class)) | |
345 | { | |
346 | in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_32(abfd, (bfd_byte *) | |
347 | ext->x_sym.x_fcnary.x_fcn.x_lnnoptr); | |
348 | in->x_sym.x_fcnary.x_fcn.x_endndx.l = bfd_h_get_32(abfd, (bfd_byte *) | |
349 | ext->x_sym.x_fcnary.x_fcn.x_endndx); | |
350 | } | |
351 | else | |
352 | { | |
353 | in->x_sym.x_fcnary.x_ary.x_dimen[0] = | |
354 | bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]); | |
355 | in->x_sym.x_fcnary.x_ary.x_dimen[1] = | |
356 | bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]); | |
357 | in->x_sym.x_fcnary.x_ary.x_dimen[2] = | |
358 | bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]); | |
359 | in->x_sym.x_fcnary.x_ary.x_dimen[3] = | |
360 | bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]); | |
361 | } | |
362 | if (ISFCN(type)) { | |
363 | in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize); | |
364 | } | |
365 | else { | |
366 | in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_16(abfd, (bfd_byte *) | |
367 | ext->x_sym.x_misc.x_lnsz.x_lnno); | |
368 | in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_16(abfd, (bfd_byte *) | |
369 | ext->x_sym.x_misc.x_lnsz.x_size); | |
370 | } | |
371 | ||
372 | end: ; | |
373 | /* the semicolon is because MSVC doesn't like labels at | |
beb1bf64 | 374 | end of block. */ |
7f6d05e8 CP |
375 | |
376 | } | |
377 | ||
beb1bf64 TR |
378 | |
379 | ||
14958a43 CP |
380 | unsigned int |
381 | _bfd_xcoff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) | |
7f6d05e8 CP |
382 | bfd *abfd; |
383 | PTR inp; | |
384 | int type; | |
385 | int class; | |
386 | int indx ATTRIBUTE_UNUSED; | |
387 | int numaux ATTRIBUTE_UNUSED; | |
388 | PTR extp; | |
389 | { | |
390 | union internal_auxent *in = (union internal_auxent *)inp; | |
391 | AUXENT *ext = (AUXENT *)extp; | |
392 | ||
393 | memset((PTR)ext, 0, bfd_coff_auxesz (abfd)); | |
394 | switch (class) | |
395 | { | |
396 | case C_FILE: | |
397 | if (in->x_file.x_fname[0] == 0) | |
398 | { | |
399 | PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes); | |
400 | PUTWORD(abfd, | |
401 | in->x_file.x_n.x_offset, | |
402 | (bfd_byte *) ext->x_file.x_n.x_offset); | |
403 | } | |
404 | else | |
405 | { | |
406 | memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN); | |
407 | } | |
408 | goto end; | |
409 | ||
410 | /* RS/6000 "csect" auxents */ | |
411 | case C_EXT: | |
412 | case C_HIDEXT: | |
413 | if (indx + 1 == numaux) | |
414 | { | |
415 | PUTWORD (abfd, in->x_csect.x_scnlen.l,ext->x_csect.x_scnlen); | |
416 | PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash); | |
417 | PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash); | |
418 | /* We don't have to hack bitfields in x_smtyp because it's | |
419 | defined by shifts-and-ands, which are equivalent on all | |
420 | byte orders. */ | |
421 | PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp); | |
422 | PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas); | |
423 | PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab); | |
424 | PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab); | |
425 | goto end; | |
426 | } | |
427 | break; | |
428 | ||
429 | case C_STAT: | |
430 | case C_LEAFSTAT: | |
431 | case C_HIDDEN: | |
432 | if (type == T_NULL) { | |
433 | bfd_h_put_32(abfd, in->x_scn.x_scnlen, (bfd_byte *) ext->x_scn.x_scnlen); | |
434 | bfd_h_put_16(abfd, in->x_scn.x_nreloc, (bfd_byte *) ext->x_scn.x_nreloc); | |
435 | bfd_h_put_16(abfd, in->x_scn.x_nlinno, (bfd_byte *) ext->x_scn.x_nlinno); | |
436 | goto end; | |
437 | } | |
438 | break; | |
439 | } | |
440 | ||
441 | PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx); | |
492055e6 | 442 | bfd_h_put_16 (abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx); |
7f6d05e8 CP |
443 | |
444 | if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class)) | |
445 | { | |
beb1bf64 | 446 | bfd_h_put_32(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, |
7f6d05e8 | 447 | (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr); |
beb1bf64 | 448 | PUTWORD(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, |
7f6d05e8 CP |
449 | (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx); |
450 | } | |
451 | else | |
452 | { | |
453 | bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], | |
454 | (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]); | |
455 | bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], | |
456 | (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]); | |
457 | bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], | |
458 | (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]); | |
459 | bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], | |
460 | (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]); | |
461 | } | |
462 | ||
463 | if (ISFCN (type)) | |
464 | PUTWORD (abfd, in->x_sym.x_misc.x_fsize, | |
465 | (bfd_byte *) ext->x_sym.x_misc.x_fsize); | |
466 | else | |
467 | { | |
beb1bf64 | 468 | bfd_h_put_16(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, |
7f6d05e8 | 469 | (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno); |
beb1bf64 | 470 | bfd_h_put_16(abfd, in->x_sym.x_misc.x_lnsz.x_size, |
7f6d05e8 CP |
471 | (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_size); |
472 | } | |
473 | ||
474 | end: | |
475 | return bfd_coff_auxesz (abfd); | |
476 | } | |
beb1bf64 TR |
477 | |
478 | ||
252b5132 RH |
479 | \f |
480 | /* The XCOFF reloc table. Actually, XCOFF relocations specify the | |
481 | bitsize and whether they are signed or not, along with a | |
482 | conventional type. This table is for the types, which are used for | |
483 | different algorithms for putting in the reloc. Many of these | |
484 | relocs need special_function entries, which I have not written. */ | |
485 | ||
7f6d05e8 CP |
486 | |
487 | reloc_howto_type xcoff_howto_table[] = | |
252b5132 RH |
488 | { |
489 | /* Standard 32 bit relocation. */ | |
c5930ee6 KH |
490 | HOWTO (0, /* type */ |
491 | 0, /* rightshift */ | |
492 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
493 | 32, /* bitsize */ | |
494 | false, /* pc_relative */ | |
495 | 0, /* bitpos */ | |
252b5132 | 496 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
497 | 0, /* special_function */ |
498 | "R_POS", /* name */ | |
499 | true, /* partial_inplace */ | |
500 | 0xffffffff, /* src_mask */ | |
501 | 0xffffffff, /* dst_mask */ | |
252b5132 RH |
502 | false), /* pcrel_offset */ |
503 | ||
504 | /* 32 bit relocation, but store negative value. */ | |
c5930ee6 KH |
505 | HOWTO (1, /* type */ |
506 | 0, /* rightshift */ | |
507 | -2, /* size (0 = byte, 1 = short, 2 = long) */ | |
508 | 32, /* bitsize */ | |
509 | false, /* pc_relative */ | |
510 | 0, /* bitpos */ | |
252b5132 | 511 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
512 | 0, /* special_function */ |
513 | "R_NEG", /* name */ | |
514 | true, /* partial_inplace */ | |
515 | 0xffffffff, /* src_mask */ | |
516 | 0xffffffff, /* dst_mask */ | |
252b5132 RH |
517 | false), /* pcrel_offset */ |
518 | ||
519 | /* 32 bit PC relative relocation. */ | |
c5930ee6 KH |
520 | HOWTO (2, /* type */ |
521 | 0, /* rightshift */ | |
522 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
523 | 32, /* bitsize */ | |
524 | true, /* pc_relative */ | |
525 | 0, /* bitpos */ | |
252b5132 | 526 | complain_overflow_signed, /* complain_on_overflow */ |
c5930ee6 KH |
527 | 0, /* special_function */ |
528 | "R_REL", /* name */ | |
529 | true, /* partial_inplace */ | |
530 | 0xffffffff, /* src_mask */ | |
531 | 0xffffffff, /* dst_mask */ | |
252b5132 | 532 | false), /* pcrel_offset */ |
c5930ee6 | 533 | |
252b5132 | 534 | /* 16 bit TOC relative relocation. */ |
c5930ee6 KH |
535 | HOWTO (3, /* type */ |
536 | 0, /* rightshift */ | |
537 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
538 | 16, /* bitsize */ | |
539 | false, /* pc_relative */ | |
540 | 0, /* bitpos */ | |
252b5132 | 541 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
542 | 0, /* special_function */ |
543 | "R_TOC", /* name */ | |
544 | true, /* partial_inplace */ | |
545 | 0xffff, /* src_mask */ | |
546 | 0xffff, /* dst_mask */ | |
252b5132 | 547 | false), /* pcrel_offset */ |
c5930ee6 | 548 | |
252b5132 | 549 | /* I don't really know what this is. */ |
c5930ee6 KH |
550 | HOWTO (4, /* type */ |
551 | 1, /* rightshift */ | |
552 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
553 | 32, /* bitsize */ | |
554 | false, /* pc_relative */ | |
555 | 0, /* bitpos */ | |
252b5132 | 556 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
557 | 0, /* special_function */ |
558 | "R_RTB", /* name */ | |
559 | true, /* partial_inplace */ | |
560 | 0xffffffff, /* src_mask */ | |
561 | 0xffffffff, /* dst_mask */ | |
252b5132 | 562 | false), /* pcrel_offset */ |
c5930ee6 | 563 | |
252b5132 | 564 | /* External TOC relative symbol. */ |
c5930ee6 KH |
565 | HOWTO (5, /* type */ |
566 | 0, /* rightshift */ | |
567 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
568 | 16, /* bitsize */ | |
569 | false, /* pc_relative */ | |
570 | 0, /* bitpos */ | |
252b5132 | 571 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
572 | 0, /* special_function */ |
573 | "R_GL", /* name */ | |
574 | true, /* partial_inplace */ | |
575 | 0xffff, /* src_mask */ | |
576 | 0xffff, /* dst_mask */ | |
252b5132 | 577 | false), /* pcrel_offset */ |
c5930ee6 | 578 | |
252b5132 | 579 | /* Local TOC relative symbol. */ |
c5930ee6 KH |
580 | HOWTO (6, /* type */ |
581 | 0, /* rightshift */ | |
582 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
583 | 16, /* bitsize */ | |
584 | false, /* pc_relative */ | |
585 | 0, /* bitpos */ | |
252b5132 | 586 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
587 | 0, /* special_function */ |
588 | "R_TCL", /* name */ | |
589 | true, /* partial_inplace */ | |
590 | 0xffff, /* src_mask */ | |
591 | 0xffff, /* dst_mask */ | |
252b5132 | 592 | false), /* pcrel_offset */ |
c5930ee6 | 593 | |
5f771d47 | 594 | EMPTY_HOWTO (7), |
c5930ee6 | 595 | |
252b5132 | 596 | /* Non modifiable absolute branch. */ |
c5930ee6 KH |
597 | HOWTO (8, /* type */ |
598 | 0, /* rightshift */ | |
599 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
600 | 26, /* bitsize */ | |
601 | false, /* pc_relative */ | |
602 | 0, /* bitpos */ | |
252b5132 | 603 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
604 | 0, /* special_function */ |
605 | "R_BA", /* name */ | |
606 | true, /* partial_inplace */ | |
607 | 0x3fffffc, /* src_mask */ | |
608 | 0x3fffffc, /* dst_mask */ | |
252b5132 | 609 | false), /* pcrel_offset */ |
c5930ee6 | 610 | |
5f771d47 | 611 | EMPTY_HOWTO (9), |
252b5132 RH |
612 | |
613 | /* Non modifiable relative branch. */ | |
c5930ee6 KH |
614 | HOWTO (0xa, /* type */ |
615 | 0, /* rightshift */ | |
616 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
617 | 26, /* bitsize */ | |
618 | true, /* pc_relative */ | |
619 | 0, /* bitpos */ | |
252b5132 | 620 | complain_overflow_signed, /* complain_on_overflow */ |
c5930ee6 KH |
621 | 0, /* special_function */ |
622 | "R_BR", /* name */ | |
623 | true, /* partial_inplace */ | |
624 | 0x3fffffc, /* src_mask */ | |
625 | 0x3fffffc, /* dst_mask */ | |
252b5132 | 626 | false), /* pcrel_offset */ |
c5930ee6 | 627 | |
5f771d47 | 628 | EMPTY_HOWTO (0xb), |
252b5132 RH |
629 | |
630 | /* Indirect load. */ | |
c5930ee6 KH |
631 | HOWTO (0xc, /* type */ |
632 | 0, /* rightshift */ | |
633 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
634 | 16, /* bitsize */ | |
635 | false, /* pc_relative */ | |
636 | 0, /* bitpos */ | |
252b5132 | 637 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
638 | 0, /* special_function */ |
639 | "R_RL", /* name */ | |
640 | true, /* partial_inplace */ | |
641 | 0xffff, /* src_mask */ | |
642 | 0xffff, /* dst_mask */ | |
252b5132 | 643 | false), /* pcrel_offset */ |
c5930ee6 | 644 | |
252b5132 | 645 | /* Load address. */ |
c5930ee6 KH |
646 | HOWTO (0xd, /* type */ |
647 | 0, /* rightshift */ | |
648 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
649 | 16, /* bitsize */ | |
650 | false, /* pc_relative */ | |
651 | 0, /* bitpos */ | |
252b5132 | 652 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
653 | 0, /* special_function */ |
654 | "R_RLA", /* name */ | |
655 | true, /* partial_inplace */ | |
656 | 0xffff, /* src_mask */ | |
657 | 0xffff, /* dst_mask */ | |
252b5132 | 658 | false), /* pcrel_offset */ |
c5930ee6 | 659 | |
5f771d47 | 660 | EMPTY_HOWTO (0xe), |
c5930ee6 | 661 | |
252b5132 | 662 | /* Non-relocating reference. */ |
c5930ee6 KH |
663 | HOWTO (0xf, /* type */ |
664 | 0, /* rightshift */ | |
665 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
666 | 32, /* bitsize */ | |
667 | false, /* pc_relative */ | |
668 | 0, /* bitpos */ | |
252b5132 | 669 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
670 | 0, /* special_function */ |
671 | "R_REF", /* name */ | |
672 | false, /* partial_inplace */ | |
673 | 0, /* src_mask */ | |
674 | 0, /* dst_mask */ | |
252b5132 | 675 | false), /* pcrel_offset */ |
c5930ee6 | 676 | |
5f771d47 ILT |
677 | EMPTY_HOWTO (0x10), |
678 | EMPTY_HOWTO (0x11), | |
c5930ee6 | 679 | |
252b5132 | 680 | /* TOC relative indirect load. */ |
c5930ee6 KH |
681 | HOWTO (0x12, /* type */ |
682 | 0, /* rightshift */ | |
683 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
684 | 16, /* bitsize */ | |
685 | false, /* pc_relative */ | |
686 | 0, /* bitpos */ | |
252b5132 | 687 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
688 | 0, /* special_function */ |
689 | "R_TRL", /* name */ | |
690 | true, /* partial_inplace */ | |
691 | 0xffff, /* src_mask */ | |
692 | 0xffff, /* dst_mask */ | |
252b5132 | 693 | false), /* pcrel_offset */ |
c5930ee6 | 694 | |
252b5132 | 695 | /* TOC relative load address. */ |
c5930ee6 KH |
696 | HOWTO (0x13, /* type */ |
697 | 0, /* rightshift */ | |
698 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
699 | 16, /* bitsize */ | |
700 | false, /* pc_relative */ | |
701 | 0, /* bitpos */ | |
252b5132 | 702 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
703 | 0, /* special_function */ |
704 | "R_TRLA", /* name */ | |
705 | true, /* partial_inplace */ | |
706 | 0xffff, /* src_mask */ | |
707 | 0xffff, /* dst_mask */ | |
252b5132 | 708 | false), /* pcrel_offset */ |
c5930ee6 | 709 | |
252b5132 | 710 | /* Modifiable relative branch. */ |
c5930ee6 KH |
711 | HOWTO (0x14, /* type */ |
712 | 1, /* rightshift */ | |
713 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
714 | 32, /* bitsize */ | |
715 | false, /* pc_relative */ | |
716 | 0, /* bitpos */ | |
252b5132 | 717 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
718 | 0, /* special_function */ |
719 | "R_RRTBI", /* name */ | |
720 | true, /* partial_inplace */ | |
721 | 0xffffffff, /* src_mask */ | |
722 | 0xffffffff, /* dst_mask */ | |
252b5132 | 723 | false), /* pcrel_offset */ |
c5930ee6 | 724 | |
252b5132 | 725 | /* Modifiable absolute branch. */ |
c5930ee6 KH |
726 | HOWTO (0x15, /* type */ |
727 | 1, /* rightshift */ | |
728 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
729 | 32, /* bitsize */ | |
730 | false, /* pc_relative */ | |
731 | 0, /* bitpos */ | |
252b5132 | 732 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
733 | 0, /* special_function */ |
734 | "R_RRTBA", /* name */ | |
735 | true, /* partial_inplace */ | |
736 | 0xffffffff, /* src_mask */ | |
737 | 0xffffffff, /* dst_mask */ | |
252b5132 | 738 | false), /* pcrel_offset */ |
c5930ee6 | 739 | |
252b5132 | 740 | /* Modifiable call absolute indirect. */ |
c5930ee6 KH |
741 | HOWTO (0x16, /* type */ |
742 | 0, /* rightshift */ | |
743 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
744 | 16, /* bitsize */ | |
745 | false, /* pc_relative */ | |
746 | 0, /* bitpos */ | |
252b5132 | 747 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
748 | 0, /* special_function */ |
749 | "R_CAI", /* name */ | |
750 | true, /* partial_inplace */ | |
751 | 0xffff, /* src_mask */ | |
752 | 0xffff, /* dst_mask */ | |
252b5132 | 753 | false), /* pcrel_offset */ |
c5930ee6 | 754 | |
252b5132 | 755 | /* Modifiable call relative. */ |
c5930ee6 KH |
756 | HOWTO (0x17, /* type */ |
757 | 0, /* rightshift */ | |
758 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
759 | 16, /* bitsize */ | |
760 | false, /* pc_relative */ | |
761 | 0, /* bitpos */ | |
252b5132 | 762 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
763 | 0, /* special_function */ |
764 | "R_CREL", /* name */ | |
765 | true, /* partial_inplace */ | |
766 | 0xffff, /* src_mask */ | |
767 | 0xffff, /* dst_mask */ | |
252b5132 | 768 | false), /* pcrel_offset */ |
c5930ee6 | 769 | |
252b5132 | 770 | /* Modifiable branch absolute. */ |
c5930ee6 KH |
771 | HOWTO (0x18, /* type */ |
772 | 0, /* rightshift */ | |
773 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
774 | 26, /* bitsize */ | |
775 | false, /* pc_relative */ | |
776 | 0, /* bitpos */ | |
252b5132 | 777 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
778 | 0, /* special_function */ |
779 | "R_RBA", /* name */ | |
780 | true, /* partial_inplace */ | |
781 | 0xffff, /* src_mask */ | |
782 | 0xffff, /* dst_mask */ | |
252b5132 | 783 | false), /* pcrel_offset */ |
c5930ee6 | 784 | |
252b5132 | 785 | /* Modifiable branch absolute. */ |
c5930ee6 KH |
786 | HOWTO (0x19, /* type */ |
787 | 0, /* rightshift */ | |
788 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
789 | 32, /* bitsize */ | |
790 | false, /* pc_relative */ | |
791 | 0, /* bitpos */ | |
252b5132 | 792 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
793 | 0, /* special_function */ |
794 | "R_RBAC", /* name */ | |
795 | true, /* partial_inplace */ | |
796 | 0xffff, /* src_mask */ | |
797 | 0xffff, /* dst_mask */ | |
252b5132 | 798 | false), /* pcrel_offset */ |
c5930ee6 | 799 | |
252b5132 | 800 | /* Modifiable branch relative. */ |
c5930ee6 KH |
801 | HOWTO (0x1a, /* type */ |
802 | 0, /* rightshift */ | |
803 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
804 | 26, /* bitsize */ | |
805 | false, /* pc_relative */ | |
806 | 0, /* bitpos */ | |
252b5132 | 807 | complain_overflow_signed, /* complain_on_overflow */ |
c5930ee6 KH |
808 | 0, /* special_function */ |
809 | "R_RBR", /* name */ | |
810 | true, /* partial_inplace */ | |
811 | 0xffff, /* src_mask */ | |
812 | 0xffff, /* dst_mask */ | |
252b5132 | 813 | false), /* pcrel_offset */ |
c5930ee6 | 814 | |
252b5132 | 815 | /* Modifiable branch absolute. */ |
c5930ee6 KH |
816 | HOWTO (0x1b, /* type */ |
817 | 0, /* rightshift */ | |
818 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
819 | 16, /* bitsize */ | |
820 | false, /* pc_relative */ | |
821 | 0, /* bitpos */ | |
252b5132 | 822 | complain_overflow_bitfield, /* complain_on_overflow */ |
c5930ee6 KH |
823 | 0, /* special_function */ |
824 | "R_RBRC", /* name */ | |
825 | true, /* partial_inplace */ | |
826 | 0xffff, /* src_mask */ | |
827 | 0xffff, /* dst_mask */ | |
7f6d05e8 | 828 | false), /* pcrel_offset */ |
beb1bf64 | 829 | |
7f6d05e8 CP |
830 | HOWTO (0, /* type */ |
831 | 0, /* rightshift */ | |
832 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
833 | 64, /* bitsize */ | |
834 | false, /* pc_relative */ | |
835 | 0, /* bitpos */ | |
836 | complain_overflow_bitfield, /* complain_on_overflow */ | |
837 | 0, /* special_function */ | |
838 | "R_POS", /* name */ | |
839 | true, /* partial_inplace */ | |
840 | MINUS_ONE, /* src_mask */ | |
841 | MINUS_ONE, /* dst_mask */ | |
252b5132 | 842 | false) /* pcrel_offset */ |
7f6d05e8 | 843 | |
252b5132 RH |
844 | }; |
845 | ||
7f6d05e8 CP |
846 | void |
847 | _bfd_xcoff_rtype2howto (relent, internal) | |
252b5132 RH |
848 | arelent *relent; |
849 | struct internal_reloc *internal; | |
850 | { | |
851 | relent->howto = xcoff_howto_table + internal->r_type; | |
852 | ||
beb1bf64 TR |
853 | /* Check for relocs we don't know of. */ |
854 | if (internal->r_type | |
855 | >= sizeof (xcoff_howto_table) / sizeof (xcoff_howto_table[0])) | |
856 | abort (); | |
857 | if (internal->r_type != relent->howto->type) | |
858 | abort (); | |
5ea1af0d | 859 | |
252b5132 RH |
860 | /* The r_size field of an XCOFF reloc encodes the bitsize of the |
861 | relocation, as well as indicating whether it is signed or not. | |
862 | Doublecheck that the relocation information gathered from the | |
c5930ee6 KH |
863 | type matches this information. The bitsize is not significant |
864 | for R_REF relocs. */ | |
865 | if (relent->howto->dst_mask != 0 | |
beb1bf64 | 866 | && (relent->howto->bitsize |
c5930ee6 | 867 | != ((unsigned int) internal->r_size & 0x3f) + 1)) |
252b5132 RH |
868 | abort (); |
869 | #if 0 | |
870 | if ((internal->r_size & 0x80) != 0 | |
871 | ? (relent->howto->complain_on_overflow != complain_overflow_signed) | |
872 | : (relent->howto->complain_on_overflow != complain_overflow_bitfield)) | |
873 | abort (); | |
874 | #endif | |
875 | } | |
876 | ||
7f6d05e8 CP |
877 | reloc_howto_type * |
878 | _bfd_xcoff_reloc_type_lookup (abfd, code) | |
5f771d47 | 879 | bfd *abfd ATTRIBUTE_UNUSED; |
252b5132 RH |
880 | bfd_reloc_code_real_type code; |
881 | { | |
882 | switch (code) | |
883 | { | |
884 | case BFD_RELOC_PPC_B26: | |
885 | return &xcoff_howto_table[0xa]; | |
886 | case BFD_RELOC_PPC_BA26: | |
887 | return &xcoff_howto_table[8]; | |
888 | case BFD_RELOC_PPC_TOC16: | |
889 | return &xcoff_howto_table[3]; | |
890 | case BFD_RELOC_32: | |
891 | case BFD_RELOC_CTOR: | |
892 | return &xcoff_howto_table[0]; | |
7f6d05e8 CP |
893 | case BFD_RELOC_64: |
894 | return &xcoff_howto_table[0x1c]; | |
252b5132 RH |
895 | default: |
896 | return NULL; | |
897 | } | |
898 | } | |
beb1bf64 | 899 | |
252b5132 RH |
900 | \f |
901 | /* XCOFF archive support. The original version of this code was by | |
902 | Damon A. Permezel. It was enhanced to permit cross support, and | |
903 | writing archive files, by Ian Lance Taylor, Cygnus Support. | |
904 | ||
905 | XCOFF uses its own archive format. Everything is hooked together | |
906 | with file offset links, so it is possible to rapidly update an | |
907 | archive in place. Of course, we don't do that. An XCOFF archive | |
908 | has a real file header, not just an ARMAG string. The structure of | |
909 | the file header and of each archive header appear below. | |
910 | ||
911 | An XCOFF archive also has a member table, which is a list of | |
912 | elements in the archive (you can get that by looking through the | |
913 | linked list, but you have to read a lot more of the file). The | |
914 | member table has a normal archive header with an empty name. It is | |
915 | normally (and perhaps must be) the second to last entry in the | |
916 | archive. The member table data is almost printable ASCII. It | |
917 | starts with a 12 character decimal string which is the number of | |
918 | entries in the table. For each entry it has a 12 character decimal | |
919 | string which is the offset in the archive of that member. These | |
920 | entries are followed by a series of null terminated strings which | |
921 | are the member names for each entry. | |
922 | ||
923 | Finally, an XCOFF archive has a global symbol table, which is what | |
924 | we call the armap. The global symbol table has a normal archive | |
925 | header with an empty name. It is normally (and perhaps must be) | |
926 | the last entry in the archive. The contents start with a four byte | |
927 | binary number which is the number of entries. This is followed by | |
928 | a that many four byte binary numbers; each is the file offset of an | |
929 | entry in the archive. These numbers are followed by a series of | |
5ea1af0d GK |
930 | null terminated strings, which are symbol names. |
931 | ||
932 | AIX 4.3 introduced a new archive format which can handle larger | |
933 | files and also 32- and 64-bit objects in the same archive. The | |
934 | things said above remain true except that there is now more than | |
935 | one global symbol table. The one is used to index 32-bit objects, | |
936 | the other for 64-bit objects. | |
937 | ||
938 | The new archives (recognizable by the new ARMAG string) has larger | |
939 | field lengths so that we cannot really share any code. Also we have | |
940 | to take care that we are not generating the new form of archives | |
941 | on AIX 4.2 or earlier systems. */ | |
252b5132 | 942 | |
5ea1af0d GK |
943 | /* XCOFF archives use this as a magic string. Note that both strings |
944 | have the same length. */ | |
252b5132 | 945 | |
252b5132 | 946 | |
252b5132 | 947 | |
252b5132 RH |
948 | /* Read in the armap of an XCOFF archive. */ |
949 | ||
7f6d05e8 CP |
950 | boolean |
951 | _bfd_xcoff_slurp_armap (abfd) | |
252b5132 RH |
952 | bfd *abfd; |
953 | { | |
954 | file_ptr off; | |
252b5132 RH |
955 | size_t namlen; |
956 | bfd_size_type sz; | |
957 | bfd_byte *contents, *cend; | |
31612ca6 | 958 | bfd_vma c, i; |
252b5132 RH |
959 | carsym *arsym; |
960 | bfd_byte *p; | |
961 | ||
962 | if (xcoff_ardata (abfd) == NULL) | |
963 | { | |
964 | bfd_has_map (abfd) = false; | |
965 | return true; | |
966 | } | |
967 | ||
5ea1af0d | 968 | if (! xcoff_big_format_p (abfd)) |
252b5132 | 969 | { |
5ea1af0d GK |
970 | /* This is for the old format. */ |
971 | struct xcoff_ar_hdr hdr; | |
972 | ||
973 | off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10); | |
974 | if (off == 0) | |
975 | { | |
976 | bfd_has_map (abfd) = false; | |
977 | return true; | |
978 | } | |
979 | ||
980 | if (bfd_seek (abfd, off, SEEK_SET) != 0) | |
981 | return false; | |
982 | ||
983 | /* The symbol table starts with a normal archive header. */ | |
984 | if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR) | |
985 | return false; | |
986 | ||
987 | /* Skip the name (normally empty). */ | |
988 | namlen = strtol (hdr.namlen, (char **) NULL, 10); | |
989 | if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0) | |
990 | return false; | |
991 | ||
992 | sz = strtol (hdr.size, (char **) NULL, 10); | |
31612ca6 GK |
993 | |
994 | /* Read in the entire symbol table. */ | |
995 | contents = (bfd_byte *) bfd_alloc (abfd, sz); | |
996 | if (contents == NULL) | |
997 | return false; | |
998 | if (bfd_read ((PTR) contents, 1, sz, abfd) != sz) | |
999 | return false; | |
1000 | ||
1001 | /* The symbol table starts with a four byte count. */ | |
1002 | c = bfd_h_get_32 (abfd, contents); | |
beb1bf64 | 1003 | |
31612ca6 GK |
1004 | if (c * 4 >= sz) |
1005 | { | |
1006 | bfd_set_error (bfd_error_bad_value); | |
1007 | return false; | |
1008 | } | |
beb1bf64 | 1009 | |
31612ca6 GK |
1010 | bfd_ardata (abfd)->symdefs = ((carsym *) |
1011 | bfd_alloc (abfd, c * sizeof (carsym))); | |
1012 | if (bfd_ardata (abfd)->symdefs == NULL) | |
1013 | return false; | |
beb1bf64 | 1014 | |
31612ca6 GK |
1015 | /* After the count comes a list of four byte file offsets. */ |
1016 | for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4; | |
1017 | i < c; | |
1018 | ++i, ++arsym, p += 4) | |
1019 | arsym->file_offset = bfd_h_get_32 (abfd, p); | |
252b5132 | 1020 | } |
5ea1af0d GK |
1021 | else |
1022 | { | |
1023 | /* This is for the new format. */ | |
1024 | struct xcoff_ar_hdr_big hdr; | |
252b5132 | 1025 | |
5ea1af0d GK |
1026 | off = strtol (xcoff_ardata_big (abfd)->symoff, (char **) NULL, 10); |
1027 | if (off == 0) | |
1028 | { | |
1029 | bfd_has_map (abfd) = false; | |
1030 | return true; | |
1031 | } | |
252b5132 | 1032 | |
5ea1af0d GK |
1033 | if (bfd_seek (abfd, off, SEEK_SET) != 0) |
1034 | return false; | |
252b5132 | 1035 | |
5ea1af0d GK |
1036 | /* The symbol table starts with a normal archive header. */ |
1037 | if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) | |
1038 | != SIZEOF_AR_HDR_BIG) | |
1039 | return false; | |
1040 | ||
1041 | /* Skip the name (normally empty). */ | |
1042 | namlen = strtol (hdr.namlen, (char **) NULL, 10); | |
1043 | if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0) | |
1044 | return false; | |
1045 | ||
1046 | /* XXX This actually has to be a call to strtoll (at least on 32-bit | |
1047 | machines) since the field width is 20 and there numbers with more | |
1048 | than 32 bits can be represented. */ | |
1049 | sz = strtol (hdr.size, (char **) NULL, 10); | |
252b5132 | 1050 | |
31612ca6 GK |
1051 | /* Read in the entire symbol table. */ |
1052 | contents = (bfd_byte *) bfd_alloc (abfd, sz); | |
1053 | if (contents == NULL) | |
1054 | return false; | |
1055 | if (bfd_read ((PTR) contents, 1, sz, abfd) != sz) | |
1056 | return false; | |
252b5132 | 1057 | |
31612ca6 GK |
1058 | /* The symbol table starts with an eight byte count. */ |
1059 | c = bfd_h_get_64 (abfd, contents); | |
252b5132 | 1060 | |
31612ca6 GK |
1061 | if (c * 8 >= sz) |
1062 | { | |
1063 | bfd_set_error (bfd_error_bad_value); | |
1064 | return false; | |
1065 | } | |
beb1bf64 | 1066 | |
31612ca6 GK |
1067 | bfd_ardata (abfd)->symdefs = ((carsym *) |
1068 | bfd_alloc (abfd, c * sizeof (carsym))); | |
1069 | if (bfd_ardata (abfd)->symdefs == NULL) | |
1070 | return false; | |
beb1bf64 | 1071 | |
31612ca6 GK |
1072 | /* After the count comes a list of eight byte file offsets. */ |
1073 | for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8; | |
1074 | i < c; | |
1075 | ++i, ++arsym, p += 8) | |
1076 | arsym->file_offset = bfd_h_get_64 (abfd, p); | |
252b5132 RH |
1077 | } |
1078 | ||
252b5132 RH |
1079 | /* After the file offsets come null terminated symbol names. */ |
1080 | cend = contents + sz; | |
1081 | for (i = 0, arsym = bfd_ardata (abfd)->symdefs; | |
1082 | i < c; | |
1083 | ++i, ++arsym, p += strlen ((char *) p) + 1) | |
1084 | { | |
1085 | if (p >= cend) | |
1086 | { | |
1087 | bfd_set_error (bfd_error_bad_value); | |
1088 | return false; | |
1089 | } | |
1090 | arsym->name = (char *) p; | |
1091 | } | |
1092 | ||
1093 | bfd_ardata (abfd)->symdef_count = c; | |
1094 | bfd_has_map (abfd) = true; | |
1095 | ||
1096 | return true; | |
1097 | } | |
1098 | ||
1099 | /* See if this is an XCOFF archive. */ | |
1100 | ||
7f6d05e8 CP |
1101 | const bfd_target * |
1102 | _bfd_xcoff_archive_p (abfd) | |
252b5132 RH |
1103 | bfd *abfd; |
1104 | { | |
5ea1af0d | 1105 | char magic[SXCOFFARMAG]; |
252b5132 | 1106 | |
5ea1af0d | 1107 | if (bfd_read ((PTR) magic, SXCOFFARMAG, 1, abfd) != SXCOFFARMAG) |
252b5132 RH |
1108 | { |
1109 | if (bfd_get_error () != bfd_error_system_call) | |
1110 | bfd_set_error (bfd_error_wrong_format); | |
1111 | return NULL; | |
1112 | } | |
1113 | ||
5ea1af0d GK |
1114 | if (strncmp (magic, XCOFFARMAG, SXCOFFARMAG) != 0 |
1115 | && strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0) | |
252b5132 RH |
1116 | { |
1117 | bfd_set_error (bfd_error_wrong_format); | |
1118 | return NULL; | |
1119 | } | |
1120 | ||
1121 | /* We are setting bfd_ardata(abfd) here, but since bfd_ardata | |
1122 | involves a cast, we can't do it as the left operand of | |
1123 | assignment. */ | |
1124 | abfd->tdata.aout_ar_data = | |
1125 | (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata)); | |
1126 | ||
1127 | if (bfd_ardata (abfd) == (struct artdata *) NULL) | |
1128 | return NULL; | |
1129 | ||
252b5132 RH |
1130 | bfd_ardata (abfd)->cache = NULL; |
1131 | bfd_ardata (abfd)->archive_head = NULL; | |
1132 | bfd_ardata (abfd)->symdefs = NULL; | |
1133 | bfd_ardata (abfd)->extended_names = NULL; | |
1134 | ||
5ea1af0d GK |
1135 | /* Now handle the two formats. */ |
1136 | if (magic[1] != 'b') | |
1137 | { | |
1138 | /* This is the old format. */ | |
1139 | struct xcoff_ar_file_hdr hdr; | |
252b5132 | 1140 | |
5ea1af0d GK |
1141 | /* Copy over the magic string. */ |
1142 | memcpy (hdr.magic, magic, SXCOFFARMAG); | |
1143 | ||
1144 | /* Now read the rest of the file header. */ | |
1145 | if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR - SXCOFFARMAG, 1, | |
1146 | abfd) != SIZEOF_AR_FILE_HDR - SXCOFFARMAG) | |
1147 | { | |
1148 | if (bfd_get_error () != bfd_error_system_call) | |
1149 | bfd_set_error (bfd_error_wrong_format); | |
1150 | return NULL; | |
1151 | } | |
1152 | ||
1153 | bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff, | |
1154 | (char **) NULL, 10); | |
1155 | ||
1156 | bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR); | |
1157 | if (bfd_ardata (abfd)->tdata == NULL) | |
1158 | return NULL; | |
1159 | ||
1160 | memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR); | |
1161 | } | |
1162 | else | |
1163 | { | |
1164 | /* This is the new format. */ | |
1165 | struct xcoff_ar_file_hdr_big hdr; | |
1166 | ||
1167 | /* Copy over the magic string. */ | |
1168 | memcpy (hdr.magic, magic, SXCOFFARMAG); | |
1169 | ||
1170 | /* Now read the rest of the file header. */ | |
1171 | if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG, 1, | |
1172 | abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG) | |
1173 | { | |
1174 | if (bfd_get_error () != bfd_error_system_call) | |
1175 | bfd_set_error (bfd_error_wrong_format); | |
1176 | return NULL; | |
1177 | } | |
1178 | ||
1179 | /* XXX This actually has to be a call to strtoll (at least on 32-bit | |
1180 | machines) since the field width is 20 and there numbers with more | |
1181 | than 32 bits can be represented. */ | |
1182 | bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff, | |
1183 | (char **) NULL, 10); | |
1184 | ||
1185 | bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR_BIG); | |
1186 | if (bfd_ardata (abfd)->tdata == NULL) | |
1187 | return NULL; | |
1188 | ||
1189 | memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG); | |
1190 | } | |
252b5132 | 1191 | |
7f6d05e8 | 1192 | if (! _bfd_xcoff_slurp_armap (abfd)) |
252b5132 RH |
1193 | { |
1194 | bfd_release (abfd, bfd_ardata (abfd)); | |
1195 | abfd->tdata.aout_ar_data = (struct artdata *) NULL; | |
1196 | return NULL; | |
1197 | } | |
1198 | ||
1199 | return abfd->xvec; | |
1200 | } | |
1201 | ||
1202 | /* Read the archive header in an XCOFF archive. */ | |
1203 | ||
7f6d05e8 CP |
1204 | PTR |
1205 | _bfd_xcoff_read_ar_hdr (abfd) | |
252b5132 RH |
1206 | bfd *abfd; |
1207 | { | |
252b5132 | 1208 | size_t namlen; |
252b5132 RH |
1209 | struct areltdata *ret; |
1210 | ||
252b5132 RH |
1211 | ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata)); |
1212 | if (ret == NULL) | |
1213 | return NULL; | |
5ea1af0d GK |
1214 | |
1215 | if (! xcoff_big_format_p (abfd)) | |
1216 | { | |
1217 | struct xcoff_ar_hdr hdr; | |
1218 | struct xcoff_ar_hdr *hdrp; | |
1219 | ||
1220 | if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR) | |
1221 | { | |
1222 | free (ret); | |
1223 | return NULL; | |
1224 | } | |
1225 | ||
1226 | namlen = strtol (hdr.namlen, (char **) NULL, 10); | |
1227 | hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd, | |
1228 | SIZEOF_AR_HDR + namlen + 1); | |
1229 | if (hdrp == NULL) | |
1230 | { | |
1231 | free (ret); | |
1232 | return NULL; | |
1233 | } | |
1234 | memcpy (hdrp, &hdr, SIZEOF_AR_HDR); | |
1235 | if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen) | |
1236 | { | |
1237 | free (ret); | |
1238 | return NULL; | |
1239 | } | |
1240 | ((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0'; | |
1241 | ||
1242 | ret->arch_header = (char *) hdrp; | |
1243 | ret->parsed_size = strtol (hdr.size, (char **) NULL, 10); | |
1244 | ret->filename = (char *) hdrp + SIZEOF_AR_HDR; | |
1245 | } | |
1246 | else | |
1247 | { | |
1248 | struct xcoff_ar_hdr_big hdr; | |
1249 | struct xcoff_ar_hdr_big *hdrp; | |
1250 | ||
1251 | if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) | |
1252 | != SIZEOF_AR_HDR_BIG) | |
1253 | { | |
1254 | free (ret); | |
1255 | return NULL; | |
1256 | } | |
1257 | ||
1258 | namlen = strtol (hdr.namlen, (char **) NULL, 10); | |
1259 | hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd, | |
1260 | SIZEOF_AR_HDR_BIG | |
1261 | + namlen + 1); | |
1262 | if (hdrp == NULL) | |
1263 | { | |
1264 | free (ret); | |
1265 | return NULL; | |
1266 | } | |
1267 | memcpy (hdrp, &hdr, SIZEOF_AR_HDR_BIG); | |
1268 | if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR_BIG, 1, namlen, abfd) != namlen) | |
1269 | { | |
1270 | free (ret); | |
1271 | return NULL; | |
1272 | } | |
1273 | ((char *) hdrp)[SIZEOF_AR_HDR_BIG + namlen] = '\0'; | |
1274 | ||
1275 | ret->arch_header = (char *) hdrp; | |
1276 | /* XXX This actually has to be a call to strtoll (at least on 32-bit | |
1277 | machines) since the field width is 20 and there numbers with more | |
1278 | than 32 bits can be represented. */ | |
1279 | ret->parsed_size = strtol (hdr.size, (char **) NULL, 10); | |
1280 | ret->filename = (char *) hdrp + SIZEOF_AR_HDR_BIG; | |
1281 | } | |
252b5132 RH |
1282 | |
1283 | /* Skip over the XCOFFARFMAG at the end of the file name. */ | |
1284 | if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0) | |
1285 | return NULL; | |
1286 | ||
1287 | return (PTR) ret; | |
1288 | } | |
1289 | ||
1290 | /* Open the next element in an XCOFF archive. */ | |
1291 | ||
7f6d05e8 CP |
1292 | bfd * |
1293 | _bfd_xcoff_openr_next_archived_file (archive, last_file) | |
252b5132 RH |
1294 | bfd *archive; |
1295 | bfd *last_file; | |
1296 | { | |
1297 | file_ptr filestart; | |
1298 | ||
1299 | if (xcoff_ardata (archive) == NULL) | |
1300 | { | |
1301 | bfd_set_error (bfd_error_invalid_operation); | |
1302 | return NULL; | |
1303 | } | |
1304 | ||
5ea1af0d GK |
1305 | if (! xcoff_big_format_p (archive)) |
1306 | { | |
1307 | if (last_file == NULL) | |
1308 | filestart = bfd_ardata (archive)->first_file_filepos; | |
1309 | else | |
1310 | filestart = strtol (arch_xhdr (last_file)->nextoff, (char **) NULL, | |
1311 | 10); | |
1312 | ||
1313 | if (filestart == 0 | |
1314 | || filestart == strtol (xcoff_ardata (archive)->memoff, | |
1315 | (char **) NULL, 10) | |
1316 | || filestart == strtol (xcoff_ardata (archive)->symoff, | |
1317 | (char **) NULL, 10)) | |
1318 | { | |
1319 | bfd_set_error (bfd_error_no_more_archived_files); | |
1320 | return NULL; | |
1321 | } | |
1322 | } | |
252b5132 | 1323 | else |
252b5132 | 1324 | { |
5ea1af0d GK |
1325 | if (last_file == NULL) |
1326 | filestart = bfd_ardata (archive)->first_file_filepos; | |
1327 | else | |
1328 | /* XXX These actually have to be a calls to strtoll (at least | |
1329 | on 32-bit machines) since the fields's width is 20 and | |
1330 | there numbers with more than 32 bits can be represented. */ | |
1331 | filestart = strtol (arch_xhdr_big (last_file)->nextoff, (char **) NULL, | |
1332 | 10); | |
1333 | ||
1334 | /* XXX These actually have to be calls to strtoll (at least on 32-bit | |
1335 | machines) since the fields's width is 20 and there numbers with more | |
1336 | than 32 bits can be represented. */ | |
1337 | if (filestart == 0 | |
1338 | || filestart == strtol (xcoff_ardata_big (archive)->memoff, | |
1339 | (char **) NULL, 10) | |
1340 | || filestart == strtol (xcoff_ardata_big (archive)->symoff, | |
1341 | (char **) NULL, 10)) | |
1342 | { | |
1343 | bfd_set_error (bfd_error_no_more_archived_files); | |
1344 | return NULL; | |
1345 | } | |
252b5132 RH |
1346 | } |
1347 | ||
1348 | return _bfd_get_elt_at_filepos (archive, filestart); | |
1349 | } | |
1350 | ||
1351 | /* Stat an element in an XCOFF archive. */ | |
1352 | ||
7f6d05e8 CP |
1353 | int |
1354 | _bfd_xcoff_generic_stat_arch_elt (abfd, s) | |
252b5132 RH |
1355 | bfd *abfd; |
1356 | struct stat *s; | |
1357 | { | |
252b5132 RH |
1358 | if (abfd->arelt_data == NULL) |
1359 | { | |
1360 | bfd_set_error (bfd_error_invalid_operation); | |
1361 | return -1; | |
1362 | } | |
1363 | ||
5ea1af0d GK |
1364 | if (! xcoff_big_format_p (abfd)) |
1365 | { | |
1366 | struct xcoff_ar_hdr *hdrp = arch_xhdr (abfd); | |
1367 | ||
1368 | s->st_mtime = strtol (hdrp->date, (char **) NULL, 10); | |
1369 | s->st_uid = strtol (hdrp->uid, (char **) NULL, 10); | |
1370 | s->st_gid = strtol (hdrp->gid, (char **) NULL, 10); | |
1371 | s->st_mode = strtol (hdrp->mode, (char **) NULL, 8); | |
1372 | s->st_size = arch_eltdata (abfd)->parsed_size; | |
1373 | } | |
1374 | else | |
1375 | { | |
1376 | struct xcoff_ar_hdr_big *hdrp = arch_xhdr_big (abfd); | |
252b5132 | 1377 | |
5ea1af0d GK |
1378 | s->st_mtime = strtol (hdrp->date, (char **) NULL, 10); |
1379 | s->st_uid = strtol (hdrp->uid, (char **) NULL, 10); | |
1380 | s->st_gid = strtol (hdrp->gid, (char **) NULL, 10); | |
1381 | s->st_mode = strtol (hdrp->mode, (char **) NULL, 8); | |
1382 | s->st_size = arch_eltdata (abfd)->parsed_size; | |
1383 | } | |
252b5132 RH |
1384 | |
1385 | return 0; | |
1386 | } | |
1387 | ||
1388 | /* Normalize a file name for inclusion in an archive. */ | |
1389 | ||
1390 | static const char * | |
1391 | normalize_filename (abfd) | |
1392 | bfd *abfd; | |
1393 | { | |
1394 | const char *file; | |
1395 | const char *filename; | |
1396 | ||
1397 | file = bfd_get_filename (abfd); | |
1398 | filename = strrchr (file, '/'); | |
1399 | if (filename != NULL) | |
1400 | filename++; | |
1401 | else | |
1402 | filename = file; | |
1403 | return filename; | |
1404 | } | |
1405 | ||
1406 | /* Write out an XCOFF armap. */ | |
1407 | ||
beb1bf64 | 1408 | /*ARGSUSED*/ |
252b5132 | 1409 | static boolean |
5ea1af0d | 1410 | xcoff_write_armap_old (abfd, elength, map, orl_count, stridx) |
252b5132 | 1411 | bfd *abfd; |
5f771d47 | 1412 | unsigned int elength ATTRIBUTE_UNUSED; |
252b5132 RH |
1413 | struct orl *map; |
1414 | unsigned int orl_count; | |
1415 | int stridx; | |
1416 | { | |
1417 | struct xcoff_ar_hdr hdr; | |
1418 | char *p; | |
1419 | unsigned char buf[4]; | |
1420 | bfd *sub; | |
1421 | file_ptr fileoff; | |
1422 | unsigned int i; | |
1423 | ||
1424 | memset (&hdr, 0, sizeof hdr); | |
1425 | sprintf (hdr.size, "%ld", (long) (4 + orl_count * 4 + stridx)); | |
1426 | sprintf (hdr.nextoff, "%d", 0); | |
1427 | memcpy (hdr.prevoff, xcoff_ardata (abfd)->memoff, 12); | |
1428 | sprintf (hdr.date, "%d", 0); | |
1429 | sprintf (hdr.uid, "%d", 0); | |
1430 | sprintf (hdr.gid, "%d", 0); | |
1431 | sprintf (hdr.mode, "%d", 0); | |
1432 | sprintf (hdr.namlen, "%d", 0); | |
1433 | ||
1434 | /* We need spaces, not null bytes, in the header. */ | |
1435 | for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR; p++) | |
1436 | if (*p == '\0') | |
1437 | *p = ' '; | |
1438 | ||
1439 | if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR | |
1440 | || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG) | |
1441 | return false; | |
5ea1af0d | 1442 | |
252b5132 RH |
1443 | bfd_h_put_32 (abfd, orl_count, buf); |
1444 | if (bfd_write (buf, 1, 4, abfd) != 4) | |
1445 | return false; | |
1446 | ||
1447 | sub = abfd->archive_head; | |
1448 | fileoff = SIZEOF_AR_FILE_HDR; | |
1449 | i = 0; | |
1450 | while (sub != NULL && i < orl_count) | |
1451 | { | |
1452 | size_t namlen; | |
1453 | ||
1454 | while (((bfd *) (map[i]).pos) == sub) | |
1455 | { | |
1456 | bfd_h_put_32 (abfd, fileoff, buf); | |
1457 | if (bfd_write (buf, 1, 4, abfd) != 4) | |
1458 | return false; | |
1459 | ++i; | |
1460 | } | |
1461 | namlen = strlen (normalize_filename (sub)); | |
1462 | namlen = (namlen + 1) &~ 1; | |
1463 | fileoff += (SIZEOF_AR_HDR | |
1464 | + namlen | |
1465 | + SXCOFFARFMAG | |
1466 | + arelt_size (sub)); | |
1467 | fileoff = (fileoff + 1) &~ 1; | |
1468 | sub = sub->next; | |
1469 | } | |
1470 | ||
1471 | for (i = 0; i < orl_count; i++) | |
1472 | { | |
1473 | const char *name; | |
1474 | size_t namlen; | |
1475 | ||
1476 | name = *map[i].name; | |
1477 | namlen = strlen (name); | |
1478 | if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1) | |
1479 | return false; | |
1480 | } | |
1481 | ||
1482 | if ((stridx & 1) != 0) | |
1483 | { | |
1484 | char b; | |
1485 | ||
1486 | b = '\0'; | |
1487 | if (bfd_write (&b, 1, 1, abfd) != 1) | |
1488 | return false; | |
1489 | } | |
1490 | ||
1491 | return true; | |
1492 | } | |
1493 | ||
1a6df346 | 1494 | /* Write a single armap in the big format. */ |
252b5132 | 1495 | static boolean |
1a6df346 GK |
1496 | xcoff_write_one_armap_big (abfd, map, orl_count, orl_ccount, stridx, bits64, |
1497 | prevoff, nextoff) | |
252b5132 | 1498 | bfd *abfd; |
5ea1af0d GK |
1499 | struct orl *map; |
1500 | unsigned int orl_count; | |
1a6df346 GK |
1501 | unsigned int orl_ccount; |
1502 | unsigned int stridx; | |
1503 | int bits64; | |
1504 | const char *prevoff; | |
1505 | char *nextoff; | |
252b5132 | 1506 | { |
5ea1af0d GK |
1507 | struct xcoff_ar_hdr_big hdr; |
1508 | char *p; | |
1509 | unsigned char buf[4]; | |
252b5132 | 1510 | bfd *sub; |
5ea1af0d | 1511 | file_ptr fileoff; |
beb1bf64 | 1512 | const bfd_arch_info_type *arch_info; |
1a6df346 | 1513 | bfd *object_bfd; |
252b5132 | 1514 | unsigned int i; |
252b5132 | 1515 | |
5ea1af0d GK |
1516 | memset (&hdr, 0, sizeof hdr); |
1517 | /* XXX This call actually should use %lld (at least on 32-bit | |
1518 | machines) since the fields's width is 20 and there numbers with | |
1519 | more than 32 bits can be represented. */ | |
1a6df346 | 1520 | sprintf (hdr.size, "%ld", (long) (4 + orl_ccount * 4 + stridx)); |
beb1bf64 | 1521 | if (bits64) { |
1a6df346 | 1522 | sprintf (hdr.nextoff, "%d", 0); |
beb1bf64 TR |
1523 | } else { |
1524 | /* do explict cast to long to remove compiler warning */ | |
1525 | sprintf (hdr.nextoff, "%ld", (strtol (prevoff, (char **) NULL, 10) | |
1526 | + (long) (4 + orl_ccount * 4 + stridx))); | |
1527 | } | |
1528 | ||
1a6df346 | 1529 | memcpy (hdr.prevoff, prevoff, sizeof (hdr.prevoff)); |
5ea1af0d GK |
1530 | sprintf (hdr.date, "%d", 0); |
1531 | sprintf (hdr.uid, "%d", 0); | |
1532 | sprintf (hdr.gid, "%d", 0); | |
1533 | sprintf (hdr.mode, "%d", 0); | |
1534 | sprintf (hdr.namlen, "%d", 0); | |
252b5132 | 1535 | |
5ea1af0d GK |
1536 | /* We need spaces, not null bytes, in the header. */ |
1537 | for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR_BIG; p++) | |
1538 | if (*p == '\0') | |
1539 | *p = ' '; | |
1540 | ||
1a6df346 GK |
1541 | memcpy (nextoff, hdr.nextoff, sizeof (hdr.nextoff)); |
1542 | ||
5ea1af0d GK |
1543 | if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) != SIZEOF_AR_HDR_BIG |
1544 | || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG) | |
252b5132 RH |
1545 | return false; |
1546 | ||
1a6df346 | 1547 | bfd_h_put_32 (abfd, orl_ccount, buf); |
5ea1af0d | 1548 | if (bfd_write (buf, 1, 4, abfd) != 4) |
252b5132 RH |
1549 | return false; |
1550 | ||
5ea1af0d GK |
1551 | sub = abfd->archive_head; |
1552 | fileoff = SIZEOF_AR_FILE_HDR_BIG; | |
1553 | i = 0; | |
1554 | while (sub != NULL && i < orl_count) | |
252b5132 | 1555 | { |
5ea1af0d GK |
1556 | size_t namlen; |
1557 | ||
1a6df346 GK |
1558 | if ((bfd_arch_bits_per_address ((bfd *) map[i].pos) == 64) == bits64) |
1559 | while (((bfd *) (map[i]).pos) == sub) | |
1560 | { | |
1561 | bfd_h_put_32 (abfd, fileoff, buf); | |
1562 | if (bfd_write (buf, 1, 4, abfd) != 4) | |
1563 | return false; | |
1564 | i++; | |
1565 | } | |
1566 | else | |
1567 | while (((bfd *) (map[i]).pos) == sub) | |
1568 | i++; | |
1569 | ||
5ea1af0d GK |
1570 | namlen = strlen (normalize_filename (sub)); |
1571 | namlen = (namlen + 1) &~ 1; | |
1572 | fileoff += (SIZEOF_AR_HDR_BIG | |
1573 | + namlen | |
1574 | + SXCOFFARFMAG | |
1575 | + arelt_size (sub)); | |
1576 | fileoff = (fileoff + 1) &~ 1; | |
1577 | sub = sub->next; | |
1578 | } | |
1579 | ||
1a6df346 | 1580 | object_bfd = NULL; |
5ea1af0d GK |
1581 | for (i = 0; i < orl_count; i++) |
1582 | { | |
1583 | const char *name; | |
1584 | size_t namlen; | |
1a6df346 GK |
1585 | bfd *ob = (bfd *)map[i].pos; |
1586 | ||
1587 | if (ob != object_bfd) | |
1588 | arch_info = bfd_get_arch_info (ob); | |
beb1bf64 | 1589 | if ((arch_info->bits_per_address == 64) != bits64) |
1a6df346 | 1590 | continue; |
5ea1af0d GK |
1591 | |
1592 | name = *map[i].name; | |
1593 | namlen = strlen (name); | |
1594 | if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1) | |
1595 | return false; | |
1596 | } | |
1597 | ||
1598 | if ((stridx & 1) != 0) | |
1599 | { | |
1600 | char b; | |
1601 | ||
1602 | b = '\0'; | |
1603 | if (bfd_write (&b, 1, 1, abfd) != 1) | |
1604 | return false; | |
1605 | } | |
1606 | ||
1607 | return true; | |
1608 | } | |
1609 | ||
beb1bf64 | 1610 | /*ARGSUSED*/ |
1a6df346 GK |
1611 | static boolean |
1612 | xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) | |
1613 | bfd *abfd; | |
1614 | unsigned int elength ATTRIBUTE_UNUSED; | |
1615 | struct orl *map; | |
1616 | unsigned int orl_count; | |
1617 | int stridx; | |
1618 | { | |
1619 | unsigned int i; | |
1620 | unsigned int orl_count_32, orl_count_64; | |
1621 | unsigned int stridx_32, stridx_64; | |
beb1bf64 | 1622 | const bfd_arch_info_type *arch_info; |
1a6df346 GK |
1623 | bfd *object_bfd; |
1624 | ||
1625 | /* First, we look through the symbols and work out which are | |
1626 | from 32-bit objects and which from 64-bit ones. */ | |
1627 | orl_count_32 = 0; | |
1628 | orl_count_64 = 0; | |
1629 | stridx_32 = 0; | |
1630 | stridx_64 = 0; | |
1631 | object_bfd = NULL; | |
1632 | for (i = 0; i < orl_count; i++) | |
1633 | { | |
1634 | bfd *ob = (bfd *)map[i].pos; | |
1635 | unsigned int len; | |
1636 | if (ob != object_bfd) | |
1637 | arch_info = bfd_get_arch_info (ob); | |
1638 | len = strlen (*map[i].name) + 1; | |
beb1bf64 | 1639 | if (arch_info->bits_per_address == 64) |
1a6df346 GK |
1640 | { |
1641 | orl_count_64++; | |
1642 | stridx_64 += len; | |
1643 | } | |
1644 | else | |
1645 | { | |
1646 | orl_count_32++; | |
1647 | stridx_32 += len; | |
1648 | } | |
1649 | object_bfd = ob; | |
1650 | } | |
beb1bf64 | 1651 | /* A quick sanity check... */ |
1a6df346 | 1652 | BFD_ASSERT (orl_count_64 + orl_count_32 == orl_count); |
beb1bf64 TR |
1653 | /* explicit cast to int for compiler */ |
1654 | BFD_ASSERT ((int)(stridx_64 + stridx_32) == stridx); | |
1a6df346 GK |
1655 | |
1656 | /* Now write out each map. */ | |
1657 | if (! xcoff_write_one_armap_big (abfd, map, orl_count, orl_count_32, | |
beb1bf64 | 1658 | stridx_32, false, |
1a6df346 GK |
1659 | xcoff_ardata_big (abfd)->memoff, |
1660 | xcoff_ardata_big (abfd)->symoff)) | |
1661 | return false; | |
1662 | if (! xcoff_write_one_armap_big (abfd, map, orl_count, orl_count_64, | |
1663 | stridx_64, true, | |
1664 | xcoff_ardata_big (abfd)->symoff, | |
1665 | xcoff_ardata_big (abfd)->symoff64)) | |
1666 | return false; | |
beb1bf64 | 1667 | |
1a6df346 GK |
1668 | return true; |
1669 | } | |
1670 | ||
beb1bf64 | 1671 | /*ARGSUSED*/ |
7f6d05e8 CP |
1672 | boolean |
1673 | _bfd_xcoff_write_armap (abfd, elength, map, orl_count, stridx) | |
5ea1af0d GK |
1674 | bfd *abfd; |
1675 | unsigned int elength ATTRIBUTE_UNUSED; | |
1676 | struct orl *map; | |
1677 | unsigned int orl_count; | |
1678 | int stridx; | |
1679 | { | |
1680 | if (! xcoff_big_format_p (abfd)) | |
1681 | return xcoff_write_armap_old (abfd, elength, map, orl_count, stridx); | |
1682 | else | |
1683 | return xcoff_write_armap_big (abfd, elength, map, orl_count, stridx); | |
1684 | } | |
1685 | ||
1686 | /* Write out an XCOFF archive. We always write an entire archive, | |
1687 | rather than fussing with the freelist and so forth. */ | |
1688 | ||
1689 | static boolean | |
1690 | xcoff_write_archive_contents_old (abfd) | |
1691 | bfd *abfd; | |
1692 | { | |
1693 | struct xcoff_ar_file_hdr fhdr; | |
1694 | size_t count; | |
1695 | size_t total_namlen; | |
1696 | file_ptr *offsets; | |
1697 | boolean makemap; | |
1698 | boolean hasobjects; | |
1699 | file_ptr prevoff, nextoff; | |
1700 | bfd *sub; | |
1701 | unsigned int i; | |
1702 | struct xcoff_ar_hdr ahdr; | |
1703 | bfd_size_type size; | |
1704 | char *p; | |
1705 | char decbuf[13]; | |
1706 | ||
1707 | memset (&fhdr, 0, sizeof fhdr); | |
1708 | strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG); | |
1709 | sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR); | |
1710 | sprintf (fhdr.freeoff, "%d", 0); | |
1711 | ||
1712 | count = 0; | |
1713 | total_namlen = 0; | |
1714 | for (sub = abfd->archive_head; sub != NULL; sub = sub->next) | |
1715 | { | |
1716 | ++count; | |
1717 | total_namlen += strlen (normalize_filename (sub)) + 1; | |
1718 | } | |
1719 | offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr)); | |
1720 | if (offsets == NULL) | |
1721 | return false; | |
1722 | ||
1723 | if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0) | |
1724 | return false; | |
1725 | ||
1726 | makemap = bfd_has_map (abfd); | |
1727 | hasobjects = false; | |
1728 | prevoff = 0; | |
1729 | nextoff = SIZEOF_AR_FILE_HDR; | |
1730 | for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++) | |
1731 | { | |
1732 | const char *name; | |
252b5132 RH |
1733 | size_t namlen; |
1734 | struct xcoff_ar_hdr *ahdrp; | |
1735 | bfd_size_type remaining; | |
1736 | ||
1737 | if (makemap && ! hasobjects) | |
1738 | { | |
1739 | if (bfd_check_format (sub, bfd_object)) | |
1740 | hasobjects = true; | |
1741 | } | |
1742 | ||
1743 | name = normalize_filename (sub); | |
1744 | namlen = strlen (name); | |
1745 | ||
1746 | if (sub->arelt_data != NULL) | |
1747 | ahdrp = arch_xhdr (sub); | |
1748 | else | |
1749 | ahdrp = NULL; | |
1750 | ||
1751 | if (ahdrp == NULL) | |
1752 | { | |
1753 | struct stat s; | |
1754 | ||
1755 | memset (&ahdr, 0, sizeof ahdr); | |
1756 | ahdrp = &ahdr; | |
1757 | if (stat (bfd_get_filename (sub), &s) != 0) | |
1758 | { | |
1759 | bfd_set_error (bfd_error_system_call); | |
1760 | return false; | |
1761 | } | |
1762 | ||
1763 | sprintf (ahdrp->size, "%ld", (long) s.st_size); | |
1764 | sprintf (ahdrp->date, "%ld", (long) s.st_mtime); | |
1765 | sprintf (ahdrp->uid, "%ld", (long) s.st_uid); | |
1766 | sprintf (ahdrp->gid, "%ld", (long) s.st_gid); | |
1767 | sprintf (ahdrp->mode, "%o", (unsigned int) s.st_mode); | |
1768 | ||
1769 | if (sub->arelt_data == NULL) | |
1770 | { | |
1771 | sub->arelt_data = bfd_alloc (sub, sizeof (struct areltdata)); | |
1772 | if (sub->arelt_data == NULL) | |
1773 | return false; | |
1774 | } | |
1775 | ||
1776 | arch_eltdata (sub)->parsed_size = s.st_size; | |
1777 | } | |
1778 | ||
1779 | sprintf (ahdrp->prevoff, "%ld", (long) prevoff); | |
1780 | sprintf (ahdrp->namlen, "%ld", (long) namlen); | |
1781 | ||
1782 | /* If the length of the name is odd, we write out the null byte | |
1783 | after the name as well. */ | |
1784 | namlen = (namlen + 1) &~ 1; | |
1785 | ||
1786 | remaining = arelt_size (sub); | |
1787 | size = (SIZEOF_AR_HDR | |
1788 | + namlen | |
1789 | + SXCOFFARFMAG | |
1790 | + remaining); | |
1791 | ||
1792 | BFD_ASSERT (nextoff == bfd_tell (abfd)); | |
1793 | ||
1794 | offsets[i] = nextoff; | |
1795 | ||
1796 | prevoff = nextoff; | |
1797 | nextoff += size + (size & 1); | |
1798 | ||
1799 | sprintf (ahdrp->nextoff, "%ld", (long) nextoff); | |
1800 | ||
1801 | /* We need spaces, not null bytes, in the header. */ | |
1802 | for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR; p++) | |
1803 | if (*p == '\0') | |
1804 | *p = ' '; | |
1805 | ||
1806 | if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR | |
1807 | || bfd_write ((PTR) name, 1, namlen, abfd) != namlen | |
1808 | || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) | |
1809 | != SXCOFFARFMAG)) | |
1810 | return false; | |
1811 | ||
1812 | if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0) | |
1813 | return false; | |
1814 | while (remaining != 0) | |
1815 | { | |
1816 | bfd_size_type amt; | |
1817 | bfd_byte buffer[DEFAULT_BUFFERSIZE]; | |
1818 | ||
1819 | amt = sizeof buffer; | |
1820 | if (amt > remaining) | |
1821 | amt = remaining; | |
1822 | if (bfd_read (buffer, 1, amt, sub) != amt | |
1823 | || bfd_write (buffer, 1, amt, abfd) != amt) | |
1824 | return false; | |
1825 | remaining -= amt; | |
1826 | } | |
1827 | ||
1828 | if ((size & 1) != 0) | |
1829 | { | |
1830 | bfd_byte b; | |
1831 | ||
1832 | b = '\0'; | |
1833 | if (bfd_write (&b, 1, 1, abfd) != 1) | |
1834 | return false; | |
1835 | } | |
1836 | } | |
1837 | ||
1838 | sprintf (fhdr.lastmemoff, "%ld", (long) prevoff); | |
1839 | ||
1840 | /* Write out the member table. */ | |
1841 | ||
1842 | BFD_ASSERT (nextoff == bfd_tell (abfd)); | |
1843 | sprintf (fhdr.memoff, "%ld", (long) nextoff); | |
1844 | ||
1845 | memset (&ahdr, 0, sizeof ahdr); | |
1846 | sprintf (ahdr.size, "%ld", (long) (12 + count * 12 + total_namlen)); | |
1847 | sprintf (ahdr.prevoff, "%ld", (long) prevoff); | |
1848 | sprintf (ahdr.date, "%d", 0); | |
1849 | sprintf (ahdr.uid, "%d", 0); | |
1850 | sprintf (ahdr.gid, "%d", 0); | |
1851 | sprintf (ahdr.mode, "%d", 0); | |
1852 | sprintf (ahdr.namlen, "%d", 0); | |
1853 | ||
1854 | size = (SIZEOF_AR_HDR | |
1855 | + 12 | |
1856 | + count * 12 | |
1857 | + total_namlen | |
1858 | + SXCOFFARFMAG); | |
1859 | ||
1860 | prevoff = nextoff; | |
1861 | nextoff += size + (size & 1); | |
1862 | ||
1863 | if (makemap && hasobjects) | |
1864 | sprintf (ahdr.nextoff, "%ld", (long) nextoff); | |
1865 | else | |
1866 | sprintf (ahdr.nextoff, "%d", 0); | |
1867 | ||
1868 | /* We need spaces, not null bytes, in the header. */ | |
1869 | for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR; p++) | |
1870 | if (*p == '\0') | |
1871 | *p = ' '; | |
1872 | ||
1873 | if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR | |
1874 | || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) | |
1875 | != SXCOFFARFMAG)) | |
1876 | return false; | |
1877 | ||
1878 | sprintf (decbuf, "%-12ld", (long) count); | |
1879 | if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12) | |
1880 | return false; | |
1881 | for (i = 0; i < count; i++) | |
1882 | { | |
1883 | sprintf (decbuf, "%-12ld", (long) offsets[i]); | |
1884 | if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12) | |
1885 | return false; | |
1886 | } | |
1887 | for (sub = abfd->archive_head; sub != NULL; sub = sub->next) | |
1888 | { | |
1889 | const char *name; | |
1890 | size_t namlen; | |
1891 | ||
1892 | name = normalize_filename (sub); | |
1893 | namlen = strlen (name); | |
1894 | if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1) | |
1895 | return false; | |
1896 | } | |
1897 | if ((size & 1) != 0) | |
1898 | { | |
1899 | bfd_byte b; | |
1900 | ||
1901 | b = '\0'; | |
1902 | if (bfd_write ((PTR) &b, 1, 1, abfd) != 1) | |
1903 | return false; | |
1904 | } | |
1905 | ||
1906 | /* Write out the armap, if appropriate. */ | |
1907 | ||
1908 | if (! makemap || ! hasobjects) | |
1909 | sprintf (fhdr.symoff, "%d", 0); | |
1910 | else | |
1911 | { | |
1912 | BFD_ASSERT (nextoff == bfd_tell (abfd)); | |
1913 | sprintf (fhdr.symoff, "%ld", (long) nextoff); | |
1914 | bfd_ardata (abfd)->tdata = (PTR) &fhdr; | |
1915 | if (! _bfd_compute_and_write_armap (abfd, 0)) | |
1916 | return false; | |
1917 | } | |
1918 | ||
1919 | /* Write out the archive file header. */ | |
1920 | ||
1921 | /* We need spaces, not null bytes, in the header. */ | |
1922 | for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR; p++) | |
1923 | if (*p == '\0') | |
1924 | *p = ' '; | |
1925 | ||
1926 | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | |
1927 | || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR, 1, abfd) != | |
1928 | SIZEOF_AR_FILE_HDR)) | |
1929 | return false; | |
1930 | ||
1931 | return true; | |
1932 | } | |
5ea1af0d GK |
1933 | |
1934 | static boolean | |
1935 | xcoff_write_archive_contents_big (abfd) | |
1936 | bfd *abfd; | |
1937 | { | |
1938 | struct xcoff_ar_file_hdr_big fhdr; | |
1939 | size_t count; | |
1940 | size_t total_namlen; | |
1941 | file_ptr *offsets; | |
1942 | boolean makemap; | |
1943 | boolean hasobjects; | |
1944 | file_ptr prevoff, nextoff; | |
1945 | bfd *sub; | |
1946 | unsigned int i; | |
1947 | struct xcoff_ar_hdr_big ahdr; | |
1948 | bfd_size_type size; | |
1949 | char *p; | |
1950 | char decbuf[13]; | |
1951 | ||
1952 | memset (&fhdr, 0, sizeof fhdr); | |
1953 | strncpy (fhdr.magic, XCOFFARMAGBIG, SXCOFFARMAG); | |
1954 | sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR_BIG); | |
1955 | sprintf (fhdr.freeoff, "%d", 0); | |
1956 | ||
1957 | count = 0; | |
1958 | total_namlen = 0; | |
1959 | for (sub = abfd->archive_head; sub != NULL; sub = sub->next) | |
1960 | { | |
1961 | ++count; | |
1962 | total_namlen += strlen (normalize_filename (sub)) + 1; | |
1963 | } | |
1964 | offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr)); | |
1965 | if (offsets == NULL) | |
1966 | return false; | |
1967 | ||
1968 | if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0) | |
1969 | return false; | |
1970 | ||
1971 | makemap = bfd_has_map (abfd); | |
1972 | hasobjects = false; | |
1973 | prevoff = 0; | |
1974 | nextoff = SIZEOF_AR_FILE_HDR_BIG; | |
1975 | for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++) | |
1976 | { | |
1977 | const char *name; | |
1978 | size_t namlen; | |
1979 | struct xcoff_ar_hdr_big *ahdrp; | |
1980 | bfd_size_type remaining; | |
1981 | ||
1982 | if (makemap && ! hasobjects) | |
1983 | { | |
1984 | if (bfd_check_format (sub, bfd_object)) | |
1985 | hasobjects = true; | |
1986 | } | |
1987 | ||
1988 | name = normalize_filename (sub); | |
1989 | namlen = strlen (name); | |
1990 | ||
1991 | if (sub->arelt_data != NULL) | |
1992 | ahdrp = arch_xhdr_big (sub); | |
1993 | else | |
1994 | ahdrp = NULL; | |
1995 | ||
1996 | if (ahdrp == NULL) | |
1997 | { | |
1998 | struct stat s; | |
1999 | ||
2000 | memset (&ahdr, 0, sizeof ahdr); | |
2001 | ahdrp = &ahdr; | |
2002 | /* XXX This should actually be a call to stat64 (at least on | |
2003 | 32-bit machines). */ | |
2004 | if (stat (bfd_get_filename (sub), &s) != 0) | |
2005 | { | |
2006 | bfd_set_error (bfd_error_system_call); | |
2007 | return false; | |
2008 | } | |
2009 | ||
2010 | /* XXX This call actually should use %lld (at least on 32-bit | |
2011 | machines) since the fields's width is 20 and there numbers with | |
2012 | more than 32 bits can be represented. */ | |
2013 | sprintf (ahdrp->size, "%ld", (long) s.st_size); | |
2014 | sprintf (ahdrp->date, "%ld", (long) s.st_mtime); | |
2015 | sprintf (ahdrp->uid, "%ld", (long) s.st_uid); | |
2016 | sprintf (ahdrp->gid, "%ld", (long) s.st_gid); | |
2017 | sprintf (ahdrp->mode, "%o", (unsigned int) s.st_mode); | |
2018 | ||
2019 | if (sub->arelt_data == NULL) | |
2020 | { | |
2021 | sub->arelt_data = bfd_alloc (sub, sizeof (struct areltdata)); | |
2022 | if (sub->arelt_data == NULL) | |
2023 | return false; | |
2024 | } | |
2025 | ||
2026 | arch_eltdata (sub)->parsed_size = s.st_size; | |
2027 | } | |
2028 | ||
2029 | /* XXX These calls actually should use %lld (at least on 32-bit | |
2030 | machines) since the fields's width is 20 and there numbers with | |
2031 | more than 32 bits can be represented. */ | |
2032 | sprintf (ahdrp->prevoff, "%ld", (long) prevoff); | |
2033 | sprintf (ahdrp->namlen, "%ld", (long) namlen); | |
2034 | ||
2035 | /* If the length of the name is odd, we write out the null byte | |
2036 | after the name as well. */ | |
2037 | namlen = (namlen + 1) &~ 1; | |
2038 | ||
2039 | remaining = arelt_size (sub); | |
2040 | size = (SIZEOF_AR_HDR_BIG | |
2041 | + namlen | |
2042 | + SXCOFFARFMAG | |
2043 | + remaining); | |
2044 | ||
2045 | BFD_ASSERT (nextoff == bfd_tell (abfd)); | |
2046 | ||
2047 | offsets[i] = nextoff; | |
2048 | ||
2049 | prevoff = nextoff; | |
2050 | nextoff += size + (size & 1); | |
2051 | ||
2052 | sprintf (ahdrp->nextoff, "%ld", (long) nextoff); | |
2053 | ||
2054 | /* We need spaces, not null bytes, in the header. */ | |
2055 | for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR_BIG; p++) | |
2056 | if (*p == '\0') | |
2057 | *p = ' '; | |
2058 | ||
2059 | if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR_BIG, abfd) | |
2060 | != SIZEOF_AR_HDR_BIG | |
2061 | || bfd_write ((PTR) name, 1, namlen, abfd) != namlen | |
2062 | || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) | |
2063 | != SXCOFFARFMAG)) | |
2064 | return false; | |
2065 | ||
2066 | if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0) | |
2067 | return false; | |
2068 | while (remaining != 0) | |
2069 | { | |
2070 | bfd_size_type amt; | |
2071 | bfd_byte buffer[DEFAULT_BUFFERSIZE]; | |
2072 | ||
2073 | amt = sizeof buffer; | |
2074 | if (amt > remaining) | |
2075 | amt = remaining; | |
2076 | if (bfd_read (buffer, 1, amt, sub) != amt | |
2077 | || bfd_write (buffer, 1, amt, abfd) != amt) | |
2078 | return false; | |
2079 | remaining -= amt; | |
2080 | } | |
2081 | ||
2082 | if ((size & 1) != 0) | |
2083 | { | |
2084 | bfd_byte b; | |
2085 | ||
2086 | b = '\0'; | |
2087 | if (bfd_write (&b, 1, 1, abfd) != 1) | |
2088 | return false; | |
2089 | } | |
2090 | } | |
2091 | ||
2092 | /* XXX This call actually should use %lld (at least on 32-bit | |
2093 | machines) since the fields's width is 20 and there numbers with | |
2094 | more than 32 bits can be represented. */ | |
2095 | sprintf (fhdr.lastmemoff, "%ld", (long) prevoff); | |
2096 | ||
2097 | /* Write out the member table. */ | |
2098 | ||
2099 | BFD_ASSERT (nextoff == bfd_tell (abfd)); | |
2100 | /* XXX This call actually should use %lld (at least on 32-bit | |
2101 | machines) since the fields's width is 20 and there numbers with | |
2102 | more than 32 bits can be represented. */ | |
2103 | sprintf (fhdr.memoff, "%ld", (long) nextoff); | |
2104 | ||
2105 | memset (&ahdr, 0, sizeof ahdr); | |
2106 | /* XXX The next two calls actually should use %lld (at least on 32-bit | |
2107 | machines) since the fields's width is 20 and there numbers with | |
2108 | more than 32 bits can be represented. */ | |
2109 | sprintf (ahdr.size, "%ld", (long) (12 + count * 12 + total_namlen)); | |
2110 | sprintf (ahdr.prevoff, "%ld", (long) prevoff); | |
2111 | sprintf (ahdr.date, "%d", 0); | |
2112 | sprintf (ahdr.uid, "%d", 0); | |
2113 | sprintf (ahdr.gid, "%d", 0); | |
2114 | sprintf (ahdr.mode, "%d", 0); | |
2115 | sprintf (ahdr.namlen, "%d", 0); | |
2116 | ||
2117 | size = (SIZEOF_AR_HDR_BIG | |
2118 | + 12 | |
2119 | + count * 12 | |
2120 | + total_namlen | |
2121 | + SXCOFFARFMAG); | |
2122 | ||
2123 | prevoff = nextoff; | |
2124 | nextoff += size + (size & 1); | |
2125 | ||
2126 | if (makemap && hasobjects) | |
2127 | /* XXX This call actually should use %lld (at least on 32-bit | |
2128 | machines) since the fields's width is 20 and there numbers with | |
2129 | more than 32 bits can be represented. */ | |
2130 | sprintf (ahdr.nextoff, "%ld", (long) nextoff); | |
2131 | else | |
2132 | sprintf (ahdr.nextoff, "%d", 0); | |
2133 | ||
2134 | /* We need spaces, not null bytes, in the header. */ | |
2135 | for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR_BIG; p++) | |
2136 | if (*p == '\0') | |
2137 | *p = ' '; | |
2138 | ||
2139 | if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR_BIG, abfd) != SIZEOF_AR_HDR_BIG | |
2140 | || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) | |
2141 | != SXCOFFARFMAG)) | |
2142 | return false; | |
2143 | ||
2144 | sprintf (decbuf, "%-12ld", (long) count); | |
2145 | if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12) | |
2146 | return false; | |
2147 | for (i = 0; i < count; i++) | |
2148 | { | |
2149 | sprintf (decbuf, "%-12ld", (long) offsets[i]); | |
2150 | if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12) | |
2151 | return false; | |
2152 | } | |
2153 | for (sub = abfd->archive_head; sub != NULL; sub = sub->next) | |
2154 | { | |
2155 | const char *name; | |
2156 | size_t namlen; | |
2157 | ||
2158 | name = normalize_filename (sub); | |
2159 | namlen = strlen (name); | |
2160 | if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1) | |
2161 | return false; | |
2162 | } | |
2163 | if ((size & 1) != 0) | |
2164 | { | |
2165 | bfd_byte b; | |
2166 | ||
2167 | b = '\0'; | |
2168 | if (bfd_write ((PTR) &b, 1, 1, abfd) != 1) | |
2169 | return false; | |
2170 | } | |
2171 | ||
2172 | /* Write out the armap, if appropriate. */ | |
2173 | ||
2174 | if (! makemap || ! hasobjects) | |
2175 | sprintf (fhdr.symoff, "%d", 0); | |
2176 | else | |
2177 | { | |
2178 | BFD_ASSERT (nextoff == bfd_tell (abfd)); | |
2179 | /* XXX This call actually should use %lld (at least on 32-bit | |
2180 | machines) since the fields's width is 20 and there numbers with | |
2181 | more than 32 bits can be represented. */ | |
5ea1af0d GK |
2182 | bfd_ardata (abfd)->tdata = (PTR) &fhdr; |
2183 | if (! _bfd_compute_and_write_armap (abfd, 0)) | |
2184 | return false; | |
2185 | } | |
2186 | ||
2187 | /* Write out the archive file header. */ | |
2188 | ||
2189 | /* We need spaces, not null bytes, in the header. */ | |
2190 | for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR_BIG; p++) | |
2191 | if (*p == '\0') | |
2192 | *p = ' '; | |
2193 | ||
2194 | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | |
2195 | || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR_BIG, 1, abfd) != | |
2196 | SIZEOF_AR_FILE_HDR_BIG)) | |
2197 | return false; | |
2198 | ||
2199 | return true; | |
2200 | } | |
2201 | ||
7f6d05e8 CP |
2202 | boolean |
2203 | _bfd_xcoff_write_archive_contents (abfd) | |
5ea1af0d GK |
2204 | bfd *abfd; |
2205 | { | |
2206 | if (! xcoff_big_format_p (abfd)) | |
2207 | return xcoff_write_archive_contents_old (abfd); | |
2208 | else | |
2209 | return xcoff_write_archive_contents_big (abfd); | |
2210 | } | |
252b5132 RH |
2211 | \f |
2212 | /* We can't use the usual coff_sizeof_headers routine, because AIX | |
2213 | always uses an a.out header. */ | |
2214 | ||
beb1bf64 | 2215 | /*ARGSUSED*/ |
7f6d05e8 | 2216 | int |
252b5132 RH |
2217 | _bfd_xcoff_sizeof_headers (abfd, reloc) |
2218 | bfd *abfd; | |
5f771d47 | 2219 | boolean reloc ATTRIBUTE_UNUSED; |
252b5132 RH |
2220 | { |
2221 | int size; | |
2222 | ||
2223 | size = FILHSZ; | |
2224 | if (xcoff_data (abfd)->full_aouthdr) | |
2225 | size += AOUTSZ; | |
2226 | else | |
2227 | size += SMALL_AOUTSZ; | |
2228 | size += abfd->section_count * SCNHSZ; | |
2229 | return size; | |
2230 | } | |
beb1bf64 TR |
2231 | \f |
2232 | /* Routines to swap information in the XCOFF .loader section. If we | |
2233 | ever need to write an XCOFF loader, this stuff will need to be | |
2234 | moved to another file shared by the linker (which XCOFF calls the | |
2235 | ``binder'') and the loader. */ | |
2236 | ||
2237 | /* Swap in the ldhdr structure. */ | |
2238 | ||
2239 | static void | |
2240 | xcoff_swap_ldhdr_in (abfd, src, dst) | |
2241 | bfd *abfd; | |
2242 | const struct external_ldhdr *src; | |
2243 | struct internal_ldhdr *dst; | |
2244 | { | |
2245 | dst->l_version = bfd_get_32 (abfd, src->l_version); | |
2246 | dst->l_nsyms = bfd_get_32 (abfd, src->l_nsyms); | |
2247 | dst->l_nreloc = bfd_get_32 (abfd, src->l_nreloc); | |
2248 | dst->l_istlen = bfd_get_32 (abfd, src->l_istlen); | |
2249 | dst->l_nimpid = bfd_get_32 (abfd, src->l_nimpid); | |
2250 | dst->l_impoff = bfd_get_32 (abfd, src->l_impoff); | |
2251 | dst->l_stlen = bfd_get_32 (abfd, src->l_stlen); | |
2252 | dst->l_stoff = bfd_get_32 (abfd, src->l_stoff); | |
2253 | } | |
2254 | ||
2255 | /* Swap out the ldhdr structure. */ | |
2256 | ||
2257 | static void | |
2258 | xcoff_swap_ldhdr_out (abfd, src, dst) | |
2259 | bfd *abfd; | |
2260 | const struct internal_ldhdr *src; | |
2261 | struct external_ldhdr *dst; | |
2262 | { | |
2263 | bfd_put_32 (abfd, src->l_version, dst->l_version); | |
2264 | bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms); | |
2265 | bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc); | |
2266 | bfd_put_32 (abfd, src->l_istlen, dst->l_istlen); | |
2267 | bfd_put_32 (abfd, src->l_nimpid, dst->l_nimpid); | |
2268 | bfd_put_32 (abfd, src->l_impoff, dst->l_impoff); | |
2269 | bfd_put_32 (abfd, src->l_stlen, dst->l_stlen); | |
2270 | bfd_put_32 (abfd, src->l_stoff, dst->l_stoff); | |
2271 | } | |
2272 | ||
2273 | /* Swap in the ldsym structure. */ | |
2274 | ||
2275 | static void | |
2276 | xcoff_swap_ldsym_in (abfd, src, dst) | |
2277 | bfd *abfd; | |
2278 | const struct external_ldsym *src; | |
2279 | struct internal_ldsym *dst; | |
2280 | { | |
2281 | if (bfd_get_32 (abfd, src->_l._l_l._l_zeroes) != 0) { | |
2282 | memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN); | |
2283 | } else { | |
2284 | dst->_l._l_l._l_zeroes = 0; | |
2285 | dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->_l._l_l._l_offset); | |
2286 | } | |
2287 | dst->l_value = bfd_get_32 (abfd, src->l_value); | |
2288 | dst->l_scnum = bfd_get_16 (abfd, src->l_scnum); | |
2289 | dst->l_smtype = bfd_get_8 (abfd, src->l_smtype); | |
2290 | dst->l_smclas = bfd_get_8 (abfd, src->l_smclas); | |
2291 | dst->l_ifile = bfd_get_32 (abfd, src->l_ifile); | |
2292 | dst->l_parm = bfd_get_32 (abfd, src->l_parm); | |
2293 | } | |
2294 | ||
2295 | /* Swap out the ldsym structure. */ | |
2296 | ||
2297 | static void | |
2298 | xcoff_swap_ldsym_out (abfd, src, dst) | |
2299 | bfd *abfd; | |
2300 | const struct internal_ldsym *src; | |
2301 | struct external_ldsym *dst; | |
2302 | { | |
2303 | ||
2304 | if (src->_l._l_l._l_zeroes != 0) | |
2305 | memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN); | |
2306 | else | |
2307 | { | |
2308 | bfd_put_32 (abfd, 0, dst->_l._l_l._l_zeroes); | |
2309 | bfd_put_32 (abfd, src->_l._l_l._l_offset, dst->_l._l_l._l_offset); | |
2310 | } | |
2311 | bfd_put_32 (abfd, src->l_value, dst->l_value); | |
2312 | bfd_put_16 (abfd, src->l_scnum, dst->l_scnum); | |
2313 | bfd_put_8 (abfd, src->l_smtype, dst->l_smtype); | |
2314 | bfd_put_8 (abfd, src->l_smclas, dst->l_smclas); | |
2315 | bfd_put_32 (abfd, src->l_ifile, dst->l_ifile); | |
2316 | bfd_put_32 (abfd, src->l_parm, dst->l_parm); | |
2317 | } | |
2318 | ||
2319 | /* Swap in the ldrel structure. */ | |
2320 | ||
2321 | static void | |
2322 | xcoff_swap_ldrel_in (abfd, src, dst) | |
2323 | bfd *abfd; | |
2324 | const struct external_ldrel *src; | |
2325 | struct internal_ldrel *dst; | |
2326 | { | |
2327 | dst->l_vaddr = bfd_get_32 (abfd, src->l_vaddr); | |
2328 | dst->l_symndx = bfd_get_32 (abfd, src->l_symndx); | |
2329 | dst->l_rtype = bfd_get_16 (abfd, src->l_rtype); | |
2330 | dst->l_rsecnm = bfd_get_16 (abfd, src->l_rsecnm); | |
2331 | } | |
2332 | ||
2333 | /* Swap out the ldrel structure. */ | |
2334 | ||
2335 | static void | |
2336 | xcoff_swap_ldrel_out (abfd, src, dst) | |
2337 | bfd *abfd; | |
2338 | const struct internal_ldrel *src; | |
2339 | struct external_ldrel *dst; | |
2340 | { | |
2341 | bfd_put_32 (abfd, src->l_vaddr, dst->l_vaddr); | |
2342 | bfd_put_32 (abfd, src->l_symndx, dst->l_symndx); | |
2343 | bfd_put_16 (abfd, src->l_rtype, dst->l_rtype); | |
2344 | bfd_put_16 (abfd, src->l_rsecnm, dst->l_rsecnm); | |
2345 | } | |
2346 | \f | |
2347 | ||
2348 | ||
2349 | /* This is the relocation function for the RS/6000/POWER/PowerPC. | |
2350 | This is currently the only processor which uses XCOFF; I hope that | |
2351 | will never change. */ | |
2352 | ||
2353 | boolean | |
2354 | xcoff_ppc_relocate_section (output_bfd, info, input_bfd, | |
2355 | input_section, contents, relocs, syms, | |
2356 | sections) | |
2357 | bfd *output_bfd; | |
2358 | struct bfd_link_info *info; | |
2359 | bfd *input_bfd; | |
2360 | asection *input_section; | |
2361 | bfd_byte *contents; | |
2362 | struct internal_reloc *relocs; | |
2363 | struct internal_syment *syms; | |
2364 | asection **sections; | |
2365 | { | |
2366 | struct internal_reloc *rel; | |
2367 | struct internal_reloc *relend; | |
2368 | ||
2369 | rel = relocs; | |
2370 | relend = rel + input_section->reloc_count; | |
2371 | ||
2372 | for (; rel < relend; rel++) | |
2373 | { | |
2374 | long symndx; | |
2375 | struct xcoff_link_hash_entry *h; | |
2376 | struct internal_syment *sym; | |
2377 | bfd_vma addend; | |
2378 | bfd_vma val; | |
2379 | struct reloc_howto_struct howto; | |
2380 | bfd_reloc_status_type rstat; | |
2381 | ||
2382 | /* Relocation type R_REF is a special relocation type which is | |
2383 | merely used to prevent garbage collection from occurring for | |
2384 | the csect including the symbol which it references. */ | |
2385 | if (rel->r_type == R_REF) | |
2386 | continue; | |
2387 | ||
2388 | symndx = rel->r_symndx; | |
2389 | ||
2390 | if (symndx == -1) | |
2391 | { | |
2392 | h = NULL; | |
2393 | sym = NULL; | |
2394 | addend = 0; | |
2395 | } | |
2396 | else | |
2397 | { | |
2398 | h = obj_xcoff_sym_hashes (input_bfd)[symndx]; | |
2399 | sym = syms + symndx; | |
2400 | addend = - sym->n_value; | |
2401 | ||
2402 | } | |
2403 | ||
2404 | /* We build the howto information on the fly. */ | |
2405 | ||
2406 | howto.type = rel->r_type; | |
2407 | howto.rightshift = 0; | |
2408 | howto.size = 2; | |
2409 | howto.bitsize = (rel->r_size & 0x1f) + 1; | |
2410 | howto.pc_relative = false; | |
2411 | howto.bitpos = 0; | |
2412 | if ((rel->r_size & 0x80) != 0) | |
2413 | howto.complain_on_overflow = complain_overflow_signed; | |
2414 | else | |
2415 | howto.complain_on_overflow = complain_overflow_bitfield; | |
2416 | howto.special_function = NULL; | |
2417 | howto.name = "internal"; | |
2418 | howto.partial_inplace = true; | |
2419 | if (howto.bitsize == 32) | |
2420 | howto.src_mask = howto.dst_mask = 0xffffffff; | |
2421 | else | |
2422 | { | |
2423 | howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1; | |
2424 | if (howto.bitsize == 16) | |
2425 | howto.size = 1; | |
2426 | } | |
2427 | howto.pcrel_offset = false; | |
2428 | ||
2429 | val = 0; | |
2430 | ||
2431 | if (h == NULL) | |
2432 | { | |
2433 | asection *sec; | |
2434 | ||
2435 | if (symndx == -1) | |
2436 | { | |
2437 | sec = bfd_abs_section_ptr; | |
2438 | val = 0; | |
2439 | } | |
2440 | else | |
2441 | { | |
2442 | sec = sections[symndx]; | |
2443 | /* Hack to make sure we use the right TOC anchor value | |
2444 | if this reloc is against the TOC anchor. */ | |
2445 | ||
2446 | if (sec->name[3] == '0' | |
2447 | && strcmp (sec->name, ".tc0") == 0) { | |
2448 | ||
2449 | val = xcoff_data (output_bfd)->toc; | |
2450 | } else { | |
2451 | ||
2452 | val = (sec->output_section->vma | |
2453 | + sec->output_offset | |
2454 | + sym->n_value | |
2455 | - sec->vma); | |
2456 | } | |
2457 | ||
2458 | } | |
2459 | } | |
2460 | else | |
2461 | { | |
2462 | if (h->root.type == bfd_link_hash_defined | |
2463 | || h->root.type == bfd_link_hash_defweak) | |
2464 | { | |
2465 | asection *sec; | |
2466 | ||
2467 | sec = h->root.u.def.section; | |
2468 | val = (h->root.u.def.value | |
2469 | + sec->output_section->vma | |
2470 | + sec->output_offset); | |
2471 | } | |
2472 | else if (h->root.type == bfd_link_hash_common) | |
2473 | { | |
2474 | asection *sec; | |
2475 | ||
2476 | sec = h->root.u.c.p->section; | |
2477 | val = (sec->output_section->vma | |
2478 | + sec->output_offset); | |
2479 | } | |
2480 | else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0 | |
2481 | || (h->flags & XCOFF_IMPORT) != 0) | |
2482 | { | |
2483 | /* Every symbol in a shared object is defined somewhere. */ | |
2484 | val = 0; | |
2485 | } | |
2486 | else if (! info->relocateable) | |
2487 | { | |
2488 | if (! ((*info->callbacks->undefined_symbol) | |
2489 | (info, h->root.root.string, input_bfd, input_section, | |
2490 | rel->r_vaddr - input_section->vma, true))) | |
2491 | return false; | |
2492 | ||
2493 | /* Don't try to process the reloc. It can't help, and | |
2494 | it may generate another error. */ | |
2495 | continue; | |
2496 | } | |
2497 | } | |
2498 | ||
2499 | /* I took the relocation type definitions from two documents: | |
2500 | the PowerPC AIX Version 4 Application Binary Interface, First | |
2501 | Edition (April 1992), and the PowerOpen ABI, Big-Endian | |
2502 | 32-Bit Hardware Implementation (June 30, 1994). Differences | |
2503 | between the documents are noted below. */ | |
2504 | ||
2505 | switch (rel->r_type) | |
2506 | { | |
2507 | case R_RTB: | |
2508 | case R_RRTBI: | |
2509 | case R_RRTBA: | |
2510 | /* These relocs are defined by the PowerPC ABI to be | |
2511 | relative branches which use half of the difference | |
2512 | between the symbol and the program counter. I can't | |
2513 | quite figure out when this is useful. These relocs are | |
2514 | not defined by the PowerOpen ABI. */ | |
2515 | default: | |
2516 | (*_bfd_error_handler) | |
2517 | (_("%s: unsupported relocation type 0x%02x"), | |
2518 | bfd_get_filename (input_bfd), (unsigned int) rel->r_type); | |
2519 | bfd_set_error (bfd_error_bad_value); | |
2520 | return false; | |
2521 | case R_POS: | |
2522 | /* Simple positive relocation. */ | |
2523 | break; | |
2524 | case R_NEG: | |
2525 | /* Simple negative relocation. */ | |
2526 | val = - val; | |
2527 | break; | |
2528 | case R_REL: | |
2529 | /* Simple PC relative relocation. */ | |
2530 | howto.pc_relative = true; | |
2531 | break; | |
2532 | case R_TOC: | |
2533 | /* TOC relative relocation. The value in the instruction in | |
2534 | the input file is the offset from the input file TOC to | |
2535 | the desired location. We want the offset from the final | |
2536 | TOC to the desired location. We have: | |
2537 | isym = iTOC + in | |
2538 | iinsn = in + o | |
2539 | osym = oTOC + on | |
2540 | oinsn = on + o | |
2541 | so we must change insn by on - in. | |
2542 | */ | |
2543 | case R_GL: | |
2544 | /* Global linkage relocation. The value of this relocation | |
2545 | is the address of the entry in the TOC section. */ | |
2546 | case R_TCL: | |
2547 | /* Local object TOC address. I can't figure out the | |
2548 | difference between this and case R_GL. */ | |
2549 | case R_TRL: | |
2550 | /* TOC relative relocation. A TOC relative load instruction | |
2551 | which may be changed to a load address instruction. | |
2552 | FIXME: We don't currently implement this optimization. */ | |
2553 | case R_TRLA: | |
2554 | /* TOC relative relocation. This is a TOC relative load | |
2555 | address instruction which may be changed to a load | |
2556 | instruction. FIXME: I don't know if this is the correct | |
2557 | implementation. */ | |
2558 | if (h != NULL && h->smclas != XMC_TD) | |
2559 | { | |
2560 | if (h->toc_section == NULL) | |
2561 | { | |
2562 | (*_bfd_error_handler) | |
2563 | (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"), | |
2564 | bfd_get_filename (input_bfd), rel->r_vaddr, | |
2565 | h->root.root.string); | |
2566 | bfd_set_error (bfd_error_bad_value); | |
2567 | return false; | |
2568 | } | |
2569 | ||
2570 | BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0); | |
2571 | val = (h->toc_section->output_section->vma | |
2572 | + h->toc_section->output_offset); | |
2573 | } | |
2574 | ||
2575 | val = ((val - xcoff_data (output_bfd)->toc) | |
2576 | - (sym->n_value - xcoff_data (input_bfd)->toc)); | |
2577 | addend = 0; | |
2578 | break; | |
2579 | case R_BA: | |
2580 | /* Absolute branch. We don't want to mess with the lower | |
2581 | two bits of the instruction. */ | |
2582 | case R_CAI: | |
2583 | /* The PowerPC ABI defines this as an absolute call which | |
2584 | may be modified to become a relative call. The PowerOpen | |
2585 | ABI does not define this relocation type. */ | |
2586 | case R_RBA: | |
2587 | /* Absolute branch which may be modified to become a | |
2588 | relative branch. */ | |
2589 | case R_RBAC: | |
2590 | /* The PowerPC ABI defines this as an absolute branch to a | |
2591 | fixed address which may be modified to an absolute branch | |
2592 | to a symbol. The PowerOpen ABI does not define this | |
2593 | relocation type. */ | |
2594 | case R_RBRC: | |
2595 | /* The PowerPC ABI defines this as an absolute branch to a | |
2596 | fixed address which may be modified to a relative branch. | |
2597 | The PowerOpen ABI does not define this relocation type. */ | |
2598 | howto.src_mask &= ~3; | |
2599 | howto.dst_mask = howto.src_mask; | |
2600 | break; | |
2601 | case R_BR: | |
2602 | /* Relative branch. We don't want to mess with the lower | |
2603 | two bits of the instruction. */ | |
2604 | case R_CREL: | |
2605 | /* The PowerPC ABI defines this as a relative call which may | |
2606 | be modified to become an absolute call. The PowerOpen | |
2607 | ABI does not define this relocation type. */ | |
2608 | case R_RBR: | |
2609 | /* A relative branch which may be modified to become an | |
2610 | absolute branch. FIXME: We don't implement this, | |
2611 | although we should for symbols of storage mapping class | |
2612 | XMC_XO. */ | |
2613 | howto.pc_relative = true; | |
2614 | howto.src_mask &= ~3; | |
2615 | howto.dst_mask = howto.src_mask; | |
2616 | break; | |
2617 | case R_RL: | |
2618 | /* The PowerPC AIX ABI describes this as a load which may be | |
2619 | changed to a load address. The PowerOpen ABI says this | |
2620 | is the same as case R_POS. */ | |
2621 | break; | |
2622 | case R_RLA: | |
2623 | /* The PowerPC AIX ABI describes this as a load address | |
2624 | which may be changed to a load. The PowerOpen ABI says | |
2625 | this is the same as R_POS. */ | |
2626 | break; | |
2627 | } | |
2628 | ||
2629 | /* If we see an R_BR or R_RBR reloc which is jumping to global | |
2630 | linkage code, and it is followed by an appropriate cror nop | |
2631 | instruction, we replace the cror with lwz r2,20(r1). This | |
2632 | restores the TOC after the glink code. Contrariwise, if the | |
2633 | call is followed by a lwz r2,20(r1), but the call is not | |
2634 | going to global linkage code, we can replace the load with a | |
2635 | cror. */ | |
2636 | if ((rel->r_type == R_BR || rel->r_type == R_RBR) | |
2637 | && h != NULL | |
2638 | && h->root.type == bfd_link_hash_defined | |
2639 | && (rel->r_vaddr - input_section->vma + 8 | |
2640 | <= input_section->_cooked_size)) | |
2641 | { | |
2642 | bfd_byte *pnext; | |
2643 | unsigned long next; | |
2644 | ||
2645 | pnext = contents + (rel->r_vaddr - input_section->vma) + 4; | |
2646 | next = bfd_get_32 (input_bfd, pnext); | |
2647 | ||
2648 | /* The _ptrgl function is magic. It is used by the AIX | |
2649 | compiler to call a function through a pointer. */ | |
2650 | if (h->smclas == XMC_GL | |
2651 | || strcmp (h->root.root.string, "._ptrgl") == 0) | |
2652 | { | |
2653 | if (next == 0x4def7b82 /* cror 15,15,15 */ | |
2654 | || next == 0x4ffffb82 /* cror 31,31,31 */ | |
2655 | || next == 0x60000000) /* ori r0,r0,0 */ | |
2656 | bfd_put_32 (input_bfd, 0x80410014, pnext); /* lwz r1,20(r1) */ | |
2657 | } | |
2658 | else | |
2659 | { | |
2660 | if (next == 0x80410014) /* lwz r1,20(r1) */ | |
2661 | bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */ | |
2662 | } | |
2663 | } | |
2664 | ||
2665 | /* A PC relative reloc includes the section address. */ | |
2666 | if (howto.pc_relative) | |
2667 | addend += input_section->vma; | |
2668 | ||
2669 | rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section, | |
2670 | contents, | |
2671 | rel->r_vaddr - input_section->vma, | |
2672 | val, addend); | |
2673 | ||
2674 | switch (rstat) | |
2675 | { | |
2676 | default: | |
2677 | abort (); | |
2678 | case bfd_reloc_ok: | |
2679 | break; | |
2680 | case bfd_reloc_overflow: | |
2681 | { | |
2682 | const char *name; | |
2683 | char buf[SYMNMLEN + 1]; | |
2684 | char howto_name[10]; | |
2685 | ||
2686 | if (symndx == -1) | |
2687 | name = "*ABS*"; | |
2688 | else if (h != NULL) | |
2689 | name = h->root.root.string; | |
2690 | else | |
2691 | { | |
2692 | ||
2693 | name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); | |
2694 | ||
2695 | if (name == NULL) | |
2696 | return false; | |
2697 | } | |
2698 | sprintf (howto_name, "0x%02x", rel->r_type); | |
2699 | ||
2700 | if (! ((*info->callbacks->reloc_overflow) | |
2701 | (info, name, howto_name, (bfd_vma) 0, input_bfd, | |
2702 | input_section, rel->r_vaddr - input_section->vma))) | |
2703 | return false; | |
2704 | } | |
2705 | } | |
2706 | } | |
2707 | ||
2708 | return true; | |
2709 | } | |
2710 | ||
2711 | static boolean | |
2712 | _bfd_xcoff_put_ldsymbol_name (abfd, ldinfo, ldsym, name) | |
2713 | bfd *abfd ATTRIBUTE_UNUSED; | |
2714 | struct xcoff_loader_info *ldinfo; | |
2715 | struct internal_ldsym *ldsym; | |
2716 | const char *name; | |
2717 | { | |
2718 | size_t len; | |
2719 | len = strlen (name); | |
2720 | ||
2721 | if (len <= SYMNMLEN) | |
2722 | strncpy (ldsym->_l._l_name, name, SYMNMLEN); | |
2723 | else | |
2724 | { | |
2725 | if (ldinfo->string_size + len + 3 > ldinfo->string_alc) | |
2726 | { | |
2727 | size_t newalc; | |
2728 | bfd_byte *newstrings; | |
2729 | ||
2730 | newalc = ldinfo->string_alc * 2; | |
2731 | if (newalc == 0) | |
2732 | newalc = 32; | |
2733 | while (ldinfo->string_size + len + 3 > newalc) | |
2734 | newalc *= 2; | |
2735 | ||
2736 | newstrings = ((bfd_byte *) | |
2737 | bfd_realloc ((PTR) ldinfo->strings, newalc)); | |
2738 | if (newstrings == NULL) | |
2739 | { | |
2740 | ldinfo->failed = true; | |
2741 | return false; | |
2742 | } | |
2743 | ldinfo->string_alc = newalc; | |
2744 | ldinfo->strings = newstrings; | |
2745 | } | |
2746 | ||
2747 | bfd_put_16 (ldinfo->output_bfd, len + 1, | |
2748 | ldinfo->strings + ldinfo->string_size); | |
2749 | strcpy (ldinfo->strings + ldinfo->string_size + 2, name); | |
2750 | ldsym->_l._l_l._l_zeroes = 0; | |
2751 | ldsym->_l._l_l._l_offset = ldinfo->string_size + 2; | |
2752 | ldinfo->string_size += len + 3; | |
2753 | } | |
2754 | ||
2755 | return true; | |
2756 | } | |
2757 | ||
2758 | static boolean | |
2759 | _bfd_xcoff_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab, | |
2760 | struct internal_syment *sym, | |
2761 | const char *name) { | |
2762 | ||
2763 | if (strlen (name) <= SYMNMLEN) { | |
2764 | strncpy (sym->_n._n_name, name, SYMNMLEN); | |
2765 | } else { | |
2766 | boolean hash; | |
2767 | bfd_size_type indx; | |
2768 | ||
2769 | hash = true; | |
2770 | if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0) | |
2771 | hash = false; | |
2772 | indx = _bfd_stringtab_add (strtab, name, hash, false); | |
2773 | if (indx == (bfd_size_type) -1) | |
2774 | return false; | |
2775 | sym->_n._n_n._n_zeroes = 0; | |
2776 | sym->_n._n_n._n_offset = STRING_SIZE_SIZE + indx; | |
2777 | } | |
2778 | return true; | |
2779 | } | |
2780 | ||
2781 | static asection * | |
2782 | xcoff_create_csect_from_smclas (abfd, aux, symbol_name) | |
2783 | bfd *abfd; | |
2784 | union internal_auxent *aux; | |
2785 | char *symbol_name; | |
2786 | { | |
2787 | ||
2788 | asection *return_value = NULL; | |
2789 | ||
2790 | /* | |
2791 | * .sv64 = x_smclas == 17 | |
2792 | * This is an invalid csect for 32 bit apps. | |
2793 | */ | |
2794 | static const char *names[19] = { | |
2795 | ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo", | |
2796 | ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0", | |
2797 | ".td", NULL, ".sv3264" | |
2798 | }; | |
2799 | ||
2800 | if ((19 >= aux->x_csect.x_smclas) && | |
2801 | (NULL != names[aux->x_csect.x_smclas])) { | |
2802 | ||
2803 | return_value = bfd_make_section_anyway | |
2804 | (abfd, names[aux->x_csect.x_smclas]); | |
2805 | ||
2806 | ||
2807 | } else { | |
2808 | (*_bfd_error_handler) | |
2809 | (_("%s: symbol `%s' has unrecognized smclas %d"), | |
2810 | bfd_get_filename (abfd), symbol_name, aux->x_csect.x_smclas); | |
2811 | bfd_set_error (bfd_error_bad_value); | |
2812 | } | |
2813 | ||
2814 | return return_value; | |
2815 | } | |
2816 | ||
2817 | boolean | |
2818 | xcoff_is_lineno_count_overflow (abfd, value) | |
2819 | bfd *abfd ATTRIBUTE_UNUSED; | |
2820 | bfd_vma value; | |
2821 | { | |
2822 | if (0xffff <= value) { | |
2823 | return true; | |
2824 | } | |
2825 | return false; | |
2826 | } | |
2827 | ||
2828 | boolean | |
2829 | xcoff_is_reloc_count_overflow (abfd, value) | |
2830 | bfd *abfd ATTRIBUTE_UNUSED; | |
2831 | bfd_vma value; | |
2832 | { | |
2833 | if (0xffff <= value) { | |
2834 | return true; | |
2835 | } | |
2836 | return false; | |
2837 | } | |
2838 | ||
2839 | bfd_vma | |
2840 | xcoff_loader_symbol_offset (abfd, ldhdr) | |
2841 | bfd *abfd; | |
2842 | struct internal_ldhdr *ldhdr ATTRIBUTE_UNUSED; | |
2843 | { | |
2844 | return bfd_xcoff_ldhdrsz(abfd); | |
2845 | } | |
2846 | ||
2847 | bfd_vma | |
2848 | xcoff_loader_reloc_offset (abfd, ldhdr) | |
2849 | bfd *abfd; | |
2850 | struct internal_ldhdr *ldhdr; | |
2851 | { | |
2852 | return bfd_xcoff_ldhdrsz(abfd) + | |
2853 | (ldhdr->l_nsyms * bfd_xcoff_ldsymsz(abfd)); | |
2854 | } | |
2855 | ||
2856 | ||
2857 | static reloc_howto_type xcoff_dynamic_reloc = | |
2858 | HOWTO (0, /* type */ | |
2859 | 0, /* rightshift */ | |
2860 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
2861 | 32, /* bitsize */ | |
2862 | false, /* pc_relative */ | |
2863 | 0, /* bitpos */ | |
2864 | complain_overflow_bitfield, /* complain_on_overflow */ | |
2865 | 0, /* special_function */ | |
2866 | "R_POS", /* name */ | |
2867 | true, /* partial_inplace */ | |
2868 | 0xffffffff, /* src_mask */ | |
2869 | 0xffffffff, /* dst_mask */ | |
2870 | false); /* pcrel_offset */ | |
2871 | ||
2872 | /* | |
2873 | * glink | |
2874 | * | |
2875 | * The first word of global linkage code must be modified by filling in | |
2876 | * the correct TOC offset. | |
2877 | */ | |
2878 | static unsigned long xcoff_glink_code[9] = | |
2879 | { | |
2880 | 0x81820000, /* lwz r12,0(r2) */ | |
2881 | 0x90410014, /* stw r2,20(r1) */ | |
2882 | 0x800c0000, /* lwz r0,0(r12) */ | |
2883 | 0x804c0004, /* lwz r2,4(r12) */ | |
2884 | 0x7c0903a6, /* mtctr r0 */ | |
2885 | 0x4e800420, /* bctr */ | |
2886 | 0x00000000, /* start of traceback table */ | |
2887 | 0x000c8000, /* traceback table */ | |
2888 | 0x00000000, /* traceback table */ | |
2889 | }; | |
2890 | ||
2891 | ||
2892 | static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = | |
2893 | { | |
2894 | { /* COFF backend, defined in libcoff.h */ | |
2895 | _bfd_xcoff_swap_aux_in, /* _bfd_coff_swap_aux_in */ | |
2896 | _bfd_xcoff_swap_sym_in, /* _bfd_coff_swap_sym_in */ | |
2897 | coff_swap_lineno_in, /* _bfd_coff_swap_lineno_in */ | |
2898 | _bfd_xcoff_swap_aux_out, /* _bfd_swap_aux_out */ | |
2899 | _bfd_xcoff_swap_sym_out, /* _bfd_swap_sym_out */ | |
2900 | coff_swap_lineno_out, /* _bfd_swap_lineno_out */ | |
2901 | coff_swap_reloc_out, /* _bfd_swap_reloc_out */ | |
2902 | coff_swap_filehdr_out, /* _bfd_swap_filehdr_out */ | |
2903 | coff_swap_aouthdr_out, /* _bfd_swap_aouthdr_out */ | |
2904 | coff_swap_scnhdr_out, /* _bfd_swap_scnhdr_out */ | |
2905 | FILHSZ, /* _bfd_filhsz */ | |
2906 | AOUTSZ, /* _bfd_aoutsz */ | |
2907 | SCNHSZ, /* _bfd_scnhsz */ | |
2908 | SYMESZ, /* _bfd_symesz */ | |
2909 | AUXESZ, /* _bfd_auxesz */ | |
2910 | RELSZ, /* _bfd_relsz */ | |
2911 | LINESZ, /* _bfd_linesz */ | |
2912 | FILNMLEN, /* _bfd_filnmlen */ | |
2913 | true, /* _bfd_coff_long_filenames */ | |
2914 | false, /* _bfd_coff_long_section_names */ | |
2915 | (3), /* _bfd_coff_default_section_alignment_power */ | |
2916 | false, /* _bfd_coff_force_symnames_in_strings */ | |
2917 | 2, /* _bfd_coff_debug_string_prefix_length */ | |
2918 | coff_swap_filehdr_in, /* _bfd_coff_swap_filehdr_in */ | |
2919 | coff_swap_aouthdr_in, /* _bfd_swap_aouthdr_in */ | |
2920 | coff_swap_scnhdr_in, /* _bfd_swap_scnhdr_in */ | |
2921 | coff_swap_reloc_in, /* _bfd_reloc_in */ | |
2922 | coff_bad_format_hook, /* _bfd_bad_format_hook */ | |
2923 | coff_set_arch_mach_hook, /* _bfd_set_arch_mach_hook */ | |
2924 | coff_mkobject_hook, /* _bfd_mkobject_hook */ | |
2925 | styp_to_sec_flags, /* _bfd_syp_to_sec_flags */ | |
2926 | coff_set_alignment_hook, /* _bfd_set_alignment_hook */ | |
2927 | coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */ | |
2928 | symname_in_debug_hook, /* _coff_symname_in_debug_hook */ | |
2929 | coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */ | |
2930 | coff_print_aux, /* bfd_coff_print_aux */ | |
2931 | dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */ | |
2932 | dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */ | |
2933 | NULL, /* bfd_coff_sym_is_global */ | |
2934 | /* _bfd_coff_compute_section_file_positions */ | |
2935 | coff_compute_section_file_positions, | |
2936 | NULL , /* _bfd_coff_start_final_link */ | |
2937 | xcoff_ppc_relocate_section, /* _bfd_coff_relocate_section */ | |
2938 | coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */ | |
2939 | NULL , /* _bfd_coff_addust_symndx */ | |
2940 | _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */ | |
2941 | coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */ | |
2942 | coff_final_link_postscript /* _bfd_coff_final_link_postscript */ | |
2943 | }, | |
2944 | ||
2945 | 0x01DF, /* magic number */ | |
2946 | bfd_arch_rs6000, /* architecture */ | |
2947 | bfd_mach_rs6k, /* machine */ | |
2948 | ||
2949 | ||
2950 | /* function pointers to xcoff specific swap routines */ | |
2951 | xcoff_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */ | |
2952 | xcoff_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */ | |
2953 | xcoff_swap_ldsym_in, /* _xcoff_swap_ldsym_in */ | |
2954 | xcoff_swap_ldsym_out, /* _xcoff_swap_ldsym_out */ | |
2955 | xcoff_swap_ldrel_in, /* _xcoff_swap_ldrel_in */ | |
2956 | xcoff_swap_ldrel_out, /* _xcoff_swap_ldrel_out */ | |
2957 | ||
2958 | /* sizes */ | |
2959 | LDHDRSZ, /* _xcoff_ldhdrsz */ | |
2960 | LDSYMSZ, /* _xcoff_ldsymsz */ | |
2961 | LDRELSZ, /* _xcoff_ldrelsz */ | |
2962 | 12, /* _xcoff_function_descriptor_size */ | |
2963 | SMALL_AOUTSZ, /* _xcoff_small_aout_header_size */ | |
2964 | ||
2965 | /* versions */ | |
2966 | 1, /* _xcoff_ldhdr_version */ | |
2967 | ||
2968 | /* xcoff vs xcoff64 putting symbol names */ | |
2969 | _bfd_xcoff_put_symbol_name, /* _xcoff_put_symbol_name */ | |
2970 | _bfd_xcoff_put_ldsymbol_name, /* _xcoff_put_ldsymbol_name */ | |
2971 | ||
2972 | &xcoff_dynamic_reloc, /* dynamic reloc howto */ | |
2973 | ||
2974 | xcoff_create_csect_from_smclas, /* _xcoff_create_csect_from_smclas */ | |
2975 | ||
2976 | /* lineno and reloc count overflow */ | |
2977 | xcoff_is_lineno_count_overflow, | |
2978 | xcoff_is_reloc_count_overflow, | |
2979 | ||
2980 | xcoff_loader_symbol_offset, | |
2981 | xcoff_loader_reloc_offset, | |
2982 | ||
2983 | /* glink */ | |
2984 | &xcoff_glink_code[0], | |
2985 | (36), /* _xcoff_glink_size */ | |
2986 | ||
2987 | }; | |
2988 | ||
2989 | /* The transfer vector that leads the outside world to all of the above. */ | |
2990 | const bfd_target rs6000coff_vec = | |
2991 | { | |
2992 | "aixcoff-rs6000", | |
2993 | bfd_target_xcoff_flavour, | |
2994 | BFD_ENDIAN_BIG, /* data byte order is big */ | |
2995 | BFD_ENDIAN_BIG, /* header byte order is big */ | |
2996 | ||
2997 | (HAS_RELOC | EXEC_P | /* object flags */ | |
2998 | HAS_LINENO | HAS_DEBUG | DYNAMIC | | |
2999 | HAS_SYMS | HAS_LOCALS | WP_TEXT), | |
3000 | ||
3001 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
3002 | 0, /* leading char */ | |
3003 | '/', /* ar_pad_char */ | |
3004 | 15, /* ar_max_namelen??? FIXMEmgo */ | |
3005 | ||
3006 | /* data */ | |
3007 | bfd_getb64, /* bfd_getx64 */ | |
3008 | bfd_getb_signed_64, /* bfd_getx_signed_64 */ | |
3009 | bfd_putb64, /* bfd_putx64 */ | |
3010 | bfd_getb32, /* bfd_getx32 */ | |
3011 | bfd_getb_signed_32, /* bfd_getx_signed_32 */ | |
3012 | bfd_putb32, /* bfd_putx32 */ | |
3013 | bfd_getb16, /* bfd_getx16 */ | |
3014 | bfd_getb_signed_16, /* bfd_getx_signed_16 */ | |
3015 | bfd_putb16, /* bfd_putx16 */ | |
3016 | ||
3017 | /* hdrs */ | |
3018 | bfd_getb64, /* bfd_h_getx64 */ | |
3019 | bfd_getb_signed_64, /* bfd_h_getx_signed_64 */ | |
3020 | bfd_putb64, /* bfd_h_putx64 */ | |
3021 | bfd_getb32, /* bfd_h_getx32 */ | |
3022 | bfd_getb_signed_32, /* bfd_h_getx_signed_32 */ | |
3023 | bfd_putb32, /* bfd_h_putx32 */ | |
3024 | bfd_getb16, /* bfd_h_getx16 */ | |
3025 | bfd_getb_signed_16, /* bfd_h_getx_signed_16 */ | |
3026 | bfd_putb16, /* bfd_h_putx16 */ | |
3027 | ||
3028 | { /* bfd_check_format */ | |
3029 | _bfd_dummy_target, | |
3030 | coff_object_p, | |
3031 | _bfd_xcoff_archive_p, | |
3032 | CORE_FILE_P | |
3033 | }, | |
3034 | ||
3035 | { /* bfd_set_format */ | |
3036 | bfd_false, | |
3037 | coff_mkobject, | |
3038 | _bfd_generic_mkarchive, | |
3039 | bfd_false | |
3040 | }, | |
3041 | ||
3042 | {/* bfd_write_contents */ | |
3043 | bfd_false, | |
3044 | coff_write_object_contents, | |
3045 | _bfd_xcoff_write_archive_contents, | |
3046 | bfd_false | |
3047 | }, | |
3048 | ||
3049 | /* Generic */ | |
3050 | bfd_true, /* _close_and_cleanup */ | |
3051 | bfd_true, /* _bfd_free_cached_info */ | |
3052 | coff_new_section_hook, /* _new_section_hook */ | |
3053 | _bfd_generic_get_section_contents, /* _bfd_get_section_contents */ | |
3054 | /* _bfd_get_section_contents_in_window */ | |
3055 | _bfd_generic_get_section_contents_in_window, | |
3056 | ||
3057 | /* Copy */ | |
3058 | _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */ | |
3059 | /* _bfd_merge_private_bfd_data */ | |
3060 | ((boolean (*) (bfd *, bfd *)) bfd_true), | |
3061 | /* _bfd_copy_pivate_section_data */ | |
3062 | ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), | |
3063 | /* _bfd_copy_private_symbol_data */ | |
3064 | ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), | |
3065 | ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */ | |
3066 | ((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */ | |
3067 | ||
3068 | /* Core */ | |
b55039f4 L |
3069 | coff_core_file_failing_command, /* _core_file_failing_command */ |
3070 | coff_core_file_failing_signal, /* _core_file_failing_signal */ | |
beb1bf64 | 3071 | /* _core_file_matches_executable_p */ |
b55039f4 | 3072 | coff_core_file_matches_executable_p, |
beb1bf64 TR |
3073 | |
3074 | /* Archive */ | |
3075 | _bfd_xcoff_slurp_armap, /* _slurp_armap */ | |
3076 | /* XCOFF archives do not have | |
3077 | anything which corresponds to | |
3078 | an extended name table. */ | |
3079 | bfd_false, /* _slurp_extended_name_table */ | |
3080 | /* _construct_extended_name_table */ | |
3081 | ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false), | |
3082 | bfd_dont_truncate_arname, /* _truncate_arname */ | |
3083 | _bfd_xcoff_write_armap, /* _write_armap */ | |
3084 | _bfd_xcoff_read_ar_hdr, /* _read_ar_hdr */ | |
3085 | _bfd_xcoff_openr_next_archived_file, /* _openr_next_archived_file */ | |
3086 | _bfd_generic_get_elt_at_index, /* _get_elt_at_index */ | |
3087 | _bfd_xcoff_generic_stat_arch_elt, /* _generic_dtat_arch_elt */ | |
3088 | /* XCOFF archives do not have | |
3089 | a timestamp. */ | |
3090 | bfd_true, /* _update_armap_timestamp */ | |
3091 | ||
3092 | /* Symbols */ | |
3093 | coff_get_symtab_upper_bound, /* _get_symtab_upper_bound */ | |
3094 | coff_get_symtab, /* _get_symtab */ | |
3095 | coff_make_empty_symbol, /* _make_empty_symbol */ | |
3096 | coff_print_symbol, /* _print_symbol */ | |
3097 | coff_get_symbol_info, /* _get_symbol_info */ | |
3098 | _bfd_xcoff_is_local_label_name, /* _bfd_is_local_label_name */ | |
3099 | coff_get_lineno, /* _get_lineno */ | |
3100 | coff_find_nearest_line, /* _find_nearest_line */ | |
3101 | coff_bfd_make_debug_symbol, /* _bfd_make_debug_symbol */ | |
3102 | _bfd_generic_read_minisymbols, /* _read_minisymbols */ | |
3103 | _bfd_generic_minisymbol_to_symbol, /* _minsymbol_to_symbol */ | |
3104 | ||
3105 | /* Reloc */ | |
3106 | coff_get_reloc_upper_bound, /* _get_reloc_upper_bound */ | |
3107 | coff_canonicalize_reloc, /* _cononicalize_reloc */ | |
3108 | _bfd_xcoff_reloc_type_lookup, /* _bfd_reloc_type_lookup */ | |
3109 | ||
3110 | /* Write */ | |
3111 | coff_set_arch_mach, /* _set_arch_mach */ | |
3112 | coff_set_section_contents, /* _set_section_contents */ | |
3113 | ||
3114 | /* Link */ | |
3115 | _bfd_xcoff_sizeof_headers, /* _sizeof_headers */ | |
3116 | /* _bfd_get_relocated_section_contents */ | |
3117 | bfd_generic_get_relocated_section_contents, | |
3118 | bfd_generic_relax_section, /* _bfd_relax_section */ | |
3119 | _bfd_xcoff_bfd_link_hash_table_create, /* _bfd_link_hash_table_create */ | |
3120 | _bfd_xcoff_bfd_link_add_symbols, /* _bfd_link_add_symbols */ | |
3121 | _bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */ | |
3122 | _bfd_generic_link_split_section, /* _bfd_link_split_section */ | |
3123 | bfd_generic_gc_sections, /* _bfd_gc_sections */ | |
3124 | bfd_generic_merge_sections, /* _bfd_merge_sections */ | |
3125 | ||
3126 | /* Dynamic */ | |
3127 | /* _get_dynamic_symtab_upper_bound */ | |
3128 | _bfd_xcoff_get_dynamic_symtab_upper_bound, | |
3129 | _bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */ | |
3130 | _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */ | |
3131 | _bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */ | |
3132 | ||
3133 | /* Opposite endian version, none exists */ | |
3134 | NULL, | |
3135 | ||
3136 | /* back end data */ | |
3137 | (void *) &bfd_xcoff_backend_data, | |
3138 | }; | |
3139 | ||
3140 | /* | |
3141 | * xcoff-powermac target | |
3142 | * Old target. | |
3143 | * Only difference between this target and the rs6000 target is the | |
3144 | * the default architecture and machine type used in coffcode.h | |
3145 | * | |
3146 | * PowerPC Macs use the same magic numbers as RS/6000 | |
3147 | * (because that's how they were bootstrapped originally), | |
3148 | * but they are always PowerPC architecture. | |
3149 | */ | |
3150 | static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = | |
3151 | { | |
3152 | { /* COFF backend, defined in libcoff.h */ | |
3153 | _bfd_xcoff_swap_aux_in, /* _bfd_coff_swap_aux_in */ | |
3154 | _bfd_xcoff_swap_sym_in, /* _bfd_coff_swap_sym_in */ | |
3155 | coff_swap_lineno_in, /* _bfd_coff_swap_lineno_in */ | |
3156 | _bfd_xcoff_swap_aux_out, /* _bfd_swap_aux_out */ | |
3157 | _bfd_xcoff_swap_sym_out, /* _bfd_swap_sym_out */ | |
3158 | coff_swap_lineno_out, /* _bfd_swap_lineno_out */ | |
3159 | coff_swap_reloc_out, /* _bfd_swap_reloc_out */ | |
3160 | coff_swap_filehdr_out, /* _bfd_swap_filehdr_out */ | |
3161 | coff_swap_aouthdr_out, /* _bfd_swap_aouthdr_out */ | |
3162 | coff_swap_scnhdr_out, /* _bfd_swap_scnhdr_out */ | |
3163 | FILHSZ, /* _bfd_filhsz */ | |
3164 | AOUTSZ, /* _bfd_aoutsz */ | |
3165 | SCNHSZ, /* _bfd_scnhsz */ | |
3166 | SYMESZ, /* _bfd_symesz */ | |
3167 | AUXESZ, /* _bfd_auxesz */ | |
3168 | RELSZ, /* _bfd_relsz */ | |
3169 | LINESZ, /* _bfd_linesz */ | |
3170 | FILNMLEN, /* _bfd_filnmlen */ | |
3171 | true, /* _bfd_coff_long_filenames */ | |
3172 | false, /* _bfd_coff_long_section_names */ | |
3173 | (3), /* _bfd_coff_default_section_alignment_power */ | |
3174 | false, /* _bfd_coff_force_symnames_in_strings */ | |
3175 | 2, /* _bfd_coff_debug_string_prefix_length */ | |
3176 | coff_swap_filehdr_in, /* _bfd_coff_swap_filehdr_in */ | |
3177 | coff_swap_aouthdr_in, /* _bfd_swap_aouthdr_in */ | |
3178 | coff_swap_scnhdr_in, /* _bfd_swap_scnhdr_in */ | |
3179 | coff_swap_reloc_in, /* _bfd_reloc_in */ | |
3180 | coff_bad_format_hook, /* _bfd_bad_format_hook */ | |
3181 | coff_set_arch_mach_hook, /* _bfd_set_arch_mach_hook */ | |
3182 | coff_mkobject_hook, /* _bfd_mkobject_hook */ | |
3183 | styp_to_sec_flags, /* _bfd_syp_to_sec_flags */ | |
3184 | coff_set_alignment_hook, /* _bfd_set_alignment_hook */ | |
3185 | coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */ | |
3186 | symname_in_debug_hook, /* _coff_symname_in_debug_hook */ | |
3187 | coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */ | |
3188 | coff_print_aux, /* bfd_coff_print_aux */ | |
3189 | dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */ | |
3190 | dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */ | |
3191 | NULL, /* bfd_coff_sym_is_global */ | |
3192 | /* _bfd_coff_compute_section_file_positions */ | |
3193 | coff_compute_section_file_positions, | |
3194 | NULL , /* _bfd_coff_start_final_link */ | |
3195 | xcoff_ppc_relocate_section, /* _bfd_coff_relocate_section */ | |
3196 | coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */ | |
3197 | NULL , /* _bfd_coff_addust_symndx */ | |
3198 | _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */ | |
3199 | coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */ | |
3200 | coff_final_link_postscript /* _bfd_coff_final_link_postscript */ | |
3201 | }, | |
3202 | ||
3203 | 0x01DF, /* magic number */ | |
3204 | bfd_arch_powerpc, /* architecture */ | |
3205 | bfd_mach_ppc, /* machine */ | |
3206 | ||
3207 | /* function pointers to xcoff specific swap routines */ | |
3208 | xcoff_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */ | |
3209 | xcoff_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */ | |
3210 | xcoff_swap_ldsym_in, /* _xcoff_swap_ldsym_in */ | |
3211 | xcoff_swap_ldsym_out, /* _xcoff_swap_ldsym_out */ | |
3212 | xcoff_swap_ldrel_in, /* _xcoff_swap_ldrel_in */ | |
3213 | xcoff_swap_ldrel_out, /* _xcoff_swap_ldrel_out */ | |
3214 | ||
3215 | /* sizes */ | |
3216 | LDHDRSZ, /* _xcoff_ldhdrsz */ | |
3217 | LDSYMSZ, /* _xcoff_ldsymsz */ | |
3218 | LDRELSZ, /* _xcoff_ldrelsz */ | |
3219 | 12, /* _xcoff_function_descriptor_size */ | |
3220 | SMALL_AOUTSZ, /* _xcoff_small_aout_header_size */ | |
3221 | ||
3222 | /* versions */ | |
3223 | 1, /* _xcoff_ldhdr_version */ | |
3224 | ||
3225 | /* xcoff vs xcoff64 putting symbol names */ | |
3226 | _bfd_xcoff_put_symbol_name, /* _xcoff_put_symbol_name */ | |
3227 | _bfd_xcoff_put_ldsymbol_name, /* _xcoff_put_ldsymbol_name */ | |
3228 | ||
3229 | &xcoff_dynamic_reloc, /* dynamic reloc howto */ | |
3230 | ||
3231 | xcoff_create_csect_from_smclas, /* _xcoff_create_csect_from_smclas */ | |
3232 | ||
3233 | /* lineno and reloc count overflow */ | |
3234 | xcoff_is_lineno_count_overflow, | |
3235 | xcoff_is_reloc_count_overflow, | |
3236 | ||
3237 | xcoff_loader_symbol_offset, | |
3238 | xcoff_loader_reloc_offset, | |
3239 | ||
3240 | /* glink */ | |
3241 | &xcoff_glink_code[0], | |
3242 | (36), /* _xcoff_glink_size */ | |
3243 | ||
3244 | }; | |
3245 | ||
3246 | /* The transfer vector that leads the outside world to all of the above. */ | |
3247 | const bfd_target pmac_xcoff_vec = | |
3248 | { | |
3249 | "xcoff-powermac", | |
3250 | bfd_target_xcoff_flavour, | |
3251 | BFD_ENDIAN_BIG, /* data byte order is big */ | |
3252 | BFD_ENDIAN_BIG, /* header byte order is big */ | |
3253 | ||
3254 | (HAS_RELOC | EXEC_P | /* object flags */ | |
3255 | HAS_LINENO | HAS_DEBUG | DYNAMIC | | |
3256 | HAS_SYMS | HAS_LOCALS | WP_TEXT), | |
3257 | ||
3258 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
3259 | 0, /* leading char */ | |
3260 | '/', /* ar_pad_char */ | |
3261 | 15, /* ar_max_namelen??? FIXMEmgo */ | |
3262 | ||
3263 | /* data */ | |
3264 | bfd_getb64, /* bfd_getx64 */ | |
3265 | bfd_getb_signed_64, /* bfd_getx_signed_64 */ | |
3266 | bfd_putb64, /* bfd_putx64 */ | |
3267 | bfd_getb32, /* bfd_getx32 */ | |
3268 | bfd_getb_signed_32, /* bfd_getx_signed_32 */ | |
3269 | bfd_putb32, /* bfd_putx32 */ | |
3270 | bfd_getb16, /* bfd_getx16 */ | |
3271 | bfd_getb_signed_16, /* bfd_getx_signed_16 */ | |
3272 | bfd_putb16, /* bfd_putx16 */ | |
3273 | ||
3274 | /* hdrs */ | |
3275 | bfd_getb64, /* bfd_h_getx64 */ | |
3276 | bfd_getb_signed_64, /* bfd_h_getx_signed_64 */ | |
3277 | bfd_putb64, /* bfd_h_putx64 */ | |
3278 | bfd_getb32, /* bfd_h_getx32 */ | |
3279 | bfd_getb_signed_32, /* bfd_h_getx_signed_32 */ | |
3280 | bfd_putb32, /* bfd_h_putx32 */ | |
3281 | bfd_getb16, /* bfd_h_getx16 */ | |
3282 | bfd_getb_signed_16, /* bfd_h_getx_signed_16 */ | |
3283 | bfd_putb16, /* bfd_h_putx16 */ | |
3284 | ||
3285 | { /* bfd_check_format */ | |
3286 | _bfd_dummy_target, | |
3287 | coff_object_p, | |
3288 | _bfd_xcoff_archive_p, | |
3289 | CORE_FILE_P | |
3290 | }, | |
3291 | ||
3292 | { /* bfd_set_format */ | |
3293 | bfd_false, | |
3294 | coff_mkobject, | |
3295 | _bfd_generic_mkarchive, | |
3296 | bfd_false | |
3297 | }, | |
3298 | ||
3299 | {/* bfd_write_contents */ | |
3300 | bfd_false, | |
3301 | coff_write_object_contents, | |
3302 | _bfd_xcoff_write_archive_contents, | |
3303 | bfd_false | |
3304 | }, | |
3305 | ||
3306 | /* Generic */ | |
3307 | bfd_true, /* _close_and_cleanup */ | |
3308 | bfd_true, /* _bfd_free_cached_info */ | |
3309 | coff_new_section_hook, /* _new_section_hook */ | |
3310 | _bfd_generic_get_section_contents, /* _bfd_get_section_contents */ | |
3311 | /* _bfd_get_section_contents_in_window */ | |
3312 | _bfd_generic_get_section_contents_in_window, | |
3313 | ||
3314 | /* Copy */ | |
3315 | _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */ | |
3316 | /* _bfd_merge_private_bfd_data */ | |
3317 | ((boolean (*) (bfd *, bfd *)) bfd_true), | |
3318 | /* _bfd_copy_pivate_section_data */ | |
3319 | ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), | |
3320 | /* _bfd_copy_private_symbol_data */ | |
3321 | ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), | |
3322 | ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */ | |
3323 | ((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */ | |
3324 | ||
3325 | /* Core */ | |
b55039f4 L |
3326 | coff_core_file_failing_command, /* _core_file_failing_command */ |
3327 | coff_core_file_failing_signal, /* _core_file_failing_signal */ | |
beb1bf64 | 3328 | /* _core_file_matches_executable_p */ |
b55039f4 | 3329 | coff_core_file_matches_executable_p, |
beb1bf64 TR |
3330 | |
3331 | /* Archive */ | |
3332 | _bfd_xcoff_slurp_armap, /* _slurp_armap */ | |
3333 | /* XCOFF archives do not have | |
3334 | anything which corresponds to | |
3335 | an extended name table. */ | |
3336 | bfd_false, /* _slurp_extended_name_table */ | |
3337 | /* _construct_extended_name_table */ | |
3338 | ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false), | |
3339 | bfd_dont_truncate_arname, /* _truncate_arname */ | |
3340 | _bfd_xcoff_write_armap, /* _write_armap */ | |
3341 | _bfd_xcoff_read_ar_hdr, /* _read_ar_hdr */ | |
3342 | _bfd_xcoff_openr_next_archived_file, /* _openr_next_archived_file */ | |
3343 | _bfd_generic_get_elt_at_index, /* _get_elt_at_index */ | |
3344 | _bfd_xcoff_generic_stat_arch_elt, /* _generic_dtat_arch_elt */ | |
3345 | /* XCOFF archives do not have | |
3346 | a timestamp. */ | |
3347 | bfd_true, /* _update_armap_timestamp */ | |
3348 | ||
3349 | /* Symbols */ | |
3350 | coff_get_symtab_upper_bound, /* _get_symtab_upper_bound */ | |
3351 | coff_get_symtab, /* _get_symtab */ | |
3352 | coff_make_empty_symbol, /* _make_empty_symbol */ | |
3353 | coff_print_symbol, /* _print_symbol */ | |
3354 | coff_get_symbol_info, /* _get_symbol_info */ | |
3355 | _bfd_xcoff_is_local_label_name, /* _bfd_is_local_label_name */ | |
3356 | coff_get_lineno, /* _get_lineno */ | |
3357 | coff_find_nearest_line, /* _find_nearest_line */ | |
3358 | coff_bfd_make_debug_symbol, /* _bfd_make_debug_symbol */ | |
3359 | _bfd_generic_read_minisymbols, /* _read_minisymbols */ | |
3360 | _bfd_generic_minisymbol_to_symbol, /* _minsymbol_to_symbol */ | |
3361 | ||
3362 | /* Reloc */ | |
3363 | coff_get_reloc_upper_bound, /* _get_reloc_upper_bound */ | |
3364 | coff_canonicalize_reloc, /* _cononicalize_reloc */ | |
3365 | _bfd_xcoff_reloc_type_lookup, /* _bfd_reloc_type_lookup */ | |
3366 | ||
3367 | /* Write */ | |
3368 | coff_set_arch_mach, /* _set_arch_mach */ | |
3369 | coff_set_section_contents, /* _set_section_contents */ | |
3370 | ||
3371 | /* Link */ | |
3372 | _bfd_xcoff_sizeof_headers, /* _sizeof_headers */ | |
3373 | /* _bfd_get_relocated_section_contents */ | |
3374 | bfd_generic_get_relocated_section_contents, | |
3375 | bfd_generic_relax_section, /* _bfd_relax_section */ | |
3376 | _bfd_xcoff_bfd_link_hash_table_create, /* _bfd_link_hash_table_create */ | |
3377 | _bfd_xcoff_bfd_link_add_symbols, /* _bfd_link_add_symbols */ | |
3378 | _bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */ | |
3379 | _bfd_generic_link_split_section, /* _bfd_link_split_section */ | |
3380 | bfd_generic_gc_sections, /* _bfd_gc_sections */ | |
3381 | bfd_generic_merge_sections, /* _bfd_merge_sections */ | |
3382 | ||
3383 | /* Dynamic */ | |
3384 | /* _get_dynamic_symtab_upper_bound */ | |
3385 | _bfd_xcoff_get_dynamic_symtab_upper_bound, | |
3386 | _bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */ | |
3387 | _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */ | |
3388 | _bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */ | |
3389 | ||
3390 | /* Opposite endian version, none exists */ | |
3391 | NULL, | |
3392 | ||
3393 | /* back end data */ | |
3394 | (void *) &bfd_pmac_xcoff_backend_data, | |
3395 | }; | |
3396 |