Commit | Line | Data |
---|---|---|
7f6d05e8 | 1 | /* BFD back-end for IBM RS/6000 "XCOFF64" files. |
7898deda | 2 | Copyright 2000, 2001 |
7f6d05e8 CP |
3 | Free Software Foundation, Inc. |
4 | Written Clinton Popetz. | |
5 | Contributed by Cygnus Support. | |
6 | ||
7 | This file is part of BFD, the Binary File Descriptor library. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program; if not, write to the Free Software | |
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
22 | ||
7f6d05e8 CP |
23 | #include "bfd.h" |
24 | #include "sysdep.h" | |
beb1bf64 | 25 | #include "bfdlink.h" |
7f6d05e8 CP |
26 | #include "libbfd.h" |
27 | #include "coff/internal.h" | |
beb1bf64 | 28 | #include "coff/xcoff.h" |
7f6d05e8 | 29 | #include "coff/rs6k64.h" |
dc810e39 | 30 | #include "libcoff.h" |
beb1bf64 | 31 | #include "libxcoff.h" |
7f6d05e8 | 32 | |
dc810e39 AM |
33 | #define GET_FILEHDR_SYMPTR H_GET_64 |
34 | #define PUT_FILEHDR_SYMPTR H_PUT_64 | |
35 | #define GET_AOUTHDR_DATA_START H_GET_64 | |
36 | #define PUT_AOUTHDR_DATA_START H_PUT_64 | |
37 | #define GET_AOUTHDR_TEXT_START H_GET_64 | |
38 | #define PUT_AOUTHDR_TEXT_START H_PUT_64 | |
39 | #define GET_AOUTHDR_TSIZE H_GET_64 | |
40 | #define PUT_AOUTHDR_TSIZE H_PUT_64 | |
41 | #define GET_AOUTHDR_DSIZE H_GET_64 | |
42 | #define PUT_AOUTHDR_DSIZE H_PUT_64 | |
43 | #define GET_AOUTHDR_BSIZE H_GET_64 | |
44 | #define PUT_AOUTHDR_BSIZE H_PUT_64 | |
45 | #define GET_AOUTHDR_ENTRY H_GET_64 | |
46 | #define PUT_AOUTHDR_ENTRY H_PUT_64 | |
47 | #define GET_SCNHDR_PADDR H_GET_64 | |
48 | #define PUT_SCNHDR_PADDR H_PUT_64 | |
49 | #define GET_SCNHDR_VADDR H_GET_64 | |
50 | #define PUT_SCNHDR_VADDR H_PUT_64 | |
51 | #define GET_SCNHDR_SIZE H_GET_64 | |
52 | #define PUT_SCNHDR_SIZE H_PUT_64 | |
53 | #define GET_SCNHDR_SCNPTR H_GET_64 | |
54 | #define PUT_SCNHDR_SCNPTR H_PUT_64 | |
55 | #define GET_SCNHDR_RELPTR H_GET_64 | |
56 | #define PUT_SCNHDR_RELPTR H_PUT_64 | |
57 | #define GET_SCNHDR_LNNOPTR H_GET_64 | |
58 | #define PUT_SCNHDR_LNNOPTR H_PUT_64 | |
59 | #define GET_SCNHDR_NRELOC H_GET_32 | |
7f6d05e8 | 60 | #define MAX_SCNHDR_NRELOC 0xffffffff |
dc810e39 AM |
61 | #define PUT_SCNHDR_NRELOC H_PUT_32 |
62 | #define GET_SCNHDR_NLNNO H_GET_32 | |
7f6d05e8 | 63 | #define MAX_SCNHDR_NLNNO 0xffffffff |
dc810e39 AM |
64 | #define PUT_SCNHDR_NLNNO H_PUT_32 |
65 | #define GET_RELOC_VADDR H_GET_64 | |
66 | #define PUT_RELOC_VADDR H_PUT_64 | |
7f6d05e8 CP |
67 | |
68 | #define COFF_FORCE_SYMBOLS_IN_STRINGS | |
69 | #define COFF_DEBUG_STRING_WIDE_PREFIX | |
70 | ||
beb1bf64 | 71 | |
dc810e39 AM |
72 | #define COFF_ADJUST_SCNHDR_OUT_POST(ABFD, INT, EXT) \ |
73 | do \ | |
74 | { \ | |
75 | memset (((SCNHDR *) EXT)->s_pad, 0, \ | |
76 | sizeof (((SCNHDR *) EXT)->s_pad)); \ | |
77 | } \ | |
78 | while (0) | |
7f6d05e8 CP |
79 | |
80 | #define NO_COFF_LINENOS | |
81 | ||
beb1bf64 TR |
82 | #define coff_SWAP_lineno_in _bfd_xcoff64_swap_lineno_in |
83 | #define coff_SWAP_lineno_out _bfd_xcoff64_swap_lineno_out | |
7f6d05e8 | 84 | |
814fa6ab AM |
85 | static void _bfd_xcoff64_swap_lineno_in PARAMS ((bfd *, PTR, PTR)); |
86 | static unsigned int _bfd_xcoff64_swap_lineno_out PARAMS ((bfd *, PTR, PTR)); | |
87 | static boolean _bfd_xcoff64_put_ldsymbol_name | |
88 | PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *, | |
89 | const char *)); | |
dc810e39 AM |
90 | static void _bfd_xcoff64_swap_sym_in PARAMS ((bfd *, PTR, PTR)); |
91 | static unsigned int _bfd_xcoff64_swap_sym_out PARAMS ((bfd *, PTR, PTR)); | |
92 | static void _bfd_xcoff64_swap_aux_in | |
93 | PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
94 | static unsigned int _bfd_xcoff64_swap_aux_out | |
95 | PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
96 | extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *)); | |
97 | extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *)); | |
98 | extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *)); | |
99 | extern void xcoff64_rtype2howto | |
100 | PARAMS ((arelent *, struct internal_reloc *)); | |
101 | extern reloc_howto_type * xcoff64_reloc_type_lookup | |
102 | PARAMS ((bfd *, bfd_reloc_code_real_type)); | |
103 | extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *)); | |
104 | extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *)); | |
105 | extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *)); | |
106 | extern int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *)); | |
107 | extern boolean _bfd_xcoff_write_armap | |
108 | PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int)); | |
109 | extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *)); | |
110 | extern int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean)); | |
111 | extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR)); | |
112 | extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR)); | |
113 | extern void _bfd_xcoff_swap_aux_in | |
114 | PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
115 | extern unsigned int _bfd_xcoff_swap_aux_out | |
116 | PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
117 | static void xcoff64_swap_ldhdr_in | |
118 | PARAMS ((bfd *, const PTR, struct internal_ldhdr *)); | |
119 | static void xcoff64_swap_ldhdr_out | |
120 | PARAMS ((bfd *, const struct internal_ldhdr *, PTR d)); | |
121 | static void xcoff64_swap_ldsym_in | |
122 | PARAMS ((bfd *, const PTR, struct internal_ldsym *)); | |
123 | static void xcoff64_swap_ldsym_out | |
124 | PARAMS ((bfd *, const struct internal_ldsym *, PTR d)); | |
125 | static void xcoff64_swap_ldrel_in | |
126 | PARAMS ((bfd *, const PTR, struct internal_ldrel *)); | |
127 | static void xcoff64_swap_ldrel_out | |
128 | PARAMS ((bfd *, const struct internal_ldrel *, PTR d)); | |
129 | static boolean xcoff64_write_object_contents PARAMS ((bfd *)); | |
130 | static boolean xcoff64_ppc_relocate_section | |
131 | PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, | |
132 | struct internal_reloc *, struct internal_syment *, | |
133 | asection **sections)); | |
134 | static boolean xcoff64_slurp_armap PARAMS ((bfd *)); | |
135 | static const bfd_target *xcoff64_archive_p PARAMS ((bfd *)); | |
136 | static bfd *xcoff64_openr_next_archived_file PARAMS ((bfd *, bfd *)); | |
137 | static int xcoff64_sizeof_headers PARAMS ((bfd *, boolean)); | |
138 | static asection *xcoff64_create_csect_from_smclas | |
139 | PARAMS ((bfd *, union internal_auxent *, const char *)); | |
140 | static boolean xcoff64_is_lineno_count_overflow PARAMS ((bfd *, bfd_vma)); | |
141 | static boolean xcoff64_is_reloc_count_overflow PARAMS ((bfd *, bfd_vma)); | |
142 | static bfd_vma xcoff64_loader_symbol_offset | |
143 | PARAMS ((bfd *, struct internal_ldhdr *)); | |
144 | static bfd_vma xcoff64_loader_reloc_offset | |
145 | PARAMS ((bfd *, struct internal_ldhdr *)); | |
146 | ||
147 | /* coffcode.h needs these to be defined */ | |
148 | /* Internalcoff.h and coffcode.h modify themselves based on these flags. */ | |
149 | #define XCOFF64 | |
150 | #define RS6000COFF_C 1 | |
151 | ||
152 | #define SELECT_RELOC(internal, howto) \ | |
153 | { \ | |
154 | internal.r_type = howto->type; \ | |
155 | internal.r_size = \ | |
156 | ((howto->complain_on_overflow == complain_overflow_signed \ | |
157 | ? 0x80 \ | |
158 | : 0) \ | |
159 | | (howto->bitsize - 1)); \ | |
160 | } | |
814fa6ab | 161 | |
dc810e39 AM |
162 | #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3) |
163 | #define COFF_LONG_FILENAMES | |
164 | #define NO_COFF_SYMBOLS | |
165 | #define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst) | |
166 | #define coff_mkobject _bfd_xcoff_mkobject | |
167 | #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data | |
168 | #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name | |
169 | #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup | |
170 | #ifdef AIX_CORE | |
171 | extern const bfd_target * rs6000coff_core_p (); | |
172 | extern boolean rs6000coff_core_file_matches_executable_p (); | |
173 | extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd)); | |
174 | extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd)); | |
175 | #define CORE_FILE_P rs6000coff_core_p | |
176 | #define coff_core_file_failing_command \ | |
177 | rs6000coff_core_file_failing_command | |
178 | #define coff_core_file_failing_signal \ | |
179 | rs6000coff_core_file_failing_signal | |
180 | #define coff_core_file_matches_executable_p \ | |
181 | rs6000coff_core_file_matches_executable_p | |
182 | #else | |
183 | #define CORE_FILE_P _bfd_dummy_target | |
184 | #define coff_core_file_failing_command \ | |
185 | _bfd_nocore_core_file_failing_command | |
186 | #define coff_core_file_failing_signal \ | |
187 | _bfd_nocore_core_file_failing_signal | |
188 | #define coff_core_file_matches_executable_p \ | |
189 | _bfd_nocore_core_file_matches_executable_p | |
190 | #endif | |
191 | #define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in | |
192 | #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out | |
193 | #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in | |
194 | #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out | |
195 | ||
196 | ||
197 | #include "coffcode.h" | |
198 | ||
199 | /* For XCOFF64, the effective width of symndx changes depending on | |
7f6d05e8 CP |
200 | whether we are the first entry. Sigh. */ |
201 | static void | |
beb1bf64 | 202 | _bfd_xcoff64_swap_lineno_in (abfd, ext1, in1) |
dc810e39 | 203 | bfd *abfd; |
7f6d05e8 CP |
204 | PTR ext1; |
205 | PTR in1; | |
206 | { | |
dc810e39 AM |
207 | LINENO *ext = (LINENO *) ext1; |
208 | struct internal_lineno *in = (struct internal_lineno *) in1; | |
7f6d05e8 | 209 | |
dc810e39 | 210 | in->l_lnno = H_GET_32 (abfd, (ext->l_lnno)); |
7f6d05e8 | 211 | if (in->l_lnno == 0) |
dc810e39 | 212 | in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx); |
7f6d05e8 | 213 | else |
dc810e39 | 214 | in->l_addr.l_paddr = H_GET_64 (abfd, ext->l_addr.l_paddr); |
7f6d05e8 CP |
215 | } |
216 | ||
217 | static unsigned int | |
beb1bf64 | 218 | _bfd_xcoff64_swap_lineno_out (abfd, inp, outp) |
dc810e39 AM |
219 | bfd *abfd; |
220 | PTR inp; | |
221 | PTR outp; | |
7f6d05e8 | 222 | { |
dc810e39 AM |
223 | struct internal_lineno *in = (struct internal_lineno *) inp; |
224 | struct external_lineno *ext = (struct external_lineno *) outp; | |
225 | ||
226 | H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx); | |
227 | H_PUT_32 (abfd, in->l_lnno, (ext->l_lnno)); | |
7f6d05e8 | 228 | |
7f6d05e8 | 229 | if (in->l_lnno == 0) |
dc810e39 | 230 | H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx); |
7f6d05e8 | 231 | else |
dc810e39 | 232 | H_PUT_64 (abfd, in->l_addr.l_paddr, ext->l_addr.l_paddr); |
7f6d05e8 CP |
233 | |
234 | return bfd_coff_linesz (abfd); | |
235 | } | |
236 | ||
7f6d05e8 | 237 | static void |
beb1bf64 | 238 | _bfd_xcoff64_swap_sym_in (abfd, ext1, in1) |
dc810e39 | 239 | bfd *abfd; |
7f6d05e8 CP |
240 | PTR ext1; |
241 | PTR in1; | |
242 | { | |
dc810e39 AM |
243 | struct external_syment *ext = (struct external_syment *) ext1; |
244 | struct internal_syment *in = (struct internal_syment *) in1; | |
7f6d05e8 | 245 | |
7f6d05e8 | 246 | in->_n._n_n._n_zeroes = 0; |
dc810e39 AM |
247 | in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e_offset); |
248 | in->n_value = H_GET_64 (abfd, ext->e_value); | |
249 | in->n_scnum = H_GET_16 (abfd, ext->e_scnum); | |
250 | in->n_type = H_GET_16 (abfd, ext->e_type); | |
251 | in->n_sclass = H_GET_8 (abfd, ext->e_sclass); | |
252 | in->n_numaux = H_GET_8 (abfd, ext->e_numaux); | |
7f6d05e8 CP |
253 | } |
254 | ||
255 | static unsigned int | |
beb1bf64 | 256 | _bfd_xcoff64_swap_sym_out (abfd, inp, extp) |
dc810e39 AM |
257 | bfd *abfd; |
258 | PTR inp; | |
259 | PTR extp; | |
7f6d05e8 | 260 | { |
dc810e39 AM |
261 | struct internal_syment *in = (struct internal_syment *) inp; |
262 | struct external_syment *ext = (struct external_syment *) extp; | |
263 | ||
264 | H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e_offset); | |
265 | H_PUT_64 (abfd, in->n_value, ext->e_value); | |
266 | H_PUT_16 (abfd, in->n_scnum, ext->e_scnum); | |
267 | H_PUT_16 (abfd, in->n_type, ext->e_type); | |
268 | H_PUT_8 (abfd, in->n_sclass, ext->e_sclass); | |
269 | H_PUT_8 (abfd, in->n_numaux, ext->e_numaux); | |
7f6d05e8 CP |
270 | return bfd_coff_symesz (abfd); |
271 | } | |
272 | ||
273 | static void | |
beb1bf64 | 274 | _bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) |
dc810e39 AM |
275 | bfd *abfd; |
276 | PTR ext1; | |
277 | int type; | |
278 | int class; | |
279 | int indx; | |
280 | int numaux; | |
281 | PTR in1; | |
7f6d05e8 | 282 | { |
dc810e39 AM |
283 | union external_auxent *ext = (union external_auxent *) ext1; |
284 | union internal_auxent *in = (union internal_auxent *) in1; | |
7f6d05e8 | 285 | |
dc810e39 AM |
286 | switch (class) |
287 | { | |
7f6d05e8 | 288 | case C_FILE: |
dc810e39 AM |
289 | if (ext->x_file.x_n.x_zeroes == 0) |
290 | { | |
7f6d05e8 | 291 | in->x_file.x_n.x_zeroes = 0; |
dc810e39 AM |
292 | in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset); |
293 | } | |
294 | else | |
295 | { | |
beb1bf64 TR |
296 | memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN); |
297 | } | |
7f6d05e8 CP |
298 | goto end; |
299 | ||
300 | /* RS/6000 "csect" auxents */ | |
301 | case C_EXT: | |
302 | case C_HIDEXT: | |
303 | if (indx + 1 == numaux) | |
304 | { | |
beb1bf64 TR |
305 | bfd_signed_vma h = 0; |
306 | bfd_vma l = 0; | |
307 | ||
dc810e39 AM |
308 | h = H_GET_S32 (abfd, ext->x_csect.x_scnlen_hi); |
309 | l = H_GET_32 (abfd, ext->x_csect.x_scnlen_lo); | |
beb1bf64 TR |
310 | |
311 | in->x_csect.x_scnlen.l = h << 32 | (l & 0xffffffff); | |
312 | ||
dc810e39 AM |
313 | in->x_csect.x_parmhash = H_GET_32 (abfd, ext->x_csect.x_parmhash); |
314 | in->x_csect.x_snhash = H_GET_16 (abfd, ext->x_csect.x_snhash); | |
7f6d05e8 CP |
315 | /* We don't have to hack bitfields in x_smtyp because it's |
316 | defined by shifts-and-ands, which are equivalent on all | |
317 | byte orders. */ | |
dc810e39 AM |
318 | in->x_csect.x_smtyp = H_GET_8 (abfd, ext->x_csect.x_smtyp); |
319 | in->x_csect.x_smclas = H_GET_8 (abfd, ext->x_csect.x_smclas); | |
7f6d05e8 CP |
320 | goto end; |
321 | } | |
322 | break; | |
323 | ||
324 | case C_STAT: | |
325 | case C_LEAFSTAT: | |
326 | case C_HIDDEN: | |
dc810e39 AM |
327 | if (type == T_NULL) |
328 | { | |
7f6d05e8 | 329 | /* PE defines some extra fields; we zero them out for |
dc810e39 | 330 | safety. */ |
7f6d05e8 CP |
331 | in->x_scn.x_checksum = 0; |
332 | in->x_scn.x_associated = 0; | |
333 | in->x_scn.x_comdat = 0; | |
334 | ||
335 | goto end; | |
336 | } | |
337 | break; | |
338 | } | |
339 | ||
340 | if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class)) | |
341 | { | |
dc810e39 AM |
342 | in->x_sym.x_fcnary.x_fcn.x_lnnoptr |
343 | = H_GET_64 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr); | |
344 | in->x_sym.x_fcnary.x_fcn.x_endndx.l | |
345 | = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx); | |
346 | } | |
347 | if (ISFCN (type)) | |
348 | { | |
349 | in->x_sym.x_misc.x_fsize | |
350 | = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_fsize); | |
351 | } | |
352 | else | |
353 | { | |
354 | in->x_sym.x_misc.x_lnsz.x_lnno | |
355 | = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_lnno); | |
356 | in->x_sym.x_misc.x_lnsz.x_size | |
357 | = H_GET_16 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_size); | |
7f6d05e8 | 358 | } |
7f6d05e8 | 359 | |
dc810e39 | 360 | end: ; |
7f6d05e8 CP |
361 | } |
362 | ||
7f6d05e8 | 363 | static unsigned int |
beb1bf64 | 364 | _bfd_xcoff64_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) |
dc810e39 AM |
365 | bfd *abfd; |
366 | PTR inp; | |
367 | int type; | |
368 | int class; | |
369 | int indx ATTRIBUTE_UNUSED; | |
370 | int numaux ATTRIBUTE_UNUSED; | |
371 | PTR extp; | |
7f6d05e8 | 372 | { |
dc810e39 AM |
373 | union internal_auxent *in = (union internal_auxent *) inp; |
374 | union external_auxent *ext = (union external_auxent *) extp; | |
7f6d05e8 | 375 | |
dc810e39 | 376 | memset ((PTR) ext, 0, bfd_coff_auxesz (abfd)); |
7f6d05e8 CP |
377 | switch (class) |
378 | { | |
dc810e39 AM |
379 | case C_FILE: |
380 | if (ext->x_file.x_n.x_zeroes == 0) | |
381 | { | |
382 | H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes); | |
383 | H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset); | |
384 | } | |
385 | else | |
386 | { | |
387 | memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN); | |
388 | } | |
389 | H_PUT_8 (abfd, _AUX_FILE, ext->x_auxtype.x_auxtype); | |
7f6d05e8 | 390 | goto end; |
dc810e39 AM |
391 | |
392 | /* RS/6000 "csect" auxents */ | |
393 | case C_EXT: | |
394 | case C_HIDEXT: | |
395 | if (indx + 1 == numaux) | |
396 | { | |
397 | bfd_vma temp; | |
398 | ||
399 | temp = in->x_csect.x_scnlen.l & 0xffffffff; | |
400 | H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_lo); | |
401 | temp = in->x_csect.x_scnlen.l >> 32; | |
402 | H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_hi); | |
403 | H_PUT_32 (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash); | |
404 | H_PUT_16 (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash); | |
405 | /* We don't have to hack bitfields in x_smtyp because it's | |
406 | defined by shifts-and-ands, which are equivalent on all | |
407 | byte orders. */ | |
408 | H_PUT_8 (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp); | |
409 | H_PUT_8 (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas); | |
410 | H_PUT_8 (abfd, _AUX_CSECT, ext->x_auxtype.x_auxtype); | |
411 | goto end; | |
412 | } | |
413 | break; | |
414 | ||
415 | case C_STAT: | |
416 | case C_LEAFSTAT: | |
417 | case C_HIDDEN: | |
418 | if (type == T_NULL) | |
419 | { | |
420 | goto end; | |
421 | } | |
422 | break; | |
7f6d05e8 | 423 | } |
7f6d05e8 CP |
424 | |
425 | if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class)) | |
426 | { | |
dc810e39 AM |
427 | H_PUT_64 (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, |
428 | ext->x_sym.x_fcnary.x_fcn.x_lnnoptr); | |
429 | H_PUT_8 (abfd, _AUX_FCN, | |
430 | ext->x_auxtype.x_auxtype); | |
431 | H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, | |
432 | ext->x_sym.x_fcnary.x_fcn.x_endndx); | |
7f6d05e8 CP |
433 | } |
434 | if (ISFCN (type)) | |
dc810e39 AM |
435 | { |
436 | H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, | |
437 | ext->x_sym.x_fcnary.x_fcn.x_fsize); | |
438 | } | |
7f6d05e8 CP |
439 | else |
440 | { | |
dc810e39 AM |
441 | H_PUT_32 (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, |
442 | ext->x_sym.x_fcnary.x_lnsz.x_lnno); | |
443 | H_PUT_16 (abfd, in->x_sym.x_misc.x_lnsz.x_size, | |
444 | ext->x_sym.x_fcnary.x_lnsz.x_size); | |
7f6d05e8 CP |
445 | } |
446 | ||
dc810e39 | 447 | end: |
beb1bf64 | 448 | |
7f6d05e8 CP |
449 | return bfd_coff_auxesz (abfd); |
450 | } | |
451 | ||
beb1bf64 | 452 | static boolean |
dc810e39 | 453 | _bfd_xcoff64_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab, |
beb1bf64 TR |
454 | struct internal_syment *sym, |
455 | const char *name) { | |
456 | boolean hash; | |
457 | bfd_size_type indx; | |
dc810e39 | 458 | |
beb1bf64 | 459 | hash = true; |
dc810e39 | 460 | |
beb1bf64 TR |
461 | if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0) |
462 | hash = false; | |
dc810e39 | 463 | |
beb1bf64 | 464 | indx = _bfd_stringtab_add (strtab, name, hash, false); |
dc810e39 | 465 | |
beb1bf64 TR |
466 | if (indx == (bfd_size_type) -1) |
467 | return false; | |
dc810e39 | 468 | |
beb1bf64 TR |
469 | sym->_n._n_n._n_zeroes = 0; |
470 | sym->_n._n_n._n_offset = STRING_SIZE_SIZE + indx; | |
dc810e39 | 471 | |
beb1bf64 TR |
472 | return true; |
473 | } | |
474 | ||
475 | static boolean | |
476 | _bfd_xcoff64_put_ldsymbol_name (abfd, ldinfo, ldsym, name) | |
477 | bfd *abfd ATTRIBUTE_UNUSED; | |
dc810e39 AM |
478 | struct xcoff_loader_info *ldinfo; |
479 | struct internal_ldsym *ldsym; | |
480 | const char *name; | |
beb1bf64 TR |
481 | { |
482 | ||
483 | size_t len; | |
484 | len = strlen (name); | |
485 | ||
dc810e39 AM |
486 | if (ldinfo->string_size + len + 3 > ldinfo->string_alc) |
487 | { | |
488 | bfd_size_type newalc; | |
489 | bfd_byte *newstrings; | |
490 | ||
491 | newalc = ldinfo->string_alc * 2; | |
492 | if (newalc == 0) | |
493 | newalc = 32; | |
494 | while (ldinfo->string_size + len + 3 > newalc) | |
495 | newalc *= 2; | |
496 | ||
497 | newstrings = ((bfd_byte *) | |
498 | bfd_realloc ((PTR) ldinfo->strings, newalc)); | |
499 | if (newstrings == NULL) | |
500 | { | |
501 | ldinfo->failed = true; | |
502 | return false; | |
503 | } | |
504 | ldinfo->string_alc = newalc; | |
505 | ldinfo->strings = newstrings; | |
beb1bf64 | 506 | } |
dc810e39 AM |
507 | |
508 | bfd_put_16 (ldinfo->output_bfd, (bfd_vma) (len + 1), | |
beb1bf64 TR |
509 | ldinfo->strings + ldinfo->string_size); |
510 | strcpy (ldinfo->strings + ldinfo->string_size + 2, name); | |
511 | ldsym->_l._l_l._l_zeroes = 0; | |
512 | ldsym->_l._l_l._l_offset = ldinfo->string_size + 2; | |
513 | ldinfo->string_size += len + 3; | |
dc810e39 | 514 | |
beb1bf64 TR |
515 | return true; |
516 | } | |
517 | ||
beb1bf64 TR |
518 | /* Routines to swap information in the XCOFF .loader section. If we |
519 | ever need to write an XCOFF loader, this stuff will need to be | |
520 | moved to another file shared by the linker (which XCOFF calls the | |
521 | ``binder'') and the loader. */ | |
522 | ||
523 | /* Swap in the ldhdr structure. */ | |
524 | ||
525 | static void | |
814fa6ab AM |
526 | xcoff64_swap_ldhdr_in (abfd, s, dst) |
527 | bfd *abfd; | |
528 | const PTR s; | |
529 | struct internal_ldhdr *dst; | |
530 | { | |
531 | const struct external_ldhdr *src = (const struct external_ldhdr *) s; | |
532 | ||
beb1bf64 TR |
533 | dst->l_version = bfd_get_32 (abfd, src->l_version); |
534 | dst->l_nsyms = bfd_get_32 (abfd, src->l_nsyms); | |
535 | dst->l_nreloc = bfd_get_32 (abfd, src->l_nreloc); | |
536 | dst->l_istlen = bfd_get_32 (abfd, src->l_istlen); | |
537 | dst->l_nimpid = bfd_get_32 (abfd, src->l_nimpid); | |
538 | dst->l_stlen = bfd_get_32 (abfd, src->l_stlen); | |
539 | dst->l_impoff = bfd_get_64 (abfd, src->l_impoff); | |
540 | dst->l_stoff = bfd_get_64 (abfd, src->l_stoff); | |
541 | dst->l_symoff = bfd_get_64 (abfd, src->l_symoff); | |
542 | dst->l_rldoff = bfd_get_64 (abfd, src->l_rldoff); | |
543 | } | |
544 | ||
545 | /* Swap out the ldhdr structure. */ | |
546 | ||
547 | static void | |
814fa6ab | 548 | xcoff64_swap_ldhdr_out (abfd, src, d) |
beb1bf64 TR |
549 | bfd *abfd; |
550 | const struct internal_ldhdr *src; | |
814fa6ab | 551 | PTR d; |
beb1bf64 | 552 | { |
814fa6ab AM |
553 | struct external_ldhdr *dst = (struct external_ldhdr *) d; |
554 | ||
dc810e39 | 555 | bfd_put_32 (abfd, (bfd_vma) src->l_version, dst->l_version); |
beb1bf64 TR |
556 | bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms); |
557 | bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc); | |
558 | bfd_put_32 (abfd, src->l_istlen, dst->l_istlen); | |
559 | bfd_put_32 (abfd, src->l_nimpid, dst->l_nimpid); | |
560 | bfd_put_32 (abfd, src->l_stlen, dst->l_stlen); | |
561 | bfd_put_64 (abfd, src->l_impoff, dst->l_impoff); | |
562 | bfd_put_64 (abfd, src->l_stoff, dst->l_stoff); | |
563 | bfd_put_64 (abfd, src->l_symoff, dst->l_symoff); | |
564 | bfd_put_64 (abfd, src->l_rldoff, dst->l_rldoff); | |
565 | } | |
566 | ||
567 | /* Swap in the ldsym structure. */ | |
568 | ||
569 | static void | |
814fa6ab | 570 | xcoff64_swap_ldsym_in (abfd, s, dst) |
beb1bf64 | 571 | bfd *abfd; |
814fa6ab | 572 | const PTR s; |
beb1bf64 TR |
573 | struct internal_ldsym *dst; |
574 | { | |
814fa6ab | 575 | const struct external_ldsym *src = (const struct external_ldsym *) s; |
dc810e39 AM |
576 | /* XCOFF64 does not use l_zeroes like XCOFF32 |
577 | Set the internal l_zeroes to 0 so the common 32/64 code uses l_value | |
578 | as an offset into the loader symbol table. */ | |
beb1bf64 TR |
579 | dst->_l._l_l._l_zeroes = 0; |
580 | dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->l_offset); | |
581 | dst->l_value = bfd_get_64 (abfd, src->l_value); | |
582 | dst->l_scnum = bfd_get_16 (abfd, src->l_scnum); | |
583 | dst->l_smtype = bfd_get_8 (abfd, src->l_smtype); | |
584 | dst->l_smclas = bfd_get_8 (abfd, src->l_smclas); | |
585 | dst->l_ifile = bfd_get_32 (abfd, src->l_ifile); | |
586 | dst->l_parm = bfd_get_32 (abfd, src->l_parm); | |
587 | } | |
588 | ||
589 | /* Swap out the ldsym structure. */ | |
590 | ||
591 | static void | |
814fa6ab | 592 | xcoff64_swap_ldsym_out (abfd, src, d) |
beb1bf64 TR |
593 | bfd *abfd; |
594 | const struct internal_ldsym *src; | |
814fa6ab | 595 | PTR d; |
beb1bf64 | 596 | { |
814fa6ab AM |
597 | struct external_ldsym *dst = (struct external_ldsym *) d; |
598 | ||
beb1bf64 | 599 | bfd_put_64 (abfd, src->l_value, dst->l_value); |
dc810e39 AM |
600 | bfd_put_32 (abfd, (bfd_vma) src->_l._l_l._l_offset, dst->l_offset); |
601 | bfd_put_16 (abfd, (bfd_vma) src->l_scnum, dst->l_scnum); | |
beb1bf64 TR |
602 | bfd_put_8 (abfd, src->l_smtype, dst->l_smtype); |
603 | bfd_put_8 (abfd, src->l_smclas, dst->l_smclas); | |
604 | bfd_put_32 (abfd, src->l_ifile, dst->l_ifile); | |
605 | bfd_put_32 (abfd, src->l_parm, dst->l_parm); | |
606 | } | |
607 | ||
608 | /* Swap in the ldrel structure. */ | |
609 | ||
610 | static void | |
814fa6ab | 611 | xcoff64_swap_ldrel_in (abfd, s, dst) |
beb1bf64 | 612 | bfd *abfd; |
814fa6ab | 613 | const PTR s; |
beb1bf64 TR |
614 | struct internal_ldrel *dst; |
615 | { | |
814fa6ab AM |
616 | const struct external_ldrel *src = (const struct external_ldrel *) s; |
617 | ||
beb1bf64 TR |
618 | dst->l_vaddr = bfd_get_64 (abfd, src->l_vaddr); |
619 | dst->l_symndx = bfd_get_32 (abfd, src->l_symndx); | |
620 | dst->l_rtype = bfd_get_16 (abfd, src->l_rtype); | |
621 | dst->l_rsecnm = bfd_get_16 (abfd, src->l_rsecnm); | |
622 | } | |
623 | ||
624 | /* Swap out the ldrel structure. */ | |
625 | ||
626 | static void | |
814fa6ab | 627 | xcoff64_swap_ldrel_out (abfd, src, d) |
beb1bf64 TR |
628 | bfd *abfd; |
629 | const struct internal_ldrel *src; | |
814fa6ab | 630 | PTR d; |
beb1bf64 | 631 | { |
814fa6ab AM |
632 | struct external_ldrel *dst = (struct external_ldrel *) d; |
633 | ||
beb1bf64 | 634 | bfd_put_64 (abfd, src->l_vaddr, dst->l_vaddr); |
dc810e39 AM |
635 | bfd_put_16 (abfd, (bfd_vma) src->l_rtype, dst->l_rtype); |
636 | bfd_put_16 (abfd, (bfd_vma) src->l_rsecnm, dst->l_rsecnm); | |
beb1bf64 TR |
637 | bfd_put_32 (abfd, src->l_symndx, dst->l_symndx); |
638 | } | |
639 | ||
640 | static boolean | |
641 | xcoff64_write_object_contents (abfd) | |
642 | bfd * abfd; | |
643 | { | |
644 | asection *current; | |
645 | boolean hasrelocs = false; | |
646 | boolean haslinno = false; | |
647 | file_ptr scn_base; | |
648 | file_ptr reloc_base; | |
649 | file_ptr lineno_base; | |
650 | file_ptr sym_base; | |
651 | unsigned long reloc_size = 0; | |
652 | unsigned long lnno_size = 0; | |
653 | boolean long_section_names; | |
dc810e39 AM |
654 | asection *text_sec = ((void *) 0); |
655 | asection *data_sec = ((void *) 0); | |
656 | asection *bss_sec = ((void *) 0); | |
beb1bf64 TR |
657 | struct internal_filehdr internal_f; |
658 | struct internal_aouthdr internal_a; | |
659 | ||
660 | bfd_set_error (bfd_error_system_call); | |
661 | ||
dc810e39 AM |
662 | if (abfd->output_has_begun == false) |
663 | { | |
664 | if (! bfd_coff_compute_section_file_positions (abfd)) | |
665 | return false; | |
666 | } | |
beb1bf64 TR |
667 | |
668 | /* Work out the size of the reloc and linno areas */ | |
669 | reloc_base = obj_relocbase (abfd); | |
670 | ||
dc810e39 | 671 | for (current = abfd->sections; current != NULL; current = current->next) |
beb1bf64 | 672 | reloc_size += current->reloc_count * bfd_coff_relsz (abfd); |
beb1bf64 TR |
673 | |
674 | lineno_base = reloc_base + reloc_size; | |
675 | ||
676 | /* Make a pass through the symbol table to count line number entries and | |
677 | put them into the correct asections */ | |
678 | lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd); | |
679 | ||
680 | sym_base = lineno_base + lnno_size; | |
681 | ||
dc810e39 AM |
682 | /* Indicate in each section->line_filepos its actual file address */ |
683 | for (current = abfd->sections; current != NULL; current = current->next) | |
684 | { | |
685 | if (current->lineno_count) | |
686 | { | |
687 | current->line_filepos = lineno_base; | |
688 | current->moving_line_filepos = lineno_base; | |
689 | lineno_base += current->lineno_count * bfd_coff_linesz (abfd); | |
690 | } | |
691 | else | |
692 | { | |
693 | current->line_filepos = 0; | |
694 | } | |
695 | ||
696 | if (current->reloc_count) | |
697 | { | |
698 | current->rel_filepos = reloc_base; | |
699 | reloc_base += current->reloc_count * bfd_coff_relsz (abfd); | |
700 | } | |
701 | else | |
702 | { | |
703 | current->rel_filepos = 0; | |
704 | } | |
705 | } | |
706 | ||
707 | if ((abfd->flags & EXEC_P) != 0) | |
708 | { | |
709 | scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd); | |
710 | internal_f.f_opthdr = bfd_coff_aoutsz (abfd); | |
beb1bf64 | 711 | } |
dc810e39 AM |
712 | else |
713 | { | |
714 | scn_base = bfd_coff_filhsz (abfd); | |
715 | internal_f.f_opthdr = 0; | |
beb1bf64 | 716 | } |
beb1bf64 TR |
717 | |
718 | internal_f.f_nscns = 0; | |
719 | ||
720 | if (bfd_seek (abfd, scn_base, SEEK_SET) != 0) | |
721 | return false; | |
722 | ||
723 | long_section_names = false; | |
dc810e39 AM |
724 | for (current = abfd->sections; current != NULL; current = current->next) |
725 | { | |
726 | struct internal_scnhdr section; | |
727 | struct external_scnhdr buff; | |
728 | bfd_size_type amount; | |
beb1bf64 | 729 | |
dc810e39 | 730 | internal_f.f_nscns++; |
beb1bf64 | 731 | |
dc810e39 | 732 | strncpy (section.s_name, current->name, SCNNMLEN); |
beb1bf64 | 733 | |
dc810e39 AM |
734 | section.s_vaddr = current->vma; |
735 | section.s_paddr = current->lma; | |
736 | section.s_size = current->_raw_size; | |
beb1bf64 | 737 | |
dc810e39 AM |
738 | /* If this section has no size or is unloadable then the scnptr |
739 | will be 0 too. */ | |
740 | if (current->_raw_size == 0 | |
741 | || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) | |
742 | { | |
743 | section.s_scnptr = 0; | |
744 | } | |
745 | else | |
746 | { | |
747 | section.s_scnptr = current->filepos; | |
748 | } | |
749 | ||
750 | section.s_relptr = current->rel_filepos; | |
751 | section.s_lnnoptr = current->line_filepos; | |
752 | section.s_nreloc = current->reloc_count; | |
753 | ||
754 | section.s_nlnno = current->lineno_count; | |
755 | if (current->reloc_count != 0) | |
756 | hasrelocs = true; | |
757 | if (current->lineno_count != 0) | |
758 | haslinno = true; | |
beb1bf64 | 759 | |
dc810e39 AM |
760 | section.s_flags = sec_to_styp_flags (current->name, current->flags); |
761 | ||
762 | if (!strcmp (current->name, _TEXT)) | |
763 | { | |
764 | text_sec = current; | |
765 | } | |
766 | else if (!strcmp (current->name, _DATA)) | |
767 | { | |
768 | data_sec = current; | |
769 | } | |
770 | else if (!strcmp (current->name, _BSS)) | |
771 | { | |
772 | bss_sec = current; | |
773 | } | |
774 | ||
775 | amount = bfd_coff_scnhsz (abfd); | |
776 | if (bfd_coff_swap_scnhdr_out (abfd, §ion, &buff) == 0 | |
777 | || bfd_bwrite ((PTR) (&buff), amount, abfd) != amount) | |
beb1bf64 | 778 | return false; |
dc810e39 | 779 | } |
beb1bf64 TR |
780 | |
781 | internal_f.f_timdat = 0; | |
782 | ||
783 | internal_f.f_flags = 0; | |
784 | ||
785 | if (!hasrelocs) | |
786 | internal_f.f_flags |= F_RELFLG; | |
787 | if (!haslinno) | |
788 | internal_f.f_flags |= F_LNNO; | |
789 | if (abfd->flags & EXEC_P) | |
790 | internal_f.f_flags |= F_EXEC; | |
791 | ||
792 | /* FIXME: this is wrong for PPC_PE! */ | |
793 | if (bfd_little_endian (abfd)) | |
794 | internal_f.f_flags |= F_AR32WR; | |
795 | else | |
796 | internal_f.f_flags |= F_AR32W; | |
797 | ||
798 | if ((abfd->flags & DYNAMIC) != 0) | |
799 | internal_f.f_flags |= F_SHROBJ; | |
800 | if (bfd_get_section_by_name (abfd, _LOADER) != NULL) | |
801 | internal_f.f_flags |= F_DYNLOAD; | |
802 | ||
803 | memset (&internal_a, 0, sizeof internal_a); | |
804 | ||
805 | ||
dc810e39 AM |
806 | /* This can only be called from the xcoff64 backend so the magic # |
807 | must be for xcoff64. */ | |
beb1bf64 TR |
808 | internal_f.f_magic = 0757; |
809 | ||
810 | internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC : | |
811 | (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC : | |
812 | RS6K_AOUTHDR_OMAGIC; | |
813 | ||
814 | /* FIXME: Does anybody ever set this to another value? */ | |
815 | internal_a.vstamp = 0; | |
816 | ||
817 | /* Now should write relocs, strings, syms */ | |
818 | obj_sym_filepos (abfd) = sym_base; | |
819 | ||
820 | internal_f.f_symptr = 0; | |
821 | internal_f.f_nsyms = 0; | |
822 | ||
dc810e39 AM |
823 | /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF |
824 | backend linker, and obj_raw_syment_count is not valid until after | |
825 | coff_write_symbols is called. */ | |
826 | if (bfd_get_symcount (abfd) != 0) | |
827 | { | |
828 | int firstundef; | |
beb1bf64 | 829 | |
dc810e39 AM |
830 | if (!coff_renumber_symbols (abfd, &firstundef)) |
831 | return false; | |
832 | coff_mangle_symbols (abfd); | |
833 | if (! coff_write_symbols (abfd)) | |
834 | return false; | |
835 | if (! coff_write_linenumbers (abfd)) | |
836 | return false; | |
837 | if (! coff_write_relocs (abfd, firstundef)) | |
838 | return false; | |
beb1bf64 | 839 | |
dc810e39 AM |
840 | internal_f.f_symptr = sym_base; |
841 | internal_f.f_nsyms = bfd_get_symcount (abfd); | |
842 | } | |
843 | else if (obj_raw_syment_count (abfd) != 0) | |
844 | { | |
845 | internal_f.f_symptr = sym_base; | |
846 | ||
847 | /* AIX appears to require that F_RELFLG not be set if there are | |
848 | local symbols but no relocations. */ | |
849 | internal_f.f_flags &=~ F_RELFLG; | |
850 | } | |
851 | else | |
852 | { | |
853 | internal_f.f_flags |= F_LSYMS; | |
854 | } | |
beb1bf64 | 855 | |
dc810e39 AM |
856 | if (text_sec) |
857 | { | |
858 | internal_a.tsize = bfd_get_section_size_before_reloc (text_sec); | |
beb1bf64 | 859 | internal_a.text_start = internal_a.tsize ? text_sec->vma : 0; |
dc810e39 | 860 | } |
beb1bf64 | 861 | |
dc810e39 AM |
862 | if (data_sec) |
863 | { | |
864 | internal_a.dsize = bfd_get_section_size_before_reloc (data_sec); | |
865 | internal_a.data_start = internal_a.dsize ? data_sec->vma : 0; | |
866 | } | |
beb1bf64 | 867 | |
dc810e39 AM |
868 | if (bss_sec) |
869 | { | |
870 | internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec); | |
871 | if (internal_a.bsize && bss_sec->vma < internal_a.data_start) | |
872 | internal_a.data_start = bss_sec->vma; | |
873 | } | |
beb1bf64 TR |
874 | |
875 | internal_a.entry = bfd_get_start_address (abfd); | |
876 | internal_f.f_nsyms = obj_raw_syment_count (abfd); | |
877 | ||
dc810e39 AM |
878 | if (xcoff_data (abfd)->full_aouthdr) |
879 | { | |
beb1bf64 TR |
880 | bfd_vma toc; |
881 | asection *loader_sec; | |
882 | ||
883 | internal_a.vstamp = 1; | |
884 | ||
885 | internal_a.o_snentry = xcoff_data (abfd)->snentry; | |
886 | if (internal_a.o_snentry == 0) | |
887 | internal_a.entry = (bfd_vma) -1; | |
888 | ||
dc810e39 AM |
889 | if (text_sec != NULL) |
890 | { | |
beb1bf64 TR |
891 | internal_a.o_sntext = text_sec->target_index; |
892 | internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec); | |
dc810e39 AM |
893 | } |
894 | else | |
895 | { | |
896 | internal_a.o_sntext = 0; | |
897 | internal_a.o_algntext = 0; | |
898 | } | |
899 | ||
900 | if (data_sec != NULL) | |
901 | { | |
902 | internal_a.o_sndata = data_sec->target_index; | |
903 | internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec); | |
904 | } | |
905 | else | |
906 | { | |
907 | internal_a.o_sndata = 0; | |
908 | internal_a.o_algndata = 0; | |
909 | } | |
beb1bf64 TR |
910 | |
911 | loader_sec = bfd_get_section_by_name (abfd, ".loader"); | |
912 | if (loader_sec != NULL) | |
913 | internal_a.o_snloader = loader_sec->target_index; | |
914 | else | |
915 | internal_a.o_snloader = 0; | |
916 | if (bss_sec != NULL) | |
917 | internal_a.o_snbss = bss_sec->target_index; | |
918 | else | |
919 | internal_a.o_snbss = 0; | |
920 | ||
921 | toc = xcoff_data (abfd)->toc; | |
922 | internal_a.o_toc = toc; | |
923 | internal_a.o_sntoc = xcoff_data (abfd)->sntoc; | |
924 | ||
925 | internal_a.o_modtype = xcoff_data (abfd)->modtype; | |
926 | if (xcoff_data (abfd)->cputype != -1) | |
927 | internal_a.o_cputype = xcoff_data (abfd)->cputype; | |
928 | else | |
929 | { | |
930 | switch (bfd_get_arch (abfd)) | |
931 | { | |
932 | case bfd_arch_rs6000: | |
933 | internal_a.o_cputype = 4; | |
934 | break; | |
935 | case bfd_arch_powerpc: | |
936 | if (bfd_get_mach (abfd) == 0) | |
937 | internal_a.o_cputype = 3; | |
938 | else | |
939 | internal_a.o_cputype = 1; | |
940 | break; | |
941 | default: | |
942 | abort (); | |
943 | } | |
944 | } | |
945 | internal_a.o_maxstack = xcoff_data (abfd)->maxstack; | |
946 | internal_a.o_maxdata = xcoff_data (abfd)->maxdata; | |
dc810e39 AM |
947 | } |
948 | ||
949 | if (bfd_seek (abfd, (file_ptr) 0, 0) != 0) | |
beb1bf64 | 950 | return false; |
dc810e39 | 951 | |
beb1bf64 TR |
952 | { |
953 | char * buff; | |
dc810e39 AM |
954 | bfd_size_type amount = bfd_coff_filhsz (abfd); |
955 | ||
956 | buff = bfd_malloc (amount); | |
957 | if (buff == NULL) | |
beb1bf64 | 958 | return false; |
dc810e39 AM |
959 | |
960 | bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, (PTR) buff); | |
961 | amount = bfd_bwrite ((PTR) buff, amount, abfd); | |
962 | ||
beb1bf64 | 963 | free (buff); |
dc810e39 | 964 | |
beb1bf64 TR |
965 | if (amount != bfd_coff_filhsz (abfd)) |
966 | return false; | |
967 | } | |
beb1bf64 | 968 | |
dc810e39 AM |
969 | if (abfd->flags & EXEC_P) |
970 | { | |
971 | char * buff; | |
972 | bfd_size_type amount = bfd_coff_aoutsz (abfd); | |
beb1bf64 | 973 | |
dc810e39 AM |
974 | buff = bfd_malloc (amount); |
975 | if (buff == NULL) | |
976 | return false; | |
beb1bf64 | 977 | |
dc810e39 AM |
978 | bfd_coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) buff); |
979 | amount = bfd_bwrite ((PTR) buff, amount, abfd); | |
980 | ||
981 | free (buff); | |
beb1bf64 | 982 | |
dc810e39 AM |
983 | if (amount != bfd_coff_aoutsz (abfd)) |
984 | return false; | |
985 | } | |
beb1bf64 TR |
986 | |
987 | return true; | |
988 | } | |
989 | ||
990 | /* This is the relocation function for the RS/6000/POWER/PowerPC. | |
991 | This is currently the only processor which uses XCOFF; I hope that | |
992 | will never change. */ | |
993 | ||
814fa6ab | 994 | static boolean |
beb1bf64 TR |
995 | xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, |
996 | input_section, contents, relocs, syms, | |
997 | sections) | |
998 | bfd *output_bfd; | |
999 | struct bfd_link_info *info; | |
1000 | bfd *input_bfd; | |
1001 | asection *input_section; | |
1002 | bfd_byte *contents; | |
1003 | struct internal_reloc *relocs; | |
1004 | struct internal_syment *syms; | |
1005 | asection **sections; | |
1006 | { | |
1007 | struct internal_reloc *rel; | |
1008 | struct internal_reloc *relend; | |
1009 | ||
1010 | rel = relocs; | |
1011 | relend = rel + input_section->reloc_count; | |
1012 | for (; rel < relend; rel++) | |
1013 | { | |
1014 | long symndx; | |
1015 | struct xcoff_link_hash_entry *h; | |
1016 | struct internal_syment *sym; | |
1017 | bfd_vma addend; | |
1018 | bfd_vma val; | |
1019 | struct reloc_howto_struct howto; | |
1020 | bfd_reloc_status_type rstat; | |
1021 | ||
1022 | /* Relocation type R_REF is a special relocation type which is | |
1023 | merely used to prevent garbage collection from occurring for | |
1024 | the csect including the symbol which it references. */ | |
1025 | if (rel->r_type == R_REF) | |
1026 | continue; | |
1027 | ||
1028 | symndx = rel->r_symndx; | |
1029 | ||
dc810e39 AM |
1030 | if (symndx == -1) |
1031 | { | |
1032 | h = NULL; | |
1033 | sym = NULL; | |
1034 | addend = 0; | |
1035 | } | |
1036 | else | |
1037 | { | |
1038 | h = obj_xcoff_sym_hashes (input_bfd)[symndx]; | |
1039 | sym = syms + symndx; | |
1040 | addend = - sym->n_value; | |
1041 | } | |
beb1bf64 TR |
1042 | |
1043 | /* We build the howto information on the fly. */ | |
1044 | ||
1045 | howto.type = rel->r_type; | |
1046 | howto.rightshift = 0; | |
1047 | howto.size = 4; | |
1048 | howto.bitsize = (rel->r_size & 0x3f) + 1; | |
1049 | howto.pc_relative = false; | |
1050 | howto.bitpos = 0; | |
1051 | if ((rel->r_size & 0x80) != 0) | |
1052 | howto.complain_on_overflow = complain_overflow_signed; | |
1053 | else | |
1054 | howto.complain_on_overflow = complain_overflow_bitfield; | |
1055 | howto.special_function = NULL; | |
1056 | howto.name = "internal"; | |
1057 | howto.partial_inplace = true; | |
1058 | ||
dc810e39 AM |
1059 | if (howto.bitsize == 64) |
1060 | { | |
1061 | howto.src_mask = howto.dst_mask = MINUS_ONE; | |
1062 | } | |
1063 | else if (howto.bitsize == 32) | |
1064 | { | |
1065 | howto.src_mask = howto.dst_mask = 0xffffffff; | |
1066 | } | |
1067 | else | |
1068 | { | |
1069 | howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1; | |
1070 | if (howto.bitsize == 16) | |
1071 | howto.size = 1; | |
1072 | } | |
beb1bf64 TR |
1073 | howto.pcrel_offset = false; |
1074 | ||
1075 | val = 0; | |
1076 | ||
dc810e39 AM |
1077 | if (h == NULL) |
1078 | { | |
1079 | asection *sec; | |
1080 | ||
1081 | if (symndx == -1) | |
1082 | { | |
1083 | sec = bfd_abs_section_ptr; | |
1084 | val = 0; | |
1085 | } | |
beb1bf64 | 1086 | else |
dc810e39 AM |
1087 | { |
1088 | sec = sections[symndx]; | |
1089 | /* Hack to make sure we use the right TOC anchor value | |
1090 | if this reloc is against the TOC anchor. */ | |
1091 | if (sec->name[3] == '0' | |
1092 | && strcmp (sec->name, ".tc0") == 0) | |
1093 | val = xcoff_data (output_bfd)->toc; | |
1094 | else | |
1095 | val = (sec->output_section->vma | |
1096 | + sec->output_offset | |
1097 | + sym->n_value | |
1098 | - sec->vma); | |
1099 | } | |
1100 | ||
beb1bf64 | 1101 | } |
dc810e39 AM |
1102 | else |
1103 | { | |
beb1bf64 | 1104 | |
dc810e39 AM |
1105 | if (h->root.type == bfd_link_hash_defined |
1106 | || h->root.type == bfd_link_hash_defweak) | |
1107 | { | |
1108 | asection *sec; | |
beb1bf64 | 1109 | |
dc810e39 AM |
1110 | sec = h->root.u.def.section; |
1111 | val = (h->root.u.def.value | |
1112 | + sec->output_section->vma | |
1113 | + sec->output_offset); | |
beb1bf64 | 1114 | |
dc810e39 AM |
1115 | } |
1116 | else if (h->root.type == bfd_link_hash_common) | |
1117 | { | |
1118 | asection *sec; | |
1119 | ||
1120 | sec = h->root.u.c.p->section; | |
1121 | val = (sec->output_section->vma | |
1122 | + sec->output_offset); | |
1123 | } | |
1124 | else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0 | |
1125 | || (h->flags & XCOFF_IMPORT) != 0) | |
1126 | { | |
1127 | /* Every symbol in a shared object is defined somewhere. */ | |
1128 | val = 0; | |
1129 | } | |
1130 | else if (! info->relocateable) | |
1131 | { | |
1132 | if (! ((*info->callbacks->undefined_symbol) | |
1133 | (info, h->root.root.string, input_bfd, input_section, | |
1134 | rel->r_vaddr - input_section->vma, true))) | |
1135 | return false; | |
1136 | ||
1137 | /* Don't try to process the reloc. It can't help, and | |
1138 | it may generate another error. */ | |
1139 | continue; | |
1140 | } | |
beb1bf64 | 1141 | } |
beb1bf64 TR |
1142 | |
1143 | /* I took the relocation type definitions from two documents: | |
1144 | the PowerPC AIX Version 4 Application Binary Interface, First | |
1145 | Edition (April 1992), and the PowerOpen ABI, Big-Endian | |
1146 | 32-Bit Hardware Implementation (June 30, 1994). Differences | |
1147 | between the documents are noted below. */ | |
1148 | ||
dc810e39 AM |
1149 | switch (rel->r_type) |
1150 | { | |
1151 | case R_RTB: | |
1152 | case R_RRTBI: | |
1153 | case R_RRTBA: | |
1154 | /* These relocs are defined by the PowerPC ABI to be | |
1155 | relative branches which use half of the difference | |
1156 | between the symbol and the program counter. I can't | |
1157 | quite figure out when this is useful. These relocs are | |
1158 | not defined by the PowerOpen ABI. */ | |
1159 | default: | |
1160 | (*_bfd_error_handler) | |
1161 | (_("%s: unsupported relocation type 0x%02x"), | |
8f615d07 | 1162 | bfd_archive_filename (input_bfd), (unsigned int) rel->r_type); |
dc810e39 AM |
1163 | bfd_set_error (bfd_error_bad_value); |
1164 | return false; | |
1165 | case R_POS: | |
1166 | /* Simple positive relocation. */ | |
1167 | break; | |
1168 | case R_NEG: | |
1169 | /* Simple negative relocation. */ | |
1170 | val = - val; | |
1171 | break; | |
1172 | case R_REL: | |
1173 | /* Simple PC relative relocation. */ | |
1174 | howto.pc_relative = true; | |
1175 | break; | |
1176 | case R_TOC: | |
1177 | /* TOC relative relocation. The value in the instruction in | |
1178 | the input file is the offset from the input file TOC to | |
1179 | the desired location. We want the offset from the final | |
1180 | TOC to the desired location. We have: | |
1181 | isym = iTOC + in | |
1182 | iinsn = in + o | |
1183 | osym = oTOC + on | |
1184 | oinsn = on + o | |
1185 | so we must change insn by on - in. | |
1186 | */ | |
1187 | case R_GL: | |
1188 | /* Global linkage relocation. The value of this relocation | |
1189 | is the address of the entry in the TOC section. */ | |
1190 | case R_TCL: | |
1191 | /* Local object TOC address. I can't figure out the | |
1192 | difference between this and case R_GL. */ | |
1193 | case R_TRL: | |
1194 | /* TOC relative relocation. A TOC relative load instruction | |
1195 | which may be changed to a load address instruction. | |
1196 | FIXME: We don't currently implement this optimization. */ | |
1197 | case R_TRLA: | |
1198 | /* TOC relative relocation. This is a TOC relative load | |
1199 | address instruction which may be changed to a load | |
1200 | instruction. FIXME: I don't know if this is the correct | |
1201 | implementation. */ | |
1202 | if (h != NULL && h->smclas != XMC_TD) | |
1203 | { | |
1204 | if (h->toc_section == NULL) | |
1205 | { | |
1206 | (*_bfd_error_handler) | |
1207 | (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"), | |
8f615d07 | 1208 | bfd_archive_filename (input_bfd), rel->r_vaddr, |
dc810e39 AM |
1209 | h->root.root.string); |
1210 | bfd_set_error (bfd_error_bad_value); | |
1211 | return false; | |
1212 | } | |
beb1bf64 | 1213 | |
dc810e39 AM |
1214 | BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0); |
1215 | val = (h->toc_section->output_section->vma | |
1216 | + h->toc_section->output_offset); | |
1217 | } | |
beb1bf64 | 1218 | |
dc810e39 AM |
1219 | val = ((val - xcoff_data (output_bfd)->toc) |
1220 | - (sym->n_value - xcoff_data (input_bfd)->toc)); | |
beb1bf64 | 1221 | |
dc810e39 AM |
1222 | addend = 0; |
1223 | break; | |
1224 | case R_BA: | |
1225 | /* Absolute branch. We don't want to mess with the lower | |
1226 | two bits of the instruction. */ | |
1227 | case R_CAI: | |
1228 | /* The PowerPC ABI defines this as an absolute call which | |
1229 | may be modified to become a relative call. The PowerOpen | |
1230 | ABI does not define this relocation type. */ | |
1231 | case R_RBA: | |
1232 | /* Absolute branch which may be modified to become a | |
1233 | relative branch. */ | |
1234 | case R_RBAC: | |
1235 | /* The PowerPC ABI defines this as an absolute branch to a | |
1236 | fixed address which may be modified to an absolute branch | |
1237 | to a symbol. The PowerOpen ABI does not define this | |
1238 | relocation type. */ | |
1239 | case R_RBRC: | |
1240 | /* The PowerPC ABI defines this as an absolute branch to a | |
1241 | fixed address which may be modified to a relative branch. | |
1242 | The PowerOpen ABI does not define this relocation type. */ | |
1243 | howto.src_mask &= ~3; | |
1244 | howto.dst_mask = howto.src_mask; | |
1245 | break; | |
1246 | case R_BR: | |
1247 | /* Relative branch. We don't want to mess with the lower | |
1248 | two bits of the instruction. */ | |
1249 | case R_CREL: | |
1250 | /* The PowerPC ABI defines this as a relative call which may | |
1251 | be modified to become an absolute call. The PowerOpen | |
1252 | ABI does not define this relocation type. */ | |
1253 | case R_RBR: | |
1254 | /* A relative branch which may be modified to become an | |
1255 | absolute branch. FIXME: We don't implement this, | |
1256 | although we should for symbols of storage mapping class | |
1257 | XMC_XO. */ | |
1258 | howto.pc_relative = true; | |
1259 | howto.src_mask &= ~3; | |
1260 | howto.dst_mask = howto.src_mask; | |
1261 | howto.size = 2; | |
1262 | howto.complain_on_overflow = complain_overflow_bitfield; | |
1263 | break; | |
1264 | case R_RL: | |
1265 | /* The PowerPC AIX ABI describes this as a load which may be | |
1266 | changed to a load address. The PowerOpen ABI says this | |
1267 | is the same as case R_POS. */ | |
1268 | break; | |
1269 | case R_RLA: | |
1270 | /* The PowerPC AIX ABI describes this as a load address | |
1271 | which may be changed to a load. The PowerOpen ABI says | |
1272 | this is the same as R_POS. */ | |
1273 | break; | |
1274 | } | |
beb1bf64 TR |
1275 | |
1276 | /* If we see an R_BR or R_RBR reloc which is jumping to global | |
1277 | linkage code, and it is followed by an appropriate cror nop | |
1278 | instruction, we replace the cror with ld r2,40(r1). This | |
1279 | restores the TOC after the glink code. Contrariwise, if the | |
1280 | call is followed by a ld r2,40(r1), but the call is not | |
1281 | going to global linkage code, we can replace the load with a | |
1282 | cror. */ | |
dc810e39 AM |
1283 | if ((rel->r_type == R_BR || rel->r_type == R_RBR) |
1284 | && h != NULL | |
1285 | && h->root.type == bfd_link_hash_defined | |
1286 | && (rel->r_vaddr - input_section->vma + 8 | |
1287 | <= input_section->_cooked_size)) | |
1288 | { | |
beb1bf64 TR |
1289 | bfd_byte *pnext; |
1290 | unsigned long next; | |
1291 | ||
1292 | pnext = contents + (rel->r_vaddr - input_section->vma) + 4; | |
1293 | next = bfd_get_32 (input_bfd, pnext); | |
1294 | ||
1295 | ||
1296 | /* The _ptrgl function is magic. It is used by the AIX | |
dc810e39 AM |
1297 | * compiler to call a function through a pointer. |
1298 | * | |
beb1bf64 TR |
1299 | * special case XMC_GL, global linkage |
1300 | */ | |
1301 | if (h->smclas == XMC_GL | |
1302 | || strcmp (h->root.root.string, "._ptrgl") == 0) | |
1303 | { | |
dc810e39 AM |
1304 | if (next == 0x4def7b82 /* cror 15,15,15 */ |
1305 | || next == 0x4ffffb82 /* cror 31,31,31 */ | |
1306 | || next == 0x60000000 /* ori r0,r0,0 */) | |
1307 | bfd_put_32 (input_bfd, (bfd_vma) 0xe8410028 /* ld r2,40(r1) */, | |
1308 | pnext); | |
beb1bf64 TR |
1309 | } |
1310 | else | |
1311 | { | |
dc810e39 AM |
1312 | if (next == 0xe8410028 /* ld r2,40(r1) */) |
1313 | bfd_put_32 (input_bfd, (bfd_vma) 0x60000000 /* ori r0,r0,0 */, | |
1314 | pnext); | |
beb1bf64 TR |
1315 | } |
1316 | } | |
1317 | ||
1318 | /* A PC relative reloc includes the section address. */ | |
1319 | if (howto.pc_relative) | |
1320 | addend += input_section->vma; | |
1321 | ||
1322 | rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section, | |
1323 | contents, | |
1324 | rel->r_vaddr - input_section->vma, | |
1325 | val, addend); | |
1326 | ||
1327 | switch (rstat) | |
1328 | { | |
1329 | default: | |
1330 | abort (); | |
1331 | case bfd_reloc_ok: | |
1332 | break; | |
1333 | case bfd_reloc_overflow: | |
1334 | { | |
1335 | const char *name; | |
1336 | char buf[SYMNMLEN + 1]; | |
1337 | char howto_name[10]; | |
1338 | ||
1339 | if (symndx == -1) | |
1340 | name = "*ABS*"; | |
1341 | else if (h != NULL) | |
1342 | name = h->root.root.string; | |
1343 | else | |
1344 | { | |
1345 | name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); | |
1346 | if (name == NULL) | |
1347 | return false; | |
1348 | } | |
1349 | sprintf (howto_name, "0x%02x", rel->r_type); | |
1350 | ||
1351 | if (! ((*info->callbacks->reloc_overflow) | |
1352 | (info, name, howto_name, (bfd_vma) 0, input_bfd, | |
1353 | input_section, rel->r_vaddr - input_section->vma))) | |
1354 | return false; | |
1355 | } | |
1356 | } | |
1357 | } | |
1358 | ||
1359 | return true; | |
1360 | } | |
1361 | ||
1362 | ||
1363 | \f | |
1364 | /* The XCOFF reloc table. Actually, XCOFF relocations specify the | |
1365 | bitsize and whether they are signed or not, along with a | |
1366 | conventional type. This table is for the types, which are used for | |
1367 | different algorithms for putting in the reloc. Many of these | |
1368 | relocs need special_function entries, which I have not written. */ | |
1369 | ||
1370 | ||
1371 | reloc_howto_type xcoff64_howto_table[] = | |
1372 | { | |
1373 | /* Standard 64 bit relocation. */ | |
dc810e39 AM |
1374 | HOWTO (0, /* type */ |
1375 | 0, /* rightshift */ | |
1376 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
1377 | 64, /* bitsize */ | |
1378 | false, /* pc_relative */ | |
1379 | 0, /* bitpos */ | |
beb1bf64 | 1380 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1381 | 0, /* special_function */ |
1382 | "R_POS", /* name */ | |
1383 | true, /* partial_inplace */ | |
1384 | MINUS_ONE, /* src_mask */ | |
1385 | MINUS_ONE, /* dst_mask */ | |
1386 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1387 | |
1388 | /* 64 bit relocation, but store negative value. */ | |
dc810e39 AM |
1389 | HOWTO (1, /* type */ |
1390 | 0, /* rightshift */ | |
1391 | -4, /* size (0 = byte, 1 = short, 2 = long) */ | |
1392 | 64, /* bitsize */ | |
1393 | false, /* pc_relative */ | |
1394 | 0, /* bitpos */ | |
beb1bf64 | 1395 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1396 | 0, /* special_function */ |
1397 | "R_NEG", /* name */ | |
1398 | true, /* partial_inplace */ | |
1399 | MINUS_ONE, /* src_mask */ | |
1400 | MINUS_ONE, /* dst_mask */ | |
1401 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1402 | |
1403 | /* 32 bit PC relative relocation. */ | |
dc810e39 AM |
1404 | HOWTO (2, /* type */ |
1405 | 0, /* rightshift */ | |
1406 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1407 | 32, /* bitsize */ | |
1408 | true, /* pc_relative */ | |
1409 | 0, /* bitpos */ | |
beb1bf64 | 1410 | complain_overflow_signed, /* complain_on_overflow */ |
dc810e39 AM |
1411 | 0, /* special_function */ |
1412 | "R_REL", /* name */ | |
1413 | true, /* partial_inplace */ | |
1414 | 0xffffffff, /* src_mask */ | |
1415 | 0xffffffff, /* dst_mask */ | |
1416 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1417 | |
1418 | /* 16 bit TOC relative relocation. */ | |
dc810e39 AM |
1419 | HOWTO (3, /* type */ |
1420 | 0, /* rightshift */ | |
1421 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
1422 | 16, /* bitsize */ | |
1423 | false, /* pc_relative */ | |
1424 | 0, /* bitpos */ | |
beb1bf64 | 1425 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1426 | 0, /* special_function */ |
1427 | "R_TOC", /* name */ | |
1428 | true, /* partial_inplace */ | |
1429 | 0xffff, /* src_mask */ | |
1430 | 0xffff, /* dst_mask */ | |
1431 | false), /* pcrel_offset */ | |
1432 | ||
1433 | /* I don't really know what this is. */ | |
1434 | HOWTO (4, /* type */ | |
1435 | 1, /* rightshift */ | |
1436 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1437 | 32, /* bitsize */ | |
1438 | false, /* pc_relative */ | |
1439 | 0, /* bitpos */ | |
beb1bf64 | 1440 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1441 | 0, /* special_function */ |
1442 | "R_RTB", /* name */ | |
1443 | true, /* partial_inplace */ | |
1444 | 0xffffffff, /* src_mask */ | |
1445 | 0xffffffff, /* dst_mask */ | |
1446 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1447 | |
1448 | /* External TOC relative symbol. */ | |
dc810e39 AM |
1449 | HOWTO (5, /* type */ |
1450 | 0, /* rightshift */ | |
1451 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1452 | 16, /* bitsize */ | |
1453 | false, /* pc_relative */ | |
1454 | 0, /* bitpos */ | |
beb1bf64 | 1455 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1456 | 0, /* special_function */ |
1457 | "R_GL", /* name */ | |
1458 | true, /* partial_inplace */ | |
1459 | 0xffff, /* src_mask */ | |
1460 | 0xffff, /* dst_mask */ | |
1461 | false), /* pcrel_offset */ | |
1462 | ||
1463 | /* Local TOC relative symbol. */ | |
1464 | HOWTO (6, /* type */ | |
1465 | 0, /* rightshift */ | |
1466 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1467 | 16, /* bitsize */ | |
1468 | false, /* pc_relative */ | |
1469 | 0, /* bitpos */ | |
beb1bf64 | 1470 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1471 | 0, /* special_function */ |
1472 | "R_TCL", /* name */ | |
1473 | true, /* partial_inplace */ | |
1474 | 0xffff, /* src_mask */ | |
1475 | 0xffff, /* dst_mask */ | |
1476 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1477 | |
1478 | EMPTY_HOWTO (7), | |
1479 | ||
1480 | /* Non modifiable absolute branch. */ | |
dc810e39 AM |
1481 | HOWTO (8, /* type */ |
1482 | 0, /* rightshift */ | |
1483 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1484 | 26, /* bitsize */ | |
1485 | false, /* pc_relative */ | |
1486 | 0, /* bitpos */ | |
beb1bf64 | 1487 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1488 | 0, /* special_function */ |
1489 | "R_BA", /* name */ | |
1490 | true, /* partial_inplace */ | |
1491 | 0x3fffffc, /* src_mask */ | |
1492 | 0x3fffffc, /* dst_mask */ | |
1493 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1494 | |
1495 | EMPTY_HOWTO (9), | |
1496 | ||
1497 | /* Non modifiable relative branch. */ | |
dc810e39 AM |
1498 | HOWTO (0xa, /* type */ |
1499 | 0, /* rightshift */ | |
1500 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1501 | 26, /* bitsize */ | |
1502 | true, /* pc_relative */ | |
1503 | 0, /* bitpos */ | |
beb1bf64 | 1504 | complain_overflow_signed, /* complain_on_overflow */ |
dc810e39 AM |
1505 | 0, /* special_function */ |
1506 | "R_BR", /* name */ | |
1507 | true, /* partial_inplace */ | |
1508 | 0x3fffffc, /* src_mask */ | |
1509 | 0x3fffffc, /* dst_mask */ | |
1510 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1511 | |
1512 | EMPTY_HOWTO (0xb), | |
1513 | ||
1514 | /* Indirect load. */ | |
dc810e39 AM |
1515 | HOWTO (0xc, /* type */ |
1516 | 0, /* rightshift */ | |
1517 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1518 | 16, /* bitsize */ | |
1519 | false, /* pc_relative */ | |
1520 | 0, /* bitpos */ | |
beb1bf64 | 1521 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1522 | 0, /* special_function */ |
1523 | "R_RL", /* name */ | |
1524 | true, /* partial_inplace */ | |
1525 | 0xffff, /* src_mask */ | |
1526 | 0xffff, /* dst_mask */ | |
1527 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1528 | |
1529 | /* Load address. */ | |
dc810e39 AM |
1530 | HOWTO (0xd, /* type */ |
1531 | 0, /* rightshift */ | |
1532 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1533 | 16, /* bitsize */ | |
1534 | false, /* pc_relative */ | |
1535 | 0, /* bitpos */ | |
beb1bf64 | 1536 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1537 | 0, /* special_function */ |
1538 | "R_RLA", /* name */ | |
1539 | true, /* partial_inplace */ | |
1540 | 0xffff, /* src_mask */ | |
1541 | 0xffff, /* dst_mask */ | |
1542 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1543 | |
1544 | EMPTY_HOWTO (0xe), | |
1545 | ||
dc810e39 AM |
1546 | /* Non-relocating reference. */ |
1547 | HOWTO (0xf, /* type */ | |
1548 | 0, /* rightshift */ | |
1549 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1550 | 32, /* bitsize */ | |
1551 | false, /* pc_relative */ | |
1552 | 0, /* bitpos */ | |
beb1bf64 | 1553 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1554 | 0, /* special_function */ |
1555 | "R_REF", /* name */ | |
1556 | false, /* partial_inplace */ | |
1557 | 0, /* src_mask */ | |
1558 | 0, /* dst_mask */ | |
1559 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1560 | |
1561 | EMPTY_HOWTO (0x10), | |
1562 | EMPTY_HOWTO (0x11), | |
1563 | ||
1564 | /* TOC relative indirect load. */ | |
dc810e39 AM |
1565 | HOWTO (0x12, /* type */ |
1566 | 0, /* rightshift */ | |
1567 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1568 | 16, /* bitsize */ | |
1569 | false, /* pc_relative */ | |
1570 | 0, /* bitpos */ | |
beb1bf64 | 1571 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1572 | 0, /* special_function */ |
1573 | "R_TRL", /* name */ | |
1574 | true, /* partial_inplace */ | |
1575 | 0xffff, /* src_mask */ | |
1576 | 0xffff, /* dst_mask */ | |
1577 | false), /* pcrel_offset */ | |
1578 | ||
1579 | /* TOC relative load address. */ | |
1580 | HOWTO (0x13, /* type */ | |
1581 | 0, /* rightshift */ | |
1582 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1583 | 16, /* bitsize */ | |
1584 | false, /* pc_relative */ | |
1585 | 0, /* bitpos */ | |
beb1bf64 | 1586 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1587 | 0, /* special_function */ |
1588 | "R_TRLA", /* name */ | |
1589 | true, /* partial_inplace */ | |
1590 | 0xffff, /* src_mask */ | |
1591 | 0xffff, /* dst_mask */ | |
1592 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1593 | |
1594 | /* Modifiable relative branch. */ | |
dc810e39 AM |
1595 | HOWTO (0x14, /* type */ |
1596 | 1, /* rightshift */ | |
1597 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1598 | 32, /* bitsize */ | |
1599 | false, /* pc_relative */ | |
1600 | 0, /* bitpos */ | |
beb1bf64 | 1601 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1602 | 0, /* special_function */ |
1603 | "R_RRTBI", /* name */ | |
1604 | true, /* partial_inplace */ | |
1605 | 0xffffffff, /* src_mask */ | |
1606 | 0xffffffff, /* dst_mask */ | |
1607 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1608 | |
1609 | /* Modifiable absolute branch. */ | |
dc810e39 AM |
1610 | HOWTO (0x15, /* type */ |
1611 | 1, /* rightshift */ | |
1612 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1613 | 32, /* bitsize */ | |
1614 | false, /* pc_relative */ | |
1615 | 0, /* bitpos */ | |
beb1bf64 | 1616 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1617 | 0, /* special_function */ |
1618 | "R_RRTBA", /* name */ | |
1619 | true, /* partial_inplace */ | |
1620 | 0xffffffff, /* src_mask */ | |
1621 | 0xffffffff, /* dst_mask */ | |
1622 | false), /* pcrel_offset */ | |
1623 | ||
1624 | /* Modifiable call absolute indirect. */ | |
1625 | HOWTO (0x16, /* type */ | |
1626 | 0, /* rightshift */ | |
1627 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1628 | 16, /* bitsize */ | |
1629 | false, /* pc_relative */ | |
1630 | 0, /* bitpos */ | |
beb1bf64 | 1631 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1632 | 0, /* special_function */ |
1633 | "R_CAI", /* name */ | |
1634 | true, /* partial_inplace */ | |
1635 | 0xffff, /* src_mask */ | |
1636 | 0xffff, /* dst_mask */ | |
1637 | false), /* pcrel_offset */ | |
1638 | ||
1639 | /* Modifiable call relative. */ | |
1640 | HOWTO (0x17, /* type */ | |
1641 | 0, /* rightshift */ | |
1642 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1643 | 16, /* bitsize */ | |
1644 | false, /* pc_relative */ | |
1645 | 0, /* bitpos */ | |
beb1bf64 | 1646 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1647 | 0, /* special_function */ |
1648 | "R_CREL", /* name */ | |
1649 | true, /* partial_inplace */ | |
1650 | 0xffff, /* src_mask */ | |
1651 | 0xffff, /* dst_mask */ | |
1652 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1653 | |
1654 | /* Modifiable branch absolute. */ | |
dc810e39 AM |
1655 | HOWTO (0x18, /* type */ |
1656 | 0, /* rightshift */ | |
1657 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1658 | 26, /* bitsize */ | |
1659 | false, /* pc_relative */ | |
1660 | 0, /* bitpos */ | |
beb1bf64 | 1661 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1662 | 0, /* special_function */ |
1663 | "R_RBA", /* name */ | |
1664 | true, /* partial_inplace */ | |
1665 | 0xffff, /* src_mask */ | |
1666 | 0xffff, /* dst_mask */ | |
1667 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1668 | |
1669 | /* Modifiable branch absolute. */ | |
dc810e39 AM |
1670 | HOWTO (0x19, /* type */ |
1671 | 0, /* rightshift */ | |
1672 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1673 | 32, /* bitsize */ | |
1674 | false, /* pc_relative */ | |
1675 | 0, /* bitpos */ | |
beb1bf64 | 1676 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1677 | 0, /* special_function */ |
1678 | "R_RBAC", /* name */ | |
1679 | true, /* partial_inplace */ | |
1680 | 0xffff, /* src_mask */ | |
1681 | 0xffff, /* dst_mask */ | |
1682 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1683 | |
1684 | /* Modifiable branch relative. */ | |
dc810e39 AM |
1685 | HOWTO (0x1a, /* type */ |
1686 | 0, /* rightshift */ | |
1687 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1688 | 26, /* bitsize */ | |
1689 | false, /* pc_relative */ | |
1690 | 0, /* bitpos */ | |
beb1bf64 | 1691 | complain_overflow_signed, /* complain_on_overflow */ |
dc810e39 AM |
1692 | 0, /* special_function */ |
1693 | "R_RBR", /* name */ | |
1694 | true, /* partial_inplace */ | |
1695 | 0xffff, /* src_mask */ | |
1696 | 0xffff, /* dst_mask */ | |
1697 | false), /* pcrel_offset */ | |
beb1bf64 TR |
1698 | |
1699 | /* Modifiable branch absolute. */ | |
dc810e39 AM |
1700 | HOWTO (0x1b, /* type */ |
1701 | 0, /* rightshift */ | |
1702 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1703 | 16, /* bitsize */ | |
1704 | false, /* pc_relative */ | |
1705 | 0, /* bitpos */ | |
beb1bf64 | 1706 | complain_overflow_bitfield, /* complain_on_overflow */ |
dc810e39 AM |
1707 | 0, /* special_function */ |
1708 | "R_RBRC", /* name */ | |
1709 | true, /* partial_inplace */ | |
1710 | 0xffff, /* src_mask */ | |
1711 | 0xffff, /* dst_mask */ | |
1712 | false), /* pcrel_offset */ | |
1713 | ||
1714 | HOWTO (0, /* type */ | |
1715 | 0, /* rightshift */ | |
1716 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
1717 | 64, /* bitsize */ | |
1718 | false, /* pc_relative */ | |
1719 | 0, /* bitpos */ | |
1720 | complain_overflow_bitfield, /* complain_on_overflow */ | |
1721 | 0, /* special_function */ | |
1722 | "R_POS", /* name */ | |
1723 | true, /* partial_inplace */ | |
1724 | MINUS_ONE, /* src_mask */ | |
1725 | MINUS_ONE, /* dst_mask */ | |
1726 | false) /* pcrel_offset */ | |
beb1bf64 TR |
1727 | }; |
1728 | ||
1729 | void | |
1730 | xcoff64_rtype2howto (relent, internal) | |
1731 | arelent *relent; | |
1732 | struct internal_reloc *internal; | |
1733 | { | |
1734 | relent->howto = xcoff64_howto_table + internal->r_type; | |
1735 | ||
1736 | /* Check for relocs we don't know of. */ | |
1737 | if (internal->r_type | |
1738 | >= sizeof (xcoff64_howto_table) / sizeof (xcoff64_howto_table[0])) | |
1739 | abort (); | |
1740 | if (internal->r_type != relent->howto->type) | |
1741 | abort (); | |
1742 | ||
1743 | /* The r_size field of an XCOFF reloc encodes the bitsize of the | |
1744 | relocation, as well as indicating whether it is signed or not. | |
1745 | Doublecheck that the relocation information gathered from the | |
1746 | type matches this information. The bitsize is not significant | |
1747 | for R_REF relocs. */ | |
1748 | if (relent->howto->dst_mask != 0 | |
dc810e39 | 1749 | && (relent->howto->bitsize |
beb1bf64 TR |
1750 | != ((unsigned int) internal->r_size & 0x3f) + 1)) |
1751 | abort (); | |
1752 | #if 0 | |
1753 | if ((internal->r_size & 0x80) != 0 | |
1754 | ? (relent->howto->complain_on_overflow != complain_overflow_signed) | |
1755 | : (relent->howto->complain_on_overflow != complain_overflow_bitfield)) | |
1756 | abort (); | |
1757 | #endif | |
1758 | } | |
1759 | ||
1760 | reloc_howto_type * | |
1761 | xcoff64_reloc_type_lookup (abfd, code) | |
1762 | bfd *abfd ATTRIBUTE_UNUSED; | |
1763 | bfd_reloc_code_real_type code; | |
1764 | { | |
1765 | switch (code) | |
1766 | { | |
1767 | case BFD_RELOC_PPC_B26: | |
1768 | return &xcoff64_howto_table[0xa]; | |
1769 | case BFD_RELOC_PPC_BA26: | |
1770 | return &xcoff64_howto_table[8]; | |
1771 | case BFD_RELOC_PPC_TOC16: | |
1772 | return &xcoff64_howto_table[3]; | |
1773 | case BFD_RELOC_32: | |
1774 | case BFD_RELOC_CTOR: | |
1775 | return &xcoff64_howto_table[0]; | |
1776 | case BFD_RELOC_64: | |
1777 | return &xcoff64_howto_table[0x1c]; | |
1778 | default: | |
1779 | return NULL; | |
1780 | } | |
1781 | } | |
1782 | ||
1783 | ||
1784 | ||
1785 | /* Read in the armap of an XCOFF archive. */ | |
1786 | ||
814fa6ab | 1787 | static boolean |
beb1bf64 TR |
1788 | xcoff64_slurp_armap (abfd) |
1789 | bfd *abfd; | |
1790 | { | |
1791 | file_ptr off; | |
1792 | size_t namlen; | |
dc810e39 | 1793 | bfd_size_type sz, amt; |
beb1bf64 TR |
1794 | bfd_byte *contents, *cend; |
1795 | bfd_vma c, i; | |
1796 | carsym *arsym; | |
1797 | bfd_byte *p; | |
dc810e39 | 1798 | file_ptr pos; |
beb1bf64 TR |
1799 | |
1800 | /* This is for the new format. */ | |
1801 | struct xcoff_ar_hdr_big hdr; | |
1802 | ||
dc810e39 AM |
1803 | if (xcoff_ardata (abfd) == NULL) |
1804 | { | |
1805 | bfd_has_map (abfd) = false; | |
1806 | return true; | |
1807 | } | |
beb1bf64 TR |
1808 | |
1809 | off = strtol (xcoff_ardata_big (abfd)->symoff64, (char **) NULL, 10); | |
dc810e39 AM |
1810 | if (off == 0) |
1811 | { | |
1812 | bfd_has_map (abfd) = false; | |
1813 | return true; | |
1814 | } | |
beb1bf64 TR |
1815 | |
1816 | if (bfd_seek (abfd, off, SEEK_SET) != 0) | |
1817 | return false; | |
1818 | ||
1819 | /* The symbol table starts with a normal archive header. */ | |
dc810e39 AM |
1820 | if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd) |
1821 | != SIZEOF_AR_HDR_BIG) | |
beb1bf64 TR |
1822 | return false; |
1823 | ||
1824 | /* Skip the name (normally empty). */ | |
1825 | namlen = strtol (hdr.namlen, (char **) NULL, 10); | |
dc810e39 AM |
1826 | pos = ((namlen + 1) & ~(size_t) 1) + SXCOFFARFMAG; |
1827 | if (bfd_seek (abfd, pos, SEEK_CUR) != 0) | |
beb1bf64 TR |
1828 | return false; |
1829 | ||
1830 | /* XXX This actually has to be a call to strtoll (at least on 32-bit | |
1831 | machines) since the field width is 20 and there numbers with more | |
1832 | than 32 bits can be represented. */ | |
1833 | sz = strtol (hdr.size, (char **) NULL, 10); | |
1834 | ||
1835 | /* Read in the entire symbol table. */ | |
1836 | contents = (bfd_byte *) bfd_alloc (abfd, sz); | |
1837 | if (contents == NULL) | |
1838 | return false; | |
dc810e39 | 1839 | if (bfd_bread ((PTR) contents, sz, abfd) != sz) |
beb1bf64 TR |
1840 | return false; |
1841 | ||
1842 | /* The symbol table starts with an eight byte count. */ | |
dc810e39 | 1843 | c = H_GET_64 (abfd, contents); |
beb1bf64 | 1844 | |
dc810e39 AM |
1845 | if (c * 8 >= sz) |
1846 | { | |
1847 | bfd_set_error (bfd_error_bad_value); | |
1848 | return false; | |
1849 | } | |
1850 | amt = c; | |
1851 | amt *= sizeof (carsym); | |
1852 | bfd_ardata (abfd)->symdefs = (carsym *) bfd_alloc (abfd, amt); | |
beb1bf64 TR |
1853 | if (bfd_ardata (abfd)->symdefs == NULL) |
1854 | return false; | |
dc810e39 | 1855 | |
beb1bf64 TR |
1856 | /* After the count comes a list of eight byte file offsets. */ |
1857 | for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8; | |
1858 | i < c; | |
1859 | ++i, ++arsym, p += 8) | |
dc810e39 | 1860 | arsym->file_offset = H_GET_64 (abfd, p); |
beb1bf64 TR |
1861 | |
1862 | /* After the file offsets come null terminated symbol names. */ | |
1863 | cend = contents + sz; | |
1864 | for (i = 0, arsym = bfd_ardata (abfd)->symdefs; | |
1865 | i < c; | |
1866 | ++i, ++arsym, p += strlen ((char *) p) + 1) | |
1867 | { | |
1868 | if (p >= cend) | |
1869 | { | |
1870 | bfd_set_error (bfd_error_bad_value); | |
1871 | return false; | |
1872 | } | |
1873 | arsym->name = (char *) p; | |
1874 | } | |
1875 | ||
1876 | bfd_ardata (abfd)->symdef_count = c; | |
1877 | bfd_has_map (abfd) = true; | |
1878 | ||
1879 | return true; | |
1880 | } | |
1881 | ||
1882 | ||
beb1bf64 TR |
1883 | /* See if this is an NEW XCOFF archive. */ |
1884 | ||
814fa6ab | 1885 | static const bfd_target * |
beb1bf64 TR |
1886 | xcoff64_archive_p (abfd) |
1887 | bfd *abfd; | |
1888 | { | |
1889 | char magic[SXCOFFARMAG]; | |
1890 | /* This is the new format. */ | |
1891 | struct xcoff_ar_file_hdr_big hdr; | |
dc810e39 | 1892 | bfd_size_type amt = SXCOFFARMAG; |
beb1bf64 | 1893 | |
dc810e39 AM |
1894 | if (bfd_bread ((PTR) magic, amt, abfd) != amt) |
1895 | { | |
1896 | if (bfd_get_error () != bfd_error_system_call) | |
1897 | bfd_set_error (bfd_error_wrong_format); | |
1898 | return NULL; | |
1899 | } | |
1900 | ||
1901 | if (strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0) | |
1902 | { | |
1903 | bfd_set_error (bfd_error_wrong_format); | |
1904 | return NULL; | |
1905 | } | |
beb1bf64 TR |
1906 | |
1907 | /* We are setting bfd_ardata(abfd) here, but since bfd_ardata | |
1908 | involves a cast, we can't do it as the left operand of | |
1909 | assignment. */ | |
dc810e39 AM |
1910 | amt = sizeof (struct artdata); |
1911 | abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt); | |
beb1bf64 TR |
1912 | |
1913 | if (bfd_ardata (abfd) == (struct artdata *) NULL) | |
1914 | return NULL; | |
1915 | ||
1916 | bfd_ardata (abfd)->cache = NULL; | |
1917 | bfd_ardata (abfd)->archive_head = NULL; | |
1918 | bfd_ardata (abfd)->symdefs = NULL; | |
1919 | bfd_ardata (abfd)->extended_names = NULL; | |
1920 | ||
1921 | /* Copy over the magic string. */ | |
1922 | memcpy (hdr.magic, magic, SXCOFFARMAG); | |
1923 | ||
1924 | /* Now read the rest of the file header. */ | |
dc810e39 AM |
1925 | if (bfd_bread ((PTR) &hdr.memoff, |
1926 | (bfd_size_type) (SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG), | |
1927 | abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG) | |
1928 | { | |
1929 | if (bfd_get_error () != bfd_error_system_call) | |
1930 | bfd_set_error (bfd_error_wrong_format); | |
1931 | return NULL; | |
1932 | } | |
beb1bf64 TR |
1933 | |
1934 | /* XXX This actually has to be a call to strtoll (at least on 32-bit | |
1935 | machines) since the field width is 20 and there numbers with more | |
1936 | than 32 bits can be represented. */ | |
1937 | bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff, | |
1938 | (char **) NULL, 10); | |
1939 | ||
dc810e39 AM |
1940 | amt = SIZEOF_AR_FILE_HDR_BIG; |
1941 | bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt); | |
beb1bf64 TR |
1942 | if (bfd_ardata (abfd)->tdata == NULL) |
1943 | return NULL; | |
dc810e39 | 1944 | |
beb1bf64 TR |
1945 | memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG); |
1946 | ||
dc810e39 AM |
1947 | if (! xcoff64_slurp_armap (abfd)) |
1948 | { | |
1949 | bfd_release (abfd, bfd_ardata (abfd)); | |
1950 | abfd->tdata.aout_ar_data = (struct artdata *) NULL; | |
1951 | return NULL; | |
1952 | } | |
beb1bf64 TR |
1953 | |
1954 | return abfd->xvec; | |
1955 | } | |
1956 | ||
1957 | ||
1958 | /* Open the next element in an XCOFF archive. */ | |
1959 | ||
814fa6ab | 1960 | static bfd * |
beb1bf64 TR |
1961 | xcoff64_openr_next_archived_file (archive, last_file) |
1962 | bfd *archive; | |
1963 | bfd *last_file; | |
1964 | { | |
1965 | file_ptr filestart; | |
1966 | ||
dc810e39 AM |
1967 | if ((xcoff_ardata (archive) == NULL) |
1968 | || ! xcoff_big_format_p (archive)) | |
1969 | { | |
1970 | bfd_set_error (bfd_error_invalid_operation); | |
1971 | return NULL; | |
1972 | } | |
beb1bf64 | 1973 | |
dc810e39 AM |
1974 | if (last_file == NULL) |
1975 | { | |
beb1bf64 | 1976 | filestart = bfd_ardata (archive)->first_file_filepos; |
dc810e39 AM |
1977 | } |
1978 | else | |
1979 | { | |
1980 | /* XXX These actually have to be a calls to strtoll (at least | |
1981 | on 32-bit machines) since the fields's width is 20 and | |
1982 | there numbers with more than 32 bits can be represented. */ | |
1983 | filestart = strtol (arch_xhdr_big (last_file)->nextoff, (char **) NULL, | |
1984 | 10); | |
1985 | } | |
beb1bf64 TR |
1986 | /* XXX These actually have to be calls to strtoll (at least on 32-bit |
1987 | machines) since the fields's width is 20 and there numbers with more | |
1988 | than 32 bits can be represented. */ | |
1989 | if (filestart == 0 | |
1990 | || filestart == strtol (xcoff_ardata_big (archive)->memoff, | |
1991 | (char **) NULL, 10) | |
1992 | || filestart == strtol (xcoff_ardata_big (archive)->symoff, | |
dc810e39 AM |
1993 | (char **) NULL, 10)) |
1994 | { | |
1995 | bfd_set_error (bfd_error_no_more_archived_files); | |
1996 | return NULL; | |
1997 | } | |
beb1bf64 TR |
1998 | |
1999 | return _bfd_get_elt_at_filepos (archive, filestart); | |
2000 | } | |
2001 | ||
2002 | /* We can't use the usual coff_sizeof_headers routine, because AIX | |
2003 | always uses an a.out header. */ | |
2004 | ||
2005 | /*ARGSUSED*/ | |
814fa6ab | 2006 | static int |
beb1bf64 TR |
2007 | xcoff64_sizeof_headers (abfd, reloc) |
2008 | bfd *abfd; | |
2009 | boolean reloc ATTRIBUTE_UNUSED; | |
2010 | { | |
2011 | int size; | |
2012 | ||
dc810e39 | 2013 | size = bfd_coff_filhsz (abfd); |
beb1bf64 | 2014 | |
08da05b0 | 2015 | /* Don't think the small aout header can be used since some of the |
dc810e39 AM |
2016 | old elements have been reordered past the end of the old coff |
2017 | small aout size. */ | |
beb1bf64 TR |
2018 | |
2019 | if (xcoff_data (abfd)->full_aouthdr) | |
dc810e39 | 2020 | size += bfd_coff_aoutsz (abfd); |
beb1bf64 | 2021 | |
dc810e39 | 2022 | size += abfd->section_count * bfd_coff_scnhsz (abfd); |
beb1bf64 TR |
2023 | return size; |
2024 | } | |
2025 | ||
2026 | ||
2027 | ||
2028 | static asection * | |
dc810e39 | 2029 | xcoff64_create_csect_from_smclas (abfd, aux, symbol_name) |
beb1bf64 TR |
2030 | bfd *abfd; |
2031 | union internal_auxent *aux; | |
2032 | const char *symbol_name; | |
2033 | { | |
2034 | asection *return_value = NULL; | |
2035 | ||
dc810e39 AM |
2036 | /* Changes from 32 : |
2037 | .sv == 8, is only for 32 bit programs | |
2038 | .ti == 12 and .tb == 13 are now reserved. */ | |
2039 | static const char *names[19] = | |
2040 | { | |
beb1bf64 TR |
2041 | ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo", |
2042 | NULL, ".bs", ".ds", ".uc", NULL, NULL, NULL, ".tc0", | |
dc810e39 | 2043 | ".td", ".sv64", ".sv3264" |
beb1bf64 TR |
2044 | }; |
2045 | ||
dc810e39 AM |
2046 | if ((19 >= aux->x_csect.x_smclas) |
2047 | && (NULL != names[aux->x_csect.x_smclas])) | |
2048 | { | |
beb1bf64 | 2049 | |
dc810e39 AM |
2050 | return_value = bfd_make_section_anyway |
2051 | (abfd, names[aux->x_csect.x_smclas]); | |
beb1bf64 | 2052 | |
dc810e39 AM |
2053 | } |
2054 | else | |
2055 | { | |
2056 | (*_bfd_error_handler) | |
2057 | (_("%s: symbol `%s' has unrecognized smclas %d"), | |
8f615d07 | 2058 | bfd_archive_filename (abfd), symbol_name, aux->x_csect.x_smclas); |
dc810e39 AM |
2059 | bfd_set_error (bfd_error_bad_value); |
2060 | } | |
beb1bf64 TR |
2061 | |
2062 | return return_value; | |
2063 | } | |
2064 | ||
dc810e39 | 2065 | static boolean |
beb1bf64 | 2066 | xcoff64_is_lineno_count_overflow (abfd, value) |
dc810e39 AM |
2067 | bfd *abfd ATTRIBUTE_UNUSED; |
2068 | bfd_vma value ATTRIBUTE_UNUSED; | |
beb1bf64 TR |
2069 | { |
2070 | return false; | |
2071 | } | |
2072 | ||
dc810e39 | 2073 | static boolean |
beb1bf64 | 2074 | xcoff64_is_reloc_count_overflow (abfd, value) |
dc810e39 AM |
2075 | bfd *abfd ATTRIBUTE_UNUSED; |
2076 | bfd_vma value ATTRIBUTE_UNUSED; | |
beb1bf64 TR |
2077 | { |
2078 | return false; | |
2079 | } | |
2080 | ||
814fa6ab | 2081 | static bfd_vma |
beb1bf64 | 2082 | xcoff64_loader_symbol_offset (abfd, ldhdr) |
dc810e39 AM |
2083 | bfd *abfd ATTRIBUTE_UNUSED; |
2084 | struct internal_ldhdr *ldhdr; | |
beb1bf64 TR |
2085 | { |
2086 | return (ldhdr->l_symoff); | |
2087 | } | |
2088 | ||
814fa6ab | 2089 | static bfd_vma |
beb1bf64 | 2090 | xcoff64_loader_reloc_offset (abfd, ldhdr) |
dc810e39 AM |
2091 | bfd *abfd ATTRIBUTE_UNUSED; |
2092 | struct internal_ldhdr *ldhdr; | |
beb1bf64 TR |
2093 | { |
2094 | return (ldhdr->l_rldoff); | |
2095 | } | |
2096 | ||
2097 | /* The typical dynamic reloc. */ | |
2098 | ||
2099 | static reloc_howto_type xcoff64_dynamic_reloc = | |
dc810e39 AM |
2100 | HOWTO (0, /* type */ |
2101 | 0, /* rightshift */ | |
2102 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
2103 | 64, /* bitsize */ | |
2104 | false, /* pc_relative */ | |
2105 | 0, /* bitpos */ | |
2106 | complain_overflow_bitfield, /* complain_on_overflow */ | |
2107 | 0, /* special_function */ | |
2108 | "R_POS", /* name */ | |
2109 | true, /* partial_inplace */ | |
2110 | MINUS_ONE, /* src_mask */ | |
2111 | MINUS_ONE, /* dst_mask */ | |
2112 | false); /* pcrel_offset */ | |
beb1bf64 TR |
2113 | |
2114 | static unsigned long xcoff64_glink_code[10] = | |
2115 | { | |
2116 | 0xe9820000, /* ld r12,0(r2) */ | |
2117 | 0xf8410028, /* std r2,40(r1) */ | |
2118 | 0xe80c0000, /* ld r0,0(r12) */ | |
2119 | 0xe84c0008, /* ld r0,8(r12) */ | |
2120 | 0x7c0903a6, /* mtctr r0 */ | |
2121 | 0x4e800420, /* bctr */ | |
2122 | 0x00000000, /* start of traceback table */ | |
2123 | 0x000ca000, /* traceback table */ | |
2124 | 0x00000000, /* traceback table */ | |
2125 | 0x00000018, /* ??? */ | |
2126 | }; | |
2127 | ||
dc810e39 | 2128 | static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = |
beb1bf64 TR |
2129 | { |
2130 | { /* COFF backend, defined in libcoff.h */ | |
2131 | _bfd_xcoff64_swap_aux_in, /* _bfd_coff_swap_aux_in */ | |
dc810e39 | 2132 | _bfd_xcoff64_swap_sym_in, /* _bfd_coff_swap_sym_in */ |
beb1bf64 TR |
2133 | _bfd_xcoff64_swap_lineno_in, /* _bfd_coff_swap_lineno_in */ |
2134 | _bfd_xcoff64_swap_aux_out, /* _bfd_swap_aux_out */ | |
2135 | _bfd_xcoff64_swap_sym_out, /* _bfd_swap_sym_out */ | |
2136 | _bfd_xcoff64_swap_lineno_out, /* _bfd_swap_lineno_out */ | |
2137 | coff_swap_reloc_out, /* _bfd_swap_reloc_out */ | |
2138 | coff_swap_filehdr_out, /* _bfd_swap_filehdr_out */ | |
2139 | coff_swap_aouthdr_out, /* _bfd_swap_aouthdr_out */ | |
2140 | coff_swap_scnhdr_out, /* _bfd_swap_scnhdr_out */ | |
2141 | FILHSZ, /* _bfd_filhsz */ | |
2142 | AOUTSZ, /* _bfd_aoutsz */ | |
2143 | SCNHSZ, /* _bfd_scnhsz */ | |
2144 | SYMESZ, /* _bfd_symesz */ | |
2145 | AUXESZ, /* _bfd_auxesz */ | |
2146 | RELSZ, /* _bfd_relsz */ | |
2147 | LINESZ, /* _bfd_linesz */ | |
2148 | FILNMLEN, /* _bfd_filnmlen */ | |
2149 | true, /* _bfd_coff_long_filenames */ | |
2150 | false, /* _bfd_coff_long_section_names */ | |
2151 | (3), /* _bfd_coff_default_section_alignment_power */ | |
2152 | true, /* _bfd_coff_force_symnames_in_strings */ | |
2153 | 4, /* _bfd_coff_debug_string_prefix_length */ | |
2154 | coff_swap_filehdr_in, /* _bfd_coff_swap_filehdr_in */ | |
2155 | coff_swap_aouthdr_in, /* _bfd_swap_aouthdr_in */ | |
2156 | coff_swap_scnhdr_in, /* _bfd_swap_scnhdr_in */ | |
2157 | coff_swap_reloc_in, /* _bfd_reloc_in */ | |
2158 | coff_bad_format_hook, /* _bfd_bad_format_hook */ | |
2159 | coff_set_arch_mach_hook, /* _bfd_set_arch_mach_hook */ | |
2160 | coff_mkobject_hook, /* _bfd_mkobject_hook */ | |
2161 | styp_to_sec_flags, /* _bfd_syp_to_sec_flags */ | |
2162 | coff_set_alignment_hook, /* _bfd_set_alignment_hook */ | |
2163 | coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */ | |
2164 | symname_in_debug_hook, /* _coff_symname_in_debug_hook */ | |
2165 | coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */ | |
2166 | coff_print_aux, /* bfd_coff_print_aux */ | |
2167 | dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */ | |
2168 | dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */ | |
2169 | NULL, /* bfd_coff_sym_is_global */ | |
dc810e39 | 2170 | /* _bfd_coff_compute_section_file_positions */ |
beb1bf64 TR |
2171 | coff_compute_section_file_positions, |
2172 | NULL , /* _bfd_coff_start_final_link */ | |
2173 | xcoff64_ppc_relocate_section, /* _bfd_coff_relocate_section */ | |
2174 | coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */ | |
2175 | NULL , /* _bfd_coff_addust_symndx */ | |
2176 | _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */ | |
2177 | coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */ | |
2178 | coff_final_link_postscript /* _bfd_coff_final_link_postscript */ | |
2179 | }, | |
2180 | ||
2181 | 0x01EF, /* magic number */ | |
2182 | bfd_arch_powerpc, /* architecture */ | |
2183 | bfd_mach_ppc_620, /* machine */ | |
2184 | ||
2185 | /* function pointers to xcoff specific swap routines */ | |
2186 | xcoff64_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */ | |
2187 | xcoff64_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */ | |
2188 | xcoff64_swap_ldsym_in, /* _xcoff_swap_ldsym_in */ | |
2189 | xcoff64_swap_ldsym_out, /* _xcoff_swap_ldsym_out */ | |
2190 | xcoff64_swap_ldrel_in, /* _xcoff_swap_ldrel_in */ | |
2191 | xcoff64_swap_ldrel_out, /* _xcoff_swap_ldrel_out */ | |
2192 | ||
2193 | /* sizes */ | |
2194 | LDHDRSZ, /* _xcoff_ldhdrsz */ | |
2195 | LDSYMSZ, /* _xcoff_ldsymsz */ | |
2196 | LDRELSZ, /* _xcoff_ldrelsz */ | |
2197 | 24, /* _xcoff_function_descriptor_size */ | |
2198 | 0, /* _xcoff_small_aout_header_size */ | |
2199 | /* versions */ | |
2200 | 2, /* _xcoff_ldhdr_version */ | |
2201 | ||
2202 | /* xcoff vs xcoff64 putting symbol names */ | |
2203 | _bfd_xcoff64_put_symbol_name, /* _xcoff_put_symbol_name */ | |
2204 | _bfd_xcoff64_put_ldsymbol_name, /* _xcoff_put_ldsymbol_name */ | |
2205 | ||
2206 | /* dynamic reloc howto */ | |
2207 | &xcoff64_dynamic_reloc, | |
2208 | ||
dc810e39 | 2209 | xcoff64_create_csect_from_smclas, |
beb1bf64 TR |
2210 | |
2211 | /* lineno and reloc count overflow */ | |
2212 | xcoff64_is_lineno_count_overflow, | |
2213 | xcoff64_is_reloc_count_overflow, | |
dc810e39 | 2214 | |
beb1bf64 TR |
2215 | xcoff64_loader_symbol_offset, |
2216 | xcoff64_loader_reloc_offset, | |
2217 | ||
2218 | /* glink */ | |
2219 | &xcoff64_glink_code[0], | |
2220 | 40, /* _xcoff_glink_size */ | |
2221 | ||
2222 | }; | |
2223 | ||
2224 | /* The transfer vector that leads the outside world to all of the above. */ | |
2225 | const bfd_target rs6000coff64_vec = | |
2226 | { | |
2227 | "aixcoff64-rs6000", | |
2228 | bfd_target_xcoff_flavour, | |
2229 | BFD_ENDIAN_BIG, /* data byte order is big */ | |
2230 | BFD_ENDIAN_BIG, /* header byte order is big */ | |
2231 | ||
2232 | (HAS_RELOC | EXEC_P | /* object flags */ | |
2233 | HAS_LINENO | HAS_DEBUG | DYNAMIC | | |
2234 | HAS_SYMS | HAS_LOCALS | WP_TEXT), | |
2235 | ||
2236 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
2237 | 0, /* leading char */ | |
2238 | '/', /* ar_pad_char */ | |
2239 | 15, /* ar_max_namelen??? FIXMEmgo */ | |
2240 | ||
dc810e39 | 2241 | /* data */ |
beb1bf64 TR |
2242 | bfd_getb64, /* bfd_getx64 */ |
2243 | bfd_getb_signed_64, /* bfd_getx_signed_64 */ | |
2244 | bfd_putb64, /* bfd_putx64 */ | |
2245 | bfd_getb32, /* bfd_getx32 */ | |
2246 | bfd_getb_signed_32, /* bfd_getx_signed_32 */ | |
2247 | bfd_putb32, /* bfd_putx32 */ | |
2248 | bfd_getb16, /* bfd_getx16 */ | |
2249 | bfd_getb_signed_16, /* bfd_getx_signed_16 */ | |
dc810e39 | 2250 | bfd_putb16, /* bfd_putx16 */ |
beb1bf64 | 2251 | |
dc810e39 | 2252 | /* hdrs */ |
beb1bf64 TR |
2253 | bfd_getb64, /* bfd_h_getx64 */ |
2254 | bfd_getb_signed_64, /* bfd_h_getx_signed_64 */ | |
2255 | bfd_putb64, /* bfd_h_putx64 */ | |
2256 | bfd_getb32, /* bfd_h_getx32 */ | |
2257 | bfd_getb_signed_32, /* bfd_h_getx_signed_32 */ | |
2258 | bfd_putb32, /* bfd_h_putx32 */ | |
2259 | bfd_getb16, /* bfd_h_getx16 */ | |
2260 | bfd_getb_signed_16, /* bfd_h_getx_signed_16 */ | |
2261 | bfd_putb16, /* bfd_h_putx16 */ | |
dc810e39 | 2262 | |
beb1bf64 | 2263 | { /* bfd_check_format */ |
dc810e39 AM |
2264 | _bfd_dummy_target, |
2265 | coff_object_p, | |
2266 | xcoff64_archive_p, | |
2267 | CORE_FILE_P | |
beb1bf64 | 2268 | }, |
dc810e39 | 2269 | |
beb1bf64 | 2270 | { /* bfd_set_format */ |
dc810e39 | 2271 | bfd_false, |
beb1bf64 | 2272 | coff_mkobject, |
dc810e39 | 2273 | _bfd_generic_mkarchive, |
beb1bf64 TR |
2274 | bfd_false |
2275 | }, | |
dc810e39 | 2276 | |
beb1bf64 | 2277 | {/* bfd_write_contents */ |
dc810e39 | 2278 | bfd_false, |
beb1bf64 | 2279 | xcoff64_write_object_contents, |
dc810e39 | 2280 | _bfd_xcoff_write_archive_contents, |
beb1bf64 TR |
2281 | bfd_false |
2282 | }, | |
dc810e39 | 2283 | |
beb1bf64 TR |
2284 | /* Generic */ |
2285 | bfd_true, /* _close_and_cleanup */ | |
2286 | bfd_true, /* _bfd_free_cached_info */ | |
2287 | coff_new_section_hook, /* _new_section_hook */ | |
2288 | _bfd_generic_get_section_contents, /* _bfd_get_section_contents */ | |
dc810e39 AM |
2289 | /* _bfd_get_section_contents_in_window */ |
2290 | _bfd_generic_get_section_contents_in_window, | |
beb1bf64 TR |
2291 | |
2292 | /* Copy */ | |
2293 | _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */ | |
dc810e39 | 2294 | /* _bfd_merge_private_bfd_data */ |
beb1bf64 | 2295 | ((boolean (*) (bfd *, bfd *)) bfd_true), |
dc810e39 | 2296 | /* _bfd_copy_pivate_section_data */ |
beb1bf64 | 2297 | ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), |
dc810e39 | 2298 | /* _bfd_copy_private_symbol_data */ |
beb1bf64 TR |
2299 | ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), |
2300 | ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */ | |
2301 | ((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */ | |
2302 | ||
2303 | /* Core */ | |
b55039f4 L |
2304 | coff_core_file_failing_command, /* _core_file_failing_command */ |
2305 | coff_core_file_failing_signal, /* _core_file_failing_signal */ | |
dc810e39 AM |
2306 | /* _core_file_matches_executable_p */ |
2307 | coff_core_file_matches_executable_p, | |
beb1bf64 TR |
2308 | |
2309 | /* Archive */ | |
2310 | xcoff64_slurp_armap, /* _slurp_armap */ | |
dc810e39 AM |
2311 | /* XCOFF archives do not have |
2312 | anything which corresponds to | |
2313 | an extended name table. */ | |
beb1bf64 | 2314 | bfd_false, /* _slurp_extended_name_table */ |
dc810e39 | 2315 | /* _construct_extended_name_table */ |
beb1bf64 TR |
2316 | ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false), |
2317 | bfd_dont_truncate_arname, /* _truncate_arname */ | |
2318 | _bfd_xcoff_write_armap, /* _write_armap */ | |
2319 | _bfd_xcoff_read_ar_hdr, /* _read_ar_hdr */ | |
2320 | xcoff64_openr_next_archived_file, /* _openr_next_archived_file */ | |
2321 | _bfd_generic_get_elt_at_index, /* _get_elt_at_index */ | |
2322 | _bfd_xcoff_generic_stat_arch_elt, /* _generic_dtat_arch_elt */ | |
dc810e39 AM |
2323 | /* XCOFF archives do not have |
2324 | a timestamp. */ | |
beb1bf64 TR |
2325 | bfd_true, /* _update_armap_timestamp */ |
2326 | ||
2327 | /* Symbols */ | |
2328 | coff_get_symtab_upper_bound, /* _get_symtab_upper_bound */ | |
2329 | coff_get_symtab, /* _get_symtab */ | |
2330 | coff_make_empty_symbol, /* _make_empty_symbol */ | |
2331 | coff_print_symbol, /* _print_symbol */ | |
2332 | coff_get_symbol_info, /* _get_symbol_info */ | |
2333 | _bfd_xcoff_is_local_label_name, /* _bfd_is_local_label_name */ | |
2334 | coff_get_lineno, /* _get_lineno */ | |
2335 | coff_find_nearest_line, /* _find_nearest_line */ | |
2336 | coff_bfd_make_debug_symbol, /* _bfd_make_debug_symbol */ | |
2337 | _bfd_generic_read_minisymbols, /* _read_minisymbols */ | |
2338 | _bfd_generic_minisymbol_to_symbol, /* _minsymbol_to_symbol */ | |
2339 | ||
2340 | /* Reloc */ | |
2341 | coff_get_reloc_upper_bound, /* _get_reloc_upper_bound */ | |
2342 | coff_canonicalize_reloc, /* _cononicalize_reloc */ | |
2343 | xcoff64_reloc_type_lookup, /* _bfd_reloc_type_lookup */ | |
2344 | ||
2345 | /* Write */ | |
2346 | coff_set_arch_mach, /* _set_arch_mach */ | |
2347 | coff_set_section_contents, /* _set_section_contents */ | |
2348 | ||
2349 | /* Link */ | |
2350 | xcoff64_sizeof_headers, /* _sizeof_headers */ | |
dc810e39 | 2351 | /* _bfd_get_relocated_section_contents */ |
beb1bf64 TR |
2352 | bfd_generic_get_relocated_section_contents, |
2353 | bfd_generic_relax_section, /* _bfd_relax_section */ | |
2354 | _bfd_xcoff_bfd_link_hash_table_create, /* _bfd_link_hash_table_create */ | |
2355 | _bfd_xcoff_bfd_link_add_symbols, /* _bfd_link_add_symbols */ | |
2356 | _bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */ | |
2357 | _bfd_generic_link_split_section, /* _bfd_link_split_section */ | |
2358 | bfd_generic_gc_sections, /* _bfd_gc_sections */ | |
2359 | bfd_generic_merge_sections, /* _bfd_merge_sections */ | |
2360 | ||
2361 | /* Dynamic */ | |
dc810e39 AM |
2362 | /* _get_dynamic_symtab_upper_bound */ |
2363 | _bfd_xcoff_get_dynamic_symtab_upper_bound, | |
beb1bf64 TR |
2364 | _bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */ |
2365 | _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */ | |
2366 | _bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */ | |
2367 | ||
2368 | /* Opposite endian version, none exists */ | |
2369 | NULL, | |
dc810e39 | 2370 | |
beb1bf64 TR |
2371 | /* back end data */ |
2372 | (void *) &bfd_xcoff_backend_data, | |
2373 | }; |